pi-agent-ide 0.9.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +5 -3
- package/dist/chunk-2EY3LEZ7.js +1 -0
- package/dist/chunk-2QCE7GOV.js +1 -0
- package/dist/chunk-3V3OQO5S.js +118 -0
- package/dist/chunk-45EJ4762.js +33 -0
- package/dist/chunk-4AEYLVSR.js +5 -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-AB6RSWMB.js +23 -0
- package/dist/chunk-AKUBFJAR.js +1 -0
- package/dist/chunk-ASVMQMPX.js +10 -0
- package/dist/chunk-BW3XONMZ.js +1 -0
- package/dist/{chunk-R2U5WXYR.js → chunk-D23NS4VV.js} +1 -1
- package/dist/chunk-DSB6A5P5.js +53 -0
- package/dist/chunk-E4V4VNRM.js +3 -0
- package/dist/chunk-E6G3UVS7.js +1 -0
- package/dist/chunk-E7JBYW43.js +1 -0
- package/dist/chunk-FVWMI4GP.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-HUICUICD.js +3 -0
- 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-KJ6HZC6L.js +7 -0
- package/dist/chunk-LG22ELG4.js +2 -0
- package/dist/chunk-LRAMFOUP.js +37 -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-NGWQRV25.js +13 -0
- package/dist/chunk-NKI4TZSS.js +2 -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-QC6VFZSB.js +2 -0
- 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-R7576HPO.js +25 -0
- package/dist/{chunk-B5UJCNQU.js → chunk-RNDSWVJF.js} +1 -1
- package/dist/chunk-S4GTWS2J.js +6 -0
- package/dist/chunk-SF44YQCB.js +2 -0
- package/dist/chunk-SJQGFUXR.js +6 -0
- package/dist/chunk-SKHD2QIT.js +1 -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-UHGHVYAW.js +4 -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-WZ7MNISG.js +5 -0
- package/dist/chunk-X4CU7CMR.js +19 -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-YSGPCH52.js +18 -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/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 +66 -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 +211 -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/line-breaks.ts +16 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +60 -16
- 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 +44 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
- 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 +346 -164
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +376 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +6 -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 +383 -92
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +305 -77
- 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 +96 -25
- 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 +92 -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 +96 -25
- 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 +66 -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 +211 -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/line-breaks.ts +16 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +60 -16
- 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 +44 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
- 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 +346 -164
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +376 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +6 -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 +383 -92
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +305 -77
- 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
package/dist/chunk-BMSAVDRD.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{a as $t,c as Ut}from"./chunk-72FL5FHZ.js";import{b as Mt,c as Ot,g as Nt,j as jt,p as xe}from"./chunk-S3T5NOSL.js";import{a as At}from"./chunk-BXGMMZT3.js";import{f as gt,g as mt}from"./chunk-JXULBI4S.js";import{a as Ce,b as _t,c as Rt}from"./chunk-HFCHOFLV.js";import{b as yt,c as wt,d as Ee}from"./chunk-5AROEOJB.js";import{a as vt}from"./chunk-47SPPIXK.js";import{a as ht,b as ft}from"./chunk-VAXLSPPU.js";import{a as Lt}from"./chunk-2YO6RVX4.js";import{b as bt,c as St}from"./chunk-MLFJU2US.js";import{a as de,e as pt}from"./chunk-PS2B6THP.js";import{a as Pt}from"./chunk-YZTVC7ME.js";import{c as lt,d as dt,f as ut}from"./chunk-VDSSAP6Y.js";import{a as at}from"./chunk-2DSY4U73.js";import{a as ot,b as it}from"./chunk-H6FEBUAP.js";import{K as st,M as K,m as rt,n as nt}from"./chunk-SIYPD5MM.js";import{d as Et,f as Ct}from"./chunk-YNOR4LIE.js";import{h as It}from"./chunk-JMQ67UNK.js";import{a as V,b as N,c as xt,d as Y}from"./chunk-T4FTT3U4.js";import{m as ct}from"./chunk-S7E2D5K7.js";import{a as T}from"./chunk-ZC65Z3CK.js";import{a as Dt}from"./chunk-ZAWRSA7N.js";import{a as kt,b as Tt}from"./chunk-OFILFO6D.js";import{a}from"./chunk-EI7MMDWY.js";import ts from"node:path";var Z=[{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"]}]}}},P("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}}),P("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"]}}},P("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"]),P("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),P("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),P("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),P("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/"),P("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"]),P("basedpyright",["python"],["basedpyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),P("pyright",["python"],["pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["pyright-langserver","--stdio"],"https://microsoft.github.io/pyright/",["pyright"]),P("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),P("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),P("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),P("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),P("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"),P("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),P("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),P("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),P("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),P("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),P("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:{}}),P("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"),P("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"),P("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),P("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),P("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),P("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"),P("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"),P("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"),P("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),P("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"),P("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),P("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),P("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 P(n,e,t,r,s,o,i,l,c,d){return{id:n,name:n,kind:"lsp",languages:e,executables:t,configFiles:r,documentation:i,...l&&{dependencies:l},lsp:{command:o,rootMarkers:r,languageIds:s,...c&&{fileNames:c},...d&&{settings:d}}}}a(P,"recipe");var ue="lsp.idle-timeout";function Ie(n){let e=n.trim(),t=e===""?10:Number(e);if(!Number.isFinite(t)||t<=0)throw new Error(`Invalid ${ue} setting "${n}": use a positive number of minutes.`);return Math.round(t*6e4)}a(Ie,"lspIdleTimeoutMs");import{readFile as qt}from"node:fs/promises";import{URI as Ft}from"vscode-uri";var se={Error:1,Warning:2,Information:3,Hint:4};var Wt={command:"typescript.tsserverRequest",async request(n,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let o=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:n.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!ke(o)||o.success!==!0||!Array.isArray(o.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return o.body.map(kr)}))).flat()}};function pe(n){return n.supportsCommand(Wt.command)?Wt:void 0}a(pe,"completedDiagnosticAdapter");function kr(n){if(!ke(n)||typeof n.message!="string"||typeof n.code!="number"&&typeof n.code!="string"||!ke(n.startLocation)||!Number.isInteger(n.startLocation.line)||!Number.isInteger(n.startLocation.offset)||Number(n.startLocation.line)<1||Number(n.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(n.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(n.code),message:n.message,line:Number(n.startLocation.line),column:Number(n.startLocation.offset),severity:n.category==="error"?"error":n.category==="warning"?"warning":n.category==="suggestion"?"hint":"info"}}a(kr,"convertTypeScriptDiagnostic");function ke(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}a(ke,"isRecord");function ge(n){return n!==null&&typeof n=="object"&&"code"in n&&n.code===-32601}a(ge,"isMethodNotFound");async function oe(n,e,t,r={}){let s=new AbortController,o=AbortSignal.any([s.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>s.abort(new Error(`[lsp] ${n.serverId}: diagnostics timed out for ${e}`)),n.timeoutMs);try{return await Tr(n,e,t,r.content,o)}finally{clearTimeout(i)}}a(oe,"requestDiagnostics");async function Tr(n,e,t,r,s){if(s.throwIfAborted(),n.diagnosticMode!=="push"){let c=n.documentVersion(e),d=n.pulledReport(e);try{let g=await n.sendRequest("textDocument/diagnostic",{textDocument:{uri:e},...d!==void 0&&{previousResultId:d.resultId}},s),m=g.kind==="full"&&Array.isArray(g.items)?g.items:g.kind==="unchanged"&&d!==void 0&&g.resultId===d.resultId?[...d.diagnostics]:void 0;if(m===void 0)throw new Error("Invalid full diagnostic report");if(n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return n.setDiagnosticMode("pull"),c!==void 0&&typeof g.resultId=="string"&&n.rememberPulledReport(e,{version:c,resultId:g.resultId,diagnostics:m}),Ht(m,!1,!0)}catch(g){if(!ge(g))throw g;n.setDiagnosticMode("push")}}let o=pe(n);if(o){n.documentVersion(e)===void 0&&n.syncDocument(e,r??await qt(Ft.parse(e).fsPath,"utf8"),t??"plaintext");let c=n.documentVersion(e),d=await o.request(n,e,s);if(s.throwIfAborted(),n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return{diagnostics:d,syntaxErrors:[],otherDiagnostics:d,unversioned:!1,complete:!0}}s.throwIfAborted();let i=n.documentVersion(e)!==void 0,l=i?void 0:r??await qt(Ft.parse(e).fsPath,"utf8");s.throwIfAborted(),n.beginDiagnosticRequest(e);try{return await new Promise((c,d)=>{let g=n.documentVersion(e)??1,m=a(h=>{let u=h;u.uri!==e||!Array.isArray(u.diagnostics)||u.version!==void 0&&u.version!==g||n.documentVersion(e)===g&&(f(),c(Ht(u.diagnostics,u.version===void 0)))},"receive"),y=n.onNotification("textDocument/publishDiagnostics",m),p=a(()=>{f(),d(s.reason)},"onAbort");function f(){y(),s.removeEventListener("abort",p)}a(f,"cleanup"),s.addEventListener("abort",p,{once:!0});try{i||n.syncDocument(e,l??"",t??"plaintext");let h=n.diagnosticPublication(e);h&&m({uri:e,...h})}catch(h){f(),d(h)}})}finally{n.endDiagnosticRequest(e)}}a(Tr,"requestCurrentDiagnostics");function Te(n){return{code:String(n.code??"LSP"),message:n.message,line:n.range.start.line+1,column:n.range.start.character+1,severity:n.severity===se.Warning?"warning":n.severity===se.Information?"info":n.severity===se.Hint?"hint":"error"}}a(Te,"toDiagnostic");function Ht(n,e,t=!1){let r=n.map(Te);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:t}}a(Ht,"classify");function Vt(n,e=(t,r)=>Promise.resolve({cwd:r,external:!1})){return{id:"lsp",async diagnose(t,r){let s=await e(t,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 n(s.cwd,s.external,r.signal);r.signal.throwIfAborted();let i=await o.getOrStart(t,s.cwd,"diagnostics",r.signal);if(r.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let l=i.toUri(t),c=o.languageId(t),d=i.retainDocument(l);try{i.syncDocument(l,r.content,c,!0)}catch(S){throw d(),S}let g=i.documentVersion(l),m={active:!0,queued:!1},y=a(()=>!r.signal.aborted&&i.documentVersion(l)===g,"current"),p=a(async()=>(await i.waitUntilLoaded(r.signal),oe(i,l,c,{signal:r.signal,content:r.content})),"request"),f,h,u=a(async()=>{if(f=void 0,h=void 0,!(m.active||!m.queued||!y())){m.active=!0,m.queued=!1;try{let S=await p();y()&&r.publish(zt(S,i.commandName))}catch(S){y()&&r.publish({status:"unavailable",diagnostics:[],reason:S instanceof Error?S.message:String(S),source:i.commandName})}finally{m.active=!1,w()}}},"pullAgain"),w=a(()=>{if(m.active||!m.queued||!y())return;let S=Date.now();h??=S,clearTimeout(f),f=setTimeout(()=>void u(),Math.max(0,Math.min(Dr,h+Ar-S)))},"schedule"),b=a(()=>{m.queued=!0,w()},"refresh"),R=i.onNotification("workspace/diagnostic/refresh",()=>{y()&&i.diagnosticMode==="pull"&&b()}),C=o.onPushDiagnostics(S=>{!y()||S.uri!==l||S.serverId!==i.serverId||S.cwd!==s.cwd||S.version!==void 0&&S.version!==g||(i.diagnosticMode==="pull"||pe(i)?b():r.publish({status:"snapshot",diagnostics:S.diagnostics,source:i.commandName,reason:Gt(S.version===void 0)}))}),L=a(()=>{clearTimeout(f),C(),R()},"unsubscribe");r.signal.addEventListener("abort",L,{once:!0});try{let S=await p();return g=i.documentVersion(l),zt(S,i.commandName)}catch(S){throw m.queued=!1,L(),r.signal.removeEventListener("abort",L),S}finally{d(),m.active=!1,w()}}}}a(Vt,"createLspDiagnosticSource");var Dr=750,Ar=3e3;function Gt(n){return`Latest push snapshot; completion is unknown${n?"; language server omitted the document version":""}`}a(Gt,"snapshotReason");function zt(n,e){return n.complete?{status:"ready",diagnostics:n.diagnostics,source:e}:{status:"snapshot",diagnostics:n.diagnostics,reason:Gt(n.unversioned),source:e}}a(zt,"toReport");import{URI as Rn}from"vscode-uri";import dn from"node:path";import un from"cross-spawn";import{createMessageConnection as pn,CancellationTokenSource as gn,ResponseError as mn,StreamMessageReader as hn}from"vscode-jsonrpc/node";import{URI as rr}from"vscode-uri";import{watch as Bt}from"node:fs";import{readdir as Mr,stat as Jt}from"node:fs/promises";import I from"node:path";import{URI as De}from"vscode-uri";var Ne=3,ie=class{static{a(this,"LspFileWatchers")}#e=new Map;#t;#n=!1;#r;#s;#o;constructor(e,t,r){this.#r=I.resolve(e),this.#s=t,this.#o=r}async register(e,t){if(this.#n)throw new Error("Language server file watchers are disposed");let r=[];for(let s of t){let o=s.globPattern,i=typeof o=="string"?this.#r:I.resolve(De.parse(typeof o.baseUri=="string"?o.baseUri:o.baseUri.uri).fsPath);!me(i,this.#r)&&!me(this.#r,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.#n=!0,this.#e.clear(),this.#i()}#a(){if(this.#t)return this.#t.ready;let e=new Oe(this.#r,(t,r)=>this.#c(e,t,r),t=>{this.#t===e&&this.#o(t)});return this.#t=e,e.ready}#i(){[...this.#e.values()].some(e=>e.length>0)||(this.#t?.close(),this.#t=void 0)}#c(e,t,r){let s=a(o=>[...this.#e.values()].some(i=>i.some(l=>(l.kind&1<<o-1)!==0&&Or(l,r))),"matching");!s(1)&&!s(2)&&!s(3)||Jt(r).then(o=>{if(this.#t!==e||o.isDirectory())return;let i=t==="rename"?1:2;s(i)&&this.#s({uri:De.file(r).toString(),type:i})},o=>{this.#t===e&&(o.code!=="ENOENT"?this.#o(o):s(3)&&this.#s({uri:De.file(r).toString(),type:3}))})}};function Or(n,e){return I.isAbsolute(n.expression)?I.matchesGlob(e,n.expression):me(e,n.base)?I.matchesGlob(I.relative(n.base,e),n.expression):!1}a(Or,"matches");function me(n,e){return n===e||n.startsWith(e.endsWith(I.sep)?e:e+I.sep)}a(me,"within");var Ae=new Set([".git"]),Me=new Set(["node_modules"]),Oe=class{static{a(this,"TreeWatcher")}#e=new Map;#t;#n=!1;#r;#s;ready=Promise.resolve();constructor(e,t,r){if(this.#r=t,this.#s=r,process.platform==="linux"){this.ready=this.#o(e);return}let s=Bt(e,{recursive:!0},(o,i)=>{if(!i)return;let l=I.join(e,i);Nr(I.relative(e,l))&&this.#r(o,l)});s.on("error",o=>this.#s(o)),this.#t=s}close(){this.#n=!0,this.#t?.close();for(let e of this.#e.values())e.close();this.#e.clear()}async#o(e){if(this.#n||this.#e.has(e))return;let t;try{t=Bt(e,(s,o)=>{o&&this.#a(s,I.join(e,o))})}catch(s){this.#i(s);return}if(t.on("error",s=>{t.close(),this.#e.get(e)===t&&this.#e.delete(e),this.#i(s)}),this.#e.set(e,t),Me.has(I.basename(e)))return;let r;try{r=await Mr(e,{withFileTypes:!0})}catch(s){this.#i(s);return}for(let s of r)s.isDirectory()&&!Ae.has(s.name)&&await this.#o(I.join(e,s.name))}#a(e,t){if(this.#n||(this.#r(e,t),e!=="rename"))return;let r=I.basename(I.dirname(t));Ae.has(I.basename(t))||Me.has(r)||Jt(t).then(s=>{s.isDirectory()&&this.#o(t)},()=>{for(let[s,o]of this.#e)me(s,t)&&(o.close(),this.#e.delete(s))})}#i(e){let t=e.code;this.#n||t==="ENOENT"||t==="EACCES"||t==="EPERM"||this.#s(e instanceof Error?e:new Error(String(e)))}};function Nr(n){let e=n.split(I.sep);return!e.some((t,r)=>Ae.has(t)||Me.has(t)&&r<e.length-2)}a(Nr,"included");function Xt(n,e){return e.map(t=>{let r=n??null;for(let s of t.section?.split(".").filter(Boolean)??[])r=typeof r=="object"&&r!==null?r[s]??null:null;return r})}a(Xt,"configurationItems");import{spawn as jr}from"node:child_process";import{closeSync as $r,openSync as Ur,renameSync as Wr,statSync as qr}from"node:fs";import{createHash as Fr}from"node:crypto";import{lstat as Hr,mkdir as zr}from"node:fs/promises";import Vr from"node:net";import he from"node:os";import je from"node:path";import{PassThrough as Qt}from"node:stream";import{fileURLToPath as Gr}from"node:url";var Kt=10*6e4,Br=Gr(new URL("shared-server-host.mjs",new URL("../src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts",import.meta.url).href)),Yt=1e4,Jr=25,fe=class{static{a(this,"LspSharedServers")}_directory;constructor(e={}){this._directory=e.directory??je.join(he.tmpdir(),`pi-agent-ide-lsp-${he.userInfo().uid}`)}async attach(e){let t=Xr(e),r=await this._socketPath(t),s=await er(r,e.signal);if(!s){let o=Qr(r,t,this._directory);s=await tn(r,o,e.signal)}try{let o=await rn(s,{protocol:Ne,key:t,command:e.command,cwd:e.cwd,env:e.env,settings:e.settings,initialize:e.initialize,lingerMs:e.lingerMs,timeoutMs:e.timeoutMs},e.timeoutMs+Yt,e.signal);if(typeof o.pid!="number")throw new Error(typeof o.error=="string"?o.error:"Shared language server did not attach");return nn(s,o.pid)}catch(o){throw s.destroy(),o}}async _socketPath(e){if(await zr(this._directory,{recursive:!0,mode:448}),process.platform==="win32")return`\\\\.\\pipe\\pi-agent-ide-lsp-${Zt(he.userInfo().username)}-${e}`;let t=await Hr(this._directory);if(!t.isDirectory()||t.uid!==he.userInfo().uid||(t.mode&63)!==0)throw new Error(`Shared language server directory is not private: ${this._directory}`);return je.join(this._directory,`${e}.sock`)}};function Xr(n){return Zt(JSON.stringify([Ne,n.serverId,n.command,n.configuredEnv,n.initialize.rootUri,n.initialize.initializationOptions??null,n.settings??null]))}a(Xr,"sharedServerKey");function Zt(n){return Fr("sha256").update(n).digest("hex").slice(0,24)}a(Zt,"hash");function Qr(n,e,t){let r=process.versions.bun||!en()?process.execPath:"node",s=je.join(t,`${e}.log`);Kr(s);let o=Ur(s,"w",384);try{let i=jr(r,[Br,n,e,s],{cwd:t,detached:!0,env:Yr(),stdio:["ignore","ignore",o],windowsHide:!0});return i.unref(),i}finally{$r(o)}}a(Qr,"startHost");function Kr(n){try{let{mtimeMs:e,size:t}=qr(n);t>0&&Wr(n,n.replace(/\.log$/u,`.${String(Math.round(e))}.log`))}catch{}}a(Kr,"keepFailureLog");function Yr(){let n={};for(let e of Zr){let t=process.env[e];t!==void 0&&(n[e]=t)}return process.versions.bun&&(n.BUN_BE_BUN="1"),n}a(Yr,"hostEnvironment");var Zr=["PATH","Path","HOME","USERPROFILE","TMPDIR","TMP","TEMP","SystemRoot","LANG"];function en(){return process.getBuiltinModule("node:sea")?.isSea?.()??!1}a(en,"singleExecutable");function er(n,e){return e?.throwIfAborted(),new Promise((t,r)=>{let s=Vr.connect(n);s.once("connect",()=>{s.removeAllListeners("error"),s.on("error",()=>{}),t(s)}),s.once("error",o=>{s.destroy(),o.code==="ENOENT"||o.code==="ECONNREFUSED"?t(void 0):r(o)})})}a(er,"connect");async function tn(n,e,t){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()+Yt;for(;;){if(r)throw r;let o=await er(n,t);if(o)return o;if(Date.now()>s)throw new Error("Shared language server host did not start");await new Promise(i=>setTimeout(i,Jr))}}a(tn,"waitForHost");function rn(n,e,t,r){return new Promise((s,o)=>{let i=Buffer.alloc(0),l=a(y=>{i=Buffer.concat([i,y]);let p=i.indexOf(10);if(p!==-1){m(),n.pause(),p+1<i.length&&n.unshift(i.subarray(p+1));try{s(JSON.parse(i.subarray(0,p).toString("utf8")))}catch(f){o(f)}}},"onData"),c=a(()=>{m(),o(new Error("Shared language server host closed the connection"))},"onClose"),d=a(()=>{m(),o(r?.reason)},"onAbort"),g=setTimeout(()=>{m(),o(new Error("Shared language server attach timed out"))},t),m=a(()=>{clearTimeout(g),n.off("data",l),n.off("close",c),r?.removeEventListener("abort",d)},"finish");n.on("data",l),n.once("close",c),r?.addEventListener("abort",d,{once:!0}),n.write(`${JSON.stringify(e)}
|
|
2
|
-
`)})}a(rn,"exchange");function nn(n,e){let t=!1,r=new Promise(i=>n.once("close",()=>i())),s=new Qt;s.end();let o=n.pipe(new Qt);return{stdin:n,stdout:o,stderr:s,pid:e,completion:r.then(()=>({exitCode:t?0:1})),async stop(){t=!0,n.end();let i=setTimeout(()=>n.destroy(),1e3);await r,clearTimeout(i)}}}a(nn,"sharedServer");import{StreamMessageWriter as sn}from"vscode-jsonrpc/node";var ye=class extends sn{constructor(t,r){super(t);this.fail=r}static{a(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(r){this.fail(r)}}};import on from"node:path";import{URI as an}from"vscode-uri";function A(n,e){if(e.startsWith("ssh://")){let t=tr(e);if(n.includes("://")){let s=tr(n);if(s.host!==t.host)throw new Error("Document belongs to another language server owner");return s.href}let r=on.posix.resolve(decodeURIComponent(t.pathname),n);return t.pathname=r.split("/").map(encodeURIComponent).join("/"),t.href}if(n.startsWith("ssh://")||n.includes("://")&&!n.startsWith("file://"))throw new Error("Document belongs to another language server owner");return n.startsWith("file://")?n:an.file(n).toString()}a(A,"documentUri");function tr(n){let e=new URL(n);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(tr,"checkedRemote");async function j(n,e){if(e?.aborted)throw n.catch(()=>{}),e.reason;if(!e)return n;let t;try{return await Promise.race([n,new Promise((r,s)=>{t=a(()=>s(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}}a(j,"waitWithSignal");function $e(n,e){let t;return j(new Promise(r=>{t=setTimeout(r,n)}),e).finally(()=>clearTimeout(t))}a($e,"delayWithSignal");var ee=class{static{a(this,"SharedStartup")}controller=new AbortController;promise;settled=!1;waiters=0;constructor(e){this.promise=e(this.controller.signal);let t=a(()=>{this.settled=!0},"settled");this.promise.then(t,t)}async wait(e){this.waiters+=1;let t=await j(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 t)throw t.error;return t.value}};var cn=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),ln=new Set(["changes","relatedDocuments"]);function q(n,e){return Array.isArray(n)?n.map(t=>q(t,e)):typeof n!="object"||n===null?n:Object.fromEntries(Object.entries(n).map(([t,r])=>cn.has(t)&&typeof r=="string"?[t,e(r)]:ln.has(t)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[t,Object.fromEntries(Object.entries(r).map(([s,o])=>[e(s),q(o,e)]))]:[t,q(r,e)]))}a(q,"mapLspUris");var G=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;_documentContents=new Map;_diagnosticPublications=new Map;_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;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4,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 Mt(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get loading(){return this._serverStatus?.quiescent===!1}async waitUntilLoaded(e){if(!this.loading)return;let t,r;try{await j(new Promise((s,o)=>{t=a(()=>{this.loading||s()},"listener"),this._serverStatusListeners.add(t),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),t&&this._serverStatusListeners.delete(t)}}_setServerStatus(e){this._serverStatus=e;for(let t of[...this._serverStatusListeners])t()}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)}pulledReport(e){let t=this._pulledReports.get(e);return t?.version===this.documentVersion(e)?t:void 0}rememberPulledReport(e,t){t.version===this.documentVersion(e)&&this._pulledReports.set(e,t)}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(t){try{await this.shutdown()}catch(r){throw new AggregateError([e?.aborted?e.reason:t,r],`[lsp] ${this.serverId}: startup and cleanup failed`,{cause:r})}throw e?.throwIfAborted(),t}}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 t=T(this._command[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):rr.parse(this.rootUri).fsPath,s=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:dn.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._command,env:this._env,signal:e});let l=await this._ownedStartup;if(this._ownedProcess=l??null,e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let c=l?void 0:await this._attachSharedServer(r,i,e);if(this._disposed)throw await c?.stop(),new Error(`[lsp] ${this.serverId}: disposed`);this._sharedServer=c??null,e?.throwIfAborted();let d=l||c?void 0:un(t,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:xe({command:this._command,env:this._env},r,process.env)});this._process=d??null;let g=d?Sn(d):Promise.resolve(),m=l??c,y=T(m?.stdin??d?.stdin),p=T(m?.stdout??d?.stdout),f=T(m?.stderr??d?.stderr);y.on("error",()=>{}),p.on("error",()=>{}),f.on("error",()=>{}),this._stderr="";let h=new Promise(v=>{f.once("end",v),f.once("close",v)}),u,w=a(()=>{},"markExited"),b=new Promise(v=>{w=v});f.setEncoding("utf8"),f.on("data",v=>{this._stderr=(this._stderr+v).slice(-4096)}),d?.on("error",v=>{("code"in v?v.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,v),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let R=a(()=>l?this._ownedProcess===l:c?this._sharedServer===c:this._process===d,"current"),C=a(v=>{R()&&(u??=v,w(),this._closeFileWatchers(),!this._disposed&&v!==0&&v!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._diagnosticPublications.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),m?.completion.then(({exitCode:v})=>C(v),()=>{R()&&(this._crashed=!0,C(null))}),await j(g,e);let L=pn(new hn(p),new ye(y,v=>{this._connection!==L||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),L.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,v))}));this._connection=L,this._connection.onError(v=>{console.error(`[lsp] ${this.serverId}: connection error:`,v)});let S=a(v=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[v]})},"changed"),M=a(v=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,v),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,S,M):c?void 0:new ie(r,S,M),this._connection.onRequest("client/registerCapability",async v=>{for(let _ of v.registrations)if(_.method!=="workspace/didChangeConfiguration"){if(_.method==="textDocument/diagnostic"){this._pullRegistration=_.id,this._initialized&&(this._diagnosticMode="pull");continue}if(_.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${_.method}`);if(!this._fileWatchers)throw new Error("File watching is unavailable for this server owner");await this._fileWatchers.register(_.id,_.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",async v=>{for(let _ of v.unregisterations)_.id===this._pullRegistration?(this._pullRegistration=void 0,this._initialized&&(this._diagnosticMode="push")):await this._fileWatchers?.unregister(_.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/diagnostic/refresh",()=>{for(let v of this._handlers.get("workspace/diagnostic/refresh")??[])v(void 0);return null}),this._connection.onRequest("workspace/configuration",v=>Xt(this._settings,v.items)),this._connection.listen(),this._connection.onNotification((v,..._)=>{let O=this._ownerTransport,U=O?q(_[0],E=>O.fromServerUri(E)):_[0];if(v==="textDocument/publishDiagnostics"){let E=U;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._diagnosticPublications.set(E.uri,{diagnostics:E.diagnostics,...typeof E.version=="number"&&{version:E.version}})}if(v==="experimental/serverStatus"){let E=U;this._setServerStatus({quiescent:E?.quiescent!==!1,...typeof E?.message=="string"&&{message:E.message}})}for(let E of this._handlers.get(v)??[])E(U)}),this._connection.onRequest("workspace/workspaceFolders",()=>s);let D=await j(nr(this._connection.sendRequest("initialize",i),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`),e).catch(async v=>{if(e?.aborted)throw v;await Promise.race([Promise.all([h,b]),$e(fn,e)]).catch(()=>{});let _=this._stderr.trim(),O=u===void 0?void 0:`exited during startup${u===null?"":` with code ${u}`}`;if(!_&&!O)throw v;let U=`[lsp] ${this.serverId}${O?` ${O}`:""}${_?`: ${_}`:""}`;throw O?new Error(U):new Error(U,{cause:v})});if(await this._connection.sendNotification("initialized",{capabilities:D.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);e?.throwIfAborted(),this._initialized=!0,this._serverCapabilities=D.capabilities,this._diagnosticMode=D.capabilities.diagnosticProvider||this._pullRegistration!==void 0?"pull":"push"}async _attachSharedServer(e,t,r){if(this._sharedServers)try{return await this._sharedServers.attach({serverId:this.serverId,command:this._command,cwd:e,configuredEnv:this._env,env:xe({command:this._command,env:this._env},e,process.env),settings:this._settings,initialize:t,lingerMs:this._idleTimeoutMs??Kt,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 t=!1;return()=>{if(t)return;t=!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._pulledReports.clear(),this._diagnosticMode="unknown",this._versionedDiagnostics=!1,this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start(e)}async sendRequest(e,t,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,t,r)}catch(l){let c=yn[o];if(c===void 0||!bn(l))throw l;await $e(c,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,t,r){let s=this._ownerTransport,o=s?q(t,d=>s.toServerUri(d)):t,i=a(d=>s?q(d,g=>s.fromServerUri(g)):d,"mapResult");if(!r)return i(await T(this._connection).sendRequest(e,o));let l=new gn,c;try{let d=T(this._connection).sendRequest(e,o,l.token);return i(await Promise.race([d,new Promise((g,m)=>{c=a(()=>{l.cancel(),m(r.reason)},"onAbort"),r.addEventListener("abort",c,{once:!0})})]))}finally{c&&r.removeEventListener("abort",c),l.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let r=this._connection;if(!r)return;let s=this._ownerTransport,o=s?q(t,i=>s.toServerUri(i)):t;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,t){let r=this._handlers.get(e)??[];return r.push(t),this._handlers.set(e,r),()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}toUri(e){return A(e,this.rootUri)}serverDocumentPath(e){let t=this.toUri(e),r=this._ownerTransport?.toServerUri(t)??t;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):rr.parse(r).fsPath}openDocument(e,t,r,s=1){let o=this._documentVersions.get(e);if(o!==void 0){this.changeDocument(e,t,Math.max(s,o+1));return}this._diagnosticPublications.delete(e),this._pulledReports.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,r,s=!1){if(this._documentContents.get(e)===t)return;let o=this._documentVersions.get(e);o===void 0?this.openDocument(e,t,r):this.changeDocument(e,t,o+1),s&&(this.loading?this._deferSave(e):this._sendSave(e))}_sendSave(e){let t=this._serverCapabilities?.textDocumentSync,r=typeof t=="object"&&t!==null?t.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 t=this._pendingSaves.size>0;if(this._pendingSaves.add(e),t)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,t,r){let s=this._documentVersions.get(e),o=Math.max(r,(s??0)+1);this._diagnosticPublications.delete(e),this._pulledReports.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:o},contentChanges:[{text:t}]}),this._documentVersions.set(e,o),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e),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 nr(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 t=this._ownedProcess??await this._ownedStartup?.catch(()=>{});this._ownedProcess=null,this._ownedStartup=void 0;let r=Promise.resolve().then(()=>t?.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._pulledReports.clear(),this._diagnosticMode="unknown",this._versionedDiagnostics=!1,this._activeDiagnosticRequests.clear(),this._serverCapabilities=null;let l=await Promise.allSettled([r,o,e]),c=[];for(let d of l)d.status==="rejected"&&c.push(d.reason);if(c.length>0)throw new AggregateError(c,`[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(t=>{console.error(`[lsp] ${this.serverId}: file watcher cleanup failed:`,t)})),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`)}},fn=250,yn=[50,100,200,400,800],wn=-32801,vn=-32802;function bn(n){if(!(n instanceof mn))return!1;if(n.code===wn)return!0;if(n.code!==vn)return!1;let e=n.data;return!(e!==null&&typeof e=="object"&&"retriggerRequest"in e&&e.retriggerRequest===!1)}a(bn,"isRetryableCancellation");function Sn(n){return new Promise((e,t)=>{let r=a(()=>{n.off("spawn",s),n.off("error",o)},"cleanup"),s=a(()=>{r(),e()},"onSpawn"),o=a(i=>{r(),t(i)},"onError");n.once("spawn",s),n.once("error",o)})}a(Sn,"waitForSpawn");function nr(n,e,t){return new Promise((r,s)=>{let o=setTimeout(()=>{s(new Error(t))},e);n.then(i=>{clearTimeout(o),r(i)}).catch(i=>{clearTimeout(o),s(i instanceof Error?i:new Error(String(i)))})})}a(nr,"withTimeout");import x from"node:path";import{existsSync as Ln}from"node:fs";function sr(n){let e=new Map,t=new Map;for(let[r,s]of Object.entries(n))for(let[o,i]of Object.entries(s.languages))for(let l of i.extensions){let c=l.toLowerCase(),d=e.get(c);if(d!==void 0&&d!==o)throw new Error(`[lsp] extension conflict: "${c}" claimed by "${d}" and "${o}"`);e.set(c,o);let g=t.get(c)??[];g.push(r),t.set(c,g)}return{extToLanguageId:e,extToServerIds:t}}a(sr,"buildLanguageLookup");var W=class n{constructor(e,t,r){this._projectRoot=r;this._entries=e;let s=e.filter(o=>o.layer!=="built-in"||t.has(o.id));this._servers=Object.fromEntries(s.map(o=>[o.id,o.config])),this._lookup=sr(this._servers)}static{a(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){t.signal?.throwIfAborted();let r=await Nt(e,"lsp-servers",c=>_n(c).servers,t);if(t.signal?.throwIfAborted(),e.startsWith("ssh://")&&(!t.executableAvailable&&!t.executableAvailability||t.requireBuiltInEvidence&&!t.recipeEvidence))throw Object.assign(new Error("Remote language server availability needs its workspace owner"),{code:"UNSUPPORTED_SOURCE"});let s=t.environment??process.env,o=r.entries.filter(c=>c.layer==="built-in"),i=[];if(t.executableAvailability){let c=await t.executableAvailability(o.map(d=>d.config));if(c.length!==o.length||c.some(d=>typeof d!="boolean"))throw new TypeError("Invalid owner executable availability report");for(let[d,g]of o.entries())i.push({id:g.id,available:c[d]===!0})}else if(t.executableAvailable)for(let c of o)i.push({id:c.id,available:await t.executableAvailable(c.config)});else i.push(...await Promise.all(o.map(async c=>({id:c.id,available:await jt(c.config,e,s,t.signal)}))));t.signal?.throwIfAborted();let l=t.requireBuiltInEvidence?t.recipeEvidence?await t.recipeEvidence(t.recipes??[]):await At(e,t.recipes??[],void 0,t.signal):void 0;return t.signal?.throwIfAborted(),new n(r.entries,new Set(i.filter(c=>c.available&&(l===void 0||(l.get(c.id)?.score??0)>0)).map(c=>c.id)),e.startsWith("ssh://")?e:x.resolve(e))}static fromConfig(e,t=process.cwd()){return new n(Object.entries(e.servers).map(([r,s])=>({id:r,config:s,layer:"project",sourcePath:"<memory>"})),new Set,t.startsWith("ssh://")?t:x.resolve(t))}resolve(e){return this.candidates(e).filter(t=>!t.config.requireRootMarker||this.hasRootMarker(e,t.config.rootMarkers))}candidates(e){let t=x.basename(e),r=x.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[l,c]of Object.entries(i.config.languages))if(c.extensions.some(d=>d.toLowerCase()===r.toLowerCase())||c.fileNames?.some(d=>s(d)===s(t))){o.push({serverId:i.id,config:i.config,languageId:l,layer:i.layer,sourcePath:i.sourcePath});break}}return o}async resolveOwned(e,t){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),l=e.includes("://")?decodeURIComponent(i.pathname):x.posix.resolve(s,e),c=x.posix.relative(s,l);if(i.origin!==r.origin||i.host!==r.host||i.protocol!==r.protocol||i.username||i.password||i.port||i.search||i.hash||c===".."||c.startsWith("../"))throw Object.assign(new Error("Language server resource belongs to another owner"),{code:"UNSUPPORTED_SOURCE"});let d=[];for(let g of this.candidates(o?e:l)){if(!g.config.requireRootMarker){d.push(g);continue}let m=o||l===s?s:x.posix.dirname(l);for(;;){let y=!1;for(let p of g.config.rootMarkers){let f=x.posix.resolve(m,p),h=x.posix.relative(s,f);if(h===".."||h.startsWith("../"))continue;let u=new URL(r.href);if(u.pathname=f.split("/").map(encodeURIComponent).join("/"),await t(u.href)){y=!0;break}}if(y){d.push(g);break}if(m===s)break;m=x.posix.dirname(m)}}return d}hasRootMarker(e,t){let r=x.dirname(x.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(x.sep)&&(r=this._projectRoot);;){let s=x.relative(this._projectRoot,r);if(s===".."||s.startsWith(`..${x.sep}`)||x.isAbsolute(s))return!1;if(t.some(o=>Ln(x.join(r,o))))return!0;if(r===this._projectRoot)return!1;r=x.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 t=e.startsWith("ssh://")?decodeURIComponent(new URL(e).pathname):e;return(this._projectRoot.startsWith("ssh://")?this.candidates(t):this.resolve(t))[0]?.languageId??e.slice(1)}};function _n(n){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("LSP config must be an object");let e=n;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,r]of Object.entries(e.servers)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LSP server ${t} 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 ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(o=>typeof o!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[o,i]of Object.entries(s.languages)){let l=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(l)||l.length===0||l.some(d=>typeof d!="string"))throw new Error(`LSP server ${t} language ${o} requires extensions`);let c=i.fileNames;if(c!==void 0&&(!Array.isArray(c)||c.some(d=>typeof d!="string"||d.length===0||/[/\\]/u.test(d))))throw new Error(`LSP server ${t} language ${o}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return n}a(_n,"parseLspConfig");var or={protocol:bt,apiVersion:St,id:"lsp",setup(n){for(let e of Z)n.addToolRecipe(e);n.addSetupCheck({id:"effective-config",inspect:Pn}),n.addCheck({id:"config",title:"LSP",async run(e){try{let t=await W.fromPackageDir(e.cwd,ir(e)),r=En(t,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,l=new G({serverId:s.serverId,rootUri:i?e.cwd:Rn.file(e.cwd).toString(),...i&&{ownerTransport:{start:a(c=>i.start(c.command,c.env,c.signal),"start"),toServerUri:a(c=>i.toNativeUri(c),"toServerUri"),fromServerUri:a(c=>i.fromNativeUri(c),"fromServerUri")}},command:s.config.command,env:Cn(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 l.start(e.signal),{status:"pass",message:`${o}: initialized`,detail:s.sourcePath}}catch(c){return{status:"fail",message:`${o}: ${c instanceof Error?c.message:String(c)}`,detail:s.sourcePath}}finally{await l.shutdown()}}))}catch(t){return e.signal?.throwIfAborted(),[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function Pn(n){try{let e=await W.fromPackageDir(n.cwd,ir(n)),t=[],r=new Map;for(let[s,o]of n.detectedLanguages){let i=o.flatMap(l=>e.resolve(l)).find(l=>l.languageId===s);i!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:i.serverId}),await Ut(n,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:t,actions:[...r.values()]}}catch(e){return n.signal?.throwIfAborted(),{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(Pn,"inspectLspSetup");function ir(n){let e=n.workspace;return{...$t(n),recipeEvidence:e?t=>e.evidence(t,n.signal):void 0}}a(ir,"lspOptions");function En(n,e){let t=new Map;for(let r of e){let s=n.resolve(r)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}a(En,"applicableServers");function Cn(n,e){return Object.fromEntries(Object.entries({...n,...e}).filter(t=>t[1]!==void 0))}a(Cn,"definedEnvironment");var xn={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 B(n){return xn[n]??`SymbolKind(${n})`}a(B,"symbolKindName");async function ae(n,e,t){return await n.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},t)??[]}a(ae,"requestDocumentSymbols");async function Ue(n,e,t=100,r){return(await n.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,t)}a(Ue,"requestWorkspaceSymbols");async function we(n,e,t,r){return await n.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:r})}a(we,"requestRename");import le from"node:path";import{diffLines as In}from"diff";var kn=500,J=class n{constructor(e){this.runs=e}static{a(this,"LinePositionMap")}static between(e,t){if(e===t)return new n([[0,0,Number.MAX_SAFE_INTEGER]]);let r=In(e,t,{timeout:kn});if(r===void 0)return new n(void 0);let s=[],o=0,i=0;for(let l of r){let c=l.count;l.added?i+=c:l.removed?o+=c:(s.push([o,i,c]),o+=c,i+=c)}return new n(s)}mapRange(e){let t=this.runs?.find(([s,,o])=>e.start.line>=s&&e.end.line<s+o);if(t===void 0)return;let r=t[1]-t[0];return{start:{line:e.start.line+r,character:e.start.character},end:{line:e.end.line+r,character:e.end.character}}}};var ar="SOURCE_CHANGED",Tn=[0,100,250,500];function F(n){return Object.assign(new Error(n),{code:ar})}a(F,"sourceChanged");async function te(n,e){for(let t=0;;t+=1)try{return await n()}catch(r){let s=Tn[t];if(!(r?.code===ar)||s===void 0||e?.aborted)throw r;s>0&&await new Promise(i=>setTimeout(i,s))}}a(te,"retryWhileSourceChanges");import{URI as Nn}from"vscode-uri";import{createHash as An}from"node:crypto";import{readdir as Mn,stat as ve}from"node:fs/promises";import H from"node:path";import{URI as Fe}from"vscode-uri";async function We(n,e){if(!n.supportsCommand("typescript.tsserverRequest"))return;if((await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:e,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for a workspace query.")}a(We,"prepareProjectQuery");import{AsyncLocalStorage as Dn}from"node:async_hooks";var qe=new Dn;async function $(n){if(qe.getStore()!==void 0)return n();let e=new Map;try{return await qe.run(e,n)}finally{for(let t of e.values())for(let r of t.values())r()}}a($,"withLspDocuments");function cr(n,e){let t=qe.getStore();if(t===void 0)return;let r=t.get(n)??new Map;t.set(n,r),r.has(e)||r.set(e,n.retainDocument(e))}a(cr,"retainForCurrentOperation");function lr(n,e){let t=a(r=>typeof r=="string"?r.replaceAll("{project}",()=>e):Array.isArray(r)?r.map(t):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([s,o])=>[s,t(o)])):r,"expand");return Object.fromEntries(Object.entries(n).map(([r,s])=>[r,t(s)]))}a(lr,"resolveInitializationOptions");var X=class n{constructor(e,t,r={}){this._registry=e;this._owner=t;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(!n._instance)throw new Error("[lsp] LspManager not initialized");return n._instance}static getInstanceOrNull(){return n._instance}static init(e,t,r={}){let s=n._instance;return s?._disposed?(s._registry=e,s._owner=t,s._options=r,s._disposed=!1,s):(n._instance=new n(e,t,r),n._instance)}static async resetForTest(){n._instance&&(await n._instance.shutdownAll(),n._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,t,r,s){if(s?.throwIfAborted(),this._disposed)return null;let o=t.startsWith("ssh://"),i=o?this.requireOwner():void 0,l=i?await this._registry.resolveOwned(e,u=>i.exists(u,s)):this._registry.resolve(e);if(s?.throwIfAborted(),this._disposed)return null;let c=r==="symbols"?l[0]:l.find(u=>u.config.capabilities.includes(r));if(!c)return null;let d=o?t:Fe.file(t).toString(),g=`${c.serverId}:${d}`,m=this._clientStarts.get(g);if(m)return m.controller.signal.aborted?(await j(m.promise.catch(()=>{}),s),this.getOrStart(e,t,r,s)):m.wait(s);let y=this._clients.get(g);if(y?.ready)return y.touch(),y;let p=new ee(u=>this._startClient(g,d,c,y,u));this._clientStarts.set(g,p);let f=a(()=>{this._clientStarts.get(g)===p&&this._clientStarts.delete(g)},"settled");p.promise.then(f,f);let h=await p.wait(s);return h.touch(),h}_stopIdleClient(e,t){if(this._clients.get(e)===t){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)}t.shutdown().catch(r=>{console.error(`[lsp] ${t.serverId}: idle shutdown failed:`,r)})}async _startClient(e,t,r,s,o){let i=s??new G({serverId:r.serverId,rootUri:t,command:r.config.command,...t.startsWith("ssh://")&&this._owner&&{ownerTransport:this._owner.transport(t)},...!t.startsWith("ssh://")&&this._options.sharedServers&&{sharedServers:this._options.sharedServers},...r.config.env&&{env:r.config.env},...r.config.initializationOptions&&{initOptions:lr(r.config.initializationOptions,t.startsWith("ssh://")?decodeURIComponent(new URL(t).pathname):Fe.parse(t).fsPath)},...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,i),"onIdle")}});try{s?await s.restart(o):await i.start(o),o.throwIfAborted()}catch(l){try{await i.shutdown()}catch(c){if(c!==l)throw new AggregateError([l,c],"Language server startup and cleanup failed",{cause:c})}throw l}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${r.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async isSourceFile(e,t,r){if(r?.throwIfAborted(),t.startsWith("ssh://")){if(this._owner===void 0)throw new Error("No language server workspace owner");return this._owner.isFile(A(e,t),r)}let s=await ve(H.resolve(t,e));return r?.throwIfAborted(),s.isFile()}async getWorkspaceClients(e,t="symbols",r=e,s=()=>!0,o){if(o?.throwIfAborted(),e.startsWith("ssh://")){let m=this._owner;if(!m)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let y=new Set,p=new Set(this._registry.knownExtensions),f=new Set([".git",".cache","node_modules","dist","build"]),h=a(async w=>{if(o?.throwIfAborted(),p.size!==0)for(let b of await m.entries(w,o)){o?.throwIfAborted();let R=A(b.name,`${w}/`);if(b.kind==="directory")f.has(b.name)||await h(R);else if(b.kind==="file"){let C=H.posix.extname(b.name).toLowerCase();if(!p.has(C)||!s(R))continue;let L=await this.openFile(R,e,t,o);L&&(y.add(L.client),p.delete(C))}}},"visit"),u=A(r,e);if(await m.isFile(u,o)){if(!s(u))return[];let w=await this.openFile(u,e,t,o);return w?[w.client]:[]}return await h(u),[...y]}let i=new Set,l=new Set(this._registry.knownExtensions),c=new Set([".git",".cache","node_modules","dist","build"]),d=a(async m=>{if(o?.throwIfAborted(),l.size===0)return;let y;try{y=await Mn(m,{withFileTypes:!0})}catch{return}for(let p of y){if(o?.throwIfAborted(),l.size===0)return;if(p.isDirectory()){c.has(p.name)||await d(H.join(m,p.name));continue}if(!p.isFile())continue;let f=H.extname(p.name).toLowerCase();if(!l.has(f))continue;let h=H.join(m,p.name);if(!s(h))continue;let u=await this.openFile(h,e,t,o);u&&(l.delete(f),u.client.hasWorkspaceSymbolCapability&&(await We(u.client,h),i.add(u.client)))}},"visit"),g=H.resolve(e,r);if((await ve(g)).isFile()){if(!s(g))return[];let m=await this.openFile(g,e,t,o);return m===null||!m.client.hasWorkspaceSymbolCapability?[]:(await We(m.client,g),[m.client])}return await d(g),o?.throwIfAborted(),[...i]}async prepareWorkspaceSymbols(e,t=e,r,s){return this.getWorkspaceClients(e,"symbols",t,r,s)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}syncEditedSource(e,t){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(H.extname(decodeURIComponent(new URL(s).pathname)));r.syncDocument(s,t,o,!0)}}async readSourceSnapshot(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readSnapshot(e,t);if(e.includes("://"))throw Object.assign(new Error("Unsupported rename source"),{code:"UNSUPPORTED_SOURCE"});let r=a(i=>`${i.dev}:${i.ino}:${i.mode}:${i.size}:${i.mtimeMs}:${i.ctimeMs}`,"identity"),s=r(await ve(e)),o=await this.readSourceText(e,t);if(s!==r(await ve(e)))throw new Error("A rename source changed while reading it. No edits applied.");return{content:o,version:An("sha256").update(s).update("\0").update(o).digest("hex")}}async readSourceBytes(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readBytes(e,t);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:t})}async readSourceText(e,t){if(t?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readText(e,t);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:t})}async openFile(e,t,r="diagnostics",s){if(s?.throwIfAborted(),e.startsWith("ssh://")&&!t.startsWith("ssh://")){if(!this._registry.projectRoot.startsWith("ssh://"))throw Object.assign(new Error("Remote document has no workspace owner"),{code:"UNSUPPORTED_SOURCE"});t=this._registry.projectRoot}let o=t.startsWith("ssh://"),i=o?A(e,t):H.resolve(t,e),l=await this.getOrStart(i,t,r,s);if(!l)return null;let c=l.toUri(i);cr(l,c);let d=o?this.requireOwner():void 0,m=(d?await this._registry.resolveOwned(i,y=>d.exists(y,s)):this._registry.resolve(i))[0]?.languageId??"plaintext";if(d){let y=await d.readText(c,s);return s?.throwIfAborted(),l.syncDocument(c,y,m),await l.waitUntilLoaded(s),{client:l,uri:c,languageId:m}}try{let{readFile:y}=await import("node:fs/promises"),p=await y(i,{encoding:"utf8",signal:s});s?.throwIfAborted(),l.syncDocument(c,p,m)}catch(y){if(s?.throwIfAborted(),!(y instanceof Error&&"code"in y&&y.code==="ENOENT"))throw y}return await l.waitUntilLoaded(s),{client:l,uri:c,languageId:m}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let r=t.onNotification("textDocument/publishDiagnostics",s=>{let o=On(s);if(!o||t.hasActiveDiagnosticRequest(o.uri))return;let i=t.documentVersion(o.uri);if(o.version!==void 0&&i!==void 0&&o.version<i)return;let l=`${e}:${o.uri}`,c=o.diagnostics.map(Te),d=JSON.stringify([o.version,i,c]);if(this._pushFingerprints.get(l)===d)return;this._pushFingerprints.set(l,d);let g={cwd:t.rootUri.startsWith("ssh://")?t.rootUri:Fe.parse(t.rootUri).fsPath,serverId:t.serverId,uri:o.uri,diagnostics:c,...o.version!==void 0&&{version:o.version}};for(let m of this._pushHandlers)m(g)});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 t=await Promise.allSettled(e.map(i=>i.promise)),r=[];for(let[i,l]of t.entries())l.status==="rejected"&&l.reason!==e[i]?.controller.signal.reason&&r.push(l.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 On(n){if(n===null||typeof n!="object")return;let e=n;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(On,"parsePushNotification");async function He(n){try{return await n}catch(e){if(ge(e))return;throw e}}a(He,"unlessUnsupported");async function ze(n,e,t){if(t?.throwIfAborted(),!n.supportsCommand("typescript.tsserverRequest"))return;let r=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:n.serverDocumentPath(e),needFileNameList:!0},{isAsync:!1,expectsResult:!0}]},t);if(t?.throwIfAborted(),r?.success!==!0)throw new Error("TypeScript could not load the project for the workspace query.")}a(ze,"loadQueryProject");async function ce(n,e,t,r){return await ze(n,e,r),await n.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}},r)??[]}a(ce,"requestReferences");async function Ve(n,e,t,r){let s=await He(n.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t},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,l]=await Promise.all([He(n.sendRequest("callHierarchy/incomingCalls",{item:o},r)),He(n.sendRequest("callHierarchy/outgoingCalls",{item:o},r))]);return{items:s,incoming:i??[],outgoing:l??[],unsupported:[...i===void 0?["incoming"]:[],...l===void 0?["outgoing"]:[]]}}a(Ve,"requestCallHierarchy");function re(n,e,t){let r=e.startsWith("ssh://"),s=r?le.posix:le,o=a(g=>r?decodeURIComponent(new URL(A(g,e)).pathname):g,"native"),i=r?o(t.path??e):le.resolve(e,t.path??"."),l=s.relative(i,o(n));if(l===".."||l.startsWith(`..${s.sep}`)||s.isAbsolute(l))return!1;let c=s.relative(o(e),o(n)).split(s.sep).join("/"),d=a(g=>Rt(g).some(m=>s.matchesGlob(m.includes("/")?c:s.basename(o(n)),m)),"matches");return(t.include===void 0||d(t.include))&&(t.exclude===void 0||!d(t.exclude))}a(re,"withinScope");function be(n,e){let t=A(n,e);if(t.startsWith("ssh://"))return t;let r=Nn.parse(t);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return le.resolve(r.fsPath)}a(be,"sourceOf");function jn(n,e){return n.start.line===e.start.line&&n.start.character===e.start.character&&n.end.line===e.end.line&&n.end.character===e.end.character}a(jn,"sameRange");function dr(n,e,t){return n.flatMap(r=>[...r.name===e&&r.range!==void 0&&jn(r.range,t)&&r.selectionRange!==void 0?[r.selectionRange]:[],...dr(r.children??[],e,t)])}a(dr,"declarationNames");function ur(n,e){return n.flatMap(t=>[...t.name===e&&t.selectionRange!==void 0?[t.selectionRange]:[],...ur(t.children??[],e)])}a(ur,"declarationsNamed");async function Ge(n,e,t,r,s={},o=X.getInstance()){return te(()=>$n(n,e,t,r,s,o),r)}a(Ge,"searchSymbols");async function $n(n,e,t,r,s,o){r?.throwIfAborted();let i=s.resultScope;if(i!==void 0&&(await K(i,r),i.targets.length===0))return{hits:[],complete:i.complete};if(i===void 0&&s.path!==void 0&&!re(e.startsWith("ssh://")?A(s.path,e):le.resolve(e,s.path),e,s)&&await o.isSourceFile(s.path,e,r))return{hits:[],complete:!0};let l=i?.targets.map(h=>h.source)??[s.path??e],c=new Set((await Promise.all(l.map(h=>o.prepareWorkspaceSymbols(e,h,u=>re(u,e,s),r)))).flat());if(c.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let d=new Map,g=a(async(h,u)=>{r?.throwIfAborted();let w=be(h.uri,e),b=d.get(w);if(b===void 0){let{content:E,version:Q}=await o.readSourceSnapshot(w,r);b={document:ct(w,E),version:Q},d.set(w,b)}let{document:R}=b,C=u?.documentContent(h.uri),L=C===void 0||C===R.content?h.range:J.between(C,R.content).mapRange(h.range);if(L===void 0)throw F("LSP range does not match its source snapshot.");let{start:S,end:M}=L,D=[S,M];for(let E of D){let Q=R.lines[E.line];if(!Number.isInteger(E.line)||!Number.isInteger(E.character)||Q===void 0||E.character<0||E.character>Q.content.length)throw F("LSP range does not match its source snapshot.")}let v=T(R.lines[S.line]),_=a(E=>R.lines.slice(0,E).reduce((Q,tt)=>Q+tt.content.length+tt.lineEnding.length,0),"offset"),O=_(S.line)+S.character,U=_(M.line)+M.character;if(U<O)throw new Error("LSP returned a reversed source range.");return{source:w,lineNumber:S.line+1,endLineNumber:M.line+1,startColumn:S.character,endColumn:M.character,matchedText:R.content.slice(O,U),lineText:v.content}},"toMatch"),m=a(h=>re(h.source,e,s)&&(i===void 0||_t(i,h)),"included"),y=[],p=new Set;for(let h of c){r?.throwIfAborted();let u=await Ue(h,n,Number.MAX_SAFE_INTEGER,r);for(let w of u){if(r?.throwIfAborted(),!re(be(w.location.uri,e),e,{}))continue;let b=await g(w.location,h).catch(v=>{if(v?.code!=="SOURCE_CHANGED")throw v}),R=await o.openFile(be(w.location.uri,e),e,"symbols",r);if(R===null)throw new Error("LSP references are unavailable for a discovered declaration.");let C=w.location;if(b?.matchedText!==w.name){let v=await ae(R.client,R.uri,r),_=dr(v,w.name,w.location.range);if(_.length!==1&&(_=ur(v,w.name)),_.length!==1)throw F("LSP declaration has no unique provider selectionRange; cannot search its references.");C={uri:R.uri,range:T(_[0])}}let L=await g(C,R.client),S={id:JSON.stringify([h.serverId,L.source,w.location.range]),name:w.name,kind:String(w.kind),source:L.source,range:{startLine:L.lineNumber,startColumn:L.startColumn,endLine:L.endLineNumber??L.lineNumber,endColumn:L.endColumn}},M=await ce(R.client,R.uri,C.range.start,r);r?.throwIfAborted();let D=[{...L,role:"definition",symbol:S}];for(let v of M){if(!re(be(v.uri,e),e,{}))continue;let _=await g(v,R.client);_.source===L.source&&_.lineNumber===L.lineNumber&&_.startColumn===L.startColumn&&_.endLineNumber===L.endLineNumber&&_.endColumn===L.endColumn||D.push({..._,role:"reference",symbol:S})}if(!(s.navigation==="references"&&!D.some(m)))for(let v of D){if(s.navigation!=="references"&&!m(v)||s.navigation==="references"&&!re(v.source,e,{}))continue;let _=JSON.stringify([S.id,v.source,v.lineNumber,v.startColumn,v.endLineNumber,v.endColumn]);p.has(_)||(p.add(_),y.push(v))}}}r?.throwIfAborted();let f=new Map;for(let[h,u]of d){let w=await o.readSourceSnapshot(h,r);w.version!==u.version&&w.content!==u.document.content&&f.set(h,J.between(u.document.content,w.content))}for(let[h,u]of y.entries()){let w=f.get(u.source);if(w===void 0)continue;let b=w.mapRange({start:{line:u.lineNumber-1,character:u.startColumn},end:{line:(u.endLineNumber??u.lineNumber)-1,character:u.endColumn}});if(b===void 0)throw F("LSP source changed during search.");y[h]={...u,lineNumber:b.start.line+1,endLineNumber:b.end.line+1}}return i!==void 0&&await K(i,r),y.sort((h,u)=>h.source.localeCompare(u.source)||h.lineNumber-u.lineNumber||h.startColumn-u.startColumn||h.endColumn-u.endColumn||h.symbol.id.localeCompare(u.symbol.id)),{hits:y.slice(0,t),complete:(i?.complete??!0)&&y.length<=t}}a($n,"searchSymbolsOnce");import Be from"node:path";import{fileURLToPath as Un}from"node:url";var Je=10,Xe=5,ne=10;async function _e(n,e,t,r,s){return te(()=>Wn(n,e,t,r,s),s)}a(_e,"resolveLspDeclaration");async function Wn(n,e,t,r,s){z(s);let o=await Pe(n,e,r,s),i=Re(o.symbols,t,o.displayPath),l=await n.readSourceText(o.filePath,s);z(s);let c=o.servedText,d=c===l||gr(l,i)?i.range:c!==void 0&&gr(c,i)?J.between(c,l).mapRange(i.range):void 0;if(d===void 0)throw F("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:d,content:l}}a(Wn,"resolveLspDeclarationOnce");async function mr(n,e,t,r,s){z(s);let o=await n.readSourceText(e,s),i=await Pe(n,e,r,s),l=Re(i.symbols,t,i.displayPath);if(o!==await n.readSourceText(e,s))throw new Error("The rename source changed during resolution.");return z(s),{client:i.client,uri:i.uri,position:l.selectionRange.start,content:o}}a(mr,"resolveLspRenameTarget");async function Ye(n,e,t,r,s){return te(async()=>{z(s);let o=await Pe(n,e,r,s),i=Re(o.symbols,t,o.displayPath),l=await vr(o,i,s),c=new Le(r),d=await qn(o,i,l,c);return await hr(n,o,s),d},s)}a(Ye,"readLspSymbolGraph");async function hr(n,e,t){if(e.servedText===void 0)return;let r=await n.readSourceText(e.filePath,t);if(e.servedText!==r)throw F("The file changed while the language server answered. Read it again.")}a(hr,"assertAnsweredForCurrentText");async function Ze(n,e,t,r){return te(async()=>{z(r);let s=await Pe(n,e,t,r),o=new Le(t),i=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let l of s.symbols){z(r);let c=await vr(s,l,r);i.push("",...await Vn(s,l,c,o))}return await hr(n,s,r),i.join(`
|
|
3
|
-
`)},r)}a(Ze,"readLspFileGraph");function Re(n,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let o=wr(n,T(e[0]));if(o.length===1)return T(o[0]);throw o.length>1?new Error(`Symbol selector "${Y(e)}" is ambiguous in ${t}; use parent/child.`):pr(e,t)}let r=n,s;for(let o of e){let i=r.filter(l=>l.name===o);if(i.length===0)throw pr(e,t);if(i.length>1)throw new Error(`Symbol selector "${Y(e)}" is ambiguous at "${o}" in ${t}.`);s=T(i[0]),r=s.children}return T(s)}a(Re,"resolveLspCodeSymbol");async function Pe(n,e,t,r){let s=N(e,t),o=await n.openFile(s,t,"symbols",r);if(!o)throw new Error(`No LSP server with symbol support is configured for ${Ke(s,t)}.`);let i=o.client.documentContent(o.uri),l=await ae(o.client,o.uri,r),c=fr(l).sort(yr);return{client:o.client,uri:o.uri,filePath:s,displayPath:Ke(s,t),symbols:c,servedText:i}}a(Pe,"openCodeDocument");function fr(n,e=[]){return n.flatMap(t=>{let r=t.selectionRange??t.range;if(!r)return[];let s=t.range??r,o=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:r,selector:o,children:fr(t.children??[],o).sort(yr)}]})}a(fr,"normalizeDocumentSymbols");function yr(n,e){return n.range.start.line-e.range.start.line||n.range.start.character-e.range.start.character||n.name.localeCompare(e.name)}a(yr,"compareSymbols");function wr(n,e){return n.flatMap(t=>[...t.name===e?[t]:[],...wr(t.children,e)])}a(wr,"collectNamedSymbols");function pr(n,e){return new Error(`Symbol "${Y(n)}" was not found in ${e}.`)}a(pr,"symbolNotFound");async function vr(n,e,t){let r=e.selectionRange.start,[s,o]=await Promise.all([ce(n.client,n.uri,r,t),Ve(n.client,n.uri,r,t)]);return z(t),{references:s,calls:o}}a(vr,"queryRelations");async function qn(n,e,t,r){let s=Y(e.selector),o=await r.line(n.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${n.displayPath} ${o} (${B(e.kind)})`,`Source: calls ${br(n.displayPath,e.selector)}`,"",...await Fn(t.references,r),"",...Se(n,t,"incoming")??await Hn(t.calls.incoming,r),"",...Se(n,t,"outgoing")??await zn(t.calls.outgoing,r)].join(`
|
|
4
|
-
`)}a(qn,"formatSymbolGraph");async function Fn(n,e){let t=Sr(n),r=[`References: ${n.length} in ${t.length} file(s)`];for(let[s,o]of t.slice(0,Je)){r.push(`- ${e.display(s)} (${o.length})`);for(let i of o.slice(0,Xe))r.push(` - ${await e.line(s,i.range.start.line+1)}`);o.length>Xe&&r.push(` - ... ${o.length-Xe} more`)}return t.length>Je&&r.push(`- ... ${t.length-Je} more file(s)`),r}a(Fn,"formatReferences");function Se(n,e,t){return e.calls.unsupported.includes(t)?[`${t==="incoming"?"Incoming calls":"Outgoing calls"}: not supported by ${n.client.serverId}`]:void 0}a(Se,"unsupportedCalls");async function Hn(n,e){let t=[`Incoming calls: ${n.length}`];n.length===0&&t.push("- none found; the server's index can miss callers added in the last seconds");for(let r of n.slice(0,ne)){let s=r.fromRanges[0]?.start.line??r.from.selectionRange.start.line,o=await e.line(r.from.uri,s+1);t.push(`- ${B(r.from.kind)} ${r.from.name} \u2014 ${e.display(r.from.uri)} ${o}`)}return n.length>ne&&t.push(`- ... ${n.length-ne} more`),t}a(Hn,"formatIncomingCalls");async function zn(n,e){let t=[`Outgoing calls: ${n.length}`];for(let r of n.slice(0,ne)){let s=await e.line(r.to.uri,r.to.selectionRange.start.line+1);t.push(`- ${B(r.to.kind)} ${r.to.name} \u2014 ${e.display(r.to.uri)} ${s}`)}return n.length>ne&&t.push(`- ... ${n.length-ne} more`),t}a(zn,"formatOutgoingCalls");async function Vn(n,e,t,r){let s=B(e.kind),o=await r.line(n.uri,e.selectionRange.start.line+1),i=Sr(t.references).map(([g,m])=>`${r.display(g)} (${m.length})`),l=t.calls.incoming.map(g=>`${g.from.name} (${r.display(g.from.uri)})`),c=t.calls.outgoing.map(g=>`${g.to.name} (${r.display(g.to.uri)})`),d=[`### ${s} ${e.name}`,`Selector: ${Y(e.selector)}`,`Definition: ${o}`,`Used by: ${Qe(i)}`,...Se(n,t,"incoming")??[`Incoming calls: ${Qe(l)}`],...Se(n,t,"outgoing")??[`Outgoing calls: ${Qe(c)}`]];if(e.children.length>0){d.push("Members:");for(let g of e.children){let m=br(n.displayPath,g.selector);d.push(`- ${B(g.kind)} ${g.name} \u2014 calls ${m}`)}}return d}a(Vn,"formatFileGraphSymbol");function br(n,e){return xt("graph",n,e).slice(6)}a(br,"callsReference");function Qe(n,e=5){if(n.length===0)return"none";let t=n.slice(0,e).join(", ");return n.length>e?`${t}, ... ${n.length-e} more`:t}a(Qe,"summarize");function Sr(n){let e=new Map;for(let t of n){let r=e.get(t.uri)??[];r.push(t),e.set(t.uri,r)}return[...e].map(([t,r])=>[t,r.sort((s,o)=>s.range.start.line-o.range.start.line||s.range.start.character-o.range.start.character)]).sort(([t],[r])=>t.localeCompare(r))}a(Sr,"groupLocationsByUri");var Le=class{static{a(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return Ke(Gn(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function Gn(n){if(!n.startsWith("file://"))return n;try{return Un(n)}catch{return decodeURIComponent(n.slice(7))}}a(Gn,"filePathFromUri");function Ke(n,e){if(n.startsWith("ssh://"))return n;let t=Be.relative(e,n);return t.length===0||t.startsWith("..")||Be.isAbsolute(t)?n:t.replaceAll(Be.sep,"/")}a(Ke,"displayFilePath");function z(n){if(n?.aborted===!0)throw Bn(n)}a(z,"throwIfAborted");function Bn(n,e){if(n.reason instanceof Error)return n.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}a(Bn,"abortReason");function gr(n,e){let t=n.split(`
|
|
5
|
-
`),{start:r,end:s}=e.selectionRange;return r.line!==s.line?!1:t[r.line]?.slice(r.character,s.character)===e.name}a(gr,"answeredFor");function et(n){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},r){r.signal?.throwIfAborted();let s=await n(r.cwd,t,r.signal);r.signal?.throwIfAborted();let o=await $(()=>Jn(t,r,s));if(!o)throw new Error("No diagnostic language server for this source");let{client:i,diagnostics:l,syntaxErrors:c,otherDiagnostics:d}=o;return e=i,{ok:!l.some(g=>g.severity==="error"),diagnostics:l,syntaxErrors:c,otherDiagnostics:d}},async restart(){e&&(await e.restart(),e=null)}}}a(et,"createLspCompiler");async function Jn(n,e,t){let r=await t.openFile(n,e.cwd,"diagnostics",e.signal);if(e.signal?.throwIfAborted(),!r)return null;let s=await oe(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(Jn,"openAndDiagnose");import Xn from"node:path";function Lr(n){let e=n.options?.lsp;return typeof e=="object"&&e!==null?e:void 0}a(Lr,"lspOptions");var Qn={resolveLspDeclaration:_e,readLspFileGraph:Ze,readLspSymbolGraph:Ye,searchSymbols:Ge};function _r(n,e,t=Qn){return{id:"lsp",supportsResultScope:!0,readResources:a(r=>Lr(r)===void 0?[]:void 0,"readResources"),toScriptData(r){let s=r;return s.mode==="calls"?{kind:"custom",resolverId:"lsp",value:{calls:s.text}}:s.data},tryResolve(r,s){return $(async()=>{let o=Lr(r);if(o===void 0)return{kind:"not-handled"};if([o.query,o.declaration,o.calls].filter(u=>u!==void 0).length!==1)return{kind:"failed",error:new Error("Pass exactly one of query, declaration or calls.")};if(o.calls!==void 0){let u=V(`graph:${o.calls}`,"graph");if(u===void 0)throw new Error("calls requires a file path.");let w=N(u.path,s.cwd),b=await n(s.cwd,w,s.signal);return{kind:"resolved",payload:{mode:"calls",text:u.selector===void 0?await t.readLspFileGraph(b,w,s.cwd,s.signal):await t.readLspSymbolGraph(b,w,u.selector,s.cwd,s.signal)}}}if(o.declaration!==void 0){let u=o.declaration.includes("#")?V(`symbol:${o.declaration}`,"symbol"):void 0;if(u?.selector===void 0)throw new Error("declaration requires file#selector, such as src/app.ts#App/start.");let w=N(u.path,s.cwd),b=u.selector,R=a(async S=>{let M=await n(s.cwd,w,S),D=await t.resolveLspDeclaration(M,w,b,s.cwd,S);return structuredClone(Kn(D.source,D.content,D.range))},"resolve"),C=await R(s.signal),L=await e({request:r,matches:[C],complete:!0,refresh:a(S=>$(async()=>({matches:[await R(S)],complete:!0})),"refresh")},s);return{kind:"resolved",payload:{mode:"declaration",sessionId:L.id,selector:o.declaration,match:C,data:Ee([C],!0,L.id,L)}}}let l=(o.query??"").trim();if(l.length===0)return{kind:"failed",error:new Error("query must not be empty")};let c=o.references===!0,d=s.scope,g=new Map;if(d!==void 0){await K(d,s.signal);for(let u of d.targets){let w=await n(s.cwd,u.source,s.signal),b=g.get(w)??[];b.push(u),g.set(w,b)}}else g.set(await n(s.cwd,r.path,s.signal),[]);let m=r.limit??100,y=a(async u=>{let w=[],b=d?.complete??!0;for(let[R,C]of g){let L=await t.searchSymbols(l,R.workspaceRoot,m,u,{...r.path===void 0?{}:{path:r.path},...r.include===void 0?{}:{include:r.include},...r.exclude===void 0?{}:{exclude:r.exclude},...c?{navigation:"references"}:{},...d===void 0?{}:{resultScope:{targets:C,complete:d.complete}}},R);w.push(...L.hits),b=b&&L.complete}return d!==void 0&&await K(d,u),structuredClone({hits:w.slice(0,m),complete:b&&w.length<=m})},"collect"),p=await y(s.signal),f=await e({request:r,matches:p.hits,complete:p.complete,refresh:a(u=>$(async()=>{let w=await y(u);return{matches:w.hits,complete:w.complete}}),"refresh")},s),h=Ee(p.hits,p.complete,f.id,f);return{kind:"resolved",payload:{mode:"symbols",sessionId:f.id,hits:p.hits,complete:p.complete,references:c,data:{...h,matches:h.matches.map((u,w)=>({...u,role:p.hits[w]?.role,symbol:p.hits[w]?.symbol}))}}}})},renderResult(r,s,o){let i=r.details;return i.mode==="calls"?new de({summary:i.text.split(`
|
|
6
|
-
`,1)[0]??"Calls",rows:i.text.split(`
|
|
7
|
-
`).slice(1).map(l=>({kind:"note",text:l}))},o,s.expanded):i.mode==="declaration"?Ce([i.match],!0,o,s.expanded,i.cwd,[],[i.selector]):Ce(i.hits,i.complete,o,s.expanded,i.cwd,i.references?["LSP reference navigation \xB7 may leave input scope"]:[],i.hits.map(l=>`${l.role} ${l.symbol.name}`))},format(r,s){let o=r,i=a(d=>d.startsWith("ssh://")?d:Xn.relative(s.cwd,d),"display");if(o.mode==="calls")return{content:[{type:"text",text:o.text}],details:o};if(o.mode==="declaration"){let{match:d}=o,g=d.endLineNumber??d.lineNumber,m=g>d.lineNumber&&d.endColumn===0?g-1:g;return{content:[{type:"text",text:[`SEARCH#${o.sessionId}:1:match ${i(d.source)}:${d.lineNumber}-${m} declaration ${o.selector}`,d.matchedText.replace(/\r?\n$/u,"")].join(`
|
|
8
|
-
`)}],details:{...o,cwd:s.cwd}}}let l=o.references?"LSP reference navigation (may leave input scope)":"LSP symbols inside scope",c=o.hits.length===0?["No symbols found."]:o.hits.slice(0,100).map((d,g)=>`SEARCH#${o.sessionId}:${g+1}:match ${i(d.source)}:${d.lineNumber}:${d.startColumn+1} ${d.role} ${d.symbol.name} \xB7 declared at ${i(d.symbol.source)}:${d.symbol.range.startLine}:${d.symbol.range.startColumn+1}`);return o.complete&&o.hits.length&&c.unshift(`SEARCH#${o.sessionId}:all:match selects all exact symbol matches.`),o.hits.length>100&&c.push("Preview shortened; full source targets retained."),{content:[{type:"text",text:[l,...c].join(`
|
|
9
|
-
`)}],details:{...o,cwd:s.cwd}}}}}a(_r,"createLspSearchResolver");function Kn(n,e,t){let r=e.split(`
|
|
10
|
-
`),s=r.map(y=>y.replace(/\r$/u,"")),o=[0];for(let y of r)o.push((o.at(-1)??0)+y.length+1);let i=t.start.line,l=t.end.line+1<r.length,c=l?t.end.line+1:t.end.line,d=l?0:(s[t.end.line]??"").length,g=o[i]??e.length,m=Math.min(e.length,(o[c]??e.length)+d);return{source:n,lineNumber:i+1,startColumn:0,...c===i?{}:{endLineNumber:c+1},endColumn:d,matchedText:e.slice(g,m),lineText:s[i]??""}}a(Kn,"declarationMatch");import{Type as k}from"typebox";var Yn=k.Object({query:k.Optional(k.String({minLength:1,description:"Symbol name to find in the workspace."})),declaration:k.Optional(k.String({minLength:1,description:"file#selector, such as src/app.ts#App/start: returns that declaration as an editable selection."})),calls:k.Optional(k.String({minLength:1,description:"file or file#selector: references and incoming/outgoing calls."})),path:k.Optional(k.Union(st.anyOf,{description:"For query: file, directory, unchanged Read/Search/edit result, its UUID, or an array of such results."})),references:k.Optional(k.Boolean({description:"For query: also follow symbols found inside path to their references outside it."})),include:k.Optional(k.String({description:"Include glob for query"})),exclude:k.Optional(k.String({description:"Exclude glob for query"})),limit:k.Optional(k.Integer({minimum:1,maximum:1e3,description:"Maximum matches (default 100)."}))},{additionalProperties:!1});async function Pr(n,e){let t;e.then(r=>t=r),n.registerTool(mt({name:"lsp_search",label:"lsp_search",exposure:"direct",namespace:{name:"ide_lsp_search",description:"Find code through language servers."},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:Yn,outputSchema:wt,renderCall(r,s,o){return pt(o.lastComponent,{tool:"lsp_search",primary:{text:r.query??r.declaration??r.calls??"",color:"accent",truncate:"end"},qualifiers:[...r.declaration===void 0?[]:[{text:"declaration"}],...r.calls===void 0?[]:[{text:"calls"}],...r.path===void 0?[]:[{text:typeof r.path=="string"?`in ${r.path}`:"in result scope",color:"accent",truncate:"start"}],...r.references===!0?[{text:"references",color:"warning"}]:[]],expanded:o.expanded},s)},renderResult(r,s,o,i){let l=r.details;if(t?.resolver.renderResult!==void 0&&l?.payload!==void 0&&!i.isError&&!s.isPartial)return t.resolver.renderResult({...r,details:l.payload},s,o,i);let c=r.content.flatMap(d=>d.type==="text"?[d.text]:[]).join(`
|
|
11
|
-
`);return new de({summary:i.isError?"lsp_search failed":"lsp_search",rows:c.split(`
|
|
12
|
-
`).map(d=>({kind:"note",text:d}))},o,s.expanded)},async execute(r,s,o,i,l){let c=s.query??s.declaration??s.calls,d=[s.query,s.declaration,s.calls].filter(p=>p!==void 0);if(c===void 0||d.length!==1)return Rr("Pass exactly one of query, declaration or calls.");let g={...s.query===void 0?{}:{query:s.query},...s.declaration===void 0?{}:{declaration:s.declaration},...s.calls===void 0?{}:{calls:s.calls},...s.references===!0?{references:!0}:{}};if(t===void 0)return Rr("lsp_search needs the Search module (search.core), which is not loaded.");let{api:m,resolver:y}=t;return await m.searchWith(y,{query:c,...s.path===void 0?{}:{path:s.path},...s.include===void 0?{}:{include:s.include},...s.exclude===void 0?{}:{exclude:s.exclude},...s.limit===void 0?{}:{limit:s.limit},options:{lsp:g}},{cwd:l.cwd,...o!==void 0&&{signal:o},...i!==void 0&&{onUpdate:i}})}},new gt))}a(Pr,"registerLspSearchTool");function Rr(n){return nt({content:[{type:"text",text:n}],details:{failure:{code:"INVALID_REQUEST",message:n}}},yt,{status:"error",errors:[rt(new Error(n),"SEARCH_FAILED")]})}a(Rr,"failure");function Er(n){return{id:"lsp-declaration-target",async tryResolve(e,t){let r=V(e,"symbol");if(r===void 0||e.endsWith("#name"))return{kind:"not-handled"};if(r.selector===void 0)return{kind:"rejected",rejection:{code:"invalid",reason:"Use symbol:<file>#<selector> to choose one declaration"}};try{let s=r.selector,o=await $(async()=>_e(await n(t.cwd,N(r.path,t.cwd),t.signal),N(r.path,t.cwd),s,t.cwd,t.signal));return{kind:"resolved",targets:[{source:o.source,expectedContent:o.content,ranges:[{start:{lineNumber:o.range.start.line+1,column:o.range.start.character},end:{lineNumber:o.range.end.line+1,column:o.range.end.character}}]}]}}catch(s){return t.signal?.aborted?{kind:"failed",error:s}:{kind:"rejected",rejection:{code:"invalid",reason:`${s instanceof Error?s.message:String(s)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`}}}}}}a(Er,"createDeclarationTargets");import{fileURLToPath as Zn}from"node:url";function Cr(n,e){if(n===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let t=new Map(Object.entries(n.changes??{}));for(let r of n.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(t.has(r.textDocument.uri))throw new Error("Rename returned duplicate document edits.");t.set(r.textDocument.uri,r.edits)}return t}a(Cr,"renameEntries");function xr(n,e){let t=n.split(`
|
|
13
|
-
`),r=t[e.line];if(!Number.isInteger(e.line)||e.line<0||r===void 0||!Number.isInteger(e.character)||e.character<0||e.character>r.replace(/\r$/u,"").length)throw new Error("The language server returned an invalid text position.");return t.slice(0,e.line).reduce((s,o)=>s+o.length+1,0)+e.character}a(xr,"offset");function Ir(n,e){return $(()=>es(n,e))}a(Ir,"prepareSymbolRename");async function es(n,e){let t=n.input;if(typeof t.path!="string"||!t.path.startsWith("symbol:")||!t.path.endsWith("#name"))return;if(typeof t.text!="string"||t.text.trim()===""||t.start!==void 0||t.end!==void 0)throw new Error("Rename needs a symbol #name path and a non-empty new name in text, without start/end.");let r=V(t.path.slice(0,-5),"symbol");if(r?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let s=N(r.path,n.cwd),o=await e(n.cwd,s,n.signal),i=await mr(o,s,r.selector,n.cwd,n.signal);await ze(i.client,i.uri,n.signal);let l=Cr(await we(i.client,i.uri,i.position,t.text),i.client),c=new Map;for(let m of new Set([i.uri,...l.keys()])){n.signal?.throwIfAborted();let y=A(m,i.client.rootUri);if(y!==m)throw new Error("Rename returned a non-canonical participant. No edits applied.");let p=y.startsWith("ssh://")?y:Zn(y),f=await o.readSourceSnapshot(p,n.signal);if(p===s&&f.content!==i.content)throw new Error("The rename source changed. Read the symbol again before retrying.");let h=await o.openFile(p,n.cwd,"symbols",n.signal);if(h?.client!==i.client||h.uri!==m)throw new Error("A rename participant has a different language server owner. No edits applied.");if(i.client.documentContent(m)!==f.content)throw new Error("A rename participant changed during synchronization. No edits applied.");c.set(m,{file:p,...f})}let d=Cr(await we(i.client,i.uri,i.position,t.text),i.client);n.signal?.throwIfAborted();for(let[m,y]of c){n.signal?.throwIfAborted();let p=await o.readSourceSnapshot(y.file,n.signal);if(y.version!==p.version||i.client.documentContent(m)!==y.content)throw new Error("A rename participant changed during the server request. No edits applied.")}let g=[];for(let[m,y]of d){let p=c.get(m);if(!p)throw new Error("Rename discovered a new participant after preflight. No edits applied.");g.push({source:p.file,expectedContent:p.content,changes:y.map(f=>({from:xr(p.content,f.range.start),to:xr(p.content,f.range.end),insert:f.newText}))})}return{...n,editPlan:{files:g},metadata:{...n.metadata,semanticEdit:{mode:"lsp-rename",server:i.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}a(es,"prepareRename");async function rs(n){await ns(n)}a(rs,"registerLsp");async function ns(n,e){let t,r=new Promise(p=>t=p),s=new Map,o=new fe,i=!1,l=a(async(p,f=!1,h)=>{if(h?.throwIfAborted(),i)throw new Error("LSP session has ended");let u=JSON.stringify([p,f]),w=s.get(u);if(w?.controller.signal.aborted)return await j(w.promise.catch(()=>{}),h),s.get(u)===w&&s.delete(u),l(p,f,h);if(!w){w=new ee(async R=>{let C=e?await e.loadRegistry(p,f,R):await os(p,f,R),L=await ss(n,p);if(R.throwIfAborted(),i)throw new Error("LSP session has ended");return X.init(C,e?.workspace(p),{idleTimeoutMs:L,sharedServers:o})});let b=w;s.set(u,b),b.promise.catch(()=>{s.get(u)===b&&s.delete(u)})}return w.wait(h)},"managerFor"),c=a(async(p,f,h)=>{if(h?.throwIfAborted(),e)return e.resolveProject(p,f,h);let u=await Ot(f,p,"lsp-servers",Z,h);return h?.throwIfAborted(),u===void 0?void 0:{cwd:u,external:u!==ts.resolve(f)}},"resolveLspProject"),d=a(async(p,f,h)=>{if(h?.throwIfAborted(),!f)return l(p,!1,h);let u=await c(f,p,h);if(h?.throwIfAborted(),!u)throw new Error("No language server project for this source");return l(u.cwd,u.external,h)},"managerForFile"),g={...et(d),name:"pi-agent-ide-lsp",priority:200},m={protocol:kt,apiVersion:5,id:"lsp",setup(p){p.addTool(g),p.addDiagnosticSource(Vt(l,c))}};n.on("session_shutdown",async()=>{i=!0,await Promise.allSettled([...s.values()].map(async p=>{p.settled||p.controller.abort(new Error("LSP session has ended")),await(await p.promise).shutdownAll()})),s.clear()});let y={protocol:ot,apiVersion:it,id:"lsp",setup(p){p.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:It()})}};await Promise.all([Dt(n,m),Pt(n,{protocol:lt,apiVersion:dt,id:"lsp-declarations",setup(p){p.onDidEdit(async f=>{await Promise.all([...s.values()].filter(h=>h.settled).map(h=>h.promise.then(u=>u.syncEditedSource(f.source,f.after.content),()=>{})))}),p.addAnchorResolver({kind:ut,type:"auxiliary",resolver:{id:"lsp-declaration",description:"symbol:<file>#<selector> selects an exact declaration for text fallback editing; imports and references are not rewritten.",renderFull:a(f=>f,"renderFull"),renderCompact:a(f=>f,"renderCompact"),tryResolve:a(()=>Promise.resolve({kind:"not-handled"}),"tryResolve")},resources:Er(d),describeInPrompt:!1});for(let f of["copy","move","delete","replace"])p.tool(f).describeField("path","symbol:<file>#<selector> selects one declaration without start; imports and references are not updated."+(f==="replace"?" symbol:<file>#<selector>#name renames it, with the new name in text.":"")),f==="replace"&&p.tool(f).describe("Use replace with a symbol:\u2026#name path to rename a symbol across the project."),p.tool(f).addHandler({stage:"text-pre-edit",async handler(h){if(f==="replace"){let b=await Ir(h,d);if(b!==void 0)return b}let u=h.input;if(![u.path,u.start,u.end,u.target,u.targetStart,u.targetEnd].some(b=>typeof b=="string"&&b.startsWith("symbol:")))return h;if((f==="copy"||f==="move")&&typeof u.target!="string")throw new Error("Copying or moving a symbol requires an explicit target file and destination anchor.");return{...h,metadata:{...h.metadata,semanticEdit:{mode:"declaration-text",referencesUpdated:!1,importsUpdated:!1},diffStatuses:[{text:"Text fallback: imports and references unchanged",tone:"warning"}]}}}});p.tool("insert").describeField("anchor","Symbol targets are not supported."),p.tool("insert").addHandler({stage:"text-pre-edit",handler(f){let h=f.input;if([h.path,h.anchor].some(u=>typeof u=="string"&&u.startsWith("symbol:")))throw new Error("Semantic insert is not supported. Get the declaration with lsp_search and use an explicit text line anchor instead.");return f}})}}),at(n,y),Lt(n,or),vt(n,{protocol:ht,apiVersion:ft,id:"lsp-search",setup(p){t({api:p,resolver:_r(d,p.registerSelection)})}}),Pr(n,r)])}a(ns,"registerLspWithOwner");async function ss(n,e){try{let{value:t}=await Ct(n.events,ue,e);if(typeof t!="string")throw new Error(`Invalid ${ue} setting`);return Ie(t)}catch(t){if(t instanceof Error&&"code"in t&&t.code===Et)return Ie("");throw t}}a(ss,"readIdleTimeoutMs");async function os(n,e,t){let r=e?n:process.env.PI_AGENT_IDE_CONFIG_DIR??n;return W.fromPackageDir(r,{signal:t,includeGlobal:!e,requireBuiltInEvidence:e,recipes:Z})}a(os,"loadRegistry");export{Z as a,W as b,rs as c,ns as d};
|
package/dist/chunk-BRJIXNFU.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as z,d as g,f as _,g as U,h as M,i as w,j as O}from"./chunk-HFCHOFLV.js";import{d as L}from"./chunk-5AROEOJB.js";import{a as H}from"./chunk-47SPPIXK.js";import{a as k,b as B}from"./chunk-VAXLSPPU.js";import{a as $}from"./chunk-2YO6RVX4.js";import{b as I,c as W}from"./chunk-MLFJU2US.js";import{d as C}from"./chunk-LY2UANKU.js";import{a as T}from"./chunk-2DSY4U73.js";import{a as x,b as P}from"./chunk-H6FEBUAP.js";import{I as A,o as E}from"./chunk-SIYPD5MM.js";import{e as F}from"./chunk-756K3LJY.js";import{a}from"./chunk-EI7MMDWY.js";import{constants as J}from"node:fs";import{access as K}from"node:fs/promises";import y from"node:path";var Q=["google-chrome-stable","google-chrome","chromium","chromium-browser"],X=["/usr/bin/google-chrome-stable","/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser","/opt/google/chrome/chrome"];function D(e={}){let t;return{async load(r,n){t??=v(e.executablePath,e.environment??process.env);let o=await t;n.signal?.throwIfAborted();let{chromium:i}=await import("playwright-core");n.signal?.throwIfAborted();let s=await i.launch({executablePath:o,headless:!0,chromiumSandbox:!1,timeout:n.timeoutMs}),l=a(()=>{s.close()},"closeOnAbort");n.signal?.addEventListener("abort",l,{once:!0});try{n.signal?.throwIfAborted();let c=await s.newPage(),u=await c.goto(r.href,{timeout:n.timeoutMs,waitUntil:"domcontentloaded"});if(u!==null&&!u.ok())throw new Error(`HTTP ${u.status()}: ${u.statusText()}`);await c.waitForLoadState("networkidle",{timeout:Math.min(n.timeoutMs,1500)}).catch(()=>{}),n.signal?.throwIfAborted(),await Z(c);let d={html:await c.content(),source:c.url()};return n.signal?.throwIfAborted(),d}catch(c){throw n.signal?.aborted===!0?ee(n.signal):new Error(`Browser read failed for ${r.href}: ${re(c)}`,{cause:c})}finally{n.signal?.removeEventListener("abort",l),await s.close().catch(()=>{})}}}}a(D,"createSystemBrowserHtmlLoader");async function v(e=process.env.PI_AGENT_IDE_BROWSER_PATH,t=process.env){if(e!==void 0&&e.trim().length>0){let r=y.resolve(e);if(await R(r))return r;throw new Error(`PI_AGENT_IDE_BROWSER_PATH is not executable: ${r}`)}for(let r of(t.PATH??"").split(y.delimiter).filter(Boolean))for(let n of Q){let o=y.join(r,n);if(await R(o))return o}for(let r of X)if(await R(r))return r;throw new Error("No system Chrome or Chromium executable was found. Install Chrome/Chromium or set PI_AGENT_IDE_BROWSER_PATH.")}a(v,"resolveSystemBrowserExecutable");async function Z(e){await e.locator("body *").evaluateAll(t=>{for(let r of t.toReversed()){let n=globalThis.getComputedStyle(r);(r.hasAttribute("hidden")||r.getAttribute("aria-hidden")==="true"||n.display==="none"||n.visibility==="hidden"||n.visibility==="collapse")&&r.remove()}})}a(Z,"removeHiddenElements");async function R(e){try{return await K(e,J.X_OK),!0}catch{return!1}}a(R,"isExecutable");function ee(e){return e.reason instanceof Error?e.reason:te()}a(ee,"abortReason");function te(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(te,"abortError");function re(e){return e instanceof Error?e.message:String(e)}a(re,"errorMessage");var N={protocol:I,apiVersion:W,id:"web-browser",setup(e){e.addCheck({id:"system-browser",title:"Browser web reads",async run(t){try{t.signal?.throwIfAborted();let r=t.workspace?await ne(t.workspace,t.signal):await F(await v(t.env.PI_AGENT_IDE_BROWSER_PATH,t.env),["--version"],t.cwd,t.env,t.signal);return t.signal?.throwIfAborted(),[r.ok?{status:"pass",message:"Chrome/Chromium is available",detail:r.detail}:{status:"warn",message:"Chrome/Chromium cannot start",detail:r.detail}]}catch(r){return t.signal?.throwIfAborted(),[{status:"warn",message:"Browser reads are unavailable",detail:r instanceof Error?r.message:String(r)}]}}})}};async function ne(e,t){if(!e.probeBrowser)throw new Error("Project owner does not provide a browser probe");return e.probeBrowser(t)}a(ne,"probeOwnerBrowser");var oe=4096;function V(e,t={}){let r=se(t);return{id:"web",async tryResolve(n,o){if(/^web:/iu.test(n)){let i=await t.owner?.tryResolve(n,o);return i!==void 0&&i.kind!=="not-handled"?i:{kind:"failed",error:new Error(`Target web execution is unavailable: ${n}`)}}return ae(n,e,r)}}}a(V,"createWebResolver");function se(e){let t=e.timeoutMs??3e4;if(!Number.isFinite(t)||t<=0)throw new TypeError("Web timeout must be a positive finite number");return{timeoutMs:t,fetchResource:e.fetch??globalThis.fetch,browser:e.browser??D(),autoBrowserFallback:e.autoBrowserFallback??!0}}a(se,"resolverSettings");function ae(e,t,r){let n;try{n=new URL(e)}catch(o){return we(e)?{kind:"failed",error:new TypeError(`Invalid HTTP source ${e}`,{cause:o})}:{kind:"not-handled"}}return n.protocol!=="http:"&&n.protocol!=="https:"?{kind:"not-handled"}:{kind:"resolved",resource:{source:n.href,read({signal:o}){return ie(n,t,r,o)}}}}a(ae,"resolveHttpSource");async function ie(e,t,r,n){let o=G(n,r.timeoutMs),i=!0;try{o.signal.throwIfAborted();let s=await r.fetchResource(e,{method:"GET",redirect:"follow",signal:o.signal,headers:{"User-Agent":"Mozilla/5.0 (compatible; Pi-LPT/1.0; +https://github.com/alexshpunt/sasha-pi)",Accept:"text/html,application/xhtml+xml,application/pdf,application/json,text/plain,image/*,*/*;q=0.8","Accept-Language":"en-US,en;q=0.5"}});if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let l=s.headers.get("content-type")??void 0;if(ue(l)&&!de(e)){let h=await me(s,oe,o.signal);return[{type:"text",text:fe(e,s,l,h)}]}let c=new Uint8Array(await s.arrayBuffer());o.signal.throwIfAborted();let d={source:s.url.length===0?e.href:s.url,bytes:c,...l!==void 0&&{mediaType:l}};i=ge(c,l);let m=await t.convert(d,{signal:o.signal});if(o.signal.throwIfAborted(),r.autoBrowserFallback&&i&&q(m))throw new Error("HTTP read returned empty HTML content");return m}catch(s){if(n?.throwIfAborted(),!r.autoBrowserFallback||!i)throw s;o.dispose();try{return await ce(e,t,r,n)}catch(l){throw n?.throwIfAborted(),new Error(`HTTP read failed (${j(s)}) and browser fallback failed: ${j(l)}`,{cause:l})}}finally{o.dispose()}}a(ie,"readWebContent");async function ce(e,t,r,n){let o=G(n,r.timeoutMs);try{o.signal.throwIfAborted();let i=await le(e,t,r,o.signal);if(o.signal.throwIfAborted(),q(i))throw new Error("Browser read returned empty content");return i}finally{o.dispose()}}a(ce,"readBrowserContent");async function le(e,t,r,n){let o=await r.browser.load(e,{signal:n,timeoutMs:r.timeoutMs});return n.throwIfAborted(),t.convert({source:o.source,bytes:new TextEncoder().encode(o.html),mediaType:"text/html; charset=utf-8"},{signal:n})}a(le,"loadAndConvertBrowser");function ue(e){if(e===void 0)return!1;let t=e.split(";",1)[0]?.trim().toLowerCase()??"";return!(t.startsWith("text/")||t.startsWith("image/")||t==="application/json"||t.endsWith("+json")||t==="application/xml"||t.endsWith("+xml")||t==="application/xhtml+xml"||t==="application/pdf")}a(ue,"isUnsupportedBinaryMediaType");function de(e){return/\.(?:avif|bmp|gif|jpe?g|pdf|png|webp)$/iu.test(e.pathname)}a(de,"hasSupportedDocumentExtension");async function me(e,t,r){if(e.body===null)return new Uint8Array;let n=e.body.getReader(),o=[],i=0;try{for(;i<t;){r.throwIfAborted();let c=await n.read();if(c.done)break;let u=t-i,d=c.value.subarray(0,u);if(o.push(d),i+=d.length,c.value.length>u)break}}finally{await n.cancel().catch(()=>{})}let s=new Uint8Array(i),l=0;for(let c of o)s.set(c,l),l+=c.length;return s}a(me,"readBoundedBody");function fe(e,t,r,n){let o=["Unsupported binary response","Read cannot convert this Content-Type. Showing response metadata and a byte preview, not document text.",`URL: ${e.href}`,`HTTP: ${t.status} ${t.statusText}`.trimEnd(),`Content-Type: ${r??"unknown"}`],i=t.headers.get("content-disposition"),s=i===null?void 0:he(i);s!==void 0&&o.push(`Filename: ${s}`);let l=t.headers.get("content-length");l!==null&&o.push(`Content-Length: ${l}`);let c=[...t.headers].filter(([u])=>!pe(u)&&u!=="content-type"&&u!=="content-length").sort(([u],[d])=>u.localeCompare(d)).map(([u,d])=>`${u}: ${d}`);return c.length>0&&o.push("","Headers:",...c),o.push("",`Preview: first ${n.length} bytes (hex).`,be(n)),o.join(`
|
|
2
|
-
`)}a(fe,"formatUnsupportedBinaryResponse");function he(e){let t=/filename\*=UTF-8''([^;]+)/iu.exec(e)?.[1];if(t!==void 0)try{return decodeURIComponent(t).replaceAll(/[\r\n]/gu,"")}catch{return t.replaceAll(/[\r\n]/gu,"")}return/filename=(?:"([^"]+)"|([^;]+))/iu.exec(e)?.slice(1).find(Boolean)?.trim()}a(he,"attachmentFilename");function pe(e){return["content-location","link","location","refresh","set-cookie"].includes(e.toLowerCase())}a(pe,"isSensitiveRedirectHeader");function be(e){if(e.length===0)return"(empty body)";let t=[];for(let r=0;r<e.length;r+=16){let n=e.subarray(r,r+16),o=[...n].map(s=>s.toString(16).padStart(2,"0")).join(" "),i=[...n].map(s=>s>=32&&s<=126?String.fromCodePoint(s):".").join("");t.push(`${r.toString(16).padStart(8,"0")} ${o.padEnd(47)} |${i}|`)}return t.join(`
|
|
3
|
-
`)}a(be,"formatHexPreview");function ge(e,t){let r=t?.split(";",1)[0]?.trim().toLowerCase();if(r==="text/html"||r==="application/xhtml+xml")return!0;let n=new TextDecoder("utf8").decode(e.subarray(0,1024));return/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu.test(n)}a(ge,"isHtml");function q(e){return e.every(t=>t.type==="text"&&t.text.trim().length===0)}a(q,"isEmptyTextContent");function G(e,t){let r=new AbortController,n=a(()=>{r.abort(ye(e))},"abortFromParent"),o=setTimeout(()=>{r.abort(ve(t))},t);return o.unref(),e?.aborted===!0?n():e?.addEventListener("abort",n,{once:!0}),{signal:r.signal,dispose(){clearTimeout(o),e?.removeEventListener("abort",n)}}}a(G,"createOperationSignal");function we(e){return/^https?:/iu.test(e)}a(we,"claimsHttpScheme");function ye(e){return e?.reason instanceof Error?e.reason:Re()}a(ye,"abortReason");function Re(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(Re,"abortError");function ve(e){let t=new Error(`Web read timed out after ${e}ms`);return t.name="TimeoutError",t}a(ve,"timeoutError");function j(e){return e instanceof Error?e.message:String(e)}a(j,"errorMessage");function Y(e){return{id:"web",readResources:a(t=>t.path!==void 0&&/^https?:/iu.test(t.path)?[t.path]:[],"readResources"),async tryResolve(t,r){let n=t.path;if(n===void 0||!/^(?:https?:|web:)/iu.test(n))return{kind:"not-handled"};if(t.include!==void 0||t.exclude!==void 0)return{kind:"failed",error:new Error("File include/exclude globs do not apply to a web page.")};let o=Ae(t),i=await e.tryResolve(n,r);if(i.kind!=="resolved")return i;if(i.resource.read===void 0)return{kind:"failed",error:new Error(`Cannot read ${n}`)};let s=await i.resource.read({signal:r.signal});if(s.some(m=>m.type!=="text"))return{kind:"failed",error:new Error(`Web search requires text content: ${n}`)};let l=s.map(m=>m.type==="text"?m.text:"").join(`
|
|
4
|
-
`),c=[],u=t.limit??50;for(let[m,h]of l.split(/\r\n|\n|\r/u).entries()){r.signal?.throwIfAborted();for(let f of h.matchAll(o)){if(f[0].length===0)continue;let p=f.index,b=p+f[0].length;if(!(t.wholeWord===!0&&(new RegExp("\\p{L}|\\p{N}|_","u").test(h[p-1]??"")||new RegExp("\\p{L}|\\p{N}|_","u").test(h[b]??"")))){if(c.length===u)return{kind:"resolved",payload:{source:n,matches:c,complete:!1}};c.push({source:n,lineNumber:m+1,startColumn:p,endColumn:b,matchedText:f[0],lineText:h})}}}let d=c.length===0&&_(t.query)?Se(l,n,t.query,r.signal):void 0;return{kind:"resolved",payload:{source:n,matches:c,complete:!0,...d===void 0?{}:{fuzzy:d}}}},toScriptData(t){let r=t;return{...L(r.matches,r.complete),...r.fuzzy===void 0?{}:{fuzzy:{...r.fuzzy,candidates:r.fuzzy.candidates.map(n=>w(n))}}}},renderResult(t,r,n){let o=t.details;return z(o.matches,o.complete,n,r.expanded,void 0,["Web page \xB7 read-only",...o.complete?[]:["Limit reached \xB7 incomplete results"]])},format(t){let r=t,n=r.matches.length===0?`No matches in ${r.source}`:`${r.matches.length}${r.complete?"":"+"} matches in ${r.source}${r.complete?"":" (limit reached)"}`,o=[n];r.fuzzy?.status==="skipped"&&o.push(`Possible-name fallback skipped: ${r.fuzzy.message}`),r.fuzzy?.candidates.length&&o.push("Possible names \u2014 spelling suggestions, not equivalent behavior.",...r.fuzzy.candidates.map(s=>O(w(s))));let i=Buffer.byteLength(n);for(let s of r.matches){let l=`${r.source}:${s.lineNumber}:${s.startColumn+1} ${Ee(s)}`;if(i+=Buffer.byteLength(l)+1,i>48*1024){o.push("Output shortened. Narrow the query or lower the limit.");break}o.push(l)}return{content:[{type:"text",text:o.join(`
|
|
5
|
-
`)}],details:r}}}}a(Y,"createWebSearchResolver");function Se(e,t,r,n){n?.throwIfAborted();let o=performance.now(),i=new U;if(i.addText(e),i.limited)return{status:"skipped",message:"name collection reached its byte or unique-name budget",candidates:[]};let s=[];for(let l of M(r,i.names)){if(n?.throwIfAborted(),performance.now()-o>g.timeoutMs)return{status:"skipped",message:"extra search reached its time budget",candidates:[]};let c=new RegExp(l.identifier.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),"gu"),u=[],d=!0,m=0;e:for(let[h,f]of e.split(/\r\n|\n|\r/u).entries()){if(performance.now()-o>g.timeoutMs)return{status:"skipped",message:"extra search reached its time budget",candidates:[]};n?.throwIfAborted();for(let p of f.matchAll(c)){let b=p.index,S=b+p[0].length;if(!(/[\p{L}\p{N}_$]/u.test(f[b-1]??"")||/[\p{L}\p{N}_$]/u.test(f[S]??""))){if(m+=Buffer.byteLength(f),u.length===g.matchesPerCandidate||m>g.verificationBytes){d=!1;break e}u.push({source:t,lineNumber:h+1,startColumn:b,endColumn:S,matchedText:p[0],lineText:f})}}}u.length>0&&s.push({...l,matches:u,complete:d})}return s.length===0?void 0:{status:"ready",candidates:s}}a(Se,"searchFuzzyText");function Ee(e){let t=Math.max(0,e.startColumn-64),r=Math.min(e.lineText.length,e.startColumn+192);return`${t>0?"\u2026":""}${e.lineText.slice(t,r)}${r<e.lineText.length?"\u2026":""}`}a(Ee,"previewMatch");function Ae(e){let t=e.query,r=t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t,n=t.startsWith("regex:")?t.slice(6):r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(n,e.caseSensitive===!0?"gu":"giu")}a(Ae,"searchPattern");var xe={provider:"web",capability:"read"},Pe=C({kind:"markdown",label:"WEB"});async function Te(e){await Ce(e)}a(Te,"registerWeb");async function Ce(e,t){let r=A(e,xe),n=V(r,{owner:t?.(r)}),o={protocol:x,apiVersion:P,id:"web",setup(s){s.addHandler({stage:"pre-read",handler(l){let c=l.request.path;if(c===void 0||!/^(?:https?:\/\/|web:ssh:\/\/)/iu.test(c)||!l.request.views?.some(d=>/^(?:image|sequence)(?::|$)/u.test(d)))return{kind:"continue",context:l};let u="Website image and sequence views are not supported. Omit these views to read website content.";return{kind:"return",result:{content:[{type:"text",text:u}],details:{source:c,resolvedBy:"web",failure:{code:"UNSUPPORTED_CAPABILITY",source:c,resolverId:"web",message:u}},isError:!0}}}}),s.addResolver({resolver:n,renderResult:Pe,preserveTruncatedOutput:!0}),s.describe({path:a(()=>E(t?"HTTP(S) URL \u2014 fetched locally; web:ssh://<target>/https://\u2026 \u2014 fetched on that SSH target.":"HTTP(S) URL \u2014 remote content.",r.listDescriptions()),"path")})}},i={protocol:k,apiVersion:B,id:"web",setup(s){s.addResolver({resolver:Y(n),priority:-100}),s.describe("HTTP(S) Search reuses converted page text for zero-result identifier spelling suggestions. Candidate groups carry the URL and line ranges, never editable SEARCH references.")}};await Promise.all([T(e,o),H(e,i),Promise.resolve($(e,N))])}a(Ce,"registerWebWithOwner");export{V as a,Te as b,Ce as c};
|
package/dist/chunk-C2GZLLSP.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{g as m,h as y,j as O,n as x,r as E}from"./chunk-SIYPD5MM.js";import{m as L,o as C}from"./chunk-S7E2D5K7.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as o}from"typebox";import{Value as f}from"typebox/value";import{Type as u}from"typebox";var R=u.Object({path:u.Optional(u.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:u.Optional(u.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:u.Optional(u.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:u.Optional(u.Array(u.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),j={path:"What to read: a path, URL, unchanged Read/Search result or its UUID, or one of the forms below. temp:<id> \u2014 saved output; raw:<file> \u2014 original bytes.",offset:"First line, from 1; negative counts from the end. For raw:, a byte offset.",limit:"Maximum lines. For raw:, bytes.",views:"Extra presentations; combine them unless a view says otherwise."};function de(e){let t=s((a,r)=>({...a,description:[j[r],e[r]].filter(d=>d!==void 0).join(`
|
|
2
|
-
`)}),"describe");return{...R,properties:{path:t(R.properties.path,"path"),offset:t(R.properties.offset,"offset"),limit:t(R.properties.limit,"limit"),views:t(R.properties.views,"views")}}}s(de,"describeReadParameters");import{Type as n}from"typebox";function Re(e,t,a,r){if(!K(e))return{content:e,source:t,resolvedBy:a,preserveTruncatedOutput:r.preserveTruncatedOutput,textMode:r.textMode,contentKind:"other"};let d=e[0].text;return{content:e,source:t,resolvedBy:a,preserveTruncatedOutput:r.preserveTruncatedOutput,textMode:r.textMode,contentKind:"text",text:L(t,d)}}s(Re,"createReadState");function ye(e,t,a){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return H({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content. Omit offset and limit to read this content without a line range."});let l=q(e.content);return{script:{kind:"native",source:e.source,blocks:e.content},content:l.content,details:{...k(e),...l.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:l.unsupportedContentBlocks}}}}let r=e.text.lines.length,d=$(t,r,a?.originLine),i=e.text.lines.slice(d.startIndex,d.endIndex),c=d.endIndex<r,b=e.textMode==="final"||i.every(l=>l.presentation===void 0),T=b?M(i,c):C({...e.text,lines:i.map((l,_)=>({...l,lineEnding:_===i.length-1&&c?"":l.lineEnding}))}),S=e.content[0],B=[{type:"text",text:T,...S.textSignature!==void 0&&{textSignature:S.textSignature}}];return{script:{kind:"text",...e.text.references===void 0?{}:{references:e.text.references},source:e.source,content:b&&!c?T:i.map(l=>l.content+l.lineEnding).join(""),lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:r},content:B,details:{...k(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:r,lines:i}}}s(ye,"projectReadState");function M(e,t){return e.map((a,r)=>`${a.content}${r===e.length-1&&t?"":a.lineEnding}`).join("")}s(M,"renderFinalTextLines");function v(e){let t=e.cause,a,r=new Set;for(;t instanceof Error&&!r.has(t);)r.add(t),a=t,t=t.cause;return a}s(v,"deepestCause");var w="Supply path with a source or an unchanged result reference.",P=s(e=>`Read ${JSON.stringify(e)} with views=["anchors"] and choose a current anchor.`,"fragmentRecovery");function N(e){return e.candidates?.length?["Possible matches:",...e.candidates.map(t=>`- ${JSON.stringify(t.path)}`),"","Retry read with an exact candidate path."]:[]}s(N,"candidateLines");function D(e){let t=v(e),a=t!==void 0&&"code"in t?t.code:void 0,r=[];return a==="ENOENT"&&!e.candidates?.length&&r.push("Search for the correct path."),e.code==="INVALID_REQUEST"?r.push(w):e.code==="FRAGMENT_FAILED"&&e.source!==void 0?r.push(P(e.source)):e.code==="NO_RESOLVER"?r.push("Choose a supported source from the path parameter."):e.code==="NO_FRAGMENT_RESOLVER"&&r.push("Read the source without the anchor."),[...r,...N(e)]}s(D,"readFailureRecovery");function V(e){let t=v(e),a=t!==void 0&&"code"in t?t.code:void 0,r=t?.message||e.message;return a==="ENOENT"?r=e.candidates?.length?"Source not found.":"Source not found. Search for the correct path.":a==="EACCES"||a==="EPERM"?r="Access denied.":e.code==="INVALID_RESOLVER_RESULT"?r="The source provider returned an invalid result.":e.code==="INVALID_RESOURCE_CONTENT"?r="The source provider returned invalid content.":e.code==="UNSUPPORTED_CAPABILITY"?r="This source does not support reading.":e.code==="NO_RESOLVER"?r="This source is not supported. Choose a supported source from the path parameter.":e.code==="NO_FRAGMENT_RESOLVER"&&(r="This anchor is not supported. Read the source without the anchor."),e.code==="INVALID_REQUEST"?r+=`. ${w}`:e.code==="FRAGMENT_FAILED"&&e.source!==void 0&&(r+=`
|
|
3
|
-
${P(e.source)}`),`Read failed${e.source===void 0?"":` for ${JSON.stringify(e.source)}`}: ${r}`}s(V,"readFailureMessage");function ge(e,t,a){if(!a?.aborted||!e.isError)return e;let r=e.details.source??e.details.failure?.source??t;return{...e,content:[{type:"text",text:`Read cancelled${r===void 0?"":` for ${JSON.stringify(r)}`}. No completed result was returned.`}]}}s(ge,"withReadCancellation");function H(e){let t=e.cause instanceof y?e.cause:void 0;return t!==void 0?e={...e,source:e.source??t.source,message:`${t.code}: ${e.source??t.source}`,cause:new y(t.code,t.source,t.effect,{metadata:m(t)})}:e.cause instanceof Error&&"code"in e.cause&&!["ENOENT","EACCES","EPERM"].includes(String(e.cause.code))&&(e={...e,message:`${e.code}: ${e.source??"source"}`,cause:void 0}),{content:[{type:"text",text:[V(e),...e.candidates?.length?["",...N(e)]:[]].join(`
|
|
4
|
-
`)}],details:{failure:e},isError:!0}}s(H,"failureResult");function k(e){return{source:e.source,resolvedBy:e.resolvedBy}}s(k,"readDetails");function q(e){let t=[],a=[];for(let[d,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}a.push({index:d,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${d}]`})}let r=a[0];return{content:t,...r!==void 0&&{unsupportedContentBlocks:[r,...a.slice(1)]}}}s(q,"projectAgentContent");function $(e,t,a){let r=e.offset===void 0?1:Math.trunc(e.offset),d=G(r,t,a),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,d-1),endIndex:Math.min(t,d-1+i)}}s($,"resolveTextRange");function G(e,t,a){if(a===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let r=e<0?a+e:a+Math.max(1,e)-1;return Math.max(1,r)}s(G,"anchoredStartLine");function K(e){return e.length===1&&e[0].type==="text"}s(K,"isSingleTextContent");var W=n.Object({value:n.String(),kind:n.String(),state:n.Optional(n.String())},{additionalProperties:!1}),J=n.Object({lineNumber:n.Integer(),content:n.String(),lineEnding:n.String(),anchors:n.Optional(n.Array(n.String()))},{additionalProperties:!1}),z=n.Object({path:n.String(),offset:n.Integer()},{additionalProperties:!1}),h={source:n.String(),truncated:n.Boolean(),continuation:n.Optional(z),fullResult:n.Optional(n.String())},A=n.Object({...h,kind:n.Literal("text"),target:n.Optional(n.String()),lines:n.Array(J),startLine:n.Integer(),endLine:n.Integer(),totalLines:n.Integer(),references:n.Optional(n.Array(W))},{additionalProperties:!1}),I=n.Object({...h,kind:n.Literal("bytes"),bytes:n.Array(n.Integer({minimum:0,maximum:255})),byteOffset:n.Integer(),byteLength:n.Integer(),totalBytes:n.Integer()},{additionalProperties:!1}),Q=n.Union([n.Object({type:n.Literal("text"),text:n.String()},{additionalProperties:!1}),n.Object({type:n.Literal("image"),mimeType:n.String()},{additionalProperties:!1})]),F=n.Object({...h,kind:n.Literal("native"),blocks:n.Array(Q)},{additionalProperties:!1}),g=n.Union([n.Object({kind:n.Literal("recovery"),source:n.String(),candidates:n.Array(n.Object({path:n.String()},{additionalProperties:!1}))},{additionalProperties:!1}),A,I,F,n.Object({kind:n.Literal("resources"),source:n.Optional(n.String()),resources:n.Array(n.Union([A,I,F])),truncated:n.Boolean(),fullResult:n.Optional(n.String())},{additionalProperties:!1})]),Y=O(g);function X(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}s(X,"publicLine");function U(e){if(e.kind==="resources"){let i=e.resources.map(c=>U(c));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:i,truncated:i.some(c=>typeof c=="object"&&c!==null&&"truncated"in c&&c.truncated===!0)}}if(e.kind==="bytes"){let i=e.bytes.slice(0,32768),c=e.truncated===!0||i.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:i,byteOffset:e.byteOffset,byteLength:i.length,totalBytes:e.totalBytes,truncated:c,...e.byteOffset+i.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+i.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(i=>{if(i.type==="text")return{type:i.type,text:i.text};if(i.type==="image")return{type:i.type,mimeType:i.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let t=[],a=0;for(let i of e.lines){let c=X(i);if(a+=Buffer.byteLength(JSON.stringify(c)),t.length>=2e3||a>512*1024)break;t.push(c)}if(t.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let r=t.length<e.lines.length,d=t.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,...e.target===void 0?{}:{target:e.target},lines:t,startLine:t[0]?.lineNumber??0,endLine:t.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:r,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...r||d<e.totalLines?{continuation:{path:e.source,offset:d+1}}:{}}}s(U,"publicData");function Z(e){let t=e.details.failure,a=t?.cause instanceof y?t.cause:void 0,r=a===void 0?void 0:m(a);if(e.isError||t!==void 0)return x(e,g,{status:"error",...t?.candidates?.length&&t.source!==void 0?{data:{kind:"recovery",source:t.source,candidates:t.candidates}}:{},errors:[{code:a?.code??t?.code??"READ_FAILED",message:a===void 0?[t?.message??"Read failed",...t===void 0?[]:D(t)].join(`
|
|
5
|
-
`):`${a.code}: ${t?.source??a.source}`,...t?.source===void 0?{}:{source:t.source},...r===void 0?{}:{metadata:r}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let d=U(e.script);return x(e,g,{status:"success",data:e.details.temporarySource!==void 0&&typeof d=="object"&&d!==null?{...d,fullResult:e.details.temporarySource}:d,errors:[]})}catch(d){return x(e,g,{status:"error",errors:[{code:d instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:d instanceof Error?d.message:String(d)}]})}}s(Z,"structuredRead");var p=o.Function([],o.Unknown()),ee=o.Object({resolver:o.Unknown(),matchesCall:o.Optional(p),renderCall:o.Optional(p),priority:o.Optional(o.Number()),renderResult:o.Optional(p),preserveTruncatedOutput:o.Optional(o.Boolean())}),te=o.Object({resolver:o.Unknown(),priority:o.Optional(o.Number())}),ne=o.Object({id:o.String({pattern:"\\S"}),priority:o.Optional(o.Number()),resolve:p}),re=o.Object({view:o.String({pattern:"\\S"}),contentKind:o.Optional(o.Union([o.Literal("text"),o.Literal("any")])),includes:o.Optional(o.Array(o.String({pattern:"\\S"}))),showsLinesOutsideRange:o.Optional(o.Boolean()),presenter:o.Object({id:o.String(),present:p}),priority:o.Optional(o.Number())}),oe=o.Object({resolvedBy:o.String({pattern:"\\S"}),contentKind:o.Union([o.Literal("text"),o.Literal("any")])}),ae=o.Union([o.Object({stage:o.Literal("pre-read"),handler:p}),o.Object({stage:o.Literal("read"),when:oe,handler:p}),o.Object({stage:o.Literal("post-read"),handler:p})]);function Ce(e){if(!f.Check(te,e))return!1;let t=e,a=t.resolver;return typeof a.id=="string"&&a.id.length>0&&typeof a.tryResolve=="function"&&(!("priority"in t)||typeof t.priority=="number")}s(Ce,"isTextTargetResolverRegistration");function ke(e){if(!f.Check(ee,e))return!1;let t=e;return E(t.resolver)?t.resolver.id!=="any"&&(!("priority"in t)||typeof t.priority=="number")&&(!("matchesCall"in t)||typeof t.matchesCall=="function")&&(!("renderCall"in t)||typeof t.renderCall=="function")&&"matchesCall"in t=="renderCall"in t&&(!("renderResult"in t)||typeof t.renderResult=="function"):!1}s(ke,"isResourceResolverRegistration");function ve(e){return f.Check(ae,e)}s(ve,"isReadHandlerRegistration");function we(e){return f.Check(re,e)}s(we,"isReadViewRegistration");function Pe(e){return f.Check(ne,e)}s(Pe,"isFragmentResolverRegistration");function Ne(e){return ie(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}s(Ne,"isReadFragmentResolution");function ie(e){return typeof e=="object"&&e!==null}s(ie,"isRecord");export{R as a,de as b,Re as c,ye as d,ge as e,H as f,$ as g,G as h,g as i,Y as j,Z as k,Ce as l,ke as m,ve as n,we as o,Pe as p,Ne as q};
|
package/dist/chunk-ECSMTGVM.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as Z}from"./chunk-K5M65CAF.js";import{a as ee}from"./chunk-P7FUD4WY.js";import{c as J}from"./chunk-HFCHOFLV.js";import{m as k}from"./chunk-S7E2D5K7.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as me}from"node:crypto";import{open as Be,readFile as Pe}from"node:fs/promises";import x from"node:path";import{spawn as Re}from"node:child_process";import{stat as Ce}from"node:fs/promises";import E from"node:path";import{createInterface as ke}from"node:readline";function z(e,t=!1){let n=O(e);return L(n)?_($(new I(e,n).parse(),t)):t?e:G(e)}u(z,"compileSearchQuery");function Q(e,t=!1){let n=O(e);return L(n)?$(new I(e,n).parse(),t):void 0}u(Q,"compileSearchCondition");function A(e,t){if(e.kind==="term")return t(e.value);let n=A(e.left,t);if(e.kind==="or")return n||A(e.right,t);let r=A(e.right,t);return n&&(e.kind==="not"?!r:r)}u(A,"satisfiesSearchCondition");function ne(e){if(L(O(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(G).join("|")})`:void 0}u(ne,"compileSearchFallbackQuery");function L(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}u(L,"containsBooleanSyntax");var I=class{static{u(this,"BooleanQueryParser")}#e;#r;#s=0;constructor(t,n){this.#e=t,this.#r=n}parse(){let t=this.#o(),n=this.#t();if(n.type!=="end"){let r=n.type==="right"?"unexpected ')'.":`unexpected ${Te(n)}.`;throw R(n.offset,r)}return t}#o(){let t=this.#n();for(;this.#t().type==="or";){let n=this.#i(),r=this.#a(`after ${n.value}`);t={kind:"or",left:t,right:this.#c(r)}}return t}#n(){return this.#c(this.#a())}#c(t){let n=t;for(;;){let r=this.#t();if(r.type==="and"||r.type==="not"){this.#i();let o=this.#a(`after ${r.value}`);n={kind:r.type,left:n,right:o};continue}if(r.type==="term"||r.type==="left"){n={kind:"and",left:n,right:this.#a()};continue}return n}}#a(t){let n=this.#t();if(n.type==="term")return this.#i(),{kind:"term",value:n.value,quoted:n.quoted};if(n.type==="left"){if(this.#i(),this.#t().type==="right"||this.#t().type==="end")throw R(this.#t().offset,"expected a term after '('.");let o=this.#o();if(this.#t().type!=="right")throw R(this.#t().offset,"expected ')'.");return this.#i(),o}if(t===void 0&&(n.type==="and"||n.type==="or"||n.type==="not"))throw R(n.offset,`expected a term before ${n.value}.`);let r=t===void 0?"":` ${t}`;throw R(n.offset,`expected a term${r}.`)}#t(){return this.#r[this.#s]??{type:"end",value:"",offset:this.#e.length}}#i(){let t=this.#t();return this.#s+=1,t}};function O(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(/\s/u.test(r)){n+=1;continue}if(r==="("&&xe(e,n)){t.push({type:"left",value:r,offset:n}),n+=1;continue}if(r===")"){t.push({type:"right",value:r,offset:n}),n+=1;continue}if(te(e,n)){let i=e.charAt(n+1)==="|"?2:1;t.push({type:"or",value:e.slice(n,n+i),offset:n}),n+=i;continue}if(r==="'"||r==='"'){let i=n,c=r,s="";for(n+=1;n<e.length&&e.charAt(n)!==c;)e.charAt(n)==="\\"&&(e.charAt(n+1)===c||e.charAt(n+1)==="\\")&&(n+=1),s+=e.charAt(n++);if(n>=e.length)throw R(i,`unterminated ${c==="'"?"single":"double"}-quoted term.`);if(n+=1,s.length===0)throw R(i,"quoted terms must not be empty.");t.push({type:"term",value:s,offset:i,quoted:!0});continue}let o=n;for(;n<e.length;){let i=e.charAt(n);if(/\s/u.test(i)||i===")"||te(e,n))break;i==="\\"&&n+1<e.length?n+=2:i==="["||i==="("?n=U(e,n)??n+1:n+=1}let a=e.slice(o,n);t.push({type:we(a),value:a,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}u(O,"tokenize");function te(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}u(te,"isBooleanPipe");function U(e,t){let n=e.charAt(t)==="["?"]":")",r=t+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===n)return r+1;if(n===")"&&(o==="("||o==="[")){let a=U(e,r);if(a===void 0)return;r=a}else r+=1}}}u(U,"regexBlockEnd");function xe(e,t){let n=U(e,t);if(n===void 0)return!0;let r=e.slice(t+1,n-1);return r.trim().length===0?!0:L(O(r))}u(xe,"isBooleanGroup");function we(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}u(we,"operatorType");function Te(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}u(Te,"quoteToken");function R(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}u(R,"syntaxError");function $(e,t){return e.kind==="term"?{kind:"term",value:t&&!e.quoted?e.value:G(e.value)}:{kind:e.kind,left:$(e.left,t),right:$(e.right,t)}}u($,"compileTerms");function _(e){if(e.kind==="term")return e.value;let t=_(e.left);return e.kind==="not"?t:`(?:${t}|${_(e.right)})`}u(_,"matchPattern");function G(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}u(G,"escapeRegex");function ie(e){if(e.multiline===!0){if(e.condition!==void 0)throw new Error("Boolean conditions check single lines and cannot be combined with multiline. Use one regex with multiline instead.");return}if(/\r|\n/u.test(e.query))throw new Error("A pattern with line breaks requires multiline: true.")}u(ie,"assertSupportedPattern");function se(e){return e.multiline===!0?["--multiline","--multiline-dotall"]:[]}u(se,"multilineArguments");async function K(e,t,n,r,o){if(e.query.length===0)throw new Error("Search query must not be empty.");return ie(e),e.condition!==void 0?ae(e,(a,i)=>re(a,t,n,i,void 0,o),n):re(e,t,n,void 0,r,o)}u(K,"searchText");async function ve(e,t,n,r){if(n===void 0&&(e.path?.includes("://")||t.includes("://")))throw new Error("No search environment owns this scope.");let o=n?.resolve(t,oe(e.path??"."))??E.resolve(t,oe(e.path??".")),a=n===void 0?(await Ce(o)).isDirectory():await n.isDirectory(o,r);return{cwd:a?o:n?.dirname(o)??E.dirname(o),target:a?".":`./${n?.basename(o)??E.basename(o)}`,arguments:["--no-config","--no-ignore-parent","--color=never",...J(e.include).flatMap(i=>["--glob",i]),...J(e.exclude).flatMap(i=>["--glob",`!${i}`])]}}u(ve,"ripgrepScope");async function Ae(e,t,n,r){if(ie(e),e.condition!==void 0)return ae(e,async(a,i)=>{let c=await Ae(a,t,n,r);for(let s of c.matches)i?.(s.source,s.lineNumber);return c},r);let o=await j(["--json","--no-config","--color=never","--with-filename","--line-number",...e.regex===!0?["--engine","auto"]:["--fixed-strings"],e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...se(e),"--",e.query,"-"],n,r,void 0,void 0,t.length===0?`
|
|
2
|
-
`:t);return t.length===0?{...o,matches:o.matches.filter(a=>a.lineNumber===1&&a.startColumn===0&&a.endColumn===0)}:o}u(Ae,"searchTextContent");async function re(e,t,n,r,o,a){let i=await ve(e,t,a,n),c=i.cwd,s=["--json","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...se(e),...i.arguments,"--",e.query,i.target];if(e.regex!==!0)return j(["--fixed-strings",...s],c,n,r,o,void 0,a);try{return await j(["--engine","auto",...s],c,n,r,o,void 0,a)}catch(l){if(!Me(l))throw l instanceof Error&&/PCRE2 is not available|does not support PCRE2/iu.test(l.message)?new Error("This regex requires PCRE2. Install ripgrep with PCRE2 support or simplify the regex.",{cause:l}):l;try{return await j(["--engine","default",...s],c,n,r,o,void 0,a)}catch(d){throw n?.aborted?d:new AggregateError([l,d],"Regex exceeded the PCRE2 match limit and cannot run with the default engine. Narrow the search or simplify the regex.",{cause:d})}}}u(re,"searchPattern");async function ae(e,t,n){let r=e.condition;if(r===void 0)throw new Error("Boolean search requires a line condition.");let o=new Set;function a(p){if(p.kind==="term"){o.add(p.value);return}a(p.left),a(p.right)}u(a,"collect"),a(r);let{condition:i,...c}=e,s=new Map,l=u(p=>JSON.stringify([p.source,p.lineNumber]),"lineKey");for(let p of o){n?.throwIfAborted();let f=new Set;await t({...c,query:p,regex:!0,wholeWord:!1},(m,y)=>f.add(JSON.stringify([m,y]))),s.set(p,f)}let d=await t(c),h=new Set,g=d.matches.filter(p=>{let f=l(p);return h.has(f)||!A(r,m=>s.get(m)?.has(f)===!0)?!1:(h.add(f),!0)});return{...d,matches:g}}u(ae,"searchBoolean");function j(e,t,n,r,o,a,i){return i!==void 0?Ee(e,t,i,n,r,o):new Promise((c,s)=>{let l=Re(Z(),e,{stdio:["pipe","pipe","pipe"],cwd:t}),d=0,h=!1;o!==void 0&&l.stdout.on("data",S=>{d+=S.length,d>o.bytes&&(h=!0,l.kill())});let g=ke({input:l.stdout});l.stdin.on("error",()=>{}),l.stdin.end(a);let p=[],f="",m,y=u(()=>{l.kill()},"abort"),T=u(()=>{n?.removeEventListener("abort",y),g.close()},"cleanup");l.stderr.setEncoding("utf8"),l.stderr.on("data",S=>{f+=S}),g.on("line",S=>{if(!(h||m!==void 0||S.length===0))try{let b=JSON.parse(S);if(b.type!=="match")return;if(r!==void 0){let{path:P,line_number:Y}=b.data;P.text!==void 0&&Number.isSafeInteger(Y)&&r(E.resolve(t,P.text),Y);return}for(let P of ce(b,t)){if(o!==void 0&&p.length===o.matches){h=!0,l.kill();break}p.push(P)}}catch(b){m=b,l.kill()}}),l.once("error",S=>{T(),s(S)}),l.once("close",S=>{if(T(),n?.aborted===!0){let b=new Error("Search was aborted.");b.name="AbortError",s(b);return}if(m!==void 0){s(new Error("Unable to parse ripgrep search output.",{cause:m}));return}if(!h&&S!==0&&S!==1){s(new Error(f.trim()||`ripgrep exited with code ${String(S)}.`));return}p.sort(ue),c({matches:p,complete:!h})}),n?.addEventListener("abort",y,{once:!0}),n?.aborted===!0&&y()})}u(j,"runRipgrep");async function Ee(e,t,n,r,o,a){let i=[],c=new AbortController,s=u(()=>c.abort(r?.reason),"abort");r?.addEventListener("abort",s,{once:!0}),r?.aborted&&s();let l=0,d={limited:!1};try{let h=await n.runLines(e,t,g=>{if(d.limited||!g.length)return;if(l+=Buffer.byteLength(g)+1,a!==void 0&&l>a.bytes){d.limited=!0,c.abort();return}let p=JSON.parse(g);if(p.type==="match"){if(o!==void 0){let f=p.data.path.text;f!==void 0&&Number.isSafeInteger(p.data.line_number)&&o(n.resolve(t,f),p.data.line_number);return}for(let f of ce(p,t,n)){if(a!==void 0&&i.length>=a.matches){d.limited=!0,c.abort();break}i.push(f)}}},c.signal);if(h.code!==0&&h.code!==1)throw new Error(h.stderr.trim()||"Ripgrep failed.")}catch(h){if(r?.throwIfAborted(),!d.limited)throw h}finally{r?.removeEventListener("abort",s)}return r?.throwIfAborted(),i.sort(ue),{matches:i,complete:!d.limited}}u(Ee,"runOwnedRipgrep");function Me(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}u(Me,"isPcre2MatchLimitError");function ce(e,t,n){let r=e.data.path.text,o=e.data.lines.text;if(r===void 0||o===void 0||!Number.isSafeInteger(e.data.line_number))return[];let a=o.split(`
|
|
3
|
-
`).map(l=>l.replace(/\r$/u,"")),i=Buffer.from(o),c=u(l=>{let d=i.subarray(0,l).toString("utf8");return{lineIndex:d.split(`
|
|
4
|
-
`).length-1,column:d.length-d.lastIndexOf(`
|
|
5
|
-
`)-1}},"position"),s=[];for(let l of e.data.submatches){if(l.start<0||l.end<l.start||l.end>i.length)continue;let d=c(l.start),h=c(l.end);s.push({source:n?.resolve(t,r)??E.resolve(t,r),lineNumber:e.data.line_number+d.lineIndex,startColumn:d.column,...h.lineIndex===d.lineIndex?{}:{endLineNumber:e.data.line_number+h.lineIndex},endColumn:h.column,matchedText:h.lineIndex===d.lineIndex?(a[d.lineIndex]??"").slice(d.column,h.column):i.subarray(l.start,l.end).toString("utf8"),lineText:a[d.lineIndex]??""})}return s}u(ce,"matchesFromEvent");function oe(e){return e.startsWith("@")?e.slice(1):e}u(oe,"stripFilePrefix");function ue(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}u(ue,"compareMatches");function nt(e){let t=z(e.query),n=z(e.query,!0),r=ne(e.query),o=[],a=Q(e.query),i=Q(e.query,!0);return(n!==t||JSON.stringify(a)!==JSON.stringify(i))&&o.push({query:n,mode:"regex",condition:i}),e.multiline!==!0&&r!==void 0&&r!==t&&r!==n&&o.push({query:r,mode:"words"}),{...e,query:t,regex:!0,condition:a,fallbacks:o}}u(nt,"createSearchRecipe");async function V(e,t,n,r){let o=e.query,a=await K(e,t,n,void 0,r),i=[];for(let c of e.fallbacks??[]){if(a.matches.length>0||!a.complete)break;n?.throwIfAborted();try{a=await K({...e,query:c.query,regex:!0,condition:c.condition},t,n,void 0,r),o=c.query,i.push(c.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words. Use these matches as location hints; refine the query before editing.")}catch(s){if(c.mode!=="regex"||!Ne(s)||n?.aborted)throw s;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...a,query:o,notices:i}}u(V,"runSearchRecipe");function Ne(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}u(Ne,"isRegexSyntaxError");var Ie=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,pe=4;function ht(e,t,n,r){return ge(e,t,n,r).slice(0,pe)}u(ht,"createSearchSessionId");function ge(e,t,n,r){let o=n===void 0?We(t.map(s=>s.source)):C(n),a=t.map(s=>({match:s,source:s.source.includes("://")?C(s.source):x.relative(o,x.resolve(s.source))})).sort((s,l)=>s.source.localeCompare(l.source)||X(s.match,l.match)).map(({match:s,source:l})=>[l,s.lineNumber,s.startColumn,s.endLineNumber??s.lineNumber,s.endColumn,s.matchedText,s.lineText]),{limit:i,...c}=Se(r??{query:e,regex:!0},o);return me("sha256").update(JSON.stringify([e,o,c,a])).digest("hex").toUpperCase()}u(ge,"createSearchSessionIdentity");function $e(e,t){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let n=pe;n<=e.length;n+=1){let r=e.slice(0,n);if(!t.has(r))return r}throw new Error("Could not allocate a unique search session id.")}u($e,"allocateSearchSessionId");function Se(e,t){return{query:e.query,path:De(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,multiline:e.multiline===!0,limit:e.limit??50,regex:e.regex===!0,condition:e.condition,fallbacks:e.fallbacks??[]}}u(Se,"normalizeRecipe");var D=class extends Error{static{u(this,"SearchSnapshotChangedError")}constructor(t){super(`Search result in ${t} changed before its anchors were registered.`),this.name="SearchSnapshotChangedError"}},le=class{constructor(t=ge,n,r){this.createIdentity=t;this.resultTargets=n;this.readSource=r}static{u(this,"SearchSessionStore")}#e=new Map;#r=new Map;async register(t,n,r,o,a,i={query:t,regex:!0},c,s,l){let d=structuredClone(n).map(S=>({...S,source:C(S.source)})).sort(X),h=this.readSource,g=h===void 0?void 0:(S,b)=>h(S,o,b),p=await he(d,a,s,l,g),f=this.createIdentity(t,d,o,i),y=this.#r.get(f)??$e(f,new Set(this.#e.keys())),T={id:y,query:t,matches:d,complete:r,digestBySource:de(p),read:g,...Le(this.resultTargets,y,d,p,o,r,(S,b)=>W(S,b,l,g)),...s===void 0?{}:{snapshotByteBudget:s},recipe:i,environment:l,...c!==void 0&&{refresh:c},cwd:C(o)};return this.#r.set(f,y),this.#e.set(y,T),T}async registerIfCurrent(t,n,r,o,a,i,c,s,l){try{return await this.register(t,n,r,o,a,i,c,s,l)}catch(d){if(d instanceof D)return;throw d}}async observeAfterEdit(t,n){let r=new Set(t.flatMap(a=>{let i=typeof a=="string"?M(a):void 0;return i===void 0?[]:[i.id]})),o=[];for(let a of r){let i=this.#e.get(a);if(i===void 0)continue;let c={sessionId:a,query:i.recipe.originalQuery??i.query,scope:Se(i.recipe,i.cwd)};try{let s=i.refresh===void 0?await V(i.recipe,i.cwd,n,i.environment):await i.refresh(n);o.push({...c,matches:s.matches.length,complete:s.complete,notices:s.notices})}catch(s){o.push({...c,error:s instanceof Error?s.message:String(s)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
|
|
6
|
-
`),renderFull(t){return t},renderCompact(t){let n=M(t);return n===void 0?"selected result":n.selector==="all"?n.mode==="match"?"all matches":"all lines":n.mode==="match"?`match ${String(n.selector)}`:`line ${String(n.selector)}`},tryResolve:u((t,n)=>this.#s(t,n.source,n.signal),"tryResolve")}}async resolveSearchScope(t,n){if(!t.startsWith("SEARCH#"))return;let r=await this.#o(t,n.cwd,n.signal,!0);if(r.kind!=="resolved")throw new Error(r.kind==="rejected"?r.rejection.reason:"Invalid Search reference.");let o=w(M(t)),a=w(this.#e.get(o.id));return{complete:!0,targets:r.targets.map(i=>{if(i.expectedContent===void 0)throw new Error("Search snapshot is unavailable.");return{source:i.source,expectedContent:i.expectedContent,ranges:i.ranges??[],readCurrent:u(async c=>{let s=await H(i.source,c,a.environment,a.read);if(s===void 0)throw new Error("Search source is unavailable.");return s},"readCurrent")}})}}resourceResolver(){return{id:"search-targets",tryResolve:u((t,n)=>this.#o(t,n.cwd),"tryResolve")}}async#s(t,n,r){let o=M(t);if(o===void 0)return{kind:"not-handled"};let a=this.#e.get(o.id);if(a===void 0)return B();if(o.selector==="all"&&!a.complete)return v();let i=C(n),c=a,s;if(o.selector==="all"){if(a.refreshedComplete?.complete===!0)c=a.refreshedComplete;else if(a.refreshedComplete!==void 0&&({snapshot:c,contents:s}=await this.#n(a,r),!c.complete))return v()}let l=N(c,o.selector,"match").find(m=>m.source===i);if(l===void 0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await H(i,r,a.environment,a.read);if(d===void 0)return B(l.lineNumber);let h=F(d);if(o.selector==="all"&&h!==c.digestBySource.get(i)&&({snapshot:c,contents:s}=await this.#n(a,r),!c.complete))return v();let g=u(m=>s===void 0?m===i?d:void 0:s.get(m),"contentOf"),p=N(c,o.selector,o.mode,g).filter(m=>m.source===i);if(p.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&h!==a.digestBySource.get(i))return B(w(p[0]).lineNumber);let f=k(i,d);return{kind:"resolved",anchor:new ee(t,i,p.map(m=>q(f,m,o.mode)))}}async#o(t,n,r,o=!1){let a=M(t);if(a===void 0)return{kind:"not-handled"};let i=this.#e.get(a.id);if(i===void 0||i.cwd!==C(n))return B();if(a.selector==="all"&&!i.complete)return v();let c=i,s=new Map;if(a.selector==="all"){if(i.refreshedComplete?.complete===!0)c=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&({snapshot:c}=await this.#n(i,r),!c.complete))return v();let f=new Set(N(c,a.selector,"match").map(m=>m.source));for(let m of f){let y=await H(m,r,i.environment,i.read);if(y===void 0||F(y)!==c.digestBySource.get(m)){let T=await this.#n(i,r);if(c=T.snapshot,s=new Map(T.contents),!c.complete)return v();break}s.set(m,y)}}else{let f=N(c,a.selector,a.mode)[0];if(f!==void 0){let m=await H(f.source,r,i.environment,i.read);if(m===void 0||F(m)!==c.digestBySource.get(f.source))return B(f.lineNumber);s.set(f.source,m)}}let l=N(c,a.selector,a.mode,f=>s.get(f)),d=new Map,h=u(f=>{let m=d.get(f.source);return m===void 0&&(m=k(f.source,s.get(f.source)??f.lineText),d.set(f.source,m)),m},"documentOf"),g=new Map;for(let f of l){let m=g.get(f.source)??[];m.push(q(h(f),f,a.mode)),g.set(f.source,m)}let p=[...g].map(([f,m])=>({source:f,ranges:m,expectedContent:s.get(f)}));return p.length===0&&!(o&&a.selector==="all")?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:p}}async#n(t,n){let r=t.refresh===void 0?await V(t.recipe,t.cwd,n,t.environment):await t.refresh(n),o=r.matches.map(c=>({...c,source:C(c.source)})).sort(X),a=await he(o,n,t.snapshotByteBudget,t.environment,t.read),i={matches:o,complete:r.complete,digestBySource:de(a)};return this.#e.set(t.id,{...t,refreshedComplete:i}),{snapshot:i,contents:a}}};function Le(e,t,n,r,o,a,i){if(e===void 0)return{};let c=new Map,s=u(d=>{let h=c.get(d);return h===void 0&&(h=k(d,w(r.get(d))),c.set(d,h)),h},"documentOf"),l=n.map(d=>({source:d.source,expectedContent:w(r.get(d.source)),ranges:[be(d)],readCurrent:Oe(i,d.source)}));for(let[d,h]of n.slice(0,100).entries()){let g=e.register([{...w(l[d]),ranges:[q(s(h.source),h,"line")]}],o);e.registerSearchReference(`SEARCH#${t}:${d+1}:line`,g,o)}return{target:e.register(l,o,a),matchTargets:l.slice(0,100).map(d=>e.register([d],o,a))}}u(Le,"registerResultReferences");function M(e){let t=Ie.exec(e);if(t!==null)return{id:w(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}u(M,"parseSearchAnchor");function Oe(e,t){return n=>e(t,n)}u(Oe,"sourceReader");function F(e){return me("sha256").update(e).digest("hex")}u(F,"digestContent");function de(e){return new Map([...e].map(([t,n])=>[t,F(n)]))}u(de,"digestContents");function N(e,t,n,r=()=>{}){let o=t==="all"?e.matches:[e.matches[t-1]].filter(je);if(n==="match"||t!=="all")return o;let a=new Set,i=new Map;return o.flatMap(c=>{let s=r(c.source),l=s===void 0?void 0:i.get(c.source);l===void 0&&(l=k(c.source,s??c.lineText),s!==void 0&&i.set(c.source,l));let d=ye(c);return l.lines.slice(c.lineNumber-1,d).flatMap(h=>{let g=`${c.source}\0${String(h.lineNumber)}`;return a.has(g)?[]:(a.add(g),[{...c,lineNumber:h.lineNumber,endLineNumber:h.lineNumber,startColumn:0,endColumn:h.content.length,lineText:h.content,matchedText:h.content}])})})}u(N,"selectMatches");function je(e){return e!==void 0}u(je,"isMatch");function ye(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}u(ye,"lastContainingLine");function q(e,t,n){if(n==="match")return be(t);let r=ye(t),o=w(e.lines[r-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:r+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}u(q,"selectionRange");function be(e){return{start:{lineNumber:e.lineNumber,column:e.startColumn},end:{lineNumber:e.endLineNumber??e.lineNumber,column:e.endColumn}}}u(be,"matchRange");function He(e,t){let n=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,n).map(r=>{let o=r.lineNumber===t.lineNumber?t.startColumn:0,a=r.lineNumber===n?t.endColumn:r.content.length;return r.content.slice(o,a)+(r.lineNumber===n?"":r.lineEnding)}).join("")}u(He,"matchedSourceText");async function he(e,t,n,r,o){let a=[...new Set(e.map(s=>s.source))];if(n!==void 0){let s=new Map,l=n;for(let d of a){let h=await Fe(d,l,t,r,o);l-=Buffer.byteLength(h),fe(d,h,e),s.set(d,h)}return s}let i=await Promise.allSettled(a.map(async s=>{let l=await W(s,t,r,o);return fe(s,l,e),[s,l]})),c=new Map;for(let s of i){if(s.status==="rejected")throw s.reason;c.set(...s.value)}return c}u(he,"snapshotContents");function fe(e,t,n){let r=k(e,t);for(let o of n.filter(a=>a.source===e))if(r.lines[o.lineNumber-1]?.content!==o.lineText||He(r,o)!==o.matchedText)throw new D(e)}u(fe,"validateSnapshot");async function Fe(e,t,n,r,o){if(n?.throwIfAborted(),e.includes("://")){let i=await W(e,n,r,o);if(Buffer.byteLength(i)>t)throw new Error("Candidate snapshot byte budget reached.");return i}let a=await Be(e,"r");try{let i=await a.stat();if(!i.isFile()||i.size>t)throw new Error("Candidate snapshot byte budget reached.");let c=Buffer.alloc(Math.min(i.size+1,t+1)),s=0;for(;s<c.length;){n?.throwIfAborted();let l=await a.read(c,s,c.length-s,s);if(l.bytesRead===0)break;s+=l.bytesRead}if(n?.throwIfAborted(),s>i.size||s>t)throw new Error("Candidate file grew during snapshot capture.");return c.subarray(0,s).toString("utf8")}finally{await a.close()}}u(Fe,"readBoundedSnapshot");async function H(e,t,n,r){try{return await W(e,t,n,r)}catch{return}}u(H,"readCurrent");function C(e){return e.includes("://")?e:x.resolve(e)}u(C,"canonicalSource");function De(e,t){return t.includes("://")?t:e.includes("://")?new URL(t,e.endsWith("/")?e:e+"/").href:x.resolve(e,t)}u(De,"resolveScope");async function W(e,t,n,r){if(t?.throwIfAborted(),r!==void 0)return r(e,t);if(n!==void 0)return n.readText(e,t);if(e.includes("://"))throw new Error("No search snapshot owner for this source.");return Pe(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}u(W,"readOwnedText");function B(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}u(B,"staleAnchor");function v(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}u(v,"missingCompleteAnchor");function We(e){if(e.length===0)return".";let t=x.dirname(x.resolve(w(e[0])));for(let n of e.slice(1)){let r=x.resolve(n);for(;!Je(t,r);){let o=x.dirname(t);if(o===t)return t;t=o}}return t}u(We,"commonSourceDirectory");function Je(e,t){let n=x.relative(e,t);return n!==".."&&!n.startsWith(`..${x.sep}`)&&!x.isAbsolute(n)}u(Je,"isWithin");function X(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||(e.endLineNumber??e.lineNumber)-(t.endLineNumber??t.lineNumber)||e.endColumn-t.endColumn}u(X,"compareMatches");export{K as a,ve as b,Ae as c,nt as d,V as e,ht as f,ge as g,$e as h,D as i,le as j};
|
package/dist/chunk-EWTVVPUA.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{d as M,h as N}from"./chunk-JXULBI4S.js";import{a as _}from"./chunk-KQV2ZXLP.js";import{l as w,m as P,n as B}from"./chunk-SIYPD5MM.js";import{a as m}from"./chunk-EI7MMDWY.js";import{Allow as $}from"partial-json";import{Guard as h}from"typebox-guard/guard";import{Allow as W,parse as U}from"partial-json";function O(o,e=W.ALL){if(!(!o||o.trim().length===0))try{let t=U(o,e);return t==null||typeof t!="object"||Array.isArray(t)?void 0:t}catch{return}}m(O,"resolvePartial");var S=class{static{m(this,"PartialToolRecoveryRegistry")}registrations=new Map;states=new Map;register(e){this.registrations.set(e.recoveryKey??e.toolName,e)}unregister(e){for(let[t,n]of this.registrations)(n.toolName===e||t===e)&&this.registrations.delete(t)}recoveryKeyFor(e){for(let[t,n]of this.registrations)if(n.toolName===e||n.toolNames?.includes(e)||t===e)return t}async recover(e){let t=this.states.get(e.contentIndex);if(t?.status==="done")return t.result;if(t?.status==="running")return t.promise;let n=this.registrations.get(e.recoveryKey??e.toolName);if(!n)return;let r=this.run(n,e);this.states.set(e.contentIndex,{status:"running",promise:r});let a=await r;return this.states.set(e.contentIndex,{status:"done",result:a}),a}cancel(e){this.states.delete(e)}cleanup(e){this.states.delete(e)}cleanupAll(){this.states.clear()}async run(e,t){let n=[],r=new Set(t.completedEntryIndexes),a=new Set(t.blockedEntryIndexes),d=e.extractEntries(t).filter(u=>{if(r.has(u.index))return n.push({index:u.index,reason:"entry already completed before recovery"}),!1;if(a.has(u.index))return n.push({index:u.index,reason:"entry was blocked by a guard"}),!1;let p=e.isCompleteEntry?.(u,t)??u.complete;return p||n.push({index:u.index,reason:t.recoverCompleteBatch?"entry was incomplete in the recovered batch":"entry was incomplete before the stale entry"}),!t.recoverCompleteBatch&&t.staleEntryIndex!==void 0&&u.index>=t.staleEntryIndex?!1:p}),l=e.filterEntries?.(d,t)??d,s=new Set(l.map(u=>u.index));for(let u of d)s.has(u.index)||n.push({index:u.index,reason:"entry was excluded by recovery filtering"});let c=[];for(let u of l)try{e.validateEntry?.(u,t),c.push(u)}catch(p){n.push({index:u.index,reason:p instanceof Error?p.message:String(p)})}let g={toolName:t.toolName,contentIndex:t.contentIndex,...t.staleEntryIndex!==void 0&&{staleEntryIndex:t.staleEntryIndex},staleDetails:t.staleDetails};if(c.length===0)return{...g,status:"skipped",appliedEntries:[],skippedEntries:n};try{let u=e.buildParams(c,t),p=await e.execute(u,{contentIndex:t.contentIndex,toolCallId:t.toolCallId,toolName:t.toolName,cwd:t.cwd,ctx:t.ctx,signal:new AbortController().signal});return{...g,status:"recovered",appliedEntries:e.getAppliedEntries?.(p,c,t)??c.map(v=>v.index),skippedEntries:n,normalResult:p}}catch(u){return{...g,status:"failed",appliedEntries:[],skippedEntries:n,error:u instanceof Error?u.message:String(u)}}}};import{createAssistantMessageEventStream as Q}from"@earendil-works/pi-ai";var j=Symbol.for("pi-agent-text-editor.tool-call-interceptor.streaming-provider.state");function K(o,e,t,n){let r=new Map,a={context:void 0,processStreamEvent:e,markStreamEventProcessed:t,finalizeStreamInterception:n},i=m((s,c)=>{if(!s)return;let g=c.modelRegistry.getProvider(s.provider);if(!g)return;let u=m(f=>{let x=c.modelRegistry.getRegisteredNativeProvider(s.provider);if(x)o.registerProvider(D(x,f));else{let I=c.modelRegistry.getRegisteredProviderConfig(s.provider);o.registerProvider(s.provider,{...I,api:s.api,streamSimple:f})}},"register"),p=r.get(s.provider);if(p){if(p.subscribers.add(a),p.api===s.api&&g.streamSimple===p.wrapper)return;p.api=s.api,u(p.wrapper);return}let v=g.streamSimple[j];if(v){if(v.subscribers.add(a),r.set(s.provider,v),v.api===s.api)return;v.api=s.api,u(v.wrapper);return}let R=g.streamSimple.bind(g),C=new Set([a]),y=m((f,x,I)=>q(R,f,x,I,C),"wrapper"),b={api:s.api,originalStreamSimple:g.streamSimple,wrapper:y,subscribers:C};y[j]=b,u(y),r.set(s.provider,b)},"install"),d=!1,l=m((s,c)=>{d||(a.context=s,i(c??s.model,s))},"attach");o.on("before_provider_request",(s,c)=>l(c)),o.on("turn_start",(s,c)=>l(c)),o.on("agent_start",(s,c)=>l(c)),o.on("session_start",(s,c)=>{d=!1,l(c)}),o.on("model_select",(s,c)=>l(c,s.model)),o.on("session_shutdown",()=>{d=!0;for(let[s,c]of r){if(c.subscribers.delete(a),c.subscribers.size!==0)continue;let g=a.context?.modelRegistry;if(g?.getProvider(s)?.streamSimple!==c.wrapper)continue;let p=g?.getRegisteredNativeProvider(s);p?o.registerProvider(D(p,c.originalStreamSimple)):o.unregisterProvider(s)}r.clear(),a.context=void 0})}m(K,"registerStreamingInterceptorProvider");function D(o,e){return Object.create(Object.getPrototypeOf(o),{...Object.getOwnPropertyDescriptors(o),streamSimple:{value:e,writable:!0,enumerable:!0,configurable:!0}})}m(D,"withStreamSimple");function q(o,e,t,n,r){let a=Q(),i=new AbortController,d=n?.signal,l=!1,s=Z(e),c=new Set,g=new Set,u=new Set,p=new Set,v=m(C=>{for(let y of r)y.markStreamEventProcessed(C)},"markStreamEventProcessed"),R=m(()=>{i.abort()},"abortFromParent");return d&&(d.aborted?i.abort():d.addEventListener("abort",R,{once:!0})),(async()=>{try{let C=o(e,t,{...n,signal:i.signal});for await(let y of C){if(l)continue;y.type==="done"?s=structuredClone(y.message):y.type==="error"?s=structuredClone(y.error):s=structuredClone(y.partial),J(y,c);let b;for(let f of r){let x=f.context;if(x){let I=await f.processStreamEvent(y,x);b??=I}}if(v(y),V(y,g,u,p),a.push(structuredClone(y)),b){if(y.type==="toolcall_delta"||y.type==="toolcall_end")for(let E of r)E.finalizeStreamInterception(y.contentIndex);l=!0,i.abort();let f=y.type==="toolcall_delta"||y.type==="toolcall_end"?y.contentIndex:void 0,x={...s,content:s.content.filter((E,A)=>c.has(A)&&(f===void 0||A<=f||p.has(A))).map(E=>E.type==="toolCall"&&E.id===b.toolCallId?{...E,arguments:structuredClone(b.arguments)}:E)};Y(a,v,x,c,g,u,p);let{errorMessage:I,...H}=x;a.push({type:"done",reason:"toolUse",message:{...H,stopReason:"toolUse"}}),a.end();continue}if(y.type==="done"||y.type==="error"){a.end();return}}}catch(C){if(l)return;let y=s,b=d?.aborted===!0?"aborted":"error",f={...y,stopReason:b,errorMessage:C instanceof Error?C.message:String(C)};a.push({type:"error",reason:b,error:f}),a.end()}finally{d?.removeEventListener("abort",R)}})(),a}m(q,"wrapStream");function J(o,e){(o.type==="text_start"||o.type==="thinking_start"||o.type==="toolcall_start")&&e.add(o.contentIndex)}m(J,"rememberStartEvent");function V(o,e,t,n){switch(o.type){case"text_end":{e.add(o.contentIndex);break}case"thinking_end":{t.add(o.contentIndex);break}case"toolcall_end":{n.add(o.contentIndex);break}}}m(V,"rememberEndEvent");function Y(o,e,t,n,r,a,i){for(let[d,l]of t.content.entries())if(n.has(d)){if(l.type==="text"&&!r.has(d)){let s={type:"text_end",contentIndex:d,content:l.text,partial:t};e(s),o.push(s)}else if(l.type==="thinking"&&!a.has(d)){let s={type:"thinking_end",contentIndex:d,content:l.thinking,partial:t};e(s),o.push(s)}else if(l.type==="toolCall"&&!i.has(d)){let s={type:"toolcall_end",contentIndex:d,toolCall:l,partial:t};e(s),o.push(s)}}}m(Y,"emitMissingEndEvents");function Z(o){return{role:"assistant",content:[],api:o.api,provider:o.provider,model:o.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"toolUse",timestamp:Date.now()}}m(Z,"emptyAssistantMessage");var ee="agentic-ide-partial-tool-recovery",L="pi-agent-text-editor/tool-call-annotation",k=new WeakMap,T=class{constructor(e){this.pi=e;e.on("tool_call",t=>{let n=this.toolCallRecords.get(t.toolCallId),r=n?.blockExecution?n.guardResult:void 0;return r?{block:!0,reason:r.content.filter(i=>i.type==="text").map(i=>i.text).join(`
|
|
2
|
-
`)||`Tool call ${t.toolName} was blocked by a streaming interceptor.`}:void 0}),e.on("tool_result",t=>{let n=this.toolCallBatchEntryIndexes.get(t.toolCallId);n!==void 0&&this.completedBatchEntryIndexes.add(n);let r=this.toolCallRecords.get(t.toolCallId)?.guardResult;if(this.toolCallRecords.delete(t.toolCallId),r){let a=r.details,i=typeof a=="object"&&a!==null&&"effect"in a&&(a.effect==="not-applied"||a.effect==="applied")?a.effect:"unknown",d=r.content.flatMap(l=>l.type==="text"?[l.text]:[]).join(`
|
|
3
|
-
`);return B({content:r.content,details:a},_(t.toolName),{status:"error",errors:[P(d,"INTERCEPTED")],data:{operation:t.toolName,operationId:t.toolCallId,effect:i,files:[]}})}}),e.on("message_update",async(t,n)=>{let r=t.assistantMessageEvent;this.consumeProcessedStreamEvent(r)||await this.processStreamEvent(r,n)}),e.on("message_end",async t=>{if(await this.finalizeRecovery(),this.annotateIncompleteCalls(),t.message.role==="toolResult"){let r=this.toolCallRecords.get(t.message.toolCallId),a=r?.blockExecution?r.guardResult:void 0;if(a){this.toolCallRecords.delete(t.message.toolCallId);let i=a.details;i!==void 0&&w(i);let d=this.toolCallBatchEntryIndexes.get(t.message.toolCallId);return d!==void 0&&this.completedBatchEntryIndexes.add(d),{message:{...t.message,content:a.content,...i!==void 0&&{details:i},isError:!0}}}}if(t.message.role!=="assistant")return;let n=this.pendingAbortReason;if(this.pendingAbortReason=void 0,!(n===void 0||t.message.stopReason!=="aborted"))return{message:{...t.message,errorMessage:n}}}),e.on("agent_end",async()=>{await this.finalizeRecovery(),this.annotateIncompleteCalls(),this.cleanupAll()})}static{m(this,"InterceptorImpl")}handlers=new Map;recoveryRegistry=new S;pendingRecoveryBlocks=[];pendingAbortReason;recoveryAppliedBatchIndexes=new Set;partialBuffers=new Map;completeArgumentContentIndices=new Set;streamedBatchEntries=new Map;batchEntryIndexes=new Map;toolCallBatchEntryIndexes=new Map;completedBatchEntryIndexes=new Set;nextBatchEntryIndex=0;contentNames=new Map;contentToolCallIds=new Map;pendingToolCallAnnotations=new Map;emittedToolCallAnnotationKinds=new Map;abortedContentIndices=new Set;dispatchQueues=new Map;abortCleanups=new Map;processedStreamEvents=new WeakSet;processedStreamEventKeys=new Map;toolCallRecords=new Map;blockedCallSink;processStreamEvent(e,t){if(e.type==="toolcall_start"){let n=e.partial.content[e.contentIndex];if(n?.type==="toolCall"){let r=this.getOrCreateBatchEntryIndex(e.contentIndex);this.contentNames.set(e.contentIndex,n.name),typeof n.id=="string"&&this.bindToolCallId(e.contentIndex,n.id),this.partialBuffers.set(e.contentIndex,""),this.streamedBatchEntries.set(e.contentIndex,{index:r,toolName:n.name,args:{},complete:!1}),this.installAbortCleanup(e.contentIndex,t.signal)}return Promise.resolve(void 0)}return e.type==="toolcall_delta"?this.enqueue(e.contentIndex,async()=>{let n=this.contentNames.get(e.contentIndex),r=this.contentToolCallIds.get(e.contentIndex);if(!n)return;let a=(this.partialBuffers.get(e.contentIndex)??"")+e.delta;this.partialBuffers.set(e.contentIndex,a),this.installAbortCleanup(e.contentIndex,t.signal);let i=O(a,$.OBJ|$.ARR)??{},d=ne(a),l=this.getOrCreateBatchEntryIndex(e.contentIndex);this.streamedBatchEntries.set(e.contentIndex,{index:l,toolName:n,args:i,complete:d!==void 0});let s=this.handlers.get(n);if(!r||!s||s.length===0||!d&&Object.keys(i).length===0)return;let c=d!==void 0;if(c&&this.completeArgumentContentIndices.has(e.contentIndex))return;c&&this.completeArgumentContentIndices.add(e.contentIndex);let g=d??i,u=await this.dispatchHandlers(s,{toolCall:{id:r,name:n,arguments:g},args:g,...!c&&{partialArgs:i},batchEntryIndex:l,batchEntries:this.getBatchEntries(l),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t});return u&&this.rememberOriginalArguments(u.toolCallId,u.arguments),u}):e.type==="toolcall_end"?this.enqueue(e.contentIndex,async()=>{let n=e.toolCall.name,r=this.handlers.get(n),a=this.getOrCreateBatchEntryIndex(e.contentIndex);this.bindToolCallId(e.contentIndex,e.toolCall.id);let i=this.toolCallRecords.get(e.toolCall.id);this.toolCallRecords.set(e.toolCall.id,{originalArguments:structuredClone(e.toolCall.arguments),...i?.guardResult&&{guardResult:i.guardResult},...i?.blockExecution&&{blockExecution:!0}}),this.streamedBatchEntries.set(e.contentIndex,{index:a,toolName:n,args:e.toolCall.arguments,complete:!1});let d=!this.completeArgumentContentIndices.has(e.contentIndex),l;d&&(this.completeArgumentContentIndices.add(e.contentIndex),l=r&&r.length>0?await this.dispatchHandlers(r,{toolCall:e.toolCall,args:e.toolCall.arguments,batchEntryIndex:a,batchEntries:this.getBatchEntries(a),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t}):void 0);let s=this.streamedBatchEntries.get(e.contentIndex);return s&&this.streamedBatchEntries.set(e.contentIndex,{...s,complete:!0}),this.cleanupContent(e.contentIndex,n),l}):Promise.resolve(void 0)}markStreamEventProcessed(e){this.processedStreamEvents.add(e);let t=G(e);t!==void 0&&this.processedStreamEventKeys.set(t,(this.processedStreamEventKeys.get(t)??0)+1)}consumeProcessedStreamEvent(e){let t=this.processedStreamEvents.delete(e),n=G(e);if(n===void 0)return t;let r=this.processedStreamEventKeys.get(n)??0;return r===0?t:(r===1?this.processedStreamEventKeys.delete(n):this.processedStreamEventKeys.set(n,r-1),!0)}finalizeStreamInterception(e){this.cleanupTransientContent(e,void 0,!0)}getToolCallRecord(e){return this.toolCallRecords.get(e)}rememberOriginalArguments(e,t){let n=this.toolCallRecords.get(e);n&&this.toolCallRecords.set(e,{originalArguments:structuredClone(t),...n.guardResult&&{guardResult:n.guardResult},...n.blockExecution&&{blockExecution:!0}})}async dispatchHandlers(e,t){for(let n of e){let r=await n.intercept(t);if(r!==void 0){this.pendingRecoveryBlocks.push({blocked:r,ctx:t});let a={content:[{type:"text",text:r.message.content}],details:r.message.details??null};return this.blockedCallSink?.({callId:t.toolCall.id,toolName:t.toolCall.name,arguments:structuredClone(t.args),...t.contentIndex!==void 0&&{contentIndex:t.contentIndex},...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},...r.message.details!==void 0&&{details:r.message.details},result:a,nativeExecutionBlocked:n.blockExecution===!0}),{toolCallId:t.toolCall.id,arguments:structuredClone(t.args),result:this.abortToolCall(r,t,n.name,n.blockExecution===!0)}}}}annotateIncompleteCalls(){for(let[e,t]of this.streamedBatchEntries)!t.complete&&this.contentNames.has(e)&&!this.recoveryAppliedBatchIndexes.has(t.index)&&!this.emittedToolCallAnnotationKinds.get(e)?.has("stale-anchor")&&this.annotateContent(e,{kind:"aborted"})}bindToolCallId(e,t){this.contentToolCallIds.set(e,t);let n=this.batchEntryIndexes.get(e);n!==void 0&&this.toolCallBatchEntryIndexes.set(t,n);let r=this.pendingToolCallAnnotations.get(e);if(r){for(let a of r)this.emitToolCallAnnotation(t,a);this.pendingToolCallAnnotations.delete(e)}}annotateContent(e,t){let n=this.emittedToolCallAnnotationKinds.get(e)??new Set;if(n.has(t.kind))return;n.add(t.kind),this.emittedToolCallAnnotationKinds.set(e,n);let r=this.contentToolCallIds.get(e);if(r){this.emitToolCallAnnotation(r,t);return}let a=this.pendingToolCallAnnotations.get(e)??[];a.push(t),this.pendingToolCallAnnotations.set(e,a)}emitToolCallAnnotation(e,t){let n={toolCallId:e,annotation:t};this.pi.events.emit(L,n)}getOrCreateBatchEntryIndex(e){let t=this.batchEntryIndexes.get(e);if(t!==void 0)return t;let n=this.nextBatchEntryIndex;return this.nextBatchEntryIndex+=1,this.batchEntryIndexes.set(e,n),n}getBatchEntries(e){return[...this.streamedBatchEntries.values()].filter(t=>t.index<=e).sort((t,n)=>t.index-n.index)}getAllBatchEntries(){return[...this.streamedBatchEntries.values()].sort((e,t)=>e.index-t.index)}abortToolCall(e,t,n,r){let a=te(e,n),i=e.annotation?e.annotation.kind==="aborted"&&e.annotation.label===void 0?{...e.annotation,label:a}:e.annotation:e.message.customType==="text-editor-stale-anchor-block"?{kind:"stale-anchor",label:a}:{kind:"aborted",label:a,color:"error"};t.contentIndex!==void 0&&(this.abortedContentIndices.add(t.contentIndex),this.annotateContent(t.contentIndex,i));let d={content:[{type:"text",text:e.message.content}],details:M(e.message.details,i,a)};return this.toolCallRecords.set(t.toolCall.id,{originalArguments:structuredClone(t.args),guardResult:d,...r&&{blockExecution:!0}}),d}async finalizeRecovery(){let e=this.pendingRecoveryBlocks.splice(0);if(e.length===0)return;let t=new Map;for(let n of e){let r=this.recoveryRegistry.recoveryKeyFor(n.ctx.toolCall.name);if(r===void 0)continue;let a=t.get(r)??[];a.push(n),t.set(r,a)}for(let n of t.values()){let r=n[0];if(!r)continue;let a=await this.recoverIfNeeded(r.blocked,r.ctx,this.getAllBatchEntries(),n);if(a===r.blocked)continue;let i=a.message.details,l=(h.IsObjectNotArray(i)&&h.IsObjectNotArray(i.recovery)?i.recovery:void 0)?.appliedEntries;if(Array.isArray(l))for(let s of l)typeof s=="number"&&this.recoveryAppliedBatchIndexes.add(s)}}async recoverIfNeeded(e,t,n,r){if(t.contentIndex===void 0)return e;let a=e.message.details,i=h.IsObjectNotArray(a)&&typeof a.entryIndex=="number"?a.entryIndex:void 0,d=[...new Set(r.map(p=>p.ctx.batchEntryIndex).filter(p=>p!==void 0))],l=[...new Set(r.map(p=>p.ctx.toolCall.id))],s=r.map(p=>p.blocked.message.details),c=r[0],g=c?this.recoveryRegistry.recoveryKeyFor(c.ctx.toolCall.name):void 0;if(!g)return e;let u=await this.recoveryRegistry.recover({contentIndex:t.contentIndex,toolCallId:t.toolCall.id,toolName:t.toolCall.name,...i!==void 0&&{staleEntryIndex:i},staleDetails:a,...t.partialArgs&&{partialArgs:t.partialArgs},args:t.args,batchEntries:n,...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},recoverCompleteBatch:!0,completedEntryIndexes:[...this.completedBatchEntryIndexes],blockedEntryIndexes:d,blockedToolCallIds:l,blockedDetails:s,recoveryKey:g,cwd:t.cwd,ctx:t.ctx});return u&&(u.appliedEntries.length>0||u.skippedEntries.length>0)?ae(e,u):e}async enqueue(e,t){let r=(this.dispatchQueues.get(e)??Promise.resolve()).catch(()=>{}).then(t);this.dispatchQueues.set(e,r);try{return await r}finally{this.dispatchQueues.get(e)===r&&this.dispatchQueues.delete(e)}}installAbortCleanup(e,t){if(!t||this.abortCleanups.has(e))return;let n=m(()=>{let r=this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let i of a??[])i.onAbort?.(e)},"listener");t.addEventListener("abort",n,{once:!0}),this.abortCleanups.set(e,()=>{t.removeEventListener("abort",n)})}cleanupContent(e,t){this.cleanupTransientContent(e,t),this.recoveryRegistry.cleanup(e)}cleanupTransientContent(e,t,n=!1){let r=t??this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let i of a??[])n&&i.onAbort?.(e),i.onContentEnd?.(e);this.abortCleanups.get(e)?.(),this.abortCleanups.delete(e),this.contentNames.delete(e),this.contentToolCallIds.delete(e),this.pendingToolCallAnnotations.delete(e),this.emittedToolCallAnnotationKinds.delete(e),this.completeArgumentContentIndices.delete(e),this.partialBuffers.delete(e),this.abortedContentIndices.delete(e)}cleanupAll(){for(let e of this.handlers.values())for(let t of e)t.onAgentEnd?.();for(let e of this.abortCleanups.values())e();this.abortCleanups.clear(),this.contentNames.clear(),this.contentToolCallIds.clear(),this.pendingToolCallAnnotations.clear(),this.completeArgumentContentIndices.clear(),this.emittedToolCallAnnotationKinds.clear(),this.partialBuffers.clear(),this.streamedBatchEntries.clear(),this.batchEntryIndexes.clear(),this.toolCallBatchEntryIndexes.clear(),this.toolCallRecords.clear(),this.completedBatchEntryIndexes.clear(),this.nextBatchEntryIndex=0,this.abortedContentIndices.clear(),this.pendingAbortReason=void 0,this.dispatchQueues.clear(),this.processedStreamEventKeys.clear(),this.recoveryRegistry.cleanupAll(),this.pendingRecoveryBlocks.length=0,this.recoveryAppliedBatchIndexes.clear()}registerRecovery(e){this.recoveryRegistry.register(e)}unregisterRecovery(e){this.recoveryRegistry.unregister(e)}registerBlockedCallSink(e){this.blockedCallSink=e}register(e){let t=new Set(e.toolNames);for(let[n,r]of this.handlers){let a=r.findIndex(i=>i.name===e.name);a!==-1&&(t.has(n)?(r[a]=e,t.delete(n)):r.splice(a,1))}for(let n of t){let r=this.handlers.get(n)??[];r.push(e),this.handlers.set(n,r)}}unregister(e){for(let[t,n]of this.handlers)this.handlers.set(t,n.filter(r=>r.name!==e))}};function G(o){if(o.type==="toolcall_end")return`${o.type}\0${o.contentIndex}\0${o.toolCall.id}`;if(o.type!=="toolcall_start"&&o.type!=="toolcall_delta")return;let e=o.partial.content[o.contentIndex],t=e?.type==="toolCall"?e.id:"",n=o.type==="toolcall_delta"?o.delta:"";return`${o.type}\0${o.contentIndex}\0${t}\0${n}`}m(G,"toolStreamEventKey");function te(o,e){return o.annotation?.reason?o.annotation.reason:o.annotation?.label?o.annotation.label:o.message.customType==="text-editor-stale-anchor-block"?"Stale Anchor":e.replace(/[-_]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())||"Blocked"}m(te,"abortReason");function ne(o){try{let e=JSON.parse(o);return h.IsObjectNotArray(e)?e:void 0}catch{return}}m(ne,"parseCompleteArguments");function re(o){let e=o.normalResult;if(!h.IsObjectNotArray(e)||!h.IsObjectNotArray(e.details))return[];let t=e.details.results;if(!Array.isArray(t))return[];let n=h.IsObjectNotArray(o.staleDetails)&&typeof o.staleDetails.path=="string"?o.staleDetails.path:void 0,r=t.filter(h.IsObjectNotArray).map(l=>h.IsObjectNotArray(l.data)?l.data:l),a=n===void 0?r:r.filter(l=>l.path===n),d=(a.length>0?a:r).flatMap(l=>{let s=l.freshAnchors;return Array.isArray(s)?s.filter(c=>typeof c=="string"):[]});return[...new Set(d)]}m(re,"freshAnchorsAfterRecovery");function oe(o,e){let n=o.indexOf(`
|
|
4
|
-
|
|
5
|
-
Current nearby anchors:`);return`${n===-1?o:o.slice(0,n)}
|
|
6
|
-
|
|
7
|
-
Current nearby anchors:
|
|
8
|
-
${e.map(a=>` ${a}`).join(`
|
|
9
|
-
`)}`}m(oe,"replaceCurrentAnchors");function ae(o,e){let t=e.appliedEntries.length,n=t>0?`${t} (indices: ${e.appliedEntries.join(", ")})`:"0",r=e.skippedEntries.length>0?e.skippedEntries.map(c=>`${c.index} (${c.reason})`).join(", "):"none",a=e.error?`Recovery execution failed: ${e.error}.`:"Recovery execution completed.",i=re(e),d=i.length>0&&h.IsObjectNotArray(o.message.details)?{...o.message.details,freshAnchors:i}:o.message.details,l=i.length>0?oe(o.message.content,i):o.message.content,s=i.length>0&&h.IsObjectNotArray(e.staleDetails)?{...e,staleDetails:{...e.staleDetails,freshAnchors:i}}:e;return{message:{customType:ee,content:`${l}
|
|
10
|
-
|
|
11
|
-
[RECOVERY] Status: ${e.status}. Applied entries: ${n}. Skipped entries: ${r}. ${a}`,display:!1,details:{blocked:d,recovery:s}}}}m(ae,"makeRecoveryResult");var z=new WeakMap;function F(o){let e=z.get(o);if(e)return e;let t=new T(o);return z.set(o,t),K(o,(n,r)=>t.processStreamEvent(n,r),n=>{t.markStreamEventProcessed(n)},n=>{t.finalizeStreamInterception(n)}),t}m(F,"coordinatorFor");function se(o,e){F(o).register(e)}m(se,"registerToolCallInterceptor");function ie(o,e){if(k.get(o)?.(),k.delete(o),e===void 0)return;let t=o.events.on(L,n=>{!h.IsObjectNotArray(n)||typeof n.toolCallId!="string"||!N(n.annotation)||e(n.toolCallId,n.annotation)});k.set(o,t)}m(ie,"registerToolCallAnnotationSink");function Re(o,e){F(o).registerBlockedCallSink(e)}m(Re,"registerBlockedToolCallSink");export{se as a,ie as b,Re as c};
|
package/dist/chunk-FBR7ZLLN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as y}from"./chunk-JHWLRL4U.js";import{a as c,g as m}from"./chunk-KJAR2WDO.js";import{q as w}from"./chunk-S3T5NOSL.js";import{a as p}from"./chunk-EI7MMDWY.js";import a from"node:path";async function C(e,f,t,v,h,n){n?.throwIfAborted();let i=c(e.target.id,f).path;if(t&&x(t,i))return{cwd:c(e.target.id,t).source,external:!1};let d=!1;try{d=(await e.stat(i,{signal:n})).kind==="directory"}catch(r){if(!(r instanceof m)||r.code!=="ENOENT")throw r}let g=d?h:h.filter(r=>w(r,i)),T=t===void 0&&x(e.target.workspace,i)?e.target.workspace:void 0,o=d?i:a.posix.dirname(i);for(;;){n?.throwIfAborted();let r=a.posix.join(o,".pi","pi-agent-ide",`${v}.json`),l=!1;try{await e.stat(r,{signal:n}),l=!0}catch(s){if(!(s instanceof m)||s.code!=="ENOENT")throw s}let E=!l&&g.length>0?[...(await y(e,o,g,n)).values()].some(s=>s.score>0):!1;if(l||E||o===T)return{cwd:c(e.target.id,o).source,external:t!==void 0};let u=a.posix.dirname(o);if(u===o)return;o=u}}p(C,"resolveSshToolProject");function x(e,f){let t=a.posix.relative(e,f);return t===""||t!==".."&&!t.startsWith("../")&&!a.posix.isAbsolute(t)}p(x,"inside");export{C as a};
|
package/dist/chunk-FGN2ZMEN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./chunk-S7E2D5K7.js";import{a as h}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{createHash as g}from"node:crypto";var u=/^([1-9]\d*)#([A-Z0-9]{3,4})$/,x=/(?<![A-Za-z0-9])([1-9]\d*#[A-Z0-9]{3,4})(?![A-Za-z0-9])/g;function A(e){let n=[...e.matchAll(x)],t=n[0];return n.length===1&&t!==void 0?h(t[1]):e}s(A,"normalizeLineHashAnchor");var d=class extends m{static{s(this,"LineHashTextAnchor")}constructor(n,t){super(`${n}#${f(t)}`,n)}};function f(e){return g("sha1").update(e).digest("hex").slice(0,4).toUpperCase()}s(f,"hashLine");function p(e,n){return new d(e,n)}s(p,"createLineHashAnchor");function v(e,n){return p(e,n).value}s(v,"formatLineHashAnchor");function y(e,n=1,t=e.length){let o=Math.max(1,n),r=Math.min(e.length,t);if(r<o)return[];let a=e.map((i,l)=>v(l+1,i)),c=Math.max(0,...a.map(i=>i.length));return e.slice(o-1,r).map((i,l)=>`${h(a[o+l-1]).padStart(c)}|${i}`)}s(y,"renderLineHashLines");function k(){return{id:"line-hash",description:"Use the complete `LINE#HASH` printed before a source line, for example `12#A4F0`; the hash rejects stale text.",normalize:A,renderFull(e){return e},renderCompact(e){return`line ${u.exec(e)?.[1]??"?"}`},tryResolve(e,n){return Promise.resolve(b(e,n))},recover(e,n){let t=u.exec(e);if(t===null)return Promise.resolve({kind:"unavailable"});let o=Number(t[1]),r=Math.min(Math.max(1,o),n.lines.length),a=n.lines[r-1];return a===void 0?Promise.resolve({kind:"unavailable"}):Promise.resolve({kind:"candidates",total:1,candidates:[{rank:1,range:{start:{lineNumber:r,column:0},end:{lineNumber:r,column:a.length}}}]})}}}s(k,"createLineHashAnchorResolver");function b(e,n){let t=u.exec(e);if(t===null)return{kind:"not-handled"};let o=Number(t[1]),r=n.lines[o-1];if(r===void 0||f(r)!==t[2]){let c=Math.max(1,o-5),i=Math.min(n.lines.length,o+5);return{kind:"rejected",rejection:{code:r===void 0?"missing":"stale",reason:r===void 0?"line hash anchor is out of range":"line hash anchor is stale",contextRange:{offset:c,limit:i-c+1}}}}return{kind:"resolved",anchor:p(o,r)}}s(b,"resolveLineHashAnchor");export{f as a,p as b,v as c,y as d,k as e};
|
package/dist/chunk-FJSYWOE6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as C}from"./chunk-FBR7ZLLN.js";import{a as w}from"./chunk-TSNY2FSU.js";import{a as E,b as g}from"./chunk-JHWLRL4U.js";import{b as S}from"./chunk-FTECKRK6.js";import"./chunk-PPCWY4BB.js";import{a as u,b as v,c as U}from"./chunk-V2D5MLGE.js";import"./chunk-5W6QQZFI.js";import{g as l}from"./chunk-KJAR2WDO.js";import{a as p,b as O,c as f,e as j}from"./chunk-OIEA4QWF.js";import"./chunk-K5G4FDXD.js";import{c as R}from"./chunk-XHFAV2NI.js";import"./chunk-72FL5FHZ.js";import{c as P}from"./chunk-S3T5NOSL.js";import"./chunk-BXGMMZT3.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-SIYPD5MM.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{fileURLToPath as x}from"node:url";function A(i){let c=E(i),T=w(i);return{async resolveProject(e,o){if(e.startsWith("ssh://")||o.startsWith("ssh://")){let n=i.resolve(e,o);if(!n)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let a=i.resolve(o);if(a&&a.location.target!==n.location.target)throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let r=await C(n.backend,n.location.path,a?.location.path,"linters",p);return r?{projectRoot:r.cwd,external:r.external}:void 0}if(e.includes("://")||o.includes("://"))throw new l("UNSUPPORTED_SOURCE",e,"not-applied");let t=await P(o,e,"linters",p);return t===void 0?void 0:{projectRoot:t,external:t!==h.resolve(o)}},async loadRegistry(e,o){let t=i.resolve(e);return O.fromDirectory(e,{includeGlobal:!o,requireBuiltInEvidence:!0,...t?{layerAccess:c,executableAvailability:s(n=>S(t.backend,t.location.path,n),"executableAvailability"),recipeEvidence:s(n=>g(t.backend,t.location.path,n),"recipeEvidence")}:{}})},async run(e,o){let t=i.resolve(o.filePath);if(!t)return f(e,o);let n=i.resolve(o.projectRoot);if(!n||n.location.target!==t.location.target)throw new l("UNSUPPORTED_SOURCE",o.filePath,"not-applied");let a=e.check.cwd==="file"?h.posix.dirname(t.location.path):n.location.path;return f(e,{...o,processAccess:T,acceptsFile(r){if(r.startsWith("ssh://")){let d=i.resolve(r);return d?.location.target===t.location.target&&d.location.path===t.location.path}let m=r.startsWith("file:")?x(r):r;return m.includes("://")?!1:h.posix.resolve(a,m)===t.location.path}})}}}s(A,"createOwnedLintRuntime");async function L(i){let c=new U(await v(u(R())));await j(i,A(c))}s(L,"registerOwnedLint");export{A as createOwnedLintRuntime,L as default};
|
package/dist/chunk-FTECKRK6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as d}from"./chunk-KJAR2WDO.js";import{a as p}from"./chunk-EI7MMDWY.js";import l from"node:path";async function y(e,o,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 e.execute("python3",["-c",'import os; print(os.environ.get("PATH", os.defpath), end="")'],o,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>l.posix.join(o,n)),t.PATH??i.stdout].join(":")}}p(y,"sshProjectEnvironment");async function v(e,o,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let h of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(h))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",o)??"",path:s.env?.PATH}}),n=await e.execute("python3",["-c","import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; 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),o],o,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",e.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",e.target.id,"not-applied");return a}p(v,"sshProjectExecutableAvailability");export{y as a,v as b};
|
package/dist/chunk-GRZTKMXQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-5W6QQZFI.js";import"./chunk-KJAR2WDO.js";import"./chunk-SIYPD5MM.js";import"./chunk-EI7MMDWY.js";export{a as startSshProcess};
|
package/dist/chunk-HFCHOFLV.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as k,d as m}from"./chunk-5AROEOJB.js";import{a as v,b}from"./chunk-PS2B6THP.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{pathToFileURL as T}from"node:url";function P(e,n,t,r,i,a=[],l=[]){let c=a.map(o=>({kind:"note",text:o}));c.push(...b(e.flatMap(o=>{let y=h.isAbsolute(o.source),D=y&&i?h.relative(i,o.source)||h.basename(o.source):o.source,z=y?T(o.source).href:/^https?:/iu.test(o.source)?o.source:void 0,x=o.endLineNumber??o.lineNumber;return(x===o.lineNumber?[o.lineText]:[o.lineText,...o.matchedText.split(/\r\n|\n|\r/u).slice(1)]).slice(0,20).map((R,f)=>({source:o.source,label:D,...z===void 0?{}:{link:z},...y?{}:{badge:o.source.startsWith("docs:")?"DOC":/^https?:/iu.test(o.source)?"WEB":"SH"},lineNumber:o.lineNumber+f,text:R,ranges:[{from:f?0:o.startColumn,to:o.lineNumber+f===x?o.endColumn:R.length}]}))}))),e.length||c.push({kind:"note",text:"No matches found"}),e.some(o=>(o.endLineNumber??o.lineNumber)-o.lineNumber>=20)&&c.push({kind:"note",text:"\u2026 source preview shortened"}),c.push(...l.map(o=>({kind:"note",text:o,expandedOnly:!0})));let u=`${e.length}${n?"":"+"}`,p=new Set(e.map(o=>o.source)),F=e.length>0&&e.every(o=>h.isAbsolute(o.source));return new v({summary:`${u} ${e.length===1?"match":"matches"} in ${p.size} ${F?p.size===1?"file":"files":p.size===1?"source":"sources"}`,rows:c},t,r)}s(P,"renderSearchMatches");function $(e,n){return e.targets.some(t=>t.source===n.source&&t.ranges.some(r=>(r.start.lineNumber<n.lineNumber||r.start.lineNumber===n.lineNumber&&r.start.column<=n.startColumn)&&(r.end.lineNumber>(n.endLineNumber??n.lineNumber)||r.end.lineNumber===(n.endLineNumber??n.lineNumber)&&r.end.column>=n.endColumn)))}s($,"containsSearchMatch");function I(e){if(e===void 0)return[];let n=[],t=0,r="";for(let i of e){if(i==="{"?t+=1:i==="}"&&(t=Math.max(0,t-1)),t===0&&(i===","||/\s/u.test(i))){r.length>0&&(n.push(r),r="");continue}r+=i}return r.length>0&&n.push(r),n}s(I,"splitGlobList");import{Value as N}from"typebox/value";var d={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function L(e){return N.Check(k,e)}s(L,"isFuzzyResultData");function g(e){return e.length>=5&&e.length<=d.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(g,"isFuzzyQuery");var S=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(n){return this.bytes+=n,this.bytes>d.vocabularyBytes&&(this.limited=!0),!this.limited}add(n){if(!(this.limited||!g(n)||this.names.has(n))){if(this.names.size===d.identifiers){this.limited=!0;return}this.names.add(n)}}addText(n){if(this.account(Buffer.byteLength(n))){for(let t of n.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(t[0]),this.limited)break}}};function w(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(n=>n.toLowerCase())}s(w,"splitName");function C(e,n){return e.length===n.length&&e.every((t,r)=>t===n[r])}s(C,"same");function M(e,n){if(e.length<5||n.length<5||Math.abs(e.length-n.length)>1||/\d/u.test(e+n))return!1;let t=0;for(;t<Math.min(e.length,n.length)&&e[t]===n[t];)t++;if(e.length===n.length)return e.slice(t+1)===n.slice(t+1)||e[t]===n[t+1]&&e[t+1]===n[t]&&e.slice(t+2)===n.slice(t+2);let r=e.length<n.length?e:n,i=e.length<n.length?n:e;return r.slice(t)===i.slice(t+1)}s(M,"oneTypo");function E(e,n){if(e.join("")===n.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let t=e.length<n.length?e:n,r=e.length<n.length?n:e;if(r.length===t.length+1&&t.length>=2&&t.every(l=>l.length>=3)){let l=C(t,r.slice(1)),c=C(t,r.slice(0,-1));if(l||c)return{kind:"component",reason:`${e.length>n.length?"remove":"add"} ${l?"leading":"trailing"} component '${l?r[0]:r.at(-1)}'`}}if(e.length!==n.length)return;let i=e.flatMap((l,c)=>{let u=n[c];return u!==void 0&&l!==u?[{word:l,other:u}]:[]}),a=i[0];if(!(i.length!==1||!a||!M(a.word,a.other)))return{kind:"typo",reason:`one character edit: '${a.word}' \u2192 '${a.other}'`}}s(E,"relation");var A={normalized:0,component:1,typo:2};function _(e,n){if(!g(e))return[];let t=w(e);if(t.length===0)return[];let r=[];for(let i of new Set(n)){if(i===e||!g(i))continue;let a=E(t,w(i));a&&r.push({identifier:i,...a})}return r.sort((i,a)=>A[i.kind]-A[a.kind]||(i.identifier<a.identifier?-1:i.identifier>a.identifier?1:0)).slice(0,d.candidates)}s(_,"rankFuzzyIdentifiers");function O(e,n,t){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(r=>r.source)).size,selection:{...m(e.matches.slice(0,d.previewMatches),e.complete,n,t),truncated:e.matches.length>d.previewMatches}}}s(O,"fuzzyCandidateData");function Z(e){let n=e.selection.complete?"":"+",t=e.selection.all?.line??e.selection.matches[0]?.references?.line,r=e.selection.matches[0],i=t??r?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${n} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${n} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${t||!r?"":` \xB7 line ${r.range.startLine}`}`]:[]].join(`
|
|
2
|
-
`)}s(Z,"formatFuzzyCandidate");export{P as a,$ as b,I as c,d,L as e,g as f,S as g,_ as h,O as i,Z as j};
|
package/dist/chunk-HFF4GY7R.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as S}from"./chunk-S7E2D5K7.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createRequire as F}from"node:module";import{Lang as y,parse as R,registerDynamicLanguage as B}from"@ast-grep/napi";var D=F(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),$={bash:"@ast-grep/lang-bash",csharp:"@ast-grep/lang-csharp",dart:"@ast-grep/lang-dart",elixir:"@ast-grep/lang-elixir",go:"@ast-grep/lang-go",html:"@ast-grep/lang-html",java:"@ast-grep/lang-java",kotlin:"@ast-grep/lang-kotlin",lua:"@ast-grep/lang-lua",markdown:"@ast-grep/lang-markdown",php:"@ast-grep/lang-php",ruby:"@ast-grep/lang-ruby",scala:"@ast-grep/lang-scala",sql:"@ast-grep/lang-sql",swift:"@ast-grep/lang-swift"},O={".bash":"bash",".cs":"csharp",".css":y.Css,".less":y.Css,".scss":y.Css,".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".htm":"html",".html":"html",".java":"java",".kt":"kotlin",".kts":"kotlin",".lua":"lua",".md":"markdown",".mdx":"markdown",".php":"php",".rb":"ruby",".rake":"ruby",".scala":"scala",".sc":"scala",".sql":"sql",".sh":"bash",".swift":"swift"},N=!1;function q(){if(N)return;let r={};for(let[e,t]of Object.entries($))r[e]=D(t);B(r),N=!0}c(q,"ensureLanguagesRegistered");function P(r,e){let t=O[r];if(t)return q(),{rootNode:new b(R(t,e).root(),e)}}c(P,"parseNativeDocument");var b=class r{constructor(e,t){this.node=e;this.source=t}static{c(this,"NativeSyntaxNode")}get type(){return String(this.node.kind())}get text(){return this.node.text()}get isNamed(){return this.node.isNamed()}get hasError(){return this.type==="ERROR"||this.node.children().some(e=>new r(e,this.source).hasError)}get startIndex(){return C(this.source,this.node.range().start.index)}get endIndex(){return C(this.source,this.node.range().end.index)}get startPosition(){let{line:e,column:t}=this.node.range().start;return{row:e,column:t}}get endPosition(){let{line:e,column:t}=this.node.range().end;return{row:e,column:t}}get parent(){let e=this.node.parent();return e?new r(e,this.source):null}get namedChildCount(){return this.namedChildren.length}get namedChildren(){return this.node.children().filter(e=>e.isNamed()).map(e=>new r(e,this.source))}childForFieldName(e){let t=this.node.field(e);return t?new r(t,this.source):null}};function C(r,e){return Buffer.from(r).subarray(0,e).toString("utf8").length}c(C,"byteOffsetToStringIndex");import{createHash as W}from"node:crypto";import{createRequire as I}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var M=I(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),G=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]);function k(r){let{startPosition:e,endPosition:t}=r;return`${r.type}:${e.row}:${e.column}:${t.row}:${t.column}`}c(k,"siblingKey");var T,A=new Map;function U(r){switch(r){case".ts":case".tsx":case".mts":case".cts":return"tree-sitter-typescript/tree-sitter-typescript.wasm";case".js":case".jsx":case".mjs":case".cjs":return"tree-sitter-javascript/tree-sitter-javascript.wasm";case".py":case".pyi":return"tree-sitter-python/tree-sitter-python.wasm";case".rs":return"tree-sitter-rust/tree-sitter-rust.wasm";case".c":case".cc":case".hh":case".hxx":case".cpp":case".cxx":case".h":case".hpp":return"tree-sitter-cpp/tree-sitter-cpp.wasm";case".json":case".jsonc":return"tree-sitter-json/tree-sitter-json.wasm";case".yaml":case".yml":return"@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm";case".toml":return"@tree-sitter-grammars/tree-sitter-toml/tree-sitter-toml.wasm";default:return}}c(U,"grammarWasmPath");async function H(r){let e=U(r);if(!e)return;T??=p.Parser.init(),await T;let t=A.get(e);if(t===void 0){let o=M.resolve(e);t=p.Language.load(o),A.set(e,t)}let i=await t,a=new p.Parser;return a.setLanguage(i),a}c(H,"ensureParser");async function K(r,e,t,i){let a=await z(r,e,t);try{return await i(a)}finally{a?.delete?.()}}c(K,"withParsedDocument");async function z(r,e,t){if(t.length===0)return;let i=r.includes("://")||L.isAbsolute(r)?r:L.resolve(e,r),a=L.extname(i).toLowerCase(),o=t.join(`
|
|
2
|
-
`),d=await H(a);if(d)try{return d.parse(o)??void 0}finally{d.delete()}return P(a,o)}c(z,"parseDocument");function v(r,e,t){let i=r.slice(Math.max(0,e-1),Math.max(0,t)).join(`
|
|
3
|
-
`);return W("sha1").update(i).digest("hex").slice(0,4).toUpperCase()}c(v,"hashScope");var w=class extends S{static{c(this,"AstScopeTextAnchor")}constructor(e,t,i,a){super(`scope-${e}-${t}${a===void 0?"":`-${a}`}`,i)}};function h(r,e,t,i){return new w(r,e,t,i)}c(h,"createScopeAnchor");var E=class{static{c(this,"AstScopeManager")}async getDocumentScopes(e,t,i){return i.length===0?[]:await K(e,t,i,a=>{if(!a)return[];let o=[];return this.collectCandidates(a.rootNode,o),this.buildEntries(o,i)})}collectCandidates(e,t,i=0,a=!1){if(i>100||!e.isNamed)return;let o=e.type;if(!o||G.has(o)){for(let n of e.namedChildren)this.collectCandidates(n,t,i+1);return}let d=new Set;for(let n of x){let s=e.childForFieldName(n);if(!s?.isNamed)continue;d.add(k(s));let u=s.startPosition.row+1,m=s.endPosition.row+1,l=m-u>=3,g=[...x].some(j=>s.childForFieldName(j)!==null);l&&!g&&t.push({startLine:u,endLine:m,kind:`${o}.${n}`,fromBodyField:!0}),this.collectCandidates(s,t,i+1,!0)}if(![...x].some(n=>e.childForFieldName(n)!==null)&&!a){let n=e.startPosition.row+1,s=e.endPosition.row+1;s-n>=3&&e.namedChildren.length>0&&t.push({startLine:n,endLine:s,kind:o,fromBodyField:!1})}for(let n of e.namedChildren)d.has(k(n))||this.collectCandidates(n,t,i+1)}buildEntries(e,t){let i=new Map;for(let n of e){let s=i.get(n.startLine);(!s||n.endLine>s.endLine||n.endLine===s.endLine&&n.fromBodyField&&!s.fromBodyField)&&i.set(n.startLine,n)}let a=[...i.values()].sort((n,s)=>n.startLine-s.startLine||s.endLine-n.endLine),o=[];for(let n of a)o.some(u=>u.startLine<n.startLine&&u.endLine===n.endLine)||o.push(n);let d=new Map;for(let n of o){let s=v(t,n.startLine,n.endLine);d.set(s,(d.get(s)??0)+1)}let f=new Map;return o.map(n=>{let s=v(t,n.startLine,n.endLine),u=d.get(s)??1,m=(f.get(s)??0)+1;f.set(s,m);let l=u>1?m:void 0;return{name:n.kind,kind:n.kind,startLine:n.startLine,endLine:n.endLine,depth:o.filter(g=>g!==n&&g.startLine<=n.startLine&&g.endLine>=n.endLine&&(g.startLine<n.startLine||g.endLine>n.endLine)).length,hash:s,blockHash:s,...l!==void 0&&{occurrence:l},beginAnchor:h("begin",s,n.startLine,l),endScopeAnchor:h("end",s,n.endLine,l),scopeBeginAnchor:h("begin",s,n.startLine,l),scopeEndAnchor:h("end",s,n.endLine,l)}})}};export{O as a,K as b,E as c};
|