pi-agent-ide 0.2.0 → 0.2.2
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 +57 -0
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/{chunk-2ZMYT6ZC.js → chunk-4U6KGABH.js} +1 -1
- package/dist/chunk-4ZTEPMJO.js +14 -0
- package/dist/{chunk-KNMWCDDK.js → chunk-6ACQQBUY.js} +1 -1
- package/dist/chunk-76WHES5H.js +7 -0
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/chunk-GFWDXTOB.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/chunk-JJVXUL5U.js +2 -0
- package/dist/chunk-KCEOTU5Z.js +3 -0
- package/dist/chunk-KVGQG43U.js +1 -0
- package/dist/{chunk-MTTKFJV6.js → chunk-LQYZG62K.js} +1 -1
- package/dist/chunk-N34ATN52.js +1 -0
- package/dist/{chunk-PETQCA7G.js → chunk-P6T3Q7LB.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-QJFRAMK7.js +2 -0
- package/dist/{chunk-2SKAED2I.js → chunk-RAZOACDD.js} +2 -2
- package/dist/chunk-RIGRP3FD.js +1 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/{chunk-266RH77Z.js → chunk-THSCUT2L.js} +1 -1
- package/dist/{chunk-EEH4WYI7.js → chunk-WNMGUALD.js} +1 -1
- package/dist/chunk-WZI4YC2O.js +1 -0
- package/dist/{chunk-5A25RATC.js → chunk-X6MPU7UO.js} +3 -3
- package/dist/{chunk-QNZVPFSP.js → chunk-XF5PVZOS.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZXN3TWWW.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +7 -1
- package/dist/entry-27.js +1 -1
- 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 +4 -1
- package/dist/entry-32.js +8 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +14 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -0
- package/dist/entry-54.js +0 -1
- package/dist/entry-55.js +1 -0
- package/dist/entry-56.js +0 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +0 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +59 -1
- package/dist/entry-70.js +4 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +29 -1
- package/dist/entry-73.js +2 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -0
- package/dist/pi-agent-ide.js +2 -13
- package/docs/configuration.md +57 -1
- package/docs/extensions.md +4 -2
- package/docs/generated/tool-catalog/cmake.md +5 -5
- package/docs/generated/tool-catalog/csharp.md +5 -5
- package/docs/generated/tool-catalog/css.md +7 -7
- package/docs/generated/tool-catalog/dart.md +9 -0
- package/docs/generated/tool-catalog/dockerfile.md +5 -5
- package/docs/generated/tool-catalog/elixir.md +9 -0
- package/docs/generated/tool-catalog/html.md +7 -6
- package/docs/generated/tool-catalog/index.md +9 -0
- package/docs/generated/tool-catalog/javascript.md +8 -8
- package/docs/generated/tool-catalog/json.md +7 -7
- package/docs/generated/tool-catalog/julia.md +8 -0
- package/docs/generated/tool-catalog/kotlin.md +6 -5
- package/docs/generated/tool-catalog/markdown.md +6 -6
- package/docs/generated/tool-catalog/powershell.md +9 -0
- package/docs/generated/tool-catalog/python.md +6 -6
- package/docs/generated/tool-catalog/r.md +9 -0
- package/docs/generated/tool-catalog/scala.md +9 -0
- package/docs/generated/tool-catalog/svelte.md +9 -0
- package/docs/generated/tool-catalog/typescript.md +9 -8
- package/docs/generated/tool-catalog/vue.md +9 -0
- package/docs/generated/tool-catalog/yaml.md +6 -6
- package/docs/generated/tool-catalog/zig.md +9 -0
- package/docs/tools.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +10 -3
- package/node_modules/pi-agent-doctor/runtime/entry-20.js +1 -0
- package/node_modules/pi-agent-doctor/src/catalog.ts +27 -1
- package/node_modules/pi-agent-doctor/src/evidence.ts +118 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +63 -17
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- 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-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +11 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +3 -0
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +92 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -14
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-changes/index.ts +1 -5
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/catalog.ts +131 -13
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +20 -8
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/src/languages.ts +15 -0
- package/node_modules/pi-agent-ide-lint/index.ts +4 -1
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/src/catalog.ts +196 -39
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +23 -3
- package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +73 -33
- package/node_modules/pi-agent-ide-lint/src/registry.ts +20 -8
- package/node_modules/pi-agent-ide-lsp/index.ts +1 -12
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/catalog.ts +161 -7
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +10 -10
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +162 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
- package/node_modules/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- 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-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +11 -11
- package/node_modules/pi-agent-read/runtime/entry-39.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-40.js +2 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -26
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-search/package.json +7 -7
- package/node_modules/pi-agent-search/runtime/entry-44.js +0 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +7 -5
- package/node_modules/pi-agent-search/src/core/search-core.ts +10 -0
- package/node_modules/pi-agent-search-text/index.ts +42 -33
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +48 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +22 -22
- package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-argument-order/package.json +3 -3
- package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -4
- package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
- package/node_modules/pi-agent-web/index.ts +1 -6
- 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/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
- package/package.json +35 -35
- package/src/api/plugin-protocol.ts +2 -0
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config/formatters.json +70 -12
- package/src/api/tool-config/linters.json +148 -66
- package/src/api/tool-config/lsp-servers.json +142 -7
- package/src/api/tool-config.ts +60 -24
- package/src/code-view/diagnostic-view.ts +14 -10
- package/src/composite/builtin-extensions.ts +148 -66
- package/src/composite/extensions-config.ts +18 -0
- package/src/core/diagnostic-entry.ts +94 -0
- package/src/core/diagnostic-store.ts +43 -21
- package/src/core/extension.ts +39 -17
- package/src/doctor/config-writer.ts +14 -1
- package/src/doctor/discovery.ts +13 -68
- package/src/doctor/run.ts +33 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- 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-pdf/package.json +4 -4
- 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-24.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
- 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/src/html-converter.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/package.json +11 -11
- package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-40.js +2 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -26
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/src/extensions/pi-agent-search/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +42 -33
- 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-46.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +48 -0
- package/src/extensions/pi-agent-search/runtime/entry-44.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +7 -5
- package/src/extensions/pi-agent-search/src/core/search-core.ts +10 -0
- package/src/extensions/pi-agent-text-editor/package.json +22 -22
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
- 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-50.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -1
- 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/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- 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-73.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +11 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +3 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +92 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -14
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +1 -5
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +1 -8
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +131 -13
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +20 -8
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/src/languages.ts +15 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +4 -1
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/src/catalog.ts +196 -39
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +23 -3
- package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +73 -33
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +20 -8
- package/src/plugins/pi-agent-ide-lsp/index.ts +1 -12
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +161 -7
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +10 -10
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +162 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
- package/src/plugins/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
- package/src/post-edit/gate.ts +44 -15
- package/src/toolchain/types.ts +4 -0
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-476MR2QB.js +0 -1
- package/dist/chunk-4KQOODGE.js +0 -13
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-52BM6J6I.js +0 -6
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-7NDBZ4WX.js +0 -1
- package/dist/chunk-AP7Z3VWC.js +0 -1
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-E4SECPF4.js +0 -1
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-KP37XTDI.js +0 -1
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QW5O42QJ.js +0 -2
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-TNWYEXFG.js +0 -1
- package/dist/chunk-U4D6FT66.js +0 -1
- package/dist/chunk-VUNCBASK.js +0 -10
- package/dist/chunk-VWVLBOMU.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YQTLJ5ZV.js +0 -58
- package/node_modules/pi-agent-filesystem/runtime/entry-20.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-32.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-resource/runtime/entry-40.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-53.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-35.js +0 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +0 -1
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-21.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-45.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-47.js +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-69.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
|
@@ -53,6 +53,8 @@ export interface LspTextEdit {
|
|
|
53
53
|
|
|
54
54
|
export interface LanguageEntry {
|
|
55
55
|
extensions: string[];
|
|
56
|
+
/** Exact basenames for files such as Dockerfile and CMakeLists.txt. */
|
|
57
|
+
fileNames?: string[];
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export type ServerCapability = "diagnostics";
|
|
@@ -61,6 +63,9 @@ export interface ServerConfig {
|
|
|
61
63
|
command: string[];
|
|
62
64
|
transport?: "stdio";
|
|
63
65
|
rootMarkers: string[];
|
|
66
|
+
|
|
67
|
+
/** Require a root marker in the file's directory or an ancestor inside the project. */
|
|
68
|
+
requireRootMarker?: boolean;
|
|
64
69
|
languages: Record<string, LanguageEntry>;
|
|
65
70
|
capabilities: ServerCapability[];
|
|
66
71
|
env?: Record<string, string>;
|
package/src/post-edit/gate.ts
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
3
|
import { warmupFormatting } from "#src/toolchain/registry.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { MutationFormatting } from "pi-agent-text-editor/api/mutation-result";
|
|
5
|
+
import type {
|
|
6
|
+
TextPostEditTransaction,
|
|
7
|
+
TextPostEditStatusContribution,
|
|
8
|
+
} from "pi-agent-text-editor/api/post-edit";
|
|
5
9
|
|
|
6
|
-
/** Finish
|
|
7
|
-
export async function runIdePostEditGate(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
10
|
+
/** Finish file-writing work and report the formatter outcome, separately from diagnostics. */
|
|
11
|
+
export async function runIdePostEditGate(
|
|
12
|
+
transaction: TextPostEditTransaction,
|
|
13
|
+
): Promise<{ formatting: MutationFormatting } & Partial<TextPostEditStatusContribution>> {
|
|
14
|
+
if (!path.isAbsolute(transaction.resourceSource))
|
|
15
|
+
return { formatting: { status: "unavailable" } };
|
|
16
|
+
let formatterName: string | undefined;
|
|
17
|
+
try {
|
|
18
|
+
const toolchain = await warmupFormatting({ cwd: transaction.cwd });
|
|
19
|
+
const extension = path.extname(transaction.resourceSource).toLowerCase();
|
|
20
|
+
const matches = (tool: { extensions: readonly string[] }) =>
|
|
21
|
+
tool.extensions.includes(extension) || tool.extensions.includes("*");
|
|
22
|
+
const syntax = toolchain.compilers.find(matches);
|
|
23
|
+
if (syntax) {
|
|
24
|
+
const result = await syntax.compile({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
25
|
+
if (result.syntaxErrors.length > 0) return { formatting: { status: "skipped-syntax" } };
|
|
26
|
+
}
|
|
27
|
+
const formatter = toolchain.formatters.find(matches);
|
|
28
|
+
if (!formatter) return { formatting: { status: "unavailable" } };
|
|
29
|
+
formatterName = formatter.name;
|
|
30
|
+
const result = await formatter.format({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
31
|
+
if (result.formatter === null) return { formatting: { status: "unavailable" } };
|
|
32
|
+
formatterName = result.formatter ?? formatter.name;
|
|
33
|
+
return {
|
|
34
|
+
formatting: {
|
|
35
|
+
status: !result.ok ? "failed" : result.edits > 0 ? "changed" : "unchanged",
|
|
36
|
+
formatter: formatterName,
|
|
37
|
+
},
|
|
38
|
+
...(result.ok
|
|
39
|
+
? { diffStatuses: [{ text: `Formatted (${formatterName})`, tone: "success" as const }] }
|
|
40
|
+
: {}),
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return {
|
|
44
|
+
formatting: {
|
|
45
|
+
status: "failed",
|
|
46
|
+
...(formatterName === undefined ? {} : { formatter: formatterName }),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
17
49
|
}
|
|
18
|
-
// Configured formatters may use their own parser to reject invalid syntax safely.
|
|
19
|
-
const formatter = toolchain.formatters.find(matches);
|
|
20
|
-
await formatter?.format({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
21
50
|
}
|
package/src/toolchain/types.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
export type Severity = "error" | "warning" | "info" | "hint";
|
|
4
4
|
|
|
5
5
|
export interface Diagnostic {
|
|
6
|
+
/** Source path when a tool reports more than the requested file. */
|
|
7
|
+
file?: string;
|
|
6
8
|
code: string;
|
|
7
9
|
message: string;
|
|
8
10
|
/**
|
|
@@ -27,6 +29,8 @@ export interface FormatInput {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export interface FormatResult {
|
|
32
|
+
/** Actual formatter executable. Omit for a named formatter plugin; null means no formatter was selected. */
|
|
33
|
+
formatter?: string | null;
|
|
30
34
|
ok: boolean;
|
|
31
35
|
/**
|
|
32
36
|
Number of edits applied. 0 = no change.
|
package/dist/chunk-34ZQTTU2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-MTTKFJV6.js";import{m as T}from"./chunk-2SKAED2I.js";import{a as S}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createHash as ce}from"node:crypto";import{readFile as Q}from"node:fs/promises";import h from"node:path";import{spawn as Y}from"node:child_process";import O from"node:path";import{createInterface as Z}from"node:readline";import{existsSync as q}from"node:fs";import X from"node:os";import H from"node:path";function F(e=process.env.PI_CODING_AGENT_DIR??H.join(X.homedir(),".pi","agent"),n=process.platform){let t=H.join(e,"bin",n==="win32"?"rg.exe":"rg");return q(t)?t:"rg"}c(F,"resolveRipgrepExecutable");async function R(e,n,t){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let r=e.limit??100,o=O.resolve(n,ne(e.path??".")),s=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...L(e.include).flatMap(i=>["--glob",i]),...L(e.exclude).flatMap(i=>["--glob",`!${i}`]),"--",e.query,o];if(e.regex!==!0)return k(["--fixed-strings",...s],r,t);try{return await k(["--engine","auto",...s],r,t)}catch(i){if(!ee(i))throw i;return k(["--engine","default",...s],r,t)}}c(R,"searchText");function k(e,n,t){return new Promise((r,o)=>{let s=Y(F(),e,{stdio:["ignore","pipe","pipe"]}),i=Z({input:s.stdout}),a=[],u="",l=!1,d,p=c(()=>{s.kill()},"abort"),f=c(()=>{t?.removeEventListener("abort",p),i.close()},"cleanup");s.stderr.setEncoding("utf8"),s.stderr.on("data",m=>{u+=m}),i.on("line",m=>{if(!(l||d!==void 0||m.length===0))try{let g=JSON.parse(m);if(g.type!=="match")return;for(let V of te(g)){if(a.length===n){l=!0,s.kill();return}a.push(V)}}catch(g){d=g,s.kill()}}),s.once("error",m=>{f(),o(m)}),s.once("close",m=>{if(f(),t?.aborted===!0){let g=new Error("Search was aborted.");g.name="AbortError",o(g);return}if(d!==void 0){o(new Error("Unable to parse ripgrep search output.",{cause:d}));return}if(!l&&m!==0&&m!==1){o(new Error(u.trim()||`ripgrep exited with code ${String(m)}.`));return}a.sort(re),r({matches:a,complete:!l})}),t?.addEventListener("abort",p,{once:!0}),t?.aborted===!0&&p()})}c(k,"runRipgrep");function ee(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}c(ee,"isPcre2MatchLimitError");function te(e){let n=e.data.path.text,t=e.data.lines.text;if(n===void 0||t===void 0||!Number.isSafeInteger(e.data.line_number))return[];let r=t.replace(/(?:\r\n|\n)$/u,""),o=Buffer.from(t),s=[];for(let i of e.data.submatches){if(i.start<0||i.end<=i.start||i.end>o.length)continue;let a=o.subarray(0,i.start).toString("utf8").length,u=o.subarray(0,i.end).toString("utf8").length;s.push({source:O.resolve(n),lineNumber:e.data.line_number,startColumn:a,endColumn:u,matchedText:r.slice(a,u),lineText:r})}return s}c(te,"matchesFromEvent");function L(e){if(e===void 0)return[];let n=[],t=0,r="";for(let o of e){if(o==="{"?t+=1:o==="}"&&(t=Math.max(0,t-1)),t===0&&(o===","||/\s/u.test(o))){r.length>0&&(n.push(r),r="");continue}r+=o}return r.length>0&&n.push(r),n}c(L,"splitGlobList");function ne(e){return e.startsWith("@")?e.slice(1):e}c(ne,"stripFilePrefix");function re(e,n){return e.source.localeCompare(n.source)||e.lineNumber-n.lineNumber||e.startColumn-n.startColumn||e.endColumn-n.endColumn}c(re,"compareMatches");function E(e,n=!1){let t=M(e);if(!C(t))return n?e:N(e);let r=v(new A(e,t).parse(),n);return`^${r.condition}.*?\\K(${r.match})`}c(E,"compileSearchQuery");function _(e){if(C(M(e)))return;let n=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return n.length>1?`(?:${n.map(N).join("|")})`:void 0}c(_,"compileSearchFallbackQuery");function C(e){return e.some(n=>n.quoted===!0||n.type==="and"||n.type==="or"||n.type==="not")}c(C,"containsBooleanSyntax");var A=class{static{c(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(n,t){this.#t=n,this.#r=t}parse(){let n=this.#s(),t=this.#e();if(t.type!=="end"){let r=t.type==="right"?"unexpected ')'.":`unexpected ${se(t)}.`;throw y(t.offset,r)}return n}#s(){let n=this.#n();for(;this.#e().type==="or";){let t=this.#o(),r=this.#a(`after ${t.value}`);n={kind:"or",left:n,right:this.#c(r)}}return n}#n(){return this.#c(this.#a())}#c(n){let t=n;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#a(`after ${r.value}`);t={kind:r.type,left:t,right:o};continue}if(r.type==="term"||r.type==="left"){t={kind:"and",left:t,right:this.#a()};continue}return t}}#a(n){let t=this.#e();if(t.type==="term")return this.#o(),{kind:"term",value:t.value,quoted:t.quoted};if(t.type==="left"){if(this.#o(),this.#e().type==="right"||this.#e().type==="end")throw y(this.#e().offset,"expected a term after '('.");let o=this.#s();if(this.#e().type!=="right")throw y(this.#e().offset,"expected ')'.");return this.#o(),o}if(n===void 0&&(t.type==="and"||t.type==="or"||t.type==="not"))throw y(t.offset,`expected a term before ${t.value}.`);let r=n===void 0?"":` ${n}`;throw y(t.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let n=this.#e();return this.#i+=1,n}};function M(e){let n=[],t=0;for(;t<e.length;){let r=e.charAt(t);if(/\s/u.test(r)){t+=1;continue}if(r==="("&&oe(e,t)){n.push({type:"left",value:r,offset:t}),t+=1;continue}if(r===")"){n.push({type:"right",value:r,offset:t}),t+=1;continue}if(W(e,t)){let i=e.charAt(t+1)==="|"?2:1;n.push({type:"or",value:e.slice(t,t+i),offset:t}),t+=i;continue}if(r==="'"||r==='"'){let i=t,a=r,u="";for(t+=1;t<e.length&&e.charAt(t)!==a;)e.charAt(t)==="\\"&&(e.charAt(t+1)===a||e.charAt(t+1)==="\\")&&(t+=1),u+=e.charAt(t++);if(t>=e.length)throw y(i,`unterminated ${a==="'"?"single":"double"}-quoted term.`);if(t+=1,u.length===0)throw y(i,"quoted terms must not be empty.");n.push({type:"term",value:u,offset:i,quoted:!0});continue}let o=t;for(;t<e.length;){let i=e.charAt(t);if(/\s/u.test(i)||i===")"||W(e,t))break;i==="\\"&&t+1<e.length?t+=2:i==="["||i==="("?t=$(e,t)??t+1:t+=1}let s=e.slice(o,t);n.push({type:ie(s),value:s,offset:o})}return n.push({type:"end",value:"",offset:e.length}),n}c(M,"tokenize");function W(e,n){return e.charAt(n)==="|"&&(e.charAt(n+1)==="|"||/\s/u.test(e.charAt(n-1))&&/\s/u.test(e.charAt(n+1)))}c(W,"isBooleanPipe");function $(e,n){let t=e.charAt(n)==="["?"]":")",r=n+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===t)return r+1;if(t===")"&&(o==="("||o==="[")){let s=$(e,r);if(s===void 0)return;r=s}else r+=1}}}c($,"regexBlockEnd");function oe(e,n){let t=$(e,n);if(t===void 0)return!0;let r=e.slice(n+1,t-1);return r.trim().length===0?!0:C(M(r))}c(oe,"isBooleanGroup");function ie(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}c(ie,"operatorType");function se(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}c(se,"quoteToken");function y(e,n){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${n}`)}c(y,"syntaxError");function v(e,n){if(e.kind==="term"){let o=n&&!e.quoted?e.value:N(e.value);return{condition:`(?=.*(?:${o}))`,match:o}}let t=v(e.left,n),r=v(e.right,n);return e.kind==="or"?{condition:`(?:${t.condition}|${r.condition})`,match:`(?:${t.match}|${r.match})`}:e.kind==="not"?{condition:`${t.condition}(?!${r.condition})`,match:t.match}:{condition:`${t.condition}${r.condition}`,match:`(?:${t.match}|${r.match})`}}c(v,"compileExpression");function N(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}c(N,"escapeRegex");function $e(e){let n=E(e.query),t=E(e.query,!0),r=_(e.query),o=[];return t!==n&&o.push({query:t,mode:"regex"}),r!==void 0&&r!==n&&r!==t&&o.push({query:r,mode:"words"}),{...e,query:n,regex:!0,fallbacks:o}}c($e,"createSearchRecipe");async function D(e,n,t){let r=e.query,o=await R(e,n,t),s=[];for(let i of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;t?.throwIfAborted();try{o=await R({...e,query:i.query,regex:!0},n,t),r=i.query,s.push(i.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(a){if(i.mode!=="regex"||!ae(a)||t?.aborted)throw a;s.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:s}}c(D,"runSearchRecipe");function ae(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}c(ae,"isRegexSyntaxError");var le=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,U=4;function We(e,n,t,r){return K(e,n,t,r).slice(0,U)}c(We,"createSearchSessionId");function K(e,n,t,r){let o=t===void 0?me(n.map(a=>a.source)):h.resolve(t),s=n.map(a=>({match:a,source:h.relative(o,h.resolve(a.source))})).sort((a,u)=>a.source.localeCompare(u.source)||I(a.match,u.match)).map(({match:a,source:u})=>[u,a.lineNumber,a.startColumn,a.endColumn,a.matchedText,a.lineText]),i=de(r??{query:e,regex:!0},o);return ce("sha256").update(JSON.stringify([e,o,i,s])).digest("hex").toUpperCase()}c(K,"createSearchSessionIdentity");function ue(e,n){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let t=U;t<=e.length;t+=1){let r=e.slice(0,t);if(!n.has(r))return r}throw new Error("Could not allocate a unique search session id.")}c(ue,"allocateSearchSessionId");function de(e,n){return{query:e.query,path:h.resolve(n,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??100,regex:e.regex===!0,fallbacks:e.fallbacks??[]}}c(de,"normalizeRecipe");var G=class{constructor(n=K){this.createIdentity=n}static{c(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(n,t,r,o,s,i={query:n,regex:!0}){let a=t.map(m=>({...m,source:h.resolve(m.source)})).sort(I),u=await z(a,s),l=this.createIdentity(n,a,o,i),p=this.#r.get(l)??ue(l,new Set(this.#t.keys())),f={id:p,query:n,matches:a,complete:r,contentBySource:u,recipe:i,cwd:h.resolve(o)};return this.#r.set(l,p),this.#t.set(p,f),f}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
|
|
2
|
-
`),renderFull(n){return n},renderCompact(n){let t=B(n);return t===void 0?"selected result":t.selector==="all"?t.mode==="match"?"all matches":"all lines":t.mode==="match"?`match ${String(t.selector)}`:`line ${String(t.selector)}`},tryResolve:c((n,t)=>this.#i(n,t.source,t.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:c((n,t)=>this.#s(n,t.cwd),"tryResolve")}}async#i(n,t,r){let o=B(n);if(o===void 0)return{kind:"not-handled"};let s=this.#t.get(o.id);if(s===void 0)return b();if(o.selector==="all"&&!s.complete)return x();let i=h.resolve(t),a=s;if(o.selector==="all"){if(s.refreshedComplete?.complete===!0)a=s.refreshedComplete;else if(s.refreshedComplete!==void 0&&(a=await this.#n(s,r),!a.complete))return x()}let u=w(a,o.selector,o.mode),l=u.filter(f=>f.source===i);if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await P(i,r);if(d===void 0)return b(S(l[0]).lineNumber);if(o.selector==="all"&&d!==a.contentBySource.get(i)){if(a=await this.#n(s,r),!a.complete)return x();u=w(a,o.selector,o.mode),l=u.filter(f=>f.source===i)}if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==s.contentBySource.get(i))return b(S(l[0]).lineNumber);let p=T(i,d);return{kind:"resolved",anchor:new j(n,i,l.map(f=>J(p,f,o.mode)))}}async#s(n,t){let r=B(n);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return b();if(r.selector==="all"&&!o.complete)return x();let s=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)s=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(s=await this.#n(o),!s.complete))return x();let l=new Set(w(s,r.selector,r.mode).map(d=>d.source));for(let d of l)if(await P(d)!==s.contentBySource.get(d)){if(s=await this.#n(o),!s.complete)return x();break}}let i=w(s,r.selector,r.mode);if(r.selector!=="all"){let l=i[0]?.source;if(l!==void 0&&await P(l)!==s.contentBySource.get(l))return b(i[0]?.lineNumber)}let a=new Map;for(let l of i){let d=a.get(l.source)??[];d.push(J(T(l.source,s.contentBySource.get(l.source)??l.lineText),l,r.mode)),a.set(l.source,d)}let u=[...a].map(([l,d])=>({source:l,ranges:d}));return u.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:u}}async#n(n,t){let r=await D(n.recipe,n.cwd,t),o=r.matches.map(i=>({...i,source:h.resolve(i.source)})).sort(I),s={matches:o,complete:r.complete,contentBySource:await z(o,t)};return this.#t.set(n.id,{...n,refreshedComplete:s}),s}};function B(e){let n=le.exec(e);if(n!==null)return{id:S(n[1]),selector:n[2]==="all"?"all":Number(n[2]),mode:n[3]==="line"?"line":"match"}}c(B,"parseSearchAnchor");function w(e,n,t){let r=n==="all"?e.matches:[e.matches[n-1]].filter(he);if(t==="match"||n!=="all")return r;let o=new Set;return r.filter(s=>{let i=`${s.source}\0${String(s.lineNumber)}`;return o.has(i)?!1:(o.add(i),!0)})}c(w,"selectMatches");function he(e){return e!==void 0}c(he,"isMatch");function J(e,n,t){if(t==="match")return{start:{lineNumber:n.lineNumber,column:n.startColumn},end:{lineNumber:n.lineNumber,column:n.endColumn}};let r=S(e.lines[n.lineNumber-1]);return{start:{lineNumber:n.lineNumber,column:0},end:{lineNumber:n.lineNumber+(r.lineEnding.length>0?1:0),column:r.lineEnding.length>0?0:r.content.length},linewise:!0}}c(J,"selectionRange");async function z(e,n){let t=new Map;for(let r of new Set(e.map(o=>o.source))){let o=await Q(r,{encoding:"utf8",...n!==void 0&&{signal:n}}),s=T(r,o);for(let i of e.filter(a=>a.source===r)){let a=s.lines[i.lineNumber-1]?.content;if(a!==i.lineText||a.slice(i.startColumn,i.endColumn)!==i.matchedText)throw new Error(`Search result in ${r} changed before its anchors were registered.`)}t.set(r,o)}return t}c(z,"snapshotContents");async function P(e,n){try{return await Q(e,{encoding:"utf8",...n!==void 0&&{signal:n}})}catch{return}}c(P,"readCurrent");function b(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}c(b,"staleAnchor");function x(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}c(x,"missingCompleteAnchor");function me(e){if(e.length===0)return".";let n=h.dirname(h.resolve(S(e[0])));for(let t of e.slice(1)){let r=h.resolve(t);for(;!fe(n,r);){let o=h.dirname(n);if(o===n)return n;n=o}}return n}c(me,"commonSourceDirectory");function fe(e,n){let t=h.relative(e,n);return t!==".."&&!t.startsWith(`..${h.sep}`)&&!h.isAbsolute(t)}c(fe,"isWithin");function I(e,n){return e.source.localeCompare(n.source)||e.lineNumber-n.lineNumber||e.startColumn-n.startColumn||e.endColumn-n.endColumn}c(I,"compareMatches");export{F as a,$e as b,D as c,We as d,K as e,ue as f,G as g};
|
package/dist/chunk-476MR2QB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as E}from"./chunk-ERVMDQGX.js";import{a as D,b as R}from"./chunk-VFBLX4TG.js";import{a as L}from"./chunk-OBWZ5RYN.js";import{a as w,b}from"./chunk-KZBAJFCV.js";import{e as v,f as j,g as h,h as x,k as P}from"./chunk-7NDBZ4WX.js";import{a as d}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";function S(n,t){if(n.trim().length===0)return[];switch(t.format){case"pi-json":return q(n);case"eslint-json":return M(n);case"sarif":return F(n);case"checkstyle":return J(n);case"gcc":case"clang":return V(n);case"regex":return z(n,d(t.pattern))}}s(S,"parseDiagnostics");function q(n){let t=JSON.parse(n);return Array.isArray(t.diagnostics)?t.diagnostics.flatMap(u):[]}s(q,"parsePiJson");function M(n){return JSON.parse(n).flatMap(e=>Array.isArray(e.messages)?e.messages.flatMap(u):[])}s(M,"parseEslintJson");function F(n){return(JSON.parse(n).runs??[]).flatMap(e=>(e.results??[]).flatMap(r=>{let i=r.locations?.[0]?.physicalLocation?.region??{},a=r.message;return u({line:i.startLine,column:i.startColumn,message:a?.text,code:r.ruleId,severity:B(r.level)})}))}s(F,"parseSarif");function J(n){let t=[],e=/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu;for(let r of n.matchAll(e)){let i=Object.fromEntries([...d(r[1]).matchAll(/([\w-]+)="([^"]*)"/gu)].map(a=>[d(a[1]),H(d(a[2]))]));t.push(...u({line:Number(i.line),column:Number(i.column??1),message:i.message,code:i.source,severity:i.severity}))}return t}s(J,"parseCheckstyle");function V(n){return T(n,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}s(V,"parseCompilerLines");function z(n,t){return T(n,new RegExp(t,"u"))}s(z,"parseRegexLines");function T(n,t){return n.split(/\r?\n/u).flatMap(e=>{let r=e.match(t)?.groups;return r===void 0?[]:u(r)})}s(T,"parseMatchingLines");function u(n){if(typeof n!="object"||n===null)return[];let t=n,e=I(t.line??t.startLine),r=I(t.column??t.startColumn,1),i=typeof t.message=="string"?t.message:void 0;return e===void 0||i===void 0?[]:[{code:O(t.code??t.ruleId,"lint"),message:i,line:e,column:r??1,severity:G(t.severity)}]}s(u,"normalizeDiagnostic");function I(n,t){let e=typeof n=="string"?Number.parseInt(n,10):n;return typeof e=="number"&&Number.isInteger(e)&&e>=1?e:t}s(I,"numberValue");function O(n,t){return typeof n=="string"||typeof n=="number"?String(n):t}s(O,"stringValue");function G(n){if(n===2)return"error";if(n===1)return"warning";let t=O(n,"warning").toLowerCase();return t.includes("error")?"error":t==="info"||t==="note"||t==="notice"?"info":t==="hint"?"hint":"warning"}s(G,"severityValue");function B(n){return n==="error"||n==="warning"||n==="note"?n:"warning"}s(B,"sarifSeverity");function H(n){return n.replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}s(H,"decodeXml");import A from"node:path";var f=class n{constructor(t,e){this.linters=t;this.availableBuiltIns=e}static{s(this,"LintCommandRegistry")}static async fromDirectory(t,e={}){let r=await v(t,"linters",o=>P(o).linters,e),i=e.environment??process.env,a=await Promise.all(r.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await h(o.config.check,t,i)})));return new n(r.entries,new Set(a.filter(o=>o.available).map(o=>o.id)))}static fromConfig(t){return new n(Object.entries(t.linters).map(([e,r])=>({id:e,config:r,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,e){return this.resolveEntry(t,e)?.config}resolveEntry(t,e){let r=A.isAbsolute(t)?t:A.join(e,t);return this.linters.find(i=>(i.layer!=="built-in"||this.availableBuiltIns.has(i.id))&&j(i.config,r,e))}get entries(){return this.linters}};async function p(n,t){let e;try{e=await x(n.check,t)}catch(a){return{ok:!1,diagnostics:[],failure:`command could not start: ${a instanceof Error?a.message:String(a)}`}}let r=e.stdout.trim().length>0?e.stdout:e.stderr,i;try{i=S(r,n.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${n.diagnostics.format} diagnostics: ${r.trim().slice(0,200)||"empty command output"}`}}return{ok:e.ok,diagnostics:i,...!e.ok&&{failure:e.stderr.trim().slice(0,200)||`command exited with code ${String(e.exitCode)}`}}}s(p,"runConfiguredLinter");function N(n){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:s(()=>Promise.resolve(!0),"detect"),async lint({filePath:t,fix:e},r){let i=n.resolve(t,r.cwd);if(i===void 0)return{ok:!0,diagnostics:[]};let a=e===!0&&i.fix!==void 0?i.fix:i.check,o=await p({...i,check:a},{projectRoot:r.cwd,filePath:t});return{ok:o.ok,diagnostics:o.diagnostics}}}}s(N,"createCommandLinter");import{copyFile as X,mkdtemp as K,rm as Q}from"node:fs/promises";import k from"node:path";var $=[c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hpp"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript"],["eslint"],["eslint.config.js","eslint.config.mjs",".eslintrc.json"],[".js",".jsx",".mjs",".cjs",".ts",".tsx"],["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","{file}"],"gcc","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"],"gcc","https://learn.microsoft.com/dotnet/core/tools/dotnet-format"),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}"],"gcc","https://detekt.dev/"),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"clang","https://docs.rubocop.org/"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=emacs","{file}"],"gcc","https://github.com/PHPCSStandards/PHP_CodeSniffer"),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--path","{file}"],"gcc","https://github.com/realm/SwiftLint"),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","{file}"],"gcc","https://github.com/lunarmodules/luacheck"),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}"],"gcc","https://stylelint.io/",void 0,["stylelint"]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"gcc","https://yamllint.readthedocs.io/"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"gcc","https://github.com/DavidAnson/markdownlint"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],["*"],["hadolint","--format","tty","{file}"],"gcc","https://github.com/hadolint/hadolint"),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","compact"],"gcc","https://github.com/terraform-linters/tflint"),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"gcc","https://cmake-format.readthedocs.io/"),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","unix","{file}"],"gcc","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],["package.json"],[".json",".jsonc"],["jsonlint","-q","{file}"],"gcc","https://github.com/zaach/jsonlint"),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","{file}"],"gcc","https://taplo.tamasfe.dev/"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"gcc","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html")];function c(n,t,e,r,i,a,o,l,m,g){return{id:n,name:n,kind:"linter",languages:t,executables:e,configFiles:r,documentation:l,...g&&{dependencies:g},linter:{extensions:i,check:{command:a,successExitCodes:[0,1]},diagnostics:{format:o,...m&&{pattern:m}}}}}s(c,"recipe");var _={protocol:D,apiVersion:1,id:"lint",setup(n){for(let t of $)n.addToolRecipe(t);n.addSetupCheck({id:"effective-config",inspect:U}),n.addCheck({id:"config",title:"Linter",async run(t){try{let e=await f.fromDirectory(t.cwd,{environment:t.env}),r=W(e,t.files,t.cwd);return r.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(r.map(async({entry:i,source:a})=>{let o=`${i.id} [${i.layer}] command ${JSON.stringify(i.config.check.command)}`,l=await K(k.join(k.dirname(a),".pi-agent-ide-doctor-")),m=k.join(l,k.basename(a));try{await X(a,m);let g=await p(i.config,{projectRoot:t.cwd,filePath:m,env:t.env});return g.ok?{status:"pass",message:`${o}: probe passed`,detail:i.sourcePath}:{status:"fail",message:`${o}: probe failed`,detail:g.failure??i.sourcePath}}catch(g){return{status:"fail",message:`${o}: ${g instanceof Error?g.message:String(g)}`,detail:i.sourcePath}}finally{await Q(l,{recursive:!0,force:!0})}}))}catch(e){return[{status:"fail",message:e instanceof Error?e.message:String(e)}]}}})}};async function U(n){try{let t=await f.fromDirectory(n.cwd,{environment:n.env}),e=[],r=new Map;for(let[i,a]of n.detectedLanguages){let o=a.map(l=>t.resolveEntry(l,n.cwd)).find(l=>l!==void 0);o!==void 0&&(e.push({kind:"linter",languageId:i,toolId:o.id}),await h(o.config.check,n.cwd,n.env)||r.set(o.id,{id:`linter-${o.id}-unavailable`,message:`Configured linter ${o.id} cannot run ${JSON.stringify(o.config.check.command)}`}))}return{selections:e,actions:[...r.values()]}}catch(t){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}s(U,"inspectLinterSetup");function W(n,t,e){let r=new Map;for(let i of t){let a=n.resolveEntry(i,e);a!==void 0&&!r.has(a.id)&&r.set(a.id,{entry:a,source:i})}return[...r.values()]}s(W,"applicableLinters");async function Y(n){let t,e,r=s(o=>((e===void 0||t!==o)&&(t=o,e=Z(o)),e),"registryFor"),i={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:s(async o=>(await r(o.cwd),!0),"detect"),async lint(o,l){let m=await r(l.cwd);return N(m).lint(o,l)}},a={protocol:w,apiVersion:3,id:"lint",setup(o){o.addTool(i),o.addDiagnosticSource({id:"lint",async diagnose(l,m){let g=await r(m.cwd);m.signal.throwIfAborted();let C=g.resolve(l,m.cwd);if(!C)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let y=await p(C,{projectRoot:m.cwd,filePath:l,signal:m.signal});return!y.ok&&y.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:y.failure??"Lint check failed"}:{status:"ready",diagnostics:y.diagnostics}}})}};await Promise.all([L(n,a),E(n,_)])}s(Y,"registerLint");async function Z(n){let t=process.env.PI_AGENT_IDE_CONFIG_DIR??n;return f.fromDirectory(t)}s(Z,"loadRegistry");export{Y as a};
|
package/dist/chunk-4KQOODGE.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{a as N,b as O}from"./chunk-QNZVPFSP.js";import{j as b,k as g}from"./chunk-5A25RATC.js";import"./chunk-2SKAED2I.js";import"./chunk-KINKBPPX.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as $}from"node:fs/promises";import U from"node:path";async function E(e){let n=[],t=await $(e,{withFileTypes:!0});for(let i of t){let r=U.join(e,i.name);i.isDirectory()?n.push(...await E(r)):(i.isFile()||i.isSymbolicLink())&&n.push(r)}return n}s(E,"collectFiles");import{readFile as Y}from"node:fs/promises";var k=256*1024;async function T(e){let n=await Y(e);if(n.byteLength>k)throw new Error(`File exceeds the ${k}-byte AST outline limit: ${e}`);if(n.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${e}`);let t=n.toString("utf8").replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`),i=t.endsWith(`
|
|
4
|
-
`)?t.slice(0,-1):t,r=i.length===0?[]:i.split(`
|
|
5
|
-
`);return{content:t,lines:r}}s(T,"readTextFile");var K=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rs",".c",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),H=new Set([".json",".jsonc",".yaml",".yml",".toml"]),R=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),X=new Set(["module","program","source_file"]),q=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),A=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),Z=new Set(["public_field_definition","variable_declarator","assignment"]),F=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function I(e){return K.has(h.extname(e).toLowerCase())}s(I,"isSupportedOutlinePath");var _={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},z={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ee(e){return g([e],z)}s(Ee,"formatAstOutline");var v=class{static{s(this,"AstOutlineManager")}fallbackScopeManager=new O;async readFileOutline(n,t){let i=W(n,t),r=h.relative(t,i)||i;if(!I(i))throw new Error(`AST outline is not supported for ${r}.`);let o=await T(i),c=await N(i,t,o.lines);if(!c)throw new Error(`No AST parser is available for ${r}.`);return await this.createSourceViewBlock(c.rootNode,i,r,t,o.lines,o.content,h.extname(i).toLowerCase())}async formatFile(n,t){let i=W(n,t),r=h.relative(t,i)||i;if(!I(i)){let o=await T(i);return g([G(i,r,o.lines)],_)}try{return g([await this.readFileOutline(i,t)],_)}catch(o){let c=o instanceof Error?o.message:String(o);return g([M(r,c)],_)}}async formatSymbol(n,t){let r=(await E(t)).filter(o=>I(o)).sort();for(let o of r){let c;try{c=await T(o)}catch{continue}let l;try{l=await N(o,t,c.lines)}catch{continue}if(!l)continue;let d=ee(l.rootNode,n);if(!d)continue;let a=h.relative(t,o)||o,u=await this.createSourceViewBlock(d,o,a,t,c.lines,c.content,h.extname(o).toLowerCase(),n,[`defined in: ${a}:${d.startPosition.row+1}`]);return g([u],_)}return g([M("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],_)}async createSourceViewBlock(n,t,i,r,o,c,l,d,a){let u=re(n,c,l),p=await J(this.fallbackScopeManager,t,r,o),S=Q(p),x=u.map(y=>{let f=y.sourceLine,m=f===void 0?void 0:o[f-1]??"",C=(f===void 0?void 0:S.get(f))?.map(D=>` <!-- ${D} -->`).join("")??"";return b({content:y.content,...!(f===void 0||m===void 0)&&{sourceLine:{source:t,lineNumber:f,content:m}},...C.length>0&&{suffix:C}})});return{path:i,...d!==void 0&&{heading:d},...a!==void 0&&{details:a},startLine:n.startPosition.row+1,endLine:n.endPosition.row+1,totalLines:o.length,renderedLines:x}}};function G(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,r)=>b({content:i,sourceLine:{source:e,lineNumber:r+1,content:i}}))}}s(G,"formatUnsupportedSourceBlock");function M(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}s(M,"failedSourceViewBlock");function J(e,n,t,i){return e.getDocumentScopes(n,t,i)}s(J,"getOutlineScopes");function Q(e){let n=new Map;for(let t of e){let i=n.get(t.startLine)??[];i.push(t.beginAnchor.value),n.set(t.startLine,i);let r=n.get(t.endLine)??[];r.push(t.endScopeAnchor.value),n.set(t.endLine,r)}return n}s(Q,"buildScopeMarkers");function W(e,n){return e.startsWith("file://")?decodeURIComponent(e.slice(7)):h.isAbsolute(e)?e:h.resolve(n,e)}s(W,"resolvePath");function ee(e,n){let t,i=s(r=>{if(!t){if(R.has(r.type)&&te(r)===n){t=ne(r);return}for(let o of r.namedChildren)i(o)}},"visit");return i(e),t}s(ee,"findSymbol");function te(e){let n=e.childForFieldName("name");if(n&&F.has(n.type))return n.text;for(let t of e.namedChildren)if(F.has(t.type))return t.text;if(e.type==="lexical_declaration"||e.type==="variable_declaration")return e.namedChildren.find(r=>r.type==="variable_declarator")?.childForFieldName("name")?.text;if(e.type==="function_definition"){let t=e.childForFieldName("declarator");return t?B(t):void 0}}s(te,"getNodeName");function B(e){if(F.has(e.type))return e.text;for(let n of e.namedChildren){let t=B(n);if(t)return t}}s(B,"findNestedName");function ne(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}s(ne,"unwrapDeclaration");function re(e,n,t){let i=[];H.has(t)?j(e,t,i):V(e,t,i);let r=ie(n,e.startIndex),o=oe(n,e.endIndex),c=i.filter(a=>a.start>=r&&a.end<=o).sort((a,u)=>u.start-a.start),l=se(n,r,o);for(let a of c){let u=a.start-r,p=a.end-r,S=ae(a);l.splice(u,p-u,...S)}for(;l.length>0&&/\s/u.test(w(l.at(-1)).char);)l.pop();let d=[[]];for(let a of l)a.char===`
|
|
6
|
-
`?d.push([]):w(d.at(-1)).push(a);return d.map(a=>{let u=[...new Set(a.flatMap(p=>p.sourceLine===void 0?[]:[p.sourceLine]))];return{content:a.map(p=>p.char).join(""),...u.length===1&&{sourceLine:u[0]}}})}s(re,"renderNodeLines");function ie(e,n){return e.lastIndexOf(`
|
|
7
|
-
`,Math.max(0,n-1))+1}s(ie,"lineStartAt");function oe(e,n){let t=e.indexOf(`
|
|
8
|
-
`,n);return t===-1?e.length:t}s(oe,"lineEndAt");function se(e,n,t){let i=e.slice(0,n).split(`
|
|
9
|
-
`).length,r=[];for(let o of e.slice(n,t))r.push({char:o,sourceLine:i}),o===`
|
|
10
|
-
`&&(i+=1);return r}s(se,"mapSourceRange");function ae(e){let n=e.lineSourceLines??[],t=0,i=[];for(let r=0;r<e.text.length;r+=1){let o=w(e.text[r]),c=n[t];i.push(c===void 0?{char:o}:{char:o,sourceLine:c}),o===`
|
|
11
|
-
`&&(t+=1)}return i}s(ae,"mapReplacement");function j(e,n,t){for(let i of e.namedChildren){if(ce(i,n)){le(i)||t.push({start:i.startIndex,end:i.endIndex,text:"\u2026",lineSourceLines:[i.startPosition.row+1]});continue}j(i,n,t)}}s(j,"collectDataReplacements");function ce(e,n){return(n===".json"||n===".jsonc"?["string","number","true","false","null"]:n===".yaml"||n===".yml"?["string_scalar","integer_scalar","float_scalar","boolean_scalar","null_scalar","block_scalar"]:["string","integer","float","boolean","date_time","offset_date_time","local_date_time","local_date","local_time"]).includes(e.type)}s(ce,"isDataScalar");function le(e){let n=e.parent;for(;n&&!n.type.endsWith("pair")&&n.type!=="pair"&&n.type!=="table";)n=n.parent;let t=n?.namedChildren[0];return t!==void 0&&t.startIndex<=e.startIndex&&t.endIndex>=e.endIndex}s(le,"isDataKey");function V(e,n,t,i=!1){if(i&&!de(e)){t.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]});return}if(A.has(e.type)){let r=ue(e);if(r){let o=pe(r,n);t.push({start:r.startIndex,end:r.endIndex,text:o.text,lineSourceLines:o.lineSourceLines});return}}if(Z.has(e.type)){let r=e.childForFieldName("value");if(r&&!A.has(r.type)){t.push({start:r.startIndex,end:r.endIndex,text:"\u2026",lineSourceLines:[r.startPosition.row+1]});return}}for(let r of e.namedChildren)V(r,n,t,X.has(e.type))}s(V,"collectReplacements");function de(e){return R.has(e.type)||q.has(e.type)||e.type==="comment"||e.type.startsWith("preproc")}s(de,"isTopLevelInterfaceNode");function ue(e){let n=e.childForFieldName("body");return n||e.namedChildren.find(t=>t.type==="block"||t.type==="compound_statement"||t.type==="statement_block")}s(ue,"findBody");function pe(e,n){let t=e.startPosition.row+1,i=e.endPosition.row+1;if(n===".py")return{text:"...",lineSourceLines:[t]};let r=e.text.split(`
|
|
12
|
-
`),o=r[0]??"",c=r.at(-1)??"",l=o.indexOf("{"),d=c.lastIndexOf("}");if(l===-1||d===-1)return{text:"\u2026",lineSourceLines:[t]};if(r.length===1){let m=o.slice(l+1,d);return m.trim()===""?{text:e.text,lineSourceLines:[t]}:{text:o.slice(0,l+1)+P(m)+o.slice(d),lineSourceLines:[t]}}let a=o.slice(l+1),u=c.slice(0,d),p=r.slice(1,-1).some(m=>m.trim()!==""),S=a.trim()!=="",x=u.trim()!=="";if(!p&&!S&&!x)return{text:e.text,lineSourceLines:r.map((m,L)=>t+L)};let y=[],f=[];if(y.push(S?o.slice(0,l+1)+P(a):o),f.push(t),!S&&p){let m=r.slice(1,-1).find(L=>L.trim()!=="")?.match(/^\s*/u)?.[0]??"";y.push(`${m}\u2026`),f.push(void 0)}return y.push(x?P(u)+c.slice(d):c),f.push(i),{text:y.join(`
|
|
13
|
-
`),lineSourceLines:f}}s(pe,"renderBodyPlaceholder");function P(e){let n=/^\s*/u.exec(e)?.[0]??"",t=/\s*$/u.exec(e)?.[0]??"";return`${n}\u2026${t}`}s(P,"maskSegment");export{v as AstOutlineManager,Ee as formatAstOutline,I as isSupportedOutlinePath};
|
package/dist/chunk-4SQQKEVD.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{e as le,f as ce,g as fe}from"./chunk-VSP2QQPQ.js";import{a as F,b as V,c as U,d as M,e as B,f as ue}from"./chunk-2ZMYT6ZC.js";import{a as oe,b as ie,c as se}from"./chunk-SSZB66C3.js";import{a as I,b as N,c as te,d as ne,g as re}from"./chunk-JASLOB2X.js";import{b as ae,e as de}from"./chunk-EW2KVKCN.js";import{m as J,o as Z,s as ee}from"./chunk-2SKAED2I.js";import{a as L}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as S}from"typebox";import{DEFAULT_MAX_BYTES as _e,DEFAULT_MAX_LINES as Ie,formatSize as j,truncateHead as Ne}from"@earendil-works/pi-coding-agent";var H=_e,W=Ie;async function D(e,t,r,n){let o=n?.originLine,i=e.content.length===1?e.content[0]:void 0;if(i?.type!=="text")return e;let d=Ne(i.text,{maxBytes:H,maxLines:W});if(d.truncated){let l=r===void 0?void 0:await r(i.text),c=d.firstLineExceedsLimit?Ve(i.text,e.details,t):Ue(d,e.details,t,o),p=l===void 0?c:Fe(c,l);return{...e,content:[{...i,text:pe(d.content,p)}],details:{...je(e.details,d),...l!==void 0&&{temporarySource:l}}}}let a=Be(e.details,t,o);return a===void 0?e:{...e,content:[{...i,text:pe(i.text,a)}]}}s(D,"limitReadOutput");function Fe(e,t){return`${e.slice(0,-1)} Full output: ${t}. Expires after 5 minutes of inactivity.]`}s(Fe,"appendTemporarySource");function Ve(e,t,r){let n=e.split(/\r\n|\r|\n/u,1)[0]??"",o=j(Buffer.byteLength(n,"utf8")),i=K(t,r);return`[${i===void 0?"First output line":`Line ${i}`} is ${o}, exceeds ${j(H)} limit. Use a source-specific tool to read this line in smaller byte ranges.]`}s(Ve,"oversizedFirstLineNotice");function Ue(e,t,r,n){let o=Me(e,t,r);if(o!==void 0&&o.endLine<o.totalLines){let d=e.truncatedBy==="bytes"?` (${j(e.maxBytes)} limit)`:"",a=ge(o.endLine+1,n);return`[Showing lines ${o.startLine}-${o.endLine} of ${o.totalLines}${d}. Use offset=${a} to continue.]`}let i=e.truncatedBy==="lines"?`${e.maxLines} line limit`:`${j(e.maxBytes)} limit`;return`[Output truncated: showing ${e.outputLines} of ${e.totalLines} rendered lines (${i}). Use a smaller line range to read this source.]`}s(Ue,"truncatedOutputNotice");function Me(e,t,r){let n=t.totalLines,o=K(t,r);if(n===void 0||n===0||o===void 0||e.outputLines===0)return;let d=(t.endLine===void 0||t.endLine<o?n:t.endLine)-o+1,a=Math.min(e.outputLines,d);return{startLine:o,endLine:o+a-1,totalLines:n}}s(Me,"shownSourceRange");function Be(e,t,r){if(t.limit===void 0||e.totalLines===void 0||e.totalLines===0)return;let n=K(e,t);if(n===void 0)return;let o=e.endLine===void 0||e.endLine<n?n:e.endLine+1;return o>e.totalLines?void 0:`[${e.totalLines-o+1} more lines in source. Use offset=${ge(o,r)} to continue.]`}s(Be,"explicitLimitNotice");function ge(e,t){return t===void 0?e:e-t+1}s(ge,"continuationOffset");function K(e,t){if(e.startLine!==void 0&&e.startLine>0)return e.startLine;if(e.totalLines===void 0||e.totalLines===0)return;let r=t.offset===void 0?1:Math.trunc(t.offset);return r<0?Math.max(1,e.totalLines+r+1):Math.max(1,r)}s(K,"sourceStartLine");function je(e,t){return{...e,...e.lines!==void 0&&{lines:e.lines.slice(0,t.outputLines)},truncation:t}}s(je,"truncatedDetails");function pe(e,t){return e.length===0?t:`${e}
|
|
2
|
-
|
|
3
|
-
${t}`}s(pe,"appendNotice");function Re(){return{id:"line-numbers",present(e){if(e.lines.length===0)return e;let t=Math.max(...e.lines.map(n=>String(n.lineNumber).length)),r=e.lines.map(n=>({...n,presentation:{...n.presentation,prefix:`${String(n.lineNumber).padStart(t)}|${n.presentation?.prefix??""}`,compactPrefix:n.presentation?.compactPrefix??`${String(n.lineNumber).padStart(t)} \u2502 `}}));return{...e,lines:r}}}}s(Re,"createLineNumberPresenter");function ye(e,t,r,n){if(!Ke(e))return{content:e,source:t,resolvedBy:r,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"other"};let o=e[0].text;return{content:e,source:t,resolvedBy:r,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"text",text:J(t,o)}}s(ye,"createReadState");function G(e,t,r){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return h({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content"});let c=Ge(e.content);return{content:c.content,details:{...me(e),...c.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:c.unsupportedContentBlocks}}}}let n=e.text.lines.length,o=qe(t,n,r?.originLine),i=e.text.lines.slice(o.startIndex,o.endIndex),d=e.textMode==="final"?He(i,o.endIndex<n):Z({...e.text,lines:i.map((c,p)=>({...c,lineEnding:p===i.length-1&&o.endIndex<n?"":c.lineEnding}))}),a=e.content[0];return{content:[{type:"text",text:d,...a.textSignature!==void 0&&{textSignature:a.textSignature}}],details:{...me(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n,lines:i}}}s(G,"projectReadState");function He(e,t){return e.map((r,n)=>`${r.content}${n===e.length-1&&t?"":r.lineEnding}`).join("")}s(He,"renderFinalTextLines");function h(e){return{content:[{type:"text",text:`${e.code}: ${e.message}`}],details:{failure:e},isError:!0}}s(h,"failureResult");function me(e){return{source:e.source,resolvedBy:e.resolvedBy}}s(me,"readDetails");function Ge(e){let t=[],r=[];for(let[o,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}r.push({index:o,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${o}]`})}let n=r[0];return{content:t,...n!==void 0&&{unsupportedContentBlocks:[n,...r.slice(1)]}}}s(Ge,"projectAgentContent");function qe(e,t,r){let n=e.offset===void 0?1:Math.trunc(e.offset),o=We(n,t,r),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,o-1),endIndex:Math.min(t,o-1+i)}}s(qe,"resolveTextRange");function We(e,t,r){if(r===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let n=e<0?r+e:r+Math.max(1,e)-1;return Math.max(1,n)}s(We,"anchoredStartLine");function Ke(e){return e.length===1&&e[0].type==="text"}s(Ke,"isSingleTextContent");import{randomUUID as Ye}from"node:crypto";import{mkdir as ze,mkdtemp as Xe,readFile as Qe,rm as Je,unlink as he,writeFile as Ze}from"node:fs/promises";import{tmpdir as et}from"node:os";import ve from"node:path";var tt=5*6e4,q=class{static{s(this,"TempResourceStore")}resolver;#e=new Map;#i;#t;#s;#o=!1;#n;constructor(t={}){if(this.#i=t.parentDirectory??et(),this.#t=t.ttlMs??tt,!Number.isFinite(this.#t)||this.#t<=0)throw new TypeError("Temporary resource TTL must be a positive finite number");this.resolver={id:"temp",tryResolve:s(r=>Promise.resolve(this.#d(r)),"tryResolve")}}async save(t){if(this.#o)throw new Error("Temporary resource store is closed");let r=await this.#l(),n=Ye(),o=`temp:${n}`,i=ve.join(r,`${n}.txt`);return await Ze(i,t,{encoding:"utf8",flag:"wx"}),this.#e.set(o,{activeReads:0,filePath:i,lastUsedAt:Date.now()}),this.#r(),o}async dispose(){if(this.#o)return;this.#o=!0,this.#a(),this.#e.clear();let t=this.#s;t!==void 0&&await Je(await t,{recursive:!0,force:!0})}#d(t){if(!t.startsWith("temp:"))return{kind:"not-handled"};let r=this.#e.get(t);return r===void 0?{kind:"failed",error:new Error(`Temporary resource ${t} expired or does not exist`)}:r.activeReads===0&&r.lastUsedAt+this.#t<=Date.now()?(this.#e.delete(t),he(r.filePath).catch(()=>{}),this.#r(),{kind:"failed",error:new Error(`Temporary resource ${t} expired or does not exist`)}):{kind:"resolved",resource:{source:t,read:s(()=>this.#u(t),"read")}}}async#u(t){let r=this.#e.get(t);if(r===void 0)throw new Error(`Temporary resource ${t} expired or does not exist`);r.activeReads+=1,this.#r();try{return[{type:"text",text:await Qe(r.filePath,"utf8")}]}finally{r.activeReads-=1,r.lastUsedAt=Date.now(),this.#r()}}async#l(){return this.#s??=(async()=>(await ze(this.#i,{recursive:!0}),Xe(ve.join(this.#i,"pi-agent-read-"))))(),this.#s}#r(){if(this.#a(),this.#o)return;let t=Date.now(),r;for(let n of this.#e.values()){if(n.activeReads>0)continue;let o=n.lastUsedAt+this.#t;r=r===void 0?o:Math.min(r,o)}r!==void 0&&(this.#n=setTimeout(()=>{this.#n=void 0,this.#c().catch(()=>{this.#r()})},Math.max(0,r-t)),this.#n.unref())}async#c(){let t=Date.now(),r=[...this.#e].filter(([,n])=>n.activeReads===0&&n.lastUsedAt+this.#t<=t);await Promise.all(r.map(async([n,o])=>{await he(o.filePath).catch(i=>{if(!(i instanceof Error)||!("code"in i)||i.code!=="ENOENT")throw i}),this.#e.delete(n)})),this.#r()}#a(){this.#n!==void 0&&(clearTimeout(this.#n),this.#n=void 0)}};var nt=S.Object({path:S.Optional(S.String({description:"Complete source resource reference: a filesystem path, URL, protocol source, temporary resource, or typed SEARCH#... selection."})),offset:S.Optional(S.Number()),limit:S.Optional(S.Number()),views:S.Optional(S.Array(S.String()))}),rt=se({kind:"source"}),ot=["lines"];function it(){return[{view:"lines",presenter:Re()}]}s(it,"createBuiltinViewRegistrations");function Ee(e){let t=new q,r=[{resolver:t.resolver,preserveTruncatedOutput:!1,priority:Number.MIN_SAFE_INTEGER,order:0}],n=[],o=it().map((l,c)=>({pluginId:"core",registration:l,order:c})),i=[],d=[],a="read";return{tool:{name:a,label:a,promptSnippet:"Read files, URLs, temporary resources, search selections, and protocol sources, with optional views projected onto text content",description:`Resolve a supported source into agent-native content. Text output is raw by default; pass optional views (string array) to add annotations: "lines" for a line-number column, or plugin views such as "anchors" (LINE#HASH), "ast", "diagnostics", and "changes" when their extensions are installed. Text output is truncated to ${W} lines or ${H/1024}KB, whichever is reached first. Use offset/limit to read a line range and continue large sources; a negative offset reads from the end. A \`path#anchor\` suffix (for example \`src/x.ts#function main\`) starts reading at the anchor's line: offset/limit then count from that line while output keeps absolute line numbers. For anchored reads, omitted offset, offset 0, and offset 1 are equivalent; positive offsets greater than one count forward and negative offsets count upward.`,get promptGuidelines(){return["Use read to examine files and other supported sources instead of cat, sed, head, tail, or similar shell commands.",'You can use read with `views: ["lines"]` to add a line-number column.',"You can use read with `offset` and `limit` to inspect a line range or continue a large source, and with a negative `offset` to read from the end.","You can combine compatible read views in one request.","When a read result is truncated and provides a `temp:` source, you can use read with that source to continue reading the saved full output.",...e?.()??[]]},parameters:nt,renderCall:ie,renderResult(l,c,p,f){let y=l.details.resolvedBy;return((y===void 0?void 0:r.find(({resolver:g})=>g.id===y)?.renderResult)??rt)(l,c,p,f)},async execute(l,c,p,f,y){let x={cwd:y.cwd,...p!==void 0&&{signal:p}};return xe(c,x,r,n,o,t,i,d)}},execute(l,c){return xe(l,c,r,n,o,t,i,d)},registerContributions(l,c){let p=[...c.resolvers??[]],f=[...c.targetResolvers??[]],y=[...c.handlers??[]],x=[...c.views??[]],g=[...c.fragments??[]];vt(l,p,y,r,n),xt(l,g,i);let v=new Set(d.map(({resolver:u})=>u.id));for(let u of f){if(!F(u))throw new TypeError(`Plugin ${l} provided an invalid text target resolver`);if(v.has(u.resolver.id))throw new Error(`Text target resolver ${u.resolver.id} is already registered`);v.add(u.resolver.id)}let R=new Set(o.map(({registration:u})=>u.view)),C=new Set(o.map(({registration:u})=>`${u.view}/${u.presenter.id}`));for(let u of x){if(!M(u))throw new TypeError(`Plugin ${l} provided an invalid view registration`);let E=`${u.view}/${u.presenter.id}`;if(C.has(E))throw new Error(`View ${u.view} already has a presenter ${u.presenter.id}`);R.add(u.view),C.add(E)}for(let u of p)r.push({resolver:u.resolver,...u.renderResult!==void 0&&{renderResult:u.renderResult},priority:u.priority??0,preserveTruncatedOutput:u.preserveTruncatedOutput??!1,order:r.length});for(let u of f)d.push({resolver:u.resolver,priority:u.priority??0,order:d.length});for(let u of y)n.push({pluginId:l,registration:u});for(let u of x)o.push({pluginId:l,registration:u,order:o.length});for(let u of g)i.push({registration:u,priority:u.priority??0,order:i.length})},dispose(){return t.dispose()}}}s(Ee,"createReadTool");async function xe(e,t,r,n,o,i,d,a){let l=[...r].sort((m,P)=>m.priority-P.priority||m.order-P.order),c=[...n],p=[...o].sort((m,P)=>(m.registration.priority??0)-(P.registration.priority??0)||m.order-P.order),f=[...d].sort((m,P)=>m.priority-P.priority||m.order-P.order),y=[...a].sort((m,P)=>m.priority-P.priority||m.order-P.order),x=new Set(e.views??[]),g=new Set([...ot,...p.map(({registration:m})=>m.view)]),v=[...x].filter(m=>!g.has(m));if(e.path!==void 0&&y.length>0){let m=await dt(e,t,y,l,c,p,x,v);if(m!==void 0)return m}let R={request:{...e},resolverContext:t};if(!R.request.path?.startsWith("temp:")){let m=await Le(R,c);if(m.kind==="return")return b(await D(m.result,R.request),v);R=m.context}let C=R.request.path;if(C===void 0||C.length===0)return h({code:"INVALID_REQUEST",message:"No source was provided"});let u=await Y(R,l),E;if(u.kind==="return"&&u.result.isError===!0&&at(u.result)&&!C.startsWith("temp:")){let m=ut(C);if(m!==void 0){let P={result:u,pipeline:R},X={...R,request:{...R.request,path:m.source}},Q=await Y(X,l);Q.kind==="continue"?(u=Q,R=X,E=m.fragment):u=P.result}}if(u.kind==="return")return D(u.result,R.request);R=u.context;let T;if(E!==void 0){let m=await lt(R,f,E);if(typeof m!="number")return m;T=m}if(R.state?.textMode==="final")return b(await D(G(R.state,R.request,{originLine:T}),R.request,void 0,{originLine:T}),v);let A=await Se(R,c);if(A.kind==="return")return b(await D(A.result,R.request,void 0,{originLine:T}),v);R=A.context,R=await be(R,p,x);let k=G(L(R.state),R.request,{originLine:T});R={...R,result:k};let $=await Ce(R,c),O=$.kind==="return"?$.result:L($.context.result),w=R.request.limit===void 0&&R.state?.preserveTruncatedOutput===!0?m=>i.save(m):void 0;return b(await D(O,R.request,w,{originLine:T}),v)}s(xe,"executeRead");var st=new Set(["INVALID_RESOLVER_RESULT","NO_RESOLVER","READ_FAILED","RESOLVE_FAILED"]);function at(e){let t=e.details.failure?.code;return t!==void 0&&st.has(t)}s(at,"isRetryableFailure");async function dt(e,t,r,n,o,i,d,a){for(let{resolver:l}of r){let c;try{c=await l.tryResolve(e.path??"",t)}catch(g){return h({code:"RESOLVE_FAILED",source:e.path,message:_(`Text target resolver ${l.id} failed`,g),cause:g})}if(!ee(c))return h({code:"INVALID_RESOLVER_RESULT",source:e.path,message:`Text target resolver ${l.id} returned an invalid result`,cause:c});let p=c;if(p.kind==="not-handled")continue;if(p.kind==="rejected")return h({code:"RESOLVE_FAILED",source:e.path,message:p.rejection.reason});if(p.kind==="failed")return h({code:"RESOLVE_FAILED",source:e.path,message:p.error instanceof Error?p.error.message:String(p.error)});if(p.targets.length===0)return h({code:"RESOLVE_FAILED",source:e.path,message:"Text target resolver returned no targets"});let f=[],y;for(let g of p.targets){let v=g.ranges??[{start:{lineNumber:1,column:0},end:{lineNumber:1,column:1}}];for(let R of v){let C=Math.max(1,R.end.lineNumber-R.start.lineNumber),u={request:{...e,path:g.source,limit:e.limit??C},resolverContext:t};if(!g.source.startsWith("temp:")){let w=await Le(u,o);if(w.kind==="return"){if(w.result.isError===!0)return b(w.result,a);for(let m of w.result.content)m.type==="text"&&f.push(m.text);y??=w.result.details;continue}u=w.context}let E=await Y(u,n);if(E.kind==="return")return b(E.result,a);let T=await Se(E.context,o);if(T.kind==="return"){if(T.result.isError===!0)return b(T.result,a);for(let w of T.result.content)w.type==="text"&&f.push(w.text);y??=T.result.details;continue}let A=await be(T.context,i,d),k=G(L(A.state),A.request,{originLine:R.start.lineNumber}),$=await Ce({...A,result:k},o);if(k.isError===!0)return b(k,a);let O=$.kind==="return"?$.result:L($.context.result);if(O.isError===!0)return b(O,a);for(let w of O.content)w.type==="text"&&f.push(w.text);y??=O.details}}let x={content:[{type:"text",text:f.join(`
|
|
4
|
-
`)}],details:y??{source:e.path}};return b(await D(x,{path:e.path,views:e.views}),a)}}s(dt,"resolveTextTargets");var we="#";function ut(e){let t=e.indexOf(we);if(!(t<=0||t===e.length-1))return{source:e.slice(0,t),fragment:e.slice(t+we.length)}}s(ut,"splitAnchoredSource");async function lt(e,t,r){let n=L(e.state);if(n.contentKind!=="text")return h({code:"UNSUPPORTED_RANGE",source:n.source,resolverId:n.resolvedBy,message:"Anchored reads require textual content"});if(t.length===0)return h({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver is registered for anchor "${r}"`});for(let{registration:o}of t){let i;try{i=await o.resolve({source:n.source,fragment:r,text:n.text,cwd:e.resolverContext.cwd,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}})}catch(d){return h({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:_(`Fragment resolver ${o.id} failed`,d),cause:d})}if(!ue(i))return h({code:"INVALID_RESOLVER_RESULT",source:n.source,resolverId:o.id,message:`Fragment resolver ${o.id} returned an invalid result`,cause:i});if(i.kind!=="not-handled")return i.kind==="failed"?h({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:i.message}):!Number.isInteger(i.originLine)||i.originLine<1||i.originLine>n.text.lines.length?h({code:"INVALID_RESOLVER_RESULT",source:n.source,resolverId:o.id,message:`Fragment resolver ${o.id} returned out-of-range origin line ${i.originLine}`}):i.originLine}return h({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver handled anchor "${r}"`})}s(lt,"resolveAnchoredOrigin");async function Y(e,t){let r=L(e.request.path),n=e.resolverContext;for(let i of t){let{resolver:d}=i,a;try{a=await d.tryResolve(r,n)}catch(p){return{kind:"return",result:h({code:"RESOLVE_FAILED",source:r,resolverId:d.id,message:_(`Resolver ${d.id} failed`,p),cause:p})}}if(!de(a))return{kind:"return",result:h({code:"INVALID_RESOLVER_RESULT",source:r,resolverId:d.id,message:`Resolver ${d.id} returned an invalid result`,cause:a})};if(a.kind==="not-handled")continue;if(a.kind==="failed")return{kind:"return",result:h({code:"RESOLVE_FAILED",source:r,resolverId:d.id,message:_(`Resolver ${d.id} failed`,a.error),cause:a.error})};let l=a.resource;if(l.read===void 0)return{kind:"return",result:h({code:"UNSUPPORTED_CAPABILITY",source:l.source,resolverId:d.id,message:`Resource ${l.source} does not support reading`})};let c;try{c=await l.read({...n.signal!==void 0&&{signal:n.signal}})}catch(p){return{kind:"return",result:h({code:"READ_FAILED",source:l.source,resolverId:d.id,message:_(`Unable to read ${l.source}`,p),cause:p})}}return ae(c)?{kind:"continue",context:{...e,state:ye(c,l.source,d.id,{preserveTruncatedOutput:i.preserveTruncatedOutput,textMode:d.id==="temp"?"final":"normal"})}}:{kind:"return",result:h({code:"INVALID_RESOURCE_CONTENT",source:l.source,resolverId:d.id,message:`Resource ${l.source} returned invalid content`,cause:c})}}let o=`No resolver handled ${r}`;return{kind:"return",result:le(h({code:"NO_RESOLVER",source:r,message:o}),o)}}s(Y,"resolveSource");async function Le(e,t){let r=e;for(let n of t){if(n.registration.stage!=="pre-read")continue;let o=await z(n.registration.handler,r,n.pluginId,"pre-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}s(Le,"runPreReadHandlers");async function Se(e,t){let r=e.state,n=r===void 0?[]:t.filter(i=>i.registration.stage==="read"&&ht(i.registration,r)),o=e;for(let i of n){let d=i.registration;if(d.stage!=="read")continue;let a=await z(d.handler,o,i.pluginId,"read");if(a.kind==="return")return a;o=a.context}return{kind:"continue",context:o}}s(Se,"runReadHandlers");async function be(e,t,r){let n=e.state;if(n?.contentKind!=="text"||r.size===0)return e;let o=n.text,i={purpose:"read",source:n.source,cwd:e.resolverContext.cwd,resolvedBy:n.resolvedBy,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}},d=t.filter(({registration:f})=>r.has(f.view)),a=new Set(d.flatMap(({registration:f})=>f.includes??[])),l=d.filter(({registration:f})=>!a.has(f.view)),c=await Promise.all(l.map(async({registration:f})=>({presenterId:f.presenter.id,document:await f.presenter.present(o,i)}))),p=ct(o,c);return{...e,state:{...n,text:p}}}s(be,"runTextPresenters");function b(e,t){if(t.length===0)return e;let r=`note: ignored unknown views: ${t.join(", ")}`,n=e.content[0],o=n?.type==="text"?[{...n,text:`${r}
|
|
5
|
-
${n.text}`}]:[...e.content];return{...e,content:o,details:{...e.details,ignoredViews:t}}}s(b,"withIgnoredViews");function ct(e,t){let r=e.lines;for(let n of t)ft(e,n),r=r.map((o,i)=>pt(L(e.lines[i]),o,L(n.document.lines[i])));return r===e.lines?e:{...e,lines:r}}s(ct,"mergeViewContributions");function ft(e,t){let r=t.document;if(r.source!==e.source||r.content!==e.content||r.lines.length!==e.lines.length)throw new Error(`Text presenter ${t.presenterId} changed canonical text`);for(let[n,o]of r.lines.entries()){let i=L(e.lines[n]);if(o.lineNumber!==i.lineNumber||o.content!==i.content||o.lineEnding!==i.lineEnding)throw new Error(`Text presenter ${t.presenterId} changed canonical text`)}}s(ft,"assertPresentationOnly");function pt(e,t,r){let n=gt(e.presentation,t.presentation,r.presentation),o=yt(e.metadata,t.metadata,r.metadata);return n===t.presentation&&o===t.metadata?t:{...t,...n!==void 0&&{presentation:n},...o!==void 0&&{metadata:o}}}s(pt,"mergePresentedLine");function gt(e,t,r){if(r===e)return t;let n=Te(e?.prefix,t?.prefix,r?.prefix),o=Te(e?.suffix,t?.suffix,r?.suffix),i=Pe(e?.before,t?.before,r?.before),d=Pe(e?.after,t?.after,r?.after),a=r?.marker===e?.marker?t?.marker:r?.marker;return n===t?.prefix&&o===t?.suffix&&i===t?.before&&d===t?.after&&a===t?.marker?t:{...t,...n!==void 0&&{prefix:n},...o!==void 0&&{suffix:o},...i!==void 0&&{before:i},...d!==void 0&&{after:d},...a!==void 0&&{marker:a}}}s(gt,"mergeLinePresentation");function Te(e,t,r){if(r===e)return t;let n=e??"",o=t??"",i=r??"";return n.length>0&&i.startsWith(n)?`${o}${i.slice(n.length)}`:n.length>0&&i.endsWith(n)?`${i.slice(0,-n.length)}${o}`:`${o}${i}`}s(Te,"mergePresentedText");function Pe(e,t,r){if(r===e)return t;let n=e??[],o=t??[],i=r??[];return Rt(i,n)?[...o,...i.slice(n.length)]:mt(i,n)?[...i.slice(0,i.length-n.length),...o]:[...o,...i]}s(Pe,"mergePresentedRows");function Rt(e,t){return t.length>0&&t.length<=e.length&&t.every((r,n)=>e[n]===r)}s(Rt,"startsWithRows");function mt(e,t){let r=e.length-t.length;return t.length>0&&r>=0&&t.every((n,o)=>e[r+o]===n)}s(mt,"endsWithRows");function yt(e,t,r){if(r===e||r===void 0)return t;let n=Object.fromEntries(Object.entries(r).filter(([o,i])=>e?.[o]!==i));return Object.keys(n).length===0?t:{...t,...n}}s(yt,"mergeLineMetadata");async function Ce(e,t){let r=e;for(let n of t){if(n.registration.stage!=="post-read")continue;let o=await z(n.registration.handler,r,n.pluginId,"post-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}s(Ce,"runPostReadHandlers");async function z(e,t,r,n){try{return await e(t)}catch(o){return{kind:"return",result:h({code:"PIPELINE_FAILED",...t.state?.source===void 0?t.result?.details.source===void 0?{}:{source:t.result.details.source}:{source:t.state.source},pluginId:r,stage:n,message:`Plugin ${r} failed during ${n}`,cause:o})}}}s(z,"invokeHandler");function ht(e,t){return(e.when.resolvedBy==="any"||e.when.resolvedBy===t.resolvedBy)&&(e.when.contentKind==="any"||e.when.contentKind===t.contentKind)}s(ht,"matchesReadState");function vt(e,t,r,n,o){let i=new Set(n.map(({resolver:a})=>a.id));for(let a of t){if(!V(a))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(i.has(a.resolver.id))throw new Error(`Resource resolver ${a.resolver.id} is already registered`);i.add(a.resolver.id)}let d=new Set(o.filter(a=>a.pluginId===e).map(a=>a.registration.stage));for(let a of r){if(!U(a))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(d.has(a.stage))throw new Error(`Plugin ${e} already handles ${a.stage}`);d.add(a.stage)}}s(vt,"validateContributions");function xt(e,t,r){let n=new Set(r.map(({registration:o})=>o.id));for(let o of t){if(!B(o))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(n.has(o.id))throw new Error(`Fragment resolver ${o.id} is already registered`);n.add(o.id)}}s(xt,"validateFragmentRegistrations");function _(e,t){return!(t instanceof Error)||t.message.length===0?e:`${e}: ${t.message}`}s(_,"appendErrorMessage");function $e(){let e=new Set,t=new Map,r=Ee(()=>Pt(t)),n=Promise.resolve();return{read:r,registerPlugin(o){let i=wt(o);if(i!==void 0)return Promise.reject(i);let d=t.get(o.id);if(d?.plugin===o)return d.ready;if(d!==void 0)return Promise.reject(new Error(`Plugin ${o.id} is already registered`));let a={status:"pending"},l=[],c=[],p=Tt(o.id,r,c,l),f=n.then(async()=>{try{await o.setup(p.api),p.commit(),a.status="active";return}catch(x){throw p.close(),x}}),y={lifecycle:a,plugin:o,promptGuidelines:c,promptContributions:l,ready:f};return t.set(o.id,y),e.add(f),n=f.catch(()=>{}),f.then(()=>{e.delete(f)},()=>{e.delete(f),t.get(o.id)===y&&t.delete(o.id)}),f},renderPluginPromptGuideline:s(()=>Et(t),"renderPluginPromptGuideline"),async waitForPendingPlugins(){await Promise.all(e)}}}s($e,"createReadCore");function wt(e){if(e.protocol!==I)return new Error(`Plugin ${e.id} uses an unsupported protocol`);if(e.apiVersion!==N)return new Error(`Plugin ${e.id} uses an unsupported API version`);if(e.id.trim().length===0)return new Error("Plugin ID must not be empty")}s(wt,"getPluginValidationError");function Tt(e,t,r,n){let o=[],i=[],d=[],a=[],l=[],c=[],p=[],f="setup",y=s(()=>{if(f==="closed")throw new Error(`Plugin ${e} API is closed`)},"assertAvailable");return{api:{read(g,v){return y(),t.execute(g,v)},addResolver(g){if(y(),!V(g))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(f==="setup"){d.push(g);return}t.registerContributions(e,{resolvers:[g]})},addTargetResolver(g){if(y(),!F(g))throw new TypeError(`Plugin ${e} provided an invalid text target resolver`);if(f==="setup"){a.push(g);return}t.registerContributions(e,{targetResolvers:[g]})},addHandler(g){if(y(),!U(g))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(f==="setup"){l.push(g);return}t.registerContributions(e,{handlers:[g]})},addView(g){if(y(),!M(g))throw new TypeError(`Plugin ${e} provided an invalid view registration`);if(f==="setup"){c.push(g);return}t.registerContributions(e,{views:[g]})},addFragmentResolver(g){if(y(),!B(g))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(f==="setup"){p.push(g);return}t.registerContributions(e,{fragments:[g]})},describe(g){if(y(),o.length>0||n.length>0)throw new Error(`Plugin ${e} provides more than one description`);let v=Ae(g);if(f==="setup"){o.push(v);return}n.push(v)},addPromptGuideline(g){y();let v=Ae(g);if(f==="setup"){i.push(v);return}r.push(v)}},close(){f="closed"},commit(){if(f!=="setup")throw new Error(`Plugin ${e} setup contributions cannot be committed`);t.registerContributions(e,{resolvers:d,targetResolvers:a,handlers:l,views:c,fragments:p}),n.push(...o),r.push(...i),f="active"}}}s(Tt,"createPluginContributionController");function Pt(e){let t=[];for(let r of e.values())if(r.lifecycle.status==="active")for(let n of r.promptGuidelines){let o=De(n);o!==void 0&&t.push(o)}return t}s(Pt,"renderPromptGuidelines");function Et(e){let t=[];for(let r of e.values()){if(r.lifecycle.status!=="active")continue;let n=r.promptContributions[0];if(n===void 0)continue;let o=De(n);o!==void 0&&t.push(Lt(r.plugin.id,o))}return t.length===0?void 0:St(["Read supports these installed protocols:",...t].join(`
|
|
6
|
-
`))}s(Et,"renderPluginPromptGuideline");function Ae(e){if(typeof e=="string")return Oe(e);if(typeof e=="function")return e;throw new TypeError("Read plugin prompt description must be a string or callback")}s(Ae,"normalizeDescriptionSource");function De(e){if(typeof e=="string")return e;let t=e();return t===void 0?void 0:Oe(t)}s(De,"renderDescriptionSource");function Oe(e){if(typeof e!="string")throw new TypeError("Read plugin prompt description must be a string");let t=e.replaceAll(`\r
|
|
7
|
-
`,`
|
|
8
|
-
`).replaceAll("\r",`
|
|
9
|
-
`).split(`
|
|
10
|
-
`).map(n=>n.trimEnd());for(;t[0]?.trim().length===0;)t.shift();for(;t.at(-1)?.trim().length===0;)t.pop();let r=t.join(`
|
|
11
|
-
`);if(r.trim().length===0)throw new Error("Read plugin prompt description is empty");return r}s(Oe,"normalizeDescription");function Lt(e,t){let[r,...n]=t.split(`
|
|
12
|
-
`);return[`- \`${bt(e)}\` \u2014 ${r??""}`,...n.map(o=>` ${o}`)].join(`
|
|
13
|
-
`)}s(Lt,"renderPromptEntry");function St(e){let[t,...r]=e.split(`
|
|
14
|
-
`);return[t??"",...r.map(n=>n.length===0?n:` ${n}`)].join(`
|
|
15
|
-
`)}s(St,"indentGuidelineContinuation");function bt(e){return e.replaceAll("`","\\`")}s(bt,"escapeInlineCode");function Ct(e){return typeof e=="object"&&e!==null}s(Ct,"isRecord");async function ke(e){let t=$e(),r=e.events.on(ne,o=>{if(!re(o))throw new Error("Invalid pi-agent-read plugin registration request");o.accept(t.registerPlugin(o.plugin))});e.on("session_shutdown",async()=>{r(),await t.read.dispose()});let n=new ce;e.registerTool(fe(t.read.tool,n)),e.on("tool_result",o=>{if(!(o.toolName!=="read"||!Ct(o.details)))return{details:oe(o.details,o.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
|
|
16
|
-
`)),...o.details.failure!==void 0&&{isError:!0}}}),e.events.emit(te,{protocol:I,apiVersion:N}),await t.waitForPendingPlugins()}s(ke,"registerReadCore");export{ke as a};
|
package/dist/chunk-52BM6J6I.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as j,b as D}from"./chunk-QNZVPFSP.js";import{b as _}from"./chunk-U4D6FT66.js";import{a as x}from"./chunk-ERVMDQGX.js";import{a as v,b as w}from"./chunk-VFBLX4TG.js";import{c as E}from"./chunk-SSZB66C3.js";import{a as T}from"./chunk-ORAPGW7W.js";import{a as P,b as L}from"./chunk-JASLOB2X.js";import{a as M}from"./chunk-E2RESHYR.js";import{a as O,b as k}from"./chunk-T2RPMEM2.js";import{a as N}from"./chunk-EEH4WYI7.js";import{a as $,b as C,c as I}from"./chunk-266RH77Z.js";import{a as y,b as A,c as R,l as S}from"./chunk-5A25RATC.js";import{g as b}from"./chunk-7NDBZ4WX.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as W}from"node:fs/promises";var h=new Set(["c","cpp","javascript","typescript","python","rust","json","yaml","toml"]),H={protocol:v,apiVersion:1,id:"ast",setup(n){n.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(r=>h.has(r))?await b({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),n.addCheck({id:"parsers",title:"AST",async run(e){let s=[];for(let r of e.detectedLanguageIds){if(!h.has(r))continue;let t=e.files.find(o=>Z(o,r));if(t!==void 0)try{let o=await W(t,"utf8"),a=await j(t,e.cwd,o.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`));s.push(a===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:t})}catch(o){s.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return s.length>0?s:[{status:"skip",message:"No supported AST files found"}]}}),n.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>h.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let s=await _("ast-grep",["--version"],e.cwd,e.env);return[s.ok?{status:"pass",message:"ast-grep is available",detail:s.detail}:{status:"fail",message:"ast-grep is not available",detail:s.detail}]}})}};function Z(n,e){let s=n.slice(n.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],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(s)??!1}i(Z,"matchesLanguage");var Q,q;function V(n){return{id:"ast",tryResolve(e,s){return Promise.resolve(ee(e,s,n))}}}i(V,"createAstOutlineResolver");function ee(n,e,s){let r;try{r=y(n,"ast")}catch(a){return{kind:"failed",error:a}}if(r===void 0)return{kind:"not-handled"};let t;try{t=A(r.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:R("ast",t),async read({signal:a}){a?.throwIfAborted();let d=await(q??=import("./chunk-4KQOODGE.js")),u=await(s??(Q??=new d.AstOutlineManager)).readFileOutline(t,e.cwd);return a?.throwIfAborted(),[d.formatAstOutline(u)]}}}}i(ee,"resolveAstOutlineSource");var B="pi-agent-ast";function G(n){return{id:"ast-scopes",async present(e,s){if(s.resolvedBy!=="filesystem")return e;try{let r=await n.getDocumentScopes(e.source,s.cwd,e.lines.map(o=>o.content)),t=te(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}i(G,"createAstScopePresenter");function Y(){return n=>{let e=n.state,s=n.result;if(e?.contentKind!=="text"||s===void 0)return{kind:"continue",context:n};let r=s.details.lines;if(r===void 0)return{kind:"continue",context:n};let t=new Map(e.text.lines.map(c=>[c.lineNumber,c])),o=new Set(r.map(c=>c.lineNumber)),a=new Map;for(let c of r){let l=t.get(c.lineNumber),p=F(l);for(let m of p?.boundaries??[]){if(o.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&a.set(m.endLine,g)}}if(a.size===0)return{kind:"continue",context:n};let d=[...a.values()].sort((c,l)=>c.lineNumber-l.lineNumber),f=[...r,...d],u=ne(s,f,r.at(-1));return{kind:"continue",context:{...n,result:u}}}}i(Y,"createAstScopePostReadHandler");function te(n,e){if(e.length===0)return n;let s=new Map,r=new Map;for(let t of e){let o=s.get(t.startLine)??[];o.push(t.beginAnchor.value),s.set(t.startLine,o);let a=r.get(t.startLine)??[];a.push({endLine:t.endLine}),r.set(t.startLine,a);let d=s.get(t.endLine)??[];d.push(t.endScopeAnchor.value),s.set(t.endLine,d)}return n.map(t=>{let o=s.get(t.lineNumber),a=r.get(t.lineNumber);return o===void 0&&a===void 0?t:{...t,...o!==void 0&&{presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${o.map(d=>` <!-- ${d} -->`).join("")}`}},metadata:{...t.metadata,[B]:{...F(t),...a!==void 0&&{boundaries:a}}}}})}i(te,"addScopeMarkers");function F(n){let e=n?.metadata?.[B];if(!(typeof e!="object"||e===null))return e}i(F,"getAstScopeMetadata");function ne(n,e,s){let r=n.content.length===1?n.content[0]:void 0;if(r?.type!=="text"||n.details.lines===void 0)return n;let t=e.slice(n.details.lines.length);if(t.length===0)return n;let o=s?.lineEnding!==void 0&&s.lineEnding.length>0?s.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
|
|
5
|
-
`,a=t.map((u,c)=>{let p=c===t.length-1?u.lineEnding:u.lineEnding||o,m=u.presentation?.prefix??"",g=u.presentation?.suffix??"";return`${m}${u.content}${g}${p}`}).join(""),d=/(?:\r\n|\r|\n)$/.test(r.text)?"":o,f=`${r.text}${d}${a}`;return{...n,content:[{...r,text:f}],details:{...n.details,lines:e}}}i(ne,"appendTextLines");var K=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function X(n){return{id:"ast-scope",description:"Use `scope-begin-HASH` or `scope-end-HASH` as shown beside source lines; a numeric suffix may distinguish repeated scopes.",renderFull(e){return e},renderCompact(e){return K.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,s){if(!K.test(e))return{kind:"not-handled"};try{let t=(await n.getDocumentScopes(s.source,s.cwd,s.lines)).find(o=>o.beginAnchor.value===e||o.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}}}}}i(X,"createAstScopeAnchorResolver");import{spawn as re}from"node:child_process";function U(){return{id:"ast",async tryResolve(n,e){if(!n.query.startsWith("ast:"))return{kind:"not-handled"};let s=n.query.slice(4).trim();if(s.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let r=await se(s,n,e.cwd,e.signal),t=n.limit??100;return{kind:"resolved",payload:{pattern:s,matches:r.slice(0,t),complete:r.length<=t}}},format(n){let e=n;if(e.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:e};let s=e.matches.flatMap((r,t)=>[`${String(t+1)}. ${r.file}:${String(r.range.start.line+1)}:${String(r.range.start.column+1)} ${r.language}`,` ${r.lines.trim()}`]);return e.complete||s.push("Result limit reached."),{content:[{type:"text",text:s.join(`
|
|
6
|
-
`)}],details:e}}}}i(U,"createAstSearchResolver");function se(n,e,s,r){let t=["run","--pattern",n,"--json=compact","--no-ignore","parent"];for(let o of J(e.include))t.push("--globs",o);for(let o of J(e.exclude))t.push("--globs",`!${o}`);return t.push(e.path??"."),new Promise((o,a)=>{let d=re("ast-grep",t,{cwd:s,stdio:["ignore","pipe","pipe"]}),f="",u="";d.stdout.setEncoding("utf8"),d.stderr.setEncoding("utf8"),d.stdout.on("data",l=>f+=l),d.stderr.on("data",l=>u+=l);let c=i(()=>{d.kill("SIGTERM")},"abort");r?.addEventListener("abort",c,{once:!0}),d.once("error",a),d.once("close",l=>{if(r?.removeEventListener("abort",c),r?.aborted===!0){a(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(l!==0&&l!==1){a(new Error(u.trim()||`ast-grep exited with code ${String(l)}`));return}try{let p=JSON.parse(f.length===0?"[]":f);if(!Array.isArray(p))throw new TypeError("ast-grep returned non-array JSON");o(p)}catch(p){a(p instanceof Error?p:new Error(String(p)))}})})}i(se,"runAstGrep");function J(n){return n?.split(",").map(e=>e.trim()).filter(Boolean)??[]}i(J,"splitGlobs");var oe=E({kind:"code-view",label:"AST"});async function z(n){let e=new D,s=G(e),r={protocol:P,apiVersion:L,id:"ast",setup(o){o.addResolver({resolver:V(),renderResult:oe}),o.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:S()}),o.addView({view:"ast",presenter:s}),o.addHandler({stage:"post-read",handler:Y()}),o.describe("Provides compact structural outlines of source files through `ast:<path>` and the `ast` view."),o.addPromptGuideline("You can use read with `ast:<path>` for a compact structural overview of a source file, including its classes, functions, signatures, and other declarations."),o.addPromptGuideline('You can use read with `views: ["ast"]` to add scope boundaries alongside the file\'s source text.')}},t={protocol:$,apiVersion:C,id:"ast",setup(o){o.addAnchorResolver({resolver:X(e),kind:I,type:"auxiliary"}),o.addTextPresenter({presenter:s})}};await Promise.all([T(n,r),x(n,H),N(n,t),M(n,{protocol:O,apiVersion:k,id:"ast-search",setup(o){o.addResolver({resolver:U()}),o.describe("Use `ast:<pattern>` for structural code search through ast-grep. Optional path and glob fields limit the workspace scope."),o.addPromptGuideline("You can use search with `ast:<pattern>` for structural code search. You can limit it with `path`, `include`, and `exclude`.")}})])}i(z,"registerAst");export{z as a};
|
package/dist/chunk-5BWUVAR4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-EEH4WYI7.js";import{a as s,b as l,c}from"./chunk-266RH77Z.js";import{a as i}from"./chunk-2SKAED2I.js";import{a as t}from"./chunk-EI7MMDWY.js";var o=class extends i{static{t(this,"ConstantTextAnchor")}constructor(n,r){super(n,r)}};function p(){return{id:"file-position",description:"`begin` and `end` select the first and last existing lines.",renderFull(e){return e},renderCompact(e){return e==="begin"?"file start":"file end"},tryResolve(e,n){return Promise.resolve(a(e,n))}}}t(p,"createConstantTextAnchorResolver");function a(e,n){return e!=="begin"&&e!=="end"?{kind:"not-handled"}:n.lines.length===0?{kind:"failed",error:new Error(`${e} cannot resolve in an empty file`)}:{kind:"resolved",anchor:new o(e,e==="begin"?1:n.lines.length)}}t(a,"resolveConstantAnchor");async function T(e){await d(e,{protocol:s,apiVersion:l,id:"text-anchor-constant",setup(r){r.addAnchorResolver({resolver:p(),kind:c,type:"constant"})}})}t(T,"registerConstantTextAnchors");export{T as a};
|
package/dist/chunk-6DN7NO7L.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{v as r}from"./chunk-EW2KVKCN.js";import{p as e}from"./chunk-2SKAED2I.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:e(),priority:300};async function i(o){await r(o,n)}t(i,"registerWebText");export{i as a};
|
package/dist/chunk-6SMFVLTY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as x,e as T}from"./chunk-PETQCA7G.js";import{a as p}from"./chunk-ORAPGW7W.js";import{a as l,b as m}from"./chunk-JASLOB2X.js";import{a as f}from"./chunk-EEH4WYI7.js";import{a as u,b as h,c as P}from"./chunk-266RH77Z.js";import{i as d}from"./chunk-2SKAED2I.js";import{a as s}from"./chunk-EI7MMDWY.js";function g(){return{id:"line-hash",present(r,o){let i=r.lines.map(e=>{let n=o.resolvedBy==="filesystem"?{lineNumber:e.lineNumber,content:e.content}:d(e);return n===void 0?void 0:{anchor:x(n.lineNumber,n.content),lineNumber:n.lineNumber}}),a=Math.max(0,...i.map(e=>e?.anchor.value.length??0)),t=Math.max(0,...i.map(e=>String(e?.lineNumber??"").length)),E=r.lines.map((e,n)=>{let c=i[n];return c===void 0?e:{...e,presentation:{...e.presentation,prefix:`${c.anchor.value.padStart(a)}|${e.presentation?.prefix??""}`,compactPrefix:e.presentation?.compactPrefix??`${String(c.lineNumber).padStart(t)} \u2502 `}}});return{...r,lines:E}}}}s(g,"createLineHashPresenter");async function A(r){let o=g(),i={protocol:l,apiVersion:m,id:"text-anchor-line-hash",setup(t){t.addView({view:"anchors",includes:["lines"],presenter:o}),t.describe("Adds `LINE#HASH` anchors to textual read results that request the `anchors` view."),t.addPromptGuideline('You can use read with `views: ["anchors"]` to add `LINE#HASH` anchors for later edits.')}},a={protocol:u,apiVersion:h,id:"text-anchor-line-hash",setup(t){t.addAnchorResolver({resolver:T(),kind:P,type:"major"}),t.addTextPresenter({presenter:o})}};await Promise.all([p(r,i),f(r,a)])}s(A,"registerLineHashTextAnchor");export{A as a};
|
package/dist/chunk-7NDBZ4WX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import N from"cross-spawn";import{constants as F}from"node:fs";import{access as O,readFile as h,writeFile as b}from"node:fs/promises";import S from"node:os";import s from"node:path";import{fileURLToPath as I}from"node:url";var j=1;function A(e){return s.join(e,".pi","pi-agent-ide")}i(A,"projectIdeConfigDirectory");function M(e,o){return s.join(A(e),`${o}.json`)}i(M,"projectIdeConfigPath");function _(e,o,n={}){let t=(n.environment??process.env).PI_CODING_AGENT_DIR?.trim(),c=t===void 0||t.length===0?s.join(n.homeDirectory??S.homedir(),".pi","agent"):s.resolve(t);return{project:M(e,o),global:s.join(c,"extensions","pi-agent-ide",`${o}.json`),builtIn:I(new URL(`tool-config/${o}.json`,new URL("../src/api/tool-config.ts",import.meta.url).href))}}i(_,"resolveToolConfigPaths");async function Q(e,o,n,r={}){let t=_(e,o,r),c=[{layer:"project",sourcePath:t.project,optional:!0},{layer:"global",sourcePath:t.global,optional:!0},{layer:"built-in",sourcePath:t.builtIn,optional:!1}],a=[],g=new Set;for(let d of c){let w=await J(d,o,n);for(let[l,y]of Object.entries(w))g.has(l)||(g.add(l),a.push({id:l,config:y,layer:d.layer,sourcePath:d.sourcePath}))}return{entries:a,paths:t}}i(Q,"loadLayeredToolConfig");function Y(e,o,n){let r=s.extname(o).toLowerCase();if(e.extensions.every(a=>!(G(a)===r||a==="*")))return!1;let t=s.relative(n,o).split(s.sep).join("/"),c=i(a=>a?.some(g=>s.matchesGlob(t,g))??!1,"matches");return(e.include===void 0||c(e.include))&&!c(e.exclude)}i(Y,"matchesConfiguredFile");async function Z(e,o,n=process.env){p(e,"process");let r=m(e.command[0]).replaceAll("{project}",o),t=L(e,o,n),c=s.isAbsolute(r)||s.dirname(r)!=="."?[s.resolve(o,r)]:(t.PATH??"").split(s.delimiter).filter(Boolean).map(a=>s.join(a,r));for(let a of c)try{return await O(a,F.X_OK),!0}catch{}return!1}i(Z,"hasConfiguredExecutable");async function D(e,o){p(e,"process");let n=e.command.map(d=>B(d,o)),r=m(n[0]),t=n.slice(1),c=e.cwd==="file"?s.dirname(o.filePath):o.projectRoot,a=e.successExitCodes??[0],g=L(e,o.projectRoot,o.env??process.env);return new Promise((d,w)=>{let l=N(r,t,{cwd:c,env:g,signal:o.signal,killSignal:"SIGKILL",stdio:["ignore","pipe","pipe"]}),y="",P="",v=m(l.stdout),T=m(l.stderr),E=!1,x=setTimeout(()=>{E=!0,l.kill("SIGKILL")},e.timeoutMs??3e4);v.setEncoding("utf8"),T.setEncoding("utf8"),v.on("data",f=>{y+=f}),T.on("data",f=>{P+=f}),l.on("error",f=>{clearTimeout(x),w(f)}),l.on("close",f=>{clearTimeout(x),d({ok:!E&&f!==null&&a.includes(f),exitCode:f,stdout:y,stderr:P})})})}i(D,"runConfiguredProcess");async function ee(e,o){let n=await h(o.filePath,"utf8"),r=await D(e.run,o);if(!r.ok)return e.output==="in-place"&&await h(o.filePath,"utf8")!==n&&await b(o.filePath,n,"utf8"),{ok:!1,changed:!1};e.output==="stdout"&&r.stdout!==n&&await b(o.filePath,r.stdout,"utf8");let t=await h(o.filePath,"utf8");return{ok:!0,changed:n!==t}}i(ee,"runConfiguredFormatter");function oe(e){let o=R(e,"formatters");for(let[n,r]of Object.entries(o.entries)){let t=u(r,`formatter ${n}`);if(k(t,`formatter ${n}`),p(t.run,`formatter ${n}.run`),t.output!=="in-place"&&t.output!=="stdout")throw new Error(`formatter ${n}.output must be in-place or stdout`)}return e}i(oe,"parseFormattersConfig");function ne(e){let o=R(e,"linters"),n=new Set(["pi-json","eslint-json","sarif","checkstyle","gcc","clang","regex"]);for(let[r,t]of Object.entries(o.entries)){let c=u(t,`linter ${r}`);k(c,`linter ${r}`),p(c.check,`linter ${r}.check`),c.fix!==void 0&&p(c.fix,`linter ${r}.fix`);let a=u(c.diagnostics,`linter ${r}.diagnostics`);if(!n.has(String(a.format)))throw new Error(`linter ${r} has an unsupported diagnostics format`);if(a.format==="regex"&&typeof a.pattern!="string")throw new Error(`linter ${r} regex diagnostics require pattern`)}return e}i(ne,"parseLintersConfig");function R(e,o){let n=u(e,"tool config");if(n.version!==j)throw new Error(`tool config version must be ${j}`);return{entries:u(n[o],o)}}i(R,"configRoot");function k(e,o){C(e.extensions,`${o}.extensions`,!1),e.include!==void 0&&C(e.include,`${o}.include`,!1),e.exclude!==void 0&&C(e.exclude,`${o}.exclude`,!0)}i(k,"assertMatcher");function p(e,o){let n=u(e,o);if(C(n.command,`${o}.command`,!1),n.cwd!==void 0&&n.cwd!=="project"&&n.cwd!=="file")throw new Error(`${o}.cwd must be project or file`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||Number(n.timeoutMs)<=0))throw new Error(`${o}.timeoutMs must be positive`);if(n.successExitCodes!==void 0&&(!Array.isArray(n.successExitCodes)||n.successExitCodes.some(r=>!Number.isInteger(r))))throw new Error(`${o}.successExitCodes must contain integers`);if(n.env!==void 0){let r=u(n.env,`${o}.env`);if(Object.values(r).some(t=>typeof t!="string"))throw new Error(`${o}.env values must be strings`)}}i(p,"assertProcessConfig");function C(e,o,n){if(!Array.isArray(e)||!n&&e.length===0||e.some(r=>typeof r!="string"||r.length===0))throw new Error(`${o} must be ${n?"an":"a non-empty"} array of strings`)}i(C,"assertStringArray");function u(e,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${o} must be an object`);return e}i(u,"configRecord");function G(e){return e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`}i(G,"normalizeExtension");async function J(e,o,n){let r;try{r=await h(e.sourcePath,"utf8")}catch(t){if(e.optional&&V(t))return{};throw new Error(`Cannot read ${e.layer} ${o} config at ${e.sourcePath}: ${$(t)}`,{cause:t})}try{return n(JSON.parse(r))}catch(t){throw new Error(`Invalid ${e.layer} ${o} config at ${e.sourcePath}: ${$(t)}`,{cause:t})}}i(J,"readToolConfigLayer");function V(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}i(V,"isMissingFile");function $(e){return e instanceof Error?e.message:String(e)}i($,"errorMessage");function L(e,o,n){let r={...n,...e.env},t=s.resolve(o,"node_modules",".bin");return r.PATH=[t,r.PATH].filter(Boolean).join(s.delimiter),r}i(L,"createConfiguredProcessEnvironment");function B(e,o){let n=s.relative(o.projectRoot,o.filePath);return e.replaceAll("{project}",o.projectRoot).replaceAll("{fileDir}",s.dirname(o.filePath)).replaceAll("{relativeFile}",n).replaceAll("{file}",o.filePath)}i(B,"expandPlaceholders");export{j as a,A as b,M as c,_ as d,Q as e,Y as f,Z as g,D as h,ee as i,oe as j,ne as k,L as l};
|
package/dist/chunk-AP7Z3VWC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p}from"./chunk-ERVMDQGX.js";import{a as l,b as c}from"./chunk-VFBLX4TG.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("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(o,i,s,r,n,a){return{id:o,name:i,extensions:s,projectMarkers:r,...n&&{ast:n},...a&&{fileNames:a}}}e(t,"language");function g(o){return p(o,{protocol:l,apiVersion:1,id:"languages",setup(s){for(let r of m)s.addLanguage(r)}})}e(g,"registerLanguages");export{g as a};
|
package/dist/chunk-BYWAG6X3.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{e as O,f as N,g as M}from"./chunk-VSP2QQPQ.js";import{c as A}from"./chunk-YHUTTZC6.js";import{a as k,b as I,c as C,d as D,g as $}from"./chunk-T2RPMEM2.js";import{a as o}from"./chunk-EI7MMDWY.js";import{keyText as re}from"@earendil-works/pi-coding-agent";import{Text as te}from"@earendil-works/pi-tui";import ne from"node:os";import{Type as p}from"typebox";function L(){let e=[],r=new Map,a=new Map,i=new Map,s=Promise.resolve(),l={registerPlugin(n){if(n.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let c=i.get(n.id);if(c!==void 0)return c;let u=s.then(async()=>{let f=[],h=[],m,g=[],d={addResolver(t){U(t),f.push(t)},addAction(t){z(t),h.push(t)},describe(t){if(m!==void 0)throw new Error(`Plugin ${n.id} provides more than one description`);m=j(t)},addPromptGuideline(t){g.push(j(t))},search:o((t,S)=>l.execute(t,S),"search"),runAction(t,S){return l.runAction(t.reference,t.capability,t.resolverId,t.input,S)}};await n.setup(d);let y=new Set(e.map(({registration:t})=>t.resolver.id));for(let t of f){if(y.has(t.resolver.id))throw new Error(`Search resolver ${t.resolver.id} is already registered`);y.add(t.resolver.id)}for(let t of h){let S=v(t.resolverId,t.capability);if(r.has(S)||h.some(x=>x!==t&&v(x.resolverId,x.capability)===S))throw new Error(`Search action ${S} is already registered`)}for(let t of f)e.push({pluginId:n.id,registration:t,order:e.length});for(let t of h)r.set(v(t.resolverId,t.capability),t);g.length>0&&a.set(n.id,g)});return i.set(n.id,u),s=u.catch(()=>{}),u.catch(()=>{i.delete(n.id)}),u},async waitForPendingPlugins(){await Promise.all(i.values())},async execute(n,c){if(n.query.trim().length===0)return w("INVALID_REQUEST","Search query must not be empty");let u=[...e].sort((g,d)=>+(g.registration.fallback===!0)-+(d.registration.fallback===!0)||(g.registration.priority??0)-(d.registration.priority??0)||g.order-d.order),f=/^[a-z][\w-]*:\s*$/iu.test(n.query),h=/^[a-z][\w-]*:/iu.test(n.query);for(let g of u){if(f&&!g.registration.fallback)continue;let d=g.registration.resolver,y;try{c.signal?.throwIfAborted(),y=await d.tryResolve(n,c)}catch(t){return w("RESOLVE_FAILED",T(t,`Resolver ${d.id} failed`),d.id,t)}if(!B(y))return w("INVALID_RESOLVER_RESULT",`Resolver ${d.id} returned an invalid result`,d.id);if(y.kind!=="not-handled"){if(y.kind==="failed")return w("RESOLVE_FAILED",T(y.error,`Resolver ${d.id} failed`),d.id,y.error);try{let t=await d.format(y.payload,c);return _(t)?{content:g.registration.fallback&&h?[{type:"text",text:f?"Search fallback: empty protocol query; searched the original text.":"Search fallback: unhandled protocol query; searched the original text."},...t.content]:t.content,details:{resolverId:d.id,payload:t.details},...t.usage!==void 0&&{usage:t.usage}}:w("FORMAT_FAILED",`Resolver ${d.id} formatter returned an invalid result`,d.id)}catch(t){return w("FORMAT_FAILED",T(t,`Resolver ${d.id} formatter failed`),d.id,t)}}}let m=`No search resolver handled ${n.query}`;return O(w("NO_RESOLVER",m),m)},runAction(n,c,u,f,h){let m=r.get(v(u,c));if(m===void 0)throw new Error(`Search reference does not support ${c}`);return m.execute(n,f,h)},renderPromptGuidelines(){return[...a.values()].flat().flatMap(n=>{let c=K(n);return c===void 0?[]:[c]})},renderer(n){return e.find(({registration:c})=>c.resolver.id===n)?.registration.resolver.renderResult}};return l}o(L,"createSearchCore");function U(e){if(!b(e)||!b(e.resolver))throw new TypeError("Invalid search resolver registration");let r=e.resolver;if(typeof r.id!="string"||r.id.trim().length===0||typeof r.tryResolve!="function"||typeof r.format!="function")throw new TypeError("Invalid search resolver registration");if(e.priority!==void 0&&(typeof e.priority!="number"||!Number.isFinite(e.priority)))throw new TypeError("Invalid search resolver priority")}o(U,"assertResolver");function z(e){if(!b(e)||typeof e.resolverId!="string"||e.resolverId.trim().length===0||typeof e.capability!="string"||e.capability.trim().length===0||typeof e.execute!="function")throw new TypeError("Invalid search action registration")}o(z,"assertAction");function b(e){return typeof e=="object"&&e!==null}o(b,"isRecord");function B(e){if(typeof e!="object"||e===null||!("kind"in e))return!1;let r=e.kind;return r==="not-handled"||r==="resolved"&&"payload"in e||r==="failed"&&"error"in e}o(B,"isAttempt");function _(e){return typeof e=="object"&&e!==null&&Array.isArray(e.content)}o(_,"isAgentToolResult");function w(e,r,a,i){return{content:[{type:"text",text:r}],details:{failure:{code:e,message:r,...a!==void 0&&{resolverId:a},...i!==void 0&&{cause:i}}}}}o(w,"failure");function j(e){if(typeof e=="function")return e;if(typeof e!="string"||e.trim().length===0)throw new TypeError("Search description must not be empty");return e.trim()}o(j,"normalizeDescriptionSource");function K(e){let r=typeof e=="function"?e():e;if(r!==void 0){if(typeof r!="string"||r.trim().length===0)throw new TypeError("Search description must not be empty");return r.trim()}}o(K,"renderDescription");function v(e,r){return`${e}:${r}`}o(v,"actionKey");function T(e,r){return!(e instanceof Error)||e.message.trim().length===0?r:e instanceof SyntaxError?e.message:`${r}: ${e.message}`}o(T,"messageFor");import{readFile as Q}from"node:fs/promises";import Y from"node:os";import P from"node:path";var X=3e4;function q(e=process.env,r=Y.homedir(),a=process.cwd()){let i=e.PI_CODING_AGENT_DIR?.trim(),s=i===void 0||i.length===0?P.join(r,".pi","agent"):P.resolve(i);return{globalPath:P.join(s,"pi-agent-ide","search.json"),projectPath:P.resolve(a,".pi","pi-agent-ide","search.json")}}o(q,"resolveSearchConfigPaths");async function G(e){let[r,a]=await Promise.all([F(e.globalPath),F(e.projectPath)]),i=a!==void 0?a:r;return{timeoutMs:i===void 0?X:i}}o(G,"loadSearchConfig");async function F(e){let r;try{r=await Q(e,"utf8")}catch(l){if(Z(l))return;throw new Error(`Cannot read Pi Agent IDE search config at ${e}`,{cause:l})}let a;try{a=JSON.parse(r)}catch(l){throw new Error(`Invalid JSON in Pi Agent IDE search config at ${e}`,{cause:l})}if(!H(a))throw new TypeError(`Pi Agent IDE search config at ${e} must be a JSON object`);let i=Object.keys(a).find(l=>l!=="timeoutMs");if(i!==void 0)throw new TypeError(`Pi Agent IDE search config at ${e} contains unknown key ${i}`);let s=a.timeoutMs;if(s==null)return s;if(typeof s!="number"||!Number.isSafeInteger(s)||s<=0)throw new TypeError(`timeoutMs must be a positive integer or null in Pi Agent IDE search config at ${e}`);return s}o(F,"readTimeout");function Z(e){return H(e)&&e.code==="ENOENT"}o(Z,"isMissingFile");function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(H,"isRecord");var V=Symbol("search-timeout"),E=class extends Error{static{o(this,"SearchTimeoutError")}constructor(r){super(r),this.name="SearchTimeoutError"}};async function W(e,r,a){if(e===null)return a(r);let i=new AbortController,s=r===void 0?i.signal:AbortSignal.any([r,i.signal]),l,n=new Promise(c=>{l=setTimeout(()=>{c(V),i.abort()},e)});try{let c=await Promise.race([a(s),n]);if(c===V)throw new E(`Search timed out after ${ee(e)}. Try a smaller path scope.`);return c}finally{clearTimeout(l)}}o(W,"runWithSearchTimeout");function ee(e){if(e%1e3!==0)return`${String(e)}ms`;let r=e/1e3;return`${String(r)} ${r===1?"second":"seconds"}`}o(ee,"formatDuration");var oe=p.Object({query:p.String({minLength:1,description:"Search query. Local text tries literal terms, then regex, then eligible word fallback. Quotes keep terms literal and Boolean conditions stay intact. Empty or unhandled prefixes are text; nonempty installed prefixes select specialized search protocols."}),path:p.Optional(p.String({description:"Optional file or directory scope for local search"})),include:p.Optional(p.String({description:"Optional include glob for local search"})),exclude:p.Optional(p.String({description:"Optional exclude glob for local search"})),caseSensitive:p.Optional(p.Boolean({description:"Match letter case in local search"})),wholeWord:p.Optional(p.Boolean({description:"Match complete words in local search"})),limit:p.Optional(p.Integer({minimum:1,maximum:1e3,description:"Maximum results (default 100)"}))},{additionalProperties:!1});function ie(e,r){let a=[...e.path===void 0?[]:[{text:`in ${e.path}`,color:"accent",underline:!0,truncate:"start"}],...e.include===void 0?[]:[{text:`include ${e.include}`}],...e.exclude===void 0?[]:[{text:`exclude ${e.exclude}`}],...e.caseSensitive===!0?[{text:"case sensitive"}]:[],...e.wholeWord===!0?[{text:"whole word"}]:[],...e.limit===void 0?[]:[{text:`limit ${String(e.limit)}`}]];return{tool:"search",primary:{text:JSON.stringify(e.query),color:"accent",truncate:"end"},qualifiers:a,details:se(e),expanded:r}}o(ie,"searchCallModel");async function J(e){let r=L(),a=new N,i=e.events.on(D,s=>{if(!$(s))throw new Error("Invalid pi-agent-search plugin registration request");s.accept(r.registerPlugin(s.plugin))});e.on("session_shutdown",i),e.registerTool(M({name:"search",label:"search",description:"Search workspace text and paths through installed local, language, and structural search protocols.",promptSnippet:"Search files and text with literals or regular expressions, plus syntax trees and language symbols",get promptGuidelines(){return["Use search instead of grep, rg, or find to search workspace text and paths.","Use the narrowest useful search query and scope; broaden when needed.","Do not use search merely to rediscover a file path already named in the request; use that path directly. Search within it only when you need to locate content.",...r.renderPromptGuidelines()]},parameters:oe,renderCall(s,l,n){return A(n.lastComponent,ie(s,n.expanded),l)},renderResult(s,l,n,c){let u=s.details,f=u?.resolverId===void 0?void 0:r.renderer(u.resolverId);if(f!==void 0){let h={...s,details:u?.payload};return f(h,l,n,c)}return ae(s,l,n)},async execute(s,l,n,c,u){let f=await G(q(process.env,ne.homedir(),u.cwd));return W(f.timeoutMs,n,async h=>(await r.waitForPendingPlugins(),r.execute(l,{cwd:u.cwd,...h!==void 0&&{signal:h},...c!==void 0&&{onUpdate:o(m=>{c(m)},"onUpdate")}})))}},a)),e.events.emit(C,{protocol:k,apiVersion:I}),await r.waitForPendingPlugins()}o(J,"registerSearchCore");function se(e){return[{label:"query",value:JSON.stringify(e.query)},...R("path",e.path),...R("include",e.include),...R("exclude",e.exclude),...R("caseSensitive",e.caseSensitive===void 0?void 0:String(e.caseSensitive)),...R("wholeWord",e.wholeWord===void 0?void 0:String(e.wholeWord)),...R("limit",e.limit===void 0?void 0:String(e.limit))]}o(se,"searchCallDetails");function R(e,r){return r===void 0?[]:[{label:e,value:r}]}o(R,"optionalDetail");function ae(e,r,a){let i=e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
2
|
-
`),s=r.expanded?i:i.split(`
|
|
3
|
-
`).slice(0,8).join(`
|
|
4
|
-
`),l=!r.expanded&&i.split(`
|
|
5
|
-
`).length>8?`
|
|
6
|
-
${a.fg("dim",`${re("app.tools.expand")} to expand`)}`:"";return new te(`${a.fg("muted",s)}${l}`,0,0)}o(ae,"fallbackResult");export{J as a};
|
package/dist/chunk-E4SECPF4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as j,b as _,c as B}from"./chunk-DEP55R35.js";import{a as U,b as M}from"./chunk-U4D6FT66.js";import{a as H}from"./chunk-ERVMDQGX.js";import{a as R,b as S}from"./chunk-VFBLX4TG.js";import{a as N}from"./chunk-ORAPGW7W.js";import{a as $,b as D}from"./chunk-JASLOB2X.js";import{a as O}from"./chunk-EEH4WYI7.js";import{a as L,b as F}from"./chunk-266RH77Z.js";import{a as I}from"./chunk-2SKAED2I.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{access as te}from"node:fs/promises";import ne from"node:path";var V={protocol:R,apiVersion:1,id:"changes",setup(r){r.addSetupCheck({id:"git",async inspect(e){return await re(e.cwd)?await U("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),r.addCheck({id:"git",title:"Git changes",async run(e){let t=await M("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 re(r){try{return await te(ne.join(r,".git")),!0}catch{return!1}}a(re,"isGitProject");import{mkdtemp as oe,rm as ie,writeFile as ae}from"node:fs/promises";import se from"node:os";import h from"node:path";var w=class r{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{a(this,"GitChangesBackend")}static async create(e,t,n){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...n!==void 0&&{signal:n}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new r(e,h.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,n){let o=h.resolve(t,e),i=h.relative(this.repositoryRoot,o);return i===".."||i.startsWith(`..${h.sep}`)||h.isAbsolute(i)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(i.split(h.sep).join("/"),n)}async readTrackedRepositoryFile(e,t){let n=await this.git(["rev-parse","--verify","HEAD"],t);if(n.code!==0)return{status:"unavailable",reason:"missing-head",message:n.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 i=de(o.stdout);if(i===void 0)return{status:"untracked"};let d=await this.readBlob(i.blob,"HEAD",e,t);if(d.status!=="found")return d;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 s=ce(c.stdout);if(s.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=s.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:n.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:d.text,indexText:l,indexMode:u?.mode??i.mode}}async writeIndexFile(e,t,n,o){let i=await oe(h.join(se.tmpdir(),"pi-agent-index-")),d=h.join(i,"content");try{await ae(d,n,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,d],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 s=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(s.code!==0)throw new Error(s.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await ie(i,{recursive:!0,force:!0})}}async readBlob(e,t,n,o){let i=await this.git(["cat-file","blob",e],o);return i.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:i.stderr.trim()||`could not read ${t}:${n}`}:{status:"found",text:i.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function de(r){let e=r.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[n,o,i]=e.slice(0,t).split(" ",3);return n===void 0||o!=="blob"||i===void 0?void 0:{mode:n,blob:i,path:e.slice(t+1)}}a(de,"parseTreeEntry");function ce(r){return r.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[n,o,i]=e.slice(0,t).split(" ",3),d=Number(i);return n===void 0||o===void 0||!Number.isInteger(d)?[]:[{mode:n,blob:o,stage:d,path:e.slice(t+1)}]})}a(ce,"parseIndexEntries");function z(r){return{exec:a((e,t,n)=>r.exec(e,t,n),"exec")}}a(z,"extensionGitExecutor");var f=class r{constructor(e){this.git=e}static{a(this,"ChangeService")}static async create(e,t,n){let o=await w.create(e,t,n);return o.status==="unavailable"?o:{status:"ready",service:new r(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 n=j(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return n.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:n}}async changeIndex(e,t,n){let o=await this.inspect(e);if(o.status!=="applicable")return o;let i=o.groups.find(u=>u.selector===t);if(i===void 0)return k(t,o.groups.map(({selector:u})=>u));let d=n==="stage"?"staged":"unstaged";if(i.state===d)return{status:"unchanged",state:d,group:i};let c=x(i.segments[0]),s={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:n==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(s,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:ue(u)}}return{status:"applied",state:d,group:i}}async prepareUndo(e,t){let n=await this.inspect(e);if(n.status!=="applicable")return n;let o=n.groups.find(s=>s.selector===t);if(o===void 0)return k(t,n.groups.map(({selector:s})=>s));let i=_(e.worktreeText,o);if(i===void 0)return k(t,n.groups.map(({selector:s})=>s));let d=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:n.head,repositoryPath:n.repositoryPath,headStart:d.headStart,headEnd:d.headEnd,replacementText:d.headText};return{status:"applied",worktreeText:i,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let n=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(n.status!=="found")throw new Error(n.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:n.message);if(n.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=B(n.headText,n.indexText,e.headStart,e.headEnd,e.replacementText);o!==n.indexText&&await this.git.writeIndexFile(e.repositoryPath,n.indexMode,o,t)}};function k(r,e){return{status:"unavailable",reason:"stale-selector",message:`${r} is not available in the current file state`,availableSelectors:e}}a(k,"staleSelector");function ue(r){return r instanceof Error?r.message:String(r)}a(ue,"errorMessage");var b="pi-agent-ide-changes/change",le=/^CHANGE#[0-9A-F]{4,64}$/,ge=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,E=class extends I{static{a(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function Q(r){return{resolver:pe(a(async t=>{if(ge.test(t.source))return;let n=await f.create(r,t.cwd,t.signal);if(n.status!=="ready")throw new Error(n.message);return n.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}a(Q,"createChangeAnchorRegistration");function pe(r){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(!le.test(e))return{kind:"not-handled"};try{let n=await r(t);if(n===void 0)return{kind:"not-handled"};if(n.status==="unavailable")return{kind:"failed",error:new Error(n.message)};let o=n.status==="applicable"?n.groups.find(i=>i.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 E(o)}}catch(n){return{kind:"failed",error:n}}}}}a(pe,"createChangeAnchorResolver");import{diffLines as fe}from"diff";var he="filesystem";function Y(r){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==he)return e;let n=await f.create(r,t.cwd,t.signal);if(n.status!=="ready")return e;let o=await n.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:me(e,o.groups)}}}a(Y,"createCurrentChangePresenter");function me(r,e){let t=new Map;for(let n of e)xe(r,n,t);return{...r,lines:r.lines.map(n=>we(n,t.get(n.lineNumber)))}}a(me,"presentChangeGroups");function xe(r,e,t){let n=x(e.segments[0]),o=fe(n.headText,n.worktreeText),i=e.currentStartLine,d,c;for(let s of o){let u=Te(s.value);if(s.removed){let l=be(r,i),g=P(t,l.lineNumber),p=l.after?g.after:g.before;for(let m of u){let y={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:m}),d??=y,c=y}continue}if(s.added){for(let l of u){let g=P(t,i),p={kind:"current",lineNumber:i};g.added=!0,d??=p,c=p,i++}continue}i+=u.length}if(d!==void 0&&c!==void 0){let s=`${e.selector} \xB7 ${e.state}`;ye(d,c)?G(t,d,`<!-- change: ${s} -->`):(G(t,d,`<!-- change-begin: ${s} -->`),G(t,c,`<!-- change-end: ${s} -->`))}}a(xe,"presentChangeGroup");function ye(r,e){return r.kind==="current"&&e.kind==="current"?r.lineNumber===e.lineNumber:r.kind==="synthetic"&&e.kind==="synthetic"?r.rows===e.rows&&r.index===e.index:!1}a(ye,"sameTarget");function G(r,e,t){if(e.kind==="current"){P(r,e.lineNumber).annotations.push(t);return}let n=x(e.rows[e.index]);e.rows[e.index]={...n,suffix:`${n.suffix??""} ${t}`}}a(G,"annotateTarget");function we(r,e){if(e===void 0)return r;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...r,presentation:{...r.presentation,...e.added&&{marker:"+"},before:[...r.presentation?.before??[],...e.before],after:[...e.after,...r.presentation?.after??[]],suffix:`${r.presentation?.suffix??""}${t}`}}}a(we,"presentLine");function P(r,e){let t=r.get(e);if(t!==void 0)return t;let n={before:[],after:[],annotations:[],added:!1};return r.set(e,n),n}a(P,"presentationsFor");function be(r,e){return e<=r.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:r.lines.length,after:!0}}a(be,"placementFor");function Te(r){if(r.length===0)return[];let e=r.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}a(Te,"splitLines");var T=class{static{a(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 ve}from"node:fs";import X from"node:path";import{fileURLToPath as ke}from"node:url";var C=class{static{a(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=K(e.resourceSource,e.cwd);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:q(e.after.content)})}restore(e,t,n){let o=K(e,t),i=this.#e.get(o);if(i===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(i.afterDigest!==q(n))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return i.before}};function K(r,e){return r.startsWith("file://")?W(ke(new URL(r))):/^[a-z][a-z\d+.-]*:/iu.test(r)?r:W(X.resolve(e,r))}a(K,"sourceKey");function W(r){try{return ve.native(r)}catch{return X.normalize(r)}}a(W,"canonicalFile");function q(r){return Ce("sha256").update(r).digest("hex")}a(q,"textDigest");import{readFile as Ee}from"node:fs/promises";import Ge from"node:path";import{defineTool as Pe,withFileMutationQueue as Ae}from"@earendil-works/pi-coding-agent";import{Type as A}from"typebox";var Ie=A.Object({file:A.String({description:"Path to the tracked text file"}),change:A.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function J(r,e,t){r.registerTool(Z("stage",e,t)),r.registerTool(Z("unstage",e,t))}a(J,"registerIndexChangeTools");function Z(r,e,t){let n=r==="stage"?"staged":"unstaged",o=r==="stage"?"Staged":"Unstaged";return Pe({name:r,label:r,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`${o.slice(0,-1)} one current Git change selected by a CHANGE# anchor without changing the worktree.`,promptGuidelines:[`You can use ${r} with a complete \`CHANGE#...\` anchor to ${r} only that current Git change without changing the worktree.`],parameters:Ie,async execute(i,d,c,s,u){let l=Re(d.file,u.cwd);return Ae(l,()=>t.run(async()=>{let g=await Ee(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let m=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},d.change,r);if(m.status==="unavailable")throw new Error(m.message);if(m.status==="not-applicable")throw new Error(`${r} is not applicable to ${l}: ${m.reason}`);let y=m.status==="unchanged";return{content:[{type:"text",text:y?`${d.change} is already ${n} in ${d.file}.`:`${o} ${d.change} in ${d.file}.`}],details:{action:r,change:d.change,file:l,state:n,unchanged:y}}}))}})}a(Z,"createIndexChangeTool");function Re(r,e){let t=r.startsWith("@")?r.slice(1):r;return Ge.resolve(e,t)}a(Re,"resolveFile");import{diffChars as Se}from"diff";import{Type as v}from"typebox";var He=v.Object({file:v.Optional(v.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:v.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)$"})},{additionalProperties:!1});function ee(r,e,t){return{name:"undo",description:"Restore one selected current Git change to HEAD in the worktree and index, or restore one file to its state before its latest text-editor transaction.",promptSnippet:"Restore a Git change or the latest text edit",promptGuidelines:["You can use undo with a complete `CHANGE#...` anchor to restore that current Git change to HEAD in both the worktree and index.",'You can use undo with `change: "last"` to restore a file to its state before its latest text-editor transaction.'],parameters:He,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[b],nonAnchorValues:["last"]}],async mutate(n,o){let i=n.sourceFor("file"),d,c;if(o.change==="last")d=e.restore(i,n.cwd,n.sourceDocument.content);else{await n.resolveAnchor("change");let s=await f.create(r,n.cwd,n.signal);if(s.status!=="ready")throw new Error(s.message);let u=await s.service.prepareUndo({source:i,worktreeText:n.sourceDocument.content,cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}},o.change);if(u.status!=="applied")throw u.status==="unavailable"?new Error(u.message):new Error(`Undo is not applicable to ${i}: ${u.reason}`);if(d=u.worktreeText,u.indexUpdate!==void 0){let l=u.indexUpdate;c=a(()=>t.run(()=>s.service.applyIndexUpdate(l,n.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:$e(n.sourceDocument.content,d),action:"edited"}]]),...c!==void 0&&{afterWrite:c}}}}}a(ee,"createUndoMutationTool");function $e(r,e){let t=[],n=0,o,i=0,d="",c=a(()=>{o!==void 0&&(t.push({from:o,to:o+i,insert:d}),o=void 0,i=0,d="")},"flush");for(let s of Se(r,e)){if(!s.added&&!s.removed){c(),n+=s.value.length;continue}o??=n,s.removed?(n+=s.value.length,i+=s.value.length):d+=s.value}return c(),t}a($e,"createTextChanges");async function De(r){if(process.argv.includes("--old-tools"))return;let e=z(r),t=new C,n=new T,o=Y(e),i=Q(e),d={protocol:$,apiVersion:D,id:"current-git-changes",setup(s){s.addView({view:"changes",presenter:o}),s.describe("Adds CHANGE anchors and Git index state to current changes in tracked text files that request the `changes` view. Use these anchors with undo, stage, and unstage."),s.addPromptGuideline('You can use read with `views: ["changes"]` to add `CHANGE#...` anchors and Git index state for current file changes.')}},c={protocol:L,apiVersion:F,id:"current-git-changes",setup(s){s.addAnchorResolver({...i,kind:b,type:"auxiliary"}),s.onDidEdit(u=>{t.observe(u)}),s.addMutationTool(ee(e,t,n)),s.addTextPresenter({presenter:o})}};await Promise.all([H(r,V),N(r,d),O(r,c)]),J(r,e,n)}a(De,"registerGitChanges");export{De as a};
|
package/dist/chunk-EW2KVKCN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-EI7MMDWY.js";function G(t,e){if(e.length===0)return;let c=t.trim();if(c.length===0||/[\r\n]/u.test(c))throw new TypeError("Content provider summary must be one non-empty line");return[c,...e.map(({id:a,description:r})=>`- \`${W(a)}\` \u2014 ${r}`)].join(`
|
|
2
|
-
`)}o(G,"renderContentDescription");function W(t){return t.replaceAll("`","\\`")}o(W,"escapeInlineCode");import{Type as i}from"typebox";import{Value as et}from"typebox/value";import{Type as n}from"typebox";import{Value as Y}from"typebox/value";var u={additionalProperties:!0},E=n.Function([],n.Unknown()),C=n.String({minLength:1}),B=n.Object({type:n.Literal("text"),text:n.String(),textSignature:n.Optional(n.String())},u),z=n.Object({type:n.Literal("image"),data:n.String(),mimeType:n.String()},u),J=n.Object({type:n.Literal("custom"),kind:C,data:n.Unknown()},u),M=n.Array(n.Union([B,z,J]),{minItems:1}),L=n.Union([n.Object({source:C,link:n.Optional(C),read:E,write:n.Optional(n.Never())},u),n.Object({source:C,link:n.Optional(C),read:n.Optional(n.Never()),write:E},u),n.Object({source:C,link:n.Optional(C),read:E,write:E},u)]),Q=n.Object({id:C,tryResolve:E},u),X=n.Union([n.Object({kind:n.Literal("not-handled")},u),n.Object({kind:n.Literal("resolved"),resource:L},u),n.Object({kind:n.Literal("failed"),error:n.Unknown()},u)]);function A(t){return x(M,t)?b(()=>t.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}o(A,"isAgentContent");function H(t){return x(L,t)?b(()=>{let e=t,c=!("read"in e)||typeof e.read=="function",a=!("write"in e)||typeof e.write=="function";return c&&a}):!1}o(H,"isResource");function Z(t){return x(Q,t)}o(Z,"isResourceResolver");function tt(t){return x(X,t)?b(()=>{let e=t;return e.kind!=="resolved"||H(e.resource)}):!1}o(tt,"isResourceResolutionAttempt");function x(t,e){return b(()=>Y.Check(t,e))}o(x,"safeCheck");function b(t){try{return t()}catch{return!1}}o(b,"safeEvaluate");var d={additionalProperties:!0},nt=i.Function([],i.Unknown()),k=i.String({minLength:1}),ot=i.Object({provider:k,capability:i.Union([i.Literal("read"),i.Literal("write")])},d),rt=i.Object({source:k,bytes:i.Unknown(),mediaType:i.Optional(i.String())},d),it=i.Object({signal:i.Optional(i.Unknown())},d),st=i.Object({id:k,description:k,tryConvert:nt},d),ct=i.Union([i.Object({kind:i.Literal("not-handled")},d),i.Object({kind:i.Literal("converted"),content:i.Unknown()},d),i.Object({kind:i.Literal("failed"),error:i.Unknown()},d)]),at=i.Object({target:i.Unknown(),converter:i.Unknown(),priority:i.Optional(i.Number())},d);function f(t){return g(ot,t)&&v(()=>t.provider.trim().length>0)}o(f,"isContentTarget");function j(t){return g(rt,t)?v(()=>{let e=t;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}o(j,"isContentInput");function I(t){return g(it,t)?v(()=>{let e=t;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}o(I,"isContentConversionContext");function q(t){return g(st,t)?v(()=>{let e=t;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}o(q,"isContentConverter");function _(t){return g(ct,t)?v(()=>{let e=t;return e.kind!=="converted"||A(e.content)}):!1}o(_,"isContentConversionAttempt");function m(t){return g(at,t)?v(()=>{let e=t;return f(e.target)&&q(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}o(m,"isContentConverterRegistration");function g(t,e){return v(()=>et.Check(t,e))}o(g,"safeCheck");function v(t){try{return t()}catch{return!1}}o(v,"safeEvaluate");var N=class extends Error{static{o(this,"UnsupportedContentError")}source;target;constructor(e,c){super(`No content converter for ${e} in ${c.provider}/${c.capability}`),this.name="UnsupportedContentError",this.source=e,this.target=c}};function V(t){if(!f(t))throw new TypeError("Invalid content target");let e={...t},c=[],a=o(()=>[...c].sort((r,s)=>r.priority-s.priority||r.order-s.order),"snapshotConverters");return{target:e,register(r){if(!m(r))throw new TypeError("Invalid content converter registration");if(!R(e,r.target))throw new Error(`Content converter ${r.converter.id} targets ${r.target.provider}/${r.target.capability}, not ${e.provider}/${e.capability}`);if(c.some(({converter:s})=>s.id===r.converter.id))throw new Error(`Content converter ${r.converter.id} is already registered for ${e.provider}/${e.capability}`);c.push({converter:r.converter,priority:r.priority??0,order:c.length})},listDescriptions(){return a().map(({converter:r})=>({id:r.id,description:r.description}))},async convert(r,s){if(!j(r))throw new TypeError("Invalid content input");if(!I(s))throw new TypeError("Invalid content conversion context");P(s.signal);let p=a();for(let{converter:O}of p){P(s.signal);let T=await O.tryConvert(r,s);if(P(s.signal),!_(T))throw new TypeError(`Content converter ${O.id} returned an invalid outcome`);if(T.kind!=="not-handled"){if(T.kind==="failed")throw T.error;return T.content}}throw new N(r.source,e)}}}o(V,"createContentRunner");function R(t,e){return t.provider===e.provider&&t.capability===e.capability}o(R,"targetsEqual");function P(t){t?.throwIfAborted()}o(P,"throwIfAborted");import{Type as l}from"typebox";import{Value as pt}from"typebox/value";var y="pi-agent-resource/content-conversion",S=2,w=`${y}/host/ready`,h=`${y}/converter/register`,K={additionalProperties:!0},ut=l.Function([],l.Unknown()),Ct=l.Object({protocol:l.Literal(y),apiVersion:l.Literal(S),target:l.Unknown()},K),dt=l.Object({registration:l.Unknown(),accept:ut},K);function D(t){return F(Ct,t)&&$(()=>f(t.target))}o(D,"isContentHostReady");function U(t){return F(dt,t)&&$(()=>m(t.registration))}o(U,"isContentConverterRegistrationRequest");function F(t,e){return $(()=>pt.Check(t,e))}o(F,"safeCheck");function $(t){try{return t()}catch{return!1}}o($,"safeEvaluate");function lt(t,e){let c=V(e),a=t.events.on(h,r=>{if(!U(r))throw new Error("Invalid content converter registration request");if(!R(c.target,r.registration.target))return;let s;try{c.register(r.registration),s=Promise.resolve()}catch(p){s=Promise.reject(p instanceof Error?p:new Error("Content converter registration failed",{cause:p}))}r.accept(s)});return t.on("session_shutdown",a),t.events.emit(w,{protocol:y,apiVersion:S,target:c.target}),{target:c.target,listDescriptions(){return c.listDescriptions()},convert(r,s){return c.convert(r,s)}}}o(lt,"createContentHost");function mt(t,e){if(!m(e))throw new TypeError("Invalid content converter registration");let c=o(()=>{let s,p={registration:e,accept(O){if(s!==void 0)throw new Error(`Content converter ${e.converter.id} registration was accepted more than once`);s=O}};return t.events.emit(h,p),s},"announce"),a=o(()=>{},"unsubscribe");a=t.events.on(w,s=>{if(!D(s))throw new Error("Invalid content conversion host readiness event");if(!R(e.target,s.target))return;let p=c();if(p===void 0)throw new Error(`${s.target.provider}/${s.target.capability} announced readiness without accepting content converter ${e.converter.id}`);a(),p.catch(()=>{})}),t.on("session_shutdown",a);let r=c();if(r!==void 0)return a(),r}o(mt,"connectContentConverter");export{G as a,A as b,H as c,Z as d,tt as e,f,j as g,I as h,q as i,_ as j,m as k,N as l,V as m,R as n,y as o,S as p,w as q,h as r,D as s,U as t,lt as u,mt as v};
|
package/dist/chunk-F6SESI3P.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-XNXQYPVT.js";import{a as l}from"./chunk-EEH4WYI7.js";import{a as c,b as u}from"./chunk-266RH77Z.js";import{a}from"./chunk-EI7MMDWY.js";function g(r,n){let t=Object.keys(n.properties??{}),o=Object.keys(r),e=-1;for(let d of o){let i=t.indexOf(d);if(i===-1){if(n.additionalProperties===!1)return{observedOrder:o,expectedOrder:t,unknownKey:d};continue}if(i<e)return{observedOrder:o,expectedOrder:t};e=i}}a(g,"checkArgumentOrder");function p(r,n){let t=n.unknownKey?` Unknown key: "${n.unknownKey}".`:"";return{annotation:{kind:"custom",label:"Argument Order",color:"warning"},message:{customType:"text-editor-argument-order-block",content:`[SYSTEM] ${r} blocked: argument order violation.${t}
|
|
2
|
-
Observed order: ${n.observedOrder.join(", ")||"(none)"}.
|
|
3
|
-
Expected schema order: ${n.expectedOrder.join(", ")||"(none)"}.
|
|
4
|
-
Call ${r} again with arguments in schema order.`,display:!1,details:n}}}a(p,"makeBlockResult");function m(r){let n=new Map,t=[],o={name:"text-editor-argument-order-guard",blockExecution:!0,toolNames:t,intercept(e){let d=n.get(e.toolCall.name);if(!d)return;let i=g(e.partialArgs??e.args,d);return i?p(e.toolCall.name,i):void 0}};return s(r,o),e=>{n.set(e.name,e.schema),t.push(e.name),s(r,o)}}a(m,"registerArgumentOrderGuard");async function f(r){await l(r,{protocol:c,apiVersion:u,id:"text-editor-argument-order",setup(t){let o=m(r);t.onMutationTool(e=>{o({name:e.name,schema:e.parameters})})}})}a(f,"registerTextEditorArgumentOrder");export{f as a};
|
package/dist/chunk-GTK5AREE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-EI7MMDWY.js";import{convertToPng as k,formatDimensionNote as x,resizeImage as A}from"@earendil-works/pi-coding-agent";var g=[137,80,78,71,13,10,26,10];function y(){return{id:"image",description:"JPEG, static PNG, GIF, WebP, and BMP images.",async tryConvert(e,n){let i=f(n.signal);if(i!==void 0)return{kind:"failed",error:i};let r=T(e.bytes);if(r.kind==="not-handled")return r;if(r.kind==="invalid")return{kind:"failed",error:new TypeError(`${e.source}: ${r.message}`)};try{let t=await h(e.bytes,r.mimeType),a=f(n.signal);return a!==void 0?{kind:"failed",error:a}:{kind:"converted",content:t}}catch(t){return{kind:"failed",error:f(n.signal)??new TypeError(`Unable to process image ${e.source}`,{cause:t})}}}}}o(y,"createImageContentConverter");function v(e){let n=T(e);return n.kind==="supported"?n.mimeType:null}o(v,"detectSupportedImageMimeType");async function h(e,n){let i=e,r=n,t;if(n==="image/bmp"){let l=await k(Buffer.from(e).toString("base64"),n);if(l===null)throw new TypeError("Unable to convert image/bmp to an inline image format");i=Buffer.from(l.data,"base64"),r=l.mimeType,t=n}let a=await A(i,r);if(a===null)throw new TypeError(`Unable to normalize ${n} within Pi inline image limits`);let u=[];t!==void 0&&t!==a.mimeType&&u.push(`[Image converted from ${t} to ${a.mimeType}.]`);let c=x(a);return c!==void 0&&u.push(c),[{type:"text",text:[`Read image [${a.mimeType}]`,...u].join(`
|
|
2
|
-
`)},{type:"image",data:a.data,mimeType:a.mimeType}]}o(h,"createImageContent");function T(e){return s(e,[255,216,255])?e[3]===247?{kind:"not-handled"}:{kind:"supported",mimeType:"image/jpeg"}:s(e,g)?P(e)?U(e)?{kind:"invalid",message:"Animated PNG is not supported"}:{kind:"supported",mimeType:"image/png"}:{kind:"invalid",message:"Malformed PNG image"}:d(e,0,"GIF87a")||d(e,0,"GIF89a")?{kind:"supported",mimeType:"image/gif"}:d(e,0,"RIFF")&&d(e,8,"WEBP")?{kind:"supported",mimeType:"image/webp"}:d(e,0,"BM")?E(e)?{kind:"supported",mimeType:"image/bmp"}:{kind:"invalid",message:"Malformed BMP image"}:{kind:"not-handled"}}o(T,"inspectImage");function P(e){return e.length>=33&&I(e,g.length)===13&&d(e,12,"IHDR")}o(P,"isPng");function U(e){let n=g.length;for(;n+8<=e.length;){let i=I(e,n),r=n+4;if(d(e,r,"acTL"))return!0;if(d(e,r,"IDAT"))return!1;let t=n+8+i+4;if(t<=n||t>e.length)return!1;n=t}return!1}o(U,"isAnimatedPng");function E(e){if(e.length<26)return!1;let n=p(e,2),i=p(e,10),r=p(e,14);if(n!==0&&(n<26||n>e.length)||i<14+r||i>=e.length||n!==0&&i>=n)return!1;let t,a;if(r===12)t=m(e,22),a=m(e,24);else if(r>=40&&r<=124){if(e.length<30)return!1;t=m(e,26),a=m(e,28)}else return!1;return t===1&&[1,4,8,16,24,32].includes(a)}o(E,"isBmp");function m(e,n){return(e[n]??0)+((e[n+1]??0)<<8)}o(m,"readUint16LE");function I(e,n){return(e[n]??0)*16777216+((e[n+1]??0)<<16)+((e[n+2]??0)<<8)+(e[n+3]??0)}o(I,"readUint32BE");function p(e,n){return(e[n]??0)+((e[n+1]??0)<<8)+((e[n+2]??0)<<16)+(e[n+3]??0)*16777216}o(p,"readUint32LE");function s(e,n){return e.length>=n.length&&n.every((i,r)=>e[r]===i)}o(s,"startsWith");function d(e,n,i){if(e.length<n+i.length)return!1;for(let r=0;r<i.length;r+=1)if(e[n+r]!==i.codePointAt(r))return!1;return!0}o(d,"startsWithAscii");function f(e){if(e?.aborted===!0)return e.reason instanceof Error?e.reason:w()}o(f,"cancellationError");function w(){let e=new Error("The operation was aborted");return e.name="AbortError",e}o(w,"abortError");export{y as a,v as b,h as c};
|
package/dist/chunk-HOBTFFQR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./chunk-SJYDLHEF.js";import{a as f}from"./chunk-EEH4WYI7.js";import{a as c,b as u,c as s}from"./chunk-266RH77Z.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFileSync as z}from"node:fs";import w from"node:path";function x(e){let n=b(e.settings,"recovery.exactText");n!==void 0&&p(n,["fuzzyEnabled","threshold","exactCandidateLimit","fuzzyCandidateLimit","maxFileSizeMiB","maxQuerySizeKiB","seedLimit","blockLineVariance"],"recovery.exactText");let t=i(o=>n===void 0?void 0:n[o],"value");return{fuzzyEnabled:g(t("fuzzyEnabled"),"fuzzyEnabled")??!0,threshold:d(t("threshold"),"threshold",0,1)??.8,exactCandidateLimit:a(t("exactCandidateLimit"),"exactCandidateLimit",1,100)??20,fuzzyCandidateLimit:a(t("fuzzyCandidateLimit"),"fuzzyCandidateLimit",1,20)??5,maxFileSizeMiB:d(t("maxFileSizeMiB"),"maxFileSizeMiB",.01,100)??20,maxQuerySizeKiB:d(t("maxQuerySizeKiB"),"maxQuerySizeKiB",.01,4096)??1024,seedLimit:a(t("seedLimit"),"seedLimit",1,10)??3,blockLineVariance:a(t("blockLineVariance"),"blockLineVariance",0,10)??2,contextLines:e.contextLines,timeoutMs:e.timeoutMs}}i(x,"parseExactTextRecoveryConfig");function l(e,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${n} must be an object`);return Object.fromEntries(Object.entries(e))}i(l,"objectRecord");function b(e,n){return e===void 0?void 0:l(e,n)}i(b,"optionalObject");function p(e,n,t){let o=new Set(n),r=Object.keys(e).find(y=>!o.has(y));if(r!==void 0)throw new TypeError(`${t} contains unknown key ${r}`)}i(p,"assertKeys");function g(e,n){if(e===void 0||typeof e=="boolean")return e;throw new TypeError(`${n} must be a boolean`)}i(g,"optionalBoolean");function d(e,n,t,o){if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e)||e<t||e>o)throw new RangeError(`${n} must be between ${t} and ${o}`);return e}}i(d,"optionalNumber");function a(e,n,t,o){let r=d(e,n,t,o);if(r!==void 0&&!Number.isInteger(r))throw new TypeError(`${n} must be an integer`);return r}i(a,"optionalInteger");async function E(e){await f(e,{protocol:c,apiVersion:u,id:"text-anchor-exact",setup(t){t.addAnchorResolver({resolver:m(x(t.recoveryConfig("exactText"))),kind:s,type:"auxiliary",describeInPrompt:!1,priority:1e4})}})}i(E,"registerExactTextAnchor");export{E as a};
|
package/dist/chunk-IMVCVPMP.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{v as c}from"./chunk-EW2KVKCN.js";import{a as r}from"./chunk-EI7MMDWY.js";import{parseHTML as g}from"linkedom";async function d(t,n,e=p){try{let o=await e(t,n);return{content:o.content.trim(),title:o.title.trim(),usedFallback:!1}}catch{return{...x(t,n),usedFallback:!0}}}r(d,"extractReadableHtml");async function p(t,n){let e=u(t,n),{Defuddle:o}=await import("defuddle/node"),i=await o(e,n,{markdown:!0,useAsync:!1});return{content:i.content,title:i.title}}r(p,"extractWithDefuddle");function x(t,n){let e=u(t,n);for(let a of e.querySelectorAll("script, style, nav, footer, header, aside, noscript, template"))a.remove();let o=e.querySelector("article, main")??e.body??e.documentElement,i=s(o?.textContent??""),l=s(e.querySelector("title")?.textContent??"");return{content:i,title:l}}r(x,"extractPlainText");function u(t,n){let e=g(t);try{Object.defineProperty(e.document,"location",{value:new URL(n),configurable:!0})}catch{}return e.document}r(u,"parseDocument");function s(t){return t.replace(/\s+/gu," ").trim()}r(s,"normalizeWhitespace");var b=new Set(["application/xhtml+xml","text/html"]),w=/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu;function f(){return{id:"html",description:"HTML and XHTML pages converted to Markdown.",async tryConvert(t,n){if(!E(t.bytes,t.mediaType))return{kind:"not-handled"};let e=m(n.signal);if(e!==void 0)return{kind:"failed",error:e};let o;try{o=new TextDecoder("utf8",{fatal:!0}).decode(t.bytes)}catch(y){return{kind:"failed",error:new TypeError(`${t.source} is not valid UTF-8 HTML`,{cause:y})}}let i=await d(o,t.source),l=m(n.signal);return l!==void 0?{kind:"failed",error:l}:{kind:"converted",content:[{type:"text",text:i.title.length===0?i.content:i.content.length===0?`# ${i.title}`:`# ${i.title}
|
|
2
|
-
|
|
3
|
-
${i.content}`}]}}}}r(f,"createHtmlContentConverter");function E(t,n){if(n!==void 0){let o=n.split(";",1)[0]?.trim().toLowerCase()??"";if(b.has(o))return!0}let e=new TextDecoder("utf8").decode(t.subarray(0,1024));return w.test(e)}r(E,"isHtmlInput");function m(t){if(t?.aborted===!0)return t.reason instanceof Error?t.reason:H()}r(m,"cancellationError");function H(){let t=new Error("The operation was aborted");return t.name="AbortError",t}r(H,"abortError");var C={target:{provider:"web",capability:"read"},converter:f(),priority:200};async function h(t){await c(t,C)}r(h,"registerWebHtml");export{h as a};
|
package/dist/chunk-IOCABSRL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./chunk-PODWLGNO.js";import{v as e}from"./chunk-EW2KVKCN.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerWebPdf");export{i as a};
|
package/dist/chunk-KP37XTDI.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as T}from"./chunk-U4D6FT66.js";import{a as g}from"./chunk-ERVMDQGX.js";import{a as h,b as p}from"./chunk-VFBLX4TG.js";import{c as R}from"./chunk-SSZB66C3.js";import{a as E}from"./chunk-ORAPGW7W.js";import{a as y,b as v}from"./chunk-JASLOB2X.js";import{a as A,u as P}from"./chunk-EW2KVKCN.js";import{a as s}from"./chunk-EI7MMDWY.js";import{constants as I}from"node:fs";import{access as _}from"node:fs/promises";import m from"node:path";var k=["google-chrome-stable","google-chrome","chromium","chromium-browser"],W=["/usr/bin/google-chrome-stable","/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser","/opt/google/chrome/chrome"];function S(e={}){let o;return{async load(t,r){o??=f(e.executablePath,e.environment??process.env);let n=await o;r.signal?.throwIfAborted();let{chromium:l}=await import("playwright-core");r.signal?.throwIfAborted();let a=await l.launch({executablePath:n,headless:!0,chromiumSandbox:!1}),c=s(()=>{a.close()},"closeOnAbort");r.signal?.addEventListener("abort",c,{once:!0});try{r.signal?.throwIfAborted();let i=await a.newPage(),u=await i.goto(t.href,{timeout:r.timeoutMs,waitUntil:"domcontentloaded"});if(u!==null&&!u.ok())throw new Error(`HTTP ${u.status()}: ${u.statusText()}`);await i.waitForLoadState("networkidle",{timeout:Math.min(r.timeoutMs,1500)}).catch(()=>{}),r.signal?.throwIfAborted(),await O(i);let d={html:await i.content(),source:i.url()};return r.signal?.throwIfAborted(),d}catch(i){throw r.signal?.aborted===!0?M(r.signal):new Error(`Browser read failed for ${t.href}: ${U(i)}`,{cause:i})}finally{r.signal?.removeEventListener("abort",c),await a.close().catch(()=>{})}}}}s(S,"createSystemBrowserHtmlLoader");async function f(e=process.env.PI_AGENT_IDE_BROWSER_PATH,o=process.env){if(e!==void 0&&e.trim().length>0){let t=m.resolve(e);if(await b(t))return t;throw new Error(`PI_AGENT_IDE_BROWSER_PATH is not executable: ${t}`)}for(let t of(o.PATH??"").split(m.delimiter).filter(Boolean))for(let r of k){let n=m.join(t,r);if(await b(n))return n}for(let t of W)if(await b(t))return t;throw new Error("No system Chrome or Chromium executable was found. Install Chrome/Chromium or set PI_AGENT_IDE_BROWSER_PATH.")}s(f,"resolveSystemBrowserExecutable");async function O(e){await e.locator("body *").evaluateAll(o=>{for(let t of o.toReversed()){let r=globalThis.getComputedStyle(t);(t.hasAttribute("hidden")||t.getAttribute("aria-hidden")==="true"||r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse")&&t.remove()}})}s(O,"removeHiddenElements");async function b(e){try{return await _(e,I.X_OK),!0}catch{return!1}}s(b,"isExecutable");function M(e){return e.reason instanceof Error?e.reason:D()}s(M,"abortReason");function D(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(D,"abortError");function U(e){return e instanceof Error?e.message:String(e)}s(U,"errorMessage");var x={protocol:h,apiVersion:1,id:"web-browser",setup(e){e.addCheck({id:"system-browser",title:"Browser web reads",async run(o){try{let t=await f(o.env.PI_AGENT_IDE_BROWSER_PATH,o.env),r=await T(t,["--version"],o.cwd,o.env);return[r.ok?{status:"pass",message:"Chrome/Chromium is available",detail:r.detail}:{status:"warn",message:"Chrome/Chromium cannot start",detail:r.detail}]}catch(t){return[{status:"warn",message:"Browser reads are unavailable",detail:t instanceof Error?t.message:String(t)}]}}})}};function H(e,o={}){let t=F(o);return{id:"web",tryResolve(r){return Promise.resolve(N(r,e,t))}}}s(H,"createWebResolver");function F(e){let o=e.timeoutMs??3e4;if(!Number.isFinite(o)||o<=0)throw new TypeError("Web timeout must be a positive finite number");return{timeoutMs:o,fetchResource:e.fetch??globalThis.fetch,browser:e.browser??S(),autoBrowserFallback:e.autoBrowserFallback??!0}}s(F,"resolverSettings");function N(e,o,t){let r;try{r=new URL(e)}catch(n){return q(e)?{kind:"failed",error:new TypeError(`Invalid HTTP source ${e}`,{cause:n})}:{kind:"not-handled"}}return r.protocol!=="http:"&&r.protocol!=="https:"?{kind:"not-handled"}:{kind:"resolved",resource:{source:r.href,read({signal:n}){return $(r,o,t,n)}}}}s(N,"resolveHttpSource");async function $(e,o,t,r){let n=L(r,t.timeoutMs),l=!0;try{n.signal.throwIfAborted();let a=await t.fetchResource(e,{method:"GET",redirect:"follow",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (compatible; Pi-LPT/1.0; +https://github.com/alexshpunt/sasha-pi)",Accept:"text/html,application/xhtml+xml,application/pdf,application/json,text/plain,image/*,*/*;q=0.8","Accept-Language":"en-US,en;q=0.5"}});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let c=new Uint8Array(await a.arrayBuffer());n.signal.throwIfAborted();let i=a.url.length===0?e.href:a.url,u=a.headers.get("content-type")??void 0,d={source:i,bytes:c,...u!==void 0&&{mediaType:u}};l=j(c,u);let w=await o.convert(d,{signal:n.signal});if(n.signal.throwIfAborted(),t.autoBrowserFallback&&l&&B(w))throw new Error("HTTP read returned empty HTML content");return w}catch(a){if(r?.throwIfAborted(),!t.autoBrowserFallback||!l)throw a;n.dispose();try{return await G(e,o,t,r)}catch(c){throw r?.throwIfAborted(),new Error(`HTTP read failed (${C(a)}) and browser fallback failed: ${C(c)}`,{cause:c})}}finally{n.dispose()}}s($,"readWebContent");async function G(e,o,t,r){let n=L(r,t.timeoutMs);try{n.signal.throwIfAborted();let l=await V(e,o,t,n.signal);if(n.signal.throwIfAborted(),B(l))throw new Error("Browser read returned empty content");return l}finally{n.dispose()}}s(G,"readBrowserContent");async function V(e,o,t,r){let n=await t.browser.load(e,{signal:r,timeoutMs:t.timeoutMs});return r.throwIfAborted(),o.convert({source:n.source,bytes:new TextEncoder().encode(n.html),mediaType:"text/html; charset=utf-8"},{signal:r})}s(V,"loadAndConvertBrowser");function j(e,o){let t=o?.split(";",1)[0]?.trim().toLowerCase();if(t==="text/html"||t==="application/xhtml+xml")return!0;let r=new TextDecoder("utf8").decode(e.subarray(0,1024));return/^\u{FEFF}?\s*(?:<!doctype\s+html\b|<(?:article|body|head|html)\b)/iu.test(r)}s(j,"isHtml");function B(e){return e.every(o=>o.type==="text"&&o.text.trim().length===0)}s(B,"isEmptyTextContent");function L(e,o){let t=new AbortController,r=s(()=>{t.abort(z(e))},"abortFromParent"),n=setTimeout(()=>{t.abort(K(o))},o);return n.unref(),e?.aborted===!0?r():e?.addEventListener("abort",r,{once:!0}),{signal:t.signal,dispose(){clearTimeout(n),e?.removeEventListener("abort",r)}}}s(L,"createOperationSignal");function q(e){return/^https?:/iu.test(e)}s(q,"claimsHttpScheme");function z(e){return e?.reason instanceof Error?e.reason:J()}s(z,"abortReason");function J(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(J,"abortError");function K(e){let o=new Error(`Web read timed out after ${e}ms`);return o.name="TimeoutError",o}s(K,"timeoutError");function C(e){return e instanceof Error?e.message:String(e)}s(C,"errorMessage");var X={provider:"web",capability:"read"},Q=R({kind:"markdown",label:"WEB"});async function Y(e){let o=P(e,X),t=H(o),r={protocol:y,apiVersion:v,id:"web",setup(n){n.addResolver({resolver:t,renderResult:Q,preserveTruncatedOutput:!0}),n.describe(()=>A("Reads HTTP(S) URLs, automatically retrying failed reads or empty HTML in a local browser.",o.listDescriptions())),n.addPromptGuideline("Use read with the plain HTTP(S) URL; browser fallback is automatic.")}};await Promise.all([E(e,r),Promise.resolve(g(e,x))])}s(Y,"registerWeb");export{Y as a};
|
package/dist/chunk-KYVOMBO5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as g}from"./chunk-XNXQYPVT.js";import{a as E}from"./chunk-EEH4WYI7.js";import{a as T,b as h}from"./chunk-266RH77Z.js";import{a as v}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import x from"node:path";var c=class{static{a(this,"OverwriteAttempts")}pending=new Set;pendingBySource=new Map;approvedForExecution=new Set;pendingEarly=new Set;approvedEarlyForExecution=new Set;inspectEarly(t){let e=f(t);return this.pendingEarly.delete(e)?(this.approvedEarlyForExecution.add(e),{kind:"accepted"}):(this.pendingBySource.get(e)?.size??0)>0?{kind:"deferred"}:(this.pendingEarly.add(e),y())}inspectStream(t){let e=f(t);if(this.pendingEarly.delete(e))return this.approvedEarlyForExecution.add(e),{kind:"accepted"};let n=k(t);return this.pending.delete(n)?(this.forgetPending(e,n),this.approvedForExecution.add(n),{kind:"accepted"}):(this.rememberPending(e,n),y())}inspectExecution(t){let e=f(t);if(this.approvedEarlyForExecution.delete(e))return{kind:"accepted"};let n=k(t);return this.approvedForExecution.delete(n)?{kind:"accepted"}:this.pending.delete(n)?(this.forgetPending(e,n),{kind:"accepted"}):(this.rememberPending(e,n),y())}rememberPending(t,e){this.pending.add(e);let n=this.pendingBySource.get(t)??new Set;n.add(e),this.pendingBySource.set(t,n)}forgetPending(t,e){let n=this.pendingBySource.get(t);n!==void 0&&(n.delete(e),n.size===0&&this.pendingBySource.delete(t))}};function P(r){let t=new c;return E(r,{protocol:T,apiVersion:h,id:"text-editor-overwrite",setup(n){n.addMutationGuard(C(t));let o=I(r,n,t);g(r,o.handler),n.onMutationTool(o.add)}})}a(P,"registerTextEditorOverwriteGuard");function _(){return C(new c)}a(_,"createOverwriteGuard");function C(r){return{id:"overwrite",guard(t,e){if(e.intent==="restore")return{kind:"accepted"};let n=M(t,e.cwd);return n.length===0?{kind:"accepted"}:r.inspectExecution(n)}}}a(C,"createGuard");function I(r,t,e){let n=new Map,o=new Set,d=[],s={name:"text-editor-overwrite-inspection",blockExecution:!0,toolNames:d,async intercept(i){if(i.contentIndex!==void 0&&o.has(i.contentIndex))return;let m=n.get(i.toolCall.name);if(m===void 0)return;let l=i.partialArgs!==void 0,R=l?A(m,v(i.partialArgs)):i.args,w=await t.previewMutation({tool:i.toolCall.name,input:R,cwd:i.cwd,...i.signal!==void 0&&{signal:i.signal}});if(w.kind==="failed")return;let p=S(w.resources,i.toolCall.name,l,i.cwd);if(p.length===0)return;let u=l?e.inspectEarly(p):e.inspectStream(p);if(u.kind==="rejected")return b(u.rejection);u.kind==="accepted"&&l&&i.contentIndex!==void 0&&o.add(i.contentIndex)},onContentEnd(i){o.delete(i)},onAbort(i){o.delete(i)},onAgentEnd(){o.clear()}};return{handler:s,add(i){i.intent!=="restore"&&(n.set(i.name,i),d.push(i.name),g(r,s))}}}a(I,"createStreamingGuard");function M(r,t){return r.resources.filter(e=>e.existed&&e.after.content!==e.before.content&&e.changes.some(({fromBefore:n,toBefore:o})=>n===0&&o===e.before.content.length)).map(e=>({source:O(e.source,t),afterContent:e.after.content}))}a(M,"planCandidates");function A(r,t){let e={...t},n=r.parameters;if(!Array.isArray(n.required))return e;for(let o of n.required)typeof o=="string"&&!(o in e)&&n.properties?.[o]?.type==="string"&&(e[o]="");return e}a(A,"preparePreviewArguments");function S(r,t,e,n){let o=e&&t==="write";return r.filter(d=>d.existed===!0&&(o||d.afterContent!==d.beforeContent&&d.beforeRanges?.some(({from:s,to:i})=>s===0&&i===d.beforeContent.length)===!0)).map(d=>({source:O(d.path,n),afterContent:d.afterContent}))}a(S,"previewCandidates");function O(r,t){return/^[A-Za-z][A-Za-z\d+.-]*:/u.test(r)||x.isAbsolute(r)?r:x.resolve(t,r)}a(O,"canonicalSource");function k(r){return[...r].sort((t,e)=>t.source.localeCompare(e.source)).map(({source:t,afterContent:e})=>`${t}\0${e}`).join("")}a(k,"attemptKey");function f(r){return[...r].map(({source:t})=>t).sort((t,e)=>t.localeCompare(e)).join("")}a(f,"sourceAttemptKey");function y(){let r="The file already exists \u2014 a full rewrite may be unnecessary. Overwriting is error-prone, token-cost ineffective and simply stupid. Think again and prefer precise text editing operations. If the task genuinely requires overwriting this file, state why and repeat the same operation.";return{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:r,message:r,annotation:{kind:"overwrite-blocked"},effect:"not-applied"}}}a(y,"rejected");function b(r){return{annotation:{kind:"custom",label:"Overwrite Blocked",color:"warning"},message:{customType:"text-editor-overwrite-block",content:`Reason: ${r.reason}`,display:!1,details:r}}}a(b,"interceptResult");export{P as a,_ as b};
|
package/dist/chunk-LFV6G5Z3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./chunk-GTK5AREE.js";import{v as e}from"./chunk-EW2KVKCN.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerWebImage");export{i as a};
|