pi-agent-ide 0.5.1 → 0.6.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 +71 -0
- package/README.md +82 -50
- package/assets/social-preview.png +0 -0
- package/dist/{chunk-LY6U5EAD.js → chunk-2527OQ4Y.js} +1 -1
- package/dist/chunk-4KUFOHWP.js +2 -0
- package/dist/chunk-4LDOV7QS.js +28 -0
- package/dist/chunk-5JELU6RV.js +7 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/chunk-FEDVTZJG.js +1 -0
- package/dist/chunk-I6Y3W4X6.js +27 -0
- package/dist/chunk-K5G4FDXD.js +1 -0
- package/dist/chunk-M5IVSCR2.js +1 -0
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/chunk-S6QRG3TQ.js +1 -0
- package/dist/chunk-T7I2VX3J.js +1 -0
- package/dist/chunk-VCTK4JSN.js +3 -0
- package/dist/chunk-W7CASEO3.js +1 -0
- package/dist/chunk-YEQOQMU7.js +5 -0
- package/dist/chunk-YT42LKFV.js +16 -0
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.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 -0
- package/dist/entry-17.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -2
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +2 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -12
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +12 -1
- package/dist/entry-32.js +1 -4
- package/dist/entry-33.js +1 -9
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +4 -1
- package/dist/entry-37.js +9 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -18
- 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 +17 -1
- package/dist/entry-46.js +1 -7
- package/dist/entry-47.js +1 -11
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +6 -1
- package/dist/entry-51.js +11 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -0
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +0 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +0 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +0 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -203
- package/dist/entry-72.js +1 -30
- package/dist/entry-73.js +1 -2
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +315 -1
- package/dist/entry-76.js +30 -3
- package/dist/entry-77.js +2 -3
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +3 -1
- package/dist/entry-81.js +3 -0
- package/dist/entry-82.js +1 -0
- package/dist/entry-83.js +1 -0
- package/dist/entry-84.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/pi-agent-ide.js +3 -3
- package/docs/agent-guides/apply.md +333 -0
- package/docs/agent-guides/debugger.md +5 -0
- package/docs/agent-guides/diagnostics.md +5 -0
- package/docs/agent-guides/editing.md +44 -0
- package/docs/agent-guides/git-changes.md +5 -0
- package/docs/agent-guides/json-reading.md +41 -0
- package/docs/agent-guides/read-resources.md +44 -0
- package/docs/agent-guides/search-code.md +29 -0
- package/docs/agent-guides/terminal.md +7 -0
- package/docs/agent-guides/vision.md +5 -0
- package/docs/configuration.md +9 -15
- package/docs/research/apply-read-latency.md +219 -0
- package/docs/tools.md +12 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-22.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
- package/node_modules/pi-agent-documentation/package.json +15 -0
- package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
- package/node_modules/pi-agent-documentation/src/index.ts +69 -0
- package/node_modules/pi-agent-filesystem/index.ts +0 -4
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-image/runtime/entry-26.js +2 -0
- package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
- package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-ide-ast/package.json +12 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- package/node_modules/pi-agent-ide-changes/index.ts +8 -0
- package/node_modules/pi-agent-ide-changes/package.json +9 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/runtime/entry-34.js +2 -0
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/node_modules/pi-agent-ide-lint/index.ts +1 -1
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +20 -2
- package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- 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 -3
- package/node_modules/pi-agent-read/package.json +12 -11
- package/node_modules/pi-agent-read/runtime/entry-41.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +4 -4
- package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
- package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +29 -17
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/runtime/entry-46.js +1 -0
- package/node_modules/pi-agent-search/package.json +8 -7
- package/node_modules/pi-agent-search/runtime/entry-47.js +1 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-51.js +2 -0
- package/node_modules/pi-agent-search-text/runtime/entry-52.js +1 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/index.ts +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/config.ts +2 -2
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/node_modules/pi-agent-text-editor/index.ts +15 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-72.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +131 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +36 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -42
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +50 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +187 -38
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +3 -8
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +770 -237
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +4 -4
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/runtime/entry-81.js +2 -0
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-84.js +2 -0
- package/package.json +112 -43
- package/src/api/documentation.ts +2 -0
- package/src/api/path-identity.ts +15 -0
- package/src/composite/builtin-extensions.ts +14 -2
- package/src/composite/extensions-config.ts +6 -0
- package/src/composite/module-labels.ts +9 -0
- package/src/composite/module-settings-store.ts +3 -0
- package/src/composite/module-settings.ts +71 -17
- package/src/composite/preferences.ts +83 -3
- package/src/composite/presentation.ts +14 -0
- package/src/composite/presets.ts +57 -0
- package/src/composite/selection.ts +5 -1
- package/src/doctor/inventory.ts +7 -2
- package/src/documentation/extension.ts +295 -0
- package/src/documentation/registry.ts +98 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-26.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -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-28.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-29.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-81.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-83.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-84.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -11
- package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-42.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +4 -4
- package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
- package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +29 -17
- package/src/extensions/pi-agent-search/package.json +8 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-51.js +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-47.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
- package/src/extensions/pi-agent-text-editor/index.ts +15 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -25
- 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/index.ts +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +2 -2
- 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-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- 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-77.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +131 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +36 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -42
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +50 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +187 -38
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +3 -8
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +770 -237
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +4 -4
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/src/pi-agent-ide.ts +21 -11
- package/src/plugins/pi-agent-ide-ast/package.json +12 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
- package/src/plugins/pi-agent-ide-changes/package.json +9 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/src/plugins/pi-agent-ide-debugger/index.ts +13 -11
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +31 -0
- package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +24 -23
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -2
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +55 -17
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -22
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-34.js +2 -0
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +20 -2
- package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +4 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +18 -9
- package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +1 -4
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +8 -5
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +1 -0
- package/src/plugins/pi-agent-ide-vision/index.ts +234 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +530 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +30 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +33 -0
- package/dist/chunk-526E364R.js +0 -3
- package/dist/chunk-5PLV4HLG.js +0 -1
- package/dist/chunk-7ALCBKCW.js +0 -26
- package/dist/chunk-DQXPQOF7.js +0 -2
- package/dist/chunk-EJ5OACQM.js +0 -1
- package/dist/chunk-G725MARR.js +0 -16
- package/dist/chunk-HKXDP2FD.js +0 -7
- package/dist/chunk-IRECDTJG.js +0 -27
- package/dist/chunk-J4RTW44E.js +0 -1
- package/dist/chunk-NZYDMBM6.js +0 -1
- package/dist/chunk-WGGIQ7IJ.js +0 -1
- package/dist/entry-18.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-17.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-24.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/node_modules/pi-agent-ide-formatter/runtime/entry-30.js +0 -2
- package/node_modules/pi-agent-ide-lint/runtime/entry-32.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-34.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-35.js +0 -1
- package/node_modules/pi-agent-pdf/runtime/entry-36.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-37.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-46.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-47.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
- package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-image/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-web-pdf/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-24.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-37.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -2
- package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -2
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-30.js +0 -2
- package/src/plugins/pi-agent-ide-lint/runtime/entry-32.js +0 -2
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-jq}/runtime/entry-27.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-filesystem-text}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search}/runtime/entry-50.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text}/runtime/entry-53.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-constant}/runtime/entry-54.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-55.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-renderer}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-80.js +0 -0
- /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-43.js +0 -0
- /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-constant}/runtime/entry-54.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-renderer}/runtime/entry-76.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
package/dist/entry-27.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
`).split(`
|
|
4
|
-
`));n.push(i===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:s})}catch(o){n.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),a.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>y.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await x("ast-grep",["--version"],e.cwd,e.env);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 re(a,e){let n=a.slice(a.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}d(re,"matchesLanguage");var se,ae;function F(a){return{id:"ast",tryResolve(e,n){return Promise.resolve(oe(e,n,a))}}}d(F,"createAstOutlineResolver");function oe(a,e,n){let r;try{r=S(a,"ast")}catch(o){return{kind:"failed",error:o}}if(r===void 0)return{kind:"not-handled"};let t;try{t=R(r.path,e.cwd)}catch(o){return{kind:"failed",error:o}}return{kind:"resolved",resource:{source:w("ast",t),async read({signal:o}){o?.throwIfAborted();let i=await(ae??=import("./chunk-5QQABP47.js")),c=await(n??(se??=new i.AstOutlineManager)).readFileOutline(t,e.cwd);return o?.throwIfAborted(),[i.formatAstOutline(c)]}}}}d(oe,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ie,DEFAULT_MAX_LINES as ce,truncateHead as A}from"@earendil-works/pi-coding-agent";var b=d(async(a,e,n)=>{let{source:r,resolvedBy:t,lines:s,totalLines:o,startLine:i}=a.details;if(!(r===void 0||t!=="filesystem"||s===void 0||s.length!==o||i!==void 0&&i!==1))try{let{AstOutlineManager:l,isSupportedOutlinePath:c}=await import("./chunk-5QQABP47.js");if(!c(r))return;let u=d(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
|
|
5
|
-
`),"format");e.signal?.throwIfAborted();let p=await new l(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!A(u(m),n).truncated)),f=u(p);return A(f,n).truncated?void 0:{content:[{type:"text",text:f}],details:{source:r,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function z(){return async a=>{let{state:e,result:n}=a,r=n?.content.length===1?n.content[0]:void 0;if(a.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||r?.type!=="text"||!A(r.text).truncated)return{kind:"continue",context:a};let t=await b({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},a.resolverContext,{maxBytes:ie,maxLines:ce});return t===void 0?{kind:"continue",context:a}:{kind:"return",result:t}}}d(z,"createAstOverflowHandler");var X="pi-agent-ast";function K(a){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem")return e;try{let r=await a.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),t=de(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}d(K,"createAstScopePresenter");function U(){return a=>{let e=a.state,n=a.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:a};let r=n.details.lines;if(r===void 0)return{kind:"continue",context:a};let t=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(r.map(u=>u.lineNumber)),o=new Map;for(let u of r){let p=t.get(u.lineNumber),f=q(p);for(let m of f?.boundaries??[]){if(s.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&o.set(m.endLine,g)}}if(o.size===0)return{kind:"continue",context:a};let i=[...o.values()].sort((u,p)=>u.lineNumber-p.lineNumber),l=[...r,...i],c=le(n,l,r.at(-1));return{kind:"continue",context:{...a,result:c}}}}d(U,"createAstScopePostReadHandler");function de(a,e){if(e.length===0)return a;let n=new Map,r=new Map;for(let t of e){let s=n.get(t.startLine)??[];s.push(t.beginAnchor.value),n.set(t.startLine,s);let o=r.get(t.startLine)??[];o.push({endLine:t.endLine,beginAnchor:t.beginAnchor.value,endAnchor:t.endScopeAnchor.value}),r.set(t.startLine,o);let i=n.get(t.endLine)??[];i.push(t.endScopeAnchor.value),n.set(t.endLine,i)}return a.map(t=>{let s=n.get(t.lineNumber),o=r.get(t.lineNumber);return s===void 0&&o===void 0?t:{...t,...s!==void 0&&{anchors:[...new Set([...t.anchors??[],...s])],presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${s.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...t.metadata,[X]:{...q(t),...o!==void 0&&{boundaries:o}}}}})}d(de,"addScopeMarkers");function q(a){let e=a?.metadata?.[X];if(!(typeof e!="object"||e===null))return e}d(q,"getAstScopeMetadata");function le(a,e,n){let r=a.content.length===1?a.content[0]:void 0;if(r?.type!=="text"||a.details.lines===void 0)return a;let t=e.slice(a.details.lines.length);if(t.length===0)return a;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
|
|
6
|
-
`,o=t.map((c,u)=>{let f=u===t.length-1?c.lineEnding:c.lineEnding||s,m=c.presentation?.prefix??"",g=c.presentation?.suffix??"";return`${m}${c.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(r.text)?"":s,l=`${r.text}${i}${o}`;return{...a,content:[{...r,text:l}],details:{...a.details,lines:e}}}d(le,"appendTextLines");var J=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function Y(a){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 J.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!J.test(e))return{kind:"not-handled"};try{let t=(await a.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}d(Y,"createAstScopeAnchorResolver");import{spawn as ue}from"node:child_process";import{readFile as pe,stat as W}from"node:fs/promises";import h from"node:path";function Q(a){return{id:"ast",async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let r=e.query.slice(4).trim();if(r.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let t=d(async i=>{let l=Date.now(),c=await me(r,e,n.cwd,i);c.sort((p,f)=>h.resolve(n.cwd,p.file).localeCompare(h.resolve(n.cwd,f.file))||p.range.byteOffset.start-f.range.byteOffset.start||p.range.byteOffset.end-f.range.byteOffset.end);let u=c.slice(0,e.limit??100);return{raw:u,matches:await fe(u,n.cwd,l,i),complete:c.length<=(e.limit??100)}},"collect"),s=await t(n.signal),o=await a({request:e,matches:s.matches,complete:s.complete,refresh:t},n);return{kind:"resolved",payload:{pattern:r,matches:s.raw.map((i,l)=>({...i,selection:s.matches[l]})),complete:s.complete,sessionId:o.id}}},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n};let r=n.matches.flatMap((t,s)=>[`SEARCH#${n.sessionId}:${String(s+1)}:match ${t.file}:${String(t.range.start.line+1)}:${String(t.range.start.column+1)} ${t.language}`,` ${t.lines.trim()}`]);return n.complete&&r.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),n.complete||r.push("Result limit reached."),{content:[{type:"text",text:r.join(`
|
|
7
|
-
`)}],details:n}}}}d(Q,"createAstSearchResolver");async function fe(a,e,n,r){let t=new Map;for(let s of a){let o=h.resolve(e,s.file);if(t.has(o))continue;let i=await W(o),l=await pe(o,{signal:r}),c=await W(o);if(i.mtimeMs>n||i.mtimeMs!==c.mtimeMs||i.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");t.set(o,l)}return a.map(s=>{let o=h.resolve(e,s.file),i=t.get(o);if(i===void 0)throw new Error("Missing AST source snapshot");let{start:l,end:c}=s.range.byteOffset;if(!Number.isInteger(l)||!Number.isInteger(c)||l<0||c<l||c>i.length||i.subarray(l,c).toString("utf8")!==s.text)throw new Error("AST range does not match its source snapshot. Search again.");let u=i.subarray(0,l).toString("utf8"),p=i.subarray(0,c).toString("utf8"),f=u.split(`
|
|
8
|
-
`).length;return{source:o,lineNumber:f,endLineNumber:p.split(`
|
|
9
|
-
`).length,startColumn:u.length-u.lastIndexOf(`
|
|
10
|
-
`)-1,endColumn:p.length-p.lastIndexOf(`
|
|
11
|
-
`)-1,matchedText:s.text,lineText:i.toString("utf8").split(`
|
|
12
|
-
`)[f-1]?.replace(/\r$/u,"")??""}})}d(fe,"selectionMatches");function me(a,e,n,r){let t=["run","--pattern",a,"--json=compact","--no-ignore","parent"];for(let s of Z(e.include))t.push("--globs",s);for(let s of Z(e.exclude))t.push("--globs",`!${s}`);return t.push(e.path??"."),new Promise((s,o)=>{let i=ue("ast-grep",t,{cwd:n,stdio:["ignore","pipe","pipe"]}),l="",c="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>l+=p),i.stderr.on("data",p=>c+=p);let u=d(()=>{i.kill("SIGTERM")},"abort");r?.addEventListener("abort",u,{once:!0}),i.once("error",o),i.once("close",p=>{if(r?.removeEventListener("abort",u),r?.aborted===!0){o(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){o(new Error(c.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(l.length===0?"[]":l);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");s(f)}catch(f){o(f instanceof Error?f:new Error(String(f)))}})})}d(me,"runAstGrep");function Z(a){return a?.split(",").map(e=>e.trim()).filter(Boolean)??[]}d(Z,"splitGlobs");var ge=$({kind:"code-view",label:"AST"});async function ee(a){let e=new V,n=K(e),r={protocol:k,apiVersion:P,id:"ast",setup(s){s.addResolver({resolver:F(),renderResult:ge}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),s.addView({view:"ast",presenter:n});let o=z();s.addOutputReducer(b);let i=U();s.addHandler({stage:"post-read",async handler(l){let c=await o(l);return c.kind==="return"?c:i(c.context)}}),s.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},t={protocol:I,apiVersion:C,id:"ast",setup(s){s.addAnchorResolver({resolver:Y(e),kind:N,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([M(a,r),E(a,G),_(a,t),D(a,{protocol:H,apiVersion:j,id:"ast-search",setup(s){s.addResolver({resolver:Q(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 captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}d(ee,"registerAst");export{ee as default};
|
|
1
|
+
import{e as P,f as x}from"./chunk-T7I2VX3J.js";import{a as T}from"./chunk-MGCHOGQD.js";import{a as E,b as h}from"./chunk-T6LX2RX5.js";import{a as S}from"./chunk-6CZO43OH.js";import{a as R,b as O}from"./chunk-OBNING2A.js";import{m as q}from"./chunk-5VSE5X5R.js";import{c as j,d as v,e as y}from"./chunk-N34ATN52.js";import{a as o}from"./chunk-EI7MMDWY.js";import C from"cross-spawn";import{fileURLToPath as L}from"node:url";var b=5e3,J=10*1024*1024,k=L(new URL(".",new URL("../src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts",import.meta.url).href));function _(r){let e=r?.filter(i=>i==="jq"||i.startsWith("jq:"))??[];if(e.length===0)return;if(e.length>1)throw new Error("Read accepts only one jq view");if(r?.length!==1)throw new Error("The jq view cannot be combined with other views");let t=e[0];if(t===void 0||t==="jq"||t.slice(3).trim().length===0)throw new Error('The jq view requires a filter, for example views: ["jq:.scripts"]');return{filter:t.slice(3)}}o(_,"parseJqView");function A(r,e,t){return t.signal?.aborted===!0?Promise.reject(new Error("jq execution was cancelled")):new Promise((i,d)=>{let s=C(t.command??"jq",["-L",k,"--",r],{cwd:t.cwd,env:V(t.cwd),shell:!1,stdio:["pipe","pipe","pipe"],windowsHide:!0}),a="",l="",u=!1,m=0,c=o(n=>{u||(u=!0,clearTimeout(p),t.signal?.removeEventListener("abort",g),n===void 0?i(a):d(n))},"finish"),f=o(n=>{s.kill(),c(n)},"stop"),g=o(()=>f(new Error("jq execution was cancelled")),"abort"),p=setTimeout(()=>f(new Error(`jq did not finish within ${b/1e3} seconds`)),b);p.unref(),t.signal?.addEventListener("abort",g,{once:!0}),s.stdout?.setEncoding("utf8"),s.stderr?.setEncoding("utf8"),s.stdout?.on("data",n=>{if(m+=Buffer.byteLength(n),m>J){f(new Error(`jq output exceeded ${J/1024/1024}MB`));return}a+=n}),s.stderr?.on("data",n=>{Buffer.byteLength(l)<16384&&(l+=n)}),s.once("error",n=>c(new Error(`Cannot start jq: ${n.message}`))),s.once("close",(n,w)=>{if(!u)if(n===0)c();else{let I=l.trim().split(/\r?\n/u).slice(0,8).join(`
|
|
2
|
+
`);c(new Error(I||`jq exited ${w===null?`with code ${String(n)}`:`after signal ${w}`}`))}}),s.stdin?.once("error",n=>c(new Error(`Cannot send JSON to jq: ${n.message}`))),s.stdin?.end(e)})}o(A,"executeJq");function V(r){let e=j(r,process.env),t={};for(let i of["PATH","PATHEXT","SystemRoot","SYSTEMROOT","WINDIR"])e[i]!==void 0&&(t[i]=e[i]);return t}o(V,"safeEnvironment");async function N(r){x(r,[await P({id:"json-reading",description:"Query and transform JSON resources with jq read views",triggers:[{tool:"read",viewPrefixes:["jq:"]}]})]),await Promise.all([S(r,B),T(r,$)])}o(N,"registerFilesystemJq");var B={protocol:R,apiVersion:O,id:"filesystem-jq",setup(r){r.addView({view:"jq",presenter:{id:"filesystem-jq",present:o(e=>e,"present")}}),r.addHandler({stage:"read",when:{resolvedBy:"filesystem",contentKind:"text"},async handler(e){let t=e.state;if(t?.contentKind!=="text")return{kind:"continue",context:e};let i;try{i=_(e.request.views)}catch(a){return D(t,a instanceof Error?a.message:String(a))}if(i===void 0)return{kind:"continue",context:e};let d;try{d=await A(i.filter,t.content[0].text,{cwd:e.resolverContext.cwd,...e.resolverContext.signal===void 0?{}:{signal:e.resolverContext.signal}})}catch(a){return D(t,a instanceof Error?a.message:String(a))}let s={...t,content:[{type:"text",text:d}],text:q(t.source,d),preserveTruncatedOutput:!0};return{kind:"continue",context:{...e,state:s}}}}),r.describe('JSON files accept views such as ["jq:.scripts | keys"] to query them with the installed jq executable.')}};function D(r,e){return{kind:"return",result:{content:[{type:"text",text:`jq failed: ${e}`}],details:{source:r.source,resolvedBy:r.resolvedBy,failure:{code:"READ_FAILED",source:r.source,resolverId:r.resolvedBy,pluginId:"filesystem-jq",stage:"read",message:e}},isError:!0}}}o(D,"jqFailure");var $={protocol:E,apiVersion:1,id:"filesystem-jq",setup(r){r.addSetupCheck({id:"jq",async inspect(e){return await v("jq",e.cwd,e.env)?{}:{actions:[{id:"jq-unavailable",message:"JSON jq views are unavailable because jq was not found"}]}}}),r.addCheck({id:"jq",title:"JSON jq views",async run(e){let t=await y("jq",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"jq is available",detail:t.detail}:{status:"fail",message:"jq is not available",detail:t.detail}]}})}};export{N as default};
|
package/dist/entry-28.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a as r}from"./chunk-BHSO2MDK.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
|
package/dist/entry-29.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as V,b as z,c as Q}from"./chunk-DEP55R35.js";import{a as O}from"./chunk-MGCHOGQD.js";import{a as L,b as N}from"./chunk-T6LX2RX5.js";import{a as j}from"./chunk-6CZO43OH.js";import{a as U,b as F}from"./chunk-OBNING2A.js";import{a as B}from"./chunk-L7JMDDSD.js";import{a as M,b as _}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Value as De}from"typebox/value";import{access as ne}from"node:fs/promises";import re from"node:path";var K={protocol:L,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await oe(e.cwd)?await $("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 D("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 oe(n){try{return await ne(re.join(n,".git")),!0}catch{return!1}}s(oe,"isGitProject");import{mkdtemp as ae,rm as ie,writeFile as se}from"node:fs/promises";import de 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 o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,r){let o=m.resolve(t,e),a=m.relative(this.repositoryRoot,o);return a===".."||a.startsWith(`..${m.sep}`)||m.isAbsolute(a)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(a.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 o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let a=ce(o.stdout);if(a===void 0)return{status:"untracked"};let i=await this.readBlob(a.blob,"HEAD",e,t);if(i.status!=="found")return i;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let d=ue(c.stdout);if(d.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=d.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:i.text,indexText:l,indexMode:u?.mode??a.mode}}async writeIndexFile(e,t,r,o){let a=await ae(m.join(de.tmpdir(),"pi-agent-index-")),i=m.join(a,"content");try{await se(i,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,i],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let d=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(d.code!==0)throw new Error(d.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await ie(a,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let a=await this.git(["cat-file","blob",e],o);return a.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:a.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:a.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function ce(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,o,a]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||a===void 0?void 0:{mode:r,blob:a,path:e.slice(t+1)}}s(ce,"parseTreeEntry");function ue(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,a]=e.slice(0,t).split(" ",3),i=Number(a);return r===void 0||o===void 0||!Number.isInteger(i)?[]:[{mode:r,blob:o,stage:i,path:e.slice(t+1)}]})}s(ue,"parseIndexEntries");function W(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(W,"extensionGitExecutor");var f=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await b.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.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=V(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 o=await this.inspect(e);if(o.status!=="applicable")return o;let a=o.groups.find(u=>u.selector===t);if(a===void 0)return A(t,o.groups.map(({selector:u})=>u));let i=r==="stage"?"staged":"unstaged";if(a.state===i)return{status:"unchanged",state:i,group:a};let c=x(a.segments[0]),d={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(d,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:le(u)}}return{status:"applied",state:i,group:a}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(d=>d.selector===t);if(o===void 0)return A(t,r.groups.map(({selector:d})=>d));let a=z(e.worktreeText,o);if(a===void 0)return A(t,r.groups.map(({selector:d})=>d));let i=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:i.headStart,headEnd:i.headEnd,replacementText:i.headText};return{status:"applied",worktreeText:a,group:o,...c!==void 0&&{indexUpdate:c}}}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 o=Q(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,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 le(n){return n instanceof Error?n.message:String(n)}s(le,"errorMessage");var T="pi-agent-ide-changes/change",ge=/^CHANGE#[0-9A-F]{4,64}$/,pe=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function Y(n){return{resolver:fe(s(async t=>{if(pe.test(t.source))return;let r=await f.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(Y,"createChangeAnchorRegistration");function fe(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(!ge.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 o=r.status==="applicable"?r.groups.find(a=>a.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(r){return{kind:"failed",error:r}}}}}s(fe,"createChangeAnchorResolver");import{diffLines as he}from"diff";var me="filesystem";function q(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==me)return e;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:ye(e,o.groups)}}}s(q,"createCurrentChangePresenter");function ye(n,e){let t=new Map;for(let r of e)xe(n,r,t);return{...n,lines:n.lines.map(r=>be(r,t.get(r.lineNumber)))}}s(ye,"presentChangeGroups");function xe(n,e,t){let r=x(e.segments[0]),o=he(r.headText,r.worktreeText),a=e.currentStartLine,i,c;for(let d of o){let u=ve(d.value);if(d.removed){let l=Te(n,a),g=R(t,l.lineNumber),p=l.after?g.after:g.before;for(let h of u){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:h}),i??=w,c=w}continue}if(d.added){for(let l of u){let g=R(t,a),p={kind:"current",lineNumber:a};g.added=!0,i??=p,c=p,a++}continue}a+=u.length}if(i!==void 0&&c!==void 0){let d=`${e.selector} \xB7 ${e.state}`;we(i,c)?I(t,i,`<!-- change: ${d} -->`):(I(t,i,`<!-- change-begin: ${d} -->`),I(t,c,`<!-- change-end: ${d} -->`))}}s(xe,"presentChangeGroup");function we(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(we,"sameTarget");function I(n,e,t){if(e.kind==="current"){R(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(I,"annotateTarget");function be(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(be,"presentLine");function R(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(R,"presentationsFor");function Te(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Te,"placementFor");function ve(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(ve,"splitLines");var v=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 Ce}from"node:crypto";import{realpathSync as ke}from"node:fs";import J from"node:path";import{fileURLToPath as Ee}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=X(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===C(e.before.content)?this.#e.set(t,{...r,afterDigest:C(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:C(e.after.content)})}restore(e,t,r){let o=X(e,t),a=this.#e.get(o);if(a===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(a.afterDigest!==C(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return a.before}};function X(n,e){return n.startsWith("file://")?Z(Ee(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:Z(J.resolve(e,n))}s(X,"sourceKey");function Z(n){try{return ke.native(n)}catch{return J.normalize(n)}}s(Z,"canonicalFile");function C(n){return Ce("sha256").update(n).digest("hex")}s(C,"textDigest");import{readFile as Pe}from"node:fs/promises";import Ae from"node:path";import{defineTool as Ge,withFileMutationQueue as Ie}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var P=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ee(n,e,t){n.registerTool(E("stage",e,t)),n.registerTool(E("unstage",e,t))}s(ee,"registerIndexChangeTools");function E(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return Ge({name:n,label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:P,async execute(a,i,c,d,u){let l=Re(i.file,u.cwd);return Ie(l,()=>t.run(async()=>{let g=await Pe(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let h=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},i.change,n);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${n} is not applicable to ${l}: ${h.reason}`);let w=h.status==="unchanged";return{content:[{type:"text",text:w?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:l,state:r,unchanged:w}}}))}})}s(E,"createIndexChangeTool");function Re(n,e){let t=n.startsWith("@")?n.slice(1):n;return Ae.resolve(e,t)}s(Re,"resolveFile");import{diffChars as Se}from"diff";import{Type as y}from"typebox";var He=y.Object({file:y.Optional(y.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:y.Optional(y.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:y.Optional(y.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function te(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:s(o=>o!==null&&typeof o=="object"&&"transaction"in o&&typeof o.transaction=="string","matches"),async execute(o,a){if(a.change!==void 0)throw new Error("transaction cannot be combined with change");let i=String(a.transaction),c=await r(i,o.signal);return{source:i,summary:`Restored ${String(c.restored.length)} paths from ${i}.`,data:{kind:"apply-undo",ok:!0,transaction:i,restored:c.restored}}}},parameters:He,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(o,a){if(a.change===void 0)throw new Error("change is required when transaction is omitted");let i=o.sourceFor("file"),c,d;if(a.change==="last")c=e.restore(i,o.cwd,o.sourceDocument.content);else{await o.resolveAnchor("change");let u=await f.create(n,o.cwd,o.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:i,worktreeText:o.sourceDocument.content,cwd:o.cwd,...o.signal!==void 0&&{signal:o.signal}},a.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;d=s(()=>t.run(()=>u.service.applyIndexUpdate(g,o.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:$e(o.sourceDocument.content,c),action:"edited"}]]),...d!==void 0&&{afterWrite:d}}}}}s(te,"createUndoMutationTool");function $e(n,e){let t=[],r=0,o,a=0,i="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+a,insert:i}),o=void 0,a=0,i="")},"flush");for(let d of Se(n,e)){if(!d.added&&!d.removed){c(),r+=d.value.length;continue}o??=r,d.removed?(r+=d.value.length,a+=d.value.length):i+=d.value}return c(),t}s($e,"createTextChanges");async function Le(n){let e=W(n),t=new k,r=new v,o=q(e),a=Y(e),i={protocol:U,apiVersion:F,id:"current-git-changes",setup(d){d.addView({view:"changes",presenter:o}),d.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:M,apiVersion:_,id:"current-git-changes",setup(d){d.addAnchorResolver({...a,kind:T,type:"auxiliary"}),d.onDidEdit(u=>{t.observe(u)}),d.addMutationTool(te(e,t,r,d.restoreApplyUndo));for(let u of["stage","unstage"]){let l=E(u,e,r);d.addScriptIndexOperation({name:u,parameters:P,execute:s((g,p,h)=>l.execute(`apply-${u}`,De.Decode(P,g),p,void 0,h),"execute")})}d.addTextPresenter({presenter:o})}};await Promise.all([O(n,K),j(n,i),B(n,c)]),ee(n,e,r)}s(Le,"registerGitChanges");export{Le as default};
|
|
1
|
+
import{v as t}from"./chunk-S3ZPXWX7.js";import{p as i}from"./chunk-5VSE5X5R.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
|
package/dist/entry-30.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-HKMBQLEK.js";import{a as h,b as v}from"./chunk-Z3VC3S2T.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:t}),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{b as e,c as o}from"./chunk-25CZ5ZIU.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};
|
package/dist/entry-31.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{b as D,c as V}from"./chunk-25CZ5ZIU.js";import{a as E}from"./chunk-MGCHOGQD.js";import{a as O,b as L}from"./chunk-T6LX2RX5.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as I,b as C,c as N}from"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as $}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as M}from"./chunk-6CZO43OH.js";import{a as k,b as P}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as B}from"./chunk-ZTYWHL2F.js";import{a as H,b as j}from"./chunk-7UGNGK7Y.js";import{a as S,b as R,c as w,l as v}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import"./chunk-KINKBPPX.js";import{j as T}from"./chunk-M5MJP7Z2.js";import"./chunk-WZI4YC2O.js";import{e as x}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";import{readFile as te}from"node:fs/promises";var ne={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"},y=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"]),G={protocol:O,apiVersion:1,id:"ast",setup(a){a.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(r=>y.has(r))?await T({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),a.addCheck({id:"parsers",title:"AST",async run(e){let n=[];for(let r of e.detectedLanguageIds){let t=ne[r];if(t!==void 0){n.push({status:"skip",message:`${r} AST is unavailable: ${t}`});continue}if(!y.has(r))continue;let s=e.files.find(o=>re(o,r));if(s!==void 0)try{let o=await te(s,"utf8"),i=await D(s,e.cwd,o.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`));n.push(i===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:s})}catch(o){n.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),a.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>y.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await x("ast-grep",["--version"],e.cwd,e.env);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 re(a,e){let n=a.slice(a.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}d(re,"matchesLanguage");var se,ae;function F(a){return{id:"ast",tryResolve(e,n){return Promise.resolve(oe(e,n,a))}}}d(F,"createAstOutlineResolver");function oe(a,e,n){let r;try{r=S(a,"ast")}catch(o){return{kind:"failed",error:o}}if(r===void 0)return{kind:"not-handled"};let t;try{t=R(r.path,e.cwd)}catch(o){return{kind:"failed",error:o}}return{kind:"resolved",resource:{source:w("ast",t),async read({signal:o}){o?.throwIfAborted();let i=await(ae??=import("./chunk-5QQABP47.js")),l=await(n??(se??=new i.AstOutlineManager)).readFileOutline(t,e.cwd);return o?.throwIfAborted(),[i.formatAstOutline(l)]}}}}d(oe,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ie,DEFAULT_MAX_LINES as ce,truncateHead as A}from"@earendil-works/pi-coding-agent";var b=d(async(a,e,n)=>{let{source:r,resolvedBy:t,lines:s,totalLines:o,startLine:i}=a.details;if(!(r===void 0||t!=="filesystem"||s===void 0||s.length!==o||i!==void 0&&i!==1))try{let{AstOutlineManager:c,isSupportedOutlinePath:l}=await import("./chunk-5QQABP47.js");if(!l(r))return;let u=d(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
|
|
5
|
+
`),"format");e.signal?.throwIfAborted();let p=await new c(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!A(u(m),n).truncated)),f=u(p);return A(f,n).truncated?void 0:{content:[{type:"text",text:f}],details:{source:r,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function z(){return async a=>{let{state:e,result:n}=a,r=n?.content.length===1?n.content[0]:void 0;if(a.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||r?.type!=="text"||!A(r.text).truncated)return{kind:"continue",context:a};let t=await b({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},a.resolverContext,{maxBytes:ie,maxLines:ce});return t===void 0?{kind:"continue",context:a}:{kind:"return",result:t}}}d(z,"createAstOverflowHandler");var X="pi-agent-ast";function K(a){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem")return e;try{let r=await a.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),t=de(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}d(K,"createAstScopePresenter");function U(){return a=>{let e=a.state,n=a.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:a};let r=n.details.lines;if(r===void 0)return{kind:"continue",context:a};let t=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(r.map(u=>u.lineNumber)),o=new Map;for(let u of r){let p=t.get(u.lineNumber),f=q(p);for(let m of f?.boundaries??[]){if(s.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&o.set(m.endLine,g)}}if(o.size===0)return{kind:"continue",context:a};let i=[...o.values()].sort((u,p)=>u.lineNumber-p.lineNumber),c=[...r,...i],l=le(n,c,r.at(-1));return{kind:"continue",context:{...a,result:l}}}}d(U,"createAstScopePostReadHandler");function de(a,e){if(e.length===0)return a;let n=new Map,r=new Map;for(let t of e){let s=n.get(t.startLine)??[];s.push(t.beginAnchor.value),n.set(t.startLine,s);let o=r.get(t.startLine)??[];o.push({endLine:t.endLine,beginAnchor:t.beginAnchor.value,endAnchor:t.endScopeAnchor.value}),r.set(t.startLine,o);let i=n.get(t.endLine)??[];i.push(t.endScopeAnchor.value),n.set(t.endLine,i)}return a.map(t=>{let s=n.get(t.lineNumber),o=r.get(t.lineNumber);return s===void 0&&o===void 0?t:{...t,...s!==void 0&&{anchors:[...new Set([...t.anchors??[],...s])],presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${s.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...t.metadata,[X]:{...q(t),...o!==void 0&&{boundaries:o}}}}})}d(de,"addScopeMarkers");function q(a){let e=a?.metadata?.[X];if(!(typeof e!="object"||e===null))return e}d(q,"getAstScopeMetadata");function le(a,e,n){let r=a.content.length===1?a.content[0]:void 0;if(r?.type!=="text"||a.details.lines===void 0)return a;let t=e.slice(a.details.lines.length);if(t.length===0)return a;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
|
|
6
|
+
`,o=t.map((l,u)=>{let f=u===t.length-1?l.lineEnding:l.lineEnding||s,m=l.presentation?.prefix??"",g=l.presentation?.suffix??"";return`${m}${l.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(r.text)?"":s,c=`${r.text}${i}${o}`;return{...a,content:[{...r,text:c}],details:{...a.details,lines:e}}}d(le,"appendTextLines");var W=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function J(a){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 W.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!W.test(e))return{kind:"not-handled"};try{let t=(await a.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}d(J,"createAstScopeAnchorResolver");import ue from"cross-spawn";import{readFile as pe,stat as Y}from"node:fs/promises";import h from"node:path";function Q(a){return{id:"ast",async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let r=e.query.slice(4).trim();if(r.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let t=d(async i=>{let c=await me(r,e,n.cwd,i);c.sort((u,p)=>h.resolve(n.cwd,u.file).localeCompare(h.resolve(n.cwd,p.file))||u.range.byteOffset.start-p.range.byteOffset.start||u.range.byteOffset.end-p.range.byteOffset.end);let l=c.slice(0,e.limit??100);return{raw:l,matches:await fe(l,n.cwd,i),complete:c.length<=(e.limit??100)}},"collect"),s=await t(n.signal),o=await a({request:e,matches:s.matches,complete:s.complete,refresh:t},n);return{kind:"resolved",payload:{pattern:r,matches:s.raw.map((i,c)=>({...i,selection:s.matches[c]})),complete:s.complete,sessionId:o.id}}},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n};let r=n.matches.flatMap((t,s)=>[`SEARCH#${n.sessionId}:${String(s+1)}:match ${t.file}:${String(t.range.start.line+1)}:${String(t.range.start.column+1)} ${t.language}`,` ${t.lines.trim()}`]);return n.complete&&r.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),n.complete||r.push("Result limit reached."),{content:[{type:"text",text:r.join(`
|
|
7
|
+
`)}],details:n}}}}d(Q,"createAstSearchResolver");async function fe(a,e,n){let r=new Map;for(let t of a){let s=h.resolve(e,t.file);if(r.has(s))continue;let o=await Y(s),i=await pe(s,{signal:n}),c=await Y(s);if(o.mtimeMs!==c.mtimeMs||o.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");r.set(s,i)}return a.map(t=>{let s=h.resolve(e,t.file),o=r.get(s);if(o===void 0)throw new Error("Missing AST source snapshot");let{start:i,end:c}=t.range.byteOffset;if(!Number.isInteger(i)||!Number.isInteger(c)||i<0||c<i||c>o.length||o.subarray(i,c).toString("utf8")!==t.text)throw new Error("AST range does not match its source snapshot. Search again.");let l=o.subarray(0,i).toString("utf8"),u=o.subarray(0,c).toString("utf8"),p=l.split(`
|
|
8
|
+
`).length;return{source:s,lineNumber:p,endLineNumber:u.split(`
|
|
9
|
+
`).length,startColumn:l.length-l.lastIndexOf(`
|
|
10
|
+
`)-1,endColumn:u.length-u.lastIndexOf(`
|
|
11
|
+
`)-1,matchedText:t.text,lineText:o.toString("utf8").split(`
|
|
12
|
+
`)[p-1]?.replace(/\r$/u,"")??""}})}d(fe,"selectionMatches");function me(a,e,n,r){let t=["run","--pattern",a,"--json=compact","--no-ignore","parent"];for(let s of Z(e.include))t.push("--globs",s);for(let s of Z(e.exclude))t.push("--globs",`!${s}`);return t.push(e.path??"."),new Promise((s,o)=>{let i=ue("ast-grep",t,{cwd:n,stdio:["ignore","pipe","pipe"]}),c="",l="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>c+=p),i.stderr.on("data",p=>l+=p);let u=d(()=>{i.kill("SIGTERM")},"abort");r?.addEventListener("abort",u,{once:!0}),i.once("error",o),i.once("close",p=>{if(r?.removeEventListener("abort",u),r?.aborted===!0){o(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){o(new Error(l.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(c.length===0?"[]":c);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");s(f)}catch(f){o(f instanceof Error?f:new Error(String(f)))}})})}d(me,"runAstGrep");function Z(a){return a?.split(",").map(e=>e.trim()).filter(Boolean)??[]}d(Z,"splitGlobs");var ge=$({kind:"code-view",label:"AST"});async function ee(a){let e=new V,n=K(e),r={protocol:k,apiVersion:P,id:"ast",setup(s){s.addResolver({resolver:F(),renderResult:ge}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),s.addView({view:"ast",presenter:n});let o=z();s.addOutputReducer(b);let i=U();s.addHandler({stage:"post-read",async handler(c){let l=await o(c);return l.kind==="return"?l:i(l.context)}}),s.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},t={protocol:I,apiVersion:C,id:"ast",setup(s){s.addAnchorResolver({resolver:J(e),kind:N,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([M(a,r),E(a,G),_(a,t),B(a,{protocol:H,apiVersion:j,id:"ast-search",setup(s){s.addResolver({resolver:Q(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 captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}d(ee,"registerAst");export{ee as default};
|
package/dist/entry-32.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-MGCHOGQD.js";import{a as T,b as N}from"./chunk-T6LX2RX5.js";import{a as L}from"./chunk-HKMBQLEK.js";import{a as j,b as P}from"./chunk-Z3VC3S2T.js";import{b as E,c as S,g as D,i as $,j as w,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 oe 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,r,f,s,l,o,d,x=[0,1],u,h){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:l,...d&&{dependencies:d},linter:{extensions:r,...h&&{fileNames:h},check:{command:f,successExitCodes:x},diagnostics:{format:s,...o&&{pattern:o},...u!==void 0&&{columnBase:u}}}}}a(c,"recipe");import b from"node:path";import{fileURLToPath as Y}from"node:url";function M(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return V(t);case"eslint-json":return B(t);case"sarif":return G(t);case"checkstyle":return W(t);case"gcc":case"clang":return Z(t);case"regex":return H(t,g(e.pattern),e.columnBase??1)}}a(M,"parseDiagnostics");function V(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(y):[]}a(V,"parsePiJson");function B(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>y(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}a(B,"parseEslintJson");function G(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,f=r?.region??{},s=i.message;return y({file:r?.artifactLocation?.uri,line:f.startLine,column:f.startColumn,message:s?.text,code:i.ruleId,severity:K(i.level)})}))}a(G,"parseSarif");function W(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=z(g(n[1])).name;for(let r of g(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let f=z(g(r[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(W,"parseCheckstyle");function z(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[g(e[1]),Q(g(e[2]))]))}a(z,"xmlAttributes");function Z(t){return U(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}a(Z,"parseCompilerLines");function H(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(H,"parseRegexLines");function U(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:y(i)})}a(U,"parseMatchingLines");function y(t){if(typeof t!="object"||t===null)return[];let e=t,n=_(e.line??e.startLine),i=_(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:q(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:X(e.severity)}]}a(y,"normalizeDiagnostic");function _(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}a(_,"numberValue");function q(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}a(q,"stringValue");function X(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(X,"severityValue");function K(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}a(K,"sarifSeverity");function Q(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(Q,"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",o=>A(o).linters,n),r=n.environment??process.env,f=await Promise.all(i.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await w(o.config.check,e,r)}))),s=await R(e,p),l=[...i.entries].sort((o,d)=>o.layer==="built-in"&&d.layer==="built-in"?(s.get(d.id)?.score??0)-(s.get(o.id)?.score??0):0);return new t(l,new Set(f.filter(o=>o.available&&(!n.requireBuiltInEvidence||(s.get(o.id)?.score??0)>0)).map(o=>o.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{n=await I(t.check,e)}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,r;try{r=M(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||r.length>0),s=t.check.cwd==="file"?b.dirname(e.filePath):e.projectRoot;return r=r.filter(l=>{if(l.file===void 0)return!0;let o=l.file.startsWith("file:")?Y(l.file):l.file;return b.resolve(s,o)===b.resolve(e.filePath)}).map(({file:l,...o})=>o),{ok:f,diagnostics:r,...!f&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}a(k,"runConfiguredLinter");function F(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let f=n===!0&&r.fix!==void 0?r.fix:r.check,s=await k({...r,check:f},{projectRoot:i.cwd,filePath:e});return{ok:s.ok,diagnostics:s.diagnostics}}}}a(F,"createCommandLinter");import{copyFile as ee,mkdtemp as te,rm as ne}from"node:fs/promises";import C from"node:path";var J={protocol:T,apiVersion:1,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:ie}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=re(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:r,source:f})=>{let s=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,l=await te(C.join(C.dirname(f),".pi-agent-ide-doctor-")),o=C.join(l,C.basename(f));try{await ee(f,o);let d=await k(r.config,{projectRoot:e.cwd,filePath:o,env:e.env});return d.ok?{status:"pass",message:`${s}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${s}: probe failed`,detail:d.failure??r.sourcePath}}catch(d){return{status:"fail",message:`${s}: ${d instanceof Error?d.message:String(d)}`,detail:r.sourcePath}}finally{await ne(l,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function ie(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,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:r,toolId:s.id}),await w(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(ie,"inspectLinterSetup");function re(t,e,n){let i=new Map;for(let r of e){let f=t.resolveEntry(r,n);f!==void 0&&!i.has(f.id)&&i.set(f.id,{entry:f,source:r})}return[...i.values()]}a(re,"applicableLinters");async function se(t){let e=new Map,n=a((s,l=!1)=>{let o=JSON.stringify([s,l]),d=e.get(o);return d===void 0&&(d=le(s,l),e.set(o,d)),d},"registryFor"),i=a(async(s,l)=>{let o=await S(l,s,"linters",p);return o===void 0?void 0:{projectRoot:o,external:o!==oe.resolve(l)}},"resolveProject"),r={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 o=await i(s.filePath,l.cwd);if(o===void 0)return{ok:!0,diagnostics:[]};let d=await n(o.projectRoot,o.external);return F(d).lint(s,{cwd:o.projectRoot})}},f={protocol:j,apiVersion:4,id:"lint",setup(s){s.addTool(r),s.addDiagnosticSource({id:"lint",async diagnose(l,o){let d=await i(l,o.cwd);if(d===void 0)return{status:"unavailable",diagnostics:[],reason:"No local linter project found for this file"};let x=await n(d.projectRoot,d.external);o.signal.throwIfAborted();let u=x.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:o.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([L(t,f),O(t,J)])}a(se,"registerLint");async function le(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:e})}a(le,"loadRegistry");export{se 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-33.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import{a as xe}from"./chunk-MGCHOGQD.js";import{a as _e,b as ke}from"./chunk-T6LX2RX5.js";import"./chunk-NNCZYO4Q.js";import{d as Ie}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as Ee}from"./chunk-6CZO43OH.js";import{a as Ce,b as De}from"./chunk-OBNING2A.js";import{a as qe}from"./chunk-ZTYWHL2F.js";import{a as Te,b as Oe}from"./chunk-7UGNGK7Y.js";import{a as Ae}from"./chunk-L7JMDDSD.js";import{a as je,b as Me,d as $e}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import{a as D,b as E,c as $,d as k,j as me,k as fe,l as he}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as be}from"./chunk-HKMBQLEK.js";import{a as ye,b as ve}from"./chunk-Z3VC3S2T.js";import"./chunk-KINKBPPX.js";import{b as Le,c as Se,g as Re,j as U,o as Pe}from"./chunk-M5MJP7Z2.js";import{a as we}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as v}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import sr from"node:path";var A=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},m("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),m("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},m("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),m("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),m("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),m("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),m("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),m("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),m("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),m("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),m("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),m("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),m("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),m("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),m("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),m("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),m("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),m("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),m("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),m("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),m("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),m("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),m("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),m("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),m("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),m("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),m("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),m("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),m("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),m("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),m("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),m("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),m("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function m(r,e,t,n,s,i,o,u,a,l){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:o,...u&&{dependencies:u},lsp:{command:i,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...l&&{settings:l}}}}c(m,"recipe");import St from"node:path";import Rt from"cross-spawn";import{createMessageConnection as Pt,CancellationTokenSource as _t,StreamMessageReader as kt}from"vscode-jsonrpc/node";import{URI as Ne}from"vscode-uri";import{watch as vt}from"node:fs";import{readdir as bt,stat as wt}from"node:fs/promises";import I from"node:path";import{URI as X}from"vscode-uri";var H=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let i=s.globPattern,o=typeof i=="string"?this.root:X.parse(typeof i.baseUri=="string"?i.baseUri:i.baseUri.uri).fsPath,u=typeof i=="string"?i:i.pattern,a=c(p=>I.matchesGlob(I.isAbsolute(u)?I.join(o,p):p,u),"matches"),l=new Set((await bt(o,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=vt(o,{recursive:!0},(p,g)=>{!g||!a(g)||wt(I.join(o,g)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let h=l.has(g)?2:1;l.add(g),(s.kind??7)&(h===1?1:2)&&this.changed({uri:X.file(I.join(o,g)).toString(),type:h})},h=>{if(this.registrations.get(e)?.includes(d)){if(h.code!=="ENOENT"){this.failed(h);return}l.delete(g)&&(s.kind??7)&4&&this.changed({uri:X.file(I.join(o,g)).toString(),type:3})}})});d.on("error",this.failed),n.push(d)}}catch(s){for(let i of n)i.close();throw s}this.unregister(e),this.registrations.set(e,n)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Lt}from"vscode-jsonrpc/node";var G=class extends Lt{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var x=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return Le(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=v(this._command[0]),t=Ne.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:St.basename(t)||t}],s=Rt(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:Pe({command:this._command,env:this._env},t,process.env)});this._process=s;let i=xt(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,l)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await i;let o=Pt(new kt(v(s.stdout)),new G(v(s.stdin),a=>{this._connection!==o||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),o.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=o,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new H(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let l of a.registrations)if(l.method!=="workspace/didChangeConfiguration"){if(l.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${l.method}`);await this._fileWatchers?.register(l.id,l.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let l of a.unregisterations)this._fileWatchers?.unregister(l.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(l=>{let d=this._settings??null;for(let p of l.section?.split(".").filter(Boolean)??[])d=typeof d=="object"&&d!==null?d[p]??null:null;return d})),this._connection.listen(),this._connection.onNotification((a,...l)=>{if(a==="textDocument/publishDiagnostics"){let d=l[0];d&&typeof d.uri=="string"&&Array.isArray(d.diagnostics)&&this._documentVersions.has(d.uri)&&(d.version===void 0||d.version===this.documentVersion(d.uri))&&this._diagnosticPublications.set(d.uri,{diagnostics:d.diagnostics,...typeof d.version=="number"&&{version:d.version}})}for(let d of this._handlers.get(a)??[])d(l[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let u=await Ve(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`).catch(a=>{let l=this._stderr.trim();throw l?new Error(`[lsp] ${this.serverId}: ${l}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:u.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);this._initialized=!0,this._serverCapabilities=u.capabilities,this._diagnosticMode=u.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return v(this._connection).sendRequest(e,t);let s=new _t,i;try{let o=v(this._connection).sendRequest(e,t,s.token);return await Promise.race([o,new Promise((u,a)=>{i=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",i,{once:!0})})])}finally{i&&n.removeEventListener("abort",i),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Ne.file(e).toString()}openDocument(e,t,n,s=1){let i=this._documentVersions.get(e);if(i!==void 0){this.changeDocument(e,t,Math.max(s,i+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let i=this._documentVersions.get(e);i===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,i+1);let o=this._serverCapabilities?.textDocumentSync,u=typeof o=="object"&&o!==null?o.save:void 0;s&&u&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof u=="object"&&u.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),i=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:i},contentChanges:[{text:t}]}),this._documentVersions.set(e,i),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await Ve(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null}}dispose(){this.shutdown()}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function xt(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",i)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),i=c(o=>{n(),t(o)},"onError");r.once("spawn",s),r.once("error",i)})}c(xt,"waitForSpawn");function Ve(r,e,t){return new Promise((n,s)=>{let i=setTimeout(()=>{s(new Error(t))},e);r.then(o=>{clearTimeout(i),n(o)}).catch(o=>{clearTimeout(i),s(o instanceof Error?o:new Error(String(o)))})})}c(Ve,"withTimeout");import{readFile as We}from"node:fs/promises";import{URI as ze}from"vscode-uri";var T={Error:1,Warning:2,Information:3,Hint:4};var Fe={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let i=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!Y(i)||i.success!==!0||!Array.isArray(i.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return i.body.map(Ct)}))).flat()}};function B(r){return r.supportsCommand(Fe.command)?Fe:void 0}c(B,"completedDiagnosticAdapter");function Ct(r){if(!Y(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!Y(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(Ct,"convertTypeScriptDiagnostic");function Y(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(Y,"isRecord");async function O(r,e,t,n={}){let s=new AbortController,i=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),o=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await Dt(r,e,t,n.content,i)}finally{clearTimeout(o)}}c(O,"requestDiagnostics");async function Dt(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let l=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),Ue(l.items,!1,!0)}catch(l){if(!Et(l))throw l;r.setDiagnosticMode("push")}}let i=B(r);if(i){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await We(ze.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),l=await i.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}s.throwIfAborted();let o=r.documentVersion(e)!==void 0,u=o?void 0:n??await We(ze.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,l)=>{let d=r.documentVersion(e)??1,p=c(f=>{let w=f;w.uri!==e||!Array.isArray(w.diagnostics)||w.version!==void 0&&w.version!==d||r.documentVersion(e)===d&&(y(),a(Ue(w.diagnostics,w.version===void 0)))},"receive"),g=r.onNotification("textDocument/publishDiagnostics",p),h=c(()=>{y(),l(s.reason)},"onAbort");function y(){g(),s.removeEventListener("abort",h)}c(y,"cleanup"),s.addEventListener("abort",h,{once:!0});try{o||r.syncDocument(e,u??"",t??"plaintext");let f=r.diagnosticPublication(e);f&&p({uri:e,...f})}catch(f){y(),l(f)}})}finally{r.endDiagnosticRequest(e)}}c(Dt,"requestCurrentDiagnostics");function Q(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===T.Warning?"warning":r.severity===T.Information?"info":r.severity===T.Hint?"hint":"error"}}c(Q,"toDiagnostic");function Ue(r,e,t=!1){let n=r.map(Q);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(Ue,"classify");function Et(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(Et,"isMethodNotFound");var It={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function P(r){return It[r]??`SymbolKind(${r})`}c(P,"symbolKindName");async function Z(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(Z,"requestDocumentSymbols");async function ee(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(ee,"requestWorkspaceSymbols");async function te(r,e,t,n){return await r.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:n})}c(te,"requestRename");import S from"node:path";import{URI as At}from"vscode-uri";import{readdir as jt,stat as Mt}from"node:fs/promises";import q from"node:path";import{URI as re}from"vscode-uri";function He(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,i])=>[s,t(i)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(He,"resolveInitializationOptions");var C=class r{constructor(e){this._registry=e}static{c(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),i=n==="symbols"?s[0]:s.find(p=>p.config.capabilities.includes(n));if(!i)return null;let o=re.file(t).toString(),u=`${i.serverId}:${o}`,a=this._clientStarts.get(u);if(a)return a;let l=this._clients.get(u);if(l?.ready)return l;let d=this._startClient(u,o,i,l);this._clientStarts.set(u,d);try{return await d}finally{this._clientStarts.get(u)===d&&this._clientStarts.delete(u)}}async _startClient(e,t,n,s){let i=s??new x({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:He(n.config.initializationOptions,re.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await i.start()}catch(o){throw await i.shutdown().catch(()=>{}),o}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async getWorkspaceClients(e,t="symbols",n=e){let s=new Set,i=new Set(this._registry.knownExtensions),o=new Set([".git",".cache","node_modules","dist","build"]),u=c(async l=>{if(i.size===0)return;let d;try{d=await jt(l,{withFileTypes:!0})}catch{return}for(let p of d){if(i.size===0)return;if(p.isDirectory()){o.has(p.name)||await u(q.join(l,p.name));continue}if(!p.isFile())continue;let g=q.extname(p.name).toLowerCase();if(!i.has(g))continue;let h=q.join(l,p.name),y=await this.openFile(h,e,t).catch(()=>null);y&&(s.add(y.client),i.delete(g))}},"visit"),a=q.resolve(e,n);if((await Mt(a)).isFile()){let l=await this.openFile(a,e,t);return l===null?[]:[l.client]}return await u(a),[...s]}async prepareWorkspaceSymbols(e,t=e){return this.getWorkspaceClients(e,"symbols",t)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=q.resolve(t,e),i=await this.getOrStart(s,t,n);if(!i)return null;let o=i.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:l}=await import("node:fs/promises"),d=await l(s,"utf8");i.openDocument(o,d,a),this._openDocs.add(o)}catch{}return{client:i,uri:o,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let i=$t(s);if(!i||t.hasActiveDiagnosticRequest(i.uri))return;let o=t.documentVersion(i.uri);if(i.version!==void 0&&o!==void 0&&i.version<o)return;let u=`${e}:${i.uri}`,a=i.diagnostics.map(Q),l=JSON.stringify([i.version,o,a]);if(this._pushFingerprints.get(u)===l)return;this._pushFingerprints.set(u,l);let d={cwd:re.parse(t.rootUri).fsPath,serverId:t.serverId,uri:i.uri,diagnostics:a,...i.version!==void 0&&{version:i.version}};for(let p of this._pushHandlers)p(d)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function $t(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c($t,"parsePushNotification");async function N(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(N,"requestReferences");async function ne(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,o]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:i??[],outgoing:o??[]}}c(ne,"requestCallHierarchy");function Ge(r,e,t){let n=S.relative(S.resolve(e,t.path??"."),r);if(n===".."||n.startsWith(`..${S.sep}`)||S.isAbsolute(n))return!1;let s=S.relative(e,r).split(S.sep).join("/"),i=c(o=>o.split(",").some(u=>{let a=u.trim();return a.length>0&&S.matchesGlob(a.includes("/")?s:S.basename(r),a)}),"matches");return(t.include===void 0||i(t.include))&&(t.exclude===void 0||!i(t.exclude))}c(Ge,"withinScope");function J(r){try{return At.parse(r).fsPath}catch{return r.startsWith("file://")?decodeURIComponent(r.slice(7)):r}}c(J,"uriToFilePath");function Be(r,e,t,n,s){let i=J(t),o=S.relative(r,i);return{filePath:o.startsWith("..")?i:o,lineNumber:n+1,column:s+1,kind:String(e.kind),name:e.name}}c(Be,"toHit");async function se(r,e,t,n,s={},i=C.getInstance()){if(n?.aborted)throw new Error("Operation aborted");let o=await i.prepareWorkspaceSymbols(e,s.path??e),u=[];for(let d of o){if(n?.aborted)throw new Error("Operation aborted");try{u.push(...await ee(d,r,Number.MAX_SAFE_INTEGER))}catch{}}let a=new Set,l=[];for(let d of u){if(n?.aborted)throw new Error("Operation aborted");if(l.length>=t)break;let p=d.location,g=Be(e,d,p.uri,p.range.start.line,p.range.start.character),h=`${g.filePath}:${g.lineNumber}:${g.column}`;if(Ge(J(p.uri),e,s)&&!a.has(h)&&(a.add(h),l.push(g)),l.length>=t)break;let y=J(p.uri),f=await i.openFile(y,e,"symbols").catch(()=>null);if(!f)continue;let w=await N(f.client,f.uri,p.range.start).catch(()=>[]);for(let R of w){let z=Be(e,d,R.uri,R.range.start.line,R.range.start.character),ge=`${z.filePath}:${z.lineNumber}:${z.column}`;if(Ge(J(R.uri),e,s)&&!a.has(ge)&&(a.add(ge),l.push(z)),l.length>=t)break}}return l}c(se,"searchSymbols");import{readFile as V}from"node:fs/promises";import j from"node:path";import{fileURLToPath as Tt}from"node:url";var Ot={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},ie=10,oe=5,M=10;async function Xe(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath),a=await V(o.filePath,"utf8");if(L(s),i!==a)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:u.range,content:a}}c(Xe,"resolveLspDeclaration");async function Ye(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath);if(i!==await V(e,"utf8"))throw new Error("The rename source changed during resolution.");return L(s),{client:o.client,uri:o.uri,position:u.selectionRange.start,content:i}}c(Ye,"resolveLspRenameTarget");async function le(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await zt(i.filePath);L(s);let a=o.range.start.line+1,l=Math.min(o.range.end.line+1,u.lines.length),d=u.lines.slice(Math.max(0,a-1),Math.max(0,l)).map((g,h)=>{let y=a+h;return me({content:g,sourceLine:{source:i.filePath,lineNumber:y,content:g}})}),p={path:i.displayPath,heading:`symbol: ${k(o.selector)}`,details:[`defined in: ${i.displayPath}:${a}-${l} (${P(o.kind)})`],startLine:a,endLine:l,totalLines:u.lines.length,renderedLines:d};return fe([p],Ot)}c(le,"readLspSymbolBody");async function de(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await tt(i,o,s),a=new K(n);return await qt(i,o,u,a)}c(de,"readLspSymbolGraph");async function ue(r,e,t,n){L(n);let s=await W(r,e,t),i=new K(t),o=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let u of s.symbols){L(n);let a=await tt(s,u,n);o.push("",...await Wt(s,u,a,i))}return o.join(`
|
|
2
|
-
`)}c(ue,"readLspFileGraph");function F(r,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let i=et(r,v(e[0]));if(i.length===1)return v(i[0]);throw i.length>1?new Error(`Symbol selector "${k(e)}" is ambiguous in ${t}; use parent/child.`):Je(e,t)}let n=r,s;for(let i of e){let o=n.filter(u=>u.name===i);if(o.length===0)throw Je(e,t);if(o.length>1)throw new Error(`Symbol selector "${k(e)}" is ambiguous at "${i}" in ${t}.`);s=v(o[0]),n=s.children}return v(s)}c(F,"resolveLspCodeSymbol");async function W(r,e,t){let n=j.isAbsolute(e)?j.normalize(e):j.resolve(t,e),s=await r.openFile(n,t,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${ce(n,t)}.`);let i=await Z(s.client,s.uri),o=Qe(i).sort(Ze);return{client:s.client,uri:s.uri,filePath:n,displayPath:ce(n,t),symbols:o}}c(W,"openCodeDocument");function Qe(r,e=[]){return r.flatMap(t=>{let n=t.selectionRange??t.range;if(!n)return[];let s=t.range??n,i=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:n,selector:i,children:Qe(t.children??[],i).sort(Ze)}]})}c(Qe,"normalizeDocumentSymbols");function Ze(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(Ze,"compareSymbols");function et(r,e){return r.flatMap(t=>[...t.name===e?[t]:[],...et(t.children,e)])}c(et,"collectNamedSymbols");function Je(r,e){return new Error(`Symbol "${k(r)}" was not found in ${e}.`)}c(Je,"symbolNotFound");async function tt(r,e,t){let n=e.selectionRange.start,[s,i]=await Promise.all([Ke(N(r.client,r.uri,n),[],t),Ke(ne(r.client,r.uri,n),{items:[],incoming:[],outgoing:[]},t)]);return L(t),{references:s,calls:i}}c(tt,"queryRelations");async function Ke(r,e,t){try{let n=await r;return L(t),n}catch(n){if(t?.aborted===!0)throw nt(t,n);return e}}c(Ke,"optionalRequest");async function qt(r,e,t,n){let s=k(e.selector),i=await n.line(r.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${r.displayPath} ${i} (${P(e.kind)})`,`Source: ${$("graph",r.displayPath,e.selector)}`,"",...await Nt(t.references,n),"",...await Vt(t.calls.incoming,n),"",...await Ft(t.calls.outgoing,n)].join(`
|
|
3
|
-
`)}c(qt,"formatSymbolGraph");async function Nt(r,e){let t=rt(r),n=[`References: ${r.length} in ${t.length} file(s)`];for(let[s,i]of t.slice(0,ie)){n.push(`- ${e.display(s)} (${i.length})`);for(let o of i.slice(0,oe))n.push(` - ${await e.line(s,o.range.start.line+1)}`);i.length>oe&&n.push(` - ... ${i.length-oe} more`)}return t.length>ie&&n.push(`- ... ${t.length-ie} more file(s)`),n}c(Nt,"formatReferences");async function Vt(r,e){let t=[`Incoming calls: ${r.length}`];for(let n of r.slice(0,M)){let s=n.fromRanges[0]?.start.line??n.from.selectionRange.start.line,i=await e.line(n.from.uri,s+1);t.push(`- ${P(n.from.kind)} ${n.from.name} \u2014 ${e.display(n.from.uri)} ${i}`)}return r.length>M&&t.push(`- ... ${r.length-M} more`),t}c(Vt,"formatIncomingCalls");async function Ft(r,e){let t=[`Outgoing calls: ${r.length}`];for(let n of r.slice(0,M)){let s=await e.line(n.to.uri,n.to.selectionRange.start.line+1);t.push(`- ${P(n.to.kind)} ${n.to.name} \u2014 ${e.display(n.to.uri)} ${s}`)}return r.length>M&&t.push(`- ... ${r.length-M} more`),t}c(Ft,"formatOutgoingCalls");async function Wt(r,e,t,n){let s=P(e.kind),i=await n.line(r.uri,e.selectionRange.start.line+1),o=rt(t.references).map(([d,p])=>`${n.display(d)} (${p.length})`),u=t.calls.incoming.map(d=>`${d.from.name} (${n.display(d.from.uri)})`),a=t.calls.outgoing.map(d=>`${d.to.name} (${n.display(d.to.uri)})`),l=[`### ${s} ${e.name}`,`Selector: ${k(e.selector)}`,`Definition: ${i}`,`Used by: ${ae(o)}`,`Incoming calls: ${ae(u)}`,`Outgoing calls: ${ae(a)}`];if(e.children.length>0){l.push("Members:");for(let d of e.children){let p=$("graph",r.displayPath,d.selector);l.push(`- ${P(d.kind)} ${d.name} \u2014 ${p}`)}}return l}c(Wt,"formatFileGraphSymbol");function ae(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(ae,"summarize");function rt(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,i)=>s.range.start.line-i.range.start.line||s.range.start.character-i.range.start.character)]).sort(([t],[n])=>t.localeCompare(n))}c(rt,"groupLocationsByUri");async function zt(r){let e=await V(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(zt,"readTextFile");var K=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return ce(Ut(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function Ut(r){if(!r.startsWith("file://"))return r;try{return Tt(r)}catch{return decodeURIComponent(r.slice(7))}}c(Ut,"filePathFromUri");function ce(r,e){let t=j.relative(e,r);return t.length===0||t.startsWith("..")||j.isAbsolute(t)?r:t.replaceAll(j.sep,"/")}c(ce,"displayFilePath");function L(r){if(r?.aborted===!0)throw nt(r)}c(L,"throwIfAborted");function nt(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(nt,"abortReason");function pe(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await Ht(t,n,r);if(!s)return Gt();let{client:i,diagnostics:o,syntaxErrors:u,otherDiagnostics:a}=s;return e=i,{ok:!o.some(l=>l.severity==="error"),diagnostics:o,syntaxErrors:u,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(pe,"createLspCompiler");async function Ht(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await O(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(Ht,"openAndDiagnose");function Gt(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(Gt,"skipOk");import b from"node:path";import{existsSync as Bt}from"node:fs";function st(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[i,o]of Object.entries(s.languages))for(let u of o.extensions){let a=u.toLowerCase(),l=e.get(a);if(l!==void 0&&l!==i)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${l}" and "${i}"`);e.set(a,i);let d=t.get(a)??[];d.push(n),t.set(a,d)}return{extToLanguageId:e,extToServerIds:t}}c(st,"buildLanguageLookup");var _=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(i=>i.layer!=="built-in"||t.has(i.id));this._servers=Object.fromEntries(s.map(i=>[i.id,i.config])),this._lookup=st(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await Re(e,"lsp-servers",u=>Jt(u).servers,t),s=t.environment??process.env,i=await Promise.all(n.entries.filter(u=>u.layer==="built-in").map(async u=>({id:u.id,available:await U(u.config,e,s)}))),o=t.requireBuiltInEvidence?await we(e,t.recipes??[]):void 0;return new r(n.entries,new Set(i.filter(u=>u.available&&(o===void 0||(o.get(u.id)?.score??0)>0)).map(u=>u.id)),b.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,b.resolve(t))}resolve(e){let t=b.basename(e),n=b.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(o=>process.platform==="win32"?o.toLowerCase():o,"normalizeName"),i=[];for(let o of this._entries)if(this._servers[o.id]&&!(o.config.requireRootMarker&&!this.hasRootMarker(e,o.config.rootMarkers))){for(let[u,a]of Object.entries(o.config.languages))if(a.extensions.some(l=>l.toLowerCase()===n.toLowerCase())||a.fileNames?.some(l=>s(l)===s(t))){i.push({serverId:o.id,config:o.config,languageId:u,layer:o.layer,sourcePath:o.sourcePath});break}}return i}hasRootMarker(e,t){let n=b.dirname(b.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(b.sep)&&(n=this._projectRoot);;){let s=b.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${b.sep}`)||b.isAbsolute(s))return!1;if(t.some(i=>Bt(b.join(n,i))))return!0;if(n===this._projectRoot)return!1;n=b.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function Jt(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(i=>typeof i!="string"||i.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(i=>typeof i!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[i,o]of Object.entries(s.languages)){let u=typeof o=="object"&&o!==null&&!Array.isArray(o)?o.extensions:void 0;if(!Array.isArray(u)||u.length===0||u.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${i} requires extensions`);let a=o.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${i}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(Jt,"parseLspConfig");function it(r){return at("symbol","lsp-symbol",r,async e=>await le(e.manager,e.filePath,v(e.selector),e.cwd,e.signal))}c(it,"createLspSymbolResolver");function ot(r){return at("graph","lsp-graph",r,async e=>e.selector===void 0?await ue(e.manager,e.filePath,e.cwd,e.signal):await de(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(ot,"createLspGraphResolver");function at(r,e,t,n){return{id:e,tryResolve(s,i){return Promise.resolve(Kt(s,i,r,t,n))}}}c(at,"createCodeViewResolver");function Kt(r,e,t,n,s){let i;try{i=D(r,t)}catch(a){return{kind:"failed",error:a}}if(i===void 0)return{kind:"not-handled"};let o;try{o=E(i.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:$(t,o,i.selector),async read(a){let l=await n(e.cwd),d=await s({manager:l,filePath:o,cwd:e.cwd,...Xt(i.selector),...Yt(a.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}c(Kt,"resolveCodeViewSource");function Xt(r){return r===void 0?{}:{selector:r}}c(Xt,"optionalSelector");function Yt(r){return r===void 0?{}:{signal:r}}c(Yt,"optionalSignal");function lt(r,e=(t,n)=>Promise.resolve({cwd:n,external:!1})){return{id:"lsp",async diagnose(t,n){let s=await e(t,n.cwd);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let i=await r(s.cwd,s.external);n.signal.throwIfAborted();let o=await i.getOrStart(t,s.cwd,"diagnostics");if(n.signal.throwIfAborted(),!o)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let u=o.toUri(t),a=i.languageId(t);o.syncDocument(u,n.content,a,!0);let l=o.documentVersion(u),d={active:!0,queued:!1},p=c(()=>!n.signal.aborted&&o.documentVersion(u)===l,"current"),g=c(()=>O(o,u,a,{signal:n.signal,content:n.content}),"request"),h=c(async()=>{if(d.queued=!0,!d.active){d.active=!0;try{for(;d.queued&&p();){d.queued=!1;let f=await g();p()&&n.publish(ct(f,o.commandName))}}catch(f){p()&&n.publish({status:"unavailable",diagnostics:[],reason:f instanceof Error?f.message:String(f),source:o.commandName})}finally{d.active=!1}}},"refresh"),y=i.onPushDiagnostics(f=>{!p()||f.uri!==u||f.serverId!==o.serverId||f.cwd!==s.cwd||f.version!==void 0&&f.version!==l||(o.diagnosticMode==="pull"||B(o)?h():n.publish({status:"snapshot",diagnostics:f.diagnostics,source:o.commandName,reason:dt(f.version===void 0)}))});n.signal.addEventListener("abort",y,{once:!0});try{let f=await g();return l=o.documentVersion(u),ct(f,o.commandName)}catch(f){throw d.queued=!1,y(),n.signal.removeEventListener("abort",y),f}finally{d.active=!1,d.queued&&p()&&queueMicrotask(()=>{h()})}}}}c(lt,"createLspDiagnosticSource");function dt(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(dt,"snapshotReason");function ct(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:dt(r.unversioned),source:e}}c(ct,"toReport");import{URI as Qt}from"vscode-uri";var ut={protocol:_e,apiVersion:1,id:"lsp",setup(r){for(let e of A)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Zt}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await _.fromPackageDir(e.cwd,{environment:e.env}),n=er(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let i=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,o=new x({serverId:s.serverId,rootUri:Qt.file(e.cwd).toString(),command:s.config.command,env:tr(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await o.start(),{status:"pass",message:`${i}: initialized`,detail:s.sourcePath}}catch(u){return{status:"fail",message:`${i}: ${u instanceof Error?u.message:String(u)}`,detail:s.sourcePath}}finally{await o.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function Zt(r){try{let e=await _.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,i]of r.detectedLanguages){let o=i.flatMap(u=>e.resolve(u)).find(u=>u.languageId===s);o!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:o.serverId}),await U(o.config,r.cwd,r.env)||n.set(o.serverId,{id:`lsp-${o.serverId}-unavailable`,message:`Configured language server ${o.serverId} cannot run ${JSON.stringify(o.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(Zt,"inspectLspSetup");function er(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(er,"applicableServers");function tr(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(tr,"definedEnvironment");function pt(r){return{id:"symbols",async tryResolve(e,t){if(!e.query.startsWith("symbols:"))return{kind:"not-handled"};let n=e.query.slice(8).trim();if(n.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let s=await r(t.cwd),i=await se(n,t.cwd,e.limit??100,t.signal,e,s);return{kind:"resolved",payload:{query:n,hits:i}}},format(e){let{query:t,hits:n}=e;return{content:[{type:"text",text:n.length===0?"No symbols found.":n.map((i,o)=>`${String(o+1)}. ${i.filePath}:${String(i.lineNumber)}:${String(i.column)} ${i.kind} ${i.name}`).join(`
|
|
8
|
-
`)}],details:{query:t,hits:n}}}}}c(pt,"createLspSearchResolver");function gt(r){return{id:"lsp-declaration-target",async tryResolve(e,t){let n=D(e,"symbol");if(n===void 0)return{kind:"not-handled"};if(n.selector===void 0)return{kind:"rejected",rejection:{code:"invalid",reason:"Use symbol:<file>#<selector> to choose one declaration"}};try{let s=await Xe(await r(t.cwd),E(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(gt,"createDeclarationTargets");import{readFile as rr,stat as mt}from"node:fs/promises";import{fileURLToPath as nr}from"node:url";function ft(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,i)=>s+i.length+1,0)+e.character}c(ft,"offset");async function ht(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=D(t.path.slice(0,-5),"symbol");if(n?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let s=E(n.path,r.cwd),i=await Ye(await e(r.cwd),s,n.selector,r.cwd,r.signal);if(i.client.supportsCommand("typescript.tsserverRequest")&&(await i.client.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:s,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for rename. No edits applied.");let o=Date.now(),u=await te(i.client,i.uri,i.position,t.text);if(r.signal?.throwIfAborted(),u===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let a=new Map(Object.entries(u.changes??{}));for(let d of u.documentChanges??[]){if(!("textDocument"in d)||!("edits"in d))throw new Error("Rename returned a file operation that is not supported; no edits applied.");if(d.textDocument.version!=null&&d.textDocument.version!==i.client.documentVersion(d.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. Refresh the source before retrying.");if(a.has(d.textDocument.uri))throw new Error("Rename returned duplicate document edits.");a.set(d.textDocument.uri,d.edits)}let l=[];for(let[d,p]of a){let g=nr(d),h=await mt(g),y=await rr(g,"utf8"),f=await mt(g),w=i.client.documentContent(d);if(w!==void 0&&w!==y)throw new Error("The language server has stale text for a rename target. Read that symbol again before retrying.");if(h.mtimeMs>o||h.mtimeMs!==f.mtimeMs||h.size!==f.size||g===s&&y!==i.content)throw new Error("A rename source changed during the language-server request. Retry from a fresh symbol read.");l.push({source:g,expectedContent:y,changes:p.map(R=>({from:ft(y,R.range.start),to:ft(y,R.range.end),insert:R.newText}))})}return{...r,editPlan:{files:l},metadata:{...r.metadata,semanticEdit:{mode:"lsp-rename",server:i.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}c(ht,"prepareSymbolRename");var yt=Ie({kind:"code-view",label:"LSP"});async function ir(r){let e=new Map,t=!1,n=c((a,l=!1)=>{if(t)return Promise.reject(new Error("LSP session has ended"));let d=JSON.stringify([a,l]),p=e.get(d);return p||(p=or(a,l).then(g=>{if(t)throw new Error("LSP session has ended");return C.init(g)}),e.set(d,p)),p},"managerFor"),s=c(async(a,l)=>{let d=await Se(l,a,"lsp-servers",A);return d===void 0?void 0:{cwd:d,external:d!==sr.resolve(l)}},"resolveLspProject"),i={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 d=await n(l.cwd);return pe(d).compile(a,l)}},o={protocol:ye,apiVersion:4,id:"lsp",setup(a){a.addTool(i),a.addDiagnosticSource(lt(n,s))}};r.on("session_shutdown",async()=>{t=!0,await Promise.allSettled([...e.values()].map(async a=>(await a).shutdownAll())),e.clear()});let u={protocol:Ce,apiVersion:De,id:"lsp",setup(a){a.addResolver({resolver:it(n),renderResult:yt}),a.addResolver({resolver:ot(n),renderResult:yt}),a.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:he()}),a.describe("symbol:<file>#<selector> \u2014 declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> \u2014 top-level declarations, references and calls; members include selectors. graph:<file>#<selector> \u2014 references and incoming/outgoing calls for that declaration or member."),a.addPromptGuideline("Use semantic code views first when exploring code supported by a configured language server. Use `symbols:<query>` to locate named declaration and reference candidates when the file is unknown. Use `graph:<file>` to map the declarations and relationships in a known file before reading implementation bodies. Use `graph:<file>#<selector>` to inspect references and incoming/outgoing calls for one declaration. Use `symbol:<file>#<selector>` to read that declaration\u2019s source. Use text search for exact text, non-code files, or when semantic views are unavailable.")}};await Promise.all([be(r,o),Ae(r,{protocol:je,apiVersion:Me,id:"lsp-declarations",setup(a){a.addAnchorResolver({kind:$e,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:gt(n),describeInPrompt:!1});for(let l of["copy","move","delete","replace"])a.tool(l).describe("Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. Copy/move require an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename."+(l==="replace"?" Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement.":"")),a.tool(l).addHandler({stage:"text-pre-edit",async handler(d){if(l==="replace"){let h=await ht(d,n);if(h!==void 0)return h}let p=d.input;if(![p.path,p.start,p.end,p.target,p.targetStart,p.targetEnd].some(h=>typeof h=="string"&&h.startsWith("symbol:")))return d;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{...d,metadata:{...d.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 d=l.input;if([d.path,d.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}})}}),Ee(r,u),xe(r,ut),qe(r,{protocol:Te,apiVersion:Oe,id:"symbols",setup(a){a.addResolver({resolver:pt(n)}),a.describe("Use `symbols:<query>` to locate named workspace declarations and references through configured language servers when the file is unknown.")}})])}c(ir,"registerLsp");async function or(r,e){let t=e?r:process.env.PI_AGENT_IDE_CONFIG_DIR??r;return _.fromPackageDir(t,{includeGlobal:!e,requireBuiltInEvidence:e,recipes:A})}c(or,"loadRegistry");export{ir as default};
|
|
1
|
+
import{a as Q,b as K,c as W}from"./chunk-DEP55R35.js";import{e as O,f as U}from"./chunk-T7I2VX3J.js";import{a as F}from"./chunk-MGCHOGQD.js";import{a as L,b as N}from"./chunk-T6LX2RX5.js";import{a as z}from"./chunk-L7JMDDSD.js";import{a as B,b as V}from"./chunk-O6LE42GK.js";import{a as _}from"./chunk-6CZO43OH.js";import{a as j,b as M}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Value as Ne}from"typebox/value";import{access as oe}from"node:fs/promises";import ae from"node:path";var Y={protocol:L,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ie(e.cwd)?await $("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 D("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 ie(n){try{return await oe(ae.join(n,".git")),!0}catch{return!1}}s(ie,"isGitProject");import{mkdtemp as se,rm as de,writeFile as ce}from"node:fs/promises";import ue 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 o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,r){let o=m.resolve(t,e),a=m.relative(this.repositoryRoot,o);return a===".."||a.startsWith(`..${m.sep}`)||m.isAbsolute(a)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(a.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 o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let a=le(o.stdout);if(a===void 0)return{status:"untracked"};let i=await this.readBlob(a.blob,"HEAD",e,t);if(i.status!=="found")return i;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let d=ge(c.stdout);if(d.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=d.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:i.text,indexText:l,indexMode:u?.mode??a.mode}}async writeIndexFile(e,t,r,o){let a=await se(m.join(ue.tmpdir(),"pi-agent-index-")),i=m.join(a,"content");try{await ce(i,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,i],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let d=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(d.code!==0)throw new Error(d.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await de(a,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let a=await this.git(["cat-file","blob",e],o);return a.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:a.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:a.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function le(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,o,a]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||a===void 0?void 0:{mode:r,blob:a,path:e.slice(t+1)}}s(le,"parseTreeEntry");function ge(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,a]=e.slice(0,t).split(" ",3),i=Number(a);return r===void 0||o===void 0||!Number.isInteger(i)?[]:[{mode:r,blob:o,stage:i,path:e.slice(t+1)}]})}s(ge,"parseIndexEntries");function q(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(q,"extensionGitExecutor");var f=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await b.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.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=Q(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 o=await this.inspect(e);if(o.status!=="applicable")return o;let a=o.groups.find(u=>u.selector===t);if(a===void 0)return A(t,o.groups.map(({selector:u})=>u));let i=r==="stage"?"staged":"unstaged";if(a.state===i)return{status:"unchanged",state:i,group:a};let c=x(a.segments[0]),d={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(d,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:pe(u)}}return{status:"applied",state:i,group:a}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(d=>d.selector===t);if(o===void 0)return A(t,r.groups.map(({selector:d})=>d));let a=K(e.worktreeText,o);if(a===void 0)return A(t,r.groups.map(({selector:d})=>d));let i=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:i.headStart,headEnd:i.headEnd,replacementText:i.headText};return{status:"applied",worktreeText:a,group:o,...c!==void 0&&{indexUpdate:c}}}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 o=W(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,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 pe(n){return n instanceof Error?n.message:String(n)}s(pe,"errorMessage");var T="pi-agent-ide-changes/change",fe=/^CHANGE#[0-9A-F]{4,64}$/,he=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function X(n){return{resolver:me(s(async t=>{if(he.test(t.source))return;let r=await f.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(X,"createChangeAnchorRegistration");function me(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(!fe.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 o=r.status==="applicable"?r.groups.find(a=>a.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(r){return{kind:"failed",error:r}}}}}s(me,"createChangeAnchorResolver");import{diffLines as ye}from"diff";var xe="filesystem";function Z(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==xe)return e;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:we(e,o.groups)}}}s(Z,"createCurrentChangePresenter");function we(n,e){let t=new Map;for(let r of e)be(n,r,t);return{...n,lines:n.lines.map(r=>ve(r,t.get(r.lineNumber)))}}s(we,"presentChangeGroups");function be(n,e,t){let r=x(e.segments[0]),o=ye(r.headText,r.worktreeText),a=e.currentStartLine,i,c;for(let d of o){let u=ke(d.value);if(d.removed){let l=Ce(n,a),g=R(t,l.lineNumber),p=l.after?g.after:g.before;for(let h of u){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:h}),i??=w,c=w}continue}if(d.added){for(let l of u){let g=R(t,a),p={kind:"current",lineNumber:a};g.added=!0,i??=p,c=p,a++}continue}a+=u.length}if(i!==void 0&&c!==void 0){let d=`${e.selector} \xB7 ${e.state}`;Te(i,c)?I(t,i,`<!-- change: ${d} -->`):(I(t,i,`<!-- change-begin: ${d} -->`),I(t,c,`<!-- change-end: ${d} -->`))}}s(be,"presentChangeGroup");function Te(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(Te,"sameTarget");function I(n,e,t){if(e.kind==="current"){R(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(I,"annotateTarget");function ve(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(ve,"presentLine");function R(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(R,"presentationsFor");function Ce(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Ce,"placementFor");function ke(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(ke,"splitLines");var v=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 Ee}from"node:crypto";import{realpathSync as Pe}from"node:fs";import te from"node:path";import{fileURLToPath as Ae}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=J(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===C(e.before.content)?this.#e.set(t,{...r,afterDigest:C(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:C(e.after.content)})}restore(e,t,r){let o=J(e,t),a=this.#e.get(o);if(a===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(a.afterDigest!==C(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return a.before}};function J(n,e){return n.startsWith("file://")?ee(Ae(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:ee(te.resolve(e,n))}s(J,"sourceKey");function ee(n){try{return Pe.native(n)}catch{return te.normalize(n)}}s(ee,"canonicalFile");function C(n){return Ee("sha256").update(n).digest("hex")}s(C,"textDigest");import{readFile as Ge}from"node:fs/promises";import Ie from"node:path";import{defineTool as Re,withFileMutationQueue as Se}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var P=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ne(n,e,t){n.registerTool(E("stage",e,t)),n.registerTool(E("unstage",e,t))}s(ne,"registerIndexChangeTools");function E(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return Re({name:n,label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:P,async execute(a,i,c,d,u){let l=He(i.file,u.cwd);return Se(l,()=>t.run(async()=>{let g=await Ge(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let h=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},i.change,n);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${n} is not applicable to ${l}: ${h.reason}`);let w=h.status==="unchanged";return{content:[{type:"text",text:w?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:l,state:r,unchanged:w}}}))}})}s(E,"createIndexChangeTool");function He(n,e){let t=n.startsWith("@")?n.slice(1):n;return Ie.resolve(e,t)}s(He,"resolveFile");import{diffChars as $e}from"diff";import{Type as y}from"typebox";var De=y.Object({file:y.Optional(y.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:y.Optional(y.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:y.Optional(y.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function re(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:s(o=>o!==null&&typeof o=="object"&&"transaction"in o&&typeof o.transaction=="string","matches"),async execute(o,a){if(a.change!==void 0)throw new Error("transaction cannot be combined with change");let i=String(a.transaction),c=await r(i,o.signal);return{source:i,summary:`Restored ${String(c.restored.length)} paths from ${i}.`,data:{kind:"apply-undo",ok:!0,transaction:i,restored:c.restored}}}},parameters:De,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(o,a){if(a.change===void 0)throw new Error("change is required when transaction is omitted");let i=o.sourceFor("file"),c,d;if(a.change==="last")c=e.restore(i,o.cwd,o.sourceDocument.content);else{await o.resolveAnchor("change");let u=await f.create(n,o.cwd,o.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:i,worktreeText:o.sourceDocument.content,cwd:o.cwd,...o.signal!==void 0&&{signal:o.signal}},a.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;d=s(()=>t.run(()=>u.service.applyIndexUpdate(g,o.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:Le(o.sourceDocument.content,c),action:"edited"}]]),...d!==void 0&&{afterWrite:d}}}}}s(re,"createUndoMutationTool");function Le(n,e){let t=[],r=0,o,a=0,i="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+a,insert:i}),o=void 0,a=0,i="")},"flush");for(let d of $e(n,e)){if(!d.added&&!d.removed){c(),r+=d.value.length;continue}o??=r,d.removed?(r+=d.value.length,a+=d.value.length):i+=d.value}return c(),t}s(Le,"createTextChanges");async function Oe(n){U(n,[await O({id:"git-changes",description:"Git change anchors, staging, and safe undo",triggers:["stage","unstage","undo"].map(d=>({tool:d}))})]);let e=q(n),t=new k,r=new v,o=Z(e),a=X(e),i={protocol:j,apiVersion:M,id:"current-git-changes",setup(d){d.addView({view:"changes",presenter:o}),d.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:B,apiVersion:V,id:"current-git-changes",setup(d){d.addAnchorResolver({...a,kind:T,type:"auxiliary"}),d.onDidEdit(u=>{t.observe(u)}),d.addMutationTool(re(e,t,r,d.restoreApplyUndo));for(let u of["stage","unstage"]){let l=E(u,e,r);d.addScriptIndexOperation({name:u,parameters:P,execute:s((g,p,h)=>l.execute(`apply-${u}`,Ne.Decode(P,g),p,void 0,h),"execute")})}d.addTextPresenter({presenter:o})}};await Promise.all([F(n,Y),_(n,i),z(n,c)]),ne(n,e,r)}s(Oe,"registerGitChanges");export{Oe as default};
|
package/dist/entry-34.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-QIJMV2P2.js";import"./chunk-EI7MMDWY.js";export{c as createImageContent,a as createImageContentConverter,b as detectSupportedImageMimeType};
|
|
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-HKMBQLEK.js";import{a as h,b as v}from"./chunk-Z3VC3S2T.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};
|
package/dist/entry-35.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a as p}from"./chunk-MGCHOGQD.js";import{a as n,b as c}from"./chunk-T6LX2RX5.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:1,id:"languages",setup(o){for(let r of m)o.addLanguage(r)}})}e(g,"registerLanguages");export{g as default};
|