pi-agent-ide 0.6.2 → 0.6.4
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 +66 -0
- package/README.md +8 -1
- package/dist/chunk-2P2OGO3G.js +2 -0
- package/dist/{chunk-5QQABP47.js → chunk-3BBJZSMS.js} +1 -1
- package/dist/chunk-5J43L2RL.js +11 -0
- package/dist/{chunk-ITSNK5YG.js → chunk-7AVXUV4A.js} +2 -2
- package/dist/chunk-BAYETTZZ.js +16 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-BSICWXMH.js} +1 -1
- package/dist/chunk-BVK5A7ED.js +28 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-L7JMDDSD.js → chunk-FBOW7XOV.js} +1 -1
- package/dist/{chunk-25CZ5ZIU.js → chunk-FUG2TEKI.js} +1 -1
- package/dist/chunk-FZBCKIJJ.js +1 -0
- package/dist/chunk-HPUAIWIH.js +25 -0
- package/dist/chunk-I5JLCFUX.js +1 -0
- package/dist/chunk-KUPHNMUK.js +2 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-MIZAFRDR.js +1 -0
- package/dist/chunk-PJPA5EEE.js +2 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-QEJGED4V.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/{chunk-VXD6FZP5.js → chunk-TQZBVOTT.js} +3 -3
- package/dist/chunk-VBICI5YA.js +1 -0
- package/dist/chunk-VWW3RLUX.js +12 -0
- package/dist/{chunk-O6LE42GK.js → chunk-WJTHY6AG.js} +1 -1
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/chunk-ZODCBFBL.js +2 -0
- package/dist/chunk-ZPT5D4VP.js +2 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -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 +11 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +2 -2
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -12
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +4 -4
- package/dist/entry-51.js +9 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +0 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -315
- package/dist/entry-78.js +324 -25
- package/dist/entry-79.js +18 -2
- package/dist/entry-80.js +2 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +1 -3
- package/dist/entry-83.js +5 -3
- package/dist/entry-84.js +3 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/apply.md +1 -1
- package/docs/agent-guides/editing.md +16 -0
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +6 -0
- package/docs/agent-guides/search-code.md +5 -1
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +34 -0
- package/docs/development.md +15 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- package/docs/research/native-codemode-batch-decision.md +27 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +59 -0
- package/docs/tools.md +18 -2
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-documentation/src/index.ts +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +6 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -6
- package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +10 -10
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +17 -0
- package/node_modules/pi-agent-ide-changes/index.ts +3 -9
- package/node_modules/pi-agent-ide-changes/package.json +8 -7
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/tools/read.ts +31 -2
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +12 -0
- package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
- package/node_modules/pi-agent-search/package.json +5 -4
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/node_modules/pi-agent-search/src/api/search.ts +11 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +93 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +40 -14
- package/node_modules/pi-agent-search/src/core/search-core.ts +136 -77
- package/node_modules/pi-agent-search-text/index.ts +3 -0
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/resolvers.ts +17 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -8
- package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +37 -3
- package/node_modules/pi-agent-search-text/src/search-session.ts +21 -13
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-document.ts +15 -10
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/index.ts +4 -2
- package/node_modules/pi-agent-text-editor/package.json +21 -17
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +314 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +8 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +7 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-web/index.ts +20 -0
- package/node_modules/pi-agent-web/package.json +8 -7
- package/node_modules/pi-agent-web/src/search.ts +112 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- 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-87.js +2 -0
- package/package.json +42 -36
- package/skills/capture-code-review-rule/SKILL.md +60 -0
- package/src/code-review/config.ts +68 -0
- package/src/code-review/extension.ts +105 -0
- package/src/code-review/fragments.ts +26 -0
- package/src/code-review/reviewer.ts +198 -0
- package/src/composite/host-version.ts +13 -0
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/tool-availability.ts +90 -0
- package/src/core/extension.ts +2 -0
- package/src/documentation/extension.ts +81 -145
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -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-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-87.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +112 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +31 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +37 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +21 -13
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/src/extensions/pi-agent-search/src/api/search.ts +11 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +93 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +40 -14
- package/src/extensions/pi-agent-search/src/core/search-core.ts +136 -77
- package/src/extensions/pi-agent-text-editor/index.ts +4 -2
- package/src/extensions/pi-agent-text-editor/package.json +21 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +8 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- 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-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +314 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/src/pi-agent-ide.ts +61 -2
- package/src/plugins/pi-agent-ide-ast/package.json +10 -10
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +17 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +3 -9
- package/src/plugins/pi-agent-ide-changes/package.json +8 -7
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
- package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
- package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +13 -8
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
- package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +97 -45
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +16 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-CEX3VOJ7.js +0 -2
- package/dist/chunk-FA6BKC5Y.js +0 -1
- package/dist/chunk-FEDVTZJG.js +0 -1
- package/dist/chunk-HMLH43ZS.js +0 -4
- package/dist/chunk-KII2JQC5.js +0 -1
- package/dist/chunk-LVWMWWWF.js +0 -28
- package/dist/chunk-P7XO5CIP.js +0 -2
- package/dist/chunk-PZFOOHY2.js +0 -15
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-YT42LKFV.js +0 -16
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- /package/dist/{chunk-4U2GUKNJ.js → chunk-F7NVAC4Q.js} +0 -0
- /package/dist/{chunk-ROXXK6TW.js → chunk-PXWDDBBC.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{d as C}from"./chunk-7AVXUV4A.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{diffChars as j}from"diff";import{DefaultLinesDiffComputer as J}from"vscode-diff";var F=2,_=.5,k=100,Q=16e3,H=1e6,Z=new J,ee=new Set(["async","boolean","const","export","false","function","interface","let","new","null","number","private","protected","public","readonly","return","static","string","true","type","undefined","var"]);function E(e,n,t=[],r={}){let o=ne(e,n,(r.beforeLineOffset??0)+1,(r.afterLineOffset??0)+1);if(o===void 0)return{rows:[],added:0,modified:0,removed:0,focusRow:0,omittedChanges:{outside:0,ambiguous:0,unavailable:!0}};let i=r.project===!1?o:oe(o),s=r.focusAfterLine??(t.length===0?void 0:fe(n,y(t.at(-1)).to)+(r.afterLineOffset??0));return{rows:i,added:o.filter(({kind:f})=>f==="added").length,modified:o.filter(({kind:f})=>f==="modified").length,removed:o.filter(({kind:f})=>f==="removed").length,focusRow:se(i,s)}}c(E,"createDiffModel");function ne(e,n,t=1,r=1){if(e.length+n.length>H)return;let o=performance.now()+k,i=W(e),s=W(n),f=[];if(i.length===0||s.length===0)return[...i.map((d,g)=>({kind:"removed",text:d,beforeLine:t+g,changed:!0})),...s.map((d,g)=>({kind:"added",text:d,afterLine:r+g,changed:!0}))];let a=Z.computeDiff([...i],[...s],{ignoreTrimWhitespace:!0,computeMoves:!1,maxComputationTimeMs:k});if(a.hitTimeout||performance.now()>=o)return;let u=0,l=0,m=c(d=>{for(;l<d;)f.push({kind:"context",text:y(s[l]),beforeLine:t+u++,afterLine:r+l++,changed:!1})},"appendContext");for(let d of a.changes){m(d.modified.startLineNumber-1);let g=i.slice(d.original.startLineNumber-1,d.original.endLineNumberExclusive-1).map((b,R)=>({text:b,line:t+u+R})),h=s.slice(d.modified.startLineNumber-1,d.modified.endLineNumberExclusive-1).map((b,R)=>({text:b,line:r+l+R})),w=te(g,h,o);f.push(...w??[...g.map(({text:b,line:R})=>({kind:"removed",text:b,beforeLine:R,changed:!0})),...h.map(({text:b,line:R})=>({kind:"added",text:b,afterLine:R,changed:!0}))]),u+=g.length,l+=h.length}if(m(s.length),e.endsWith(`
|
|
2
|
+
`)!==n.endsWith(`
|
|
3
|
+
`)){let d=f.at(-1);d?.kind==="context"&&(f[f.length-1]={...d,kind:"modified",changed:!0,addedRanges:[],deletedOffsets:e.endsWith(`
|
|
4
|
+
`)?[d.text.length]:[]})}return f}c(ne,"createSemanticRows");function D(e,n,t){let r=e[n]?.[t];if(r===void 0)throw new RangeError(`Score [${n}, ${t}] is outside the alignment matrix.`);return r}c(D,"scoreAt");function te(e,n,t){let r=new Map,o=c((l,m)=>{if(performance.now()>=t)return;let d=r.get(l)?.get(m);if(d!==void 0)return d;let g=ie(l,m,t);if(g!==void 0){let h=r.get(l);h===void 0&&(h=new Map,r.set(l,h)),h.set(m,g)}return g},"compareCharacters");if(e.length>1&&e.length===n.length){let l=[];for(let[m,d]of e.entries()){let g=y(n[m]),h=z(d.text,g.text,o);if(h===void 0)return;if(h<_)break;let w=v(d,g,t);if(w===void 0)return;l.push(w)}if(l.length===e.length)return l}if(e.length===1&&n.length===1){let l=v(y(e[0]),y(n[0]),t);return l===void 0?void 0:[l]}if(e.length*n.length>Q)return;let i=Array.from({length:e.length},()=>Array(n.length).fill(0)),s=Array.from({length:e.length+1},()=>Array.from({length:n.length+1}).fill(0));for(let l=1;l<=e.length;l++)for(let m=1;m<=n.length;m++){let d=z(y(e[l-1]).text,y(n[m-1]).text,o);if(d===void 0)return;y(i[l-1])[m-1]=d;let g=d>=_?D(s,l-1,m-1)+d:Number.NEGATIVE_INFINITY;y(s[l])[m]=Math.max(D(s,l-1,m),D(s,l,m-1),g)}let f=[],a=e.length,u=n.length;for(;a>0||u>0;){let l=a>0&&u>0?D(i,a-1,u-1):0;if((a>0&&u>0&&l>=_?D(s,a-1,u-1)+l:Number.NEGATIVE_INFINITY)===D(s,a,u)){let d=v(y(e[a-1]),y(n[u-1]),t);if(d===void 0)return;f.push(d),a--,u--}else if(u>0&&D(s,a,u-1)>=(a>0?D(s,a-1,u):Number.NEGATIVE_INFINITY)){let d=y(n[u-1]);f.push({kind:"added",text:d.text,afterLine:d.line,changed:!0}),u--}else{let d=y(e[a-1]);f.push({kind:"removed",text:d.text,beforeLine:d.line,changed:!0}),a--}}return f.reverse()}c(te,"alignChangedLines");function v(e,n,t){let r=re(e.text,n.text,t);if(r!==void 0)return{kind:"modified",text:n.text,beforeLine:e.line,afterLine:n.line,changed:!0,...r}}c(v,"modifiedRow");function re(e,n,t=performance.now()+k){let r=t-performance.now();if(r<=0||e.length+n.length>H)return;let o=j(e.trim(),n.trim(),{timeout:r,maxEditLength:5e3});if(o===void 0)return;let i=[],s=[],f=n.length-n.trimStart().length;for(let a=0;a<o.length;a++){let u=y(o[a]);u.removed?o[a+1]?.added||s.push(f):(u.added&&i.push({from:f,to:f+u.value.length}),f+=u.value.length)}return{addedRanges:i,deletedOffsets:s}}c(re,"compareInlineText");function z(e,n,t){let r=t(e,n);if(r===void 0)return;let o=V(e),i=V(n);if(o.length===0&&i.length===0)return r;let s=B(o,i,t),f=B(i,o,t);if(s===void 0||f===void 0)return;let a=(s+f)/2;return r*.35+a*.65}c(z,"lineSimilarity");function V(e){return(e.toLowerCase().match(/[\p{L}\p{N}_$]+/gu)??[]).filter(n=>!ee.has(n))}c(V,"semanticTokens");function B(e,n,t){if(e.length===0||n.length===0)return 0;let r=0;for(let o of e){let i=0;for(let s of n){let f=t(o,s);if(f===void 0)return;i=Math.max(i,f)}r+=i}return r/e.length}c(B,"directionalTokenSimilarity");function ie(e,n,t){if(t-performance.now()<=0)return;let o=Math.max(e.length,n.length);if(o===0||e===n)return 1;let i=Array.from(e),s=Array.from(n),f=0,a=0;for(;f<i.length&&f<s.length&&i[f]===s[f];)a+=y(i[f]).length,f++;let u=i.length,l=s.length;for(;u>f&&l>f&&i[u-1]===s[l-1];)a+=y(i[--u]).length,l--;let m=i.slice(f,u),d=s.slice(f,l);if(d.length>m.length&&([m,d]=[d,m]),d.length<=31&&m.every(w=>w.length===1)){let w=new Map;for(let[T,x]of d.entries())w.set(x,(w.get(x)??0)|1<<T);let b=0;for(let T of m){let x=(w.get(T)??0)|b;b=x&~(x-(b<<1|1))}let R=a;for(;b!==0;)b&=b-1,R++;return R/o}let g=j(e,n,{timeout:t-performance.now(),maxEditLength:2e3});return g===void 0?void 0:g.filter(w=>!w.added&&!w.removed).reduce((w,b)=>w+b.value.length,0)/o}c(ie,"characterSimilarity");function oe(e){let n=[];for(let t=0;t<e.length;t++){if(!y(e[t]).changed)continue;let r=t;for(;t+1<e.length&&y(e[t+1]).changed;)t++;let o={start:Math.max(0,r-F),end:Math.min(e.length-1,t+F)},i=n.at(-1);i!==void 0&&o.start<=i.end+1?n[n.length-1]={start:i.start,end:Math.max(i.end,o.end)}:n.push(o)}return n.flatMap((t,r)=>{let o=n[r-1];return[...o===void 0?[]:[de(t.start-o.end-1)],...e.slice(t.start,t.end+1)]})}c(oe,"projectHunks");function de(e){return{kind:"omitted",text:"",changed:!1,omitted:e}}c(de,"omittedRow");function W(e){if(e.length===0)return[];let n=e.replaceAll(`\r
|
|
5
|
+
`,`
|
|
6
|
+
`),t=n.split(`
|
|
7
|
+
`);return n.endsWith(`
|
|
8
|
+
`)&&t.pop(),t}c(W,"splitPart");function fe(e,n){let t=1;for(let r=0;r<Math.min(n,e.length);r++)e[r]===`
|
|
9
|
+
`&&t++;return t}c(fe,"lineAtOffset");function se(e,n){if(n!==void 0){let t=e.findLastIndex(r=>r.afterLine!==void 0&&r.afterLine<=n&&r.changed);if(t!==-1)return t}return Math.max(0,e.findLastIndex(t=>t.changed))}c(se,"findFocusRow");function G(e){return{resources:e.flatMap(n=>{let t=n.model??E(n.beforeContent,n.afterContent,n.ranges),r=ae(t,n),o=t.rows[t.focusRow]?.afterLine;return r.length===0?[]:[{path:n.path,windows:r,...o!==void 0&&{focusAfterLine:o}}]})}}c(G,"freezeMutationViewports");function $(e,n){return e.map(t=>{let r=n?.resources.find(o=>ce(o.path,t.path));return r===void 0?{...t,model:E(t.beforeContent,t.afterContent,t.ranges)}:{...t,model:ue(t.beforeContent,t.afterContent,r,t.diffPeerRanges,t.finalLineOwnership)}})}c($,"projectFinalResources");function ae(e,n){let t=[],r=[],o=c(()=>{if(r.length===0)return;let i=r.flatMap(h=>h.beforeLine===void 0?[]:[h.beforeLine]),s=I(n.beforeContent,n.beforeRanges?.at(-1)),f=i.length===0?s-1:Math.min(...i)-1,a=i.length===0?f:Math.max(...i),u=r.flatMap(h=>h.changed&&h.beforeLine!==void 0?[h.beforeLine]:[]),l=r.findIndex(h=>h.changed),m=r.slice(0,l).findLast(h=>h.beforeLine!==void 0)?.beforeLine,d=r.slice(l+1).find(h=>h.beforeLine!==void 0)?.beforeLine,g=m??(d===void 0?s-1:d-1);t.push({beforeStart:f,beforeEnd:a,seedStart:u.length===0?g:Math.min(...u)-1,seedEnd:u.length===0?g:Math.max(...u)}),r=[]},"flush");for(let i of e.rows)i.kind==="omitted"?o():r.push(i);return o(),t}c(ae,"freezeWindows");function ue(e,n,t,r=[],o){let i=E(e,n,[],{project:!1});if(i.rows.length===0&&e!==n)return{...i,omittedChanges:{outside:0,ambiguous:0,unavailable:!0}};let s=new Set,f=0,a=0,u=0;for(let d=0;d<i.rows.length;){let g=y(i.rows[d]);if(!g.changed){u=g.beforeLine??u,d++;continue}let h=d,w=u,b=[];for(;d<i.rows.length&&y(i.rows[d]).changed;){let p=y(i.rows[d]).beforeLine;p!==void 0&&(b.push(p),u=p),d++}let R=b.length===0?w:Math.min(...b)-1,T=b.length===0?w:Math.max(...b),x=t.windows.filter(p=>P(R,T,p.seedStart,p.seedEnd));if(r.some(p=>{let M=I(e,p)-1,A=I(e,{from:Math.max(p.from,p.to-1),to:p.to});return P(R,T,M,p.from===p.to?M:A)})){if(x.length>0)for(let p=h;p<d;p++){let M=y(i.rows[p]).beforeLine,A=y(i.rows[p]).afterLine;if(M===void 0&&A!==void 0&&o!==void 0){let L=o.own.includes(A),N=o.peers.includes(A);L&&!N?s.add(p):(L||!N)&&a++;continue}let S=M!==void 0&&x.some(L=>P(M-1,M,L.seedStart,L.seedEnd)),O=M!==void 0&&r.some(L=>{let N=I(e,L)-1,U=I(e,{from:Math.max(L.from,L.to-1),to:L.to});return P(M-1,M,N,U)});S&&!O?s.add(p):(!O||S)&&a++}continue}if(x.length===0){f+=d-h;continue}if(!x.some(p=>R>=p.beforeStart&&T<=p.beforeEnd)){a+=d-h;continue}for(let p=h;p<d;p++)s.add(p)}for(let d of[...s])for(let g=Math.max(0,d-F);g<Math.min(i.rows.length,d+F+1);g++)y(i.rows[g]).changed||s.add(g);let l=[],m=-1;for(let d of[...s].sort((g,h)=>g-h))m!==-1&&d>m+1&&l.push({kind:"omitted",text:"",changed:!1,omitted:d-m-1}),l.push(y(i.rows[d])),m=d;return{rows:l,added:l.filter(({kind:d})=>d==="added").length,modified:l.filter(({kind:d})=>d==="modified").length,removed:l.filter(({kind:d})=>d==="removed").length,focusRow:le(l,t.focusAfterLine),...f+a>0&&{omittedChanges:{outside:f,ambiguous:a}}}}c(ue,"createFrozenModel");function P(e,n,t,r){return e===n?e>=t&&e<=r:t===r?t>=e&&t<=n:e<r&&n>t}c(P,"overlaps");function I(e,n){let t=n?.from??0;return e.slice(0,t).split(`
|
|
10
|
+
`).length}c(I,"lineAtRange");function le(e,n){if(n!==void 0){let t=e.findLastIndex(r=>r.afterLine!==void 0&&r.afterLine<=n);if(t!==-1)return t}return Math.max(0,e.findLastIndex(({changed:t})=>t))}c(le,"focusRowAt");function ce(e,n){return e===n||e.endsWith(`/${n}`)||n.endsWith(`/${e}`)}c(ce,"samePath");function X(e,n,t=!0){let r=e?.mutationRender;if(r!==void 0)return r.map(({path:f,model:a,diffStatuses:u})=>({path:f,model:a,...u===void 0?{}:{diffStatuses:u},ranges:[],beforeContent:"",afterContent:""}));let o=(e?.results??[]).map(f=>C.ensure(f)),i=o.flatMap(me);if(!t)return i;let s=n??he(o);return $(i,s)}c(X,"resolveMutationResultResources");function me(e){let n=e.afterContent,t=Y(e.data.rawChanges);return!e.ok||typeof n!="string"?[]:K(e).flatMap(r=>{let o=e.beforeContentMap?.[r];if(typeof o!="string"&&o!==null)return[];let i=t===void 0?void 0:q(o??"",t),s=ge(o??"",n,t,e.data.diffPeerRanges),f=i===n?{beforeRanges:t?.map(({fromA:a,toA:u})=>({from:a,to:u}))??[],ranges:t?.map(({fromB:a,toB:u})=>({from:a,to:u}))??[]}:void 0;return[{path:r,ranges:[],beforeContent:o??"",...f===void 0?{}:{typingIdentity:f},...s===void 0?{}:{finalLineOwnership:s},...e.data.diffPeerRanges===void 0?{}:{diffPeerRanges:e.data.diffPeerRanges},...e.data.diffStatuses===void 0?{}:{diffStatuses:e.data.diffStatuses},afterContent:n}]})}c(me,"finalResource");function ge(e,n,t,r){if(t===void 0||r===void 0)return;let o=[...t.map(({fromA:a,toA:u,insertedText:l})=>({from:a,to:u,insert:l,own:!0})),...r.map(a=>({...a,own:!1}))].sort((a,u)=>a.from-u.from),i={own:new Set,peers:new Set},s="",f=0;for(let a of o){if(a.from<f||a.to<a.from||a.to>e.length)return;s+=e.slice(f,a.from);let u=s.split(`
|
|
11
|
+
`).length;if(s+=a.insert,a.insert.length>0){let l=s.slice(0,-1).split(`
|
|
12
|
+
`).length;for(let m=u;m<=l;m++)i[a.own?"own":"peers"].add(m)}f=a.to}if(s+e.slice(f)===n)return{own:[...i.own],peers:[...i.peers]}}c(ge,"unchangedBatchOwnership");function he(e){let n=e.flatMap(pe);return n.length===0?void 0:G(n)}c(he,"persistedViewports");function pe(e){if(!e.ok)return[];let n=Y(e.data.rawChanges);return n===void 0||n.length===0?[]:K(e).flatMap(t=>{let r=e.beforeContentMap?.[t];if(typeof r!="string"&&r!==null)return[];let o=r??"",i=q(o,n);return i===void 0?[]:[{path:t,beforeContent:o,afterContent:i,beforeRanges:n.map(({fromA:s,toA:f})=>({from:s,to:f})),ranges:n.map(({fromB:s,toB:f})=>({from:s,to:f}))}]})}c(pe,"generatedResource");function K(e){return e.files.length>0?e.files.map(({path:n})=>n):e.path===void 0?[]:[e.path]}c(K,"resultPaths");function Y(e){if(!(!Array.isArray(e)||!e.every(ye)))return[...e].sort((n,t)=>n.fromA-t.fromA)}c(Y,"persistedChanges");function ye(e){if(typeof e!="object"||e===null)return!1;let n=e;return Number.isInteger(n.fromA)&&Number.isInteger(n.toA)&&Number.isInteger(n.fromB)&&Number.isInteger(n.toB)&&typeof n.insertedText=="string"}c(ye,"isPersistedTextChange");function q(e,n){let t="",r=0;for(let o of n){if(o.fromA<r||o.toA<o.fromA||o.toA>e.length)return;t+=e.slice(r,o.fromA)+o.insertedText,r=o.toA}return t+e.slice(r)}c(q,"replayChanges");function ve(e){let n=X(e,void 0),{displayResults:t,...r}=e;return{...r,results:e.results?.map(o=>{let i=C.ensure(o),{beforeContentMap:s,afterContent:f,afterDocument:a,snapshot:u,activeEdits:l,inputEdits:m,beforeReadText:d,rawChanges:g,diffPeerRanges:h,diffs:w,...b}=i.data;return new C(b)}),mutationRender:n.flatMap(({path:o,model:i,diffStatuses:s})=>i===void 0?[]:[{path:o,model:i,...s===void 0?{}:{diffStatuses:s}}])}}c(ve,"compactMutationDetails");export{F as a,E as b,re as c,G as d,X as e,ve as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{m as c}from"./chunk-2P2OGO3G.js";import{e as a}from"./chunk-ZPT5D4VP.js";import{a as r}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";var n="pi-agent-text-editor",p=22,P="pi-agent-text-editor/position",S="pi-agent-text-editor/search",I=`${n}/core/ready`,b=`${n}/plugin/register`,s=e.Function([],e.Unknown()),u=e.Object({tryResolve:s},{additionalProperties:!0}),l=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),T=e.Object({start:l,end:l,linewise:e.Optional(e.Boolean())}),x=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(T))}),R=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(x,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),g=e.String({pattern:"\\S"}),m=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),y=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),v=e.Object({protocol:e.Literal(n),apiVersion:e.Literal(p)}),d=e.Object({protocol:e.Literal(n),apiVersion:e.Literal(p),id:e.String(),setup:s}),E=e.Object({plugin:d,accept:s});function k(t){return i.Check(g,t)}r(k,"isTextEditorToolId");function _(t){if(!i.Check(m,t))return!1;let o=t;return c(o.resolver)&&(!("priority"in o)||typeof o.priority=="number")}r(_,"isResourceResolverRegistration");function C(t){if(!i.Check(y,t))return!1;let o=t;return a(o.resolver)&&(!("resources"in o)||i.Check(u,o.resources))&&(!("priority"in o)||typeof o.priority=="number")}r(C,"isTextAnchorResolverRegistration");function j(t){return i.Check(R,t)}r(j,"isTextAnchorResourceResolutionAttempt");function w(t){return i.Check(v,t)}r(w,"isTextEditorCoreReady");function L(t){return i.Check(d,t)}r(L,"isTextEditorPlugin");function N(t){return i.Check(E,t)}r(N,"isTextEditorPluginRegistrationRequest");export{n as a,p as b,P as c,S as d,I as e,b as f,k as g,_ as h,C as i,j,w as k,L as l,N as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t="pi-agent-text-editor:native-batch-finished";export{t as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as W}from"./chunk-PLKYHUNT.js";import{m as w}from"./chunk-ZPT5D4VP.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createHash as ye}from"node:crypto";import{readFile as Z}from"node:fs/promises";import m from"node:path";import{spawn as le}from"node:child_process";import{stat as ue}from"node:fs/promises";import k from"node:path";import{createInterface as de}from"node:readline";import{existsSync as oe}from"node:fs";import ie from"node:os";import q from"node:path";function Q(e=process.env.PI_CODING_AGENT_DIR??q.join(ie.homedir(),".pi","agent"),t=process.platform){let n=q.join(e,"bin",t==="win32"?"rg.exe":"rg");return oe(n)?n:"rg"}c(Q,"resolveRipgrepExecutable");function j(e,t=!1){let n=E(e);return N(n)?I(A(new v(e,n).parse(),t)):t?e:O(e)}c(j,"compileSearchQuery");function L(e,t=!1){let n=E(e);return N(n)?A(new v(e,n).parse(),t):void 0}c(L,"compileSearchCondition");function T(e,t){if(e.kind==="term")return t(e.value);let n=T(e.left,t);if(e.kind==="or")return n||T(e.right,t);let r=T(e.right,t);return n&&(e.kind==="not"?!r:r)}c(T,"satisfiesSearchCondition");function z(e){if(N(E(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(O).join("|")})`:void 0}c(z,"compileSearchFallbackQuery");function N(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}c(N,"containsBooleanSyntax");var v=class{static{c(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(t,n){this.#t=t,this.#r=n}parse(){let t=this.#s(),n=this.#e();if(n.type!=="end"){let r=n.type==="right"?"unexpected ')'.":`unexpected ${ce(n)}.`;throw y(n.offset,r)}return t}#s(){let t=this.#n();for(;this.#e().type==="or";){let n=this.#o(),r=this.#a(`after ${n.value}`);t={kind:"or",left:t,right:this.#c(r)}}return t}#n(){return this.#c(this.#a())}#c(t){let n=t;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#a(`after ${r.value}`);n={kind:r.type,left:n,right:o};continue}if(r.type==="term"||r.type==="left"){n={kind:"and",left:n,right:this.#a()};continue}return n}}#a(t){let n=this.#e();if(n.type==="term")return this.#o(),{kind:"term",value:n.value,quoted:n.quoted};if(n.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(t===void 0&&(n.type==="and"||n.type==="or"||n.type==="not"))throw y(n.offset,`expected a term before ${n.value}.`);let r=t===void 0?"":` ${t}`;throw y(n.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let t=this.#e();return this.#i+=1,t}};function E(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(/\s/u.test(r)){n+=1;continue}if(r==="("&&se(e,n)){t.push({type:"left",value:r,offset:n}),n+=1;continue}if(r===")"){t.push({type:"right",value:r,offset:n}),n+=1;continue}if(G(e,n)){let s=e.charAt(n+1)==="|"?2:1;t.push({type:"or",value:e.slice(n,n+s),offset:n}),n+=s;continue}if(r==="'"||r==='"'){let s=n,l=r,a="";for(n+=1;n<e.length&&e.charAt(n)!==l;)e.charAt(n)==="\\"&&(e.charAt(n+1)===l||e.charAt(n+1)==="\\")&&(n+=1),a+=e.charAt(n++);if(n>=e.length)throw y(s,`unterminated ${l==="'"?"single":"double"}-quoted term.`);if(n+=1,a.length===0)throw y(s,"quoted terms must not be empty.");t.push({type:"term",value:a,offset:s,quoted:!0});continue}let o=n;for(;n<e.length;){let s=e.charAt(n);if(/\s/u.test(s)||s===")"||G(e,n))break;s==="\\"&&n+1<e.length?n+=2:s==="["||s==="("?n=H(e,n)??n+1:n+=1}let i=e.slice(o,n);t.push({type:ae(i),value:i,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}c(E,"tokenize");function G(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}c(G,"isBooleanPipe");function H(e,t){let n=e.charAt(t)==="["?"]":")",r=t+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===n)return r+1;if(n===")"&&(o==="("||o==="[")){let i=H(e,r);if(i===void 0)return;r=i}else r+=1}}}c(H,"regexBlockEnd");function se(e,t){let n=H(e,t);if(n===void 0)return!0;let r=e.slice(t+1,n-1);return r.trim().length===0?!0:N(E(r))}c(se,"isBooleanGroup");function ae(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}c(ae,"operatorType");function ce(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}c(ce,"quoteToken");function y(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}c(y,"syntaxError");function A(e,t){return e.kind==="term"?{kind:"term",value:t&&!e.quoted?e.value:O(e.value)}:{kind:e.kind,left:A(e.left,t),right:A(e.right,t)}}c(A,"compileTerms");function I(e){if(e.kind==="term")return e.value;let t=I(e.left);return e.kind==="not"?t:`(?:${t}|${I(e.right)})`}c(I,"matchPattern");function O(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}c(O,"escapeRegex");async function M(e,t,n){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");return e.condition!==void 0?he(e,t,n):K(e,t,n)}c(M,"searchText");async function K(e,t,n,r){let o=k.resolve(t,pe(e.path??".")),i=(await ue(o)).isDirectory(),s=i?o:k.dirname(o),l=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...U(e.include).flatMap(a=>["--glob",a]),...U(e.exclude).flatMap(a=>["--glob",`!${a}`]),"--",e.query,i?".":k.basename(o)];if(e.regex!==!0)return F(["--fixed-strings",...l],s,n,r);try{return await F(["--engine","auto",...l],s,n,r)}catch(a){if(!fe(a))throw a instanceof Error&&/PCRE2 is not available|does not support PCRE2/iu.test(a.message)?new Error("This regex requires PCRE2. Install ripgrep with PCRE2 support or simplify the regex.",{cause:a}):a;try{return await F(["--engine","default",...l],s,n,r)}catch(u){throw n?.aborted?u:new AggregateError([a,u],"Regex exceeded the PCRE2 match limit and cannot run with the default engine. Narrow the search or simplify the regex.",{cause:u})}}}c(K,"searchPattern");async function he(e,t,n){let r=e.condition;if(r===void 0)throw new Error("Boolean search requires a line condition.");let o=new Set;function i(h){if(h.kind==="term"){o.add(h.value);return}i(h.left),i(h.right)}c(i,"collect"),i(r);let{condition:s,...l}=e,a=new Map,u=c(h=>JSON.stringify([h.source,h.lineNumber]),"lineKey");for(let h of o){n?.throwIfAborted();let f=new Set;await K({...l,query:h,regex:!0,wholeWord:!1},t,n,(S,C)=>f.add(JSON.stringify([S,C]))),a.set(h,f)}let d=await M(l,t,n),g=new Set,p=d.matches.filter(h=>{let f=u(h);return g.has(f)||!T(r,S=>a.get(S)?.has(f)===!0)?!1:(g.add(f),!0)});return{...d,matches:p}}c(he,"searchBoolean");function F(e,t,n,r){return new Promise((o,i)=>{let s=le(Q(),e,{stdio:["ignore","pipe","pipe"],cwd:t}),l=de({input:s.stdout}),a=[],u="",d,g=c(()=>{s.kill()},"abort"),p=c(()=>{n?.removeEventListener("abort",g),l.close()},"cleanup");s.stderr.setEncoding("utf8"),s.stderr.on("data",h=>{u+=h}),l.on("line",h=>{if(!(d!==void 0||h.length===0))try{let f=JSON.parse(h);if(f.type!=="match")return;if(r!==void 0){let{path:S,line_number:C}=f.data;S.text!==void 0&&Number.isSafeInteger(C)&&r(k.resolve(t,S.text),C);return}for(let S of me(f,t))a.push(S)}catch(f){d=f,s.kill()}}),s.once("error",h=>{p(),i(h)}),s.once("close",h=>{if(p(),n?.aborted===!0){let f=new Error("Search was aborted.");f.name="AbortError",i(f);return}if(d!==void 0){i(new Error("Unable to parse ripgrep search output.",{cause:d}));return}if(h!==0&&h!==1){i(new Error(u.trim()||`ripgrep exited with code ${String(h)}.`));return}a.sort(ge),o({matches:a,complete:!0})}),n?.addEventListener("abort",g,{once:!0}),n?.aborted===!0&&g()})}c(F,"runRipgrep");function fe(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}c(fe,"isPcre2MatchLimitError");function me(e,t){let n=e.data.path.text,r=e.data.lines.text;if(n===void 0||r===void 0||!Number.isSafeInteger(e.data.line_number))return[];let o=r.replace(/(?:\r\n|\n)$/u,""),i=Buffer.from(r),s=[];for(let l of e.data.submatches){if(l.start<0||l.end<=l.start||l.end>i.length)continue;let a=i.subarray(0,l.start).toString("utf8").length,u=i.subarray(0,l.end).toString("utf8").length;s.push({source:k.resolve(t,n),lineNumber:e.data.line_number,startColumn:a,endColumn:u,matchedText:o.slice(a,u),lineText:o})}return s}c(me,"matchesFromEvent");function U(e){if(e===void 0)return[];let t=[],n=0,r="";for(let o of e){if(o==="{"?n+=1:o==="}"&&(n=Math.max(0,n-1)),n===0&&(o===","||/\s/u.test(o))){r.length>0&&(t.push(r),r="");continue}r+=o}return r.length>0&&t.push(r),t}c(U,"splitGlobList");function pe(e){return e.startsWith("@")?e.slice(1):e}c(pe,"stripFilePrefix");function ge(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}c(ge,"compareMatches");function Je(e){let t=j(e.query),n=j(e.query,!0),r=z(e.query),o=[],i=L(e.query),s=L(e.query,!0);return(n!==t||JSON.stringify(i)!==JSON.stringify(s))&&o.push({query:n,mode:"regex",condition:s}),r!==void 0&&r!==t&&r!==n&&o.push({query:r,mode:"words"}),{...e,query:t,regex:!0,condition:i,fallbacks:o}}c(Je,"createSearchRecipe");async function _(e,t,n){let r=e.query,o=await M(e,t,n),i=[];for(let s of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;n?.throwIfAborted();try{o=await M({...e,query:s.query,regex:!0,condition:s.condition},t,n),r=s.query,i.push(s.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(l){if(s.mode!=="regex"||!Se(l)||n?.aborted)throw l;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:i}}c(_,"runSearchRecipe");function Se(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}c(Se,"isRegexSyntaxError");var be=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,ee=4;function Ye(e,t,n,r){return te(e,t,n,r).slice(0,ee)}c(Ye,"createSearchSessionId");function te(e,t,n,r){let o=n===void 0?ke(t.map(a=>a.source)):m.resolve(n),i=t.map(a=>({match:a,source:m.relative(o,m.resolve(a.source))})).sort((a,u)=>a.source.localeCompare(u.source)||J(a.match,u.match)).map(({match:a,source:u})=>[u,a.lineNumber,a.startColumn,a.endLineNumber??a.lineNumber,a.endColumn,a.matchedText,a.lineText]),{limit:s,...l}=ne(r??{query:e,regex:!0},o);return ye("sha256").update(JSON.stringify([e,o,l,i])).digest("hex").toUpperCase()}c(te,"createSearchSessionIdentity");function xe(e,t){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let n=ee;n<=e.length;n+=1){let r=e.slice(0,n);if(!t.has(r))return r}throw new Error("Could not allocate a unique search session id.")}c(xe,"allocateSearchSessionId");function ne(e,t){return{query:e.query,path:m.resolve(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??50,regex:e.regex===!0,condition:e.condition,fallbacks:e.fallbacks??[]}}c(ne,"normalizeRecipe");var $=class extends Error{static{c(this,"SearchSnapshotChangedError")}constructor(t){super(`Search result in ${t} changed before its anchors were registered.`),this.name="SearchSnapshotChangedError"}},V=class{constructor(t=te){this.createIdentity=t}static{c(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(t,n,r,o,i,s={query:t,regex:!0},l){let a=n.map(f=>({...f,source:m.resolve(f.source)})).sort(J),u=await Y(a,i),d=this.createIdentity(t,a,o,s),p=this.#r.get(d)??xe(d,new Set(this.#t.keys())),h={id:p,query:t,matches:a,complete:r,contentBySource:u,recipe:s,...l!==void 0&&{refresh:l},cwd:m.resolve(o)};return this.#r.set(d,p),this.#t.set(p,h),h}async registerIfCurrent(t,n,r,o,i,s,l){try{return await this.register(t,n,r,o,i,s,l)}catch(a){if(a instanceof $)return;throw a}}async observeAfterEdit(t,n){let r=new Set(t.flatMap(i=>{let s=typeof i=="string"?P(i):void 0;return s===void 0?[]:[s.id]})),o=[];for(let i of r){let s=this.#t.get(i);if(s===void 0)continue;let l={sessionId:i,query:s.recipe.originalQuery??s.query,scope:ne(s.recipe,s.cwd)};try{let a=s.refresh===void 0?await _(s.recipe,s.cwd,n):await s.refresh(n);o.push({...l,matches:a.matches.length,complete:a.complete,notices:a.notices})}catch(a){o.push({...l,error:a instanceof Error?a.message:String(a)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
|
|
2
|
+
`),renderFull(t){return t},renderCompact(t){let n=P(t);return n===void 0?"selected result":n.selector==="all"?n.mode==="match"?"all matches":"all lines":n.mode==="match"?`match ${String(n.selector)}`:`line ${String(n.selector)}`},tryResolve:c((t,n)=>this.#i(t,n.source,n.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:c((t,n)=>this.#s(t,n.cwd),"tryResolve")}}async#i(t,n,r){let o=P(t);if(o===void 0)return{kind:"not-handled"};let i=this.#t.get(o.id);if(i===void 0)return R();if(o.selector==="all"&&!i.complete)return x();let s=m.resolve(n),l=i;if(o.selector==="all"){if(i.refreshedComplete?.complete===!0)l=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&(l=await this.#n(i,r),!l.complete))return x()}let a=B(l,o.selector,o.mode),u=a.filter(p=>p.source===s);if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await D(s,r);if(d===void 0)return R(b(u[0]).lineNumber);if(o.selector==="all"&&d!==l.contentBySource.get(s)){if(l=await this.#n(i,r),!l.complete)return x();a=B(l,o.selector,o.mode),u=a.filter(p=>p.source===s)}if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==i.contentBySource.get(s))return R(b(u[0]).lineNumber);let g=w(s,d);return{kind:"resolved",anchor:new W(t,s,u.map(p=>X(g,p,o.mode)))}}async#s(t,n){let r=P(t);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return R();if(r.selector==="all"&&!o.complete)return x();let i=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)i=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(i=await this.#n(o),!i.complete))return x();let u=new Set(B(i,r.selector,r.mode).map(d=>d.source));for(let d of u)if(await D(d)!==i.contentBySource.get(d)){if(i=await this.#n(o),!i.complete)return x();break}}let s=B(i,r.selector,r.mode);if(r.selector!=="all"){let u=s[0]?.source;if(u!==void 0&&await D(u)!==i.contentBySource.get(u))return R(s[0]?.lineNumber)}let l=new Map;for(let u of s){let d=l.get(u.source)??[];d.push(X(w(u.source,i.contentBySource.get(u.source)??u.lineText),u,r.mode)),l.set(u.source,d)}let a=[...l].map(([u,d])=>({source:u,ranges:d,expectedContent:i.contentBySource.get(u)}));return a.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:a}}async#n(t,n){let r=t.refresh===void 0?await _(t.recipe,t.cwd,n):await t.refresh(n),o=r.matches.map(s=>({...s,source:m.resolve(s.source)})).sort(J),i={matches:o,complete:r.complete,contentBySource:await Y(o,n)};return this.#t.set(t.id,{...t,refreshedComplete:i}),i}};function P(e){let t=be.exec(e);if(t!==null)return{id:b(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}c(P,"parseSearchAnchor");function B(e,t,n){let r=t==="all"?e.matches:[e.matches[t-1]].filter(we);if(n==="match"||t!=="all")return r;let o=new Set;return r.flatMap(i=>{let s=w(i.source,e.contentBySource.get(i.source)??i.lineText),l=re(i);return s.lines.slice(i.lineNumber-1,l).flatMap(a=>{let u=`${i.source}\0${String(a.lineNumber)}`;return o.has(u)?[]:(o.add(u),[{...i,lineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:0,endColumn:a.content.length,lineText:a.content,matchedText:a.content}])})})}c(B,"selectMatches");function we(e){return e!==void 0}c(we,"isMatch");function re(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}c(re,"lastContainingLine");function X(e,t,n){if(n==="match")return{start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:t.endLineNumber??t.lineNumber,column:t.endColumn}};let r=re(t),o=b(e.lines[r-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:r+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}c(X,"selectionRange");function Te(e,t){let n=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,n).map(r=>{let o=r.lineNumber===t.lineNumber?t.startColumn:0,i=r.lineNumber===n?t.endColumn:r.content.length;return r.content.slice(o,i)+(r.lineNumber===n?"":r.lineEnding)}).join("")}c(Te,"matchedSourceText");async function Y(e,t){let n=[...new Set(e.map(i=>i.source))],r=await Promise.allSettled(n.map(async i=>{let s=await Z(i,{encoding:"utf8",...t!==void 0&&{signal:t}}),l=w(i,s);for(let a of e.filter(u=>u.source===i))if(l.lines[a.lineNumber-1]?.content!==a.lineText||Te(l,a)!==a.matchedText)throw new $(i);return[i,s]})),o=new Map;for(let i of r){if(i.status==="rejected")throw i.reason;o.set(...i.value)}return o}c(Y,"snapshotContents");async function D(e,t){try{return await Z(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}catch{return}}c(D,"readCurrent");function R(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}c(R,"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 ke(e){if(e.length===0)return".";let t=m.dirname(m.resolve(b(e[0])));for(let n of e.slice(1)){let r=m.resolve(n);for(;!Re(t,r);){let o=m.dirname(t);if(o===t)return t;t=o}}return t}c(ke,"commonSourceDirectory");function Re(e,t){let n=m.relative(e,t);return n!==".."&&!n.startsWith(`..${m.sep}`)&&!m.isAbsolute(n)}c(Re,"isWithin");function J(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||(e.endLineNumber??e.lineNumber)-(t.endLineNumber??t.lineNumber)||e.endColumn-t.endColumn}c(J,"compareMatches");export{Q as a,Je as b,_ as c,Ye as d,te as e,xe as f,$ as g,V as h};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";import{Value as C}from"typebox/value";var f=Symbol.for("pi-agent-text/TextAnchor"),u=class{constructor(n,r){this.value=n;this.lineNumber=r;if(n.length===0)throw new TypeError("Text anchor value must be non-empty");if(!Number.isSafeInteger(r)||r<1)throw new RangeError("Text anchor line number must be a positive safe integer")}static{o(this,"TextAnchor")}[f]=!0;static is(n){if(typeof n!="object"||n===null)return!1;try{let r=n;return r[f]===!0&&typeof r.value=="string"&&Number.isSafeInteger(r.lineNumber)&&r.lineNumber>=1}catch{return!1}}toString(){return this.value}},x=new WeakMap;function w(e,n,r){x.set(e,{renderer:n,resolverId:r})}o(w,"attachTextAnchorRenderer");function S(e){return x.get(e)?.renderer}o(S,"getTextAnchorRenderer");function P(e,n,r){let i=x.get(e);if(i===void 0)throw new Error(`No renderer is attached to text anchor "${n}"`);return{...i.renderer,resolverId:i.resolverId,full:i.renderer.renderFull(n,r),compact:i.renderer.renderCompact(n,r)}}o(P,"renderTextAnchor");var c={additionalProperties:!0},l=t.Function([],t.Unknown()),g=t.Object({lineNumber:t.Integer({minimum:1}),column:t.Integer({minimum:0})},c),j=t.Object({rank:t.Integer({minimum:1}),range:t.Object({start:g,end:g},c)},c),L=t.Object({id:t.String({minLength:1}),description:t.Union([t.String(),l]),normalize:t.Optional(l),renderFull:l,renderCompact:l,tryResolve:l,recover:t.Optional(l)},c),O=t.Object({code:t.Union([t.Literal("invalid"),t.Literal("stale"),t.Literal("missing"),t.Literal("ambiguous")]),reason:t.String(),contextRange:t.Optional(t.Object({offset:t.Number(),limit:t.Number()}))}),E=t.Union([t.Object({kind:t.Literal("not-handled")},c),t.Object({kind:t.Literal("resolved"),anchor:t.Unknown()},c),t.Object({kind:t.Literal("rejected"),rejection:O},c),t.Object({kind:t.Literal("failed"),error:t.Unknown()},c)]),N=t.Union([t.Object({kind:t.Literal("unavailable")},c),t.Object({kind:t.Literal("candidates"),candidates:t.Array(j),total:t.Integer({minimum:0})},c),t.Object({kind:t.Literal("timed-out")},c),t.Object({kind:t.Literal("failed"),error:t.Unknown()},c)]);function D(e){return p(L,e)&&y(()=>e.id.trim().length>0)}o(D,"isTextAnchorResolver");function I(e){return p(E,e)&&y(()=>{let n=e;return n.kind!=="resolved"||u.is(n.anchor)})}o(I,"isTextAnchorResolutionAttempt");function M(e){return p(N,e)}o(M,"isTextAnchorRecoveryOutcome");function p(e,n){return y(()=>C.Check(e,n))}o(p,"safeCheck");function y(e){try{return e()}catch{return!1}}o(y,"safeEvaluate");function T(e){if(!e.some(i=>i.marker!==void 0))return e.map(i=>`${i.prefix??""}${i.content}${i.suffix??""}`);let r=Math.max(0,...e.map(i=>i.prefix?.length??0));return e.map(i=>`${i.marker??" "}|${(i.prefix??"").padStart(r," ")}${i.content}${i.suffix??""}`)}o(T,"renderPresentedTextRows");var h="pi-agent-text/source-line";function $(e){let n=e.metadata?.[h];if(F(n))return n}o($,"getTextSourceLine");function U(e,n){return{...e,metadata:{...e.metadata,[h]:n}}}o(U,"withTextSourceLine");function F(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.source=="string"&&n.source.length>0&&typeof n.lineNumber=="number"&&Number.isInteger(n.lineNumber)&&n.lineNumber>0&&typeof n.content=="string"}o(F,"isTextSourceLine");import{Type as d}from"typebox";import{Value as W}from"typebox/value";var q=d.Function([],d.Unknown()),R=d.Object({id:d.String({minLength:1}),present:q}),B=d.Object({presenter:R,priority:d.Optional(d.Number())});function V(e){return A(R,e)}o(V,"isTextLinePresenter");function _(e){return A(B,e)}o(_,"isTextPresenterRegistration");function z(e,n){return{source:e,content:n,lines:H(n)}}o(z,"createTextDocument");function K(e){return e.lines.map(n=>`${n.content}${n.lineEnding}`).join("")}o(K,"renderTextDocument");function Y(e,n={}){let r=e.lines.flatMap(s=>[...s.presentation?.before??[],G(s,n.compact===!0),...s.presentation?.after??[]]),i=T(r),a=0;return e.lines.map(s=>{let m=1+(s.presentation?.before?.length??0)+(s.presentation?.after?.length??0),k=i.slice(a,a+m).join(`
|
|
2
|
+
`);return a+=m,`${k}${s.lineEnding}`}).join("")}o(Y,"renderPresentedTextDocument");function G(e,n){let r=n&&e.presentation?.compactPrefix!==void 0?e.presentation.compactPrefix:e.presentation?.prefix,i=n&&e.presentation?.compactSuffix!==void 0?e.presentation.compactSuffix:e.presentation?.suffix;return{content:e.content,...r!==void 0&&{prefix:r},...i!==void 0&&{suffix:i},...e.presentation?.marker!==void 0&&{marker:e.presentation.marker}}}o(G,"presentedRowFor");function H(e){if(e.length===0)return[];let n=[],r=/\r\n|\r|\n/gu,i=0,a;for(;(a=r.exec(e))!==null;)n.push({lineNumber:n.length+1,content:e.slice(i,a.index),lineEnding:a[0]}),i=a.index+a[0].length;return i<e.length&&n.push({lineNumber:n.length+1,content:e.slice(i),lineEnding:""}),n}o(H,"splitTextLines");function A(e,n){try{return W.Check(e,n)}catch{return!1}}o(A,"safeCheck");var J=new Set(["application/ecmascript","application/graphql","application/javascript","application/json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-ndjson","application/x-www-form-urlencoded","application/x-yaml","application/xml","application/yaml"]);function Q(){return{id:"text",description:"Text file paths and URLs return their text.",tryConvert(e,n){return Promise.resolve(X(e,n))}}}o(Q,"createTextContentConverter");function X(e,n){let r=ee(n.signal);if(r!==void 0)return{kind:"failed",error:r};try{return{kind:"converted",content:[{type:"text",text:new TextDecoder("utf8",{fatal:!0}).decode(e.bytes)}]}}catch(i){return b(e.mediaType)?{kind:"failed",error:new TypeError(`${e.source} is not valid UTF-8 text`,{cause:i})}:{kind:"not-handled"}}}o(X,"convertText");function b(e){if(e===void 0)return!1;let n=e.split(";",1)[0]?.trim().toLowerCase()??"";return n.startsWith("text/")||J.has(n)||n.endsWith("+json")||n.endsWith("+xml")}o(b,"isTextualMediaType");function Z(e){let n=e[0];if(e.length!==1||n.type!=="text")throw new TypeError("Text resources require exactly one text block");return n.text}o(Z,"textFromAgentContent");function ee(e){if(e?.aborted===!0)return e.reason instanceof Error?e.reason:ne()}o(ee,"cancellationError");function ne(){let e=new Error("The operation was aborted");return e.name="AbortError",e}o(ne,"abortError");function te(e){if(e===null||typeof e!="object")return!1;let n=e;if(n.kind==="not-handled")return!0;if(n.kind==="failed")return"error"in n;if(n.kind==="rejected"){let r=n.rejection;return r!==null&&typeof r=="object"&&["invalid","stale","missing","ambiguous"].includes(r.code)&&typeof r.reason=="string"}return n.kind!=="resolved"||!Array.isArray(n.targets)||n.targets.length===0?!1:n.targets.every(r=>{if(r===null||typeof r!="object")return!1;let i=r.source,a=r.ranges;return typeof i=="string"&&i.length>0&&(r.expectedContent===void 0||typeof r.expectedContent=="string")&&(a===void 0||Array.isArray(a)&&a.every(re))})}o(te,"isTextTargetResolutionAttempt");function re(e){if(e===null||typeof e!="object")return!1;let n=e;return v(n.start)&&v(n.end)&&(n.linewise===void 0||typeof n.linewise=="boolean")}o(re,"isTextSelectionRange");function v(e){if(e===null||typeof e!="object")return!1;let n=e;return Number.isInteger(n.lineNumber)&&n.lineNumber>=1&&Number.isInteger(n.column)&&n.column>=0}o(v,"isTextSelectionPosition");function oe(e,n){if(e.length<16)return e;let r=n.indexOf(e);return r<0?e:[r,e.length]}o(oe,"storeText");function ie(e,n){return typeof e=="string"?e:n.slice(e[0],e[0]+e[1])}o(ie,"restoreText");export{u as a,w as b,S as c,P as d,D as e,I as f,M as g,T as h,$ as i,U as j,V as k,_ as l,z as m,K as n,Y as o,Q as p,b as q,Z as r,te as s,oe as t,ie as u};
|
package/dist/entry-0.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{h as addDiagnosticAnnotations,g as createDiagnosticViewContent,l as createSourceMappedTextReadHandler,i as diagnosticStatus,c as formatCodeViewReference,f as formatDiagnosticViewSource,k as formatSourceViewResults,d as formatSymbolSelector,a as parseCodeViewReference,j as renderSourceViewLine,b as resolveCodeViewPath,e as resolveDiagnosticViewPath};
|
package/dist/entry-11.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-IQD6PON5.js";import"./chunk-
|
|
1
|
+
import"./chunk-IQD6PON5.js";import"./chunk-VBICI5YA.js";import{a as l}from"./chunk-FBOW7XOV.js";import{a as s,b as c}from"./chunk-WJTHY6AG.js";import"./chunk-U2JKHKLK.js";import"./chunk-FZBCKIJJ.js";import"./chunk-NNCZYO4Q.js";import"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import{a as g}from"./chunk-6CZO43OH.js";import{a as f,b as y}from"./chunk-OBNING2A.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function x(n,e){return u(e),g(n,{protocol:f,apiVersion:y,id:`hook/before-read/${e.id}`,setup(t){t.addResourceGuard({id:e.id,async guard(o){let r=await e.run(o);return r.decision==="allow"?{kind:"accepted"}:{kind:"rejected",reason:r.reason}}})}})}d(x,"connectBeforeReadHook");function A(n,e){return u(e),l(n,{protocol:s,apiVersion:c,id:`hook/before-edit/${e.id}`,setup(t){t.addMutationGuard({id:e.id,async guard(o,r){let a=await e.run({cwd:r.cwd,intent:r.intent??"edit",resources:o.resources.map(i=>({resourceSource:i.source,existed:i.existed,before:i.before,after:i.after,changes:i.changes})),...r.signal!==void 0&&{signal:r.signal}});return a.decision==="allow"?{kind:"accepted"}:{kind:"rejected",rejection:{code:"MUTATION_REJECTED",reason:a.reason,message:`Edit blocked by hook ${e.id}: ${a.reason}`,effect:"not-applied"}}}})}})}d(A,"connectBeforeEditHook");function m(n,e){return u(e),l(n,{protocol:s,apiVersion:c,id:`hook/after-edit/${e.id}`,setup(t){t.onDidEdit(async o=>{if(o.postProcessing!=="deferred")try{return await e.run(o)}catch(r){return{feedback:`After-edit hook ${e.id} failed after the edit was saved: ${r instanceof Error?r.message:String(r)}`,tone:"error"}}})}})}d(m,"connectAfterEditHook");function u(n){if(n.id.trim().length===0||typeof n.run!="function")throw new TypeError("A file hook needs a non-empty id and run function")}d(u,"assertHook");export{m as connectAfterEditHook,A as connectBeforeEditHook,x as connectBeforeReadHook};
|
package/dist/entry-13.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-U2JKHKLK.js";import{a as k,b as l,c as m,d as n,e as o,f as p,g as q}from"./chunk-
|
|
1
|
+
import"./chunk-U2JKHKLK.js";import{a as k,b as l,c as m,d as n,e as o,f as p,g as q,h as r,i as s,j as t}from"./chunk-FZBCKIJJ.js";import"./chunk-NNCZYO4Q.js";import{b as i,d as j}from"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import{a as h}from"./chunk-6CZO43OH.js";import{a,b,c,d,e,f,g}from"./chunk-OBNING2A.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{i as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,j as createReadResultRenderer,s as isFragmentResolverRegistration,e as isReadCoreReady,t as isReadFragmentResolution,q as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,r as isReadViewRegistration,p as isResourceResolverRegistration,o as isTextTargetResolverRegistration,l as readDataSchema,m as readOutputSchema,k as readParameters,n as structuredRead};
|
package/dist/entry-14.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u}from"./chunk-
|
|
1
|
+
import{A,B,C,D,E,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-2P2OGO3G.js";import"./chunk-EI7MMDWY.js";export{y as CONTENT_API_VERSION,A as CONTENT_CONVERTER_REGISTER_EVENT,z as CONTENT_HOST_READY_EVENT,w as CONTENT_PROTOCOL,p as MAX_STRUCTURED_BYTES,o as ResourceScheduler,s as UnsupportedContentError,t as assertJsonData,E as connectContentConverter,D as createContentHost,u as createContentRunner,c as isAgentContent,n as isContentConversionAttempt,k as isContentConversionContext,l as isContentConverter,q as isContentConverterRegistration,C as isContentConverterRegistrationRequest,B as isContentHostReady,j as isContentInput,i as isContentTarget,d as isResource,h as isResourceResolutionAttempt,g as isResourceResolver,b as renderContentDescription,e as resourceAccesses,r as resourceScheduler,x as resultError,f as resultErrorSchema,m as structuredResultSchema,v as targetsEqual,a as withStructuredResult};
|
package/dist/entry-15.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-F7NVAC4Q.js";import{a,b,c,d}from"./chunk-MIZAFRDR.js";import{a as x}from"./chunk-ZTYWHL2F.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-7UGNGK7Y.js";import"./chunk-2P2OGO3G.js";import"./chunk-EI7MMDWY.js";export{r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,x as connectSearchPlugin,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,b as searchDataSchema,c as searchOutputSchema,a as searchSchema,d as selectionData};
|
package/dist/entry-16.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
|
package/dist/entry-17.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-IQD6PON5.js";import{m as o}from"./chunk-
|
|
1
|
+
import"./chunk-IQD6PON5.js";import{m as o}from"./chunk-VBICI5YA.js";import{a as n}from"./chunk-FBOW7XOV.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-WJTHY6AG.js";import"./chunk-2P2OGO3G.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{b as TEXT_EDITOR_API_VERSION,e as TEXT_EDITOR_CORE_READY_EVENT,f as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,a as TEXT_EDITOR_PROTOCOL,c as TEXT_POSITION_ANCHOR_KIND,d as TEXT_SEARCH_ANCHOR_KIND,n as connectTextEditorPlugin,o as connectTextEditorPostEditHandler,h as isResourceResolverRegistration,i as isTextAnchorResolverRegistration,j as isTextAnchorResourceResolutionAttempt,k as isTextEditorCoreReady,l as isTextEditorPlugin,m as isTextEditorPluginRegistrationRequest,g as isTextEditorToolId};
|
package/dist/entry-25.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)}]}
|
|
1
|
+
import{a as k}from"./chunk-FBOW7XOV.js";import{a as A,b as D}from"./chunk-WJTHY6AG.js";import"./chunk-NNCZYO4Q.js";import{d as T}from"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import{a as P}from"./chunk-6CZO43OH.js";import{a as F,b as C}from"./chunk-OBNING2A.js";import{D as v,j as E}from"./chunk-2P2OGO3G.js";import{r as b}from"./chunk-ZPT5D4VP.js";import{a as p}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{readdirSync as V,realpathSync as j,statSync as U}from"node:fs";import{mkdir as $,readFile as z,writeFile as Z}from"node:fs/promises";import I from"node:path";import{fileURLToPath as B,pathToFileURL as G}from"node:url";function O(e){return _("read",e)}s(O,"createFilesystemReadResolver");function S(e){return _("write",e)}s(S,"createFilesystemWriteResolver");function _(e,t){return{id:"filesystem",tryResolve(r,n){return Promise.resolve(X(r,n,e,t))}}}s(_,"createFilesystemResolver");function X(e,t,r,n){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!K(e))return{kind:"not-handled"};if(t.signal?.aborted===!0)return{kind:"failed",error:x()};let o=e.startsWith("file://")?j(B(new URL(e))):I.resolve(t.cwd,e),i=G(o).href,d=(()=>{try{return U(o).isDirectory()}catch{return!1}})(),u=s(async({signal:f})=>d?q(o,f):J(o,n,f),"read");return r==="read"||d?{kind:"resolved",resource:{source:o,link:i,read:u}}:{kind:"resolved",resource:{source:o,link:i,read:u,async write(f,m){y(m.signal);let h=b(f);await $(I.dirname(o),{recursive:!0}),y(m.signal),await Z(o,h,{encoding:"utf8",...m.signal!==void 0&&{signal:m.signal}})}}}}s(X,"resolveFilesystemSource");function q(e,t){y(t);let r=V(e,{withFileTypes:!0}),n=[`\u{1F4C1} ${e}/`];r.length>0&&n.push("");for(let o of r){let i=o.isDirectory()?"\u{1F4C1}":o.isFile()?"\u{1F4C4}":"\u{1F517}";n.push(` ${i} ${o.name}`)}return[{type:"text",text:n.join(`
|
|
2
|
+
`)}]}s(q,"readDirectoryContent");async function J(e,t,r){y(r);let n=await z(e,{encoding:null,...r!==void 0&&{signal:r}});return y(r),t.convert({source:e,bytes:n},r===void 0?{}:{signal:r})}s(J,"readFilesystemContent");function K(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}s(K,"isFilesystemSource");function y(e){if(e?.aborted===!0)throw x()}s(y,"throwIfAborted");function x(){let e=new Error("The operation was aborted");return e.name="AbortError",e}s(x,"abortError");import{execFile as Q}from"node:child_process";import{existsSync as Y}from"node:fs";import{realpath as H}from"node:fs/promises";import ee from"node:os";import c from"node:path";import{fileURLToPath as te}from"node:url";async function L(e,t){let r=e.cause,n=Date.now()+500;if(t.signal?.aborted||e.source===void 0||typeof r!="object"||r===null||!("code"in r)||r.code!=="ENOENT")return;let o=e.source.startsWith("file://")?te(e.source):e.source,i=c.relative(t.cwd,c.resolve(t.cwd,o));if(!w(i)||i.includes("#"))return;let d=c.basename(i).toLowerCase();if(d.length<3||d.length>160)return;let u=c.join(process.env.PI_CODING_AGENT_DIR??c.join(ee.homedir(),".pi","agent"),"bin",process.platform==="win32"?"rg.exe":"rg"),f=await new Promise(a=>{Q(Y(u)?u:"rg",["--files","--hidden","--no-config","--no-ignore-parent","--null","--glob","!.git/**"],{cwd:t.cwd,timeout:250,maxBuffer:2*1024*1024,...t.signal===void 0?{}:{signal:t.signal}},(l,R)=>a(l?[]:R.split("\0").filter(Boolean).slice(0,2e4)))}),m=Math.min(3,Math.max(1,Math.floor(d.length*.2))),h=f.flatMap(a=>{if(t.signal?.aborted||Date.now()>n||!w(a))return[];let l=c.basename(a).toLowerCase();if(l.length>160||Math.abs(l.length-d.length)>m)return[];let R=re(d,l);if(R>m)return[];let M=c.dirname(i).toLowerCase(),W=c.dirname(a).toLowerCase();return[{path:a,distance:R,directoryDistance:M===W?0:1}]}).sort((a,l)=>a.distance-l.distance||a.directoryDistance-l.directoryDistance||a.path.localeCompare(l.path)),g=[],N=await H(t.cwd);for(let a of h.slice(0,20)){if(t.signal?.aborted||Date.now()>n)return;try{let l=await H(c.resolve(t.cwd,a.path));w(c.relative(N,l))&&g.push({path:a.path})}catch{}if(g.length===3)break}return g.length?g:void 0}s(L,"recoverFilesystemPath");function w(e){return e!==""&&!/^\.\.(?:[\\/]|$)/u.test(e)&&!c.isAbsolute(e)}s(w,"insideWorkspace");function re(e,t){let r=Array.from({length:t.length+1},(n,o)=>o);for(let n=1;n<=e.length;n++){let o=[n];for(let i=1;i<=t.length;i++)o[i]=Math.min(p(o[i-1])+1,p(r[i])+1,p(r[i-1])+(e[n-1]===t[i-1]?0:1));r=o}return p(r[t.length])}s(re,"editDistance");var oe={provider:"filesystem",capability:"read"},ne={provider:"filesystem",capability:"write"},ie=T({kind:"source",nativeResources:!0});async function se(e){let t=v(e,oe),r=v(e,ne),n=O(t),o=S(r),i={protocol:F,apiVersion:C,id:"filesystem",setup(u){u.addResolver({resolver:n,renderResult:ie,recoverFailure:L}),u.describe(()=>E("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",t.listDescriptions()))}},d={protocol:A,apiVersion:D,id:"filesystem",setup(u){u.addResolver({resolver:o})}};await Promise.all([P(e,i),k(e,d)])}s(se,"registerFilesystemPlugin");export{se as default};
|
package/dist/entry-26.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./chunk-QIJMV2P2.js";import{
|
|
1
|
+
import{a as r}from"./chunk-QIJMV2P2.js";import{E as e}from"./chunk-2P2OGO3G.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
|
package/dist/entry-27.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as P,f as x}from"./chunk-T7I2VX3J.js";import{a as T}from"./chunk-MGCHOGQD.js";import{a as E,b as h}from"./chunk-T6LX2RX5.js";import{a as S}from"./chunk-6CZO43OH.js";import{a as R,b as O}from"./chunk-OBNING2A.js";import{m as q}from"./chunk-
|
|
1
|
+
import{e as P,f as x}from"./chunk-T7I2VX3J.js";import{a as T}from"./chunk-MGCHOGQD.js";import{a as E,b as h}from"./chunk-T6LX2RX5.js";import{a as S}from"./chunk-6CZO43OH.js";import{a as R,b as O}from"./chunk-OBNING2A.js";import{m as q}from"./chunk-ZPT5D4VP.js";import{c as j,d as v,e as y}from"./chunk-N34ATN52.js";import{a as o}from"./chunk-EI7MMDWY.js";import C from"cross-spawn";import{fileURLToPath as L}from"node:url";var b=5e3,J=10*1024*1024,k=L(new URL(".",new URL("../src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts",import.meta.url).href));function _(r){let e=r?.filter(i=>i==="jq"||i.startsWith("jq:"))??[];if(e.length===0)return;if(e.length>1)throw new Error("Read accepts only one jq view");if(r?.length!==1)throw new Error("The jq view cannot be combined with other views");let t=e[0];if(t===void 0||t==="jq"||t.slice(3).trim().length===0)throw new Error('The jq view requires a filter, for example views: ["jq:.scripts"]');return{filter:t.slice(3)}}o(_,"parseJqView");function A(r,e,t){return t.signal?.aborted===!0?Promise.reject(new Error("jq execution was cancelled")):new Promise((i,d)=>{let s=C(t.command??"jq",["-L",k,"--",r],{cwd:t.cwd,env:V(t.cwd),shell:!1,stdio:["pipe","pipe","pipe"],windowsHide:!0}),a="",l="",u=!1,m=0,c=o(n=>{u||(u=!0,clearTimeout(p),t.signal?.removeEventListener("abort",g),n===void 0?i(a):d(n))},"finish"),f=o(n=>{s.kill(),c(n)},"stop"),g=o(()=>f(new Error("jq execution was cancelled")),"abort"),p=setTimeout(()=>f(new Error(`jq did not finish within ${b/1e3} seconds`)),b);p.unref(),t.signal?.addEventListener("abort",g,{once:!0}),s.stdout?.setEncoding("utf8"),s.stderr?.setEncoding("utf8"),s.stdout?.on("data",n=>{if(m+=Buffer.byteLength(n),m>J){f(new Error(`jq output exceeded ${J/1024/1024}MB`));return}a+=n}),s.stderr?.on("data",n=>{Buffer.byteLength(l)<16384&&(l+=n)}),s.once("error",n=>c(new Error(`Cannot start jq: ${n.message}`))),s.once("close",(n,w)=>{if(!u)if(n===0)c();else{let I=l.trim().split(/\r?\n/u).slice(0,8).join(`
|
|
2
2
|
`);c(new Error(I||`jq exited ${w===null?`with code ${String(n)}`:`after signal ${w}`}`))}}),s.stdin?.once("error",n=>c(new Error(`Cannot send JSON to jq: ${n.message}`))),s.stdin?.end(e)})}o(A,"executeJq");function V(r){let e=j(r,process.env),t={};for(let i of["PATH","PATHEXT","SystemRoot","SYSTEMROOT","WINDIR"])e[i]!==void 0&&(t[i]=e[i]);return t}o(V,"safeEnvironment");async function N(r){x(r,[await P({id:"json-reading",description:"Query and transform JSON resources with jq read views",triggers:[{tool:"read",viewPrefixes:["jq:"]}]})]),await Promise.all([S(r,B),T(r,$)])}o(N,"registerFilesystemJq");var B={protocol:R,apiVersion:O,id:"filesystem-jq",setup(r){r.addView({view:"jq",presenter:{id:"filesystem-jq",present:o(e=>e,"present")}}),r.addHandler({stage:"read",when:{resolvedBy:"filesystem",contentKind:"text"},async handler(e){let t=e.state;if(t?.contentKind!=="text")return{kind:"continue",context:e};let i;try{i=_(e.request.views)}catch(a){return D(t,a instanceof Error?a.message:String(a))}if(i===void 0)return{kind:"continue",context:e};let d;try{d=await A(i.filter,t.content[0].text,{cwd:e.resolverContext.cwd,...e.resolverContext.signal===void 0?{}:{signal:e.resolverContext.signal}})}catch(a){return D(t,a instanceof Error?a.message:String(a))}let s={...t,content:[{type:"text",text:d}],text:q(t.source,d),preserveTruncatedOutput:!0};return{kind:"continue",context:{...e,state:s}}}}),r.describe('JSON files accept views such as ["jq:.scripts | keys"] to query them with the installed jq executable.')}};function D(r,e){return{kind:"return",result:{content:[{type:"text",text:`jq failed: ${e}`}],details:{source:r.source,resolvedBy:r.resolvedBy,failure:{code:"READ_FAILED",source:r.source,resolverId:r.resolvedBy,pluginId:"filesystem-jq",stage:"read",message:e}},isError:!0}}}o(D,"jqFailure");var $={protocol:E,apiVersion:1,id:"filesystem-jq",setup(r){r.addSetupCheck({id:"jq",async inspect(e){return await v("jq",e.cwd,e.env)?{}:{actions:[{id:"jq-unavailable",message:"JSON jq views are unavailable because jq was not found"}]}}}),r.addCheck({id:"jq",title:"JSON jq views",async run(e){let t=await y("jq",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"jq is available",detail:t.detail}:{status:"fail",message:"jq is not available",detail:t.detail}]}})}};export{N as default};
|
package/dist/entry-28.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./chunk-BHSO2MDK.js";import{
|
|
1
|
+
import{a as r}from"./chunk-BHSO2MDK.js";import{E as e}from"./chunk-2P2OGO3G.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
|
package/dist/entry-29.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{E as t}from"./chunk-2P2OGO3G.js";import{p as i}from"./chunk-ZPT5D4VP.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
|
package/dist/entry-30.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,c as o}from"./chunk-
|
|
1
|
+
import{b as e,c as o}from"./chunk-FUG2TEKI.js";import"./chunk-ZPT5D4VP.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};
|
package/dist/entry-31.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as V}from"./chunk-PJPA5EEE.js";import"./chunk-7WCZOO5I.js";import{b as F,c as G}from"./chunk-FUG2TEKI.js";import{a as E}from"./chunk-MGCHOGQD.js";import{a as L,b as O}from"./chunk-T6LX2RX5.js";import{a as D}from"./chunk-FBOW7XOV.js";import{a as $,b as C,c as N}from"./chunk-WJTHY6AG.js";import"./chunk-NNCZYO4Q.js";import{d as I}from"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import{a as M}from"./chunk-6CZO43OH.js";import{a as P,b as k}from"./chunk-OBNING2A.js";import"./chunk-F7NVAC4Q.js";import{d as B}from"./chunk-MIZAFRDR.js";import{a as j}from"./chunk-ZTYWHL2F.js";import{a as _,b as H}from"./chunk-7UGNGK7Y.js";import"./chunk-2P2OGO3G.js";import{a as R,b,c as w,l as v}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import"./chunk-KINKBPPX.js";import{j as T}from"./chunk-M5MJP7Z2.js";import"./chunk-WZI4YC2O.js";import{e as x}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import{readFile as ae}from"node:fs/promises";var oe={cmake:"no compatible Tree-sitter parser is packaged",dockerfile:"no compatible Tree-sitter parser is packaged",julia:"no compatible Tree-sitter parser is packaged",powershell:"no compatible Tree-sitter parser is packaged",r:"no compatible Tree-sitter parser is packaged",svelte:"the container grammar is not available as an ast-grep language package",terraform:"the HCL grammar is not available as an ast-grep language package",vue:"the container grammar is not available as an ast-grep language package",xml:"no compatible Tree-sitter parser is packaged",zig:"no compatible Tree-sitter parser is packaged"},y=new Set(["c","cpp","csharp","css","dart","elixir","go","html","java","kotlin","lua","markdown","php","ruby","scala","shell","sql","swift","javascript","typescript","python","rust","json","yaml","toml"]),z={protocol:L,apiVersion:1,id:"ast",setup(a){a.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(r=>y.has(r))?await T({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),a.addCheck({id:"parsers",title:"AST",async run(e){let t=[];for(let r of e.detectedLanguageIds){let n=oe[r];if(n!==void 0){t.push({status:"skip",message:`${r} AST is unavailable: ${n}`});continue}if(!y.has(r))continue;let s=e.files.find(o=>ie(o,r));if(s!==void 0)try{let o=await ae(s,"utf8"),i=await F(s,e.cwd,o.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`).split(`
|
|
4
|
-
`));
|
|
5
|
-
`),"format");e.signal?.throwIfAborted();let p=await new c(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!
|
|
6
|
-
`,o=
|
|
7
|
-
`);c.at(-1)===""&&c.pop();let
|
|
8
|
-
`)}],details:
|
|
9
|
-
`).length;return{source:s,lineNumber:p,endLineNumber:
|
|
10
|
-
`).length,startColumn:
|
|
11
|
-
`)-1,endColumn:
|
|
12
|
-
`)-1,matchedText:
|
|
13
|
-
`)[p-1]?.replace(/\r$/u,"")??""}})}l(
|
|
4
|
+
`));t.push(i===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:s})}catch(o){t.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return t.length>0?t:[{status:"skip",message:"No supported AST files found"}]}}),a.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>y.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let t=await x("ast-grep",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"ast-grep is available",detail:t.detail}:{status:"fail",message:"ast-grep is not available",detail:t.detail}]}})}};function ie(a,e){let t=a.slice(a.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],csharp:[".cs"],css:[".css",".scss",".less"],dart:[".dart"],elixir:[".ex",".exs"],go:[".go"],html:[".html",".htm"],java:[".java"],kotlin:[".kt",".kts"],lua:[".lua"],markdown:[".md",".mdx"],php:[".php"],ruby:[".rb",".rake"],scala:[".scala",".sc"],shell:[".sh",".bash"],sql:[".sql"],swift:[".swift"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(t)??!1}l(ie,"matchesLanguage");var ce,le;function U(a){return{id:"ast",tryResolve(e,t){return Promise.resolve(de(e,t,a))}}}l(U,"createAstOutlineResolver");function de(a,e,t){let r;try{r=R(a,"ast")}catch(o){return{kind:"failed",error:o}}if(r===void 0)return{kind:"not-handled"};let n;try{n=b(r.path,e.cwd)}catch(o){return{kind:"failed",error:o}}return{kind:"resolved",resource:{source:w("ast",n),async read({signal:o}){o?.throwIfAborted();let i=await(le??=import("./chunk-3BBJZSMS.js")),u=await(t??(ce??=new i.AstOutlineManager)).readFileOutline(n,e.cwd);return o?.throwIfAborted(),[i.formatAstOutline(u)]}}}}l(de,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ue,DEFAULT_MAX_LINES as pe,truncateHead as S}from"@earendil-works/pi-coding-agent";var A=l(async(a,e,t)=>{let{source:r,resolvedBy:n,lines:s,totalLines:o,startLine:i}=a.details;if(!(r===void 0||n!=="filesystem"||s===void 0||s.length!==o||i!==void 0&&i!==1))try{let{AstOutlineManager:c,isSupportedOutlinePath:u}=await import("./chunk-3BBJZSMS.js");if(!u(r))return;let d=l(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
|
|
5
|
+
`),"format");e.signal?.throwIfAborted();let p=await new c(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!S(d(m),t).truncated)),f=d(p);return S(f,t).truncated?void 0:{script:a.script,content:[{type:"text",text:f}],details:{source:r,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function X(){return async a=>{let{state:e,result:t}=a,r=t?.content.length===1?t.content[0]:void 0;if(a.audience==="script"||t===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||r?.type!=="text"||!S(r.text).truncated)return{kind:"continue",context:a};let n=await A({...t,details:{...t.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},a.resolverContext,{maxBytes:ue,maxLines:pe});return n===void 0?{kind:"continue",context:a}:{kind:"return",result:n}}}l(X,"createAstOverflowHandler");var K="pi-agent-ast";function W(a){return{id:"ast-scopes",async present(e,t){if(t.resolvedBy!=="filesystem")return e;try{let r=await a.getDocumentScopes(e.source,t.cwd,e.lines.map(s=>s.content)),n=fe(e.lines,r);return n===e.lines?e:{...e,lines:n}}catch{return e}}}}l(W,"createAstScopePresenter");function q(){return a=>{let e=a.state,t=a.result;if(e?.contentKind!=="text"||t===void 0)return{kind:"continue",context:a};let r=t.details.lines;if(r===void 0)return{kind:"continue",context:a};let n=new Map(e.text.lines.map(d=>[d.lineNumber,d])),s=new Set(r.map(d=>d.lineNumber)),o=new Map;for(let d of r){let p=n.get(d.lineNumber),f=J(p);for(let m of f?.boundaries??[]){if(s.has(m.endLine))continue;let g=n.get(m.endLine);g!==void 0&&o.set(m.endLine,g)}}if(o.size===0)return{kind:"continue",context:a};let i=[...o.values()].sort((d,p)=>d.lineNumber-p.lineNumber),c=[...r,...i],u=r.at(-1);return{kind:"continue",context:a,transform:l(d=>me(d,c,u),"transform")}}}l(q,"createAstScopePostReadHandler");function fe(a,e){if(e.length===0)return a;let t=new Map,r=new Map;for(let n of e){let s=t.get(n.startLine)??[];s.push(n.beginAnchor.value),t.set(n.startLine,s);let o=r.get(n.startLine)??[];o.push({endLine:n.endLine,beginAnchor:n.beginAnchor.value,endAnchor:n.endScopeAnchor.value}),r.set(n.startLine,o);let i=t.get(n.endLine)??[];i.push(n.endScopeAnchor.value),t.set(n.endLine,i)}return a.map(n=>{let s=t.get(n.lineNumber),o=r.get(n.lineNumber);return s===void 0&&o===void 0?n:{...n,...s!==void 0&&{anchors:[...new Set([...n.anchors??[],...s])],presentation:{...n.presentation,suffix:`${n.presentation?.suffix??""}${s.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...n.metadata,[K]:{...J(n),...o!==void 0&&{boundaries:o}}}}})}l(fe,"addScopeMarkers");function J(a){let e=a?.metadata?.[K];if(!(typeof e!="object"||e===null))return e}l(J,"getAstScopeMetadata");function me(a,e,t){let r=a.content.length===1?a.content[0]:void 0;if(r?.type!=="text"||a.details.lines===void 0)return a;let n=e.slice(a.details.lines.length);if(n.length===0)return a;let s=t?.lineEnding!==void 0&&t.lineEnding.length>0?t.lineEnding:n[0]?.lineEnding!==void 0&&n[0].lineEnding.length>0?n[0].lineEnding:`
|
|
6
|
+
`,o=n.map((u,d)=>{let f=d===n.length-1?u.lineEnding:u.lineEnding||s,m=u.presentation?.prefix??"",g=u.presentation?.suffix??"";return`${m}${u.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(r.text)?"":s,c=`${r.text}${i}${o}`;return{...a,content:[{...r,text:c}],details:{...a.details,lines:e}}}l(me,"appendTextLines");var Y=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function Z(a){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return Y.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,t){if(!Y.test(e))return{kind:"not-handled"};try{let n=(await a.getDocumentScopes(t.source,t.cwd,t.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return n===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:n.beginAnchor.value===e?n.beginAnchor:n.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}l(Z,"createAstScopeAnchorResolver");import Ae from"cross-spawn";import{readFile as Re,stat as te}from"node:fs/promises";import h from"node:path";import Q from"node:path";import{pathToFileURL as ge}from"node:url";function ee(a,e,t,r,n){let s=new Map;for(let i of e){let c=s.get(i.file)??[];c.push(i),s.set(i.file,c)}let o=[...s.entries()].map(([i,c])=>he(i,c,r));return{sessionId:n,query:a,matchCount:e.length,fileCount:o.length,complete:t,files:o}}l(ee,"createAstSearchPresentation");function he(a,e,t){let r=new Map;e.forEach((o,i)=>{let c=o.lines.replace(/\r/gu,"").split(`
|
|
7
|
+
`);c.at(-1)===""&&c.pop();let u=`${a}:${String(i)}`;c.forEach((d,p)=>{let f=o.range.start.line+p+1,m=ye(o,d,p,c.length);if(m===void 0)return;let g=r.get(f)??{text:d,ranges:[],logicalMatchIds:[]};g.ranges.push(m),g.logicalMatchIds.push(u),r.set(f,g)})});let n=[...r.entries()].sort(([o],[i])=>o-i).map(([o,i])=>{let c=Se(i.ranges);return{lineNumber:o,text:i.text,matchCount:c.length,ranges:c,logicalMatchIds:[...new Set(i.logicalMatchIds)]}}),s=Q.resolve(t,a);return{path:Q.relative(t,s),link:ge(s).href,matchCount:e.length,lines:n}}l(he,"createFilePresentation");function ye(a,e,t,r){let n=t===0,s=t===r-1,o=n?a.range.start.column:0,i=s?a.range.end.column:e.length;if(!(i<=o))return{from:Math.min(o,e.length),to:Math.min(i,e.length)}}l(ye,"highlightedRange");function Se(a){let e=[...a].sort((r,n)=>r.from-n.from||r.to-n.to),t=[];for(let r of e){let n=t.at(-1);n===void 0||r.from>n.to?t.push(r):t[t.length-1]={from:n.from,to:Math.max(n.to,r.to)}}return t}l(Se,"mergeRanges");function re(a){return{id:"ast",readResources:l((e,t)=>e.query.startsWith("ast:")?[e.path??t.cwd]:[],"readResources"),renderResult:V,async tryResolve(e,t){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let r=e.query.slice(4).trim();if(r.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let n=l(async i=>{let c=await we(r,e,t.cwd,i);c.sort((d,p)=>h.resolve(t.cwd,d.file).localeCompare(h.resolve(t.cwd,p.file))||d.range.byteOffset.start-p.range.byteOffset.start||d.range.byteOffset.end-p.range.byteOffset.end);let u=c.slice(0,e.limit??100);return{raw:u,matches:await be(u,t.cwd,i),complete:c.length<=(e.limit??100)}},"collect"),s=await n(t.signal),o=await a({request:e,matches:s.matches,complete:s.complete,refresh:n},t);return{kind:"resolved",payload:{pattern:r,matches:s.raw.map((i,c)=>({...i,selection:s.matches[c]})),complete:s.complete,sessionId:o.id,presentation:ee(e.query,s.raw,s.complete,t.cwd,o.id)}}},toScriptData(e){let t=e;return B(t.matches.map(r=>r.selection),t.complete,t.sessionId)},format(e){let t=e;if(t.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:t.presentation};let r=t.matches.flatMap((n,s)=>[`SEARCH#${t.sessionId}:${String(s+1)}:match ${n.file}:${String(n.range.start.line+1)}:${String(n.range.start.column+1)} ${n.language}`,` ${n.lines.trim()}`]);return t.complete&&r.unshift(`SEARCH#${t.sessionId}:all:match selects all exact AST matches.`),t.complete||r.push("Result limit reached."),{content:[{type:"text",text:r.join(`
|
|
8
|
+
`)}],details:t.presentation}}}}l(re,"createAstSearchResolver");async function be(a,e,t){let r=new Map;for(let n of a){let s=h.resolve(e,n.file);if(r.has(s))continue;let o=await te(s),i=await Re(s,{signal:t}),c=await te(s);if(o.mtimeMs!==c.mtimeMs||o.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");r.set(s,i)}return a.map(n=>{let s=h.resolve(e,n.file),o=r.get(s);if(o===void 0)throw new Error("Missing AST source snapshot");let{start:i,end:c}=n.range.byteOffset;if(!Number.isInteger(i)||!Number.isInteger(c)||i<0||c<i||c>o.length||o.subarray(i,c).toString("utf8")!==n.text)throw new Error("AST range does not match its source snapshot. Search again.");let u=o.subarray(0,i).toString("utf8"),d=o.subarray(0,c).toString("utf8"),p=u.split(`
|
|
9
|
+
`).length;return{source:s,lineNumber:p,endLineNumber:d.split(`
|
|
10
|
+
`).length,startColumn:u.length-u.lastIndexOf(`
|
|
11
|
+
`)-1,endColumn:d.length-d.lastIndexOf(`
|
|
12
|
+
`)-1,matchedText:n.text,lineText:o.toString("utf8").split(`
|
|
13
|
+
`)[p-1]?.replace(/\r$/u,"")??""}})}l(be,"selectionMatches");function we(a,e,t,r){let n=["run","--pattern",a,"--json=compact","--no-ignore","parent"];for(let s of ne(e.include))n.push("--globs",s);for(let s of ne(e.exclude))n.push("--globs",`!${s}`);return n.push(e.path??"."),new Promise((s,o)=>{let i=Ae("ast-grep",n,{cwd:t,stdio:["ignore","pipe","pipe"]}),c="",u="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>c+=p),i.stderr.on("data",p=>u+=p);let d=l(()=>{i.kill("SIGTERM")},"abort");r?.addEventListener("abort",d,{once:!0}),i.once("error",o),i.once("close",p=>{if(r?.removeEventListener("abort",d),r?.aborted===!0){o(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){o(new Error(u.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(c.length===0?"[]":c);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");s(f)}catch(f){o(f instanceof Error?f:new Error(String(f)))}})})}l(we,"runAstGrep");function ne(a){return a?.split(",").map(e=>e.trim()).filter(Boolean)??[]}l(ne,"splitGlobs");var ve=I({kind:"code-view",label:"AST"});async function se(a){let e=new G,t=W(e),r={protocol:P,apiVersion:k,id:"ast",setup(s){s.addResolver({resolver:U(),renderResult:ve}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),s.addView({view:"ast",presenter:t});let o=X();s.addOutputReducer(A);let i=q();s.addHandler({stage:"post-read",async handler(c){let u=await o(c);return u.kind==="return"?u:i(u.context)}}),s.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},n={protocol:$,apiVersion:C,id:"ast",setup(s){s.addAnchorResolver({resolver:Z(e),kind:N,type:"auxiliary"}),s.addTextPresenter({presenter:t})}};await Promise.all([M(a,r),E(a,z),D(a,n),j(a,{protocol:_,apiVersion:H,id:"ast-search",setup(s){s.addResolver({resolver:re(s.registerSelection)}),s.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}l(se,"registerAst");export{se as default};
|
package/dist/entry-33.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Q,b as K,c as W}from"./chunk-DEP55R35.js";import{e as O,f as U}from"./chunk-T7I2VX3J.js";import{a as F}from"./chunk-MGCHOGQD.js";import{a as L,b as N}from"./chunk-T6LX2RX5.js";import{a as z}from"./chunk-L7JMDDSD.js";import{a as B,b as V}from"./chunk-O6LE42GK.js";import{a as _}from"./chunk-6CZO43OH.js";import{a as j,b as M}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Value as Ne}from"typebox/value";import{access as oe}from"node:fs/promises";import ae from"node:path";var Y={protocol:L,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ie(e.cwd)?await $("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await D("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function ie(n){try{return await oe(ae.join(n,".git")),!0}catch{return!1}}s(ie,"isGitProject");import{mkdtemp as se,rm as de,writeFile as ce}from"node:fs/promises";import ue from"node:os";import m from"node:path";var b=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,r){let o=m.resolve(t,e),a=m.relative(this.repositoryRoot,o);return a===".."||a.startsWith(`..${m.sep}`)||m.isAbsolute(a)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(a.split(m.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let a=le(o.stdout);if(a===void 0)return{status:"untracked"};let i=await this.readBlob(a.blob,"HEAD",e,t);if(i.status!=="found")return i;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let d=ge(c.stdout);if(d.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=d.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:i.text,indexText:l,indexMode:u?.mode??a.mode}}async writeIndexFile(e,t,r,o){let a=await se(m.join(ue.tmpdir(),"pi-agent-index-")),i=m.join(a,"content");try{await ce(i,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,i],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let d=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(d.code!==0)throw new Error(d.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await de(a,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let a=await this.git(["cat-file","blob",e],o);return a.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:a.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:a.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function le(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,o,a]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||a===void 0?void 0:{mode:r,blob:a,path:e.slice(t+1)}}s(le,"parseTreeEntry");function ge(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,a]=e.slice(0,t).split(" ",3),i=Number(a);return r===void 0||o===void 0||!Number.isInteger(i)?[]:[{mode:r,blob:o,stage:i,path:e.slice(t+1)}]})}s(ge,"parseIndexEntries");function q(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(q,"extensionGitExecutor");var f=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await b.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=Q(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let o=await this.inspect(e);if(o.status!=="applicable")return o;let a=o.groups.find(u=>u.selector===t);if(a===void 0)return A(t,o.groups.map(({selector:u})=>u));let i=r==="stage"?"staged":"unstaged";if(a.state===i)return{status:"unchanged",state:i,group:a};let c=x(a.segments[0]),d={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(d,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:pe(u)}}return{status:"applied",state:i,group:a}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(d=>d.selector===t);if(o===void 0)return A(t,r.groups.map(({selector:d})=>d));let a=K(e.worktreeText,o);if(a===void 0)return A(t,r.groups.map(({selector:d})=>d));let i=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:i.headStart,headEnd:i.headEnd,replacementText:i.headText};return{status:"applied",worktreeText:a,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=W(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,t)}};function A(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(A,"staleSelector");function pe(n){return n instanceof Error?n.message:String(n)}s(pe,"errorMessage");var T="pi-agent-ide-changes/change",fe=/^CHANGE#[0-9A-F]{4,64}$/,he=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function X(n){return{resolver:me(s(async t=>{if(he.test(t.source))return;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(X,"createChangeAnchorRegistration");function me(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!fe.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let o=r.status==="applicable"?r.groups.find(a=>a.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(r){return{kind:"failed",error:r}}}}}s(me,"createChangeAnchorResolver");import{diffLines as ye}from"diff";var xe="filesystem";function Z(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==xe)return e;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:we(e,o.groups)}}}s(Z,"createCurrentChangePresenter");function we(n,e){let t=new Map;for(let r of e)be(n,r,t);return{...n,lines:n.lines.map(r=>ve(r,t.get(r.lineNumber)))}}s(we,"presentChangeGroups");function be(n,e,t){let r=x(e.segments[0]),o=ye(r.headText,r.worktreeText),a=e.currentStartLine,i,c;for(let d of o){let u=ke(d.value);if(d.removed){let l=Ce(n,a),g=R(t,l.lineNumber),p=l.after?g.after:g.before;for(let h of u){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:h}),i??=w,c=w}continue}if(d.added){for(let l of u){let g=R(t,a),p={kind:"current",lineNumber:a};g.added=!0,i??=p,c=p,a++}continue}a+=u.length}if(i!==void 0&&c!==void 0){let d=`${e.selector} \xB7 ${e.state}`;Te(i,c)?I(t,i,`<!-- change: ${d} -->`):(I(t,i,`<!-- change-begin: ${d} -->`),I(t,c,`<!-- change-end: ${d} -->`))}}s(be,"presentChangeGroup");function Te(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(Te,"sameTarget");function I(n,e,t){if(e.kind==="current"){R(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(I,"annotateTarget");function ve(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s(ve,"presentLine");function R(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(R,"presentationsFor");function Ce(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Ce,"placementFor");function ke(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(ke,"splitLines");var v=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ee}from"node:crypto";import{realpathSync as Pe}from"node:fs";import te from"node:path";import{fileURLToPath as Ae}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=J(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===C(e.before.content)?this.#e.set(t,{...r,afterDigest:C(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:C(e.after.content)})}restore(e,t,r){let o=J(e,t),a=this.#e.get(o);if(a===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(a.afterDigest!==C(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return a.before}};function J(n,e){return n.startsWith("file://")?ee(Ae(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:ee(te.resolve(e,n))}s(J,"sourceKey");function ee(n){try{return Pe.native(n)}catch{return te.normalize(n)}}s(ee,"canonicalFile");function C(n){return Ee("sha256").update(n).digest("hex")}s(C,"textDigest");import{readFile as Ge}from"node:fs/promises";import Ie from"node:path";import{defineTool as Re,withFileMutationQueue as Se}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var P=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ne(n,e,t){n.registerTool(E("stage",e,t)),n.registerTool(E("unstage",e,t))}s(ne,"registerIndexChangeTools");function E(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return Re({name:n,label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:P,async execute(a,i,c,d,u){let l=He(i.file,u.cwd);return Se(l,()=>t.run(async()=>{let g=await Ge(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let h=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},i.change,n);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${n} is not applicable to ${l}: ${h.reason}`);let w=h.status==="unchanged";return{content:[{type:"text",text:w?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:l,state:r,unchanged:w}}}))}})}s(E,"createIndexChangeTool");function He(n,e){let t=n.startsWith("@")?n.slice(1):n;return Ie.resolve(e,t)}s(He,"resolveFile");import{diffChars as $e}from"diff";import{Type as y}from"typebox";var De=y.Object({file:y.Optional(y.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:y.Optional(y.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:y.Optional(y.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function re(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:s(o=>o!==null&&typeof o=="object"&&"transaction"in o&&typeof o.transaction=="string","matches"),async execute(o,a){if(a.change!==void 0)throw new Error("transaction cannot be combined with change");let i=String(a.transaction),c=await r(i,o.signal);return{source:i,summary:`Restored ${String(c.restored.length)} paths from ${i}.`,data:{kind:"apply-undo",ok:!0,transaction:i,restored:c.restored}}}},parameters:De,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(o,a){if(a.change===void 0)throw new Error("change is required when transaction is omitted");let i=o.sourceFor("file"),c,d;if(a.change==="last")c=e.restore(i,o.cwd,o.sourceDocument.content);else{await o.resolveAnchor("change");let u=await f.create(n,o.cwd,o.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:i,worktreeText:o.sourceDocument.content,cwd:o.cwd,...o.signal!==void 0&&{signal:o.signal}},a.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;d=s(()=>t.run(()=>u.service.applyIndexUpdate(g,o.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:Le(o.sourceDocument.content,c),action:"edited"}]]),...d!==void 0&&{afterWrite:d}}}}}s(re,"createUndoMutationTool");function Le(n,e){let t=[],r=0,o,a=0,i="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+a,insert:i}),o=void 0,a=0,i="")},"flush");for(let d of $e(n,e)){if(!d.added&&!d.removed){c(),r+=d.value.length;continue}o??=r,d.removed?(r+=d.value.length,a+=d.value.length):i+=d.value}return c(),t}s(Le,"createTextChanges");async function Oe(n){U(n,[await O({id:"git-changes",description:"Git change anchors, staging, and safe undo",triggers:["stage","unstage","undo"].map(d=>({tool:d}))})]);let e=q(n),t=new k,r=new v,o=Z(e),a=X(e),i={protocol:j,apiVersion:M,id:"current-git-changes",setup(d){d.addView({view:"changes",presenter:o}),d.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:B,apiVersion:V,id:"current-git-changes",setup(d){d.addAnchorResolver({...a,kind:T,type:"auxiliary"}),d.onDidEdit(u=>{t.observe(u)}),d.addMutationTool(re(e,t,r,d.restoreApplyUndo));for(let u of["stage","unstage"]){let l=E(u,e,r);d.addScriptIndexOperation({name:u,parameters:P,execute:s((g,p,h)=>l.execute(`apply-${u}`,Ne.Decode(P,g),p,void 0,h),"execute")})}d.addTextPresenter({presenter:o})}};await Promise.all([F(n,Y),_(n,i),z(n,c)]),ne(n,e,r)}s(Oe,"registerGitChanges");export{Oe as default};
|
|
1
|
+
import{a as X,b as Z,c as J}from"./chunk-DEP55R35.js";import{e as j,f as M}from"./chunk-T7I2VX3J.js";import{a as _}from"./chunk-MGCHOGQD.js";import{a as U,b as F}from"./chunk-T6LX2RX5.js";import{a as q}from"./chunk-FBOW7XOV.js";import{a as K,b as Y}from"./chunk-WJTHY6AG.js";import{a as z}from"./chunk-6CZO43OH.js";import{a as B,b as V}from"./chunk-OBNING2A.js";import{e as Q,h as W,i as P}from"./chunk-2P2OGO3G.js";import{a as L}from"./chunk-ZPT5D4VP.js";import{d as O,e as N}from"./chunk-N34ATN52.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";import{Value as _e}from"typebox/value";import{access as ue}from"node:fs/promises";import le from"node:path";var ee={protocol:U,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ge(e.cwd)?await O("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await N("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function ge(n){try{return await ue(le.join(n,".git")),!0}catch{return!1}}d(ge,"isGitProject");import{mkdtemp as fe,rm as pe,writeFile as he}from"node:fs/promises";import me from"node:os";import m from"node:path";var b=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{d(this,"GitChangesBackend")}static async create(e,t,r){let a=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return a.code!==0?{status:"unavailable",reason:"no-worktree",message:a.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(a.stdout.trim()))}}async readTrackedFile(e,t,r){let a=m.resolve(t,e),o=m.relative(this.repositoryRoot,a);return o===".."||o.startsWith(`..${m.sep}`)||m.isAbsolute(o)?{status:"unavailable",reason:"outside-worktree",message:`${a} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(o.split(m.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let a=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(a.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:a.stderr.trim()||`could not inspect HEAD:${e}`};let o=xe(a.stdout);if(o===void 0)return{status:"untracked"};let s=await this.readBlob(o.blob,"HEAD",e,t);if(s.status!=="found")return s;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 i=ye(c.stdout);if(i.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=i.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:s.text,indexText:l,indexMode:u?.mode??o.mode}}async writeIndexFile(e,t,r,a){let o=await fe(m.join(me.tmpdir(),"pi-agent-index-")),s=m.join(o,"content");try{await he(s,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,s],a);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let i=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],a);if(i.code!==0)throw new Error(i.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await pe(o,{recursive:!0,force:!0})}}async readBlob(e,t,r,a){let o=await this.git(["cat-file","blob",e],a);return o.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:o.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:o.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function xe(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,a,o]=e.slice(0,t).split(" ",3);return r===void 0||a!=="blob"||o===void 0?void 0:{mode:r,blob:o,path:e.slice(t+1)}}d(xe,"parseTreeEntry");function ye(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,a,o]=e.slice(0,t).split(" ",3),s=Number(o);return r===void 0||a===void 0||!Number.isInteger(s)?[]:[{mode:r,blob:a,stage:s,path:e.slice(t+1)}]})}d(ye,"parseIndexEntries");function te(n){return{exec:d((e,t,r)=>n.exec(e,t,r),"exec")}}d(te,"extensionGitExecutor");var h=class n{constructor(e){this.git=e}static{d(this,"ChangeService")}static async create(e,t,r){let a=await b.create(e,t,r);return a.status==="unavailable"?a:{status:"ready",service:new n(a.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=X(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let a=await this.inspect(e);if(a.status!=="applicable")return a;let o=a.groups.find(u=>u.selector===t);if(o===void 0)return A(t,a.groups.map(({selector:u})=>u));let s=r==="stage"?"staged":"unstaged";if(o.state===s)return{status:"unchanged",state:s,group:o};let c=y(o.segments[0]),i={head:a.head,repositoryPath:a.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(i,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:we(u)}}return{status:"applied",state:s,group:o}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let a=r.groups.find(i=>i.selector===t);if(a===void 0)return A(t,r.groups.map(({selector:i})=>i));let o=Z(e.worktreeText,a);if(o===void 0)return A(t,r.groups.map(({selector:i})=>i));let s=y(a.segments[0]),c=a.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:s.headStart,headEnd:s.headEnd,replacementText:s.headText};return{status:"applied",worktreeText:o,group:a,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let a=J(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);a!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,a,t)}};function A(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}d(A,"staleSelector");function we(n){return n instanceof Error?n.message:String(n)}d(we,"errorMessage");var T="pi-agent-ide-changes/change",be=/^CHANGE#[0-9A-F]{4,64}$/,Te=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends L{static{d(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function ne(n){return{resolver:Ce(d(async t=>{if(Te.test(t.source))return;let r=await h.create(n,t.cwd,t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}d(ne,"createChangeAnchorRegistration");function Ce(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!be.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let a=r.status==="applicable"?r.groups.find(o=>o.selector===e):void 0;return a===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(a)}}catch(r){return{kind:"failed",error:r}}}}}d(Ce,"createChangeAnchorResolver");import{diffLines as ve}from"diff";var ke="filesystem";function re(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==ke)return e;let r=await h.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let a=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return a.status!=="applicable"?e:Ee(e,a.groups)}}}d(re,"createCurrentChangePresenter");function Ee(n,e){let t=new Map;for(let r of e)Pe(n,r,t);return{...n,references:e.map(r=>({value:r.selector,kind:"change",state:r.state})),lines:n.lines.map(r=>Ge(r,t.get(r.lineNumber)))}}d(Ee,"presentChangeGroups");function Pe(n,e,t){let r=y(e.segments[0]),a=ve(r.headText,r.worktreeText),o=e.currentStartLine,s,c;for(let i of a){let u=Se(i.value);if(i.removed){let l=Ie(n,o),g=S(t,l.lineNumber),p=l.after?g.after:g.before;for(let w of u){let $={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:w}),s??=$,c=$}continue}if(i.added){for(let l of u){let g=S(t,o),p={kind:"current",lineNumber:o};g.added=!0,s??=p,c=p,o++}continue}o+=u.length}if(s!==void 0&&c!==void 0){let i=`${e.selector} \xB7 ${e.state}`;Ae(s,c)?I(t,s,`<!-- change: ${i} -->`):(I(t,s,`<!-- change-begin: ${i} -->`),I(t,c,`<!-- change-end: ${i} -->`))}}d(Pe,"presentChangeGroup");function Ae(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}d(Ae,"sameTarget");function I(n,e,t){if(e.kind==="current"){S(n,e.lineNumber).annotations.push(t);return}let r=y(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}d(I,"annotateTarget");function Ge(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}d(Ge,"presentLine");function S(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}d(S,"presentationsFor");function Ie(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}d(Ie,"placementFor");function Se(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}d(Se,"splitLines");var C=class{static{d(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Re}from"node:crypto";import{realpathSync as He}from"node:fs";import ie from"node:path";import{fileURLToPath as De}from"node:url";var k=class{static{d(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=ae(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===v(e.before.content)?this.#e.set(t,{...r,afterDigest:v(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:v(e.after.content)})}restore(e,t,r){let a=ae(e,t),o=this.#e.get(a);if(o===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(o.afterDigest!==v(r))throw this.#e.delete(a),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return o.before}};function ae(n,e){return n.startsWith("file://")?oe(De(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:oe(ie.resolve(e,n))}d(ae,"sourceKey");function oe(n){try{return He.native(n)}catch{return ie.normalize(n)}}d(oe,"canonicalFile");function v(n){return Re("sha256").update(n).digest("hex")}d(v,"textDigest");import{readFile as $e}from"node:fs/promises";import Le from"node:path";import{defineTool as Oe,withFileMutationQueue as Ne}from"@earendil-works/pi-coding-agent";import{Type as f}from"typebox";var R=f.Object({action:f.Union([f.Literal("stage"),f.Literal("unstage")]),change:f.String(),file:f.String(),state:f.Optional(f.Union([f.Literal("staged"),f.Literal("unstaged")])),effect:f.Union([f.Literal("applied"),f.Literal("not-applied"),f.Literal("unknown")]),unchanged:f.Optional(f.Boolean())},{additionalProperties:!1}),Ue=Q(R),E=f.Object({file:f.String({description:"Path to the tracked text file"}),change:f.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function de(n,e,t){n.registerTool(se("stage",e,t)),n.registerTool(se("unstage",e,t))}d(de,"registerIndexChangeTools");function se(n,e,t){let r=D(n,e,t);return Oe({name:n,exposure:"deferred",namespace:{name:"ide_git",description:"Stage or unstage selected Git changes without changing worktree files."},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},label:n,promptSnippet:`${(n==="stage"?"Staged":"Unstaged").slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:E,outputSchema:Ue,async execute(o,s,c,i,u){try{let l=await r(s,c,u);return P(l,R,{status:"success",data:{...l.details,effect:l.details.unchanged?"not-applied":"applied"},errors:[]})}catch(l){if(c?.aborted)throw l;let g=W(l,"INDEX_CHANGE_FAILED",s.file);return P({content:[{type:"text",text:g.message}],details:{action:n,change:s.change,file:H(s.file,u.cwd)}},R,{status:"error",data:{action:n,change:s.change,file:H(s.file,u.cwd),effect:"unknown"},errors:[g]})}}})}d(se,"createIndexChangeTool");function D(n,e,t){let r=n==="stage"?"staged":"unstaged",a=n==="stage"?"Staged":"Unstaged";return async(o,s,c)=>{let i=H(o.file,c.cwd);return Ne(i,()=>t.run(async()=>{let u=await $e(i,"utf8"),l=await h.create(e,c.cwd,s);if(l.status!=="ready")throw new Error(l.message);let g=await l.service.changeIndex({source:i,worktreeText:u,cwd:c.cwd,...s!==void 0&&{signal:s}},o.change,n);if(g.status==="unavailable")throw new Error(g.message);if(g.status==="not-applicable")throw new Error(`${n} is not applicable to ${i}: ${g.reason}`);let p=g.status==="unchanged";return{content:[{type:"text",text:p?`${o.change} is already ${r} in ${o.file}.`:`${a} ${o.change} in ${o.file}.`}],details:{action:n,change:o.change,file:i,state:r,unchanged:p}}}))}}d(D,"createIndexChangeExecutor");function H(n,e){let t=n.startsWith("@")?n.slice(1):n;return Le.resolve(e,t)}d(H,"resolveFile");import{diffChars as Fe}from"diff";import{Type as x}from"typebox";var je=x.Object({file:x.Optional(x.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:x.Optional(x.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:x.Optional(x.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function ce(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:d(a=>a!==null&&typeof a=="object"&&"transaction"in a&&typeof a.transaction=="string","matches"),async execute(a,o){if(o.change!==void 0)throw new Error("transaction cannot be combined with change");let s=String(o.transaction),c=await r(s,a.signal);return{source:s,summary:`Restored ${String(c.restored.length)} paths from ${s}.`,data:{kind:"apply-undo",ok:!0,transaction:s,restored:c.restored}}}},parameters:je,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(a,o){if(o.change===void 0)throw new Error("change is required when transaction is omitted");let s=a.sourceFor("file"),c,i;if(o.change==="last")c=e.restore(s,a.cwd,a.sourceDocument.content);else{await a.resolveAnchor("change");let u=await h.create(n,a.cwd,a.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:s,worktreeText:a.sourceDocument.content,cwd:a.cwd,...a.signal!==void 0&&{signal:a.signal}},o.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${s}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;i=d(()=>t.run(()=>u.service.applyIndexUpdate(g,a.signal)),"afterWrite")}}return{edits:new Map([[s,{changes:Me(a.sourceDocument.content,c),action:"edited"}]]),...i!==void 0&&{afterWrite:i}}}}}d(ce,"createUndoMutationTool");function Me(n,e){let t=[],r=0,a,o=0,s="",c=d(()=>{a!==void 0&&(t.push({from:a,to:a+o,insert:s}),a=void 0,o=0,s="")},"flush");for(let i of Fe(n,e)){if(!i.added&&!i.removed){c(),r+=i.value.length;continue}a??=r,i.removed?(r+=i.value.length,o+=i.value.length):s+=i.value}return c(),t}d(Me,"createTextChanges");async function Be(n){M(n,[await j({id:"git-changes",description:"Git change anchors, staging, and safe undo",triggers:["stage","unstage","undo"].map(i=>({tool:i}))})]);let e=te(n),t=new k,r=new C,a=re(e),o=ne(e),s={protocol:B,apiVersion:V,id:"current-git-changes",setup(i){i.addView({view:"changes",presenter:a}),i.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:K,apiVersion:Y,id:"current-git-changes",setup(i){i.addAnchorResolver({...o,kind:T,type:"auxiliary"}),i.onDidEdit(u=>{t.observe(u)}),i.addMutationTool(ce(e,t,r,i.restoreApplyUndo));for(let u of["stage","unstage"]){let l=D(u,e,r);i.addScriptIndexOperation({name:u,parameters:E,execute:d((g,p,w)=>l(_e.Decode(E,g),p,w),"execute")})}i.addTextPresenter({presenter:a})}};await Promise.all([_(n,ee),z(n,s),q(n,c)]),de(n,e,r)}d(Be,"registerGitChanges");export{Be as default};
|