pi-agent-ide 0.6.3 → 0.7.0
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 +97 -0
- package/README.md +10 -3
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-3HYXQ4YA.js +28 -0
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/chunk-4NIFBFFR.js +11 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-5QQABP47.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-O6LE42GK.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/chunk-KBP3QUDT.js +2 -0
- package/dist/chunk-KR36BT5E.js +1 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/chunk-PYPPV2F5.js +25 -0
- package/dist/{chunk-25CZ5ZIU.js → chunk-QFTBY67N.js} +3 -3
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/{chunk-L7JMDDSD.js → chunk-YRF7OATP.js} +1 -1
- 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 -9
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +12 -11
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +3 -6
- package/dist/entry-51.js +11 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -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 +0 -1
- package/dist/entry-62.js +1 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-72.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +50 -307
- package/dist/entry-78.js +14 -26
- package/dist/entry-79.js +2 -2
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -3
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/editing.md +31 -3
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +15 -1
- package/docs/agent-guides/search-code.md +43 -2
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +36 -7
- package/docs/development.md +16 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- package/docs/research/apply-native-capability-matrix.md +174 -0
- package/docs/research/apply-read-latency.md +2 -0
- package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
- package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
- package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
- package/docs/research/native-codemode-batch-decision.md +29 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +86 -0
- package/docs/tools.md +24 -4
- package/docs/user-hooks.md +1 -1
- 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 +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- 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 +110 -7
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -24
- 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 +126 -48
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- 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/index.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
- 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/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +35 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- 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/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +22 -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/result-targets.ts +233 -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/fuzzy.ts +208 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +13 -6
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +39 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +148 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +90 -24
- package/node_modules/pi-agent-search/src/core/search-core.ts +145 -78
- package/node_modules/pi-agent-search-text/index.ts +6 -1
- package/node_modules/pi-agent-search-text/package.json +7 -6
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +174 -26
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +201 -18
- 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 +90 -259
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +110 -17
- 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 -7
- package/node_modules/pi-agent-text-editor/package.json +20 -21
- 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/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- 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 +78 -41
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -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/mutation-result-targets.ts +168 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +820 -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/result-input.ts +22 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +412 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- 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 +236 -185
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- 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-tool-schema-properties.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +9 -73
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +276 -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-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
- package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
- package/node_modules/pi-agent-web/index.ts +23 -0
- package/node_modules/pi-agent-web/package.json +7 -6
- package/node_modules/pi-agent-web/src/search.ts +221 -0
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +42 -37
- 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/module-labels.ts +1 -1
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/preferences.ts +0 -5
- 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 +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +221 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +35 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- 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/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +6 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +174 -26
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +201 -18
- 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 +90 -259
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +110 -17
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +13 -6
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +39 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +148 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +90 -24
- package/src/extensions/pi-agent-search/src/core/search-core.ts +145 -78
- package/src/extensions/pi-agent-text-editor/index.ts +4 -7
- package/src/extensions/pi-agent-text-editor/package.json +20 -21
- 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 +9 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +276 -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-renderer/src/renderer.ts +19 -45
- 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 +4 -4
- 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/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- 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 +78 -41
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -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/mutation-result-targets.ts +168 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +820 -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/result-input.ts +22 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +412 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- 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 +236 -185
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- 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-tool-schema-properties.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +61 -8
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- 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 +110 -7
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -24
- 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 +126 -48
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- 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/index.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
- 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 +16 -37
- 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 +98 -46
- 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 +35 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-4U2GUKNJ.js +0 -0
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7WCZOO5I.js +0 -1
- 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-ITSNK5YG.js +0 -7
- 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-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-VXD6FZP5.js +0 -5
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-YT42LKFV.js +0 -16
- package/docs/agent-guides/apply.md +0 -333
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -155
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -133
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -155
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -133
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
|
@@ -5,6 +5,10 @@ import { requiredValue } from "pi-agent-invariant";
|
|
|
5
5
|
import {
|
|
6
6
|
isAgentContent,
|
|
7
7
|
isResourceResolutionAttempt,
|
|
8
|
+
resourceScheduler,
|
|
9
|
+
resourceAccesses,
|
|
10
|
+
type ResourceAccess,
|
|
11
|
+
type ResourceResolutionAttempt,
|
|
8
12
|
type Resource,
|
|
9
13
|
type ResourceResolver,
|
|
10
14
|
type ResourceResolverContext,
|
|
@@ -42,7 +46,6 @@ import {
|
|
|
42
46
|
isTextAnchorResolverRegistration,
|
|
43
47
|
isTextEditorToolId,
|
|
44
48
|
type PromptDescriptionSource,
|
|
45
|
-
type ScriptIndexOperation,
|
|
46
49
|
type ResourceResolverRegistration,
|
|
47
50
|
TEXT_EDITOR_API_VERSION,
|
|
48
51
|
TEXT_EDITOR_PROTOCOL,
|
|
@@ -74,11 +77,6 @@ import {
|
|
|
74
77
|
} from "#src/core/text-change-engine.js";
|
|
75
78
|
import { previewTextMutation } from "#src/core/text-mutation.js";
|
|
76
79
|
import { loadTextEditorConfig, recoverySection } from "#src/core/text-editor-config.js";
|
|
77
|
-
import {
|
|
78
|
-
ApplyUndoStore,
|
|
79
|
-
type ApplyUndoBeforeState,
|
|
80
|
-
type ApplyUndoResult,
|
|
81
|
-
} from "#src/core/apply/apply-undo-store.js";
|
|
82
80
|
|
|
83
81
|
import type {
|
|
84
82
|
TextAnchorInspectionOutcome,
|
|
@@ -128,6 +126,53 @@ interface RegisteredResolver {
|
|
|
128
126
|
readonly order: number;
|
|
129
127
|
}
|
|
130
128
|
|
|
129
|
+
/** Resolve owners once before scheduling, without reading or modifying their contents. */
|
|
130
|
+
function scopedResolvers(
|
|
131
|
+
sources: readonly string[],
|
|
132
|
+
context: ResourceResolverContext,
|
|
133
|
+
resolvers: readonly RegisteredResolver[],
|
|
134
|
+
mode: ResourceAccess["mode"] = "write",
|
|
135
|
+
): {
|
|
136
|
+
resolvers: readonly RegisteredResolver[];
|
|
137
|
+
accesses: Promise<readonly ResourceAccess[] | undefined>;
|
|
138
|
+
} {
|
|
139
|
+
const cached = resolvers.map((registered) => {
|
|
140
|
+
const attempts = new Map<string, Promise<ResourceResolutionAttempt>>();
|
|
141
|
+
return {
|
|
142
|
+
...registered,
|
|
143
|
+
resolver: {
|
|
144
|
+
...registered.resolver,
|
|
145
|
+
tryResolve(source: string, request: ResourceResolverContext) {
|
|
146
|
+
let pending = attempts.get(source);
|
|
147
|
+
if (pending === undefined) {
|
|
148
|
+
pending = registered.resolver.tryResolve(source, request);
|
|
149
|
+
attempts.set(source, pending);
|
|
150
|
+
}
|
|
151
|
+
return pending;
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
const accesses = Promise.all(
|
|
157
|
+
sources.map(async (source) => {
|
|
158
|
+
try {
|
|
159
|
+
for (const { resolver } of cached) {
|
|
160
|
+
const attempt = await resolver.tryResolve(source, context);
|
|
161
|
+
if (!isResourceResolutionAttempt(attempt)) return undefined;
|
|
162
|
+
if (attempt.kind === "not-handled") continue;
|
|
163
|
+
if (attempt.kind === "failed") return undefined;
|
|
164
|
+
return await resourceAccesses(attempt.resource.source, context.cwd, mode);
|
|
165
|
+
}
|
|
166
|
+
} catch {
|
|
167
|
+
// Let the normal edit pipeline report the cached resolution failure.
|
|
168
|
+
}
|
|
169
|
+
return undefined;
|
|
170
|
+
}),
|
|
171
|
+
).then((sets) =>
|
|
172
|
+
sets.some((set) => set === undefined) ? undefined : sets.flatMap((set) => set ?? []),
|
|
173
|
+
);
|
|
174
|
+
return { resolvers: cached, accesses };
|
|
175
|
+
}
|
|
131
176
|
interface ResolverContribution {
|
|
132
177
|
readonly pluginId: string;
|
|
133
178
|
readonly registration: ResourceResolverRegistration;
|
|
@@ -171,7 +216,6 @@ interface PluginContributionDraft {
|
|
|
171
216
|
readonly editCompletionListeners?: TextEditCompletionListener[];
|
|
172
217
|
readonly mutationGuards?: TextMutationGuardRegistration[];
|
|
173
218
|
readonly toolRenderers?: TextEditorToolRendererRegistration[];
|
|
174
|
-
readonly scriptIndexOperations?: ScriptIndexOperation[];
|
|
175
219
|
}
|
|
176
220
|
|
|
177
221
|
interface PluginContributionController {
|
|
@@ -231,6 +275,8 @@ export type TextResourceEditOutcome<Result> =
|
|
|
231
275
|
| { readonly kind: "failed"; readonly failure: TextResourceEditFailure };
|
|
232
276
|
|
|
233
277
|
export interface TextResourceEditRequest {
|
|
278
|
+
/** Reject a resource created or removed since its batch snapshot was captured. */
|
|
279
|
+
readonly expectedExistence?: boolean;
|
|
234
280
|
readonly source: string;
|
|
235
281
|
readonly read: boolean;
|
|
236
282
|
readonly allowReadFailure?: boolean;
|
|
@@ -283,16 +329,18 @@ export interface TextResourcesEditContext
|
|
|
283
329
|
extends ResourceResolverContext, TextMutationGuardContext {}
|
|
284
330
|
|
|
285
331
|
export interface TextEditorCore {
|
|
286
|
-
/** Record the complete pre-Apply state and return a session-scoped undo receipt. */
|
|
287
|
-
recordApplyUndo(before: readonly ApplyUndoBeforeState[]): Promise<string>;
|
|
288
|
-
/** Atomically restore one Apply receipt. */
|
|
289
|
-
restoreApplyUndo(transaction: string, signal?: AbortSignal): Promise<ApplyUndoResult>;
|
|
290
|
-
/** Return whether an Apply receipt is still active in this session. */
|
|
291
|
-
hasApplyUndo(transaction: string): boolean;
|
|
292
332
|
/** Finalize a surviving local text file after a whole-file operation; binary files are untouched. */
|
|
293
333
|
postProcessFile(source: string, context: ResourceResolverContext): Promise<void>;
|
|
294
|
-
/**
|
|
295
|
-
enqueueFileOperation<T>(
|
|
334
|
+
/** Reserve complete file sets. Only an explicit transaction owner may enqueue covered nested edits. */
|
|
335
|
+
enqueueFileOperation<T>(
|
|
336
|
+
action: () => Promise<T>,
|
|
337
|
+
signal?: AbortSignal,
|
|
338
|
+
scope?: {
|
|
339
|
+
readonly sources: readonly string[];
|
|
340
|
+
readonly cwd: string;
|
|
341
|
+
readonly allowNestedEdits?: boolean;
|
|
342
|
+
},
|
|
343
|
+
): Promise<T>;
|
|
296
344
|
inspectTextAnchors(request: TextAnchorInspectionRequest): Promise<TextAnchorInspectionOutcome>;
|
|
297
345
|
addAnchorResolver(registration: TextAnchorResolverRegistration): void;
|
|
298
346
|
resolveTextAnchorResources(
|
|
@@ -341,8 +389,6 @@ export interface TextEditorCore {
|
|
|
341
389
|
onMutationTool(listener: TextMutationToolListener): () => void;
|
|
342
390
|
onDidEdit(listener: TextEditCompletionListener): () => void;
|
|
343
391
|
getToolRenderer(tool: TextEditorToolId): TextEditorToolRendererRegistration | undefined;
|
|
344
|
-
/** Return a configured index operation for the Apply host. */
|
|
345
|
-
getScriptIndexOperation(name: string): ScriptIndexOperation | undefined;
|
|
346
392
|
registerPlugin(plugin: TextEditorPlugin): Promise<void>;
|
|
347
393
|
registerPostEditHandler(registration: TextPostEditHandlerRegistration): () => void;
|
|
348
394
|
registerTool(tool: TextEditorToolId): void;
|
|
@@ -374,33 +420,15 @@ export function createTextEditorCore(
|
|
|
374
420
|
const mutationTools = new Map<string, AnyTextMutationToolRegistration>();
|
|
375
421
|
const mutationListeners = new Set<TextMutationToolListener>();
|
|
376
422
|
const editCompletionListeners = new Set<TextEditCompletionListener>();
|
|
377
|
-
const applyUndoStore = new ApplyUndoStore();
|
|
378
|
-
editCompletionListeners.add((completion) => {
|
|
379
|
-
applyUndoStore.observeTextChange(
|
|
380
|
-
path.resolve(completion.cwd, completion.resourceSource),
|
|
381
|
-
completion.before.content,
|
|
382
|
-
completion.after.content,
|
|
383
|
-
completion.postProcessing ?? "complete",
|
|
384
|
-
);
|
|
385
|
-
});
|
|
386
423
|
const mutationGuards: TextMutationGuardRegistration[] = [];
|
|
387
424
|
const toolRenderers = new Map<TextEditorToolId, TextEditorToolRendererRegistration>();
|
|
388
|
-
const scriptIndexOperations = new Map<string, ScriptIndexOperation>();
|
|
389
425
|
let registrationQueue = Promise.resolve();
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return action();
|
|
397
|
-
});
|
|
398
|
-
mutationTail = pending.then(
|
|
399
|
-
() => undefined,
|
|
400
|
-
() => undefined,
|
|
401
|
-
);
|
|
402
|
-
return pending;
|
|
403
|
-
};
|
|
426
|
+
const scheduler = resourceScheduler;
|
|
427
|
+
const enqueueMutation = <T>(
|
|
428
|
+
action: () => Promise<T>,
|
|
429
|
+
signal?: AbortSignal,
|
|
430
|
+
accesses?: Promise<readonly ResourceAccess[] | undefined>,
|
|
431
|
+
): Promise<T> => scheduler.run(accesses, action, signal);
|
|
404
432
|
const registerContributions = (draft: PluginContributionDraft): void => {
|
|
405
433
|
validateContributionDraft(
|
|
406
434
|
draft,
|
|
@@ -412,17 +440,6 @@ export function createTextEditorCore(
|
|
|
412
440
|
);
|
|
413
441
|
|
|
414
442
|
const incomingMutationNames = new Set<string>();
|
|
415
|
-
const incomingIndexNames = new Set<string>();
|
|
416
|
-
for (const operation of draft.scriptIndexOperations ?? []) {
|
|
417
|
-
if (
|
|
418
|
-
!["stage", "unstage"].includes(operation.name) ||
|
|
419
|
-
typeof operation.execute !== "function" ||
|
|
420
|
-
scriptIndexOperations.has(operation.name) ||
|
|
421
|
-
incomingIndexNames.has(operation.name)
|
|
422
|
-
)
|
|
423
|
-
throw new Error(`Invalid or duplicate script index operation ${operation.name}`);
|
|
424
|
-
incomingIndexNames.add(operation.name);
|
|
425
|
-
}
|
|
426
443
|
|
|
427
444
|
for (const registration of draft.mutationTools ?? []) {
|
|
428
445
|
assertTextMutationToolRegistration(registration);
|
|
@@ -476,8 +493,6 @@ export function createTextEditorCore(
|
|
|
476
493
|
|
|
477
494
|
handlers.push(...draft.handlers);
|
|
478
495
|
semanticHandlers.push(...(draft.semanticHandlers ?? []));
|
|
479
|
-
for (const operation of draft.scriptIndexOperations ?? [])
|
|
480
|
-
scriptIndexOperations.set(operation.name, operation);
|
|
481
496
|
mutationGuards.push(...(draft.mutationGuards ?? []));
|
|
482
497
|
promptContributions.push(...draft.promptContributions);
|
|
483
498
|
writablePromptContributions.push(...draft.writablePromptContributions);
|
|
@@ -513,45 +528,50 @@ export function createTextEditorCore(
|
|
|
513
528
|
};
|
|
514
529
|
|
|
515
530
|
const core: TextEditorCore = {
|
|
516
|
-
recordApplyUndo(before) {
|
|
517
|
-
return applyUndoStore.record(before);
|
|
518
|
-
},
|
|
519
|
-
restoreApplyUndo(transaction, signal) {
|
|
520
|
-
return enqueueMutation(() => applyUndoStore.restore(transaction), signal);
|
|
521
|
-
},
|
|
522
|
-
hasApplyUndo(transaction) {
|
|
523
|
-
return applyUndoStore.has(transaction);
|
|
524
|
-
},
|
|
525
531
|
async postProcessFile(source, context) {
|
|
526
|
-
await enqueueMutation(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
532
|
+
await enqueueMutation(
|
|
533
|
+
async () => {
|
|
534
|
+
const file = path.resolve(context.cwd, source);
|
|
535
|
+
const stat = await lstat(file).catch(() => undefined);
|
|
536
|
+
if (!stat?.isFile() || stat.isSymbolicLink()) return;
|
|
537
|
+
const bytes = await readFile(file);
|
|
538
|
+
const text = bytes.toString("utf8");
|
|
539
|
+
if (bytes.includes(0) || !Buffer.from(text).equals(bytes)) return;
|
|
540
|
+
await finalizeTextResource({
|
|
541
|
+
requestedSource: file,
|
|
542
|
+
outcomeSource: file,
|
|
543
|
+
resource: {
|
|
544
|
+
source: file,
|
|
545
|
+
async read() {
|
|
546
|
+
return [{ type: "text", text: await readFile(file, "utf8") }];
|
|
547
|
+
},
|
|
540
548
|
},
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
|
|
549
|
+
resolvedBy: "filesystem",
|
|
550
|
+
existed: true,
|
|
551
|
+
before: createTextDocument(file, text),
|
|
552
|
+
requestedText: text,
|
|
553
|
+
context,
|
|
554
|
+
presenters: [...presenters],
|
|
555
|
+
postEditHandlers: [...postEditHandlers.values()],
|
|
556
|
+
editCompletionListeners: [...editCompletionListeners],
|
|
557
|
+
result: undefined,
|
|
558
|
+
});
|
|
559
|
+
},
|
|
560
|
+
context.signal,
|
|
561
|
+
resourceAccesses(source, context.cwd, "write"),
|
|
562
|
+
);
|
|
563
|
+
},
|
|
564
|
+
enqueueFileOperation(action, signal, scope) {
|
|
565
|
+
const accesses =
|
|
566
|
+
scope === undefined
|
|
567
|
+
? undefined
|
|
568
|
+
: Promise.all(
|
|
569
|
+
scope.sources.map((source) => resourceAccesses(source, scope.cwd, "write")),
|
|
570
|
+
).then((sets) => sets.flat());
|
|
571
|
+
return scheduler.run(accesses, action, signal, {
|
|
572
|
+
allowNestedWrites: scope?.allowNestedEdits === true,
|
|
573
|
+
});
|
|
553
574
|
},
|
|
554
|
-
enqueueFileOperation: enqueueMutation,
|
|
555
575
|
addAnchorResolver(registration): void {
|
|
556
576
|
if (!isTextAnchorResolverRegistration(registration)) {
|
|
557
577
|
throw new TypeError("Invalid text anchor resolver");
|
|
@@ -581,9 +601,6 @@ export function createTextEditorCore(
|
|
|
581
601
|
editCompletionListeners.add(listener);
|
|
582
602
|
return () => editCompletionListeners.delete(listener);
|
|
583
603
|
},
|
|
584
|
-
getScriptIndexOperation(name) {
|
|
585
|
-
return scriptIndexOperations.get(name);
|
|
586
|
-
},
|
|
587
604
|
getSemanticMutationHandler(tool, input): TextSemanticMutationHandler | undefined {
|
|
588
605
|
const matches = semanticHandlers.filter(
|
|
589
606
|
(registered) => registered.tool === tool && registered.handler.matches(input),
|
|
@@ -644,12 +661,13 @@ export function createTextEditorCore(
|
|
|
644
661
|
(left.registration.priority ?? 0) - (right.registration.priority ?? 0) ||
|
|
645
662
|
left.order - right.order,
|
|
646
663
|
);
|
|
664
|
+
const scoped = scopedResolvers([source], context, resolverSnapshot);
|
|
647
665
|
return enqueueMutation(
|
|
648
666
|
() =>
|
|
649
667
|
editTextResource(
|
|
650
668
|
source,
|
|
651
669
|
context,
|
|
652
|
-
|
|
670
|
+
scoped.resolvers,
|
|
653
671
|
anchorRegistry.snapshot(),
|
|
654
672
|
presenterSnapshot,
|
|
655
673
|
[...postEditHandlers.values()],
|
|
@@ -657,6 +675,7 @@ export function createTextEditorCore(
|
|
|
657
675
|
operation,
|
|
658
676
|
),
|
|
659
677
|
context.signal,
|
|
678
|
+
scoped.accesses,
|
|
660
679
|
);
|
|
661
680
|
},
|
|
662
681
|
editTexts<Result>(
|
|
@@ -675,12 +694,17 @@ export function createTextEditorCore(
|
|
|
675
694
|
(left.registration.priority ?? 0) - (right.registration.priority ?? 0) ||
|
|
676
695
|
left.order - right.order,
|
|
677
696
|
);
|
|
697
|
+
const scoped = scopedResolvers(
|
|
698
|
+
sources.map((request) => request.source),
|
|
699
|
+
context,
|
|
700
|
+
resolverSnapshot,
|
|
701
|
+
);
|
|
678
702
|
return enqueueMutation(
|
|
679
703
|
() =>
|
|
680
704
|
editTextResources(
|
|
681
705
|
sources,
|
|
682
706
|
context,
|
|
683
|
-
|
|
707
|
+
scoped.resolvers,
|
|
684
708
|
anchorRegistry.snapshot(),
|
|
685
709
|
presenterSnapshot,
|
|
686
710
|
[...postEditHandlers.values()],
|
|
@@ -689,18 +713,30 @@ export function createTextEditorCore(
|
|
|
689
713
|
operation,
|
|
690
714
|
),
|
|
691
715
|
context.signal,
|
|
716
|
+
scoped.accesses,
|
|
692
717
|
);
|
|
693
718
|
},
|
|
694
719
|
previewTexts(sources, context, operation): Promise<TextMutationPreviewOutcome> {
|
|
695
720
|
const resolverSnapshot = [...resolvers].sort(
|
|
696
721
|
(left, right) => left.priority - right.priority || left.order - right.order,
|
|
697
722
|
);
|
|
698
|
-
|
|
699
|
-
sources,
|
|
723
|
+
const scoped = scopedResolvers(
|
|
724
|
+
sources.map((request) => request.source),
|
|
700
725
|
context,
|
|
701
726
|
resolverSnapshot,
|
|
702
|
-
|
|
703
|
-
|
|
727
|
+
"read",
|
|
728
|
+
);
|
|
729
|
+
return scheduler.run(
|
|
730
|
+
scoped.accesses,
|
|
731
|
+
() =>
|
|
732
|
+
previewTextResources(
|
|
733
|
+
sources,
|
|
734
|
+
context,
|
|
735
|
+
scoped.resolvers,
|
|
736
|
+
anchorRegistry.snapshot(),
|
|
737
|
+
operation,
|
|
738
|
+
),
|
|
739
|
+
context.signal,
|
|
704
740
|
);
|
|
705
741
|
},
|
|
706
742
|
async executeEdit<Input, Result>(
|
|
@@ -792,7 +828,6 @@ export function createTextEditorCore(
|
|
|
792
828
|
(listener) => core.onDidEdit(listener),
|
|
793
829
|
(request) => previewTextMutation(core, request),
|
|
794
830
|
(section) => recoverySection(projectConfig, section),
|
|
795
|
-
(transaction, signal) => core.restoreApplyUndo(transaction, signal),
|
|
796
831
|
);
|
|
797
832
|
const ready = registrationQueue.then(async () => {
|
|
798
833
|
try {
|
|
@@ -1003,6 +1038,12 @@ async function previewTextResources(
|
|
|
1003
1038
|
return { kind: "failed", reason: outcome.failure.message };
|
|
1004
1039
|
}
|
|
1005
1040
|
|
|
1041
|
+
if (
|
|
1042
|
+
request.expectedExistence !== undefined &&
|
|
1043
|
+
request.expectedExistence !== outcome.existed
|
|
1044
|
+
) {
|
|
1045
|
+
throw new Error(`Snapshot source ${source} was created or removed before the edit batch.`);
|
|
1046
|
+
}
|
|
1006
1047
|
prepared.set(source, outcome);
|
|
1007
1048
|
}
|
|
1008
1049
|
|
|
@@ -1031,6 +1072,7 @@ async function previewTextResources(
|
|
|
1031
1072
|
path: source,
|
|
1032
1073
|
existed: item.existed,
|
|
1033
1074
|
beforeRanges: applied.changes.map(({ fromBefore: from, toBefore: to }) => ({ from, to })),
|
|
1075
|
+
resolvedBy: item.resolverId,
|
|
1034
1076
|
...(item.resource.link !== undefined && { link: item.resource.link }),
|
|
1035
1077
|
beforeContent: item.before.content,
|
|
1036
1078
|
afterContent: applied.content,
|
|
@@ -1081,21 +1123,31 @@ async function editTextResources<Result>(
|
|
|
1081
1123
|
|
|
1082
1124
|
const prepared = new Map<string, PreparedTextResource>();
|
|
1083
1125
|
|
|
1084
|
-
|
|
1126
|
+
// Settle every read before releasing the transaction's resource reservations.
|
|
1127
|
+
const reads = await Promise.allSettled(
|
|
1128
|
+
sources.map((source) => {
|
|
1129
|
+
const request = requiredValue(requestBySource.get(source));
|
|
1130
|
+
return prepareTextResource(
|
|
1131
|
+
source,
|
|
1132
|
+
request.read,
|
|
1133
|
+
request.allowReadFailure ?? false,
|
|
1134
|
+
request.requireWrite ?? true,
|
|
1135
|
+
context,
|
|
1136
|
+
resolvers,
|
|
1137
|
+
);
|
|
1138
|
+
}),
|
|
1139
|
+
);
|
|
1140
|
+
for (const [index, read] of reads.entries()) {
|
|
1141
|
+
if (read.status === "rejected") throw read.reason;
|
|
1142
|
+
const source = requiredValue(sources[index]);
|
|
1085
1143
|
const request = requiredValue(requestBySource.get(source));
|
|
1086
|
-
const outcome =
|
|
1087
|
-
source,
|
|
1088
|
-
request.read,
|
|
1089
|
-
request.allowReadFailure ?? false,
|
|
1090
|
-
request.requireWrite ?? true,
|
|
1091
|
-
context,
|
|
1092
|
-
resolvers,
|
|
1093
|
-
);
|
|
1094
|
-
|
|
1144
|
+
const outcome = read.value;
|
|
1095
1145
|
if ("failure" in outcome) {
|
|
1096
1146
|
return { kind: "failed", failure: outcome.failure, completed: [] };
|
|
1097
1147
|
}
|
|
1098
|
-
|
|
1148
|
+
if (request.expectedExistence !== undefined && request.expectedExistence !== outcome.existed) {
|
|
1149
|
+
throw new Error(`Snapshot source ${source} was created or removed before the edit batch.`);
|
|
1150
|
+
}
|
|
1099
1151
|
prepared.set(source, outcome);
|
|
1100
1152
|
}
|
|
1101
1153
|
|
|
@@ -1142,6 +1194,36 @@ async function editTextResources<Result>(
|
|
|
1142
1194
|
}
|
|
1143
1195
|
}
|
|
1144
1196
|
|
|
1197
|
+
if (mutation.changes.size > 1) {
|
|
1198
|
+
const identities = await Promise.all(
|
|
1199
|
+
[...mutation.changes.keys()].map(async (source) => ({
|
|
1200
|
+
source,
|
|
1201
|
+
accesses: await resourceAccesses(
|
|
1202
|
+
requiredValue(prepared.get(source)).resource.source,
|
|
1203
|
+
context.cwd,
|
|
1204
|
+
"write",
|
|
1205
|
+
),
|
|
1206
|
+
})),
|
|
1207
|
+
);
|
|
1208
|
+
const owners = new Map<string, string>();
|
|
1209
|
+
for (const { source, accesses } of identities) {
|
|
1210
|
+
for (const { resource } of accesses) {
|
|
1211
|
+
const owner = owners.get(resource);
|
|
1212
|
+
if (owner !== undefined && owner !== source) {
|
|
1213
|
+
return {
|
|
1214
|
+
kind: "failed",
|
|
1215
|
+
failure: {
|
|
1216
|
+
code: "MUTATION_REJECTED",
|
|
1217
|
+
source,
|
|
1218
|
+
message: `Sources ${owner} and ${source} alias the same resource; use one source name for its edits.`,
|
|
1219
|
+
},
|
|
1220
|
+
completed: [],
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
owners.set(resource, source);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1145
1227
|
const applied = new Map<string, TextChangeResult>();
|
|
1146
1228
|
|
|
1147
1229
|
for (const [source, changes] of mutation.changes) {
|
|
@@ -1199,69 +1281,57 @@ async function editTextResources<Result>(
|
|
|
1199
1281
|
}
|
|
1200
1282
|
}
|
|
1201
1283
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
for (const source of sources) {
|
|
1284
|
+
// A guard may finish after cancellation; reject before the first write.
|
|
1285
|
+
context.signal?.throwIfAborted();
|
|
1286
|
+
const written = sources.filter((source) => {
|
|
1207
1287
|
const text = applied.get(source)?.content;
|
|
1208
1288
|
const item = requiredValue(prepared.get(source));
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
if (!isAgentContent(finalContent)) {
|
|
1217
|
-
return {
|
|
1218
|
-
kind: "failed",
|
|
1219
|
-
failure: {
|
|
1220
|
-
code: "INVALID_WRITE_CONTENT",
|
|
1221
|
-
source,
|
|
1222
|
-
message: `Text edit for ${source} produced invalid content`,
|
|
1223
|
-
},
|
|
1224
|
-
completed,
|
|
1225
|
-
};
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
try {
|
|
1289
|
+
return text !== undefined && (!item.existed || text !== item.before.content);
|
|
1290
|
+
});
|
|
1291
|
+
const writes = await Promise.allSettled(
|
|
1292
|
+
written.map(async (source) => {
|
|
1293
|
+
const item = requiredValue(prepared.get(source));
|
|
1294
|
+
const text = requiredValue(applied.get(source)).content;
|
|
1229
1295
|
await requiredValue(item.resource.write)(
|
|
1230
|
-
|
|
1296
|
+
[{ type: "text", text }],
|
|
1231
1297
|
context.signal === undefined ? {} : { signal: context.signal },
|
|
1232
1298
|
);
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1299
|
+
}),
|
|
1300
|
+
);
|
|
1301
|
+
const failedIndex = writes.findIndex((result) => result.status === "rejected");
|
|
1302
|
+
if (failedIndex !== -1) {
|
|
1303
|
+
const source = requiredValue(written[failedIndex]);
|
|
1304
|
+
const item = requiredValue(prepared.get(source));
|
|
1305
|
+
const failure = requiredValue(writes[failedIndex]);
|
|
1306
|
+
const rollbackFailures: string[] = [];
|
|
1307
|
+
// All attempts have settled; even a rejected write may have changed its resource.
|
|
1308
|
+
for (const writtenSource of [...written].reverse()) {
|
|
1309
|
+
const writtenItem = requiredValue(prepared.get(writtenSource));
|
|
1310
|
+
try {
|
|
1311
|
+
await requiredValue(writtenItem.resource.write)(
|
|
1312
|
+
[{ type: "text", text: writtenItem.before.content }],
|
|
1313
|
+
{},
|
|
1314
|
+
);
|
|
1315
|
+
} catch {
|
|
1316
|
+
rollbackFailures.push(writtenSource);
|
|
1245
1317
|
}
|
|
1246
|
-
return {
|
|
1247
|
-
kind: "failed",
|
|
1248
|
-
failure: {
|
|
1249
|
-
code: "WRITE_FAILED",
|
|
1250
|
-
source,
|
|
1251
|
-
resolverId: item.resolverId,
|
|
1252
|
-
message:
|
|
1253
|
-
rollbackFailures.length === 0
|
|
1254
|
-
? `Unable to write ${source}; completed writes were rolled back`
|
|
1255
|
-
: `Unable to write ${source}; rollback failed for ${rollbackFailures.join(", ")}`,
|
|
1256
|
-
cause: error,
|
|
1257
|
-
},
|
|
1258
|
-
completed: rollbackFailures,
|
|
1259
|
-
};
|
|
1260
1318
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1319
|
+
return {
|
|
1320
|
+
kind: "failed",
|
|
1321
|
+
failure: {
|
|
1322
|
+
code: "WRITE_FAILED",
|
|
1323
|
+
source,
|
|
1324
|
+
resolverId: item.resolverId,
|
|
1325
|
+
message:
|
|
1326
|
+
rollbackFailures.length === 0
|
|
1327
|
+
? `Unable to write ${source}; completed writes were rolled back`
|
|
1328
|
+
: `Unable to write ${source}; rollback failed for ${rollbackFailures.join(", ")}`,
|
|
1329
|
+
cause: failure.status === "rejected" ? failure.reason : undefined,
|
|
1330
|
+
},
|
|
1331
|
+
completed: rollbackFailures,
|
|
1332
|
+
};
|
|
1264
1333
|
}
|
|
1334
|
+
const outcomes: Exclude<TextResourceEditOutcome<unknown>, { readonly kind: "failed" }>[] = [];
|
|
1265
1335
|
|
|
1266
1336
|
await collectPostEditNotifications(async () => {
|
|
1267
1337
|
for (const source of written) {
|
|
@@ -1867,7 +1937,6 @@ function createPluginContributionController(
|
|
|
1867
1937
|
onDidEdit: (listener: TextEditCompletionListener) => () => void,
|
|
1868
1938
|
previewMutation: (request: TextMutationPreviewRequest) => Promise<TextMutationPreviewOutcome>,
|
|
1869
1939
|
recoveryConfig: (section: string) => TextEditorRecoveryConfigSection,
|
|
1870
|
-
restoreApplyUndo: TextEditorPluginApi["restoreApplyUndo"],
|
|
1871
1940
|
): PluginContributionController {
|
|
1872
1941
|
const setupDraft: PluginContributionDraft = {
|
|
1873
1942
|
resolvers: [],
|
|
@@ -1883,7 +1952,6 @@ function createPluginContributionController(
|
|
|
1883
1952
|
editCompletionListeners: [],
|
|
1884
1953
|
mutationGuards: [],
|
|
1885
1954
|
toolRenderers: [],
|
|
1886
|
-
scriptIndexOperations: [],
|
|
1887
1955
|
};
|
|
1888
1956
|
let state: "active" | "closed" | "setup" = "setup";
|
|
1889
1957
|
const assertAvailable = (): void => {
|
|
@@ -1965,7 +2033,6 @@ function createPluginContributionController(
|
|
|
1965
2033
|
},
|
|
1966
2034
|
});
|
|
1967
2035
|
const api: TextEditorPluginApi = {
|
|
1968
|
-
restoreApplyUndo,
|
|
1969
2036
|
addMutationTool(registration): void {
|
|
1970
2037
|
assertAvailable();
|
|
1971
2038
|
assertTextMutationToolRegistration(registration);
|
|
@@ -1985,22 +2052,6 @@ function createPluginContributionController(
|
|
|
1985
2052
|
mutationTools: [registration],
|
|
1986
2053
|
});
|
|
1987
2054
|
},
|
|
1988
|
-
addScriptIndexOperation(operation): void {
|
|
1989
|
-
assertAvailable();
|
|
1990
|
-
if (state === "setup") {
|
|
1991
|
-
requiredValue(setupDraft.scriptIndexOperations).push(operation);
|
|
1992
|
-
return;
|
|
1993
|
-
}
|
|
1994
|
-
registerContributions({
|
|
1995
|
-
resolvers: [],
|
|
1996
|
-
anchorResolvers: [],
|
|
1997
|
-
handlers: [],
|
|
1998
|
-
promptContributions: [],
|
|
1999
|
-
writablePromptContributions: [],
|
|
2000
|
-
tools: [],
|
|
2001
|
-
scriptIndexOperations: [operation],
|
|
2002
|
-
});
|
|
2003
|
-
},
|
|
2004
2055
|
addToolRenderer(registration): void {
|
|
2005
2056
|
assertAvailable();
|
|
2006
2057
|
|