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
package/dist/entry-33.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import{a as Z,b as Y,c as J}from"./chunk-DEP55R35.js";import{e as F,f as j}from"./chunk-T7I2VX3J.js";import{a as M}from"./chunk-MGCHOGQD.js";import{a as O,b as U}from"./chunk-T6LX2RX5.js";import{a as q}from"./chunk-2ZMMRINH.js";import{a as K,b as X}from"./chunk-HZ5BNF3A.js";import{a as V}from"./chunk-BU7IZLKB.js";import{a as _,b as B}from"./chunk-S5PL5DFQ.js";import{G as W,f as z,i as Q,j as E}from"./chunk-6U5OU77O.js";import{a as D}from"./chunk-ZPT5D4VP.js";import{d as L,e as N}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{access as ue}from"node:fs/promises";import le from"node:path";var ee={protocol:O,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ge(e.cwd)?await L("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await N("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function ge(n){try{return await ue(le.join(n,".git")),!0}catch{return!1}}s(ge,"isGitProject");import{mkdtemp as fe,rm as pe,writeFile as he}from"node:fs/promises";import me from"node:os";import m from"node:path";var b=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let i=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return i.code!==0?{status:"unavailable",reason:"no-worktree",message:i.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(i.stdout.trim()))}}async readTrackedFile(e,t,r){let i=m.resolve(t,e),o=m.relative(this.repositoryRoot,i);return o===".."||o.startsWith(`..${m.sep}`)||m.isAbsolute(o)?{status:"unavailable",reason:"outside-worktree",message:`${i} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(o.split(m.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let i=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(i.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:i.stderr.trim()||`could not inspect HEAD:${e}`};let o=xe(i.stdout);if(o===void 0)return{status:"untracked"};let c=await this.readBlob(o.blob,"HEAD",e,t);if(c.status!=="found")return c;let d=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(d.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:d.stderr.trim()||`could not inspect the index entry for ${e}`};let a=ye(d.stdout);if(a.some(({stage:u})=>u!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let l=a.find(({stage:u})=>u===0),f="";if(l!==void 0){let u=await this.readBlob(l.blob,"index",e,t);if(u.status!=="found")return u;f=u.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:c.text,indexText:f,indexMode:l?.mode??o.mode}}async writeIndexFile(e,t,r,i){let o=await fe(m.join(me.tmpdir(),"pi-agent-index-")),c=m.join(o,"content");try{await he(c,r,"utf8");let d=await this.git(["hash-object","-w",`--path=${e}`,c],i);if(d.code!==0||d.stdout.trim().length===0)throw new Error(d.stderr.trim()||`could not write a Git blob for ${e}`);let a=await this.git(["update-index","--add","--cacheinfo",t,d.stdout.trim(),e],i);if(a.code!==0)throw new Error(a.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await pe(o,{recursive:!0,force:!0})}}async readBlob(e,t,r,i){let o=await this.git(["cat-file","blob",e],i);return o.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:o.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:o.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function xe(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,i,o]=e.slice(0,t).split(" ",3);return r===void 0||i!=="blob"||o===void 0?void 0:{mode:r,blob:o,path:e.slice(t+1)}}s(xe,"parseTreeEntry");function ye(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,i,o]=e.slice(0,t).split(" ",3),c=Number(o);return r===void 0||i===void 0||!Number.isInteger(c)?[]:[{mode:r,blob:i,stage:c,path:e.slice(t+1)}]})}s(ye,"parseIndexEntries");function te(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(te,"extensionGitExecutor");var h=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let i=await b.create(e,t,r);return i.status==="unavailable"?i:{status:"ready",service:new n(i.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=Z(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let i=await this.inspect(e);if(i.status!=="applicable")return i;let o=i.groups.find(l=>l.selector===t);if(o===void 0)return A(t,i.groups.map(({selector:l})=>l));let c=r==="stage"?"staged":"unstaged";if(o.state===c)return{status:"unchanged",state:c,group:o};let d=x(o.segments[0]),a={head:i.head,repositoryPath:i.repositoryPath,headStart:d.headStart,headEnd:d.headEnd,replacementText:r==="stage"?d.worktreeText:d.headText};try{await this.applyIndexUpdate(a,e.signal)}catch(l){return{status:"unavailable",reason:"index-write-failed",message:we(l)}}return{status:"applied",state:c,group:o}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let i=r.groups.find(a=>a.selector===t);if(i===void 0)return A(t,r.groups.map(({selector:a})=>a));let o=Y(e.worktreeText,i);if(o===void 0)return A(t,r.groups.map(({selector:a})=>a));let c=x(i.segments[0]),d=i.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:c.headText};return{status:"applied",worktreeText:o,group:i,...d!==void 0&&{indexUpdate:d}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let i=J(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);i!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,i,t)}};function A(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(A,"staleSelector");function we(n){return n instanceof Error?n.message:String(n)}s(we,"errorMessage");var T="pi-agent-ide-changes/change",be=/^CHANGE#[0-9A-F]{4,64}$/,Te=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,P=class extends D{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function ne(n){return{resolver:Ce(s(async t=>{if(Te.test(t.source))return;let r=await h.create(n,t.cwd,t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(ne,"createChangeAnchorRegistration");function Ce(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!be.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let i=r.status==="applicable"?r.groups.find(o=>o.selector===e):void 0;return i===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new P(i)}}catch(r){return{kind:"failed",error:r}}}}}s(Ce,"createChangeAnchorResolver");import{diffLines as ve}from"diff";var ke="filesystem";function re(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==ke)return e;let r=await h.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let i=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return i.status!=="applicable"?e:Ee(e,i.groups)}}}s(re,"createCurrentChangePresenter");function Ee(n,e){let t=new Map;for(let r of e)Ae(n,r,t);return{...n,references:e.map(r=>({value:r.selector,kind:"change",state:r.state})),lines:n.lines.map(r=>Ge(r,t.get(r.lineNumber)))}}s(Ee,"presentChangeGroups");function Ae(n,e,t){let r=x(e.segments[0]),i=ve(r.headText,r.worktreeText),o=e.currentStartLine,c,d;for(let a of i){let l=Re(a.value);if(a.removed){let f=Ie(n,o),u=I(t,f.lineNumber),p=f.after?u.after:u.before;for(let $ of l){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:$}),c??=w,d=w}continue}if(a.added){for(let f of l){let u=I(t,o),p={kind:"current",lineNumber:o};u.added=!0,c??=p,d=p,o++}continue}o+=l.length}if(c!==void 0&&d!==void 0){let a=`${e.selector} \xB7 ${e.state}`;Pe(c,d)?G(t,c,`<!-- change: ${a} -->`):(G(t,c,`<!-- change-begin: ${a} -->`),G(t,d,`<!-- change-end: ${a} -->`))}}s(Ae,"presentChangeGroup");function Pe(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(Pe,"sameTarget");function G(n,e,t){if(e.kind==="current"){I(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(G,"annotateTarget");function Ge(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s(Ge,"presentLine");function I(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(I,"presentationsFor");function Ie(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Ie,"placementFor");function Re(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(Re,"splitLines");var C=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Se}from"node:crypto";import{realpathSync as He}from"node:fs";import ae from"node:path";import{fileURLToPath as $e}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=ie(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===v(e.before.content)?this.#e.set(t,{...r,afterDigest:v(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:v(e.after.content)})}restore(e,t,r){let i=ie(e,t),o=this.#e.get(i);if(o===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(o.afterDigest!==v(r))throw this.#e.delete(i),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return o.before}};function ie(n,e){return n.startsWith("file://")?oe($e(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:oe(ae.resolve(e,n))}s(ie,"sourceKey");function oe(n){try{return He.native(n)}catch{return ae.normalize(n)}}s(oe,"canonicalFile");function v(n){return Se("sha256").update(n).digest("hex")}s(v,"textDigest");import{readFile as De}from"node:fs/promises";import Le from"node:path";import{defineTool as Ne,withFileMutationQueue as Oe}from"@earendil-works/pi-coding-agent";import{Text as Ue}from"@earendil-works/pi-tui";import{Type as g}from"typebox";var R=g.Object({action:g.Union([g.Literal("stage"),g.Literal("unstage")]),change:g.String(),file:g.String(),state:g.Optional(g.Union([g.Literal("staged"),g.Literal("unstaged")])),effect:g.Union([g.Literal("applied"),g.Literal("not-applied"),g.Literal("unknown")]),unchanged:g.Optional(g.Boolean())},{additionalProperties:!1}),Fe=z(R),y=g.Object({file:g.String({description:"Path to the tracked text file"}),change:g.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1}),je=g.Object({file:{...y.properties.file,description:"Path to a tracked text file in the current Git worktree. Relative paths resolve from the workspace."},change:{...y.properties.change,description:'Select one complete current CHANGE#HASH anchor returned by read with views: ["changes"].'}},{additionalProperties:!1});function de(n,e,t){n.registerTool(se("stage",e,t)),n.registerTool(se("unstage",e,t))}s(de,"registerIndexChangeTools");function se(n,e,t){let r=Me(n,e,t),i=n==="stage"?"Staged":"Unstaged",o=n==="stage"?{...y,properties:{file:{...y.properties.file,description:"Path to the tracked text file, absolute or relative to the current working directory."},change:{...y.properties.change,description:'Use the complete current CHANGE#HASH anchor shown by read with views: ["changes"].'}}}:je;return Ne({name:n,exposure:"deferred",namespace:{name:"ide_git",description:"Stage or unstage selected Git changes without changing worktree files."},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},label:n,promptSnippet:`${i.slice(0,-1)} a selected Git change`,description:n==="stage"?"Use stage to add one selected Git change to the index without changing the worktree file.":"Use unstage to remove one selected Git change from the index. Worktree content is kept.",parameters:o,outputSchema:Fe,...n==="stage"&&{renderResult(c,d,a){return new Ue(a.fg("toolOutput",c.content.flatMap(l=>l.type==="text"?[l.text]:[]).join(`
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import{a as Te}from"./chunk-LEKC4GQK.js";import{b as Le}from"./chunk-EMRJP6EM.js";import"./chunk-D4IA2MTA.js";import{f as Re,g as Ae}from"./chunk-XH5WN5XA.js";import{b as P,c as Oe}from"./chunk-UEVGZUII.js";import{b as Ie,c as ve}from"./chunk-R2U5WXYR.js";import{a as we}from"./chunk-47SPPIXK.js";import{a as be,b as Se}from"./chunk-VAXLSPPU.js";import{b as xe}from"./chunk-OI3HBIPK.js";import{e as N}from"./chunk-YTYLS2UM.js";import{e as te,f as ne}from"./chunk-T7I2VX3J.js";import{a as re}from"./chunk-YJ6T3PEP.js";import{b as Z,c as ee}from"./chunk-S72FVLUX.js";import{a as ye}from"./chunk-M4TVRCMZ.js";import{c as fe,d as ge,e as he}from"./chunk-TGC2ZACO.js";import"./chunk-NNCZYO4Q.js";import{d as de}from"./chunk-IICJXZBU.js";import{a as ae,b as ce,e as le}from"./chunk-PS2B6THP.js";import{a as ie}from"./chunk-BU7IZLKB.js";import{a as oe,b as se}from"./chunk-S5PL5DFQ.js";import{H as D,J as k,K as me,f as ue,i as pe,j as M}from"./chunk-DXONCYWF.js";import{h as Q}from"./chunk-DUUOCBS3.js";import{a as J,b as X,c as W}from"./chunk-T4FTT3U4.js";import{m as Y}from"./chunk-ZPT5D4VP.js";import"./chunk-KINKBPPX.js";import"./chunk-756K3LJY.js";import{a as K}from"./chunk-ZC65Z3CK.js";import{a as p}from"./chunk-EI7MMDWY.js";import{readFile as dt}from"node:fs/promises";var ut={cmake:"no compatible Tree-sitter parser is packaged",dockerfile:"no compatible Tree-sitter parser is packaged",julia:"no compatible Tree-sitter parser is packaged",powershell:"no compatible Tree-sitter parser is packaged",r:"no compatible Tree-sitter parser is packaged",svelte:"the container grammar is not available as an ast-grep language package",terraform:"the HCL grammar is not available as an ast-grep language package",vue:"the container grammar is not available as an ast-grep language package",xml:"no compatible Tree-sitter parser is packaged",zig:"no compatible Tree-sitter parser is packaged"},U=new Set(["c","cpp","csharp","css","dart","elixir","go","html","java","kotlin","lua","markdown","php","ruby","scala","shell","sql","swift","javascript","typescript","python","rust","json","yaml","toml"]),Ee={protocol:Z,apiVersion:ee,id:"ast",setup(t){t.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(o=>U.has(o))?await ve(e,"ast-grep")?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),t.addCheck({id:"parsers",title:"AST",async run(e){let n=[];for(let o of e.detectedLanguageIds){let r=ut[o];if(r!==void 0){n.push({status:"skip",message:`${o} AST is unavailable: ${r}`});continue}if(!U.has(o))continue;let s=e.files.find(i=>pt(i,o));if(s!==void 0)try{e.signal?.throwIfAborted();let i=e.workspace?await e.workspace.readText(s,e.signal):await dt(s,{encoding:"utf8",signal:e.signal});if(i===void 0)throw new Error(`Source disappeared: ${s}`);e.signal?.throwIfAborted();let a=await P(s,e.cwd,i.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`));n.push(a===void 0?{status:"fail",message:`${o} parser did not return a tree`}:{status:"pass",message:`${o} parser loaded`,detail:s})}catch(i){e.signal?.throwIfAborted(),n.push({status:"fail",message:`${o}: ${i instanceof Error?i.message:String(i)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),t.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(o=>U.has(o)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await Ie(e,"ast-grep",["--version"]);return[n.ok?{status:"pass",message:"ast-grep is available",detail:n.detail}:{status:"fail",message:"ast-grep is not available",detail:n.detail}]}})}};function pt(t,e){let n=t.slice(t.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],csharp:[".cs"],css:[".css",".scss",".less"],dart:[".dart"],elixir:[".ex",".exs"],go:[".go"],html:[".html",".htm"],java:[".java"],kotlin:[".kt",".kts"],lua:[".lua"],markdown:[".md",".mdx"],php:[".php"],ruby:[".rb",".rake"],scala:[".scala",".sc"],shell:[".sh",".bash"],sql:[".sql"],swift:[".swift"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(n)??!1}p(pt,"matchesLanguage");var mt,ft;function ke(t,e){return{id:"ast",tryResolve(n,o){return Promise.resolve(gt(n,o,t,e))}}}p(ke,"createAstOutlineResolver");function gt(t,e,n,o){let r;try{r=J(t,"ast")}catch(a){return{kind:"failed",error:a}}if(r===void 0)return{kind:"not-handled"};let s;try{s=X(r.path,e.cwd)}catch(a){return{kind:"failed",error:a}}let i=W("ast",s);return{kind:"resolved",resource:{source:s,link:i,async read({signal:a}){a?.throwIfAborted();let l=await(ft??=import("./chunk-4W7GH3T7.js")),d=n??(mt??=new l.AstOutlineManager),u;if(s.startsWith("ssh://")){if(o===void 0)throw new Error("No AST snapshot owner for this resource.");let f=await o(s,{...e,signal:a});if(Buffer.byteLength(f.lines.join(`
|
|
5
|
+
`))>Te)throw new Error("File exceeds the 262144-byte AST outline limit.");if(f.lines.some(g=>g.includes("\0")))throw new Error("Binary resources cannot be read as AST outlines.");u=await d.readDocumentOutline(f.source,e.cwd,f.lines)}else u=await d.readFileOutline(s,e.cwd);return a?.throwIfAborted(),[l.formatAstOutline(u)]}}}}p(gt,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ht,DEFAULT_MAX_LINES as yt,truncateHead as G}from"@earendil-works/pi-coding-agent";var B=p(async(t,e,n)=>{let{source:o,resolvedBy:r,lines:s,totalLines:i,startLine:a}=t.details;if(!(o===void 0||r!=="filesystem"&&!o.startsWith("ssh://")||s===void 0||s.length!==i||a!==void 0&&a!==1))try{let{AstOutlineManager:l,isSupportedOutlinePath:d}=await import("./chunk-4W7GH3T7.js");if(!d(o))return;let u=p(h=>[`Code overview of ${h.path}, source lines 1-${h.totalLines}: the requested text exceeded the output limit.`,`Some source text is omitted. Read ${JSON.stringify(o)} with offset and limit for exact source text.`,...h.renderedLines.map(b=>`${b.sourceLine?.lineNumber??"\u2026"} | ${b.text}`)].join(`
|
|
6
|
+
`),"format");e.signal?.throwIfAborted();let f=await new l(12).readDocumentOutline(o,e.cwd,s.map(h=>h.content),h=>(e.signal?.throwIfAborted(),!G(u(h),n).truncated)),g=u(f);return G(g,n).truncated?void 0:{script:t.script,content:[{type:"text",text:g}],details:{source:o,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function Ne(){return async t=>{let{state:e,result:n}=t,o=n?.content.length===1?n.content[0]:void 0;if(t.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"&&!e.source.startsWith("ssh://")||o?.type!=="text"||!G(o.text).truncated)return{kind:"continue",context:t};let r=await B({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},t.resolverContext,{maxBytes:ht,maxLines:yt});return r===void 0?{kind:"continue",context:t}:{kind:"continue",context:t,transform:p(s=>({...r,script:s.script}),"transform")}}}p(Ne,"createAstOverflowHandler");var Pe="pi-agent-ast";function je(t){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem"&&!e.source.startsWith("ssh://"))return e;try{let o=await t.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),r=bt(e.lines,o);return r===e.lines?e:{...e,lines:r}}catch{return e}}}}p(je,"createAstScopePresenter");function Ce(){return t=>{let e=t.state,n=t.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:t};let o=n.details.lines;if(o===void 0)return{kind:"continue",context:t};let r=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(o.map(u=>u.lineNumber)),i=new Map;for(let u of o){let f=r.get(u.lineNumber),g=$e(f);for(let h of g?.boundaries??[]){if(s.has(h.endLine))continue;let b=r.get(h.endLine);b!==void 0&&i.set(h.endLine,b)}}if(i.size===0)return{kind:"continue",context:t};let a=[...i.values()].sort((u,f)=>u.lineNumber-f.lineNumber),l=[...o,...a],d=o.at(-1);return{kind:"continue",context:t,transform:p(u=>St(u,l,d),"transform")}}}p(Ce,"createAstScopePostReadHandler");function bt(t,e){if(e.length===0)return t;let n=new Map,o=new Map;for(let r of e){let s=n.get(r.startLine)??[];s.push(r.beginAnchor.value),n.set(r.startLine,s);let i=o.get(r.startLine)??[];i.push({endLine:r.endLine,beginAnchor:r.beginAnchor.value,endAnchor:r.endScopeAnchor.value}),o.set(r.startLine,i);let a=n.get(r.endLine)??[];a.push(r.endScopeAnchor.value),n.set(r.endLine,a)}return t.map(r=>{let s=n.get(r.lineNumber),i=o.get(r.lineNumber);return s===void 0&&i===void 0?r:{...r,...s!==void 0&&{anchors:[...new Set([...r.anchors??[],...s])],presentation:{...r.presentation,suffix:`${r.presentation?.suffix??""}${s.map(a=>` <!-- ${a} -->`).join("")}`}},metadata:{...r.metadata,[Pe]:{...$e(r),...i!==void 0&&{boundaries:i}}}}})}p(bt,"addScopeMarkers");function $e(t){let e=t?.metadata?.[Pe];if(!(typeof e!="object"||e===null))return e}p($e,"getAstScopeMetadata");function St(t,e,n){let o=t.content.length===1?t.content[0]:void 0;if(o?.type!=="text"||t.details.lines===void 0)return t;let r=e.slice(t.details.lines.length);if(r.length===0)return t;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:r[0]?.lineEnding!==void 0&&r[0].lineEnding.length>0?r[0].lineEnding:`
|
|
7
|
+
`,i=r.map((d,u)=>{let g=u===r.length-1?d.lineEnding:d.lineEnding||s,h=d.presentation?.prefix??"",b=d.presentation?.suffix??"";return`${h}${d.content}${b}${g}`}).join(""),a=/(?:\r\n|\r|\n)$/.test(o.text)?"":s,l=`${o.text}${a}${i}`;return{...t,content:[{...o,text:l}],details:{...t.details,lines:e}}}p(St,"appendTextLines");var _e=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function Me(t){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return _e.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!_e.test(e))return{kind:"not-handled"};try{let r=(await t.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return r===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:r.beginAnchor.value===e?r.beginAnchor:r.endScopeAnchor}}catch(o){return{kind:"failed",error:o}}}}}p(Me,"createAstScopeAnchorResolver");import It from"cross-spawn";import{readFile as vt,stat as Ge}from"node:fs/promises";import Lt from"node:path";import De from"node:path";import{pathToFileURL as wt}from"node:url";function Ue(t,e,n,o,r){let s=new Map;for(let a of e){let l=s.get(a.file)??[];l.push(a),s.set(a.file,l)}let i=[...s.entries()].map(([a,l])=>xt(a,l,o));return{sessionId:r,query:t,matchCount:e.length,fileCount:i.length,complete:n,files:i}}p(Ue,"createAstSearchPresentation");function xt(t,e,n){let o=new Map;e.forEach((a,l)=>{let d=a.lines.replace(/\r/gu,"").split(`
|
|
8
|
+
`);d.at(-1)===""&&d.pop();let u=`${t}:${String(l)}`;d.forEach((f,g)=>{let h=a.range.start.line+g+1,b=Rt(a,f,g,d.length);if(b===void 0)return;let w=o.get(h)??{text:f,ranges:[],logicalMatchIds:[]};w.ranges.push(b),w.logicalMatchIds.push(u),o.set(h,w)})});let r=[...o.entries()].sort(([a],[l])=>a-l).map(([a,l])=>{let d=At(l.ranges);return{lineNumber:a,text:l.text,matchCount:d.length,ranges:d,logicalMatchIds:[...new Set(l.logicalMatchIds)]}}),s=t.includes("://"),i=s?t:De.resolve(n,t);return{path:s?i:De.relative(n,i),link:s?i:wt(i).href,matchCount:e.length,lines:r}}p(xt,"createFilePresentation");function Rt(t,e,n,o){let r=n===0,s=n===o-1,i=r?t.range.start.column:0,a=s?t.range.end.column:e.length;if(!(a<=i))return{from:Math.min(i,e.length),to:Math.min(a,e.length)}}p(Rt,"highlightedRange");function At(t){let e=[...t].sort((o,r)=>o.from-r.from||o.to-r.to),n=[];for(let o of e){let r=n.at(-1);r===void 0||o.from>r.to?n.push(o):n[n.length-1]={from:r.from,to:Math.max(r.to,o.to)}}return n}p(At,"mergeRanges");function He(t){return{id:"ast",supportsResultScope:!0,readResources:p((e,n)=>e.query.startsWith("ast:")?n.scope?.targets.map(o=>o.source)??[e.path??n.cwd]:[],"readResources"),renderResult:Le,async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let o=e.query.slice(4).trim();if(o.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let r=p(f=>n.environmentForSource?.(f)??n.environment,"owner"),s=p(async f=>{n.scope!==void 0&&await k(n.scope,f);let g=[];if(n.scope===void 0)g.push(...await Ve(o,e,n.cwd,f,n.environment));else for(let m of new Set(n.scope.targets.map(y=>y.source)))f?.throwIfAborted(),g.push(...await Ve(o,{...e,path:m},n.cwd,f,r(m)));let h=g.map(m=>({...m,file:j(n.cwd,m.file,r(m.file))}));h.sort((m,y)=>m.file.localeCompare(y.file)||m.range.byteOffset.start-y.range.byteOffset.start||m.range.byteOffset.end-y.range.byteOffset.end);let b=[];for(let m of h){let y=(await Be([m],n.cwd,f,r(m.file)))[0];if(y===void 0)throw new Error("Missing AST selection snapshot");n.scope!==void 0&&!xe(n.scope,y)||b.push({selection:y,raw:{...m,range:{...m.range,start:{line:y.lineNumber-1,column:y.startColumn},end:{line:(y.endLineNumber??y.lineNumber)-1,column:y.endColumn}}}})}let w=b.slice(0,e.limit??100);return n.scope!==void 0&&await k(n.scope,f),{raw:w.map(m=>m.raw),matches:w.map(m=>m.selection),complete:(n.scope?.complete??!0)&&b.length<=(e.limit??100)}},"collect"),i=await s(n.signal),a=await t({request:e,matches:i.matches,complete:i.complete,refresh:s},n),l=N(i.matches,i.complete,a.id,a),d=[],u=[];for(let f of i.raw.slice(0,l.matches.length)){let g=Object.entries({...Object.fromEntries(Object.entries(f.metaVariables?.single??{}).map(([w,m])=>[w,[m]])),...f.metaVariables?.multi}),h=[],b={};for(let[w,m]of g){for(let R of m)if(R.range.byteOffset.start<f.range.byteOffset.start||R.range.byteOffset.end>f.range.byteOffset.end)throw new Error("AST capture lies outside its parent match.");let y=await Be(m.map(R=>({...f,...R})),n.cwd,n.signal,r(f.file)),x=await t({request:e,matches:y,complete:i.complete,refresh:p(async()=>{throw new Error("Capture snapshots cannot refresh; repeat the AST search.")},"refresh")},n);b[w]={target:K(N(y,i.complete,void 0,x).target),nodes:y.length};let A=[];for(let R=0;R<y.length;R+=100){let E=y.slice(R,R+100),I=await t({request:e,matches:E,complete:i.complete,refresh:p(async()=>{throw new Error("Capture snapshots cannot refresh; repeat the AST search.")},"refresh")},n);A.push(...N(E,i.complete,void 0,I).matches)}h.push([w,A])}d.push(Object.fromEntries(h)),u.push(b)}return n.scope!==void 0&&await k(n.scope,n.signal),{kind:"resolved",payload:{data:{...l,matches:l.matches.map((f,g)=>({...f,captures:d[g]}))},captureGroups:u,pattern:o,matches:i.raw.map((f,g)=>({...f,selection:i.matches[g]})),complete:i.complete,sessionId:a.id,presentation:Ue(e.query,i.raw,i.complete,n.cwd,a.id)}}},toScriptData(e){return e.data},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n.presentation};let o=n.matches.flatMap((r,s)=>{let i=[`SEARCH#${n.sessionId}:${s+1}:match ${r.file}:${r.range.start.line+1}:${r.range.start.column+1} ${r.language}`,` ${r.lines.trim()}`];for(let[a,l]of Object.entries(n.captureGroups[s]??{}))i.push(` capture ${a}: ${l.target} ${l.nodes} node(s)`);return i});return n.complete&&o.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),{content:[{type:"text",text:o.join(`
|
|
9
|
+
`)}],details:n.presentation}}}}p(He,"createAstSearchResolver");async function Be(t,e,n,o){let r=new Map;for(let s of t){let i=j(e,s.file,o);if(!r.has(i))if(o!==void 0)r.set(i,Buffer.from(await o.readText(i,n)));else{let a=await Ge(i),l=await vt(i,{signal:n}),d=await Ge(i);if(a.mtimeMs!==d.mtimeMs||a.size!==d.size)throw new Error("AST source changed during search. Run the structural query again.");r.set(i,l)}}return t.map(s=>{let i=j(e,s.file,o),a=r.get(i);if(a===void 0)throw new Error("Missing AST source snapshot");let{start:l,end:d}=s.range.byteOffset;if(!Number.isInteger(l)||!Number.isInteger(d)||l<0||d<l||d>a.length||a.subarray(l,d).toString("utf8")!==s.text)throw new Error("AST range does not match its source snapshot. Search again.");let u=a.subarray(0,l).toString("utf8"),f=a.subarray(0,d).toString("utf8"),g=u.split(`
|
|
10
|
+
`).length;return{source:i,lineNumber:g,endLineNumber:f.split(`
|
|
11
|
+
`).length,startColumn:u.length-u.lastIndexOf(`
|
|
12
|
+
`)-1,endColumn:f.length-f.lastIndexOf(`
|
|
13
|
+
`)-1,matchedText:s.text,lineText:a.toString("utf8").split(`
|
|
14
|
+
`)[g-1]?.replace(/\r$/u,"")??""}})}p(Be,"selectionMatches");function Ve(t,e,n,o,r){o?.throwIfAborted();let s=["run","--pattern",t,"--json=compact","--no-ignore","parent"];for(let i of Fe(e.include))s.push("--globs",i);for(let i of Fe(e.exclude))s.push("--globs",`!${i}`);return r!==void 0?Ot(r,s,e,n,o):(j(n,e.path??"."),s.push(e.path??"."),new Promise((i,a)=>{let l=It("ast-grep",s,{cwd:n,stdio:["ignore","pipe","pipe"]}),d="",u="";l.stdout.setEncoding("utf8"),l.stderr.setEncoding("utf8"),l.stdout.on("data",g=>d+=g),l.stderr.on("data",g=>u+=g);let f=p(()=>{l.kill("SIGTERM")},"abort");o?.addEventListener("abort",f,{once:!0}),l.once("error",a),l.once("close",g=>{if(o?.removeEventListener("abort",f),o?.aborted===!0){a(o.reason instanceof Error?o.reason:new Error("AST search aborted"));return}if(g!==0&&g!==1){a(new Error(u.trim()||`ast-grep exited with code ${String(g)}`));return}try{let h=JSON.parse(d.length===0?"[]":d);if(!Array.isArray(h))throw new TypeError("ast-grep returned non-array JSON");i(h)}catch(h){a(h instanceof Error?h:new Error(String(h)))}})}))}p(Ve,"runAstGrep");function j(t,e,n){if(n!==void 0)return n.resolve(t,e);if(e.includes("://")||t.includes("://"))throw new Error("No structural search owner for this resource.");return Lt.resolve(t,e)}p(j,"resolveSource");async function Ot(t,e,n,o,r){if(t.execute===void 0)throw new Error("This resource owner does not support structural search execution.");let s=t.resolve(o,n.path??"."),i=await t.isDirectory(s,r),a=i?s:t.dirname(s);e.push(i?".":`./${t.basename(s)}`);let l=await t.execute("ast-grep",e,a,r);if(r?.throwIfAborted(),l.code!==0&&l.code!==1)throw new Error(`Structural search failed with exit ${String(l.code)}.`);let d=JSON.parse(l.stdout.length===0?"[]":l.stdout);if(!Array.isArray(d))throw new TypeError("ast-grep returned non-array JSON");return d.map(u=>({...u,file:t.resolve(a,u.file)}))}p(Ot,"runOwnedAstGrep");function Fe(t){return t?.split(",").map(e=>e.trim()).filter(Boolean)??[]}p(Fe,"splitGlobs");import{Text as Ft}from"@earendil-works/pi-tui";import ze from"node:path";import{pathToFileURL as Tt}from"node:url";function qe(t,e,n,o){let r=new Map;for(let a of t){let l=r.get(a.target.source);l?l.push(a):r.set(a.target.source,[a])}let s=[];t.length||s.push({kind:"note",text:"No selections"}),e||s.push({kind:"note",text:"Incomplete input; not a complete edit scope"}),n&&s.push({kind:"note",text:`${n} input(s) without a selection`});let i=100;for(let[a,l]of r){if(!i)break;let d=l.slice(0,i);i-=d.length;let u=a.startsWith("ssh://"),f=u?a:ze.relative(o,a)||ze.basename(a),g=[],h=!1,b=l[0]?.target.expectedContent.split(/\r\n|\n|\r/u)??[];for(let m of d){let{start:y,end:x}=m.range,R=y.lineNumber===x.lineNumber&&y.column===x.column?y.lineNumber:x.lineNumber-(x.column===0?1:0),E=Math.min(R,y.lineNumber+19);h||=E<R;for(let I=y.lineNumber;I<=E;I++){let q=b[I-1]??"";g.push({source:a,label:f,link:u?a:Tt(a).href,lineNumber:I,text:q,ranges:[{from:I===y.lineNumber?y.column:0,to:I===x.lineNumber?x.column:q.length}]})}}let w=ce(g);s.push(...w.map(m=>m.kind==="source"?{...m,count:l.length}:m)),h&&s.push({kind:"note",text:"\u2026 selection preview shortened \xB7 full target retained"});for(let m of d){m.range.start.lineNumber===m.range.end.lineNumber&&m.range.start.column===m.range.end.column&&s.push({kind:"note",text:`zero-width \xB7 ${m.range.start.lineNumber}:${m.range.start.column}`});let{start:y,end:x}=m.range;s.push({kind:"note",expandedOnly:!0,text:`${m.syntax?`${m.syntax.object}${m.syntax.part?`/${m.syntax.part}`:""} \xB7 `:""}${y.lineNumber}:${y.column}\u2013${x.lineNumber}:${x.column} \xB7 ${m.origins.length} origin(s)${m.origins.some(A=>A.expanded)?" \xB7 expanded":""}`});for(let A of m.origins.slice(0,20)){let R=A.range;s.push({kind:"note",expandedOnly:!0,text:`from ${R.startLine}:${R.startColumn}\u2013${R.endLine}:${R.endColumn}`})}m.origins.length>20&&s.push({kind:"note",expandedOnly:!0,text:"\u2026 more origins retained in this result reference"})}}return t.length>100&&s.push({kind:"note",text:"\u2026 more selections \xB7 consume the complete result target"}),{summary:`${t.length} ${t.length===1?"selection":"selections"} in ${r.size} ${r.size===1?"file":"files"}${e?"":" \xB7 incomplete"}`,rows:s}}p(qe,"selectPresentation");import Pt from"node:path";var S=class extends Error{constructor(n,o){super(o);this.code=n}static{p(this,"SelectionError")}};function v(t){return{startLine:t.start.lineNumber,startColumn:t.start.column,endLine:t.end.lineNumber,endColumn:t.end.column}}p(v,"publicRange");function T(t,e){let n=JSON.stringify([e.target.source,e.range]),o=t.get(n);t.set(n,o?{...e,origins:[...o.origins,...e.origins]}:e)}p(T,"retainRegion");var L=class{constructor(e){this.content=e;let n=0,o=Y("",e),r=o.lines.map(s=>{let i=n;return n+=s.content.length+s.lineEnding.length,{start:i,length:s.content.length,end:n}});(r.length===0||o.lines.at(-1)?.lineEnding)&&r.push({start:n,length:0,end:n}),this.lines=r}static{p(this,"SourceText")}lines;boundary(e){if(!Number.isSafeInteger(e)||e<0||e>this.content.length)throw new S("INVALID_RANGE","Text bounds are outside the retained snapshot.");let n=this.content.charCodeAt(e-1),o=this.content.charCodeAt(e);if(n>=55296&&n<=56319&&o>=56320&&o<=57343||n===13&&o===10)throw new S("INVALID_BOUNDARY","Text boundary splits a surrogate pair or CRLF separator.")}offset(e){let n=this.lines[e.lineNumber-1];if(!Number.isSafeInteger(e.lineNumber)||!n||!Number.isSafeInteger(e.column)||e.column<0||e.column>n.length)throw new S("INVALID_RANGE","Source bounds are outside the retained snapshot.");let o=n.start+e.column;return this.boundary(o),o}lineIndex(e){let n=0,o=this.lines.length-1;for(;n<o;){let r=Math.ceil((n+o)/2);(this.lines[r]?.start??0)<=e?n=r:o=r-1}return n}position(e){this.boundary(e);let n=this.lineIndex(e);return{lineNumber:n+1,column:e-(this.lines[n]?.start??0)}}range(e,n){if(n<e)throw new S("INVALID_RANGE","Text bounds are reversed.");return{start:this.position(e),end:this.position(n)}}fullLines(e,n){let o=this.lines[this.lineIndex(e)],r=this.lines[this.lineIndex(n>e?n-1:e)];if(!o||!r)throw new S("INVALID_RANGE","Source line bounds are unavailable.");return{from:o.start,to:r.end}}};function Je(t,e,n){let o=t;for(;o.parent&&o.parent.node.startIndex===o.node.startIndex&&o.parent.node.endIndex===o.node.endIndex;)o=o.parent;let r=o.parent;if(!r||!(r.node.type==="arguments"&&r.parent?.object==="call"||r.node.type==="formal_parameters"&&r.parent?.object==="function")||o.node.type==="comment")throw new S("EXACT_LIST_ELEMENT_REQUIRED","elementExtent requires an exact direct call argument or parenthesized function parameter. Use a full AST capture; partial expressions and other lists are not supported.");let s=r.node.startIndex,i=r.node.endIndex-1;if(n[s]!=="("||n[i]!==")")throw new S("UNSUPPORTED_LIST","Only parenthesized argument and parameter lists are supported.");if(e==="inside")return{startIndex:o.node.startIndex,endIndex:o.node.endIndex};let a=r.children.filter(w=>w.node.type!=="comment"),l=a.indexOf(o),d=a[l-1],u=a[l+1],f=d?.node.endIndex??s+1,g=u?.node.startIndex??i,h=n.slice(f,o.node.startIndex),b=n.slice(o.node.endIndex,g);if(!(d?/^\s*,\s*$/u:/^\s*$/u).test(h)||!(u?/^\s*,\s*$/u:/^\s*,?\s*$/u).test(b))throw new S("AMBIGUOUS_LIST_TRIVIA","Comments or unsupported trivia in adjacent list gaps have no inferred owner. Use inside for the exact element, or choose explicit text boundaries.");return a.length===1?{startIndex:s+1,endIndex:i}:u||b.includes(",")?{startIndex:o.node.startIndex,endIndex:g}:{startIndex:f,endIndex:o.node.endIndex}}p(Je,"listElementExtent");var Et={function_declaration:"function",generator_function_declaration:"function",function_expression:"function",generator_function:"function",arrow_function:"function",method_definition:"function",function_signature:"function",method_signature:"function",abstract_method_signature:"function",call_expression:"call",new_expression:"call",class_declaration:"class",class:"class",abstract_class_declaration:"class",if_statement:"if",switch_statement:"switch",for_statement:"loop",for_in_statement:"loop",while_statement:"loop",do_statement:"loop",try_statement:"try",catch_clause:"catch",variable_declarator:"binding",assignment_expression:"assignment",augmented_assignment_expression:"assignment",object:"object",object_pattern:"object",pair:"property",pair_pattern:"property",shorthand_property_identifier:"property",shorthand_property_identifier_pattern:"property",array:"array",array_pattern:"array",return_statement:"return",throw_statement:"throw"};function Xe(t,e){let n=[],o=[{node:t,parent:void 0}];for(;o.length;){e?.throwIfAborted();let r=o.pop();if(!r)continue;let s={node:r.node,object:Et[r.node.type],parent:r.parent,children:[]};r.parent?.children.push(s),n.push(s);for(let i of r.node.namedChildren.toReversed())o.push({node:i,parent:s})}return n}p(Xe,"constructIndex");function O(t){let e=t.parent;for(;e&&!e.object;)e=e.parent;return e}p(O,"constructParent");function V(t,e,n){let o=[],r=[...t.children].reverse();for(;r.length;){n?.throwIfAborted();let s=r.pop();s&&(s.object&&o.push(s),(e||!s.object)&&r.push(...s.children.toReversed()))}return o}p(V,"constructChildren");var kt={function:[["name",["name"]],["body",["body"]],["parameters",["parameters","parameter"]],["returnType",["return_type"]]],call:[["callee",["function","constructor"]],["arguments",["arguments"]]],class:[["name",["name"]],["body",["body"]]],if:[["condition",["condition"]],["then",["consequence"]],["else",["alternative"]]],switch:[["condition",["value"]],["body",["body"]]],loop:[["condition",["condition"]],["body",["body"]]],try:[["body",["body"]],["handler",["handler"]],["finalizer",["finalizer"]]],catch:[["body",["body"]],["parameter",["parameter"]]],binding:[["name",["name"]],["type",["type"]],["value",["value"]]],assignment:[["left",["left"]],["right",["right"]]],property:[["key",["key"]],["value",["value"]]],return:[["value",[]]],throw:[["value",[]]],object:[],array:[]};function Nt(t){return t.node.type==="for_statement"?[["initializer",["initializer"]],["condition",["condition"]],["update",["increment"]],["body",["body"]]]:t.node.type==="for_in_statement"?[["left",["left"]],["iterable",["right"]],["body",["body"]]]:t.node.type==="finally_clause"?[["body",["body"]]]:t.object?kt[t.object]:[]}p(Nt,"partFields");function We(t,e){let n=Nt(t),o=n.find(([r])=>r===e)?.[1];if(!o)throw new S("UNSUPPORTED_PART",`Unsupported part ${e} for ${t.object??"this syntax container"}; supported parts: ${n.map(([r])=>r).join(", ")||"none"}. Use navigate children/descendants for nested constructs.`);if(t.object==="property"&&t.node.type.startsWith("shorthand_property_identifier"))return t.node;if(t.object==="return"||t.object==="throw")return t.node.namedChildren.find(r=>r.type!=="comment");for(let r of o){let s=t.node.childForFieldName(r);if(s)return s}}p(We,"constructPart");var jt=new Set([".js",".mjs",".cjs",".ts",".mts",".cts"]);function Ct(t,e,n){let o=t.filter(s=>s.node.startIndex===e&&s.node.endIndex===n),r=o.find(s=>s.object)??o.at(-1);if(!r)throw new S("EXACT_NODE_REQUIRED","Navigation and parts require an exact syntax node. Use object/enclosing first for a partial match; use a returned part target to navigate its contents.");return r}p(Ct,"exactNode");function $t(t,e,n,o){let r;for(let i of t)i.object!==o.object||i.node.startIndex>e||i.node.endIndex<n||e===n&&i.node.endIndex===n||(!r||i.node.endIndex-i.node.startIndex<r.node.endIndex-r.node.startIndex)&&(r=i);if(!r&&t.some(i=>i.object===o.object&&i.node.startIndex<n&&i.node.endIndex>e))throw new S("AMBIGUOUS_SEED","The seed crosses a construct boundary or spans separate constructs; select narrower input ranges.");let s=1;for(;r&&s<(o.level??1);){for(r=O(r);r&&r.object!==o.object;)r=O(r);s++}return r}p($t,"enclosing");function _t(t,e,n,o){let r;switch(e.relation){case"parent":{let s=O(t);r=s?[s]:[];break}case"ancestors":{r=[];let s=O(t);for(;s;)o?.throwIfAborted(),r.push(s),s=O(s);break}case"children":case"descendants":{r=V(t,e.relation==="descendants",o);break}case"siblings":{if(!t.object)throw new S("EXACT_CONSTRUCT_REQUIRED","siblings requires an exact supported construct, not a part container. Use enclosing first.");let s=V(O(t)??n,!1,o),i=s.indexOf(t),a=e.direction??"all",l=a==="previous"?s[i-1]:s[i+1];r=a==="all"?s.filter(d=>d!==t):l?[l]:[];break}}return r.filter(s=>!e.object||s.object===e.object).sort((s,i)=>s.node.startIndex-i.node.startIndex||i.node.endIndex-s.node.endIndex)}p(_t,"navigate");async function Ke(t,e,n,o){let r=new Map,s=0;for(let i of t.targets){if(o?.throwIfAborted(),!jt.has(Pt.extname(i.source).toLowerCase()))throw new S("UNSUPPORTED_LANGUAGE","Select AST supports JavaScript and TypeScript files, without JSX/TSX.");let a=await P(i.source,n,i.expectedContent.split(`
|
|
15
|
+
`));if(!a)throw new S("UNSUPPORTED_PROVIDER","No syntax provider is available for this source.");try{if(a.rootNode.hasError)throw new S("INVALID_SYNTAX","The syntax provider reports errors; no structural targets were created.");let l=Xe(a.rootNode,o),d=l[0];if(!d)throw Error("Missing syntax root");let u=new L(i.expectedContent);for(let f of i.ranges){o?.throwIfAborted();let g=u.offset(f.start),h=u.offset(f.end),b=e.kind==="object"?$t(l,g,h,e):Ct(l,g,h),w=b&&e.kind==="elementExtent"?Je(b,e.extent,i.expectedContent):void 0,m=b?e.kind==="part"?[We(b,e.part)].filter(y=>y!==void 0).map(y=>({node:y,object:b.object})):e.kind==="navigate"?_t(b,e,d,o):[b]:[];m.length||s++;for(let y of m){let x=w??y.node,A=y.object&&e.kind!=="elementExtent"?{object:y.object,...e.kind==="part"?{part:e.part}:{}}:void 0;T(r,{target:i,range:{start:u.position(x.startIndex),end:u.position(x.endIndex)},text:i.expectedContent.slice(x.startIndex,x.endIndex),origins:[{source:i.source,range:v({start:f.start,end:u.position(h)}),expanded:x.startIndex<g||x.endIndex>h}],...A?{syntax:A}:{}})}}}finally{a.delete?.()}}return{regions:[...r.values()],missingInputs:s}}p(Ke,"selectStructuralRegions");function Qe(t,e,n){n?.throwIfAborted();let o=e.kind==="range"||e.kind==="lines";if(o&&new Set(t.targets.map(i=>i.source)).size>1)throw new S("MULTIPLE_SOURCES","Absolute text bounds require one source.");let r=new Map,s=0;for(let i of t.targets){n?.throwIfAborted();let a=new L(i.expectedContent),l=o?Mt(a,e):void 0,d=!1;for(let u of i.ranges){n?.throwIfAborted();let f=a.offset(u.start),g=a.offset(u.end);a.range(f,g);let h=l?l.from>=f&&l.to<=g?[l]:[]:Dt(a,{from:f,to:g},e,n);h.length?d=!0:s++;for(let b of h){n?.throwIfAborted();let w=a.range(b.from,b.to),m=b.from<f||b.to>g;if(m&&e.kind!=="linesOf"&&!(e.kind==="between"&&e.extent==="lines"))throw new S("OUTSIDE_SCOPE","Text selection exceeds its input scope.");T(r,{target:i,range:w,text:a.content.slice(b.from,b.to),origins:[{source:i.source,range:v(u),expanded:m}]})}}if(l&&!d)throw new S("OUTSIDE_SCOPE","Requested text bounds are outside every input scope.")}return{regions:[...r.values()],missingInputs:s}}p(Qe,"selectTextRegions");function Mt(t,e){if(e.kind==="range"){let r=t.offset({lineNumber:e.startLine,column:e.startColumn}),s=t.offset({lineNumber:e.endLine,column:e.endColumn});return t.range(r,s),{from:r,to:s}}let n=t.lines[e.first-1],o=t.lines[e.last-1];if(!Number.isSafeInteger(e.first)||!Number.isSafeInteger(e.last)||!n||!o||e.last<e.first)throw new S("INVALID_RANGE","Line bounds are outside the retained snapshot or reversed.");return{from:n.start,to:o.end}}p(Mt,"absoluteInterval");function Dt(t,e,n,o){let r=t.content.slice(e.from,e.to);switch(n.kind){case"between":{F(n.start),F(n.end);let s=[],i=0;for(;i<=r.length;){o?.throwIfAborted();let a=r.indexOf(n.start,i);if(a<0)break;let l=r.indexOf(n.end,a+n.start.length);if(l<0)throw new S("UNMATCHED_MARKER","Opening marker has no following closing marker in its input scope.");let d=e.from+a,u=e.from+l+n.end.length;t.boundary(d),t.boundary(d+n.start.length),t.boundary(e.from+l),t.boundary(u),s.push(n.extent==="lines"?t.fullLines(d,u):{from:n.extent==="inside"?d+n.start.length:d,to:n.extent==="inside"?e.from+l:u}),i=l+n.end.length}return s}case"sliceText":{let s=n.to??r.length;return Ye(n.from,s,r.length),[{from:e.from+n.from,to:e.from+s}]}case"trim":{if(!r.trim().length)return[{from:e.to,to:e.to}];let s=n.side==="end"?0:r.length-r.trimStart().length,i=n.side==="start"?r.length:r.trimEnd().length;return[{from:e.from+s,to:e.from+i}]}case"split":{F(n.delimiter);let s=[],i=0;for(;i<=r.length;){o?.throwIfAborted();let a=r.indexOf(n.delimiter,i);if(s.push({from:e.from+i,to:a<0?e.to:e.from+a}),a<0)break;i=a+n.delimiter.length}return s}case"linesOf":return[t.fullLines(e.from,e.to)];case"position":{let s=n.edge==="before"?e.from:e.to;return[{from:s,to:s}]}case"columns":{let s=[],i=t.lineIndex(e.from),a=t.lineIndex(e.to>e.from?e.to-1:e.from);for(let l=i;l<=a;l++){o?.throwIfAborted();let d=t.lines[l];if(!d)throw new S("INVALID_RANGE","Source line bounds are unavailable.");Ye(n.from,n.to,d.length);let u={from:d.start+n.from,to:d.start+n.to};if(u.from<e.from||u.to>e.to)throw new S("OUTSIDE_SCOPE","Requested columns exceed their input scope.");s.push(u)}return s}case"range":case"lines":throw new S("INVALID_RANGE","Absolute bounds must resolve against one source.")}}p(Dt,"transform");function F(t){if(!t.length)throw new S("INVALID_MARKER","Use a non-empty literal marker or delimiter.")}p(F,"nonEmpty");function Ye(t,e,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||t<0||e<t||e>n)throw new S("INVALID_RANGE","Text bounds are outside their region or reversed.")}p(Ye,"orderedBounds");function tt(t,e,n,o){o?.throwIfAborted();let r=new Map;for(let d of[...t.targets,...n.targets]){o?.throwIfAborted();let u=r.get(d.source);if(u&&u.content!==d.expectedContent)throw new S("INCOMPATIBLE_SNAPSHOTS","Geometry inputs use different snapshots of the same source.");u||r.set(d.source,new L(d.expectedContent))}let s=Ze(t,r,o),i=Ze(n,r,o),a=new Map,l=0;for(let[d,u]of s){o?.throwIfAborted();let f=r.get(d);if(!f)throw new S("MISSING_SOURCE","Verified source text is unavailable.");let g=i.get(d)??[],h=et(g.map($),!0,o),b=[];if(e.kind==="merge")b.push(...et(u.map($),e.adjacent??!1,o));else for(let w of u){o?.throwIfAborted();let m=Ut(w,g,h,e.kind,o);m.length||l++,b.push(...m)}for(let w of b){o?.throwIfAborted();let m=w.seeds[0];if(!m)throw new S("MISSING_ORIGIN","Geometry output has no candidate origin.");T(a,{target:m.target,range:f.range(w.from,w.to),text:f.content.slice(w.from,w.to),origins:w.seeds.map(y=>({source:d,range:v(y.range),expanded:w.from<y.from||w.to>y.to}))})}}return{regions:[...a.values()],missingInputs:l}}p(tt,"selectGeometryRegions");function Ze(t,e,n){let o=new Map;for(let r of t.targets){let s=e.get(r.source);if(!s)throw new S("MISSING_SOURCE","Verified source text is unavailable.");let i=o.get(r.source)??[];for(let a of r.ranges){n?.throwIfAborted();let l=s.offset(a.start),d=s.offset(a.end);s.range(l,d),i.push({target:r,range:a,from:l,to:d})}o.set(r.source,i)}return o}p(Ze,"seedsBySource");function $(t){return{from:t.from,to:t.to,seeds:[t]}}p($,"asSpan");function C(t,e){return e.from===e.to?t.from===t.to?e.from===t.from:t.from<=e.from&&e.from<t.to:t.from<=e.from&&e.to<=t.to}p(C,"contains");function Ut(t,e,n,o,r){if(o==="within")return e.some(a=>C(a,t))?[$(t)]:[];if(t.from===t.to)return n.some(l=>C(l,t))===(o==="intersection")?[$(t)]:[];if(o==="intersection"){let a=[];for(let l of n)if(r?.throwIfAborted(),l.from===l.to)C(t,l)&&a.push({from:l.from,to:l.to,seeds:[t]});else{let d=Math.max(t.from,l.from),u=Math.min(t.to,l.to);d<u&&a.push({from:d,to:u,seeds:[t]})}return a}let s=[],i=t.from;for(let a of n)if(r?.throwIfAborted(),!(a.from===a.to||a.to<=i||a.from>=t.to)&&(a.from>i&&s.push({from:i,to:a.from,seeds:[t]}),i=Math.max(i,a.to),i>=t.to))break;return i<t.to&&s.push({from:i,to:t.to,seeds:[t]}),s}p(Ut,"transform");function et(t,e,n){let o=[...t].sort((i,a)=>i.from-a.from||i.to-a.to),r=[];for(let i of o){if(n?.throwIfAborted(),i.from===i.to)continue;let a=r.at(-1);a&&(i.from<a.to||e&&i.from===a.to)?r[r.length-1]={from:a.from,to:Math.max(a.to,i.to),seeds:[...a.seeds,...i.seeds]}:r.push(i)}let s=new Map;for(let i of o){if(n?.throwIfAborted(),i.from!==i.to)continue;let a=r.findIndex(u=>C(u,i)),l=a>=0?r[a]:s.get(i.from),d=l?{...l,seeds:[...l.seeds,...i.seeds]}:i;a>=0?r[a]=d:s.set(i.from,d)}return[...r,...s.values()].sort((i,a)=>i.from-a.from||i.to-a.to)}p(et,"mergeSpans");import{Type as c}from"typebox";var Gt=c.Union([c.Object({kind:c.Literal("range"),startLine:c.Integer({minimum:1}),startColumn:c.Integer({minimum:0}),endLine:c.Integer({minimum:1}),endColumn:c.Integer({minimum:0})},{additionalProperties:!1,description:"Use absolute one-based lines and exclusive UTF-16 columns in one source. Require full containment in an input region."}),c.Object({kind:c.Literal("lines"),first:c.Integer({minimum:1}),last:c.Integer({minimum:1})},{additionalProperties:!1,description:"Use inclusive absolute line numbers in one source. Include existing line endings; require full containment in an input region."}),c.Object({kind:c.Literal("between"),start:c.String({minLength:1}),end:c.String({minLength:1}),extent:c.Union([c.Literal("inside"),c.Literal("around"),c.Literal("lines")])},{additionalProperties:!1,description:"Pair non-empty literal opening markers with the next closing marker per region, without nesting. Resume after each pair; unmatched openings are errors. inside excludes markers, around includes them, lines explicitly expands to complete containing lines."}),c.Object({kind:c.Literal("sliceText"),from:c.Integer({minimum:0}),to:c.Optional(c.Integer({minimum:0}))},{additionalProperties:!1,description:"Slice each region by non-negative relative UTF-16 offsets. The exclusive to defaults to its end. Equal offsets select a zero-width point."}),c.Object({kind:c.Literal("trim"),side:c.Union([c.Literal("start"),c.Literal("end"),c.Literal("both")])},{additionalProperties:!1,description:"Trim Unicode whitespace from the requested edges of each region. A whitespace-only region selects a zero-width point at its end."}),c.Object({kind:c.Literal("split"),delimiter:c.String({minLength:1})},{additionalProperties:!1,description:"Split each region by a non-empty literal delimiter, excluding delimiters and retaining empty segments as zero-width points."}),c.Object({kind:c.Literal("linesOf")},{additionalProperties:!1,description:"Expand each region to complete containing lines, preserving line endings and reporting expansion. An exclusive end at next-line column zero does not include that next line."}),c.Object({kind:c.Literal("position"),edge:c.Union([c.Literal("before"),c.Literal("after")])},{additionalProperties:!1,description:"Select the zero-width start or end of each region. Use a whole-file Read for file edges."}),c.Object({kind:c.Literal("columns"),from:c.Integer({minimum:0}),to:c.Integer({minimum:0})},{additionalProperties:!1,description:"Select an exclusive UTF-16 column interval on each touched line, excluding line endings. Every interval must fit its line and original input region; no clipping."})]);function H(t,e){return c.Object({kind:c.Literal(t),scopes:{...D,description:"Comparison scopes: unchanged results, issued UUIDs or item references, arrays of those strings, or a readable source path. Match sets by source, not array position."}},{additionalProperties:!1,description:e})}p(H,"scopedOperation");var Bt=c.Union([H("within","Retain each candidate whole only when one comparison scope contains it. Never clip or join scopes for containment."),H("intersection","Clip each candidate to the union of comparison scopes in its source. Touching text ranges do not create a point."),H("difference","Subtract comparison scopes from each candidate, retaining separate surviving fragments. Point scopes do not cut text."),c.Object({kind:c.Literal("merge"),adjacent:c.Optional(c.Boolean({description:"Also merge touching nonempty ranges. Default false; never fill a gap or extend text for a point."}))},{additionalProperties:!1,description:"Explicitly merge overlapping ranges by source, retaining every contributing origin. Covered points are absorbed; other points remain separate."})]),z=c.Union([c.Literal("function"),c.Literal("call"),c.Literal("class"),c.Literal("if"),c.Literal("switch"),c.Literal("loop"),c.Literal("try"),c.Literal("catch"),c.Literal("binding"),c.Literal("assignment"),c.Literal("object"),c.Literal("property"),c.Literal("array"),c.Literal("return"),c.Literal("throw")]),ot=c.Union([c.Literal("name"),c.Literal("body"),c.Literal("parameters"),c.Literal("returnType"),c.Literal("type"),c.Literal("callee"),c.Literal("arguments"),c.Literal("condition"),c.Literal("then"),c.Literal("else"),c.Literal("initializer"),c.Literal("update"),c.Literal("iterable"),c.Literal("left"),c.Literal("right"),c.Literal("value"),c.Literal("key"),c.Literal("handler"),c.Literal("finalizer"),c.Literal("parameter")]),nt=c.Optional({...z,description:"Filter results by construct category after navigation. The filter does not change parent/child/sibling relationships."}),Vt=c.Union([c.Object({kind:c.Literal("elementExtent"),extent:c.Union([c.Literal("inside"),c.Literal("around")])},{additionalProperties:!1,description:"Select an exact direct JS/TS call argument or parenthesized function parameter. inside keeps the element; around includes owned comma/whitespace. around includes the following gap; the last element without a trailing comma includes the preceding gap, and an only element includes the whole list interior. Adjacent boundary comments reject around. No destination syntax repair."}),c.Object({kind:c.Literal("object"),object:z,relation:c.Optional(c.Literal("enclosing")),level:c.Optional(c.Integer({minimum:1,description:"Default 1 (nearest). Count only constructs of the requested category."})),extent:c.Optional(c.Literal("around"))},{additionalProperties:!1,description:"Select the requested containing construct. level=1 is nearest and includes an exact seed; higher levels count only that category. Match the entire seed, not its first character."}),c.Object({kind:c.Literal("part"),part:ot},{additionalProperties:!1,description:"Select an exact supported construct's named part, including delimiters belonging to its syntax node. A supported optional part may be absent; unsupported parts are errors with available names. Use an enclosing object first for partial input."}),c.Object({kind:c.Literal("navigate"),relation:c.Union([c.Literal("parent"),c.Literal("ancestors"),c.Literal("children"),c.Literal("descendants")]),object:nt},{additionalProperties:!1,description:"Navigate from an exact named syntax node, including constructs, part targets and the document root. Skip parser-only wrappers in results. Exclude the starting node; ancestors/descendants return results in source order. parent/children never skip recognized constructs to satisfy a filter. Use enclosing first for ranges that cut through a node."}),c.Object({kind:c.Literal("navigate"),relation:c.Literal("siblings"),object:nt,direction:c.Optional(c.Union([c.Literal("previous"),c.Literal("next"),c.Literal("all")],{description:"Default all. previous/next select the immediate sibling before category filtering, not the next matching category."}))},{additionalProperties:!1,description:"Select siblings of an exact supported construct under the same normalized parent. Exclude the input; return source order. A missing neighbor is valid absence."})]),st=c.Object({path:{...D,description:"File path, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Pass the whole result; do not rebuild it from preview text."},operation:c.Union([Vt,Gt,Bt],{description:"Choose a text, syntax or range-set operation. Text operations apply separately to each input region; range/lines require one source. Use UTF-16 bounds that do not split surrogate pairs or CRLF. Range-set operations match sources and snapshots, not array positions."})},{additionalProperties:!1}),rt=c.Object({startLine:c.Integer({minimum:1}),startColumn:c.Integer({minimum:0}),endLine:c.Integer({minimum:1}),endColumn:c.Integer({minimum:0})},{additionalProperties:!1}),_=c.Object({kind:c.Literal("selection"),target:c.String({description:"Stored target for every selected range, including items beyond the preview."}),complete:c.Boolean({description:"Execution completeness inherited from all inputs, independent of preview limits."}),totalItems:c.Integer({minimum:0}),missingInputs:c.Integer({minimum:0}),truncated:c.Boolean(),items:c.Array(c.Object({target:c.String(),source:c.String(),range:rt,syntax:c.Optional(c.Object({object:z,part:c.Optional(ot)},{additionalProperties:!1,description:"Parser-derived normalized construct category and selected part. This describes the target; it is not edit authority."})),origins:c.Array(c.Object({source:c.String(),range:rt,expanded:c.Boolean()},{additionalProperties:!1})),preview:c.String({maxLength:1e3}),textTruncated:c.Boolean()},{additionalProperties:!1}),{maxItems:100})},{additionalProperties:!1}),it=ue(_);function Ht(t){let e=[`${t.totalItems} selection(s)${t.complete?"":" \xB7 incomplete input"}`];t.complete||e.push("Obtain complete source selections before checking absence or editing."),t.missingInputs&&e.push(`${t.missingInputs} input range(s) produced no selection`);for(let n of t.items){let o=n.range;e.push(`${n.target} ${n.source}:${o.startLine}:${o.startColumn}\u2013${o.endLine}:${o.endColumn}${n.syntax?` ${n.syntax.object}${n.syntax.part?`/${n.syntax.part}`:""}`:""}`,n.preview),o.startLine===o.endLine&&o.startColumn===o.endColumn&&e.push("Zero-width position; no text selected."),n.textTruncated&&e.push("\u2026 preview shortened; pass this item reference to consume the full selection")}return t.truncated&&e.push("\u2026 more selections retained; pass the whole result to consume all selections"),e.join(`
|
|
16
|
+
`)}p(Ht,"selectionText");function zt(t){switch(t.kind){case"object":return`enclosing ${t.object} \xB7 level ${t.level??1}`;case"part":return`part ${t.part}`;case"elementExtent":return`list element \xB7 ${t.extent}`;case"navigate":return`${t.relation}${t.relation==="siblings"?` ${t.direction??"all"}`:""}${t.object?` \xB7 ${t.object}`:""}`;case"between":return`between ${JSON.stringify(t.start)} \u2026 ${JSON.stringify(t.end)} \xB7 ${t.extent}`;case"range":return`range ${t.startLine}:${t.startColumn}\u2013${t.endLine}:${t.endColumn}`;case"lines":return`lines ${t.first}\u2013${t.last}`;case"sliceText":return`text slice ${t.from}\u2013${t.to??"end"}`;case"trim":return`trim ${t.side}`;case"split":return`split ${JSON.stringify(t.delimiter)}`;case"linesOf":return"containing lines";case"position":return`position ${t.edge}`;case"columns":return`columns ${t.from}\u2013${t.to}`;case"within":case"intersection":case"difference":return t.kind;case"merge":return t.adjacent?"merge overlaps and adjacent ranges":"merge overlaps"}}p(zt,"operationLabel");function at(t){return t.kind==="within"||t.kind==="intersection"||t.kind==="difference"||t.kind==="merge"}p(at,"isGeometryOperation");async function ct(t,e){let n=me(t);ne(t,[await te({id:"select-code",description:"Derive text and AST boundaries, navigate constructs and combine source-range sets",triggers:[{tool:"select"}]})]),t.registerTool(Ae({name:"select",label:"select",exposure:"direct",namespace:{name:"ide_select",description:"Derive exact source boundaries from existing targets."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Use select to derive text ranges or positions, navigate JavaScript/TypeScript constructs and their parts (without JSX/TSX), and combine source-local selections. Pass the returned result or an item reference to Read, Search or an edit tool. Select does not change files.",promptSnippet:"Derive text and AST boundaries, navigate constructs and combine source-range sets",promptGuidelines:["Use Search for predicate matches and existing captures; use Select when a target needs new text or structural boundaries.","Compare the enclosing owner of each inner match with the original function when checking a condition in that function's own body."],parameters:st,outputSchema:it,renderCall(o,r,s){return le(s.lastComponent,{tool:"select",primary:{text:zt(o.operation),color:"accent"},qualifiers:[{text:typeof o.path=="string"&&!o.path.startsWith("RESULT#")?o.path:"in result scope"}],expanded:s.expanded},r)},renderResult(o,r,s){let i=o.details;return typeof i?.summary=="string"&&Array.isArray(i.rows)?new ae(i,s,r.expanded):new Ft(o.content.flatMap(a=>a.type==="text"?[a.text]:[]).join(`
|
|
17
|
+
`),0,0)},async execute(o,r,s,i,a){try{s?.throwIfAborted();let l=p(async m=>{if(typeof m=="string"&&!m.startsWith("RESULT#")){let y=await e.read({path:m},{cwd:a.cwd,...s!==void 0&&{signal:s}},"script");if(y.isError)throw new Error("Select could not read this source.");m=y.script}return n.resolve(m,a.cwd)},"resolve"),d=await l(r.path),u=r.operation,f=at(u)&&"scopes"in u?await l(u.scopes):{targets:[],complete:!0},g={targets:[...d.targets,...f.targets],complete:d.complete&&f.complete};await n.verify(g,s);let h=at(u)?tt(d,u,f,s):u.kind==="object"||u.kind==="part"||u.kind==="navigate"||u.kind==="elementExtent"?await Ke(d,u,a.cwd,s):Qe(d,u,s);await n.verify(g,s),s?.throwIfAborted();let b=h.regions.map(m=>({...m.target,ranges:[m.range]})),w={kind:"selection",target:n.register(b,a.cwd,g.complete),complete:g.complete,totalItems:h.regions.length,missingInputs:h.missingInputs,truncated:h.regions.length>100,items:h.regions.slice(0,100).map(m=>{let y=m.text.slice(0,1e3).replace(/[\uD800-\uDBFF]$/u,"");return{target:n.register([{...m.target,ranges:[m.range]}],a.cwd,g.complete),source:m.target.source,range:v(m.range),origins:m.origins,...m.syntax?{syntax:m.syntax}:{},preview:y,textTruncated:y.length<m.text.length}})};return M({content:[{type:"text",text:Ht(w)}],details:qe(h.regions,g.complete,h.missingInputs,a.cwd)},_,{status:"success",data:w,errors:[]})}catch(l){if(s?.aborted)throw l;return M({content:[{type:"text",text:`${l instanceof Error?l.message:String(l)}
|
|
18
|
+
Resolve the reported error before retrying. Do not treat a failed selection as an empty result.`}],details:void 0},_,{status:"error",errors:[pe(l,"SELECT_FAILED")]})}}},new Re))}p(ct,"registerSelect");var qt=de({kind:"code-view",label:"AST"});async function lt(t){let e=new Oe,n=je(e),o={protocol:oe,apiVersion:se,id:"ast",async setup(s){s.addResolver({resolver:ke(void 0,async(l,d)=>{let u=await s.read({path:l},d,"script");if(u.isError===!0)throw new Error(u.details.failure?.message??"Could not acquire an owned text snapshot for the AST outline.");if(u.script?.kind!=="text")throw new Error("AST outlines require an owned text snapshot.");return{source:u.script.source,lines:u.script.lines.map(f=>f.content)}}),renderResult:qt}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:Q()}),s.addView({view:"ast",presenter:n});let i=Ne();s.addOutputReducer(B);let a=Ce();s.addHandler({stage:"post-read",async handler(l){let d=await i(l);return d.kind==="return"||d.transform!==void 0?d:a(d.context)}}),s.describe({path:"ast:<path> \u2014 compact declaration outline for a code file.",views:"ast \u2014 scope boundaries alongside source text."}),await ct(t,s)}},r={protocol:fe,apiVersion:ge,id:"ast",setup(s){s.addAnchorResolver({resolver:Me(e),kind:he,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([ie(t,o),re(t,Ee),ye(t,r),we(t,{protocol:be,apiVersion:Se,id:"ast-search",setup(s){s.addResolver({resolver:He(s.registerSelection)}),s.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use the displayed capture NAME reference as a Search/Select/edit source. Single captures contain one node; multi captures retain provider nodes, including punctuation. Strict result scopes return only wholly contained matches. These edits do not update imports or references.")}})])}p(lt,"registerAst");export{lt as default};
|
package/dist/entry-34.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as P}from"./chunk-MGCHOGQD.js";import{a as F,b as R}from"./chunk-T6LX2RX5.js";import{a as j}from"./chunk-QDLTO5PH.js";import{a as h,b as v}from"./chunk-QIK2E64R.js";import{b as C,c as w,g as k,i as x,j as g,l as u,m as E}from"./chunk-M5MJP7Z2.js";import{a as b}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as f}from"./chunk-EI7MMDWY.js";import{copyFile as $,mkdtemp as A,rm as M}from"node:fs/promises";import y from"node:path";var D=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],d=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],D,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(o,t,r,i,n,m,a,l,s,c){return{id:o,name:o,kind:"formatter",languages:t,executables:r,configFiles:i,documentation:a,...l&&{dependencies:l},...s&&{configSections:s},formatter:{extensions:n,...c&&{fileNames:c},run:{command:m},output:"in-place"}}}f(e,"recipe");var p=class o{constructor(t,r,i=new Map){this.formatters=t;this.availableBuiltIns=r;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,r={}){let i=await k(t,"formatters",s=>E(s).formatters,r),n=r.environment??process.env,m=await Promise.all(i.entries.filter(s=>s.layer==="built-in").map(async s=>({id:s.id,available:await g(s.config.run,t,n)}))),a=await b(t,d),l=[...i.entries].sort((s,c)=>s.layer==="built-in"&&c.layer==="built-in"?(a.get(c.id)?.score??0)-(a.get(s.id)?.score??0):0);return new o(l,new Set(m.filter(s=>s.available&&(!r.requireBuiltInEvidence||(a.get(s.id)?.score??0)>0)).map(s=>s.id)),a)}static fromConfig(t){return new o(Object.entries(t.formatters).map(([r,i])=>({id:r,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,r){return this.resolveEntry(t,r)?.config}resolveEntry(t,r){return x(this.formatters,this.availableBuiltIns,this.evidence,t,r)}get entries(){return this.formatters}};var T={protocol:F,apiVersion:1,id:"formatter",setup(o){for(let t of d)o.addToolRecipe(t);o.addSetupCheck({id:"effective-config",inspect:_}),o.addCheck({id:"config",title:"Formatter",async run(t){try{let r=await p.fromDirectory(t.cwd,{environment:t.env}),i=q(r,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:n,source:m})=>{let a=`${n.id} [${n.layer}] command ${JSON.stringify(n.config.run.command)}`,l=await A(y.join(y.dirname(m),".pi-agent-ide-doctor-")),s=y.join(l,y.basename(m));try{return await $(m,s),(await u(n.config,{projectRoot:t.cwd,filePath:s,env:t.env})).ok?{status:"pass",message:`${a}: probe passed`,detail:n.sourcePath}:{status:"fail",message:`${a}: probe failed`,detail:n.sourcePath}}catch(c){return{status:"fail",message:`${a}: ${c instanceof Error?c.message:String(c)}`,detail:n.sourcePath}}finally{await M(l,{recursive:!0,force:!0})}}))}catch(r){return[{status:"fail",message:r instanceof Error?r.message:String(r)}]}}})}};async function _(o){try{let t=await p.fromDirectory(o.cwd,{environment:o.env}),r=[],i=new Map;for(let[n,m]of o.detectedLanguages){let a=m.map(l=>t.resolveEntry(l,o.cwd)).find(l=>l!==void 0);a!==void 0&&(r.push({kind:"formatter",languageId:n,toolId:a.id}),await g(a.config.run,o.cwd,o.env)||i.set(a.id,{id:`formatter-${a.id}-unavailable`,message:`Configured formatter ${a.id} cannot run ${JSON.stringify(a.config.run.command)}`}))}return{selections:r,actions:[...i.values()]}}catch(t){return{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f(_,"inspectFormatterSetup");function q(o,t,r){let i=new Map;for(let n of t){let m=o.resolveEntry(n,r);m!==void 0&&!i.has(m.id)&&i.set(m.id,{entry:m,source:n})}return[...i.values()]}f(q,"applicableFormatters");import L from"node:path";var S=new Map;function O(){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async o=>(await I(o.cwd),!0),"detect"),async format({filePath:o},t){let r=await w(t.cwd,o,"formatters",d);if(r===void 0)return{ok:!0,edits:0,formatter:null};let i=r!==L.resolve(t.cwd),m=(await I(r,i)).resolve(o,r);if(m===void 0)return{ok:!0,edits:0,formatter:null};let a=C(m.run.command);try{let l=await u(m,{projectRoot:r,filePath:o});return{ok:l.ok,edits:l.changed?1:0,formatter:a}}catch{return{ok:!1,edits:0,formatter:a}}}}}f(O,"createFormatter");async function I(o,t=!1){let r=JSON.stringify([o,t]),i=S.get(r);return i===void 0&&(i=p.fromDirectory(o,{includeGlobal:!t,requireBuiltInEvidence:!0}),S.set(r,i)),i}f(I,"loadRegistry");async function N(o){let t={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(i,n){return O().format(i,n)}},r={protocol:h,apiVersion:4,id:"formatter",setup(i){i.addTool(t)}};await Promise.all([j(o,r),P(o,T)])}f(N,"registerFormatter");export{N as default};
|
|
1
|
+
import{a,b,c}from"./chunk-DEP55R35.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createChangeGroups,c as replaceHeadRangeInIndex,b as reverseChangeGroup};
|
package/dist/entry-35.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a,b}from"./chunk-LAJQSHEI.js";import"./chunk-DEP55R35.js";import"./chunk-R2U5WXYR.js";import"./chunk-T7I2VX3J.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-M4TVRCMZ.js";import"./chunk-TGC2ZACO.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-ZPT5D4VP.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as default,b as registerGitChangesWithExecutor};
|
package/dist/entry-36.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{a as _}from"./chunk-MGCHOGQD.js";import{a as T,b as N}from"./chunk-T6LX2RX5.js";import{a as O}from"./chunk-K5G4FDXD.js";import{a as P}from"./chunk-QDLTO5PH.js";import{a as j,b as L}from"./chunk-QIK2E64R.js";import{b as E,c as S,g as D,i as $,j as C,k as I,n as A}from"./chunk-M5MJP7Z2.js";import{a as R}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as g}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import le from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,i,o,f,s,l,r,d,b=[0,1],u,h){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:l,...d&&{dependencies:d},linter:{extensions:o,...h&&{fileNames:h},check:{command:f,successExitCodes:b},diagnostics:{format:s,...r&&{pattern:r},...u!==void 0&&{columnBase:u}}}}}a(c,"recipe");import w from"node:path";import ee from"node:os";import{fileURLToPath as te}from"node:url";function F(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return B(t);case"eslint-json":return G(t);case"sarif":return H(t);case"checkstyle":return U(t);case"gcc":case"clang":return W(t);case"regex":return Z(t,g(e.pattern),e.columnBase??1)}}a(F,"parseDiagnostics");function B(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(y):[]}a(B,"parsePiJson");function G(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>y(i).map(o=>({...o,...n.filePath&&{file:n.filePath}}))):[])}a(G,"parseEslintJson");function H(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let o=i.locations?.[0]?.physicalLocation,f=o?.region??{},s=i.message;return y({file:o?.artifactLocation?.uri,line:f.startLine,column:f.startColumn,message:s?.text,code:i.ruleId,severity:Q(i.level)})}))}a(H,"parseSarif");function U(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=z(g(n[1])).name;for(let o of g(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let f=z(g(o[1]));e.push(...y({file:i,line:Number(f.line),column:Number(f.column??1),message:f.message,code:f.source,severity:f.severity}))}}return e}a(U,"parseCheckstyle");function z(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[g(e[1]),Y(g(e[2]))]))}a(z,"xmlAttributes");function W(t){return X(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}a(W,"parseCompilerLines");function Z(t,e,n){return[...t.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:y({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}a(Z,"parseRegexLines");function X(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:y(i)})}a(X,"parseMatchingLines");function y(t){if(typeof t!="object"||t===null)return[];let e=t,n=M(e.line??e.startLine),i=M(e.column??e.startColumn,1),o=typeof e.message=="string"?e.message:void 0;return n===void 0||o===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:q(e.code??e.ruleId,"lint"),message:o,line:n,column:i??1,severity:K(e.severity)}]}a(y,"normalizeDiagnostic");function M(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}a(M,"numberValue");function q(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}a(q,"stringValue");function K(t){if(t===2)return"error";if(t===1)return"warning";let e=q(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}a(K,"severityValue");function Q(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}a(Q,"sarifSeverity");function Y(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}a(Y,"decodeXml");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{a(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await D(e,"linters",r=>A(r).linters,n),o=n.environment??process.env,f=await Promise.all(i.entries.filter(r=>r.layer==="built-in").map(async r=>({id:r.id,available:await C(r.config.check,e,o)}))),s=await R(e,p),l=[...i.entries].sort((r,d)=>r.layer==="built-in"&&d.layer==="built-in"?(s.get(d.id)?.score??0)-(s.get(r.id)?.score??0):0);return new t(l,new Set(f.filter(r=>r.available&&(!n.requireBuiltInEvidence||(s.get(r.id)?.score??0)>0)).map(r=>r.id)),s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return $(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function k(t,e){let n;try{let l=w.basename(t.check.command[0]??"").toLocaleLowerCase(),r=l==="ruff"||l==="ruff.exe",d=e.env??process.env;n=await I(t.check,{...e,...r?{env:{...d,RUFF_CACHE_DIR:d.RUFF_CACHE_DIR??w.join(ee.tmpdir(),"pi-agent-ide","ruff-cache")}}:{}})}catch(l){return{ok:!1,diagnostics:[],failure:`command could not start: ${l instanceof Error?l.message:String(l)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(l=>l.trim().length>0).join(`
|
|
4
|
-
`):n.stdout.trim().length>0?n.stdout:n.stderr,o;try{o=F(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let f=n.ok&&(n.exitCode===0||o.length>0),s=t.check.cwd==="file"?w.dirname(e.filePath):e.projectRoot;return o=o.filter(l=>{if(l.file===void 0)return!0;let r=l.file.startsWith("file:")?te(l.file):l.file;return O(w.resolve(s,r),e.filePath)}).map(({file:l,...r})=>r),{ok:f,diagnostics:o,...!f&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}a(k,"runConfiguredLinter");function J(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let o=t.resolve(e,i.cwd);if(o===void 0)return{ok:!0,diagnostics:[]};let f=n===!0&&o.fix!==void 0?o.fix:o.check,s=await k({...o,check:f},{projectRoot:i.cwd,filePath:e});return{ok:s.ok,diagnostics:s.diagnostics}}}}a(J,"createCommandLinter");import{copyFile as ne,mkdtemp as ie,rm as re}from"node:fs/promises";import x from"node:path";var V={protocol:T,apiVersion:1,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:oe}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=se(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:o,source:f})=>{let s=`${o.id} [${o.layer}] command ${JSON.stringify(o.config.check.command)}`,l=await ie(x.join(x.dirname(f),".pi-agent-ide-doctor-")),r=x.join(l,x.basename(f));try{await ne(f,r);let d=await k(o.config,{projectRoot:e.cwd,filePath:r,env:e.env});return d.ok?{status:"pass",message:`${s}: probe passed`,detail:o.sourcePath}:{status:"fail",message:`${s}: probe failed`,detail:d.failure??o.sourcePath}}catch(d){return{status:"fail",message:`${s}: ${d instanceof Error?d.message:String(d)}`,detail:o.sourcePath}}finally{await re(l,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function oe(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[o,f]of t.detectedLanguages){let s=f.map(l=>e.resolveEntry(l,t.cwd)).find(l=>l!==void 0);s!==void 0&&(n.push({kind:"linter",languageId:o,toolId:s.id}),await C(s.config.check,t.cwd,t.env)||i.set(s.id,{id:`linter-${s.id}-unavailable`,message:`Configured linter ${s.id} cannot run ${JSON.stringify(s.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(oe,"inspectLinterSetup");function se(t,e,n){let i=new Map;for(let o of e){let f=t.resolveEntry(o,n);f!==void 0&&!i.has(f.id)&&i.set(f.id,{entry:f,source:o})}return[...i.values()]}a(se,"applicableLinters");async function ae(t){let e=new Map,n=a((s,l=!1)=>{let r=JSON.stringify([s,l]),d=e.get(r);return d===void 0&&(d=ce(s,l),e.set(r,d)),d},"registryFor"),i=a(async(s,l)=>{let r=await S(l,s,"linters",p);return r===void 0?void 0:{projectRoot:r,external:r!==le.resolve(l)}},"resolveProject"),o={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:a(async s=>(await n(s.cwd),!0),"detect"),async lint(s,l){let r=await i(s.filePath,l.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let d=await n(r.projectRoot,r.external);return J(d).lint(s,{cwd:r.projectRoot})}},f={protocol:j,apiVersion:4,id:"lint",setup(s){s.addTool(o),s.addDiagnosticSource({id:"lint",async diagnose(l,r){let d=await i(l,r.cwd);if(d===void 0)return{status:"unavailable",diagnostics:[],reason:"No local linter project found for this file"};let b=await n(d.projectRoot,d.external);r.signal.throwIfAborted();let u=b.resolve(l,d.projectRoot);if(!u)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let h=E(u.check.command),v=await k(u,{projectRoot:d.projectRoot,filePath:l,signal:r.signal});return!v.ok&&v.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:v.failure??"Lint check failed",source:h}:{status:"ready",diagnostics:v.diagnostics,source:h}}})}};await Promise.all([P(t,f),_(t,V)])}a(ae,"registerLint");async function ce(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:!0})}a(ce,"loadRegistry");export{ae as default};
|
|
1
|
+
import{a,b,c,d}from"./chunk-6EDOLYOV.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as FORMATTER_RECIPES,b as FormatterCommandRegistry,c as default,d as registerFormatterWithOwner};
|
package/dist/entry-37.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import{a as $e}from"./chunk-MGCHOGQD.js";import{a as Ae,b as Te}from"./chunk-T6LX2RX5.js";import{a as He}from"./chunk-2ZMMRINH.js";import{a as Fe,b as We,d as ze}from"./chunk-HZ5BNF3A.js";import"./chunk-NNCZYO4Q.js";import{d as Ve}from"./chunk-IICJXZBU.js";import{a as qe}from"./chunk-BU7IZLKB.js";import{a as Oe,b as Ne}from"./chunk-S5PL5DFQ.js";import{a as Je,b as Ke}from"./chunk-STBJO3Z3.js";import{e as Xe}from"./chunk-OB46OPMZ.js";import{a as Be}from"./chunk-ZTYWHL2F.js";import{a as Ue,b as Ge}from"./chunk-7UGNGK7Y.js";import"./chunk-PS2B6THP.js";import{I as oe}from"./chunk-6U5OU77O.js";import{a as T,b as $,c as W,d as E,j as Re,k as Pe,l as Ce}from"./chunk-KVHDMIZS.js";import{m as Se}from"./chunk-ZPT5D4VP.js";import{a as xe}from"./chunk-QDLTO5PH.js";import{a as _e,b as ke}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import{b as Ee,c as Ie,g as je,j as ee,o as Me}from"./chunk-M5MJP7Z2.js";import{a as De}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as L}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import Lr from"node:path";var z=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},h("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),h("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},h("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),h("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),h("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),h("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),h("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),h("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),h("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),h("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),h("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),h("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),h("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),h("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),h("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),h("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),h("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),h("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),h("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),h("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),h("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),h("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),h("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),h("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),h("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),h("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),h("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),h("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),h("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),h("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),h("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),h("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),h("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function h(r,e,t,n,s,o,i,d,a,l){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:i,...d&&{dependencies:d},lsp:{command:o,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...l&&{settings:l}}}}c(h,"recipe");import Ot from"node:path";import Nt from"cross-spawn";import{createMessageConnection as qt,CancellationTokenSource as Vt,StreamMessageReader as Ft}from"vscode-jsonrpc/node";import{URI as Qe}from"vscode-uri";import{watch as Mt}from"node:fs";import{readdir as At,stat as Tt}from"node:fs/promises";import O from"node:path";import{URI as ie}from"vscode-uri";var te=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let o=s.globPattern,i=typeof o=="string"?this.root:ie.parse(typeof o.baseUri=="string"?o.baseUri:o.baseUri.uri).fsPath,d=typeof o=="string"?o:o.pattern,a=c(p=>O.matchesGlob(O.isAbsolute(d)?O.join(i,p):p,d),"matches"),l=new Set((await At(i,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let u=Mt(i,{recursive:!0},(p,f)=>{!f||!a(f)||Tt(O.join(i,f)).then(()=>{if(!this.registrations.get(e)?.includes(u))return;let y=l.has(f)?2:1;l.add(f),(s.kind??7)&(y===1?1:2)&&this.changed({uri:ie.file(O.join(i,f)).toString(),type:y})},y=>{if(this.registrations.get(e)?.includes(u)){if(y.code!=="ENOENT"){this.failed(y);return}l.delete(f)&&(s.kind??7)&4&&this.changed({uri:ie.file(O.join(i,f)).toString(),type:3})}})});u.on("error",this.failed),n.push(u)}}catch(s){for(let o of n)o.close();throw s}this.unregister(e),this.registrations.set(e,n)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as $t}from"vscode-jsonrpc/node";var re=class extends $t{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var I=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return Ee(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasWorkspaceSymbolCapability(){let e=this._serverCapabilities?.workspaceSymbolProvider;return e===!0||typeof e=="object"&&e!==null}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=L(this._command[0]),t=Qe.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:Ot.basename(t)||t}],s=Nt(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:Me({command:this._command,env:this._env},t,process.env)});this._process=s;let o=Wt(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,l)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await o;let i=qt(new Ft(L(s.stdout)),new re(L(s.stdin),a=>{this._connection!==i||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),i.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=i,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new te(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let l of a.registrations)if(l.method!=="workspace/didChangeConfiguration"){if(l.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${l.method}`);await this._fileWatchers?.register(l.id,l.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let l of a.unregisterations)this._fileWatchers?.unregister(l.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(l=>{let u=this._settings??null;for(let p of l.section?.split(".").filter(Boolean)??[])u=typeof u=="object"&&u!==null?u[p]??null:null;return u})),this._connection.listen(),this._connection.onNotification((a,...l)=>{if(a==="textDocument/publishDiagnostics"){let u=l[0];u&&typeof u.uri=="string"&&Array.isArray(u.diagnostics)&&this._documentVersions.has(u.uri)&&(u.version===void 0||u.version===this.documentVersion(u.uri))&&this._diagnosticPublications.set(u.uri,{diagnostics:u.diagnostics,...typeof u.version=="number"&&{version:u.version}})}for(let u of this._handlers.get(a)??[])u(l[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let d=await Ye(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`).catch(a=>{let l=this._stderr.trim();throw l?new Error(`[lsp] ${this.serverId}: ${l}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:d.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);this._initialized=!0,this._serverCapabilities=d.capabilities,this._diagnosticMode=d.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return L(this._connection).sendRequest(e,t);let s=new Vt,o;try{let i=L(this._connection).sendRequest(e,t,s.token);return await Promise.race([i,new Promise((d,a)=>{o=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",o,{once:!0})})])}finally{o&&n.removeEventListener("abort",o),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Qe.file(e).toString()}openDocument(e,t,n,s=1){let o=this._documentVersions.get(e);if(o!==void 0){this.changeDocument(e,t,Math.max(s,o+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let o=this._documentVersions.get(e);o===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,o+1);let i=this._serverCapabilities?.textDocumentSync,d=typeof i=="object"&&i!==null?i.save:void 0;s&&d&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof d=="object"&&d.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),o=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:o},contentChanges:[{text:t}]}),this._documentVersions.set(e,o),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await Ye(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null}}dispose(){this.shutdown()}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function Wt(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",o)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),o=c(i=>{n(),t(i)},"onError");r.once("spawn",s),r.once("error",o)})}c(Wt,"waitForSpawn");function Ye(r,e,t){return new Promise((n,s)=>{let o=setTimeout(()=>{s(new Error(t))},e);r.then(i=>{clearTimeout(o),n(i)}).catch(i=>{clearTimeout(o),s(i instanceof Error?i:new Error(String(i)))})})}c(Ye,"withTimeout");import{readFile as et}from"node:fs/promises";import{URI as tt}from"vscode-uri";var H={Error:1,Warning:2,Information:3,Hint:4};var Ze={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let o=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!ae(o)||o.success!==!0||!Array.isArray(o.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return o.body.map(zt)}))).flat()}};function ne(r){return r.supportsCommand(Ze.command)?Ze:void 0}c(ne,"completedDiagnosticAdapter");function zt(r){if(!ae(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!ae(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(zt,"convertTypeScriptDiagnostic");function ae(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(ae,"isRecord");async function U(r,e,t,n={}){let s=new AbortController,o=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),i=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await Ht(r,e,t,n.content,o)}finally{clearTimeout(i)}}c(U,"requestDiagnostics");async function Ht(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let l=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),rt(l.items,!1,!0)}catch(l){if(!Ut(l))throw l;r.setDiagnosticMode("push")}}let o=ne(r);if(o){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await et(tt.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),l=await o.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}s.throwIfAborted();let i=r.documentVersion(e)!==void 0,d=i?void 0:n??await et(tt.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,l)=>{let u=r.documentVersion(e)??1,p=c(g=>{let v=g;v.uri!==e||!Array.isArray(v.diagnostics)||v.version!==void 0&&v.version!==u||r.documentVersion(e)===u&&(m(),a(rt(v.diagnostics,v.version===void 0)))},"receive"),f=r.onNotification("textDocument/publishDiagnostics",p),y=c(()=>{m(),l(s.reason)},"onAbort");function m(){f(),s.removeEventListener("abort",y)}c(m,"cleanup"),s.addEventListener("abort",y,{once:!0});try{i||r.syncDocument(e,d??"",t??"plaintext");let g=r.diagnosticPublication(e);g&&p({uri:e,...g})}catch(g){m(),l(g)}})}finally{r.endDiagnosticRequest(e)}}c(Ht,"requestCurrentDiagnostics");function ce(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===H.Warning?"warning":r.severity===H.Information?"info":r.severity===H.Hint?"hint":"error"}}c(ce,"toDiagnostic");function rt(r,e,t=!1){let n=r.map(ce);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(rt,"classify");function Ut(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(Ut,"isMethodNotFound");var Gt={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function x(r){return Gt[r]??`SymbolKind(${r})`}c(x,"symbolKindName");async function G(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(G,"requestDocumentSymbols");async function le(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(le,"requestWorkspaceSymbols");async function de(r,e,t,n){return await r.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:n})}c(de,"requestRename");import{readFile as st,stat as ot}from"node:fs/promises";import k from"node:path";import{URI as Xt}from"vscode-uri";import{readdir as Bt,stat as Jt}from"node:fs/promises";import J from"node:path";import{URI as ue}from"vscode-uri";async function B(r,e){if(!r.supportsCommand("typescript.tsserverRequest"))return;if((await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:e,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for a workspace query.")}c(B,"prepareProjectQuery");function nt(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,o])=>[s,t(o)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(nt,"resolveInitializationOptions");var j=class r{constructor(e){this._registry=e}static{c(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),o=n==="symbols"?s[0]:s.find(p=>p.config.capabilities.includes(n));if(!o)return null;let i=ue.file(t).toString(),d=`${o.serverId}:${i}`,a=this._clientStarts.get(d);if(a)return a;let l=this._clients.get(d);if(l?.ready)return l;let u=this._startClient(d,i,o,l);this._clientStarts.set(d,u);try{return await u}finally{this._clientStarts.get(d)===u&&this._clientStarts.delete(d)}}async _startClient(e,t,n,s){let o=s??new I({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:nt(n.config.initializationOptions,ue.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await o.start()}catch(i){throw await o.shutdown().catch(()=>{}),i}if(this._disposed)throw await o.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,o),this._subscribeToPushDiagnostics(e,o),o}async getWorkspaceClients(e,t="symbols",n=e){let s=new Set,o=new Set(this._registry.knownExtensions),i=new Set([".git",".cache","node_modules","dist","build"]),d=c(async l=>{if(o.size===0)return;let u;try{u=await Bt(l,{withFileTypes:!0})}catch{return}for(let p of u){if(o.size===0)return;if(p.isDirectory()){i.has(p.name)||await d(J.join(l,p.name));continue}if(!p.isFile())continue;let f=J.extname(p.name).toLowerCase();if(!o.has(f))continue;let y=J.join(l,p.name),m=await this.openFile(y,e,t).catch(()=>null);m&&(o.delete(f),m.client.hasWorkspaceSymbolCapability&&(await B(m.client,y),s.add(m.client)))}},"visit"),a=J.resolve(e,n);if((await Jt(a)).isFile()){let l=await this.openFile(a,e,t);return l===null||!l.client.hasWorkspaceSymbolCapability?[]:(await B(l.client,a),[l.client])}return await d(a),[...s]}async prepareWorkspaceSymbols(e,t=e){return this.getWorkspaceClients(e,"symbols",t)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=J.resolve(t,e),o=await this.getOrStart(s,t,n);if(!o)return null;let i=o.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:l}=await import("node:fs/promises"),u=await l(s,"utf8");o.openDocument(i,u,a),this._openDocs.add(i)}catch{}return{client:o,uri:i,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let o=Kt(s);if(!o||t.hasActiveDiagnosticRequest(o.uri))return;let i=t.documentVersion(o.uri);if(o.version!==void 0&&i!==void 0&&o.version<i)return;let d=`${e}:${o.uri}`,a=o.diagnostics.map(ce),l=JSON.stringify([o.version,i,a]);if(this._pushFingerprints.get(d)===l)return;this._pushFingerprints.set(d,l);let u={cwd:ue.parse(t.rootUri).fsPath,serverId:t.serverId,uri:o.uri,diagnostics:a,...o.version!==void 0&&{version:o.version}};for(let p of this._pushHandlers)p(u)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function Kt(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c(Kt,"parsePushNotification");async function K(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(K,"requestReferences");async function pe(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[o,i]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:o??[],outgoing:i??[]}}c(pe,"requestCallHierarchy");function it(r,e,t){let n=k.relative(k.resolve(e,t.path??"."),r);if(n===".."||n.startsWith(`..${k.sep}`)||k.isAbsolute(n))return!1;let s=k.relative(e,r).split(k.sep).join("/"),o=c(i=>i.split(",").some(d=>{let a=d.trim();return a.length>0&&k.matchesGlob(a.includes("/")?s:k.basename(r),a)}),"matches");return(t.include===void 0||o(t.include))&&(t.exclude===void 0||!o(t.exclude))}c(it,"withinPath");function Qt(r){let e=Xt.parse(r);if(e.scheme!=="file")throw new Error("LSP Search supports only file locations.");return k.resolve(e.fsPath)}c(Qt,"sourceOf");function Yt(r,e){return r.start.line===e.start.line&&r.start.character===e.start.character&&r.end.line===e.end.line&&r.end.character===e.end.character}c(Yt,"sameRange");function at(r,e,t){return r.flatMap(n=>[...n.name===e&&n.range!==void 0&&Yt(n.range,t)&&n.selectionRange!==void 0?[n.selectionRange]:[],...at(n.children??[],e,t)])}c(at,"declarationNames");async function ge(r,e,t,n,s={},o=j.getInstance()){n?.throwIfAborted();let i=s.resultScope;if(i!==void 0&&(await oe(i,n),i.targets.length===0))return{hits:[],complete:i.complete};let d=i?.targets.map(m=>m.source)??[s.path??e],a=new Set((await Promise.all(d.map(m=>o.prepareWorkspaceSymbols(e,m)))).flat());if(a.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let l=new Map,u=c(async m=>{n?.throwIfAborted();let g=Qt(m.uri),v=l.get(g);if(v===void 0){let b=await ot(g),w=await st(g,{encoding:"utf8",signal:n}),F=await ot(g);if(b.mtimeMs!==F.mtimeMs||b.size!==F.size)throw new Error("LSP source changed during search.");v=Se(g,w),l.set(g,v)}let{start:R,end:P}=m.range,V=[R,P];for(let b of V){let w=v.lines[b.line];if(!Number.isInteger(b.line)||!Number.isInteger(b.character)||w===void 0||b.character<0||b.character>w.content.length)throw new Error("LSP range does not match its source snapshot.")}let S=L(v.lines[R.line]),M=c(b=>v.lines.slice(0,b).reduce((w,F)=>w+F.content.length+F.lineEnding.length,0),"offset"),Z=M(R.line)+R.character,A=M(P.line)+P.character;if(A<Z)throw new Error("LSP returned a reversed source range.");return{source:g,lineNumber:R.line+1,endLineNumber:P.line+1,startColumn:R.character,endColumn:P.character,matchedText:v.content.slice(Z,A),lineText:S.content}},"toMatch"),p=c(m=>it(m.source,e,s)&&(i===void 0||Ke(i,m)),"included"),f=[],y=new Set;for(let m of a){n?.throwIfAborted();let g=await le(m,r,Number.MAX_SAFE_INTEGER);for(let v of g){n?.throwIfAborted();let R=await u(v.location),P=await o.openFile(R.source,e,"symbols");if(P===null)throw new Error("LSP references are unavailable for a discovered declaration.");let V=v.location;if(R.matchedText!==v.name){let b=await G(P.client,P.uri),w=at(b,v.name,v.location.range);if(w.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");V={uri:P.uri,range:L(w[0])}}let S=await u(V),M={id:JSON.stringify([m.serverId,S.source,v.location.range]),name:v.name,kind:String(v.kind),source:S.source,range:{startLine:S.lineNumber,startColumn:S.startColumn,endLine:S.endLineNumber??S.lineNumber,endColumn:S.endColumn}},Z=await K(P.client,P.uri,V.range.start);n?.throwIfAborted();let A=[{...S,role:"definition",symbol:M}];for(let b of Z){let w=await u(b);w.source===S.source&&w.lineNumber===S.lineNumber&&w.startColumn===S.startColumn&&w.endLineNumber===S.endLineNumber&&w.endColumn===S.endColumn||A.push({...w,role:"reference",symbol:M})}if(!(s.navigation==="references"&&!A.some(p)))for(let b of A){if(s.navigation!=="references"&&!p(b)||s.navigation==="references"&&!it(b.source,e,{}))continue;let w=JSON.stringify([M.id,b.source,b.lineNumber,b.startColumn,b.endLineNumber,b.endColumn]);y.has(w)||(y.add(w),f.push(b))}}}n?.throwIfAborted();for(let[m,g]of l)if(await st(m,{encoding:"utf8",signal:n})!==g.content)throw new Error("LSP source changed during search.");return i!==void 0&&await oe(i,n),f.sort((m,g)=>m.source.localeCompare(g.source)||m.lineNumber-g.lineNumber||m.startColumn-g.startColumn||m.endColumn-g.endColumn||m.symbol.id.localeCompare(g.symbol.id)),{hits:f.slice(0,t),complete:(i?.complete??!0)&&f.length<=t}}c(ge,"searchSymbols");import{readFile as X}from"node:fs/promises";import N from"node:path";import{fileURLToPath as Zt}from"node:url";var er={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},me=10,fe=5,q=10;async function dt(r,e,t,n,s){_(s);let o=await X(e,"utf8"),i=await Y(r,e,n),d=Q(i.symbols,t,i.displayPath),a=await X(i.filePath,"utf8");if(_(s),o!==a)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:d.range,content:a}}c(dt,"resolveLspDeclaration");async function ut(r,e,t,n,s){_(s);let o=await X(e,"utf8"),i=await Y(r,e,n),d=Q(i.symbols,t,i.displayPath);if(o!==await X(e,"utf8"))throw new Error("The rename source changed during resolution.");return _(s),{client:i.client,uri:i.uri,position:d.selectionRange.start,content:o}}c(ut,"resolveLspRenameTarget");async function ve(r,e,t,n,s){_(s);let o=await Y(r,e,n),i=Q(o.symbols,t,o.displayPath),d=await ir(o.filePath);_(s);let a=i.range.start.line+1,l=Math.min(i.range.end.line+1,d.lines.length),u=d.lines.slice(Math.max(0,a-1),Math.max(0,l)).map((f,y)=>{let m=a+y;return Re({content:f,sourceLine:{source:o.filePath,lineNumber:m,content:f}})}),p={path:o.displayPath,heading:`symbol: ${E(i.selector)}`,details:[`defined in: ${o.displayPath}:${a}-${l} (${x(i.kind)})`],startLine:a,endLine:l,totalLines:d.lines.length,renderedLines:u};return Pe([p],er)}c(ve,"readLspSymbolBody");async function be(r,e,t,n,s){_(s);let o=await Y(r,e,n),i=Q(o.symbols,t,o.displayPath),d=await ft(o,i,s),a=new se(n);return await tr(o,i,d,a)}c(be,"readLspSymbolGraph");async function we(r,e,t,n){_(n);let s=await Y(r,e,t),o=new se(t),i=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let d of s.symbols){_(n);let a=await ft(s,d,n);i.push("",...await or(s,d,a,o))}return i.join(`
|
|
2
|
-
`)}c(we,"readLspFileGraph");function Q(r,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let o=mt(r,L(e[0]));if(o.length===1)return L(o[0]);throw o.length>1?new Error(`Symbol selector "${E(e)}" is ambiguous in ${t}; use parent/child.`):ct(e,t)}let n=r,s;for(let o of e){let i=n.filter(d=>d.name===o);if(i.length===0)throw ct(e,t);if(i.length>1)throw new Error(`Symbol selector "${E(e)}" is ambiguous at "${o}" in ${t}.`);s=L(i[0]),n=s.children}return L(s)}c(Q,"resolveLspCodeSymbol");async function Y(r,e,t){let n=N.isAbsolute(e)?N.normalize(e):N.resolve(t,e),s=await r.openFile(n,t,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${ye(n,t)}.`);let o=await G(s.client,s.uri),i=pt(o).sort(gt);return{client:s.client,uri:s.uri,filePath:n,displayPath:ye(n,t),symbols:i}}c(Y,"openCodeDocument");function pt(r,e=[]){return r.flatMap(t=>{let n=t.selectionRange??t.range;if(!n)return[];let s=t.range??n,o=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:n,selector:o,children:pt(t.children??[],o).sort(gt)}]})}c(pt,"normalizeDocumentSymbols");function gt(r,e){return r.range.start.line-e.range.start.line||r.range.start.character-e.range.start.character||r.name.localeCompare(e.name)}c(gt,"compareSymbols");function mt(r,e){return r.flatMap(t=>[...t.name===e?[t]:[],...mt(t.children,e)])}c(mt,"collectNamedSymbols");function ct(r,e){return new Error(`Symbol "${E(r)}" was not found in ${e}.`)}c(ct,"symbolNotFound");async function ft(r,e,t){let n=e.selectionRange.start,[s,o]=await Promise.all([lt(K(r.client,r.uri,n),[],t),lt(pe(r.client,r.uri,n),{items:[],incoming:[],outgoing:[]},t)]);return _(t),{references:s,calls:o}}c(ft,"queryRelations");async function lt(r,e,t){try{let n=await r;return _(t),n}catch(n){if(t?.aborted===!0)throw yt(t,n);return e}}c(lt,"optionalRequest");async function tr(r,e,t,n){let s=E(e.selector),o=await n.line(r.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${r.displayPath} ${o} (${x(e.kind)})`,`Source: ${W("graph",r.displayPath,e.selector)}`,"",...await rr(t.references,n),"",...await nr(t.calls.incoming,n),"",...await sr(t.calls.outgoing,n)].join(`
|
|
3
|
-
`)}c(tr,"formatSymbolGraph");async function rr(r,e){let t=ht(r),n=[`References: ${r.length} in ${t.length} file(s)`];for(let[s,o]of t.slice(0,me)){n.push(`- ${e.display(s)} (${o.length})`);for(let i of o.slice(0,fe))n.push(` - ${await e.line(s,i.range.start.line+1)}`);o.length>fe&&n.push(` - ... ${o.length-fe} more`)}return t.length>me&&n.push(`- ... ${t.length-me} more file(s)`),n}c(rr,"formatReferences");async function nr(r,e){let t=[`Incoming calls: ${r.length}`];for(let n of r.slice(0,q)){let s=n.fromRanges[0]?.start.line??n.from.selectionRange.start.line,o=await e.line(n.from.uri,s+1);t.push(`- ${x(n.from.kind)} ${n.from.name} \u2014 ${e.display(n.from.uri)} ${o}`)}return r.length>q&&t.push(`- ... ${r.length-q} more`),t}c(nr,"formatIncomingCalls");async function sr(r,e){let t=[`Outgoing calls: ${r.length}`];for(let n of r.slice(0,q)){let s=await e.line(n.to.uri,n.to.selectionRange.start.line+1);t.push(`- ${x(n.to.kind)} ${n.to.name} \u2014 ${e.display(n.to.uri)} ${s}`)}return r.length>q&&t.push(`- ... ${r.length-q} more`),t}c(sr,"formatOutgoingCalls");async function or(r,e,t,n){let s=x(e.kind),o=await n.line(r.uri,e.selectionRange.start.line+1),i=ht(t.references).map(([u,p])=>`${n.display(u)} (${p.length})`),d=t.calls.incoming.map(u=>`${u.from.name} (${n.display(u.from.uri)})`),a=t.calls.outgoing.map(u=>`${u.to.name} (${n.display(u.to.uri)})`),l=[`### ${s} ${e.name}`,`Selector: ${E(e.selector)}`,`Definition: ${o}`,`Used by: ${he(i)}`,`Incoming calls: ${he(d)}`,`Outgoing calls: ${he(a)}`];if(e.children.length>0){l.push("Members:");for(let u of e.children){let p=W("graph",r.displayPath,u.selector);l.push(`- ${x(u.kind)} ${u.name} \u2014 ${p}`)}}return l}c(or,"formatFileGraphSymbol");function he(r,e=5){if(r.length===0)return"none";let t=r.slice(0,e).join(", ");return r.length>e?`${t}, ... ${r.length-e} more`:t}c(he,"summarize");function ht(r){let e=new Map;for(let t of r){let n=e.get(t.uri)??[];n.push(t),e.set(t.uri,n)}return[...e].map(([t,n])=>[t,n.sort((s,o)=>s.range.start.line-o.range.start.line||s.range.start.character-o.range.start.character)]).sort(([t],[n])=>t.localeCompare(n))}c(ht,"groupLocationsByUri");async function ir(r){let e=await X(r);if(e.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${r}`);if(e.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${r}`);let t=e.toString("utf8").replaceAll(`\r
|
|
4
|
-
`,`
|
|
5
|
-
`),n=t.endsWith(`
|
|
6
|
-
`)?t.slice(0,-1):t,s=n.length===0?[]:n.split(`
|
|
7
|
-
`);return{content:t,lines:s}}c(ir,"readTextFile");var se=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return ye(ar(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function ar(r){if(!r.startsWith("file://"))return r;try{return Zt(r)}catch{return decodeURIComponent(r.slice(7))}}c(ar,"filePathFromUri");function ye(r,e){let t=N.relative(e,r);return t.length===0||t.startsWith("..")||N.isAbsolute(t)?r:t.replaceAll(N.sep,"/")}c(ye,"displayFilePath");function _(r){if(r?.aborted===!0)throw yt(r)}c(_,"throwIfAborted");function yt(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(yt,"abortReason");function Le(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await cr(t,n,r);if(!s)return lr();let{client:o,diagnostics:i,syntaxErrors:d,otherDiagnostics:a}=s;return e=o,{ok:!i.some(l=>l.severity==="error"),diagnostics:i,syntaxErrors:d,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(Le,"createLspCompiler");async function cr(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await U(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(cr,"openAndDiagnose");function lr(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(lr,"skipOk");import C from"node:path";import{existsSync as dr}from"node:fs";function vt(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[o,i]of Object.entries(s.languages))for(let d of i.extensions){let a=d.toLowerCase(),l=e.get(a);if(l!==void 0&&l!==o)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${l}" and "${o}"`);e.set(a,o);let u=t.get(a)??[];u.push(n),t.set(a,u)}return{extToLanguageId:e,extToServerIds:t}}c(vt,"buildLanguageLookup");var D=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(o=>o.layer!=="built-in"||t.has(o.id));this._servers=Object.fromEntries(s.map(o=>[o.id,o.config])),this._lookup=vt(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await je(e,"lsp-servers",d=>ur(d).servers,t),s=t.environment??process.env,o=await Promise.all(n.entries.filter(d=>d.layer==="built-in").map(async d=>({id:d.id,available:await ee(d.config,e,s)}))),i=t.requireBuiltInEvidence?await De(e,t.recipes??[]):void 0;return new r(n.entries,new Set(o.filter(d=>d.available&&(i===void 0||(i.get(d.id)?.score??0)>0)).map(d=>d.id)),C.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,C.resolve(t))}resolve(e){let t=C.basename(e),n=C.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),o=[];for(let i of this._entries)if(this._servers[i.id]&&!(i.config.requireRootMarker&&!this.hasRootMarker(e,i.config.rootMarkers))){for(let[d,a]of Object.entries(i.config.languages))if(a.extensions.some(l=>l.toLowerCase()===n.toLowerCase())||a.fileNames?.some(l=>s(l)===s(t))){o.push({serverId:i.id,config:i.config,languageId:d,layer:i.layer,sourcePath:i.sourcePath});break}}return o}hasRootMarker(e,t){let n=C.dirname(C.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(C.sep)&&(n=this._projectRoot);;){let s=C.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${C.sep}`)||C.isAbsolute(s))return!1;if(t.some(o=>dr(C.join(n,o))))return!0;if(n===this._projectRoot)return!1;n=C.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function ur(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(o=>typeof o!="string"||o.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(o=>typeof o!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[o,i]of Object.entries(s.languages)){let d=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(d)||d.length===0||d.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${o} requires extensions`);let a=i.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${o}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(ur,"parseLspConfig");function bt(r){return Lt("symbol","lsp-symbol",r,async e=>await ve(e.manager,e.filePath,L(e.selector),e.cwd,e.signal))}c(bt,"createLspSymbolResolver");function wt(r){return Lt("graph","lsp-graph",r,async e=>e.selector===void 0?await we(e.manager,e.filePath,e.cwd,e.signal):await be(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(wt,"createLspGraphResolver");function Lt(r,e,t,n){return{id:e,tryResolve(s,o){return Promise.resolve(pr(s,o,r,t,n))}}}c(Lt,"createCodeViewResolver");function pr(r,e,t,n,s){let o;try{o=T(r,t)}catch(a){return{kind:"failed",error:a}}if(o===void 0)return{kind:"not-handled"};let i;try{i=$(o.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:W(t,i,o.selector),async read(a){let l=await n(e.cwd),u=await s({manager:l,filePath:i,cwd:e.cwd,...gr(o.selector),...mr(a.signal)});return[typeof u=="string"?{type:"text",text:u}:u]}}}}c(pr,"resolveCodeViewSource");function gr(r){return r===void 0?{}:{selector:r}}c(gr,"optionalSelector");function mr(r){return r===void 0?{}:{signal:r}}c(mr,"optionalSignal");function Rt(r,e=(t,n)=>Promise.resolve({cwd:n,external:!1})){return{id:"lsp",async diagnose(t,n){let s=await e(t,n.cwd);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let o=await r(s.cwd,s.external);n.signal.throwIfAborted();let i=await o.getOrStart(t,s.cwd,"diagnostics");if(n.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let d=i.toUri(t),a=o.languageId(t);i.syncDocument(d,n.content,a,!0);let l=i.documentVersion(d),u={active:!0,queued:!1},p=c(()=>!n.signal.aborted&&i.documentVersion(d)===l,"current"),f=c(()=>U(i,d,a,{signal:n.signal,content:n.content}),"request"),y=c(async()=>{if(u.queued=!0,!u.active){u.active=!0;try{for(;u.queued&&p();){u.queued=!1;let g=await f();p()&&n.publish(St(g,i.commandName))}}catch(g){p()&&n.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:i.commandName})}finally{u.active=!1}}},"refresh"),m=o.onPushDiagnostics(g=>{!p()||g.uri!==d||g.serverId!==i.serverId||g.cwd!==s.cwd||g.version!==void 0&&g.version!==l||(i.diagnosticMode==="pull"||ne(i)?y():n.publish({status:"snapshot",diagnostics:g.diagnostics,source:i.commandName,reason:Pt(g.version===void 0)}))});n.signal.addEventListener("abort",m,{once:!0});try{let g=await f();return l=i.documentVersion(d),St(g,i.commandName)}catch(g){throw u.queued=!1,m(),n.signal.removeEventListener("abort",m),g}finally{u.active=!1,u.queued&&p()&&queueMicrotask(()=>{y()})}}}}c(Rt,"createLspDiagnosticSource");function Pt(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(Pt,"snapshotReason");function St(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:Pt(r.unversioned),source:e}}c(St,"toReport");import{URI as fr}from"vscode-uri";var Ct={protocol:Ae,apiVersion:1,id:"lsp",setup(r){for(let e of z)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:hr}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await D.fromPackageDir(e.cwd,{environment:e.env}),n=yr(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let o=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,i=new I({serverId:s.serverId,rootUri:fr.file(e.cwd).toString(),command:s.config.command,env:vr(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await i.start(),{status:"pass",message:`${o}: initialized`,detail:s.sourcePath}}catch(d){return{status:"fail",message:`${o}: ${d instanceof Error?d.message:String(d)}`,detail:s.sourcePath}}finally{await i.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function hr(r){try{let e=await D.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,o]of r.detectedLanguages){let i=o.flatMap(d=>e.resolve(d)).find(d=>d.languageId===s);i!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:i.serverId}),await ee(i.config,r.cwd,r.env)||n.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(hr,"inspectLspSetup");function yr(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(yr,"applicableServers");function vr(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(vr,"definedEnvironment");import _t from"node:path";function kt(r,e){return{id:"symbols",supportsResultScope:!0,readResources:c(t=>t.query.startsWith("symbols:")?void 0:[],"readResources"),toScriptData(t){return t.data},async tryResolve(t,n){if(!t.query.startsWith("symbols:"))return{kind:"not-handled"};let s=t.query.slice(8).trim();if(s.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let o=await r(n.cwd),i=c(u=>ge(s,n.cwd,t.limit??100,u,{...t,...n.scope===void 0?{}:{resultScope:n.scope}},o),"collect"),d=await i(n.signal),a=await e({request:t,matches:d.hits,complete:d.complete,refresh:c(async u=>{let p=await i(u);return{matches:p.hits,complete:p.complete}},"refresh")},n),l=Xe(d.hits,d.complete,a.id,a);return{kind:"resolved",payload:{query:s,hits:d.hits,sessionId:a.id,complete:d.complete,navigation:t.navigation,data:{...l,matches:l.matches.map((u,p)=>({...u,role:d.hits[p]?.role,symbol:d.hits[p]?.symbol}))}}}},renderResult(t,n,s){let o=t.details;return Je(o.hits,o.complete,s,n.expanded,o.cwd,o.navigation==="references"?["LSP reference navigation \xB7 may leave input scope"]:[],o.hits.map(i=>`${i.role} ${i.symbol.name}`))},format(t,n){let s=t,o=s.navigation==="references"?"LSP reference navigation (may leave input scope)":"LSP symbols inside scope",i=s.hits.length===0?["No symbols found."]:s.hits.slice(0,100).map((d,a)=>`SEARCH#${s.sessionId}:${a+1}:match ${_t.relative(n.cwd,d.source)}:${d.lineNumber}:${d.startColumn+1} ${d.role} ${d.symbol.name} \xB7 declared at ${_t.relative(n.cwd,d.symbol.source)}:${d.symbol.range.startLine}:${d.symbol.range.startColumn+1}`);return s.complete&&s.hits.length&&i.unshift(`SEARCH#${s.sessionId}:all:match selects all exact symbol matches.`),s.hits.length>100&&i.push("Preview shortened; full source targets retained."),{content:[{type:"text",text:[o,...i].join(`
|
|
8
|
-
`)}],details:{...s,cwd:n.cwd}}}}}c(kt,"createLspSearchResolver");function xt(r){return{id:"lsp-declaration-target",async tryResolve(e,t){let n=T(e,"symbol");if(n===void 0||e.endsWith("#name"))return{kind:"not-handled"};if(n.selector===void 0)return{kind:"rejected",rejection:{code:"invalid",reason:"Use symbol:<file>#<selector> to choose one declaration"}};try{let s=await dt(await r(t.cwd),$(n.path,t.cwd),n.selector,t.cwd,t.signal);return{kind:"resolved",targets:[{source:s.source,expectedContent:s.content,ranges:[{start:{lineNumber:s.range.start.line+1,column:s.range.start.character},end:{lineNumber:s.range.end.line+1,column:s.range.end.character}}]}]}}catch(s){return{kind:"failed",error:new Error(`${s instanceof Error?s.message:String(s)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`,{cause:s})}}}}}c(xt,"createDeclarationTargets");import{readFile as br,stat as Dt}from"node:fs/promises";import{fileURLToPath as wr}from"node:url";function Et(r,e){let t=r.split(`
|
|
9
|
-
`),n=t[e.line];if(!Number.isInteger(e.line)||e.line<0||n===void 0||!Number.isInteger(e.character)||e.character<0||e.character>n.replace(/\r$/u,"").length)throw new Error("The language server returned an invalid text position.");return t.slice(0,e.line).reduce((s,o)=>s+o.length+1,0)+e.character}c(Et,"offset");async function It(r,e){let t=r.input;if(typeof t.path!="string"||!t.path.startsWith("symbol:")||!t.path.endsWith("#name"))return;if(typeof t.text!="string"||t.text.trim()===""||t.start!==void 0||t.end!==void 0)throw new Error("Rename needs a symbol #name path and a non-empty new name in text, without start/end.");let n=T(t.path.slice(0,-5),"symbol");if(n?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let s=$(n.path,r.cwd),o=await ut(await e(r.cwd),s,n.selector,r.cwd,r.signal);await B(o.client,s);let i=Date.now(),d=await de(o.client,o.uri,o.position,t.text);if(r.signal?.throwIfAborted(),d===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let a=new Map(Object.entries(d.changes??{}));for(let u of d.documentChanges??[]){if(!("textDocument"in u)||!("edits"in u))throw new Error("Rename returned a file operation that is not supported; no edits applied.");if(u.textDocument.version!=null&&u.textDocument.version!==o.client.documentVersion(u.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. Refresh the source before retrying.");if(a.has(u.textDocument.uri))throw new Error("Rename returned duplicate document edits.");a.set(u.textDocument.uri,u.edits)}let l=[];for(let[u,p]of a){let f=wr(u),y=await Dt(f),m=await br(f,"utf8"),g=await Dt(f),v=o.client.documentContent(u);if(v!==void 0&&v!==m)throw new Error("The language server has stale text for a rename target. Read that symbol again before retrying.");if(y.mtimeMs>i||y.mtimeMs!==g.mtimeMs||y.size!==g.size||f===s&&m!==o.content)throw new Error("A rename source changed during the language-server request. Retry from a fresh symbol read.");l.push({source:f,expectedContent:m,changes:p.map(R=>({from:Et(m,R.range.start),to:Et(m,R.range.end),insert:R.newText}))})}return{...r,editPlan:{files:l},metadata:{...r.metadata,semanticEdit:{mode:"lsp-rename",server:o.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}c(It,"prepareSymbolRename");var jt=Ve({kind:"code-view",label:"LSP"});async function Sr(r){let e=new Map,t=!1,n=c((a,l=!1)=>{if(t)return Promise.reject(new Error("LSP session has ended"));let u=JSON.stringify([a,l]),p=e.get(u);return p||(p=Rr(a,l).then(f=>{if(t)throw new Error("LSP session has ended");return j.init(f)}),e.set(u,p)),p},"managerFor"),s=c(async(a,l)=>{let u=await Ie(l,a,"lsp-servers",z);return u===void 0?void 0:{cwd:u,external:u!==Lr.resolve(l)}},"resolveLspProject"),o={kind:"compiler",name:"pi-agent-ide-lsp",priority:200,extensions:["*"],detect:c(async a=>(await n(a.cwd),!0),"detect"),async compile(a,l){let u=await n(l.cwd);return Le(u).compile(a,l)}},i={protocol:_e,apiVersion:4,id:"lsp",setup(a){a.addTool(o),a.addDiagnosticSource(Rt(n,s))}};r.on("session_shutdown",async()=>{t=!0,await Promise.allSettled([...e.values()].map(async a=>(await a).shutdownAll())),e.clear()});let d={protocol:Oe,apiVersion:Ne,id:"lsp",setup(a){a.addResolver({resolver:bt(n),renderResult:jt}),a.addResolver({resolver:wt(n),renderResult:jt}),a.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:Ce()}),a.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([xe(r,i),He(r,{protocol:Fe,apiVersion:We,id:"lsp-declarations",setup(a){a.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:c(l=>l,"renderFull"),renderCompact:c(l=>l,"renderCompact"),tryResolve:c(()=>Promise.resolve({kind:"not-handled"}),"tryResolve")},resources:xt(n),describeInPrompt:!1});for(let l of["copy","move","delete","replace"])a.tool(l).describe("Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. 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."+(l==="replace"?" Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement.":"")),a.tool(l).addHandler({stage:"text-pre-edit",async handler(u){if(l==="replace"){let y=await It(u,n);if(y!==void 0)return y}let p=u.input;if(![p.path,p.start,p.end,p.target,p.targetStart,p.targetEnd].some(y=>typeof y=="string"&&y.startsWith("symbol:")))return u;if((l==="copy"||l==="move")&&typeof p.target!="string")throw new Error("Copying or moving a symbol requires an explicit target file and destination anchor.");return{...u,metadata:{...u.metadata,semanticEdit:{mode:"declaration-text",referencesUpdated:!1,importsUpdated:!1},diffStatuses:[{text:"Text fallback: imports and references unchanged",tone:"warning"}]}}}});a.tool("insert").describe("Symbol targets are unsupported for insert. Read the declaration and select an ordinary text line anchor instead."),a.tool("insert").addHandler({stage:"text-pre-edit",handler(l){let u=l.input;if([u.path,u.anchor].some(p=>typeof p=="string"&&p.startsWith("symbol:")))throw new Error("Semantic insert is not supported. Read the declaration and use an explicit text line anchor instead.");return l}})}}),qe(r,d),$e(r,Ct),Be(r,{protocol:Ue,apiVersion:Ge,id:"symbols",setup(a){a.addResolver({resolver:kt(n,a.registerSelection)}),a.describe('Use `symbols:<query>` to locate named workspace declarations and references through configured language servers when the file is unknown. Results contain exact source targets, roles, and originating symbols. Default search stays within path. Use navigation: "references" explicitly to follow symbols represented inside path to references outside it, within the workspace.')}})])}c(Sr,"registerLsp");async function Rr(r,e){let t=e?r:process.env.PI_AGENT_IDE_CONFIG_DIR??r;return D.fromPackageDir(t,{includeGlobal:!e,requireBuiltInEvidence:e,recipes:z})}c(Rr,"loadRegistry");export{Sr as default};
|
|
1
|
+
import{a as p}from"./chunk-YJ6T3PEP.js";import{b as n,c}from"./chunk-S72FVLUX.js";import{a as e}from"./chunk-EI7MMDWY.js";var m=[t("c","C",[".c",".h"],["CMakeLists.txt","meson.build","compile_commands.json"],"tree-sitter"),t("cpp","C++",[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["CMakeLists.txt","meson.build","compile_commands.json","conanfile.py","vcpkg.json"],"tree-sitter"),t("csharp","C#",[".cs"],[".sln",".csproj","global.json"]),t("go","Go",[".go"],["go.mod","go.work"]),t("java","Java",[".java"],["pom.xml","build.gradle","build.gradle.kts"]),t("kotlin","Kotlin",[".kt",".kts"],["build.gradle.kts","settings.gradle.kts"]),t("javascript","JavaScript",[".js",".jsx",".mjs",".cjs"],["package.json"],"tree-sitter"),t("typescript","TypeScript",[".ts",".tsx",".mts",".cts"],["tsconfig.json","package.json"],"tree-sitter"),t("python","Python",[".py",".pyi"],["pyproject.toml","requirements.txt","setup.py"],"tree-sitter"),t("rust","Rust",[".rs"],["Cargo.toml"],"tree-sitter"),t("ruby","Ruby",[".rb",".rake"],["Gemfile",".ruby-version"]),t("php","PHP",[".php"],["composer.json"]),t("swift","Swift",[".swift"],["Package.swift"]),t("lua","Lua",[".lua"],[".luarc.json","stylua.toml"]),t("dart","Dart",[".dart"],["pubspec.yaml","analysis_options.yaml"]),t("powershell","PowerShell",[".ps1",".psm1",".psd1"],["PSScriptAnalyzerSettings.psd1"]),t("r","R",[".r"],["DESCRIPTION",".lintr",".Rprofile"]),t("scala","Scala",[".scala",".sc"],["build.sbt","project.scala",".scalafmt.conf"]),t("elixir","Elixir",[".ex",".exs"],["mix.exs",".formatter.exs"]),t("zig","Zig",[".zig",".zon"],["build.zig","build.zig.zon","zls.json"]),t("julia","Julia",[".jl"],["Project.toml",".JuliaFormatter.toml"]),t("vue","Vue",[".vue"],["package.json"]),t("svelte","Svelte",[".svelte"],["svelte.config.js","svelte.config.ts"]),t("shell","Shell",[".sh",".bash",".zsh"],[".shellcheckrc"]),t("html","HTML",[".html",".htm"],[]),t("css","CSS",[".css",".scss",".sass",".less"],["stylelint.config.js"]),t("json","JSON",[".json",".jsonc"],[],"tree-sitter"),t("yaml","YAML",[".yaml",".yml"],[".yamllint"],"tree-sitter"),t("toml","TOML",[".toml"],["taplo.toml"],"tree-sitter"),t("xml","XML",[".xml",".xsd",".xsl"],[]),t("markdown","Markdown",[".md",".mdx"],[".markdownlint.json"]),t("sql","SQL",[".sql"],[".sqlfluff"]),t("dockerfile","Dockerfile",[],["Dockerfile","compose.yaml"],void 0,["Dockerfile","Containerfile"]),t("terraform","Terraform",[".tf",".tfvars"],[".terraform.lock.hcl"]),t("cmake","CMake",[".cmake"],["CMakeLists.txt"],void 0,["CMakeLists.txt"])];function t(s,i,o,r,l,a){return{id:s,name:i,extensions:o,projectMarkers:r,...l&&{ast:l},...a&&{fileNames:a}}}e(t,"language");function g(s){return p(s,{protocol:n,apiVersion:c,id:"languages",setup(o){for(let r of m)o.addLanguage(r)}})}e(g,"registerLanguages");export{g as default};
|
package/dist/entry-38.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-MKEC3U2M.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-K5G4FDXD.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as LINTER_RECIPES,b as LintCommandRegistry,d as default,e as registerLintWithOwner,c as runConfiguredLinter};
|
package/dist/entry-39.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as
|
|
1
|
+
import{a,b,c,d}from"./chunk-TXG2H7YQ.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-OI3HBIPK.js";import"./chunk-YTYLS2UM.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-M4TVRCMZ.js";import"./chunk-TGC2ZACO.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-DXONCYWF.js";import"./chunk-DUUOCBS3.js";import"./chunk-T4FTT3U4.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-KINKBPPX.js";import"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as LSP_RECIPES,b as LspServerRegistry,c as default,d as registerLspWithOwner};
|
package/dist/entry-4.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as TOOL_CONFIG_VERSION,b as configuredExecutableName,p as createConfiguredProcessEnvironment,j as hasConfiguredExecutable,g as loadLayeredToolConfig,h as matchesConfiguredFile,n as parseFormattersConfig,o as parseLintersConfig,d as projectIdeConfigDirectory,e as projectIdeConfigPath,q as recipeMatchesFile,c as resolveExternalToolProjectRoot,f as resolveToolConfigPaths,m as runConfiguredFormatter,l as runConfiguredProcess,i as selectConfiguredEntry,k as toolRuntimeEvidence};
|
package/dist/entry-40.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-
|
|
1
|
+
import{a,b,c}from"./chunk-QIJMV2P2.js";import"./chunk-EI7MMDWY.js";export{c as createImageContent,a as createImageContentConverter,b as detectSupportedImageMimeType};
|
package/dist/entry-41.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as requiredValue};
|
package/dist/entry-42.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a,b,c}from"./chunk-BHSO2MDK.js";import"./chunk-EI7MMDWY.js";export{c as createPdfContent,a as createPdfContentConverter,b as isPdf};
|
package/dist/entry-43.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-EI7MMDWY.js";export{a as connectReadPlugin};
|
package/dist/entry-44.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"./chunk-NNCZYO4Q.js";import{b as a,d as b}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as COMPACT_READ_ROWS,b as createReadResultRenderer};
|