pi-agent-ide 0.7.3 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -35
- package/README.md +70 -19
- package/dist/chunk-246NTPOS.js +1 -0
- package/dist/chunk-2ITKAXHO.js +1 -0
- package/dist/chunk-3WO2NOEQ.js +1 -0
- package/dist/{chunk-ZTYWHL2F.js → chunk-47SPPIXK.js} +1 -1
- package/dist/chunk-4HWKBCBH.js +1 -0
- package/dist/chunk-4W7GH3T7.js +10 -0
- package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
- package/dist/chunk-6EDOLYOV.js +1 -0
- package/dist/chunk-756K3LJY.js +1 -0
- package/dist/chunk-7LOVUWNI.js +1 -0
- package/dist/chunk-A64JRDZK.js +1 -0
- package/dist/chunk-AIT3YWR5.js +3 -0
- package/dist/chunk-AKNHSDGV.js +1 -0
- package/dist/chunk-AUL5FGGK.js +2 -0
- package/dist/chunk-BB4A5UI3.js +5 -0
- package/dist/chunk-BQAKA3FU.js +1 -0
- package/dist/chunk-BR7GRH4A.js +5 -0
- package/dist/chunk-BXGMMZT3.js +1 -0
- package/dist/{chunk-ZIWPKIBZ.js → chunk-D4IA2MTA.js} +1 -1
- package/dist/chunk-DUUOCBS3.js +3 -0
- package/dist/chunk-DXONCYWF.js +3 -0
- package/dist/chunk-E2PHA4SQ.js +1 -0
- package/dist/{chunk-H445SHSJ.js → chunk-EMRJP6EM.js} +1 -1
- package/dist/chunk-GEMDU6XW.js +1 -0
- package/dist/chunk-GNACBJM3.js +1 -0
- package/dist/chunk-HCK7OIQ3.js +1 -0
- package/dist/chunk-HFJGCYFO.js +11 -0
- package/dist/chunk-ID4RJIVZ.js +9 -0
- package/dist/chunk-IMGIDBCC.js +1 -0
- package/dist/chunk-JKMXND6V.js +1 -0
- package/dist/chunk-L2B4DTVS.js +1 -0
- package/dist/chunk-LAJQSHEI.js +4 -0
- package/dist/chunk-LEKC4GQK.js +5 -0
- package/dist/chunk-LLRUJD62.js +1 -0
- package/dist/{chunk-2ZMMRINH.js → chunk-M4TVRCMZ.js} +1 -1
- package/dist/chunk-MKEC3U2M.js +4 -0
- package/dist/chunk-N56WAVYA.js +1 -0
- package/dist/chunk-OFILFO6D.js +1 -0
- package/dist/chunk-OI3HBIPK.js +2 -0
- package/dist/{chunk-S6QRG3TQ.js → chunk-OM4LYD3S.js} +1 -1
- package/dist/{chunk-WLZIUMJL.js → chunk-PRLIHLCS.js} +1 -1
- package/dist/chunk-Q5X6OXNS.js +2 -0
- package/dist/chunk-R2U5WXYR.js +1 -0
- package/dist/chunk-S72FVLUX.js +1 -0
- package/dist/chunk-SWA5B5B2.js +9 -0
- package/dist/chunk-T4FTT3U4.js +1 -0
- package/dist/chunk-T7MWQQIF.js +3 -0
- package/dist/chunk-TGC2ZACO.js +1 -0
- package/dist/chunk-TOYN4W4F.js +1 -0
- package/dist/chunk-TXG2H7YQ.js +9 -0
- package/dist/{chunk-QFTBY67N.js → chunk-UEVGZUII.js} +3 -3
- package/dist/{chunk-7UGNGK7Y.js → chunk-VAXLSPPU.js} +1 -1
- package/dist/chunk-VDP5CQHM.js +3 -0
- package/dist/chunk-VMGZMXEM.js +10 -0
- package/dist/chunk-VNTY7BKC.js +1 -0
- package/dist/chunk-W3YFF6OO.js +1 -0
- package/dist/chunk-W7M3V7FR.js +28 -0
- package/dist/chunk-WMHSVEIT.js +29 -0
- package/dist/chunk-WPBQ45ZL.js +1 -0
- package/dist/chunk-WXGTU2M6.js +1 -0
- package/dist/chunk-XSIKDVAR.js +25 -0
- package/dist/chunk-YHREORHH.js +2 -0
- package/dist/chunk-YJ6T3PEP.js +1 -0
- package/dist/chunk-YTYLS2UM.js +1 -0
- package/dist/chunk-Z2QGNTGQ.js +1 -0
- package/dist/{chunk-QDLTO5PH.js → chunk-ZAWRSA7N.js} +1 -1
- package/dist/chunk-ZV5ETNLQ.js +1 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -0
- package/dist/entry-2.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-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +4 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +1 -17
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +18 -3
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -4
- package/dist/entry-37.js +1 -9
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +1 -25
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +25 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -3
- package/dist/entry-51.js +1 -13
- package/dist/entry-52.js +3 -1
- package/dist/entry-53.js +13 -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-6.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -0
- package/dist/entry-62.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +0 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-7.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +0 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -80
- package/dist/entry-78.js +1 -19
- package/dist/entry-79.js +80 -2
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +22 -1
- package/dist/entry-81.js +2 -1
- package/dist/entry-82.js +1 -5
- package/dist/entry-83.js +1 -3
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +3 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/entry-88.js +1 -0
- package/dist/pi-agent-ide.js +53 -24
- package/docs/agent-guides/debugger.md +2 -0
- package/docs/agent-guides/editing.md +1 -1
- package/docs/agent-guides/search-code.md +7 -2
- package/docs/agent-guides/ssh.md +58 -0
- package/docs/agent-guides/vision.md +6 -0
- package/docs/configuration.md +51 -5
- package/docs/development.md +1 -13
- package/docs/extensions.md +1 -1
- package/docs/releases.md +1 -1
- package/docs/settings-help.md +39 -0
- package/docs/tools.md +22 -14
- package/docs/user-hooks.md +7 -3
- package/node_modules/pi-agent-doctor/package.json +10 -9
- package/node_modules/pi-agent-doctor/runtime/entry-25.js +1 -0
- package/node_modules/pi-agent-doctor/src/evidence.ts +49 -4
- package/node_modules/pi-agent-doctor/src/executable.ts +46 -16
- package/node_modules/pi-agent-doctor/src/fixtures/executable-probe.ts +78 -0
- package/node_modules/pi-agent-doctor/src/fixtures/probe-executable-wait.mjs +10 -0
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +6 -0
- package/node_modules/pi-agent-doctor/src/project-probes.ts +73 -0
- package/node_modules/pi-agent-doctor/src/workspace.ts +106 -0
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-26.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +8 -8
- package/node_modules/pi-agent-filesystem/src/resolver.ts +23 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/index.ts +33 -6
- package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +67 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-30.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-ide-ast/package.json +15 -41
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +10 -3
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +3 -3
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
- package/node_modules/pi-agent-ide-ast/src/extension.ts +17 -1
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +4 -3
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +100 -42
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +3 -2
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +2 -1
- package/node_modules/pi-agent-ide-changes/index.ts +10 -2
- package/node_modules/pi-agent-ide-changes/package.json +10 -11
- package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +1 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +7 -2
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
- package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
- package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
- package/node_modules/pi-agent-ide-formatter/index.ts +14 -2
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +41 -11
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -28
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/index.ts +35 -4
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-38.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +14 -10
- package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -25
- package/node_modules/pi-agent-ide-lsp/index.ts +107 -25
- package/node_modules/pi-agent-ide-lsp/package.json +10 -13
- package/node_modules/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -4
- package/node_modules/pi-agent-read/package.json +12 -12
- package/node_modules/pi-agent-read/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-47.js +2 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +4 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +20 -5
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +75 -16
- package/node_modules/pi-agent-resource/src/index.ts +3 -0
- package/node_modules/pi-agent-resource/src/resource-error.ts +17 -0
- package/node_modules/pi-agent-resource/src/resource.ts +23 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +25 -2
- package/node_modules/pi-agent-resource/src/validation.ts +2 -1
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-51.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-52.js +2 -0
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +7 -3
- package/node_modules/pi-agent-search/src/api/search.ts +51 -2
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -3
- package/node_modules/pi-agent-search/src/core/search-core.ts +98 -8
- package/node_modules/pi-agent-search-text/index.ts +37 -1
- package/node_modules/pi-agent-search-text/package.json +14 -12
- package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-search-text/runtime/entry-56.js +1 -0
- package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +10 -5
- package/node_modules/pi-agent-search-text/src/file-search.ts +26 -3
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +54 -3
- package/node_modules/pi-agent-search-text/src/resolvers.ts +22 -5
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +4 -5
- package/node_modules/pi-agent-search-text/src/search-backend.ts +123 -17
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +5 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +166 -31
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/src/text-document.ts +2 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
- package/node_modules/pi-agent-text-editor/package.json +26 -34
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-78.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/file-operations.ts +55 -0
- package/node_modules/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
- 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 +127 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +93 -85
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +15 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +70 -25
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +123 -27
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +74 -9
- package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +49 -25
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +122 -39
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +85 -31
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +139 -27
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +1 -0
- package/node_modules/pi-agent-web/index.ts +28 -4
- package/node_modules/pi-agent-web/package.json +8 -11
- package/node_modules/pi-agent-web/src/doctor-plugin.ts +21 -6
- package/node_modules/pi-agent-web/src/resolver.ts +12 -2
- package/node_modules/pi-agent-web/src/search.ts +2 -1
- package/node_modules/pi-agent-web-html/package.json +3 -5
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-87.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-88.js +2 -0
- package/package.json +43 -39
- package/skills/configure-agent-ide/SKILL.md +38 -0
- package/src/api/content.ts +6 -0
- package/src/api/doctor-runtime.ts +80 -0
- package/src/api/doctor.ts +6 -0
- package/src/api/hooks.ts +3 -0
- package/src/api/plugin-protocol.ts +11 -1
- package/src/api/tips.ts +3 -0
- package/src/api/tool-config.ts +143 -24
- package/src/backend/config.ts +85 -0
- package/src/backend/configured-process.ts +59 -0
- package/src/backend/dap-java-transport.ts +112 -0
- package/src/backend/dap-java-worker.py +218 -0
- package/src/backend/dap-node-transport.ts +112 -0
- package/src/backend/dap-powershell-worker.py +44 -0
- package/src/backend/dap-r-worker.py +210 -0
- package/src/backend/dap-tcp-transport.ts +42 -0
- package/src/backend/dap-tcp-worker.py +125 -0
- package/src/backend/dap-transport.ts +69 -0
- package/src/backend/dap-unix-worker.py +63 -0
- package/src/backend/debugger-registration.ts +62 -0
- package/src/backend/debugger-workspace-owner.ts +413 -0
- package/src/backend/doctor-inventory-worker.py +54 -0
- package/src/backend/doctor-probe-worker.py +140 -0
- package/src/backend/doctor-registration.ts +18 -0
- package/src/backend/doctor-workspace.ts +381 -0
- package/src/backend/file-operation-resolver.ts +58 -0
- package/src/backend/file-revision.ts +13 -0
- package/src/backend/file-transfer.ts +302 -0
- package/src/backend/file-watch-worker.py +119 -0
- package/src/backend/formatter-registration.ts +114 -0
- package/src/backend/git-registration.ts +60 -0
- package/src/backend/identity.ts +47 -0
- package/src/backend/index.ts +12 -0
- package/src/backend/lint-registration.ts +102 -0
- package/src/backend/lsp-file-watchers.ts +220 -0
- package/src/backend/lsp-registration.ts +83 -0
- package/src/backend/lsp-transport.ts +87 -0
- package/src/backend/lsp-workspace-owner.ts +50 -0
- package/src/backend/object-transfer.ts +299 -0
- package/src/backend/owned-command.ts +105 -0
- package/src/backend/owned-process-stop.ts +36 -0
- package/src/backend/owned-read-command.ts +20 -0
- package/src/backend/process-environment.ts +77 -0
- package/src/backend/process-metadata-worker.py +98 -0
- package/src/backend/process-metadata.ts +99 -0
- package/src/backend/recipe-evidence-worker.py +26 -0
- package/src/backend/recipe-evidence.ts +77 -0
- package/src/backend/registration.ts +124 -0
- package/src/backend/registry.ts +29 -0
- package/src/backend/resource-resolver.ts +147 -0
- package/src/backend/search-environment.ts +100 -0
- package/src/backend/ssh-channel-worker.py +306 -0
- package/src/backend/ssh-channel.ts +376 -0
- package/src/backend/ssh-transfer-worker.py +99 -0
- package/src/backend/ssh-transport.ts +54 -0
- package/src/backend/ssh-worker.py +730 -0
- package/src/backend/ssh.ts +610 -0
- package/src/backend/tool-config-access.ts +63 -0
- package/src/backend/tool-project.ts +71 -0
- package/src/backend/vision-capture-worker.py +319 -0
- package/src/backend/vision-capture.ts +165 -0
- package/src/backend/vision-registration.ts +104 -0
- package/src/backend/web-browser-worker.mjs +182 -0
- package/src/backend/web-browser.ts +128 -0
- package/src/backend/web-http-worker.py +62 -0
- package/src/backend/web-http.ts +79 -0
- package/src/backend/web-owner.ts +68 -0
- package/src/backend/web-registration.ts +14 -0
- package/src/code-view/diagnostic-view.ts +2 -2
- package/src/code-view/reference.ts +9 -0
- package/src/composite/builtin-extensions.ts +9 -14
- package/src/composite/module-labels.ts +1 -0
- package/src/composite/nested-tool-rendering.ts +26 -6
- package/src/composite/preferences.ts +13 -0
- package/src/composite/settings-documentation.ts +59 -0
- package/src/composite/settings-help.ts +106 -0
- package/src/composite/text-results.ts +50 -22
- package/src/core/diagnostic-store.ts +32 -10
- package/src/core/ide-core.ts +22 -2
- package/src/doctor/arguments.ts +19 -0
- package/src/doctor/config-writer.ts +72 -29
- package/src/doctor/discovery.ts +53 -15
- package/src/doctor/extension.ts +27 -10
- package/src/doctor/run.ts +42 -7
- package/src/documentation/extension.ts +12 -0
- package/src/documentation/search.ts +166 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +33 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +67 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-30.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +23 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-87.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-88.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +21 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +12 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +2 -1
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-46.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-47.js +2 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +4 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +20 -5
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +37 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +10 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +26 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +54 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +22 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +4 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +123 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +5 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +166 -31
- package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-51.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-52.js +2 -0
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +7 -3
- package/src/extensions/pi-agent-search/src/api/search.ts +51 -2
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -3
- package/src/extensions/pi-agent-search/src/core/search-core.ts +98 -8
- package/src/extensions/pi-agent-text-editor/package.json +26 -34
- 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-exact/package.json +5 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +139 -27
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/file-operations.ts +55 -0
- package/src/extensions/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
- 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 +127 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +93 -85
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +15 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +70 -25
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +123 -27
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +74 -9
- package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +49 -25
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +122 -39
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +85 -31
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
- package/src/pi-agent-ide.ts +14 -2
- package/src/plugins/pi-agent-ide-ast/package.json +15 -41
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +10 -3
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +3 -3
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +17 -1
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +4 -3
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +100 -42
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +3 -2
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +2 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +10 -2
- package/src/plugins/pi-agent-ide-changes/package.json +10 -11
- package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +1 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +7 -2
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
- package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
- package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
- package/src/plugins/pi-agent-ide-debugger/index.ts +62 -25
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +33 -0
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +150 -171
- package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +2 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +152 -58
- package/src/plugins/pi-agent-ide-debugger/src/workspace-owner.ts +28 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +4 -1
- package/src/plugins/pi-agent-ide-formatter/index.ts +14 -2
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +41 -11
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -28
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/index.ts +35 -4
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-38.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +14 -10
- package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -25
- package/src/plugins/pi-agent-ide-lsp/index.ts +107 -25
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +8 -1
- package/src/plugins/pi-agent-ide-terminal/index.ts +7 -0
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +5 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -2
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +161 -42
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +7 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +11 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +33 -8
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +5 -0
- package/src/plugins/pi-agent-ide-vision/index.ts +170 -9
- package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +47 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +42 -1
- package/src/post-edit/gate.ts +4 -1
- package/src/tips/core.ts +5 -2
- package/src/tips/extension.ts +30 -2
- package/src/tips/persistence.ts +29 -27
- package/src/tips/setup-hint.ts +19 -0
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-3YK4XMWB.js +0 -0
- package/dist/chunk-5JELU6RV.js +0 -7
- package/dist/chunk-6U5OU77O.js +0 -3
- package/dist/chunk-7LD2OQH3.js +0 -14
- package/dist/chunk-BMOJTJJJ.js +0 -3
- package/dist/chunk-BYZSBXUK.js +0 -2
- package/dist/chunk-CEX73RI5.js +0 -28
- package/dist/chunk-DZWTKF2K.js +0 -1
- package/dist/chunk-EOKEQ3YH.js +0 -25
- package/dist/chunk-HZ5BNF3A.js +0 -1
- package/dist/chunk-IG56UGSO.js +0 -2
- package/dist/chunk-KVHDMIZS.js +0 -3
- package/dist/chunk-M5IVSCR2.js +0 -1
- package/dist/chunk-M5MJP7Z2.js +0 -1
- package/dist/chunk-MGCHOGQD.js +0 -1
- package/dist/chunk-N34ATN52.js +0 -1
- package/dist/chunk-NHKPP2AI.js +0 -28
- package/dist/chunk-NRZO5KJT.js +0 -9
- package/dist/chunk-OB46OPMZ.js +0 -1
- package/dist/chunk-Q6CZ6GBR.js +0 -3
- package/dist/chunk-QIK2E64R.js +0 -1
- package/dist/chunk-SBP3ABH4.js +0 -5
- package/dist/chunk-STBJO3Z3.js +0 -2
- package/dist/chunk-T6LX2RX5.js +0 -1
- package/dist/chunk-TXOTNK6B.js +0 -11
- package/dist/chunk-WZI4YC2O.js +0 -1
- package/dist/entry-19.js +0 -1
- package/docs/research/apply-native-capability-matrix.md +0 -174
- package/docs/research/apply-read-latency.md +0 -221
- package/docs/research/codemode-write-context.md +0 -56
- package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
- package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
- package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
- package/docs/research/native-codemode-batch-decision.md +0 -31
- package/docs/research/native-codemode-batching.md +0 -65
- package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-25.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-26.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +0 -1
- package/node_modules/pi-agent-ide-formatter/runtime/entry-34.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-38.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-39.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-51.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/node_modules/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-26.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-84.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-51.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-48.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -2
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-34.js +0 -2
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-24.js +0 -0
- /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-27.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-32.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-55.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-58.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-60.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-61.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-58.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-59.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-60.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-32.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-33.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-WPBQ45ZL.js";import{a as d}from"./chunk-WXGTU2M6.js";import{g as m}from"./chunk-4HWKBCBH.js";import{a as c}from"./chunk-EI7MMDWY.js";import l from"node:path";function k(p){return{async run(t,e){e.signal?.throwIfAborted();let r=p.resolve(e.projectRoot),n=p.resolve(e.filePath);if(!r||!n||r.location.target!==n.location.target)throw new m("UNSUPPORTED_SOURCE",e.filePath,"not-applied");let o=r.location.path,s=n.location.path,u=c(a=>a.replaceAll("{project}",o).replaceAll("{fileDir}",l.posix.dirname(s)).replaceAll("{relativeFile}",l.posix.relative(o,s)).replaceAll("{file}",s),"expand"),h=t.command.map(u),g=await f(r.backend,o,t.env,e.signal);e.signal?.throwIfAborted();let i=await d({...r.backend.target,workspace:t.cwd==="file"?l.posix.dirname(s):o},"env",[...Object.entries(g).map(([a,w])=>`${a}=${w}`),...h],e.filePath,{signal:e.signal,timeoutMs:t.timeoutMs??3e4,maxBytes:20*1024*1024,closeInput:!0,effect:"unknown"});return{ok:(t.successExitCodes??[0]).includes(i.exitCode),exitCode:i.exitCode,stdout:i.stdout.toString("utf8"),stderr:i.stderr.toString("utf8")}}}}c(k,"createSshConfiguredProcessAccess");export{k as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";var t="pi-agent-ide",r=5,a="pi-agent-ide/core/ready",s="pi-agent-ide/plugin/register";function d(e){return n(e)&&e.protocol===t&&e.apiVersion===5}o(d,"isIdeCoreReady");function i(e){return n(e)&&e.protocol===t&&e.apiVersion===5&&typeof e.id=="string"&&e.id.length>0&&typeof e.setup=="function"}o(i,"isIdePlugin");function c(e){return n(e)&&i(e.plugin)&&typeof e.accept=="function"}o(c,"isIdePluginRegistrationRequest");function n(e){return typeof e=="object"&&e!==null}o(n,"isUnknownRecord");export{t as a,r as b,a as c,s as d,d as e,i as f,c as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as k,e as f}from"./chunk-YTYLS2UM.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,r,o,i,a=[],l=[]){let c=a.map(t=>({kind:"note",text:t}));c.push(...b(e.flatMap(t=>{let p=h.isAbsolute(t.source),D=p&&i?h.relative(i,t.source)||h.basename(t.source):t.source,z=p?T(t.source).href:/^https?:/iu.test(t.source)?t.source:void 0,x=t.endLineNumber??t.lineNumber;return(x===t.lineNumber?[t.lineText]:[t.lineText,...t.matchedText.split(/\r\n|\n|\r/u).slice(1)]).slice(0,20).map((R,m)=>({source:t.source,label:D,...z===void 0?{}:{link:z},...p?{}:{badge:t.source.startsWith("docs:")?"DOC":/^https?:/iu.test(t.source)?"WEB":"SH"},lineNumber:t.lineNumber+m,text:R,ranges:[{from:m?0:t.startColumn,to:t.lineNumber+m===x?t.endColumn:R.length}]}))}))),e.length||c.push({kind:"note",text:"No matches found"}),e.some(t=>(t.endLineNumber??t.lineNumber)-t.lineNumber>=20)&&c.push({kind:"note",text:"\u2026 source preview shortened"}),c.push(...l.map(t=>({kind:"note",text:t,expandedOnly:!0})));let u=`${e.length}${n?"":"+"}`,y=new Set(e.map(t=>t.source)),F=e.length>0&&e.every(t=>h.isAbsolute(t.source));return new v({summary:`${u} ${e.length===1?"match":"matches"} in ${y.size} ${F?y.size===1?"file":"files":y.size===1?"source":"sources"}`,rows:c},r,o)}s(P,"renderSearchMatches");function $(e,n){return e.targets.some(r=>r.source===n.source&&r.ranges.some(o=>(o.start.lineNumber<n.lineNumber||o.start.lineNumber===n.lineNumber&&o.start.column<=n.startColumn)&&(o.end.lineNumber>(n.endLineNumber??n.lineNumber)||o.end.lineNumber===(n.endLineNumber??n.lineNumber)&&o.end.column>=n.endColumn)))}s($,"containsSearchMatch");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 I(e){return N.Check(k,e)}s(I,"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 r of n.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(r[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((r,o)=>r===n[o])}s(C,"same");function L(e,n){if(e.length<5||n.length<5||Math.abs(e.length-n.length)>1||/\d/u.test(e+n))return!1;let r=0;for(;r<Math.min(e.length,n.length)&&e[r]===n[r];)r++;if(e.length===n.length)return e.slice(r+1)===n.slice(r+1)||e[r]===n[r+1]&&e[r+1]===n[r]&&e.slice(r+2)===n.slice(r+2);let o=e.length<n.length?e:n,i=e.length<n.length?n:e;return o.slice(r)===i.slice(r+1)}s(L,"oneTypo");function M(e,n){if(e.join("")===n.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let r=e.length<n.length?e:n,o=e.length<n.length?n:e;if(o.length===r.length+1&&r.length>=2&&r.every(l=>l.length>=3)){let l=C(r,o.slice(1)),c=C(r,o.slice(0,-1));if(l||c)return{kind:"component",reason:`${e.length>n.length?"remove":"add"} ${l?"leading":"trailing"} component '${l?o[0]:o.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||!L(a.word,a.other)))return{kind:"typo",reason:`one character edit: '${a.word}' \u2192 '${a.other}'`}}s(M,"relation");var A={normalized:0,component:1,typo:2};function E(e,n){if(!g(e))return[];let r=w(e);if(r.length===0)return[];let o=[];for(let i of new Set(n)){if(i===e||!g(i))continue;let a=M(r,w(i));a&&o.push({identifier:i,...a})}return o.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(E,"rankFuzzyIdentifiers");function _(e,n,r){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(o=>o.source)).size,selection:{...f(e.matches.slice(0,d.previewMatches),e.complete,n,r),truncated:e.matches.length>d.previewMatches}}}s(_,"fuzzyCandidateData");function O(e){let n=e.selection.complete?"":"+",r=e.selection.all?.line??e.selection.matches[0]?.references?.line,o=e.selection.matches[0],i=r??o?.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}${r||!o?"":` \xB7 line ${o.range.startLine}`}`]:[]].join(`
|
|
2
|
+
`)}s(O,"formatFuzzyCandidate");export{P as a,$ as b,d as c,I as d,g as e,S as f,E as g,_ as h,O as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-L2B4DTVS.js";import{c as S,d as M}from"./chunk-W7CASEO3.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Container as _,Key as x,matchesKey as P,SelectList as k,Text as v,truncateToWidth as T,visibleWidth as A}from"@earendil-works/pi-tui";var I=class{constructor(e,o,s){this.registry=e;this.activityMode=o;e.onDidChange(()=>this.#s()),s.registerCommand("agent-ide-processes",{description:"Show active terminal and debugger processes created by Agent IDE",handler:n(async(d,c)=>{if(this.bind(c),c.mode!=="tui"){c.ui.notify("The Agent IDE process overlay requires the TUI.","info");return}await this.#r(c)},"handler")})}static{n(this,"AgentIdeProcessesUi")}#t;#i=!1;#e;bind(e){this.#i||(this.#t=e,this.#s())}dispose(){this.#i=!0,this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0,this.#t?.ui.setWidget("agent-ide-processes",void 0),this.#t?.ui.setStatus("agent-ide-processes",void 0),this.#t=void 0}#n(){return this.registry.list()}#s(){let e=this.#t;if(this.#i||e===void 0||!e.hasUI)return;let o=this.#n();if(this.activityMode==="off"||o.length===0){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",void 0),this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0;return}if(this.activityMode==="compact"){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",`Agent IDE processes: ${o.length}`);return}e.ui.setStatus("agent-ide-processes",void 0),e.ui.setWidget("agent-ide-processes",(s,d)=>({invalidate(){},render:n(c=>q(o,c,d),"render")}),{placement:"belowEditor"}),this.#e??=setInterval(()=>this.#s(),1e3)}async#r(e){for(;;){if(this.#n().length===0){e.ui.notify("No active Agent IDE processes.","info");return}let o=n(()=>{},"disposeRefresh"),s,d;try{d=await e.ui.custom((g,a,O,E)=>{let h=this.#n(),l="list",f,$=n(r=>{let u=h.map(t=>({value:t.source,label:`${t.status} ${t.kind} ${t.title}`,description:t.description})),p=new k(u,Math.min(u.length,12),{selectedPrefix:n(t=>a.fg("accent",t),"selectedPrefix"),selectedText:n(t=>a.fg("accent",t),"selectedText"),description:n(t=>a.fg("muted",t),"description"),scrollInfo:n(t=>a.fg("dim",t),"scrollInfo"),noMatch:n(t=>a.fg("warning",t),"noMatch")}),y=u.findIndex(t=>t.value===r);return y>=0&&p.setSelectedIndex(y),p.onSelect=t=>{f=h.find(W=>W.source===t.value),l="detail",g.requestRender()},p.onCancel=()=>E(null),p},"createList"),m=$(),C=n(()=>{let r=f?.source??m.getSelectedItem()?.value;h=this.#n(),f=l==="list"?void 0:h.find(u=>u.source===r),m=$(r),g.requestRender()},"refresh");return o=this.registry.onDidChange(C),s=setInterval(C,1e3),{invalidate:n(()=>m.invalidate(),"invalidate"),render(r){let u=new _;l==="list"?(u.addChild(m),u.addChild(new v(a.fg("dim",h.length===0?"esc close":"enter view \xB7 d stop \xB7 esc close"),1,0))):f===void 0?(u.addChild(new v(a.fg("warning","Process is no longer active."),1,0)),u.addChild(new v(a.fg("dim","esc back"),1,0))):(u.addChild(f.renderDetail(a)),u.addChild(new v(a.fg(l==="confirm"?"warning":"dim",l==="confirm"?"Stop this process? y confirm \xB7 n/esc cancel":l==="input"?"input mode \xB7 type to send \xB7 esc stop input":f.sendInput===void 0?"esc back \xB7 d stop":"i input \xB7 esc back \xB7 d stop"),1,0)));let p=n(t=>a.fg("accent",t),"accent"),y=Math.max(1,r-2);return[D("Agent IDE Processes",`${h.length} active`,r,p),...u.render(y).map(t=>b(t,r,p)),R(r,p)]},handleInput(r){l==="list"?r==="d"?(f=h.find(u=>u.source===m.getSelectedItem()?.value),f!==void 0&&(l="confirm")):m.handleInput(r):l==="detail"?P(r,x.escape)?l="list":r==="d"&&f!==void 0?l="confirm":r==="i"&&f?.sendInput!==void 0&&(l="input"):l==="input"?P(r,x.escape)?l="detail":f?.sendInput?.(r):r==="y"&&f!==void 0?E({source:f.source}):(r==="n"||P(r,x.escape))&&(l="detail"),g.requestRender()}}},{overlay:!0,overlayOptions:{width:"75%",maxHeight:"80%",minWidth:52}})}finally{o(),s!==void 0&&clearInterval(s)}if(d===null)return;let c=this.#n().find(g=>g.source===d.source);c!==void 0&&await c.stop()}}};function q(i,e,o){if(i.length===0)return[];let s=n(c=>o.fg("accent",c),"accent"),d=[D("Agent IDE Processes",`${i.length} active`,e,s)];for(let[c,g]of i.entries()){for(let a of g.renderSummary(o))d.push(b(` ${a} `,e,s));c<i.length-1&&d.push(b("",e,s))}return d.push(R(e,s)),d}n(q,"renderProcessWidget");function D(i,e,o,s){if(o<=1)return s("\u256D");let d=o-2,c=`\u2500 ${i} `,g=` ${e} \u2500`,a="\u2500".repeat(Math.max(0,d-A(c)-A(g)));return s(`\u256D${T(`${c}${a}${g}`,d).padEnd(d,"\u2500")}\u256E`)}n(D,"borderTop");function b(i,e,o){if(e<=1)return o("\u2502");let s=e-2,d=T(i,s);return`${o("\u2502")}${d}${" ".repeat(Math.max(0,s-A(d)))}${o("\u2502")}`}n(b,"borderLine");function R(i,e){return e(i<=1?"\u2570":`\u2570${"\u2500".repeat(i-2)}\u256F`)}n(R,"borderBottom");async function L(i){let e=w(i),o=await M(S()),s=new I(e,K(o.preferences?.["processes.activity"]),i);i.on("session_start",(d,c)=>s.bind(c)),i.on("session_shutdown",()=>s.dispose())}n(L,"registerAgentIdeProcesses");function K(i){return i==="compact"||i==="off"?i:"detailed"}n(K,"activityMode");export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as T,i as m,j as M}from"./chunk-
|
|
1
|
+
import{f as T,i as m,j as M}from"./chunk-DXONCYWF.js";import{a as p}from"./chunk-EI7MMDWY.js";import{Type as o}from"typebox";var E=o.Union([o.Literal("pending"),o.Literal("applied"),o.Literal("not-applied"),o.Literal("unknown")]),b=o.Object({source:o.String(),effect:E,state:o.Optional(o.Union([o.Literal("present"),o.Literal("absent"),o.Literal("unknown")]))},{additionalProperties:!1}),L={effect:E,files:o.Array(b)};function R(n){return o.Object({operation:o.Literal(n),...L,operationId:o.Optional(o.String()),...n==="delete"?{}:{target:o.Optional(o.String()),targetUnavailable:o.Optional(o.String())}},{additionalProperties:!1})}p(R,"mutationDataSchema");function v(n){return T(R(n))}p(v,"mutationResultSchema");function u(n){return typeof n=="object"&&n!==null}p(u,"record");function U(n,c,h=[]){let r=n.details,l=u(r)?r:{};if((u(r)&&u(r.nativeEditBatch)?r.nativeEditBatch:void 0)?.state==="accepted")return{status:"success",errors:[],data:{operation:c,effect:"pending",...c!=="delete"&&typeof r.metadata?.resultTarget=="string"?{target:r.metadata.resultTarget}:{},files:typeof l.source=="string"?[{source:l.source,effect:"pending"}]:[]}};let g=new Set(h.map(t=>t.resourceSource)),s=[],f=[],y=r.results;for(let t of y??[]){let e=t.data,k=[...new Set([...(e.files??[]).map(i=>i.path),...e.path?[e.path]:[],...e.rollback?.failedSources??[],...e.rollback?.restoredSources??[]])];for(let i of k)f.push({source:i,...g.has(i)?{state:"present"}:{},effect:g.has(i)||e.ok===!0&&e.files?.some(A=>A.path===i)?"applied":e.rollback?.failedSources.includes(i)?"unknown":e.rollback?.restoredSources.includes(i)?"not-applied":r.effect??"unknown"});for(let i of e.errors??[])s.push({code:i.code??"MUTATION_FAILED",message:i.reason??"Mutation failed",source:i.path});e.ok===!1&&(e.errors?.length??0)===0&&s.push({code:"MUTATION_FAILED",message:"Mutation failed",...e.path?{source:e.path}:{}})}for(let t of g)f.some(e=>e.source===t)||f.push({source:t,effect:"applied",state:"present"});let a=u(r.metadata)&&u(r.metadata.semanticAction)?r.metadata.semanticAction:void 0;if(a){let t=a.effect==="not-applied"||a.effect==="unknown"?a.effect:a.ok===!1?"unknown":"applied",e=typeof a.source=="string"?a.source:void 0;e&&f.push({source:e,...a.kind==="file-operation"&&a.ok===!0?{state:c==="delete"||c==="move"?"absent":"present"}:{},effect:c==="copy"&&typeof a.target=="string"&&a.target!==e?"not-applied":t}),typeof a.target=="string"&&f.push({source:a.target,effect:t,...a.kind==="file-operation"&&a.ok===!0?{state:"present"}:{}}),u(a.error)&&s.push(m(a.error.message,typeof a.error.code=="string"?a.error.code:"MUTATION_FAILED",e)),typeof a.postProcessingError=="string"&&s.push(m(a.postProcessingError,"POST_EDIT_FAILED",e)),a.ok===!1&&s.length===0&&s.push(m("Resource operation failed","MUTATION_FAILED",e))}let d=[...new Map(f.map(t=>[t.source,t])).values()];if(Array.isArray(r.metadata?.resultFileStates))for(let t of r.metadata.resultFileStates){if(!u(t))continue;let e=d.find(k=>k.source===t.source);e&&(t.state==="present"||t.state==="absent")&&(e.state=t.state)}let S=d.some(t=>t.effect==="applied");n.isError&&s.length===0&&s.push({code:"MUTATION_FAILED",message:"Mutation failed"}),(y?.length??0)===0&&!a&&g.size===0&&s.length===0&&r.effect!=="not-applied"&&s.push({code:"UNKNOWN_RESULT",message:"Mutation effects were not reported"});let w=r.effect==="unknown"||d.some(t=>t.effect==="unknown")||s.some(t=>t.code==="UNKNOWN_RESULT")?"unknown":S?"applied":"not-applied";return{status:s.length===0?"success":!a&&S&&d.some(t=>t.effect!=="applied")?"partial":"error",data:{operation:c,effect:w,files:d,...c!=="delete"&&typeof r.metadata?.resultTarget=="string"?{target:r.metadata.resultTarget}:{},...c!=="delete"&&typeof r.metadata?.targetUnavailable=="string"?{targetUnavailable:r.metadata.targetUnavailable}:{}},errors:s}}p(U,"mutationOutcome");function F(n,c,h=[],r){let l=U(n,c,h);return l.data&&r!==void 0&&(l.data.operationId=r),M(n,R(c),l)}p(F,"structuredMutation");export{R as a,v as b,U as c,F as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as p,c as y,d as w,e as g,f as b,g as l}from"./chunk-4HWKBCBH.js";import{a as c}from"./chunk-EI7MMDWY.js";import{spawn as v}from"node:child_process";import{PassThrough as S}from"node:stream";import{Type as r}from"typebox";import{Value as L}from"typebox/value";var I=r.Union([r.Object({kind:r.Literal("ready"),pid:r.Integer({minimum:1}),identity:r.Optional(r.String({pattern:"^[a-f0-9-]+:[0-9]+$"}))}),r.Object({kind:r.Literal("ack"),id:r.Integer({minimum:1})}),r.Object({kind:r.Union([r.Literal("stdout"),r.Literal("stderr")]),bytes:r.String({maxLength:32768})}),r.Object({kind:r.Literal("exit"),exitCode:r.Integer()}),r.Object({kind:r.Literal("error"),code:r.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:r.Union([r.Literal("not-applied"),r.Literal("unknown")])})]);async function R(a,e,t,s,i={}){y(a),i.pty&&E(i.pty.cols,i.pty.rows);let d=p(a.id,s).source,n=i.timeoutMs??3e4;if(!Number.isFinite(n)||n<=0)throw new TypeError("SSH startup deadline must be positive");i.signal?.throwIfAborted();let o=await w(new URL("./ssh-channel-worker.py",new URL("../src/backend/ssh-channel.ts",import.meta.url).href));i.signal?.throwIfAborted();let u=JSON.stringify({command:e,args:t,cwd:s,...i.pty?{pty:i.pty}:{}});if(Buffer.byteLength(u)>48*1024*1024)throw new l("FRAME_LIMIT",d,"not-applied");let h=v("ssh",g(a,o),{stdio:"pipe"}),f=new m(h,d,i.pty!==void 0,i.signal),P=setTimeout(()=>f.cancel("TIMEOUT"),n);try{return await f.sendInitial(u),await f.ready,f}finally{clearTimeout(P)}}c(R,"startSshProcess");function E(a,e){if(![a,e].every(t=>Number.isSafeInteger(t)&&t>0&&t<=1e3))throw new TypeError("PTY dimensions must be integers between 1 and 1000")}c(E,"validateDimensions");var m=class{constructor(e,t,s,i){this.child=e;this.source=t;this.pty=s;this.ready=new Promise((n,o)=>{this.#c=n,this.#l=o}),this.completion=new Promise((n,o)=>{this.#u=n,this.#f=o}),this.ready.catch(()=>{}),this.completion.catch(()=>{}),e.stdout.on("data",n=>{this.#e=Buffer.concat([this.#e,n]),this.parse()}),e.stderr.on("data",n=>{this.#d.length<16384&&(this.#d+=n.toString())}),e.stdin.on("error",()=>{}),e.once("error",()=>{this.#i="DEPENDENCY_UNAVAILABLE"});let d=c(()=>this.cancel("CANCELLED"),"abort");i?.addEventListener("abort",d,{once:!0}),e.once("close",n=>{this.#r=!0,this.#S=n,clearTimeout(this.#E),i?.removeEventListener("abort",d);let o=this.#i??(n!==0?b(n,this.#d):this.#s===void 0?"TRANSPORT_FAILED":void 0);this.stdout.end(),this.stderr.end();let u=this.error(o??"INPUT_CLOSED");for(let h of this.#t.values())h.reject(u);if(this.#t.clear(),o){let h=this.error(o);this.#l(h),this.#f(h)}else this.#s!==void 0&&this.#u({exitCode:this.#s})});for(let n of[this.stdout,this.stderr]){let o=c(()=>{this.#n.delete(n),this.parse(),this.#n.size===0&&e.stdout.resume()},"resume");n.on("drain",o),n.on("close",o)}i?.aborted&&d()}static{c(this,"ProcessChannel")}stdout=new S({highWaterMark:65536});stderr=new S({highWaterMark:65536});completion;ready;#t=new Map;#n=new Set;#c;#l;#u;#f;#e=Buffer.alloc(0);#d="";#i;#m;#p=!1;#y=!1;#w=0;#g;#r=!1;#b=!1;#o=!1;#s;#S;#P=0;#a=0;#h=Promise.resolve();#E;get pid(){return this.#w}get identity(){return this.#g}async sendInitial(e){this.#p=!0,await this.sendLine(e)}async write(e){if(this.#r||this.#b||this.#o)throw this.error("INPUT_CLOSED");if(this.#a+e.length>1024*1024)throw this.error("INPUT_LIMIT");let t=Buffer.from(e);this.#a+=t.length;let s=this.#h.then(async()=>{for(let i=0;i<t.length;i+=16384){if(this.#o||this.#r)throw this.error("INPUT_CLOSED");await this.sendAcknowledged({kind:"input",bytes:t.subarray(i,i+16384).toString("base64")})}});this.#h=s.catch(()=>{});try{await s}finally{this.#a-=t.length}}async end(){if(this.pty)throw new l("PTY_INPUT_NOT_CLOSABLE",this.source,"not-applied");this.#b=!0,await this.#h,await this.send({kind:"end"})}async resize(e,t){if(!this.pty)throw new l("PTY_REQUIRED",this.source,"not-applied");E(e,t),await this.sendAcknowledged({kind:"resize",cols:e,rows:t})}stop(){return!this.#r&&!this.#o&&(this.#o=!0,this.send({kind:"stop"}).catch(()=>{}),this.#E=setTimeout(()=>{this.#i??="TRANSPORT_FAILED",this.child.kill("SIGKILL")},5e3),this.child.stdout.resume(),this.stdout.resume(),this.stderr.resume()),this.completion.catch(e=>{if(this.#i==="CANCELLED"&&this.#S===0&&this.#s!==void 0)return{exitCode:this.#s};throw e})}cancel(e){this.#r||(this.#i??=e,this.stop().catch(()=>{}))}error(e){let t=["HOST_KEY_FAILED","AUTH_FAILED","DEPENDENCY_UNAVAILABLE"].includes(e),s=this.#m??(!this.#p||t?"not-applied":"unknown");return new l(e,this.source,s)}async sendAcknowledged(e){let t=++this.#P,s=new Promise((i,d)=>{this.#t.set(t,{resolve:i,reject:d})});s.catch(()=>{});try{await this.send({...e,id:t}),await s}finally{this.#t.delete(t)}}async send(e){await this.sendLine(JSON.stringify(e))}sendLine(e){return this.#r?Promise.reject(this.error("INPUT_CLOSED")):new Promise((t,s)=>{this.child.stdin.write(`${e}
|
|
2
|
+
`,i=>{i?s(this.error("INPUT_CLOSED")):t()})})}parse(){for(;this.#n.size===0;){let e=this.#e.indexOf(10);if(e<0){this.#e.length>65536&&this.cancel("FRAME_LIMIT");return}if(e>65536){this.cancel("FRAME_LIMIT");return}let t=this.#e.subarray(0,e);this.#e=this.#e.subarray(e+1);let s;try{s=JSON.parse(t.toString("utf8"))}catch{this.cancel("INVALID_RESPONSE");return}if(!L.Check(I,s)){this.cancel("INVALID_RESPONSE");return}this.receive(s)}this.child.stdout.pause()}receive(e){if(e.kind==="ready"){if(this.#y){this.cancel("INVALID_RESPONSE");return}this.#y=!0,this.#w=e.pid,this.#g=e.identity,this.#c()}else if(e.kind==="ack"){let t=this.#t.get(e.id);if(!t){this.cancel("INVALID_RESPONSE");return}this.#t.delete(e.id),t.resolve()}else if(e.kind==="exit")this.#s=e.exitCode;else if(e.kind==="error")this.#i=e.code,this.#m=e.effect;else{let t=Buffer.from(e.bytes,"base64");if(t.toString("base64")!==e.bytes){this.cancel("INVALID_RESPONSE");return}let s=e.kind==="stdout"?this.stdout:this.stderr;!s.destroyed&&!s.write(t)&&this.#n.add(s)}}};export{R as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a,e as s}from"./chunk-756K3LJY.js";import{a as t}from"./chunk-EI7MMDWY.js";import{access as b}from"node:fs/promises";async function p(r,o){if(r.signal?.throwIfAborted(),r.workspace)return r.workspace.exists(o,r.signal);if(o.includes("://"))throw Object.assign(new Error("Doctor needs the file owner"),{code:"UNSUPPORTED_SOURCE"});try{return await b(o),r.signal?.throwIfAborted(),!0}catch(e){if(r.signal?.throwIfAborted(),typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return!1;throw e}}t(p,"projectFileExists");async function f(r,o,e){if(r.signal?.throwIfAborted(),!r.workspace){let n=await s(o,e,r.cwd,r.env,r.signal);return r.signal?.throwIfAborted(),n}let i=await r.workspace.run({command:[o,...e],timeoutMs:5e3},r.cwd,r.signal);r.signal?.throwIfAborted();let l=(i.stdout.trim()||i.stderr.trim()).split(/\r?\n/u)[0]||`${o} exited with code ${String(i.exitCode)}`;return{ok:i.ok,detail:l}}t(f,"probeProjectExecutable");async function c(r,o){if(r.signal?.throwIfAborted(),!r.workspace)return a(o,r.cwd,r.env,r.signal);let e=await r.workspace.executableAvailability([{command:[o]}],r.signal);if(r.signal?.throwIfAborted(),e.length!==1||typeof e[0]!="boolean")throw new TypeError("Invalid Doctor availability report");return e[0]}t(c,"projectExecutableAvailable");export{p as a,f as b,c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-EI7MMDWY.js";var i=["PI_PYTHON_PATH","PI_JS_DEBUG_PATH","PI_ELIXIR_LS_DEBUG_PATH","PI_R_PATH","PI_LLDB_DAP_PATH","PI_DELVE_PATH","PI_KOTLIN_DEBUG_ADAPTER_PATH","PI_JULIA_DEBUG_PROJECT","PI_DART_PATH","PI_JULIA_PATH","PI_NETCOREDBG_PATH","PI_RUBY_DEBUG_PATH","PI_PHP_PATH","PI_PHP_DEBUG_PATH","PI_LUA_PATH","PI_LUA_DEBUG_PATH","PI_BASH_PATH","PI_BASH_DEBUG_PATH","PI_PWSH_PATH","PI_POWERSHELL_EDITOR_SERVICES_PATH"];var t="pi-agent-ide-doctor",n=1,s="pi-agent-ide-doctor/core/ready",l="pi-agent-ide-doctor/plugin/register";function c(o){return r(o)&&o.protocol===t&&o.apiVersion===n}e(c,"isDoctorCoreReady");function d(o){return!r(o)||typeof o.accept!="function"||!r(o.plugin)?!1:o.plugin.protocol===t&&o.plugin.apiVersion===n&&typeof o.plugin.id=="string"&&o.plugin.id.length>0&&typeof o.plugin.setup=="function"}e(d,"isDoctorPluginRegistrationRequest");function r(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}e(r,"isRecord");export{i as a,t as b,n as c,s as d,l as e,c as f,d as g};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as le,b as fe,c as ue}from"./chunk-LLRUJD62.js";import{a as de}from"./chunk-Q5X6OXNS.js";import{a as N,g as l}from"./chunk-4HWKBCBH.js";import{a as se}from"./chunk-47SPPIXK.js";import{a as ie,b as ae}from"./chunk-VAXLSPPU.js";import{c as ce}from"./chunk-W7CASEO3.js";import{e as q,f as Z}from"./chunk-T7I2VX3J.js";import{a as ne}from"./chunk-M4TVRCMZ.js";import{b as te,c as re,d as oe}from"./chunk-TGC2ZACO.js";import"./chunk-NNCZYO4Q.js";import{d as ee}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as G}from"./chunk-BU7IZLKB.js";import{a as H,b as V}from"./chunk-S5PL5DFQ.js";import{F as z}from"./chunk-DXONCYWF.js";import{r as J}from"./chunk-ZPT5D4VP.js";import{a as X}from"./chunk-ZAWRSA7N.js";import{a as x,b as Q}from"./chunk-OFILFO6D.js";import"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import pe from"node:path";import{StringDecoder as Oe}from"node:string_decoder";function he(r){return(i,a)=>{let n=r.resolve(i.path??".",a.cwd);if(n===void 0)return;let{backend:c,location:w}=n,e=s((t,o=w.source)=>{let m=r.resolve(t,o);if(m===void 0||m.backend!==c)throw new l("UNSUPPORTED_SOURCE",t,"not-applied");return m.location},"own");return{resolve:s((t,o)=>e(o,t.includes("://")?t:w.source).source,"resolve"),dirname:s(t=>N(w.target,pe.posix.dirname(e(t).path)).source,"dirname"),basename:s(t=>pe.posix.basename(e(t).path),"basename"),isDirectory:s(async(t,o)=>(await c.stat(e(t).path,{signal:o})).kind==="directory","isDirectory"),byteSize:s(async(t,o)=>(await c.stat(e(t).path,{signal:o})).size,"byteSize"),readText:s(async(t,o)=>(await c.read(e(t).path,{signal:o})).bytes.toString("utf8"),"readText"),async execute(t,o,m,R){let d=await c.execute(t,o,e(m).path,{signal:R});return{code:d.exitCode,stdout:d.stdout.toString("utf8"),stderr:d.stderr.toString("utf8")}},async runLines(t,o,m,R){let d=await c.startProcess("rg",t,e(o).path,{signal:R}),g=new Oe("utf8"),u=[],p=0,f="",h,y=s(k=>{let E=k.split(`
|
|
2
|
+
`);for(let[O,b]of E.entries()){if(u.push(b),p+=Buffer.byteLength(b),p>32*1024*1024)throw new l("CONTENT_LIMIT",w.source,"not-applied");O<E.length-1&&(m(u.join("")),u.length=0,p=0)}},"consume"),v=(async()=>{try{for await(let k of d.stdout)y(g.write(k));y(g.end()),p>0&&m(u.join(""))}catch(k){h=k,await d.stop()}})(),T=(async()=>{for await(let k of d.stderr)f+=k.toString("utf8"),f.length>65536&&(f=f.slice(-65536))})();try{try{await d.end()}catch(E){if(!(E instanceof l)||E.code!=="INPUT_CLOSED")throw E}let k=await d.completion;if(await Promise.all([v,T]),h!==void 0)throw h instanceof Error?h:new Error("Search output failed.",{cause:h});return R?.throwIfAborted(),{code:k.exitCode,stderr:f}}finally{await d.stop(),await Promise.allSettled([v,T])}}}}}s(he,"createSshSearchEnvironmentProvider");import{lstat as Ue,mkdir as ke,rm as Me,symlink as He,unlink as Ve,open as Ge}from"node:fs/promises";import A from"node:path";import{constants as $}from"node:fs";import{createHash as Pe,randomBytes as Te}from"node:crypto";import{constants as we}from"node:fs";import{lstat as Ie,mkdir as Ne,open as me,readFile as Ce,rename as _e,rm as Ae,unlink as Fe}from"node:fs/promises";import D from"node:path";import{fileURLToPath as Le}from"node:url";function C(r,i,a){if(a?.has(r)&&a.get(r)!==i)throw new l("CONFLICT",r,"not-applied")}s(C,"checkCapturedRevision");var Be=1024*1024,De=Ce(new URL("./ssh-transfer-worker.py",new URL("../src/backend/file-transfer.ts",import.meta.url).href),"utf8");function j(r,i){if(r.startsWith("file:"))try{return Le(r)}catch{throw new l("UNSUPPORTED_SOURCE",r,"not-applied")}if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");if(i.startsWith("ssh://"))throw new l("UNSUPPORTED_SOURCE",r,"not-applied");return D.resolve(i,r)}s(j,"localTransferSource");function F(r){return[r.dev,r.ino,r.mode,r.uid,r.gid,r.size,r.mtimeNs,r.ctimeNs].join(":")}s(F,"localRevision");async function U(r){let i=await Ie(r,{bigint:!0});if(!i.isFile()||i.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");if(i.size>BigInt(Number.MAX_SAFE_INTEGER))throw new l("CONTENT_LIMIT",r,"not-applied");return i}s(U,"localEntry");function ye(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code==="ENOENT"}s(ye,"missing");function ge(r){return r!==null&&typeof r=="object"&&"code"in r&&typeof r.code=="string"&&/^[A-Z][A-Z0-9_]*$/u.test(r.code)?r.code:"TRANSFER_FAILED"}s(ge,"errorCode");async function je(r,i,a,n){a.signal?.throwIfAborted();let c=r.resolve(i.path,a.cwd),w=r.resolve(i.target??"",a.cwd),e=c?.location.source??j(i.path,a.cwd),t=w?.location.source??j(i.target??"",a.cwd);if(e===t)throw new l("SAME_FILE",e,"not-applied");let o=c?await c.backend.lstat(c.location.path,a):await U(e);if("kind"in o&&o.kind!=="file")throw new l("INVALID_FILE_TYPE",e,"not-applied");let m=Number(o.size),R=Number(o.mode),d="revision"in o?o.revision:F(o);C(e,d,n);let g;try{g=w?await w.backend.lstat(w.location.path,a):await U(t)}catch(p){if(!ye(p))throw p}if(g!==void 0){if("kind"in g&&g.kind!=="file")throw new l("INVALID_FILE_TYPE",t,"not-applied");if(C(t,"revision"in g?g.revision:F(g),n),c&&w&&c.backend.target.host===w.backend.target.host&&c.backend.target.configFile===w.backend.target.configFile&&"identity"in o&&"identity"in g&&o.identity.device===g.identity.device&&o.identity.inode===g.identity.inode)throw new l("SAME_FILE",e,"not-applied")}let u=g===void 0?null:"revision"in g?g.revision:F(g);return g===void 0&&C(t,null,n),{source:e,target:t,remoteSource:c,remoteTarget:w,size:m,mode:R,sourceRevision:d,targetRevision:u}}s(je,"prepareTransfer");async function Y(r,i,a,n,c,w){let{source:e,target:t,remoteSource:o,remoteTarget:m,size:R,mode:d,sourceRevision:g,targetRevision:u}=await je(r,a,n,c);await w?.();let p=o?void 0:await me(e,we.O_RDONLY|we.O_NOFOLLOW),f,h,y,v=!1,T="",k=s(async()=>{let E=o?await o.backend.lstat(o.location.path,n):await U(e);if(("revision"in E?E.revision:F(E))!==g)throw new l("CONFLICT",e,"not-applied")},"verifySource");try{if(p&&F(await p.stat({bigint:!0}))!==g)throw new l("CONFLICT",e,"not-applied");m?(y=await de(m.backend.target,"python3",["-c",await De,JSON.stringify({destination:m.location.path,size:R,mode:d,expected:u})],"/",n),y.completion.catch(()=>{}),y.stdout.on("data",b=>{T.length<=8192&&(T+=b.toString("utf8")),T.length>8192&&y?.stop().catch(()=>{})}),y.stderr.resume()):(await Ne(D.dirname(t),{recursive:!0}),f=D.join(D.dirname(t),`.pi-ide-transfer-${Te(12).toString("hex")}`),h=await me(f,"wx",d&4095));let E=Pe("sha256");for(let b=0;b<R;){n.signal?.throwIfAborted();let S=Math.min(Be,R-b),I;if(o){let P=await o.backend.readRange(o.location.path,b,S,n);if(P.revision!==g||P.offset!==b||P.totalBytes!==R)throw new l("CONFLICT",e,"not-applied");I=P.bytes}else{if(p===void 0)throw new Error("Missing source descriptor");let P=Buffer.allocUnsafe(S),{bytesRead:B}=await p.read(P,0,S,b);I=P.subarray(0,B)}if(I.length===0)throw new l("CONFLICT",e,"not-applied");if(E.update(I),y)await y.write(I);else{if(h===void 0)throw new Error("Missing destination descriptor");for(let P=0;P<I.length;){let B=await h.write(I,P,I.length-P);if(B.bytesWritten===0)throw new l("TRANSFER_FAILED",t,"not-applied");P+=B.bytesWritten}}b+=I.length}await k(),await w?.();let O=E.digest("hex");if(n.signal?.throwIfAborted(),y){if(await y.write(Buffer.from(`${JSON.stringify({sha256:O})}
|
|
3
|
+
`)),await y.end(),(await y.completion).exitCode!==0||T.length>8192)throw new l("TRANSFER_FAILED",t,"unknown");let S;try{S=JSON.parse(T)}catch{throw new l("INVALID_REPLY",t,"unknown")}if(S===null||typeof S!="object"||!("ok"in S))throw new l("INVALID_REPLY",t,"unknown");if(S.ok!==!0){let I="effect"in S&&(S.effect==="not-applied"||S.effect==="applied")?S.effect:"unknown";throw new l(ge(S),t,I)}if(!("sha256"in S)||S.sha256!==O)throw new l("CHECKSUM_MISMATCH",t,"unknown");v=!0}else{if(h===void 0||f===void 0)throw new Error("Missing staged destination");await h.chmod(d&4095),await h.sync(),await h.close(),h=void 0;let b=null;try{b=F(await U(t))}catch(S){if(!ye(S))throw S}if(b!==u)throw new l("CONFLICT",t,"not-applied");n.signal?.throwIfAborted(),await _e(f,t),f=void 0,v=!0}return i==="move"&&(await k(),o?await o.backend.removeEntry(o.location.path,g,n):await Fe(e)),{source:e,target:t}}catch(E){throw v?new l(ge(E),e,"unknown"):E}finally{await p?.close(),await h?.close(),f!==void 0&&await Ae(f,{force:!0}),y&&await y.stop().catch(()=>{})}}s(Y,"transferFile");function Re(r,i,a){let n=r.resolve(i,a.cwd);if(n===void 0){let e=j(i,a.cwd);return{path:e,source:e,cwd:a.cwd,files:te}}let c=r.resolve(a.cwd,a.cwd),w=c?.location.target===n.location.target?c.location.path:n.backend.target.workspace;return{remote:n,source:n.location.source,path:n.location.path,cwd:w,files:{owner:JSON.stringify([n.backend.target.host,n.backend.target.configFile??null]),realpath:s(e=>n.backend.realpath(e,a),"realpath"),inspect:s(e=>n.backend.lstat(e,a),"inspect"),read:s(async e=>(await n.backend.read(e,a)).bytes.toString("utf8"),"read"),git:s((e,t,o)=>n.backend.queryGit(e,t,{...a,signal:o}),"git"),source:s(e=>N(n.location.target,e).source,"source"),snapshot:s((e,t)=>n.backend.objectSnapshot(e,{...a,signal:t}),"snapshot")}}}s(Re,"endpoint");function L(r,i,a){let n=r.remote?A.posix:A;if(n.sep==="\\"&&a.split("/").some(c=>c.includes("\\")||c.includes(":")))throw new l("INVALID_TARGET",r.source,"not-applied");return n.join(i,...a.split("/"))}s(L,"leaf");function K(r,i){return r.remote?N(r.remote.location.target,i).source:i}s(K,"receiptPath");async function _(r,i,a){let n;try{n=await r.files.inspect(i)}catch(c){if(c!==null&&typeof c=="object"&&"code"in c&&c.code==="ENOENT"){if(a===void 0)return}else throw c}if(a===void 0||n?.revision!==a.revision)throw new l("TRANSFER_TARGET_CHANGED",K(r,i),"not-applied")}s(_,"checkEntry");async function M(r){let i;try{i=await Ue(r)}catch(a){if(a===null||typeof a!="object"||!("code"in a)||a.code!=="ENOENT")throw a;await M(A.dirname(r)),await ke(r);return}if(!i.isDirectory()||i.isSymbolicLink())throw new l("INVALID_FILE_TYPE",r,"not-applied");A.dirname(r)!==r&&await M(A.dirname(r))}s(M,"directoryParents");async function ve(r,i,a,n){r.remote?await r.remote.backend.removeObject(i,a.revision,n):(await _(r,i,a),a.kind==="directory"?await Me(i,{recursive:!0,force:!1}):await Ve(i))}s(ve,"remove");async function Ee(r,i,a,n,c,w){let e=Re(r,a.path,n),t=Re(r,a.target??"",n),o=await c.prepareTransfer(i,e,t),m=o.source.entries[0];if(m===void 0)throw new l("ENOENT",e.source,"not-applied");e.remote&&C(e.source,m.revision,w),t.remote&&C(t.source,o.target.entries[0]?.revision??null,w);let R=!1;try{n.signal?.throwIfAborted();for(let d of o.source.entries)L(e,o.source.path,d.relativePath),L(t,o.target.path,d.relativePath);if(o.sourceKind==="file")e.remote&&t.remote&&e.remote.location.target===t.remote.location.target?await e.remote.backend[i](o.source.path,o.target.path,m.revision,o.target.entries[0]?.revision??null,n):await Y(r,i,a,n,w,async()=>{await _(e,o.source.path,m),await _(t,o.target.path,o.target.entries[0])});else{if(i==="move"&&e.remote&&t.remote&&e.files.owner===t.files.owner&&await e.remote.backend.moveObject(o.source,o.target,n))return{kind:"file-operation",operation:i,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:o.sourceKind};let d=new Map(o.target.entries.map(u=>[u.relativePath,u])),g=new Map;i==="move"&&o.target.entries[0]&&(R=!0,await ve(t,o.target.path,o.target.entries[0],n),d.clear());for(let u of o.source.entries){n.signal?.throwIfAborted();let p=L(e,o.source.path,u.relativePath),f=L(t,o.target.path,u.relativePath);await _(e,p,u);let h=d.get(u.relativePath);if(await _(t,f,h),u.kind==="directory")h===void 0&&(R=!0),t.remote?await t.remote.backend.ensureObjectDirectory(f,u.mode|448,h?.revision??null,n):h===void 0&&(await M(A.dirname(f)),await ke(f,{mode:u.mode|448})),h===void 0&&g.set(u.relativePath,(await t.files.inspect(f)).identity);else if(u.kind==="symlink"){if(R=!0,u.link===void 0)throw new l("INVALID_RESPONSE",e.source,"unknown");t.remote?await t.remote.backend.createObjectLink(f,u.link,n):(await M(A.dirname(f)),await He(Buffer.from(u.link,"base64"),f))}else{R=!0;let y=K(e,p),v=K(t,f);e.remote&&t.remote&&e.files.owner===t.files.owner?await e.remote.backend.copy(p,f,u.revision,h?.revision??null,n):await Y(r,"copy",{path:y,target:v},n,void 0,async()=>{await _(e,p,u),await _(t,f,h)})}}for(let u of[...o.source.entries].reverse()){if(u.kind!=="directory"||d.has(u.relativePath))continue;let p=L(t,o.target.path,u.relativePath),f=await t.files.inspect(p),h=g.get(u.relativePath);if(f.kind!=="directory"||h?.device!==f.identity.device||h.inode!==f.identity.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");if(t.remote)await t.remote.backend.setObjectMode(p,u.mode,f.revision,n);else{let y=await Ge(p,$.O_RDONLY|$.O_DIRECTORY|$.O_NOFOLLOW);try{let v=await y.stat();if(String(v.dev)!==h.device||String(v.ino)!==h.inode)throw new l("TRANSFER_TARGET_CHANGED",t.source,"unknown");await y.chmod(u.mode&4095)}finally{await y.close()}}}await o.verifySource(),i==="move"&&await ve(e,o.source.path,m,n)}return{kind:"file-operation",operation:i,ok:!0,effect:"applied",path:e.source,target:t.source,sourceKind:o.sourceKind}}catch(d){throw R?Object.assign(d instanceof Error?d:new Error(String(d)),{effect:"unknown"}):d}}s(Ee,"transferObject");function Se(r,i){return async(a,n,c,w)=>{let e=r.resolve(n.path,c.cwd);if(e===void 0&&(n.target===void 0||r.resolve(n.target,c.cwd)===void 0))return;if(a!=="delete"){if(w===void 0)throw new l("TRANSFER_POLICY_REQUIRED",n.path,"not-applied");return Ee(r,a,n,c,w,i)}if(e===void 0)return;let t=await e.backend.lstat(e.location.path,c);C(e.location.source,t.revision,i);{if(w===void 0)throw new l("DELETE_POLICY_REQUIRED",e.location.source,"not-applied");let o=r.resolve(c.cwd,c.cwd);if(o!==void 0&&o.location.target!==e.location.target)throw new l("UNSUPPORTED_SOURCE",e.location.source,"not-applied");let m=o?.location.path??e.backend.target.workspace,R=await w.prepare(e.location.path,m,{temporaryEnvironment:s(d=>e.backend.temporaryEnvironment({...c,signal:d}),"temporaryEnvironment"),realpath:s(d=>e.backend.realpath(d,c),"realpath"),inspect:s(d=>e.backend.lstat(d,c),"inspect"),read:s(async d=>(await e.backend.read(d,c)).bytes.toString("utf8"),"read"),git:s((d,g,u)=>e.backend.queryGit(d,g,{...c,signal:u}),"git"),source:s(d=>N(e.location.target,d).source,"source")});if(R.revision!==t.revision)throw new l("DELETE_TARGET_CHANGED",e.location.source,"not-applied");return await e.backend.removeObject(R.resolvedPath,R.revision,c),{kind:"file-operation",operation:a,ok:!0,effect:"applied",path:e.location.source}}}}s(Se,"createSshFileOperationResolver");function W(r,i,a){return{id:"ssh",async tryResolve(n,c){try{let w=r.resolve(n,c.cwd);if(!w)return{kind:"not-handled"};let{backend:e,location:t}=w,o=!1;try{o=(await e.stat(t.path,c)).kind==="directory"}catch(p){if(!(p instanceof l)||p.code!=="ENOENT")throw p}let m,R,d=s(async p=>{try{let f=await e.read(t.path,p);return m=f.version,f.bytes}catch(f){throw f instanceof l&&f.code==="ENOENT"&&(m=null),f}},"snapshot"),g=s(async p=>{if(R=void 0,o){let h=(await e.list(t.path,p)).map(y=>` ${y.kind==="directory"?"\u{1F4C1}":y.kind==="file"?"\u{1F4C4}":"\u{1F517}"} ${y.name}`);return[{type:"text",text:[`\u{1F4C1} ${t.source}/`,...h.length?["",...h]:[]].join(`
|
|
4
|
+
`)}]}return R=await d(p),i.convert({source:t.source,bytes:R},p)},"read"),u=s(async(p,f,h)=>{let v=await e.readRange(t.path,p,Math.min(f??4194304,4194304),h),T=[v.bytes],k=v.bytes.length,E=Math.min(f??v.totalBytes,v.totalBytes-v.offset);for(;k<E;){let O=await e.readRange(t.path,v.offset+k,Math.min(E-k,4194304),h);if(O.revision!==v.revision||O.totalBytes!==v.totalBytes||O.offset!==v.offset+k)throw new l("SOURCE_CHANGED",t.source,"not-applied");if(O.bytes.length===0)break;T.push(O.bytes),k+=O.bytes.length}return{bytes:Buffer.concat(T,k),byteOffset:v.offset,totalBytes:v.totalBytes}},"readBytes");return a==="read"||o?{kind:"resolved",resource:{source:t.source,link:t.source,read:g,get sourceBytes(){return R},...o?{}:{readBytes:u}}}:{kind:"resolved",resource:{source:t.source,link:t.source,read:g,readBytes:u,get sourceBytes(){return R},async write(p,f){let h=J(p);if(m===void 0)try{await d(f)}catch(y){if(!(y instanceof l)||y.code!=="ENOENT")throw y}if(m===void 0)throw new l("SNAPSHOT_REQUIRED",t.source,"not-applied");m=await e.write(t.path,Buffer.from(h,"utf8"),m,f)}}}}catch(w){return{kind:"failed",error:w}}}}}s(W,"createSshResourceResolver");async function be(r,i){let a=await q({id:"ssh",description:"Set up SSH targets and use remote resources",triggers:[{tool:"read",resourcePrefixes:["ssh://","raw:ssh://","ast:ssh://","web:ssh://"]},{tool:"search",resourcePrefixes:["ssh://","web:ssh://"]},{tool:"debug",resourcePrefixes:["ssh://"]},...["write","replace","insert","delete","copy","move","stage","unstage","undo"].map(o=>({tool:o,resourcePrefixes:["ssh://"]}))]});if(Z(r,[{...a,markdown:`${a.markdown}
|
|
5
|
+
## Configured workspaces
|
|
6
|
+
|
|
7
|
+
${i.length===0?"No SSH targets are configured. Follow the setup steps above.":i.map(o=>`- \`${N(o.id,o.workspace).source}\``).join(`
|
|
8
|
+
`)}
|
|
9
|
+
`}]),await G(r,{protocol:H,apiVersion:V,id:"ssh-guidance",setup(o){o.addPromptGuideline("When the user asks to connect to or work on a remote device or environment over SSH, read docs:ssh first and follow its setup and usage steps.")}}),i.length===0)return;let n=new ue(i),c=z(r,{provider:"filesystem",capability:"read"}),w=z(r,{provider:"filesystem",capability:"write"}),e={protocol:H,apiVersion:V,id:"ssh",setup(o){o.addResolver({resolver:W(n,c,"read"),priority:-50,preserveTruncatedOutput:!0,renderResult:ee({kind:"source"})})}},t={protocol:re,apiVersion:oe,id:"ssh",setup(o){o.addFileOperationResolver(Se(n)),o.addResolver({resolver:W(n,w,"write"),priority:-50})}};await Promise.all([X(r,{protocol:x,apiVersion:5,id:"ssh-diagnostic-files",setup(o){o.addDiagnosticFileReader({id:"ssh",async readText(m,R){let d=n.resolve(m,R.cwd);if(d)return(await d.backend.read(d.location.path,{signal:R.signal})).bytes.toString("utf8")}})}}),G(r,e),ne(r,t),se(r,{protocol:ie,apiVersion:ae,id:"ssh",setup(o){o.addEnvironmentProvider(he(n))}})])}s(be,"registerSshResources");async function ze(r){let i=await fe(le(ce()));await be(r,i)}s(ze,"registerSshModule");export{ze as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-EI7MMDWY.js";import p from"node:path";import{fileURLToPath as u}from"node:url";function y(r,e){let n=`${e}:`;if(!r.startsWith(n))return;let t=r.slice(n.length),o=t.indexOf("#"),a=o===-1?t:t.slice(0,o);if(a.length===0)throw new TypeError(`${e}: requires a file path.`);let d=l(a,`${e}: path`),s=o===-1?void 0:t.slice(o+1);if(e==="ast"){if(s!==void 0)throw new TypeError("ast: accepts only a file path and does not accept a symbol selector.");return{scheme:e,path:d}}if(e==="symbol"&&s===void 0)throw new TypeError("symbol: requires #<symbol-selector> after the file path.");if(s===void 0)return{scheme:e,path:d};if(s.length===0)throw new TypeError(`${e}: symbol selector must not be empty.`);let f=s.split("/").map(c=>{if(c.length===0)throw new TypeError(`${e}: symbol selector contains an empty segment.`);return l(c,`${e}: symbol selector`)});return{scheme:e,path:d,selector:f}}i(y,"parseCodeViewReference");function h(r,e){if(r.startsWith("file://"))return u(new URL(r));if(r.startsWith("ssh://"))return r;if(r.includes("://"))throw new TypeError("Unsupported code-view resource owner.");if(e.startsWith("ssh://")){let n=new URL(e),t=p.posix.resolve(decodeURIComponent(n.pathname),r);return n.pathname=t.split("/").map(encodeURIComponent).join("/"),n.href}if(e.includes("://"))throw new TypeError("Unsupported code-view resource owner.");return p.isAbsolute(r)?p.normalize(r):p.resolve(e,r)}i(h,"resolveCodeViewPath");function g(r,e,n){let t=e.replaceAll("%","%25").replaceAll("#","%23"),o=n===void 0?"":`#${n.map(a=>encodeURIComponent(a)).join("/")}`;return`${r}:${t}${o}`}i(g,"formatCodeViewReference");function C(r){return r.map(e=>encodeURIComponent(e)).join("/")}i(C,"formatSymbolSelector");function l(r,e){try{return decodeURIComponent(r)}catch(n){throw new TypeError(`${e} contains invalid percent encoding.`,{cause:n})}}i(l,"decodePart");export{y as a,h as b,g as c,C as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as X}from"./chunk-PLKYHUNT.js";import{m as v}from"./chunk-ZPT5D4VP.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as Ee}from"node:crypto";import{open as Ne,readFile as Me}from"node:fs/promises";import b from"node:path";import{spawn as xe}from"node:child_process";import{stat as we}from"node:fs/promises";import E from"node:path";import{createInterface as Te}from"node:readline";import{existsSync as me}from"node:fs";import ge from"node:os";import Y from"node:path";function Z(e=process.env.PI_CODING_AGENT_DIR??Y.join(ge.homedir(),".pi","agent"),t=process.platform){let r=Y.join(e,"bin",t==="win32"?"rg.exe":"rg");return me(r)?r:"rg"}u(Z,"resolveRipgrepExecutable");function J(e,t=!1){let r=L(e);return $(r)?D(I(new P(e,r).parse(),t)):t?e:G(e)}u(J,"compileSearchQuery");function z(e,t=!1){let r=L(e);return $(r)?I(new P(e,r).parse(),t):void 0}u(z,"compileSearchCondition");function A(e,t){if(e.kind==="term")return t(e.value);let r=A(e.left,t);if(e.kind==="or")return r||A(e.right,t);let n=A(e.right,t);return r&&(e.kind==="not"?!n:n)}u(A,"satisfiesSearchCondition");function te(e){if($(L(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(G).join("|")})`:void 0}u(te,"compileSearchFallbackQuery");function $(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}u($,"containsBooleanSyntax");var P=class{static{u(this,"BooleanQueryParser")}#e;#n;#a=0;constructor(t,r){this.#e=t,this.#n=r}parse(){let t=this.#o(),r=this.#t();if(r.type!=="end"){let n=r.type==="right"?"unexpected ')'.":`unexpected ${be(r)}.`;throw T(r.offset,n)}return t}#o(){let t=this.#r();for(;this.#t().type==="or";){let r=this.#i(),n=this.#s(`after ${r.value}`);t={kind:"or",left:t,right:this.#c(n)}}return t}#r(){return this.#c(this.#s())}#c(t){let r=t;for(;;){let n=this.#t();if(n.type==="and"||n.type==="not"){this.#i();let o=this.#s(`after ${n.value}`);r={kind:n.type,left:r,right:o};continue}if(n.type==="term"||n.type==="left"){r={kind:"and",left:r,right:this.#s()};continue}return r}}#s(t){let r=this.#t();if(r.type==="term")return this.#i(),{kind:"term",value:r.value,quoted:r.quoted};if(r.type==="left"){if(this.#i(),this.#t().type==="right"||this.#t().type==="end")throw T(this.#t().offset,"expected a term after '('.");let o=this.#o();if(this.#t().type!=="right")throw T(this.#t().offset,"expected ')'.");return this.#i(),o}if(t===void 0&&(r.type==="and"||r.type==="or"||r.type==="not"))throw T(r.offset,`expected a term before ${r.value}.`);let n=t===void 0?"":` ${t}`;throw T(r.offset,`expected a term${n}.`)}#t(){return this.#n[this.#a]??{type:"end",value:"",offset:this.#e.length}}#i(){let t=this.#t();return this.#a+=1,t}};function L(e){let t=[],r=0;for(;r<e.length;){let n=e.charAt(r);if(/\s/u.test(n)){r+=1;continue}if(n==="("&&Se(e,r)){t.push({type:"left",value:n,offset:r}),r+=1;continue}if(n===")"){t.push({type:"right",value:n,offset:r}),r+=1;continue}if(ee(e,r)){let i=e.charAt(r+1)==="|"?2:1;t.push({type:"or",value:e.slice(r,r+i),offset:r}),r+=i;continue}if(n==="'"||n==='"'){let i=r,c=n,a="";for(r+=1;r<e.length&&e.charAt(r)!==c;)e.charAt(r)==="\\"&&(e.charAt(r+1)===c||e.charAt(r+1)==="\\")&&(r+=1),a+=e.charAt(r++);if(r>=e.length)throw T(i,`unterminated ${c==="'"?"single":"double"}-quoted term.`);if(r+=1,a.length===0)throw T(i,"quoted terms must not be empty.");t.push({type:"term",value:a,offset:i,quoted:!0});continue}let o=r;for(;r<e.length;){let i=e.charAt(r);if(/\s/u.test(i)||i===")"||ee(e,r))break;i==="\\"&&r+1<e.length?r+=2:i==="["||i==="("?r=Q(e,r)??r+1:r+=1}let s=e.slice(o,r);t.push({type:ye(s),value:s,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}u(L,"tokenize");function ee(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(ee,"isBooleanPipe");function Q(e,t){let r=e.charAt(t)==="["?"]":")",n=t+1;for(;n<e.length;){let o=e.charAt(n);if(o==="\\")n+=2;else{if(o===r)return n+1;if(r===")"&&(o==="("||o==="[")){let s=Q(e,n);if(s===void 0)return;n=s}else n+=1}}}u(Q,"regexBlockEnd");function Se(e,t){let r=Q(e,t);if(r===void 0)return!0;let n=e.slice(t+1,r-1);return n.trim().length===0?!0:$(L(n))}u(Se,"isBooleanGroup");function ye(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}u(ye,"operatorType");function be(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}u(be,"quoteToken");function T(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}u(T,"syntaxError");function I(e,t){return e.kind==="term"?{kind:"term",value:t&&!e.quoted?e.value:G(e.value)}:{kind:e.kind,left:I(e.left,t),right:I(e.right,t)}}u(I,"compileTerms");function D(e){if(e.kind==="term")return e.value;let t=D(e.left);return e.kind==="not"?t:`(?:${t}|${D(e.right)})`}u(D,"matchPattern");function G(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}u(G,"escapeRegex");async function U(e,t,r,n,o){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");return e.condition!==void 0?ie(e,(s,i)=>re(s,t,r,i,void 0,o),r):re(e,t,r,void 0,n,o)}u(U,"searchText");async function Re(e,t,r,n){if(r===void 0&&(e.path?.includes("://")||t.includes("://")))throw new Error("No search environment owns this scope.");let o=r?.resolve(t,oe(e.path??"."))??E.resolve(t,oe(e.path??".")),s=r===void 0?(await we(o)).isDirectory():await r.isDirectory(o,n);return{cwd:s?o:r?.dirname(o)??E.dirname(o),target:s?".":`./${r?.basename(o)??E.basename(o)}`,arguments:["--no-config","--no-ignore-parent","--color=never",...ne(e.include).flatMap(i=>["--glob",i]),...ne(e.exclude).flatMap(i=>["--glob",`!${i}`])]}}u(Re,"ripgrepScope");async function ve(e,t,r,n){if(e.condition!==void 0)return ie(e,async(s,i)=>{let c=await ve(s,t,r,n);for(let a of c.matches)i?.(a.source,a.lineNumber);return c},n);if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");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"]:[],"--",e.query,"-"],r,n,void 0,void 0,t.length===0?`
|
|
2
|
+
`:t);return t.length===0?{...o,matches:o.matches.filter(s=>s.lineNumber===1&&s.startColumn===0&&s.endColumn===0)}:o}u(ve,"searchTextContent");async function re(e,t,r,n,o,s){let i=await Re(e,t,s,r),c=i.cwd,a=["--json","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...i.arguments,"--",e.query,i.target];if(e.regex!==!0)return j(["--fixed-strings",...a],c,r,n,o,void 0,s);try{return await j(["--engine","auto",...a],c,r,n,o,void 0,s)}catch(l){if(!ke(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",...a],c,r,n,o,void 0,s)}catch(d){throw r?.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 ie(e,t,r){let n=e.condition;if(n===void 0)throw new Error("Boolean search requires a line condition.");let o=new Set;function s(p){if(p.kind==="term"){o.add(p.value);return}s(p.left),s(p.right)}u(s,"collect"),s(n);let{condition:i,...c}=e,a=new Map,l=u(p=>JSON.stringify([p.source,p.lineNumber]),"lineKey");for(let p of o){r?.throwIfAborted();let g=new Set;await t({...c,query:p,regex:!0,wholeWord:!1},(w,x)=>g.add(JSON.stringify([w,x]))),a.set(p,g)}let d=await t(c),h=new Set,f=d.matches.filter(p=>{let g=l(p);return h.has(g)||!A(n,w=>a.get(w)?.has(g)===!0)?!1:(h.add(g),!0)});return{...d,matches:f}}u(ie,"searchBoolean");function j(e,t,r,n,o,s,i){return i!==void 0?Ce(e,t,i,r,n,o):new Promise((c,a)=>{let l=xe(Z(),e,{stdio:["pipe","pipe","pipe"],cwd:t}),d=0,h=!1;o!==void 0&&l.stdout.on("data",m=>{d+=m.length,d>o.bytes&&(h=!0,l.kill())});let f=Te({input:l.stdout});l.stdin.on("error",()=>{}),l.stdin.end(s);let p=[],g="",w,x=u(()=>{l.kill()},"abort"),k=u(()=>{r?.removeEventListener("abort",x),f.close()},"cleanup");l.stderr.setEncoding("utf8"),l.stderr.on("data",m=>{g+=m}),f.on("line",m=>{if(!(h||w!==void 0||m.length===0))try{let S=JSON.parse(m);if(S.type!=="match")return;if(n!==void 0){let{path:B,line_number:V}=S.data;B.text!==void 0&&Number.isSafeInteger(V)&&n(E.resolve(t,B.text),V);return}for(let B of ae(S,t)){if(o!==void 0&&p.length===o.matches){h=!0,l.kill();break}p.push(B)}}catch(S){w=S,l.kill()}}),l.once("error",m=>{k(),a(m)}),l.once("close",m=>{if(k(),r?.aborted===!0){let S=new Error("Search was aborted.");S.name="AbortError",a(S);return}if(w!==void 0){a(new Error("Unable to parse ripgrep search output.",{cause:w}));return}if(!h&&m!==0&&m!==1){a(new Error(g.trim()||`ripgrep exited with code ${String(m)}.`));return}p.sort(se),c({matches:p,complete:!h})}),r?.addEventListener("abort",x,{once:!0}),r?.aborted===!0&&x()})}u(j,"runRipgrep");async function Ce(e,t,r,n,o,s){let i=[],c=new AbortController,a=u(()=>c.abort(n?.reason),"abort");n?.addEventListener("abort",a,{once:!0}),n?.aborted&&a();let l=0,d={limited:!1};try{let h=await r.runLines(e,t,f=>{if(d.limited||!f.length)return;if(l+=Buffer.byteLength(f)+1,s!==void 0&&l>s.bytes){d.limited=!0,c.abort();return}let p=JSON.parse(f);if(p.type==="match"){if(o!==void 0){let g=p.data.path.text;g!==void 0&&Number.isSafeInteger(p.data.line_number)&&o(r.resolve(t,g),p.data.line_number);return}for(let g of ae(p,t,r)){if(s!==void 0&&i.length>=s.matches){d.limited=!0,c.abort();break}i.push(g)}}},c.signal);if(h.code!==0&&h.code!==1)throw new Error(h.stderr.trim()||"Ripgrep failed.")}catch(h){if(n?.throwIfAborted(),!d.limited)throw h}finally{n?.removeEventListener("abort",a)}return n?.throwIfAborted(),i.sort(se),{matches:i,complete:!d.limited}}u(Ce,"runOwnedRipgrep");function ke(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}u(ke,"isPcre2MatchLimitError");function ae(e,t,r){let n=e.data.path.text,o=e.data.lines.text;if(n===void 0||o===void 0||!Number.isSafeInteger(e.data.line_number))return[];let s=o.replace(/(?:\r\n|\n)$/u,""),i=Buffer.from(o),c=[];for(let a of e.data.submatches){if(a.start<0||a.end<a.start||a.end>i.length)continue;let l=i.subarray(0,a.start).toString("utf8").length,d=i.subarray(0,a.end).toString("utf8").length;c.push({source:r?.resolve(t,n)??E.resolve(t,n),lineNumber:e.data.line_number,startColumn:l,endColumn:d,matchedText:s.slice(l,d),lineText:s})}return c}u(ae,"matchesFromEvent");function ne(e){if(e===void 0)return[];let t=[],r=0,n="";for(let o of e){if(o==="{"?r+=1:o==="}"&&(r=Math.max(0,r-1)),r===0&&(o===","||/\s/u.test(o))){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}u(ne,"splitGlobList");function oe(e){return e.startsWith("@")?e.slice(1):e}u(oe,"stripFilePrefix");function se(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}u(se,"compareMatches");function nt(e){let t=J(e.query),r=J(e.query,!0),n=te(e.query),o=[],s=z(e.query),i=z(e.query,!0);return(r!==t||JSON.stringify(s)!==JSON.stringify(i))&&o.push({query:r,mode:"regex",condition:i}),n!==void 0&&n!==t&&n!==r&&o.push({query:n,mode:"words"}),{...e,query:t,regex:!0,condition:s,fallbacks:o}}u(nt,"createSearchRecipe");async function q(e,t,r,n){let o=e.query,s=await U(e,t,r,void 0,n),i=[];for(let c of e.fallbacks??[]){if(s.matches.length>0||!s.complete)break;r?.throwIfAborted();try{s=await U({...e,query:c.query,regex:!0,condition:c.condition},t,r,void 0,n),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(a){if(c.mode!=="regex"||!Ae(a)||r?.aborted)throw a;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...s,query:o,notices:i}}u(q,"runSearchRecipe");function Ae(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}u(Ae,"isRegexSyntaxError");var Be=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,de=4;function ft(e,t,r,n){return he(e,t,r,n).slice(0,de)}u(ft,"createSearchSessionId");function he(e,t,r,n){let o=r===void 0?Oe(t.map(a=>a.source)):R(r),s=t.map(a=>({match:a,source:a.source.includes("://")?R(a.source):b.relative(o,b.resolve(a.source))})).sort((a,l)=>a.source.localeCompare(l.source)||K(a.match,l.match)).map(({match:a,source:l})=>[l,a.lineNumber,a.startColumn,a.endLineNumber??a.lineNumber,a.endColumn,a.matchedText,a.lineText]),{limit:i,...c}=fe(n??{query:e,regex:!0},o);return Ee("sha256").update(JSON.stringify([e,o,c,s])).digest("hex").toUpperCase()}u(he,"createSearchSessionIdentity");function Pe(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 r=de;r<=e.length;r+=1){let n=e.slice(0,r);if(!t.has(n))return n}throw new Error("Could not allocate a unique search session id.")}u(Pe,"allocateSearchSessionId");function fe(e,t){return{query:e.query,path:He(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??50,regex:e.regex===!0,condition:e.condition,fallbacks:e.fallbacks??[]}}u(fe,"normalizeRecipe");var F=class extends Error{static{u(this,"SearchSnapshotChangedError")}constructor(t){super(`Search result in ${t} changed before its anchors were registered.`),this.name="SearchSnapshotChangedError"}},ce=class{constructor(t=he,r,n){this.createIdentity=t;this.resultTargets=r;this.readSource=n}static{u(this,"SearchSessionStore")}#e=new Map;#n=new Map;async register(t,r,n,o,s,i={query:t,regex:!0},c,a,l){let d=r.map(m=>({...m,source:R(m.source)})).sort(K),h=this.readSource,f=h===void 0?void 0:(m,S)=>h(m,o,S),p=await le(d,s,a,l,f),g=this.createIdentity(t,d,o,i),x=this.#n.get(g)??Pe(g,new Set(this.#e.keys())),k={id:x,query:t,matches:d,complete:n,contentBySource:p,read:f,...Ie(this.resultTargets,x,d,p,o,n,(m,S)=>_(m,S,l,f)),...a===void 0?{}:{snapshotByteBudget:a},recipe:i,environment:l,...c!==void 0&&{refresh:c},cwd:R(o)};return this.#n.set(g,x),this.#e.set(x,k),k}async registerIfCurrent(t,r,n,o,s,i,c,a,l){try{return await this.register(t,r,n,o,s,i,c,a,l)}catch(d){if(d instanceof F)return;throw d}}async observeAfterEdit(t,r){let n=new Set(t.flatMap(s=>{let i=typeof s=="string"?N(s):void 0;return i===void 0?[]:[i.id]})),o=[];for(let s of n){let i=this.#e.get(s);if(i===void 0)continue;let c={sessionId:s,query:i.recipe.originalQuery??i.query,scope:fe(i.recipe,i.cwd)};try{let a=i.refresh===void 0?await q(i.recipe,i.cwd,r,i.environment):await i.refresh(r);o.push({...c,matches:a.matches.length,complete:a.complete,notices:a.notices})}catch(a){o.push({...c,error:a instanceof Error?a.message:String(a)})}}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(`
|
|
3
|
+
`),renderFull(t){return t},renderCompact(t){let r=N(t);return r===void 0?"selected result":r.selector==="all"?r.mode==="match"?"all matches":"all lines":r.mode==="match"?`match ${String(r.selector)}`:`line ${String(r.selector)}`},tryResolve:u((t,r)=>this.#a(t,r.source,r.signal),"tryResolve")}}async resolveSearchScope(t,r){if(!t.startsWith("SEARCH#"))return;let n=await this.#o(t,r.cwd,r.signal,!0);if(n.kind!=="resolved")throw new Error(n.kind==="rejected"?n.rejection.reason:"Invalid Search reference.");let o=y(N(t)),s=y(this.#e.get(o.id));return{complete:!0,targets:n.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 a=await O(i.source,c,s.environment,s.read);if(a===void 0)throw new Error("Search source is unavailable.");return a},"readCurrent")}})}}resourceResolver(){return{id:"search-targets",tryResolve:u((t,r)=>this.#o(t,r.cwd),"tryResolve")}}async#a(t,r,n){let o=N(t);if(o===void 0)return{kind:"not-handled"};let s=this.#e.get(o.id);if(s===void 0)return M();if(o.selector==="all"&&!s.complete)return C();let i=R(r),c=s;if(o.selector==="all"){if(s.refreshedComplete?.complete===!0)c=s.refreshedComplete;else if(s.refreshedComplete!==void 0&&(c=await this.#r(s,n),!c.complete))return C()}let a=H(c,o.selector,o.mode),l=a.filter(f=>f.source===i);if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await O(i,n,s.environment,s.read);if(d===void 0)return M(y(l[0]).lineNumber);if(o.selector==="all"&&d!==c.contentBySource.get(i)){if(c=await this.#r(s,n),!c.complete)return C();a=H(c,o.selector,o.mode),l=a.filter(f=>f.source===i)}if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==s.contentBySource.get(i))return M(y(l[0]).lineNumber);let h=v(i,d);return{kind:"resolved",anchor:new X(t,i,l.map(f=>W(h,f,o.mode)))}}async#o(t,r,n,o=!1){let s=N(t);if(s===void 0)return{kind:"not-handled"};let i=this.#e.get(s.id);if(i===void 0||i.cwd!==R(r))return M();if(s.selector==="all"&&!i.complete)return C();let c=i;if(s.selector==="all"){if(i.refreshedComplete?.complete===!0)c=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&(c=await this.#r(i,n),!c.complete))return C();let h=new Set(H(c,s.selector,s.mode).map(f=>f.source));for(let f of h)if(await O(f,n,i.environment,i.read)!==c.contentBySource.get(f)){if(c=await this.#r(i,n),!c.complete)return C();break}}let a=H(c,s.selector,s.mode);if(s.selector!=="all"){let h=a[0]?.source;if(h!==void 0&&await O(h,n,i.environment,i.read)!==c.contentBySource.get(h))return M(a[0]?.lineNumber)}let l=new Map;for(let h of a){let f=l.get(h.source)??[];f.push(W(v(h.source,c.contentBySource.get(h.source)??h.lineText),h,s.mode)),l.set(h.source,f)}let d=[...l].map(([h,f])=>({source:h,ranges:f,expectedContent:c.contentBySource.get(h)}));return d.length===0&&!(o&&s.selector==="all")?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:d}}async#r(t,r){let n=t.refresh===void 0?await q(t.recipe,t.cwd,r,t.environment):await t.refresh(r),o=n.matches.map(i=>({...i,source:R(i.source)})).sort(K),s={matches:o,complete:n.complete,contentBySource:await le(o,r,t.snapshotByteBudget,t.environment,t.read)};return this.#e.set(t.id,{...t,refreshedComplete:s}),s}};function Ie(e,t,r,n,o,s,i){if(e===void 0)return{};let c=new Map([...n].map(([l,d])=>[l,v(l,d)])),a=r.map(l=>({source:l.source,expectedContent:y(n.get(l.source)),ranges:[W(y(c.get(l.source)),l,"match")],readCurrent:u(d=>i(l.source,d),"readCurrent")}));for(let[l,d]of r.slice(0,100).entries()){let h=e.register([{...y(a[l]),ranges:[W(y(c.get(d.source)),d,"line")]}],o);e.registerSearchReference(`SEARCH#${t}:${l+1}:line`,h,o)}return{target:e.register(a,o,s),matchTargets:a.slice(0,100).map(l=>e.register([l],o,s))}}u(Ie,"registerResultReferences");function N(e){let t=Be.exec(e);if(t!==null)return{id:y(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}u(N,"parseSearchAnchor");function H(e,t,r){let n=t==="all"?e.matches:[e.matches[t-1]].filter($e);if(r==="match"||t!=="all")return n;let o=new Set;return n.flatMap(s=>{let i=v(s.source,e.contentBySource.get(s.source)??s.lineText),c=pe(s);return i.lines.slice(s.lineNumber-1,c).flatMap(a=>{let l=`${s.source}\0${String(a.lineNumber)}`;return o.has(l)?[]:(o.add(l),[{...s,lineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:0,endColumn:a.content.length,lineText:a.content,matchedText:a.content}])})})}u(H,"selectMatches");function $e(e){return e!==void 0}u($e,"isMatch");function pe(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}u(pe,"lastContainingLine");function W(e,t,r){if(r==="match")return{start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:t.endLineNumber??t.lineNumber,column:t.endColumn}};let n=pe(t),o=y(e.lines[n-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:n+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}u(W,"selectionRange");function Le(e,t){let r=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,r).map(n=>{let o=n.lineNumber===t.lineNumber?t.startColumn:0,s=n.lineNumber===r?t.endColumn:n.content.length;return n.content.slice(o,s)+(n.lineNumber===r?"":n.lineEnding)}).join("")}u(Le,"matchedSourceText");async function le(e,t,r,n,o){let s=[...new Set(e.map(a=>a.source))];if(r!==void 0){let a=new Map,l=r;for(let d of s){let h=await je(d,l,t,n,o);l-=Buffer.byteLength(h),ue(d,h,e),a.set(d,h)}return a}let i=await Promise.allSettled(s.map(async a=>{let l=await _(a,t,n,o);return ue(a,l,e),[a,l]})),c=new Map;for(let a of i){if(a.status==="rejected")throw a.reason;c.set(...a.value)}return c}u(le,"snapshotContents");function ue(e,t,r){let n=v(e,t);for(let o of r.filter(s=>s.source===e))if(n.lines[o.lineNumber-1]?.content!==o.lineText||Le(n,o)!==o.matchedText)throw new F(e)}u(ue,"validateSnapshot");async function je(e,t,r,n,o){if(r?.throwIfAborted(),e.includes("://")){let i=await _(e,r,n,o);if(Buffer.byteLength(i)>t)throw new Error("Candidate snapshot byte budget reached.");return i}let s=await Ne(e,"r");try{let i=await s.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)),a=0;for(;a<c.length;){r?.throwIfAborted();let l=await s.read(c,a,c.length-a,a);if(l.bytesRead===0)break;a+=l.bytesRead}if(r?.throwIfAborted(),a>i.size||a>t)throw new Error("Candidate file grew during snapshot capture.");return c.subarray(0,a).toString("utf8")}finally{await s.close()}}u(je,"readBoundedSnapshot");async function O(e,t,r,n){try{return await _(e,t,r,n)}catch{return}}u(O,"readCurrent");function R(e){return e.includes("://")?e:b.resolve(e)}u(R,"canonicalSource");function He(e,t){return t.includes("://")?t:e.includes("://")?new URL(t,e.endsWith("/")?e:e+"/").href:b.resolve(e,t)}u(He,"resolveScope");async function _(e,t,r,n){if(t?.throwIfAborted(),n!==void 0)return n(e,t);if(r!==void 0)return r.readText(e,t);if(e.includes("://"))throw new Error("No search snapshot owner for this source.");return Me(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}u(_,"readOwnedText");function M(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}u(M,"staleAnchor");function C(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}u(C,"missingCompleteAnchor");function Oe(e){if(e.length===0)return".";let t=b.dirname(b.resolve(y(e[0])));for(let r of e.slice(1)){let n=b.resolve(r);for(;!Fe(t,n);){let o=b.dirname(t);if(o===t)return t;t=o}}return t}u(Oe,"commonSourceDirectory");function Fe(e,t){let r=b.relative(e,t);return r!==".."&&!r.startsWith(`..${b.sep}`)&&!b.isAbsolute(r)}u(Fe,"isWithin");function K(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(K,"compareMatches");export{Z as a,U as b,Re as c,ve as d,nt as e,q as f,ft as g,he as h,Pe as i,F as j,ce as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as E}from"./chunk-DXONCYWF.js";import{e as f}from"./chunk-ZPT5D4VP.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";import{execFile as I}from"node:child_process";import{lstat as O,readdir as k,readFile as _,readlink as L,realpath as h}from"node:fs/promises";import i from"node:path";import v from"node:os";import{promisify as C}from"node:util";var F=C(I);function A(t){return t.isSymbolicLink()?"symlink":t.isDirectory()?"directory":t.isFile()?"file":"other"}o(A,"kind");function R(t){return JSON.stringify([t.dev,t.ino,t.birthtimeMs,t.ctimeMs,t.mtimeMs,t.size,t.mode])}o(R,"revision");async function x(t){return O(t).catch(r=>{if(r.code!=="ENOENT")throw r})}o(x,"optionalStat");async function b(t){try{return await h(t)}catch(r){if(r.code!=="ENOENT"||await x(t))throw r;return i.join(await b(i.dirname(t)),i.basename(t))}}o(b,"resolveParent");async function S(t,r){let c=i.join(await b(i.dirname(t)),i.basename(t)),l=[],p=o(async(s,d)=>{r?.throwIfAborted();let a=await x(s);if(a===void 0){if(d!=="")throw Object.assign(new Error("Transfer entry disappeared"),{code:"TRANSFER_TARGET_CHANGED"});return}let T={relativePath:d,kind:A(a),revision:R(a),identity:{device:String(a.dev),inode:String(a.ino)},mode:a.mode,...a.isSymbolicLink()?{link:(await L(s,{encoding:"buffer"})).toString("base64")}:{}};if(l.push(T),T.kind==="directory"){for(let m of(await k(s)).sort())await p(i.join(s,m),d===""?m:`${d}/${m}`);let y=await x(s);if(y===void 0||R(y)!==T.revision)throw Object.assign(new Error("Transfer directory changed while inspecting its children"),{code:"TRANSFER_TARGET_CHANGED"})}},"walk");return await p(c,""),{path:c,entries:l}}o(S,"snapshotLocalObjects");var N={owner:"local",async temporaryEnvironment(t){t?.throwIfAborted();let r=process.env.PI_CODING_AGENT_DIR?.trim();return{home:v.homedir(),temporary:v.tmpdir(),...r?{agentDirectory:i.resolve(r)}:{}}},pathStyle:"native",realpath:h,async inspect(t){let r=await O(t);return{kind:A(r),revision:R(r),identity:{device:String(r.dev),inode:String(r.ino)},mode:r.mode}},read:o(t=>_(t,"utf8"),"read"),async git(t,r,c){let l=Object.fromEntries(Object.entries(process.env).filter(([s])=>!s.startsWith("GIT_"))),{stdout:p}=await F("git",["-C",t,...r],{env:{...l,GIT_OPTIONAL_LOCKS:"0"},signal:c,timeout:5e3,maxBuffer:16*1024*1024});return p},source:o(t=>t,"source"),snapshot:S};var u="pi-agent-text-editor",P=32,oe="pi-agent-text-editor/position",ie="pi-agent-text-editor/search",ne=`${u}/core/ready`,se=`${u}/plugin/register`,g=e.Function([],e.Unknown()),D=e.Object({tryResolve:g},{additionalProperties:!0}),j=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),M=e.Object({start:j,end:j,linewise:e.Optional(e.Boolean())}),G=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(M))}),q=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(G,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),V=e.String({pattern:"\\S"}),X=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),U=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),H=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P)}),w=e.Object({protocol:e.Literal(u),apiVersion:e.Literal(P),id:e.String(),setup:g}),K=e.Object({plugin:w,accept:g});function ae(t){return n.Check(V,t)}o(ae,"isTextEditorToolId");function ce(t){if(!n.Check(X,t))return!1;let r=t;return E(r.resolver)&&(!("priority"in r)||typeof r.priority=="number")}o(ce,"isResourceResolverRegistration");function le(t){if(!n.Check(U,t))return!1;let r=t;return f(r.resolver)&&(!("resources"in r)||n.Check(D,r.resources))&&(!("priority"in r)||typeof r.priority=="number")}o(le,"isTextAnchorResolverRegistration");function pe(t){return n.Check(q,t)}o(pe,"isTextAnchorResourceResolutionAttempt");function de(t){return n.Check(H,t)}o(de,"isTextEditorCoreReady");function ue(t){return n.Check(w,t)}o(ue,"isTextEditorPlugin");function Te(t){return n.Check(K,t)}o(Te,"isTextEditorPluginRegistrationRequest");export{S as a,N as b,u as c,P as d,oe as e,ie as f,ne as g,se as h,ae as i,ce as j,le as k,pe as l,de as m,ue as n,Te as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./chunk-IMGIDBCC.js";import{a as i}from"./chunk-EI7MMDWY.js";import{copyFile as c,mkdtemp as l,rm as p}from"node:fs/promises";import a from"node:path";function d(o){let e=o.workspace;return{environment:o.env,signal:o.signal,...e?{layerAccess:{paths:i((r,t,n)=>e.configPaths(t,n),"paths"),async readText(r,t){let n=await e.readText(r,t);if(n===void 0)throw Object.assign(new Error(`ENOENT: ${r}`),{code:"ENOENT"});return n}},executableAvailability:i((r,t)=>e.executableAvailability(r,t),"executableAvailability"),recipeEvidence:i((r,t)=>e.evidence(r,t),"recipeEvidence")}:{}}}i(d,"doctorRuntimeOptions");function f(o){let e=o.workspace;return e?{run:i((r,t)=>e.run(r,t.filePath,t.signal),"run")}:void 0}i(f,"doctorProcessAccess");async function u(o,e){if(o.signal?.throwIfAborted(),!o.workspace)return s(e,o.cwd,o.env,o.signal);let r=await o.workspace.executableAvailability([e],o.signal);if(o.signal?.throwIfAborted(),r.length!==1||typeof r[0]!="boolean")throw new TypeError("Invalid Doctor executable availability report");return r[0]}i(u,"doctorExecutableAvailable");async function w(o,e,r){if(o.signal?.throwIfAborted(),o.workspace)return o.workspace.withProbeCopy(e,r,o.signal);if(e.includes("://"))throw Object.assign(new Error(`Doctor requires the owner of ${e}`),{code:"UNSUPPORTED_SOURCE"});let t=await l(a.join(a.dirname(e),".pi-agent-ide-doctor-")),n=a.join(t,a.basename(e));try{return await c(e,n),o.signal?.throwIfAborted(),await r(n)}finally{await p(t,{recursive:!0,force:!0})}}i(w,"withDoctorProbeCopy");export{d as a,f as b,u as c,w as d};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as nt}from"./chunk-47SPPIXK.js";import{a as tt,b as rt}from"./chunk-VAXLSPPU.js";import{a as ot,b as st}from"./chunk-OI3HBIPK.js";import{e as it}from"./chunk-YTYLS2UM.js";import{a as ze,c as He}from"./chunk-TOYN4W4F.js";import{a as Ge}from"./chunk-YJ6T3PEP.js";import{b as Fe,c as Ve}from"./chunk-S72FVLUX.js";import{a as et}from"./chunk-M4TVRCMZ.js";import{c as Qe,d as Ye,f as Ze}from"./chunk-TGC2ZACO.js";import{d as Xe}from"./chunk-IICJXZBU.js";import{a as Ke}from"./chunk-BU7IZLKB.js";import{a as Be,b as Je}from"./chunk-S5PL5DFQ.js";import{J as F}from"./chunk-DXONCYWF.js";import{f as Ie,g as De,h as Ae}from"./chunk-DUUOCBS3.js";import{a as q,b as E,c as J,d as M}from"./chunk-T4FTT3U4.js";import{m as Ee}from"./chunk-ZPT5D4VP.js";import{a as Oe}from"./chunk-ZAWRSA7N.js";import{a as je,b as Te}from"./chunk-OFILFO6D.js";import{b as $e,c as We,g as Ue,j as Ne,p as qe}from"./chunk-IMGIDBCC.js";import{a as Me}from"./chunk-BXGMMZT3.js";import{a as _}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Dr from"node:path";var V=[{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"]}]}}},b("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}}),b("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"]}}},b("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"]),b("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),b("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),b("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),b("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/"),b("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"]),b("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),b("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),b("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),b("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),b("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),b("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"),b("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),b("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),b("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),b("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),b("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),b("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:{}}),b("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"),b("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"),b("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),b("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),b("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),b("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"),b("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"),b("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"),b("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),b("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"),b("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),b("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),b("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 b(n,e,t,r,o,s,i,l,c,p){return{id:n,name:n,kind:"lsp",languages:e,executables:t,configFiles:r,documentation:i,...l&&{dependencies:l},lsp:{command:s,rootMarkers:r,languageIds:o,...c&&{fileNames:c},...p&&{settings:p}}}}a(b,"recipe");import Jt from"node:path";import Kt from"cross-spawn";import{createMessageConnection as Xt,CancellationTokenSource as Qt,StreamMessageReader as Yt}from"vscode-jsonrpc/node";import{URI as ct}from"vscode-uri";import{watch as Nt}from"node:fs";import{readdir as qt,stat as Ft}from"node:fs/promises";import z from"node:path";import{URI as le}from"vscode-uri";var ne=class{constructor(e,t,r){this.root=e;this.changed=t;this.failed=r}static{a(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let r=[];try{for(let o of t){let s=o.globPattern,i=typeof s=="string"?this.root:le.parse(typeof s.baseUri=="string"?s.baseUri:s.baseUri.uri).fsPath,l=typeof s=="string"?s:s.pattern,c=a(g=>z.matchesGlob(z.isAbsolute(l)?z.join(i,g):g,l),"matches"),p=new Set((await qt(i,{recursive:!0})).filter(c));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=Nt(i,{recursive:!0},(g,u)=>{!u||!c(u)||Ft(z.join(i,u)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let m=p.has(u)?2:1;p.add(u),(o.kind??7)&(m===1?1:2)&&this.changed({uri:le.file(z.join(i,u)).toString(),type:m})},m=>{if(this.registrations.get(e)?.includes(d)){if(m.code!=="ENOENT"){this.failed(m);return}p.delete(u)&&(o.kind??7)&4&&this.changed({uri:le.file(z.join(i,u)).toString(),type:3})}})});d.on("error",this.failed),r.push(d)}}catch(o){for(let s of r)s.close();throw o}this.unregister(e),this.registrations.set(e,r)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Vt}from"vscode-jsonrpc/node";var oe=class extends Vt{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 zt from"node:path";import{URI as Ht}from"vscode-uri";function k(n,e){if(e.startsWith("ssh://")){let t=at(e);if(n.includes("://")){let o=at(n);if(o.host!==t.host)throw new Error("Document belongs to another language server owner");return o.href}let r=zt.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:Ht.file(n).toString()}a(k,"documentUri");function at(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(at,"checkedRemote");async function A(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,o)=>{t=a(()=>o(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}}a(A,"waitWithSignal");var H=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 A(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 Gt=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),Bt=new Set(["changes","relatedDocuments"]);function j(n,e){return Array.isArray(n)?n.map(t=>j(t,e)):typeof n!="object"||n===null?n:Object.fromEntries(Object.entries(n).map(([t,r])=>Gt.has(t)&&typeof r=="string"?[t,e(r)]:Bt.has(t)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[t,Object.fromEntries(Object.entries(r).map(([o,s])=>[e(o),j(s,e)]))]:[t,j(r,e)]))}a(j,"mapLspUris");var $=class{static{a(this,"LspClient")}_process=null;_ownedProcess=null;_ownedStartup;_ownerTransport;_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;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4,this._ownerTransport=e.ownerTransport}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get remote(){return this._ownedProcess?.remote}get commandName(){return $e(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasWorkspaceSymbolCapability(){let e=this._serverCapabilities?.workspaceSymbolProvider;return e===!0||typeof e=="object"&&e!==null}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(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=_(this._command[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):ct.parse(this.rootUri).fsPath,o=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:Jt.basename(r)||r}];this._ownedStartup=this._ownerTransport?.start({rootUri:this.rootUri,command:this._command,env:this._env,signal:e});let s=await this._ownedStartup;if(this._ownedProcess=s??null,e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let i=s?void 0:Kt(t,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:qe({command:this._command,env:this._env},r,process.env)});this._process=i??null;let l=i?Zt(i):Promise.resolve(),c=_(s?.stdin??i?.stdin),p=_(s?.stdout??i?.stdout),d=_(s?.stderr??i?.stderr);c.on("error",()=>{}),p.on("error",()=>{}),d.on("error",()=>{}),this._stderr="",d.setEncoding("utf8"),d.on("data",h=>{this._stderr=(this._stderr+h).slice(-4096)}),i?.on("error",h=>{("code"in h?h.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,h),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let g=a(h=>{(s?this._ownedProcess!==s:this._process!==i)||(this._closeFileWatchers(),!this._disposed&&h!==0&&h!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._diagnosticPublications.clear(),this._activeDiagnosticRequests.clear(),this._diagnosticMode="unknown",this._process=null,this._initialized=!1)},"onExit");i?.on("exit",g),s?.completion.then(({exitCode:h})=>g(h),()=>{this._ownedProcess===s&&(this._crashed=!0,g(null))}),await A(l,e);let u=Xt(new Yt(p),new oe(c,h=>{this._connection!==u||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),u.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,h))}));this._connection=u,this._connection.onError(h=>{console.error(`[lsp] ${this.serverId}: connection error:`,h)});let m=a(h=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[h]})},"changed"),y=a(h=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,h),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,m,y):new ne(r,m,y),this._connection.onRequest("client/registerCapability",async h=>{for(let w of h.registrations)if(w.method!=="workspace/didChangeConfiguration"){if(w.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${w.method}`);if(!this._fileWatchers)throw new Error("File watching is unavailable for this server owner");await this._fileWatchers.register(w.id,w.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",async h=>{for(let w of h.unregisterations)await this._fileWatchers?.unregister(w.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",h=>h.items.map(w=>{let S=this._settings??null;for(let R of w.section?.split(".").filter(Boolean)??[])S=typeof S=="object"&&S!==null?S[R]??null:null;return S})),this._connection.listen(),this._connection.onNotification((h,...w)=>{let S=this._ownerTransport,R=S?j(w[0],v=>S.fromServerUri(v)):w[0];if(h==="textDocument/publishDiagnostics"){let v=R;v&&typeof v.uri=="string"&&Array.isArray(v.diagnostics)&&this._documentVersions.has(v.uri)&&(v.version===void 0||v.version===this.documentVersion(v.uri))&&this._diagnosticPublications.set(v.uri,{diagnostics:v.diagnostics,...typeof v.version=="number"&&{version:v.version}})}for(let v of this._handlers.get(h)??[])v(R)}),this._connection.onRequest("workspace/workspaceFolders",()=>o);let f=await A(lt(this._connection.sendRequest("initialize",{processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:o,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:this._fileWatchers!==void 0,relativePatternSupport:this._fileWatchers!==void 0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`),e).catch(h=>{let w=this._stderr.trim();throw w?new Error(`[lsp] ${this.serverId}: ${w}`,{cause:h}):h});if(await this._connection.sendNotification("initialized",{capabilities:f.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=f.capabilities,this._diagnosticMode=f.capabilities.diagnosticProvider?"pull":"push"}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._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start(e)}async sendRequest(e,t,r){this._assertReady(),r?.throwIfAborted();let o=this._ownerTransport,s=o?j(t,p=>o.toServerUri(p)):t,i=a(p=>o?j(p,d=>o.fromServerUri(d)):p,"mapResult");if(!r)return i(await _(this._connection).sendRequest(e,s));let l=new Qt,c;try{let p=_(this._connection).sendRequest(e,s,l.token);return i(await Promise.race([p,new Promise((d,g)=>{c=a(()=>{l.cancel(),g(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 o=this._ownerTransport,s=o?j(t,i=>o.toServerUri(i)):t;r.sendNotification(e,s).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 o=r.indexOf(t);o!==-1&&r.splice(o,1)}}toUri(e){return k(e,this.rootUri)}serverDocumentPath(e){let t=this.toUri(e),r=this._ownerTransport?.toServerUri(t)??t;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):ct.parse(r).fsPath}openDocument(e,t,r,o=1){let s=this._documentVersions.get(e);if(s!==void 0){this.changeDocument(e,t,Math.max(o,s+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:o,text:t}}),this._documentVersions.set(e,o),this._documentContents.set(e,t)}syncDocument(e,t,r,o=!1){if(this._documentContents.get(e)===t)return;let s=this._documentVersions.get(e);s===void 0?this.openDocument(e,t,r):this.changeDocument(e,t,s+1);let i=this._serverCapabilities?.textDocumentSync,l=typeof i=="object"&&i!==null?i.save:void 0;o&&l&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof l=="object"&&l.includeText&&{text:t}})}changeDocument(e,t,r){let o=this._documentVersions.get(e),s=Math.max(r,(o??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:s},contentChanges:[{text:t}]}),this._documentVersions.set(e,s),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)}shutdown(){return this._shutdownPromise??=this._shutdown()}async _shutdown(){this._disposed=!0;let e=this._closeFileWatchers();if(this._connection&&this._initialized)try{await lt(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()),o=this._process;this._process=null,o&&!o.killed&&(o.kill("SIGTERM"),setTimeout(()=>{o.exitCode===null&&o.signalCode===null&&o.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null;let s=await Promise.allSettled([r,e]),i=[];for(let l of s)l.status==="rejected"&&i.push(l.reason);if(i.length>0)throw new AggregateError(i,`[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`)}};function Zt(n){return new Promise((e,t)=>{let r=a(()=>{n.off("spawn",o),n.off("error",s)},"cleanup"),o=a(()=>{r(),e()},"onSpawn"),s=a(i=>{r(),t(i)},"onError");n.once("spawn",o),n.once("error",s)})}a(Zt,"waitForSpawn");function lt(n,e,t){return new Promise((r,o)=>{let s=setTimeout(()=>{o(new Error(t))},e);n.then(i=>{clearTimeout(s),r(i)}).catch(i=>{clearTimeout(s),o(i instanceof Error?i:new Error(String(i)))})})}a(lt,"withTimeout");import{readFile as pt}from"node:fs/promises";import{URI as ut}from"vscode-uri";var K={Error:1,Warning:2,Information:3,Hint:4};var dt={command:"typescript.tsserverRequest",async request(n,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async o=>{let s=await n.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[o,{file:n.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!de(s)||s.success!==!0||!Array.isArray(s.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${o}`);return s.body.map(er)}))).flat()}};function se(n){return n.supportsCommand(dt.command)?dt:void 0}a(se,"completedDiagnosticAdapter");function er(n){if(!de(n)||typeof n.message!="string"||typeof n.code!="number"&&typeof n.code!="string"||!de(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(er,"convertTypeScriptDiagnostic");function de(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}a(de,"isRecord");async function X(n,e,t,r={}){let o=new AbortController,s=AbortSignal.any([o.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>o.abort(new Error(`[lsp] ${n.serverId}: diagnostics timed out for ${e}`)),n.timeoutMs);try{return await tr(n,e,t,r.content,s)}finally{clearTimeout(i)}}a(X,"requestDiagnostics");async function tr(n,e,t,r,o){if(o.throwIfAborted(),n.diagnosticMode!=="push"){let c=n.documentVersion(e);try{let p=await n.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},o);if(p.kind!=="full"||!Array.isArray(p.items))throw new Error("Invalid full diagnostic report");if(n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return n.setDiagnosticMode("pull"),gt(p.items,!1,!0)}catch(p){if(!rr(p))throw p;n.setDiagnosticMode("push")}}let s=se(n);if(s){n.documentVersion(e)===void 0&&n.syncDocument(e,r??await pt(ut.parse(e).fsPath,"utf8"),t??"plaintext");let c=n.documentVersion(e),p=await s.request(n,e,o);if(o.throwIfAborted(),n.documentVersion(e)!==c)throw new Error("Document changed during diagnostic request");return{diagnostics:p,syntaxErrors:[],otherDiagnostics:p,unversioned:!1,complete:!0}}o.throwIfAborted();let i=n.documentVersion(e)!==void 0,l=i?void 0:r??await pt(ut.parse(e).fsPath,"utf8");o.throwIfAborted(),n.beginDiagnosticRequest(e);try{return await new Promise((c,p)=>{let d=n.documentVersion(e)??1,g=a(f=>{let h=f;h.uri!==e||!Array.isArray(h.diagnostics)||h.version!==void 0&&h.version!==d||n.documentVersion(e)===d&&(y(),c(gt(h.diagnostics,h.version===void 0)))},"receive"),u=n.onNotification("textDocument/publishDiagnostics",g),m=a(()=>{y(),p(o.reason)},"onAbort");function y(){u(),o.removeEventListener("abort",m)}a(y,"cleanup"),o.addEventListener("abort",m,{once:!0});try{i||n.syncDocument(e,l??"",t??"plaintext");let f=n.diagnosticPublication(e);f&&g({uri:e,...f})}catch(f){y(),p(f)}})}finally{n.endDiagnosticRequest(e)}}a(tr,"requestCurrentDiagnostics");function pe(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===K.Warning?"warning":n.severity===K.Information?"info":n.severity===K.Hint?"hint":"error"}}a(pe,"toDiagnostic");function gt(n,e,t=!1){let r=n.map(pe);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:t}}a(gt,"classify");function rr(n){return n!==null&&typeof n=="object"&&"code"in n&&n.code===-32601}a(rr,"isMethodNotFound");var nr={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 T(n){return nr[n]??`SymbolKind(${n})`}a(T,"symbolKindName");async function Q(n,e,t){return await n.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},t)??[]}a(Q,"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 ie(n,e,t,r){return await n.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:r})}a(ie,"requestRename");import Z from"node:path";import{URI as ar}from"vscode-uri";import{createHash as or}from"node:crypto";import{readdir as sr,stat as ae}from"node:fs/promises";import O from"node:path";import{URI as me}from"vscode-uri";async function ge(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(ge,"prepareProjectQuery");function mt(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(([o,s])=>[o,t(s)])):r,"expand");return Object.fromEntries(Object.entries(n).map(([r,o])=>[r,t(o)]))}a(mt,"resolveInitializationOptions");var W=class n{constructor(e,t){this._registry=e;this._owner=t}static{a(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!n._instance)throw new Error("[lsp] LspManager not initialized");return n._instance}static getInstanceOrNull(){return n._instance}static init(e,t){let r=n._instance;return r?._disposed?(r._registry=e,r._owner=t,r._disposed=!1,r):(n._instance=new n(e,t),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,o){if(o?.throwIfAborted(),this._disposed)return null;let s=t.startsWith("ssh://"),i=s?this.requireOwner():void 0,l=i?await this._registry.resolveOwned(e,f=>i.exists(f,o)):this._registry.resolve(e);if(o?.throwIfAborted(),this._disposed)return null;let c=r==="symbols"?l[0]:l.find(f=>f.config.capabilities.includes(r));if(!c)return null;let p=s?t:me.file(t).toString(),d=`${c.serverId}:${p}`,g=this._clientStarts.get(d);if(g)return g.controller.signal.aborted?(await A(g.promise.catch(()=>{}),o),this.getOrStart(e,t,r,o)):g.wait(o);let u=this._clients.get(d);if(u?.ready)return u;let m=new H(f=>this._startClient(d,p,c,u,f));this._clientStarts.set(d,m);let y=a(()=>{this._clientStarts.get(d)===m&&this._clientStarts.delete(d)},"settled");return m.promise.then(y,y),m.wait(o)}async _startClient(e,t,r,o,s){let i=o??new $({serverId:r.serverId,rootUri:t,command:r.config.command,...t.startsWith("ssh://")&&this._owner&&{ownerTransport:this._owner.transport(t)},...r.config.env&&{env:r.config.env},...r.config.initializationOptions&&{initOptions:mt(r.config.initializationOptions,t.startsWith("ssh://")?decodeURIComponent(new URL(t).pathname):me.parse(t).fsPath)},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs}});try{o?await o.restart(s):await i.start(s),s.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(k(e,t),r)}let o=await ae(O.resolve(t,e));return r?.throwIfAborted(),o.isFile()}async getWorkspaceClients(e,t="symbols",r=e,o=()=>!0,s){if(s?.throwIfAborted(),e.startsWith("ssh://")){let g=this._owner;if(!g)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});let u=new Set,m=new Set(this._registry.knownExtensions),y=new Set([".git",".cache","node_modules","dist","build"]),f=a(async w=>{if(s?.throwIfAborted(),m.size!==0)for(let S of await g.entries(w,s)){s?.throwIfAborted();let R=k(S.name,`${w}/`);if(S.kind==="directory")y.has(S.name)||await f(R);else if(S.kind==="file"){let v=O.posix.extname(S.name).toLowerCase();if(!m.has(v)||!o(R))continue;let D=await this.openFile(R,e,t,s);D&&(u.add(D.client),m.delete(v))}}},"visit"),h=k(r,e);if(await g.isFile(h,s)){if(!o(h))return[];let w=await this.openFile(h,e,t,s);return w?[w.client]:[]}return await f(h),[...u]}let i=new Set,l=new Set(this._registry.knownExtensions),c=new Set([".git",".cache","node_modules","dist","build"]),p=a(async g=>{if(s?.throwIfAborted(),l.size===0)return;let u;try{u=await sr(g,{withFileTypes:!0})}catch{return}for(let m of u){if(s?.throwIfAborted(),l.size===0)return;if(m.isDirectory()){c.has(m.name)||await p(O.join(g,m.name));continue}if(!m.isFile())continue;let y=O.extname(m.name).toLowerCase();if(!l.has(y))continue;let f=O.join(g,m.name);if(!o(f))continue;let h=await this.openFile(f,e,t,s);h&&(l.delete(y),h.client.hasWorkspaceSymbolCapability&&(await ge(h.client,f),i.add(h.client)))}},"visit"),d=O.resolve(e,r);if((await ae(d)).isFile()){if(!o(d))return[];let g=await this.openFile(d,e,t,s);return g===null||!g.client.hasWorkspaceSymbolCapability?[]:(await ge(g.client,d),[g.client])}return await p(d),s?.throwIfAborted(),[...i]}async prepareWorkspaceSymbols(e,t=e,r,o){return this.getWorkspaceClients(e,"symbols",t,r,o)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}syncEditedSource(e,t){for(let r of this._clients.values()){if(!r.ready)continue;let o=r.toUri(e);if(r.documentContent(o)===void 0)continue;let s=this.languageId(O.extname(decodeURIComponent(new URL(o).pathname)));r.syncDocument(o,t,s,!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"),o=r(await ae(e)),s=await this.readSourceText(e,t);if(o!==r(await ae(e)))throw new Error("A rename source changed while reading it. No edits applied.");return{content:s,version:or("sha256").update(o).update("\0").update(s).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",o){if(o?.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 s=t.startsWith("ssh://"),i=s?k(e,t):O.resolve(t,e),l=await this.getOrStart(i,t,r,o);if(!l)return null;let c=l.toUri(i),p=s?this.requireOwner():void 0,g=(p?await this._registry.resolveOwned(i,u=>p.exists(u,o)):this._registry.resolve(i))[0]?.languageId??"plaintext";if(p){let u=await p.readText(c,o);return o?.throwIfAborted(),l.syncDocument(c,u,g),this._openDocs.add(c),{client:l,uri:c,languageId:g}}try{let{readFile:u}=await import("node:fs/promises"),m=await u(i,{encoding:"utf8",signal:o});o?.throwIfAborted(),l.syncDocument(c,m,g),this._openDocs.add(c)}catch(u){if(o?.throwIfAborted(),!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}return{client:l,uri:c,languageId:g}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let r=t.onNotification("textDocument/publishDiagnostics",o=>{let s=ir(o);if(!s||t.hasActiveDiagnosticRequest(s.uri))return;let i=t.documentVersion(s.uri);if(s.version!==void 0&&i!==void 0&&s.version<i)return;let l=`${e}:${s.uri}`,c=s.diagnostics.map(pe),p=JSON.stringify([s.version,i,c]);if(this._pushFingerprints.get(l)===p)return;this._pushFingerprints.set(l,p);let d={cwd:t.rootUri.startsWith("ssh://")?t.rootUri:me.parse(t.rootUri).fsPath,serverId:t.serverId,uri:s.uri,diagnostics:c,...s.version!==void 0&&{version:s.version}};for(let g of this._pushHandlers)g(d)});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 o=[...this._clients.values()],s=await Promise.allSettled(o.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 s)i.status==="rejected"&&r.push(i.reason);if(r.length>0)throw new AggregateError(r,"Language server cleanup failed")}dispose(){return this.shutdownAll()}};function ir(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(ir,"parsePushNotification");async function fe(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(fe,"loadQueryProject");async function Y(n,e,t,r){return await fe(n,e,r),await n.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}},r)??[]}a(Y,"requestReferences");async function he(n,e,t,r){let o=await n.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t},r),s=o?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,l]=await Promise.all([n.sendRequest("callHierarchy/incomingCalls",{item:s},r),n.sendRequest("callHierarchy/outgoingCalls",{item:s},r)]);return{items:o,incoming:i??[],outgoing:l??[]}}a(he,"requestCallHierarchy");function G(n,e,t){let r=e.startsWith("ssh://"),o=r?Z.posix:Z,s=a(d=>r?decodeURIComponent(new URL(k(d,e)).pathname):d,"native"),i=r?s(t.path??e):Z.resolve(e,t.path??"."),l=o.relative(i,s(n));if(l===".."||l.startsWith(`..${o.sep}`)||o.isAbsolute(l))return!1;let c=o.relative(s(e),s(n)).split(o.sep).join("/"),p=a(d=>d.split(",").some(g=>{let u=g.trim();return u.length>0&&o.matchesGlob(u.includes("/")?c:o.basename(s(n)),u)}),"matches");return(t.include===void 0||p(t.include))&&(t.exclude===void 0||!p(t.exclude))}a(G,"withinScope");function ye(n,e){let t=k(n,e);if(t.startsWith("ssh://"))return t;let r=ar.parse(t);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return Z.resolve(r.fsPath)}a(ye,"sourceOf");function cr(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(cr,"sameRange");function ft(n,e,t){return n.flatMap(r=>[...r.name===e&&r.range!==void 0&&cr(r.range,t)&&r.selectionRange!==void 0?[r.selectionRange]:[],...ft(r.children??[],e,t)])}a(ft,"declarationNames");async function we(n,e,t,r,o={},s=W.getInstance()){r?.throwIfAborted();let i=o.resultScope;if(i!==void 0&&(await F(i,r),i.targets.length===0))return{hits:[],complete:i.complete};if(i===void 0&&o.path!==void 0&&!G(e.startsWith("ssh://")?k(o.path,e):Z.resolve(e,o.path),e,o)&&await s.isSourceFile(o.path,e,r))return{hits:[],complete:!0};let l=i?.targets.map(y=>y.source)??[o.path??e],c=new Set((await Promise.all(l.map(y=>s.prepareWorkspaceSymbols(e,y,f=>G(f,e,o),r)))).flat());if(c.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let p=new Map,d=a(async y=>{r?.throwIfAborted();let f=ye(y.uri,e),h=p.get(f);if(h===void 0){let{content:L,version:N}=await s.readSourceSnapshot(f,r);h={document:Ee(f,L),version:N},p.set(f,h)}let{document:w}=h,{start:S,end:R}=y.range,v=[S,R];for(let L of v){let N=w.lines[L.line];if(!Number.isInteger(L.line)||!Number.isInteger(L.character)||N===void 0||L.character<0||L.character>N.content.length)throw new Error("LSP range does not match its source snapshot.")}let D=_(w.lines[S.line]),re=a(L=>w.lines.slice(0,L).reduce((N,xe)=>N+xe.content.length+xe.lineEnding.length,0),"offset"),U=re(S.line)+S.character,C=re(R.line)+R.character;if(C<U)throw new Error("LSP returned a reversed source range.");return{source:f,lineNumber:S.line+1,endLineNumber:R.line+1,startColumn:S.character,endColumn:R.character,matchedText:w.content.slice(U,C),lineText:D.content}},"toMatch"),g=a(y=>G(y.source,e,o)&&(i===void 0||st(i,y)),"included"),u=[],m=new Set;for(let y of c){r?.throwIfAborted();let f=await ue(y,n,Number.MAX_SAFE_INTEGER,r);for(let h of f){if(r?.throwIfAborted(),!G(ye(h.location.uri,e),e,{}))continue;let w=await d(h.location),S=await s.openFile(w.source,e,"symbols",r);if(S===null)throw new Error("LSP references are unavailable for a discovered declaration.");let R=h.location;if(w.matchedText!==h.name){let C=await Q(S.client,S.uri,r),L=ft(C,h.name,h.location.range);if(L.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");R={uri:S.uri,range:_(L[0])}}let v=await d(R),D={id:JSON.stringify([y.serverId,v.source,h.location.range]),name:h.name,kind:String(h.kind),source:v.source,range:{startLine:v.lineNumber,startColumn:v.startColumn,endLine:v.endLineNumber??v.lineNumber,endColumn:v.endColumn}},re=await Y(S.client,S.uri,R.range.start,r);r?.throwIfAborted();let U=[{...v,role:"definition",symbol:D}];for(let C of re){if(!G(ye(C.uri,e),e,{}))continue;let L=await d(C);L.source===v.source&&L.lineNumber===v.lineNumber&&L.startColumn===v.startColumn&&L.endLineNumber===v.endLineNumber&&L.endColumn===v.endColumn||U.push({...L,role:"reference",symbol:D})}if(!(o.navigation==="references"&&!U.some(g)))for(let C of U){if(o.navigation!=="references"&&!g(C)||o.navigation==="references"&&!G(C.source,e,{}))continue;let L=JSON.stringify([D.id,C.source,C.lineNumber,C.startColumn,C.endLineNumber,C.endColumn]);m.has(L)||(m.add(L),u.push(C))}}}r?.throwIfAborted();for(let[y,f]of p){let h=await s.readSourceSnapshot(y,r);if(h.version!==f.version||h.content!==f.document.content)throw new Error("LSP source changed during search.")}return i!==void 0&&await F(i,r),u.sort((y,f)=>y.source.localeCompare(f.source)||y.lineNumber-f.lineNumber||y.startColumn-f.startColumn||y.endColumn-f.endColumn||y.symbol.id.localeCompare(f.symbol.id)),{hits:u.slice(0,t),complete:(i?.complete??!0)&&u.length<=t}}a(we,"searchSymbols");import{readFile as lr}from"node:fs/promises";import ve from"node:path";import{fileURLToPath as dr}from"node:url";var pr={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},be=10,Se=5,B=10;async function yt(n,e,t,r,o){x(o);let s=await n.readSourceText(e,o),i=await te(n,e,r,o),l=ee(i.symbols,t,i.displayPath),c=await n.readSourceText(i.filePath,o);if(x(o),s!==c)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:l.range,content:c}}a(yt,"resolveLspDeclaration");async function wt(n,e,t,r,o){x(o);let s=await n.readSourceText(e,o),i=await te(n,e,r,o),l=ee(i.symbols,t,i.displayPath);if(s!==await n.readSourceText(e,o))throw new Error("The rename source changed during resolution.");return x(o),{client:i.client,uri:i.uri,position:l.selectionRange.start,content:s}}a(wt,"resolveLspRenameTarget");async function Pe(n,e,t,r,o){x(o);let s=await te(n,e,r,o),i=ee(s.symbols,t,s.displayPath),l=await yr(s.filePath,n,o);x(o);let c=i.range.start.line+1,p=Math.min(i.range.end.line+1,l.lines.length),d=l.lines.slice(Math.max(0,c-1),Math.max(0,p)).map((u,m)=>{let y=c+m;return Ie({content:u,sourceLine:{source:s.filePath,lineNumber:y,content:u}})}),g={path:s.displayPath,heading:`symbol: ${M(i.selector)}`,details:[`defined in: ${s.displayPath}:${c}-${p} (${T(i.kind)})`],startLine:c,endLine:p,totalLines:l.lines.length,renderedLines:d};return De([g],pr)}a(Pe,"readLspSymbolBody");async function _e(n,e,t,r,o){x(o);let s=await te(n,e,r,o),i=ee(s.symbols,t,s.displayPath),l=await Lt(s,i,o),c=new ce(r);return await ur(s,i,l,c)}a(_e,"readLspSymbolGraph");async function Ce(n,e,t,r){x(r);let o=await te(n,e,t,r),s=new ce(t),i=[`## file graph: ${o.displayPath}`,`Top-level declarations: ${o.symbols.length}`];for(let l of o.symbols){x(r);let c=await Lt(o,l,r);i.push("",...await hr(o,l,c,s))}return i.join(`
|
|
2
|
+
`)}a(Ce,"readLspFileGraph");function ee(n,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let s=St(n,_(e[0]));if(s.length===1)return _(s[0]);throw s.length>1?new Error(`Symbol selector "${M(e)}" is ambiguous in ${t}; use parent/child.`):ht(e,t)}let r=n,o;for(let s of e){let i=r.filter(l=>l.name===s);if(i.length===0)throw ht(e,t);if(i.length>1)throw new Error(`Symbol selector "${M(e)}" is ambiguous at "${s}" in ${t}.`);o=_(i[0]),r=o.children}return _(o)}a(ee,"resolveLspCodeSymbol");async function te(n,e,t,r){let o=E(e,t),s=await n.openFile(o,t,"symbols",r);if(!s)throw new Error(`No LSP server with symbol support is configured for ${Re(o,t)}.`);let i=await Q(s.client,s.uri,r),l=vt(i).sort(bt);return{client:s.client,uri:s.uri,filePath:o,displayPath:Re(o,t),symbols:l}}a(te,"openCodeDocument");function vt(n,e=[]){return n.flatMap(t=>{let r=t.selectionRange??t.range;if(!r)return[];let o=t.range??r,s=[...e,t.name];return[{name:t.name,kind:t.kind,range:o,selectionRange:r,selector:s,children:vt(t.children??[],s).sort(bt)}]})}a(vt,"normalizeDocumentSymbols");function bt(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(bt,"compareSymbols");function St(n,e){return n.flatMap(t=>[...t.name===e?[t]:[],...St(t.children,e)])}a(St,"collectNamedSymbols");function ht(n,e){return new Error(`Symbol "${M(n)}" was not found in ${e}.`)}a(ht,"symbolNotFound");async function Lt(n,e,t){let r=e.selectionRange.start,[o,s]=await Promise.all([Y(n.client,n.uri,r,t),he(n.client,n.uri,r,t)]);return x(t),{references:o,calls:s}}a(Lt,"queryRelations");async function ur(n,e,t,r){let o=M(e.selector),s=await r.line(n.uri,e.selectionRange.start.line+1);return[`## graph: ${o}`,`Definition: ${n.displayPath} ${s} (${T(e.kind)})`,`Source: ${J("graph",n.displayPath,e.selector)}`,"",...await gr(t.references,r),"",...await mr(t.calls.incoming,r),"",...await fr(t.calls.outgoing,r)].join(`
|
|
3
|
+
`)}a(ur,"formatSymbolGraph");async function gr(n,e){let t=Rt(n),r=[`References: ${n.length} in ${t.length} file(s)`];for(let[o,s]of t.slice(0,be)){r.push(`- ${e.display(o)} (${s.length})`);for(let i of s.slice(0,Se))r.push(` - ${await e.line(o,i.range.start.line+1)}`);s.length>Se&&r.push(` - ... ${s.length-Se} more`)}return t.length>be&&r.push(`- ... ${t.length-be} more file(s)`),r}a(gr,"formatReferences");async function mr(n,e){let t=[`Incoming calls: ${n.length}`];for(let r of n.slice(0,B)){let o=r.fromRanges[0]?.start.line??r.from.selectionRange.start.line,s=await e.line(r.from.uri,o+1);t.push(`- ${T(r.from.kind)} ${r.from.name} \u2014 ${e.display(r.from.uri)} ${s}`)}return n.length>B&&t.push(`- ... ${n.length-B} more`),t}a(mr,"formatIncomingCalls");async function fr(n,e){let t=[`Outgoing calls: ${n.length}`];for(let r of n.slice(0,B)){let o=await e.line(r.to.uri,r.to.selectionRange.start.line+1);t.push(`- ${T(r.to.kind)} ${r.to.name} \u2014 ${e.display(r.to.uri)} ${o}`)}return n.length>B&&t.push(`- ... ${n.length-B} more`),t}a(fr,"formatOutgoingCalls");async function hr(n,e,t,r){let o=T(e.kind),s=await r.line(n.uri,e.selectionRange.start.line+1),i=Rt(t.references).map(([d,g])=>`${r.display(d)} (${g.length})`),l=t.calls.incoming.map(d=>`${d.from.name} (${r.display(d.from.uri)})`),c=t.calls.outgoing.map(d=>`${d.to.name} (${r.display(d.to.uri)})`),p=[`### ${o} ${e.name}`,`Selector: ${M(e.selector)}`,`Definition: ${s}`,`Used by: ${Le(i)}`,`Incoming calls: ${Le(l)}`,`Outgoing calls: ${Le(c)}`];if(e.children.length>0){p.push("Members:");for(let d of e.children){let g=J("graph",n.displayPath,d.selector);p.push(`- ${T(d.kind)} ${d.name} \u2014 ${g}`)}}return p}a(hr,"formatFileGraphSymbol");function Le(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(Le,"summarize");function Rt(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((o,s)=>o.range.start.line-s.range.start.line||o.range.start.character-s.range.start.character)]).sort(([t],[r])=>t.localeCompare(r))}a(Rt,"groupLocationsByUri");async function yr(n,e,t){let r=n.startsWith("ssh://")?Buffer.from(await e.readSourceBytes(n,t)):await lr(n,{signal:t});if(r.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${n}`);if(r.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${n}`);let o=r.toString("utf8").replaceAll(`\r
|
|
4
|
+
`,`
|
|
5
|
+
`),s=o.endsWith(`
|
|
6
|
+
`)?o.slice(0,-1):o,i=s.length===0?[]:s.split(`
|
|
7
|
+
`);return{content:o,lines:i}}a(yr,"readTextFile");var ce=class{static{a(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return Re(wr(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function wr(n){if(!n.startsWith("file://"))return n;try{return dr(n)}catch{return decodeURIComponent(n.slice(7))}}a(wr,"filePathFromUri");function Re(n,e){if(n.startsWith("ssh://"))return n;let t=ve.relative(e,n);return t.length===0||t.startsWith("..")||ve.isAbsolute(t)?n:t.replaceAll(ve.sep,"/")}a(Re,"displayFilePath");function x(n){if(n?.aborted===!0)throw vr(n)}a(x,"throwIfAborted");function vr(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(vr,"abortReason");function ke(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 o=await n(r.cwd,t,r.signal);r.signal?.throwIfAborted();let s=await br(t,r,o);if(!s)throw new Error("No diagnostic language server for this source");let{client:i,diagnostics:l,syntaxErrors:c,otherDiagnostics:p}=s;return e=i,{ok:!l.some(d=>d.severity==="error"),diagnostics:l,syntaxErrors:c,otherDiagnostics:p}},async restart(){e&&(await e.restart(),e=null)}}}a(ke,"createLspCompiler");async function br(n,e,t){let r=await t.openFile(n,e.cwd,"diagnostics",e.signal);if(e.signal?.throwIfAborted(),!r)return null;let o=await X(r.client,r.uri,r.languageId,{signal:e.signal});if(e.signal?.throwIfAborted(),!o.complete)throw new Error("Language server diagnostics are a snapshot, not a completed report");return{client:r.client,...o}}a(br,"openAndDiagnose");import P from"node:path";import{existsSync as Sr}from"node:fs";function Pt(n){let e=new Map,t=new Map;for(let[r,o]of Object.entries(n))for(let[s,i]of Object.entries(o.languages))for(let l of i.extensions){let c=l.toLowerCase(),p=e.get(c);if(p!==void 0&&p!==s)throw new Error(`[lsp] extension conflict: "${c}" claimed by "${p}" and "${s}"`);e.set(c,s);let d=t.get(c)??[];d.push(r),t.set(c,d)}return{extToLanguageId:e,extToServerIds:t}}a(Pt,"buildLanguageLookup");var I=class n{constructor(e,t,r){this._projectRoot=r;this._entries=e;let o=e.filter(s=>s.layer!=="built-in"||t.has(s.id));this._servers=Object.fromEntries(o.map(s=>[s.id,s.config])),this._lookup=Pt(this._servers)}static{a(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){t.signal?.throwIfAborted();let r=await Ue(e,"lsp-servers",c=>Lr(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 o=t.environment??process.env,s=r.entries.filter(c=>c.layer==="built-in"),i=[];if(t.executableAvailability){let c=await t.executableAvailability(s.map(p=>p.config));if(c.length!==s.length||c.some(p=>typeof p!="boolean"))throw new TypeError("Invalid owner executable availability report");for(let[p,d]of s.entries())i.push({id:d.id,available:c[p]===!0})}else if(t.executableAvailable)for(let c of s)i.push({id:c.id,available:await t.executableAvailable(c.config)});else i.push(...await Promise.all(s.map(async c=>({id:c.id,available:await Ne(c.config,e,o,t.signal)}))));t.signal?.throwIfAborted();let l=t.requireBuiltInEvidence?t.recipeEvidence?await t.recipeEvidence(t.recipes??[]):await Me(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:P.resolve(e))}static fromConfig(e,t=process.cwd()){return new n(Object.entries(e.servers).map(([r,o])=>({id:r,config:o,layer:"project",sourcePath:"<memory>"})),new Set,t.startsWith("ssh://")?t:P.resolve(t))}resolve(e){return this.candidates(e).filter(t=>!t.config.requireRootMarker||this.hasRootMarker(e,t.config.rootMarkers))}candidates(e){let t=P.basename(e),r=P.extname(e)||(e.startsWith(".")?e:`.${e}`),o=a(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),s=[];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(p=>p.toLowerCase()===r.toLowerCase())||c.fileNames?.some(p=>o(p)===o(t))){s.push({serverId:i.id,config:i.config,languageId:l,layer:i.layer,sourcePath:i.sourcePath});break}}return s}async resolveOwned(e,t){if(!this._projectRoot.startsWith("ssh://"))return this.resolve(e);let r=new URL(this._projectRoot),o=decodeURIComponent(r.pathname),s=e.startsWith(".")&&!e.includes("/"),i=e.includes("://")?new URL(e):new URL(r.href),l=e.includes("://")?decodeURIComponent(i.pathname):P.posix.resolve(o,e),c=P.posix.relative(o,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 p=[];for(let d of this.candidates(s?e:l)){if(!d.config.requireRootMarker){p.push(d);continue}let g=s||l===o?o:P.posix.dirname(l);for(;;){let u=!1;for(let m of d.config.rootMarkers){let y=P.posix.resolve(g,m),f=P.posix.relative(o,y);if(f===".."||f.startsWith("../"))continue;let h=new URL(r.href);if(h.pathname=y.split("/").map(encodeURIComponent).join("/"),await t(h.href)){u=!0;break}}if(u){p.push(d);break}if(g===o)break;g=P.posix.dirname(g)}}return p}hasRootMarker(e,t){let r=P.dirname(P.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(P.sep)&&(r=this._projectRoot);;){let o=P.relative(this._projectRoot,r);if(o===".."||o.startsWith(`..${P.sep}`)||P.isAbsolute(o))return!1;if(t.some(s=>Sr(P.join(r,s))))return!0;if(r===this._projectRoot)return!1;r=P.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 Lr(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 o=r;if(!Array.isArray(o.command)||o.command.length===0||o.command.some(s=>typeof s!="string"||s.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(o.transport!==void 0&&o.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(o.rootMarkers)||o.rootMarkers.some(s=>typeof s!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(o.requireRootMarker!==void 0&&typeof o.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(o.requireRootMarker&&o.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof o.languages!="object"||o.languages===null||Array.isArray(o.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[s,i]of Object.entries(o.languages)){let l=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(l)||l.length===0||l.some(p=>typeof p!="string"))throw new Error(`LSP server ${t} language ${s} requires extensions`);let c=i.fileNames;if(c!==void 0&&(!Array.isArray(c)||c.some(p=>typeof p!="string"||p.length===0||/[/\\]/u.test(p))))throw new Error(`LSP server ${t} language ${s}.fileNames must contain basenames`)}if(!Array.isArray(o.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return n}a(Lr,"parseLspConfig");function _t(n){return kt("symbol","lsp-symbol",n,async e=>await Pe(e.manager,e.filePath,_(e.selector),e.cwd,e.signal))}a(_t,"createLspSymbolResolver");function Ct(n){return kt("graph","lsp-graph",n,async e=>e.selector===void 0?await Ce(e.manager,e.filePath,e.cwd,e.signal):await _e(e.manager,e.filePath,e.selector,e.cwd,e.signal))}a(Ct,"createLspGraphResolver");function kt(n,e,t,r){return{id:e,tryResolve(o,s){return Promise.resolve(Rr(o,s,n,t,r))}}}a(kt,"createCodeViewResolver");function Rr(n,e,t,r,o){let s;try{s=q(n,t)}catch(c){return{kind:"failed",error:c}}if(s===void 0)return{kind:"not-handled"};let i;try{i=E(s.path,e.cwd)}catch(c){return{kind:"failed",error:c}}return{kind:"resolved",resource:{source:J(t,i,s.selector),async read(c){let p=await r(e.cwd,i,c.signal),d=await o({manager:p,filePath:i,cwd:e.cwd,...Pr(s.selector),..._r(c.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}a(Rr,"resolveCodeViewSource");function Pr(n){return n===void 0?{}:{selector:n}}a(Pr,"optionalSelector");function _r(n){return n===void 0?{}:{signal:n}}a(_r,"optionalSignal");function Et(n,e=(t,r)=>Promise.resolve({cwd:r,external:!1})){return{id:"lsp",async diagnose(t,r){let o=await e(t,r.cwd,r.signal);if(o===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let s=await n(o.cwd,o.external,r.signal);r.signal.throwIfAborted();let i=await s.getOrStart(t,o.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=s.languageId(t);i.syncDocument(l,r.content,c,!0);let p=i.documentVersion(l),d={active:!0,queued:!1},g=a(()=>!r.signal.aborted&&i.documentVersion(l)===p,"current"),u=a(()=>X(i,l,c,{signal:r.signal,content:r.content}),"request"),m=a(async()=>{if(d.queued=!0,!d.active){d.active=!0;try{for(;d.queued&&g();){d.queued=!1;let f=await u();g()&&r.publish(xt(f,i.commandName))}}catch(f){g()&&r.publish({status:"unavailable",diagnostics:[],reason:f instanceof Error?f.message:String(f),source:i.commandName})}finally{d.active=!1}}},"refresh"),y=s.onPushDiagnostics(f=>{!g()||f.uri!==l||f.serverId!==i.serverId||f.cwd!==o.cwd||f.version!==void 0&&f.version!==p||(i.diagnosticMode==="pull"||se(i)?m():r.publish({status:"snapshot",diagnostics:f.diagnostics,source:i.commandName,reason:It(f.version===void 0)}))});r.signal.addEventListener("abort",y,{once:!0});try{let f=await u();return p=i.documentVersion(l),xt(f,i.commandName)}catch(f){throw d.queued=!1,y(),r.signal.removeEventListener("abort",y),f}finally{d.active=!1,d.queued&&g()&&queueMicrotask(()=>{m()})}}}}a(Et,"createLspDiagnosticSource");function It(n){return`Latest push snapshot; completion is unknown${n?"; language server omitted the document version":""}`}a(It,"snapshotReason");function xt(n,e){return n.complete?{status:"ready",diagnostics:n.diagnostics,source:e}:{status:"snapshot",diagnostics:n.diagnostics,reason:It(n.unversioned),source:e}}a(xt,"toReport");import{URI as Cr}from"vscode-uri";var Dt={protocol:Fe,apiVersion:Ve,id:"lsp",setup(n){for(let e of V)n.addToolRecipe(e);n.addSetupCheck({id:"effective-config",inspect:kr}),n.addCheck({id:"config",title:"LSP",async run(e){try{let t=await I.fromPackageDir(e.cwd,At(e)),r=xr(t,e.files);return r.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(r.map(async o=>{let s=`${o.serverId} [${o.layer}] command ${JSON.stringify(o.config.command)}`,i=e.workspace,l=new $({serverId:o.serverId,rootUri:i?e.cwd:Cr.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:o.config.command,env:Er(e.env,o.config.env),...o.config.initializationOptions&&{initOptions:o.config.initializationOptions},...o.config.settings&&{settings:o.config.settings},...o.config.timeoutMs&&{timeoutMs:o.config.timeoutMs}});try{return await l.start(e.signal),{status:"pass",message:`${s}: initialized`,detail:o.sourcePath}}catch(c){return{status:"fail",message:`${s}: ${c instanceof Error?c.message:String(c)}`,detail:o.sourcePath}}finally{await l.shutdown()}}))}catch(t){return e.signal?.throwIfAborted(),[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function kr(n){try{let e=await I.fromPackageDir(n.cwd,At(n)),t=[],r=new Map;for(let[o,s]of n.detectedLanguages){let i=s.flatMap(l=>e.resolve(l)).find(l=>l.languageId===o);i!==void 0&&(t.push({kind:"lsp",languageId:o,toolId:i.serverId}),await He(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(kr,"inspectLspSetup");function At(n){let e=n.workspace;return{...ze(n),recipeEvidence:e?t=>e.evidence(t,n.signal):void 0}}a(At,"lspOptions");function xr(n,e){let t=new Map;for(let r of e){let o=n.resolve(r)[0];o!==void 0&&!t.has(o.serverId)&&t.set(o.serverId,o)}return[...t.values()]}a(xr,"applicableServers");function Er(n,e){return Object.fromEntries(Object.entries({...n,...e}).filter(t=>t[1]!==void 0))}a(Er,"definedEnvironment");import jt from"node:path";function Tt(n,e){return{id:"symbols",supportsResultScope:!0,readResources:a(t=>t.query.startsWith("symbols:")?void 0:[],"readResources"),toScriptData(t){return t.data},async tryResolve(t,r){if(!t.query.startsWith("symbols:"))return{kind:"not-handled"};let o=t.query.slice(8).trim();if(o.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let s=r.scope,i=new Map;if(s!==void 0){await F(s,r.signal);for(let u of s.targets){let m=await n(r.cwd,u.source,r.signal),y=i.get(m)??[];y.push(u),i.set(m,y)}}else i.set(await n(r.cwd,t.path,r.signal),[]);let l=t.limit??100,c=a(async u=>{let m=[],y=s?.complete??!0;for(let[f,h]of i){let w=await we(o,f.workspaceRoot,l,u,{...t,...s===void 0?{}:{resultScope:{targets:h,complete:s.complete}}},f);m.push(...w.hits),y=y&&w.complete}return s!==void 0&&await F(s,u),{hits:m.slice(0,l),complete:y&&m.length<=l}},"collect"),p=await c(r.signal),d=await e({request:t,matches:p.hits,complete:p.complete,refresh:a(async u=>{let m=await c(u);return{matches:m.hits,complete:m.complete}},"refresh")},r),g=it(p.hits,p.complete,d.id,d);return{kind:"resolved",payload:{query:o,sessionId:d.id,hits:p.hits,complete:p.complete,navigation:t.navigation,data:{...g,matches:g.matches.map((u,m)=>({...u,role:p.hits[m]?.role,symbol:p.hits[m]?.symbol}))}}}},renderResult(t,r,o){let s=t.details;return ot(s.hits,s.complete,o,r.expanded,s.cwd,s.navigation==="references"?["LSP reference navigation \xB7 may leave input scope"]:[],s.hits.map(i=>`${i.role} ${i.symbol.name}`))},format(t,r){let o=t,s=o.navigation==="references"?"LSP reference navigation (may leave input scope)":"LSP symbols inside scope",i=o.hits.length===0?["No symbols found."]:o.hits.slice(0,100).map((l,c)=>`SEARCH#${o.sessionId}:${c+1}:match ${l.source.startsWith("ssh://")?l.source:jt.relative(r.cwd,l.source)}:${l.lineNumber}:${l.startColumn+1} ${l.role} ${l.symbol.name} \xB7 declared at ${l.symbol.source.startsWith("ssh://")?l.symbol.source:jt.relative(r.cwd,l.symbol.source)}:${l.symbol.range.startLine}:${l.symbol.range.startColumn+1}`);return o.complete&&o.hits.length&&i.unshift(`SEARCH#${o.sessionId}:all:match selects all exact symbol matches.`),o.hits.length>100&&i.push("Preview shortened; full source targets retained."),{content:[{type:"text",text:[s,...i].join(`
|
|
8
|
+
`)}],details:{...o,cwd:r.cwd}}}}}a(Tt,"createLspSearchResolver");function Ot(n){return{id:"lsp-declaration-target",async tryResolve(e,t){let r=q(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 o=await yt(await n(t.cwd,E(r.path,t.cwd),t.signal),E(r.path,t.cwd),r.selector,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(o){return{kind:"failed",error:new Error(`${o instanceof Error?o.message:String(o)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`,{cause:o})}}}}}a(Ot,"createDeclarationTargets");import{fileURLToPath as Ir}from"node:url";function Mt(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(Mt,"renameEntries");function $t(n,e){let t=n.split(`
|
|
9
|
+
`),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((o,s)=>o+s.length+1,0)+e.character}a($t,"offset");async function Wt(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=q(t.path.slice(0,-5),"symbol");if(r?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let o=E(r.path,n.cwd),s=await e(n.cwd,o,n.signal),i=await wt(s,o,r.selector,n.cwd,n.signal);await fe(i.client,i.uri,n.signal);let l=Mt(await ie(i.client,i.uri,i.position,t.text),i.client),c=new Map;for(let g of new Set([i.uri,...l.keys()])){n.signal?.throwIfAborted();let u=k(g,i.client.rootUri);if(u!==g)throw new Error("Rename returned a non-canonical participant. No edits applied.");let m=u.startsWith("ssh://")?u:Ir(u),y=await s.readSourceSnapshot(m,n.signal);if(m===o&&y.content!==i.content)throw new Error("The rename source changed. Read the symbol again before retrying.");let f=await s.openFile(m,n.cwd,"symbols",n.signal);if(f?.client!==i.client||f.uri!==g)throw new Error("A rename participant has a different language server owner. No edits applied.");if(i.client.documentContent(g)!==y.content)throw new Error("A rename participant changed during synchronization. No edits applied.");c.set(g,{file:m,...y})}let p=Mt(await ie(i.client,i.uri,i.position,t.text),i.client);n.signal?.throwIfAborted();for(let[g,u]of c){n.signal?.throwIfAborted();let m=await s.readSourceSnapshot(u.file,n.signal);if(u.version!==m.version||i.client.documentContent(g)!==u.content)throw new Error("A rename participant changed during the server request. No edits applied.")}let d=[];for(let[g,u]of p){let m=c.get(g);if(!m)throw new Error("Rename discovered a new participant after preflight. No edits applied.");d.push({source:m.file,expectedContent:m.content,changes:u.map(y=>({from:$t(m.content,y.range.start),to:$t(m.content,y.range.end),insert:y.newText}))})}return{...n,editPlan:{files:d},metadata:{...n.metadata,semanticEdit:{mode:"lsp-rename",server:i.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}a(Wt,"prepareSymbolRename");var Ut=Xe({kind:"code-view",label:"LSP"});async function Ar(n){await jr(n)}a(Ar,"registerLsp");async function jr(n,e){let t=new Map,r=!1,o=a(async(d,g=!1,u)=>{if(u?.throwIfAborted(),r)throw new Error("LSP session has ended");let m=JSON.stringify([d,g]),y=t.get(m);if(y?.controller.signal.aborted)return await A(y.promise.catch(()=>{}),u),t.get(m)===y&&t.delete(m),o(d,g,u);if(!y){y=new H(async h=>{let w=e?await e.loadRegistry(d,g,h):await Tr(d,g,h);if(h.throwIfAborted(),r)throw new Error("LSP session has ended");return W.init(w,e?.workspace(d))});let f=y;t.set(m,f),f.promise.catch(()=>{t.get(m)===f&&t.delete(m)})}return y.wait(u)},"managerFor"),s=a(async(d,g,u)=>{if(u?.throwIfAborted(),e)return e.resolveProject(d,g,u);let m=await We(g,d,"lsp-servers",V,u);return u?.throwIfAborted(),m===void 0?void 0:{cwd:m,external:m!==Dr.resolve(g)}},"resolveLspProject"),i=a(async(d,g,u)=>{if(u?.throwIfAborted(),!g)return o(d,!1,u);let m=await s(g,d,u);if(u?.throwIfAborted(),!m)throw new Error("No language server project for this source");return o(m.cwd,m.external,u)},"managerForFile"),l={...ke(i),name:"pi-agent-ide-lsp",priority:200},c={protocol:je,apiVersion:5,id:"lsp",setup(d){d.addTool(l),d.addDiagnosticSource(Et(o,s))}};n.on("session_shutdown",async()=>{r=!0,await Promise.allSettled([...t.values()].map(async d=>{d.settled||d.controller.abort(new Error("LSP session has ended")),await(await d.promise).shutdownAll()})),t.clear()});let p={protocol:Be,apiVersion:Je,id:"lsp",setup(d){d.addResolver({resolver:_t(i),renderResult:Ut}),d.addResolver({resolver:Ct(i),renderResult:Ut}),d.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:Ae()}),d.describe({path:"symbol:<file>#<selector> \u2014 declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> \u2014 top-level declarations, references and calls; members include selectors. graph:<file>#<selector> \u2014 references and incoming/outgoing calls for that declaration or member."})}};await Promise.all([Oe(n,c),et(n,{protocol:Qe,apiVersion:Ye,id:"lsp-declarations",setup(d){d.onDidEdit(async g=>{await Promise.all([...t.values()].filter(u=>u.settled).map(u=>u.promise.then(m=>m.syncEditedSource(g.source,g.after.content),()=>{})))}),d.addAnchorResolver({kind:Ze,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(g=>g,"renderFull"),renderCompact:a(g=>g,"renderCompact"),tryResolve:a(()=>Promise.resolve({kind:"not-handled"}),"tryResolve")},resources:Ot(i),describeInPrompt:!1});for(let g of["copy","move","delete","replace"])d.tool(g).describe("Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. For declaration-text Copy/Move, supply an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename."+(g==="replace"?" Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement.":"")),d.tool(g).addHandler({stage:"text-pre-edit",async handler(u){if(g==="replace"){let f=await Wt(u,i);if(f!==void 0)return f}let m=u.input;if(![m.path,m.start,m.end,m.target,m.targetStart,m.targetEnd].some(f=>typeof f=="string"&&f.startsWith("symbol:")))return u;if((g==="copy"||g==="move")&&typeof m.target!="string")throw new Error("Copying or moving a symbol requires an explicit target file and destination anchor.");return{...u,metadata:{...u.metadata,semanticEdit:{mode:"declaration-text",referencesUpdated:!1,importsUpdated:!1},diffStatuses:[{text:"Text fallback: imports and references unchanged",tone:"warning"}]}}}});d.tool("insert").describe("Symbol targets are unsupported for insert. Read the declaration and select an ordinary text line anchor instead."),d.tool("insert").addHandler({stage:"text-pre-edit",handler(g){let u=g.input;if([u.path,u.anchor].some(m=>typeof m=="string"&&m.startsWith("symbol:")))throw new Error("Semantic insert is not supported. Read the declaration and use an explicit text line anchor instead.");return g}})}}),Ke(n,p),Ge(n,Dt),nt(n,{protocol:tt,apiVersion:rt,id:"symbols",setup(d){d.addResolver({resolver:Tt(i,d.registerSelection)}),d.describe('Use `symbols:<query>` to locate named workspace declarations and references through configured language servers when the file is unknown. Results contain exact source targets, roles, and originating symbols. Default search stays within path. Use navigation: "references" explicitly to follow symbols represented inside path to references outside it, within the workspace.')}})])}a(jr,"registerLspWithOwner");async function Tr(n,e,t){let r=e?n:process.env.PI_AGENT_IDE_CONFIG_DIR??n;return I.fromPackageDir(r,{signal:t,includeGlobal:!e,requireBuiltInEvidence:e,recipes:V})}a(Tr,"loadRegistry");export{V as a,I as b,Ar as c,jr as d};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as S}from"./chunk-ZPT5D4VP.js";import{a as d}from"./chunk-EI7MMDWY.js";import{createRequire as j}from"node:module";import{Lang as y,parse as T,registerDynamicLanguage as F}from"@ast-grep/napi";var R=j(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),B={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"},D={".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 O(){if(N)return;let r={};for(let[e,t]of Object.entries(B))r[e]=R(t);F(r),N=!0}d(O,"ensureLanguagesRegistered");function C(r,e){let t=D[r];if(t)return O(),{rootNode:new b(T(t,e).root(),e)}}d(C,"parseNativeDocument");var b=class r{constructor(e,t){this.node=e;this.source=t}static{d(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 k(this.source,this.node.range().start.index)}get endIndex(){return k(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 k(r,e){return Buffer.from(r).subarray(0,e).toString("utf8").length}d(k,"byteOffsetToStringIndex");import{createHash as q}from"node:crypto";import{createRequire as W}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var I=W(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),M=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]),A,
|
|
2
|
-
`),l=await G(o);if(l)try{return l.parse(i)??void 0}finally{l.delete()}return C(o,i)}d(U,"parseDocument");function
|
|
3
|
-
`);return q("sha1").update(a).digest("hex").slice(0,4).toUpperCase()}d(
|
|
1
|
+
import{a as S}from"./chunk-ZPT5D4VP.js";import{a as d}from"./chunk-EI7MMDWY.js";import{createRequire as j}from"node:module";import{Lang as y,parse as T,registerDynamicLanguage as F}from"@ast-grep/napi";var R=j(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),B={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"},D={".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 O(){if(N)return;let r={};for(let[e,t]of Object.entries(B))r[e]=R(t);F(r),N=!0}d(O,"ensureLanguagesRegistered");function C(r,e){let t=D[r];if(t)return O(),{rootNode:new b(T(t,e).root(),e)}}d(C,"parseNativeDocument");var b=class r{constructor(e,t){this.node=e;this.source=t}static{d(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 k(this.source,this.node.range().start.index)}get endIndex(){return k(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 k(r,e){return Buffer.from(r).subarray(0,e).toString("utf8").length}d(k,"byteOffsetToStringIndex");import{createHash as q}from"node:crypto";import{createRequire as W}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var I=W(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),M=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]),A,E=new Map;function $(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}}d($,"grammarWasmPath");async function G(r){let e=$(r);if(!e)return;A??=p.Parser.init(),await A;let t=E.get(e);if(t===void 0){let i=I.resolve(e);t=p.Language.load(i),E.set(e,t)}let a=await t,o=new p.Parser;return o.setLanguage(a),o}d(G,"ensureParser");async function U(r,e,t){if(t.length===0)return;let a=r.includes("://")||L.isAbsolute(r)?r:L.resolve(e,r),o=L.extname(a).toLowerCase(),i=t.join(`
|
|
2
|
+
`),l=await G(o);if(l)try{return l.parse(i)??void 0}finally{l.delete()}return C(o,i)}d(U,"parseDocument");function P(r,e,t){let a=r.slice(Math.max(0,e-1),Math.max(0,t)).join(`
|
|
3
|
+
`);return q("sha1").update(a).digest("hex").slice(0,4).toUpperCase()}d(P,"hashScope");var w=class extends S{static{d(this,"AstScopeTextAnchor")}constructor(e,t,a,o){super(`scope-${e}-${t}${o===void 0?"":`-${o}`}`,a)}};function f(r,e,t,a){return new w(r,e,t,a)}d(f,"createScopeAnchor");var v=class{static{d(this,"AstScopeManager")}async getDocumentScopes(e,t,a){if(a.length===0)return[];let o=await U(e,t,a);if(!o)return[];let i=[];return this.collectCandidates(o.rootNode,i),this.buildEntries(i,a)}collectCandidates(e,t,a=0,o=!1){if(a>100||!e.isNamed)return;let i=e.type;if(!i||M.has(i)){for(let c of e.namedChildren)this.collectCandidates(c,t,a+1);return}for(let c of x){let n=e.childForFieldName(c);if(!n?.isNamed)continue;let s=n.startPosition.row+1,g=n.endPosition.row+1,h=g-s>=3,u=[...x].some(m=>n.childForFieldName(m)!==null);h&&!u&&t.push({startLine:s,endLine:g,kind:`${i}.${c}`,fromBodyField:!0}),this.collectCandidates(n,t,a+1,!0)}if(![...x].some(c=>e.childForFieldName(c)!==null)&&!o){let c=e.startPosition.row+1,n=e.endPosition.row+1;n-c>=3&&e.namedChildren.length>0&&t.push({startLine:c,endLine:n,kind:i,fromBodyField:!1})}for(let c of e.namedChildren)this.collectCandidates(c,t,a+1)}buildEntries(e,t){let a=new Map;for(let n of e){let s=a.get(n.startLine);(!s||n.endLine>s.endLine||n.endLine===s.endLine&&n.fromBodyField&&!s.fromBodyField)&&a.set(n.startLine,n)}let o=[...a.values()].sort((n,s)=>n.startLine-s.startLine||s.endLine-n.endLine),i=[];for(let n of o)i.some(g=>g.startLine<n.startLine&&g.endLine===n.endLine)||i.push(n);let l=new Map;for(let n of i){let s=P(t,n.startLine,n.endLine);l.set(s,(l.get(s)??0)+1)}let c=new Map;return i.map(n=>{let s=P(t,n.startLine,n.endLine),g=l.get(s)??1,h=(c.get(s)??0)+1;c.set(s,h);let u=g>1?h:void 0;return{name:n.kind,kind:n.kind,startLine:n.startLine,endLine:n.endLine,depth:i.filter(m=>m!==n&&m.startLine<=n.startLine&&m.endLine>=n.endLine&&(m.startLine<n.startLine||m.endLine>n.endLine)).length,hash:s,blockHash:s,...u!==void 0&&{occurrence:u},beginAnchor:f("begin",s,n.startLine,u),endScopeAnchor:f("end",s,n.endLine,u),scopeBeginAnchor:f("begin",s,n.startLine,u),scopeEndAnchor:f("end",s,n.endLine,u)}})}};export{D as a,U as b,v as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-search",i=
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-search",i=6,S="pi-agent-search/core/ready",R="pi-agent-search/plugin/register",a=e.Unsafe({type:"Function"}),s=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(i)}),c=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(i),id:e.String({minLength:1}),setup:a}),p=e.Object({plugin:c,accept:a});function g(r){return n.Check(s,r)}o(g,"isSearchCoreReady");function h(r){return n.Check(c,r)}o(h,"isSearchPlugin");function y(r){return n.Check(p,r)}o(y,"isSearchPluginRegistrationRequest");export{t as a,i as b,S as c,R as d,g as e,h as f,y as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a}from"./chunk-EI7MMDWY.js";import{constants as v}from"node:fs";import{access as E}from"node:fs/promises";import f from"node:path";var A=["google-chrome-stable","google-chrome","chromium","chromium-browser"],R=["/usr/bin/google-chrome-stable","/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser","/opt/google/chrome/chrome"];function b(e={}){let t;return{async load(o,r){t??=x(e.executablePath,e.environment??process.env);let n=await t;r.signal?.throwIfAborted();let{chromium:s}=await import("playwright-core");r.signal?.throwIfAborted();let i=await s.launch({executablePath:n,headless:!0,chromiumSandbox:!1,timeout:r.timeoutMs}),c=a(()=>{i.close()},"closeOnAbort");r.signal?.addEventListener("abort",c,{once:!0});try{r.signal?.throwIfAborted();let l=await i.newPage(),u=await l.goto(o.href,{timeout:r.timeoutMs,waitUntil:"domcontentloaded"});if(u!==null&&!u.ok())throw new Error(`HTTP ${u.status()}: ${u.statusText()}`);await l.waitForLoadState("networkidle",{timeout:Math.min(r.timeoutMs,1500)}).catch(()=>{}),r.signal?.throwIfAborted(),await T(l);let d={html:await l.content(),source:l.url()};return r.signal?.throwIfAborted(),d}catch(l){throw r.signal?.aborted===!0?S(r.signal):new Error(`Browser read failed for ${o.href}: ${B(l)}`,{cause:l})}finally{r.signal?.removeEventListener("abort",c),await i.close().catch(()=>{})}}}}a(b,"createSystemBrowserHtmlLoader");async function x(e=process.env.PI_AGENT_IDE_BROWSER_PATH,t=process.env){if(e!==void 0&&e.trim().length>0){let o=f.resolve(e);if(await m(o))return o;throw new Error(`PI_AGENT_IDE_BROWSER_PATH is not executable: ${o}`)}for(let o of(t.PATH??"").split(f.delimiter).filter(Boolean))for(let r of A){let n=f.join(o,r);if(await m(n))return n}for(let o of R)if(await m(o))return o;throw new Error("No system Chrome or Chromium executable was found. Install Chrome/Chromium or set PI_AGENT_IDE_BROWSER_PATH.")}a(x,"resolveSystemBrowserExecutable");async function T(e){await e.locator("body *").evaluateAll(t=>{for(let o of t.toReversed()){let r=globalThis.getComputedStyle(o);(o.hasAttribute("hidden")||o.getAttribute("aria-hidden")==="true"||r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse")&&o.remove()}})}a(T,"removeHiddenElements");async function m(e){try{return await E(e,v.X_OK),!0}catch{return!1}}a(m,"isExecutable");function S(e){return e.reason instanceof Error?e.reason:P()}a(S,"abortReason");function P(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(P,"abortError");function B(e){return e instanceof Error?e.message:String(e)}a(B,"errorMessage");var H=4096;function Z(e,t={}){let o=C(t);return{id:"web",async tryResolve(r,n){if(/^web:/iu.test(r)){let s=await t.owner?.tryResolve(r,n);return s!==void 0&&s.kind!=="not-handled"?s:{kind:"failed",error:new Error(`Target web execution is unavailable: ${r}`)}}return L(r,e,o)}}}a(Z,"createWebResolver");function C(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??b(),autoBrowserFallback:e.autoBrowserFallback??!0}}a(C,"resolverSettings");function L(e,t,o){let r;try{r=new URL(e)}catch(n){return G(e)?{kind:"failed",error:new TypeError(`Invalid HTTP source ${e}`,{cause:n})}:{kind:"not-handled"}}return r.protocol!=="http:"&&r.protocol!=="https:"?{kind:"not-handled"}:{kind:"resolved",resource:{source:r.href,read({signal:n}){return k(r,t,o,n)}}}}a(L,"resolveHttpSource");async function k(e,t,o,r){let n=g(r,o.timeoutMs),s=!0;try{n.signal.throwIfAborted();let i=await o.fetchResource(e,{method:"GET",redirect:"follow",signal:n.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(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);let c=i.headers.get("content-type")??void 0;if($(c)&&!W(e)){let y=await M(i,H,n.signal);return[{type:"text",text:_(e,i,c,y)}]}let l=new Uint8Array(await i.arrayBuffer());n.signal.throwIfAborted();let d={source:i.url.length===0?e.href:i.url,bytes:l,...c!==void 0&&{mediaType:c}};s=D(l,c);let h=await t.convert(d,{signal:n.signal});if(n.signal.throwIfAborted(),o.autoBrowserFallback&&s&&p(h))throw new Error("HTTP read returned empty HTML content");return h}catch(i){if(r?.throwIfAborted(),!o.autoBrowserFallback||!s)throw i;n.dispose();try{return await I(e,t,o,r)}catch(c){throw r?.throwIfAborted(),new Error(`HTTP read failed (${w(i)}) and browser fallback failed: ${w(c)}`,{cause:c})}}finally{n.dispose()}}a(k,"readWebContent");async function I(e,t,o,r){let n=g(r,o.timeoutMs);try{n.signal.throwIfAborted();let s=await U(e,t,o,n.signal);if(n.signal.throwIfAborted(),p(s))throw new Error("Browser read returned empty content");return s}finally{n.dispose()}}a(I,"readBrowserContent");async function U(e,t,o,r){let n=await o.browser.load(e,{signal:r,timeoutMs:o.timeoutMs});return r.throwIfAborted(),t.convert({source:n.source,bytes:new TextEncoder().encode(n.html),mediaType:"text/html; charset=utf-8"},{signal:r})}a(U,"loadAndConvertBrowser");function $(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($,"isUnsupportedBinaryMediaType");function W(e){return/\.(?:avif|bmp|gif|jpe?g|pdf|png|webp)$/iu.test(e.pathname)}a(W,"hasSupportedDocumentExtension");async function M(e,t,o){if(e.body===null)return new Uint8Array;let r=e.body.getReader(),n=[],s=0;try{for(;s<t;){o.throwIfAborted();let l=await r.read();if(l.done)break;let u=t-s,d=l.value.subarray(0,u);if(n.push(d),s+=d.length,l.value.length>u)break}}finally{await r.cancel().catch(()=>{})}let i=new Uint8Array(s),c=0;for(let l of n)i.set(l,c),c+=l.length;return i}a(M,"readBoundedBody");function _(e,t,o,r){let n=["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: ${o??"unknown"}`],s=t.headers.get("content-disposition"),i=s===null?void 0:F(s);i!==void 0&&n.push(`Filename: ${i}`);let c=t.headers.get("content-length");c!==null&&n.push(`Content-Length: ${c}`);let l=[...t.headers].filter(([u])=>!j(u)&&u!=="content-type"&&u!=="content-length").sort(([u],[d])=>u.localeCompare(d)).map(([u,d])=>`${u}: ${d}`);return l.length>0&&n.push("","Headers:",...l),n.push("",`Preview: first ${r.length} bytes (hex).`,N(r)),n.join(`
|
|
2
|
+
`)}a(_,"formatUnsupportedBinaryResponse");function F(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(F,"attachmentFilename");function j(e){return["content-location","link","location","refresh","set-cookie"].includes(e.toLowerCase())}a(j,"isSensitiveRedirectHeader");function N(e){if(e.length===0)return"(empty body)";let t=[];for(let o=0;o<e.length;o+=16){let r=e.subarray(o,o+16),n=[...r].map(i=>i.toString(16).padStart(2,"0")).join(" "),s=[...r].map(i=>i>=32&&i<=126?String.fromCodePoint(i):".").join("");t.push(`${o.toString(16).padStart(8,"0")} ${n.padEnd(47)} |${s}|`)}return t.join(`
|
|
3
|
+
`)}a(N,"formatHexPreview");function D(e,t){let o=t?.split(";",1)[0]?.trim().toLowerCase();if(o==="text/html"||o==="application/xhtml+xml")return!0;let r=new TextDecoder("utf8").decode(e.subarray(0,1024));return/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu.test(r)}a(D,"isHtml");function p(e){return e.every(t=>t.type==="text"&&t.text.trim().length===0)}a(p,"isEmptyTextContent");function g(e,t){let o=new AbortController,r=a(()=>{o.abort(O(e))},"abortFromParent"),n=setTimeout(()=>{o.abort(z(t))},t);return n.unref(),e?.aborted===!0?r():e?.addEventListener("abort",r,{once:!0}),{signal:o.signal,dispose(){clearTimeout(n),e?.removeEventListener("abort",r)}}}a(g,"createOperationSignal");function G(e){return/^https?:/iu.test(e)}a(G,"claimsHttpScheme");function O(e){return e?.reason instanceof Error?e.reason:q()}a(O,"abortReason");function q(){let e=new Error("The operation was aborted");return e.name="AbortError",e}a(q,"abortError");function z(e){let t=new Error(`Web read timed out after ${e}ms`);return t.name="TimeoutError",t}a(z,"timeoutError");function w(e){return e instanceof Error?e.message:String(e)}a(w,"errorMessage");export{x as a,Z as b};
|