pi-agent-ide 0.2.1 → 0.3.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 +56 -0
- package/README.md +12 -8
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/{chunk-MTTKFJV6.js → chunk-GUTQ3PWL.js} +1 -1
- package/dist/chunk-HGPUI7F3.js +1 -0
- package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
- package/dist/chunk-ITSNK5YG.js +7 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/chunk-M5L42DWE.js +7 -0
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/chunk-TPIHQYK2.js +14 -0
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZM4L5AGN.js} +1 -1
- package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +12 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +9 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +18 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -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 +123 -1
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +3 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -13
- package/docs/configuration.md +57 -11
- package/docs/extensions.md +4 -2
- package/docs/tools.md +7 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- 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 +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +11 -15
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +22 -10
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +49 -17
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +127 -20
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- 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-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +32 -28
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/node_modules/pi-agent-search/src/api/search.ts +55 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +8 -27
- package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
- package/node_modules/pi-agent-search-text/index.ts +82 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +112 -24
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text/src/text-document.ts +5 -0
- package/node_modules/pi-agent-text/src/text-target.ts +4 -0
- 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-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/node_modules/pi-agent-text-editor/index.ts +1 -3
- package/node_modules/pi-agent-text-editor/package.json +34 -24
- package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +93 -2
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +38 -38
- package/src/api/plugin-protocol.ts +12 -2
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +77 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +138 -67
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +142 -0
- package/src/core/diagnostic-store.ts +96 -23
- package/src/core/extension.ts +45 -22
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -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-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-web/index.ts +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +32 -28
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -33
- 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/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +112 -24
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
- package/src/extensions/pi-agent-search/src/core/extension.ts +8 -27
- package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -3
- package/src/extensions/pi-agent-text-editor/index.ts +1 -3
- package/src/extensions/pi-agent-text-editor/package.json +34 -24
- 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-line-hash/index.ts +2 -6
- 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-anchor-line-hash/src/read-handler.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +93 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- 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/runtime/entry-69.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +11 -15
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +49 -17
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +127 -20
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/src/post-edit/gate.ts +57 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2SKAED2I.js +0 -2
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-2ZMYT6ZC.js +0 -1
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KNMWCDDK.js +0 -7
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/chunk-ZIHEF6K3.js +0 -3
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { lstat, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { deferPostEdit, collectPostEditNotifications } from "#src/core/post-edit-scope.js";
|
|
1
4
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
5
|
import {
|
|
3
6
|
isAgentContent,
|
|
@@ -39,6 +42,7 @@ import {
|
|
|
39
42
|
isTextAnchorResolverRegistration,
|
|
40
43
|
isTextEditorToolId,
|
|
41
44
|
type PromptDescriptionSource,
|
|
45
|
+
type ScriptIndexOperation,
|
|
42
46
|
type ResourceResolverRegistration,
|
|
43
47
|
TEXT_EDITOR_API_VERSION,
|
|
44
48
|
TEXT_EDITOR_PROTOCOL,
|
|
@@ -156,6 +160,7 @@ interface PluginContributionDraft {
|
|
|
156
160
|
readonly editCompletionListeners?: TextEditCompletionListener[];
|
|
157
161
|
readonly mutationGuards?: TextMutationGuardRegistration[];
|
|
158
162
|
readonly toolRenderers?: TextEditorToolRendererRegistration[];
|
|
163
|
+
readonly scriptIndexOperations?: ScriptIndexOperation[];
|
|
159
164
|
}
|
|
160
165
|
|
|
161
166
|
interface PluginContributionController {
|
|
@@ -261,6 +266,10 @@ export interface TextResourcesEditContext
|
|
|
261
266
|
extends ResourceResolverContext, TextMutationGuardContext {}
|
|
262
267
|
|
|
263
268
|
export interface TextEditorCore {
|
|
269
|
+
/** Finalize a surviving local text file after a whole-file operation; binary files are untouched. */
|
|
270
|
+
postProcessFile(source: string, context: ResourceResolverContext): Promise<void>;
|
|
271
|
+
/** Serialize whole-file effects with text edits; the action must not enqueue another edit. */
|
|
272
|
+
enqueueFileOperation<T>(action: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
264
273
|
inspectTextAnchors(request: TextAnchorInspectionRequest): Promise<TextAnchorInspectionOutcome>;
|
|
265
274
|
addAnchorResolver(registration: TextAnchorResolverRegistration): void;
|
|
266
275
|
resolveTextAnchorResources(
|
|
@@ -305,11 +314,13 @@ export interface TextEditorCore {
|
|
|
305
314
|
onMutationTool(listener: TextMutationToolListener): () => void;
|
|
306
315
|
onDidEdit(listener: TextEditCompletionListener): () => void;
|
|
307
316
|
getToolRenderer(tool: TextEditorToolId): TextEditorToolRendererRegistration | undefined;
|
|
317
|
+
/** Return a configured index operation for the Apply host. */
|
|
318
|
+
getScriptIndexOperation(name: string): ScriptIndexOperation | undefined;
|
|
308
319
|
registerPlugin(plugin: TextEditorPlugin): Promise<void>;
|
|
309
320
|
registerPostEditHandler(registration: TextPostEditHandlerRegistration): () => void;
|
|
310
321
|
registerTool(tool: TextEditorToolId): void;
|
|
311
322
|
waitForPendingPlugins(): Promise<void>;
|
|
312
|
-
renderGeneralPromptGuideline(): string | undefined;
|
|
323
|
+
renderGeneralPromptGuideline(kinds?: ReadonlySet<string>): string | undefined;
|
|
313
324
|
/** Returns the configured number of lines around recovery candidates. */
|
|
314
325
|
recoveryContextLines(): number;
|
|
315
326
|
renderToolPromptGuideline(tool: TextEditorToolId): string | undefined;
|
|
@@ -337,7 +348,22 @@ export function createTextEditorCore(
|
|
|
337
348
|
const editCompletionListeners = new Set<TextEditCompletionListener>();
|
|
338
349
|
const mutationGuards: TextMutationGuardRegistration[] = [];
|
|
339
350
|
const toolRenderers = new Map<TextEditorToolId, TextEditorToolRendererRegistration>();
|
|
351
|
+
const scriptIndexOperations = new Map<string, ScriptIndexOperation>();
|
|
340
352
|
let registrationQueue = Promise.resolve();
|
|
353
|
+
// One core owns all IDE mutations, including ordinary tools and Apply. Queue the full
|
|
354
|
+
// read-modify-write window so aliases and multi-resource edits cannot lose updates.
|
|
355
|
+
let mutationTail: Promise<void> = Promise.resolve();
|
|
356
|
+
const enqueueMutation = <T>(action: () => Promise<T>, signal?: AbortSignal): Promise<T> => {
|
|
357
|
+
const pending = mutationTail.then(() => {
|
|
358
|
+
signal?.throwIfAborted();
|
|
359
|
+
return action();
|
|
360
|
+
});
|
|
361
|
+
mutationTail = pending.then(
|
|
362
|
+
() => undefined,
|
|
363
|
+
() => undefined,
|
|
364
|
+
);
|
|
365
|
+
return pending;
|
|
366
|
+
};
|
|
341
367
|
const registerContributions = (draft: PluginContributionDraft): void => {
|
|
342
368
|
validateContributionDraft(
|
|
343
369
|
draft,
|
|
@@ -348,6 +374,17 @@ export function createTextEditorCore(
|
|
|
348
374
|
);
|
|
349
375
|
|
|
350
376
|
const incomingMutationNames = new Set<string>();
|
|
377
|
+
const incomingIndexNames = new Set<string>();
|
|
378
|
+
for (const operation of draft.scriptIndexOperations ?? []) {
|
|
379
|
+
if (
|
|
380
|
+
!["stage", "unstage"].includes(operation.name) ||
|
|
381
|
+
typeof operation.execute !== "function" ||
|
|
382
|
+
scriptIndexOperations.has(operation.name) ||
|
|
383
|
+
incomingIndexNames.has(operation.name)
|
|
384
|
+
)
|
|
385
|
+
throw new Error(`Invalid or duplicate script index operation ${operation.name}`);
|
|
386
|
+
incomingIndexNames.add(operation.name);
|
|
387
|
+
}
|
|
351
388
|
|
|
352
389
|
for (const registration of draft.mutationTools ?? []) {
|
|
353
390
|
assertTextMutationToolRegistration(registration);
|
|
@@ -400,6 +437,8 @@ export function createTextEditorCore(
|
|
|
400
437
|
}
|
|
401
438
|
|
|
402
439
|
handlers.push(...draft.handlers);
|
|
440
|
+
for (const operation of draft.scriptIndexOperations ?? [])
|
|
441
|
+
scriptIndexOperations.set(operation.name, operation);
|
|
403
442
|
mutationGuards.push(...(draft.mutationGuards ?? []));
|
|
404
443
|
promptContributions.push(...draft.promptContributions);
|
|
405
444
|
writablePromptContributions.push(...draft.writablePromptContributions);
|
|
@@ -435,6 +474,36 @@ export function createTextEditorCore(
|
|
|
435
474
|
};
|
|
436
475
|
|
|
437
476
|
const core: TextEditorCore = {
|
|
477
|
+
async postProcessFile(source, context) {
|
|
478
|
+
await enqueueMutation(async () => {
|
|
479
|
+
const file = path.resolve(context.cwd, source);
|
|
480
|
+
const stat = await lstat(file).catch(() => undefined);
|
|
481
|
+
if (!stat?.isFile() || stat.isSymbolicLink()) return;
|
|
482
|
+
const bytes = await readFile(file);
|
|
483
|
+
const text = bytes.toString("utf8");
|
|
484
|
+
if (bytes.includes(0) || !Buffer.from(text).equals(bytes)) return;
|
|
485
|
+
await finalizeTextResource({
|
|
486
|
+
requestedSource: file,
|
|
487
|
+
outcomeSource: file,
|
|
488
|
+
resource: {
|
|
489
|
+
source: file,
|
|
490
|
+
async read() {
|
|
491
|
+
return [{ type: "text", text: await readFile(file, "utf8") }];
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
resolvedBy: "filesystem",
|
|
495
|
+
existed: true,
|
|
496
|
+
before: createTextDocument(file, text),
|
|
497
|
+
requestedText: text,
|
|
498
|
+
context,
|
|
499
|
+
presenters: [...presenters],
|
|
500
|
+
postEditHandlers: [...postEditHandlers.values()],
|
|
501
|
+
editCompletionListeners: [...editCompletionListeners],
|
|
502
|
+
result: undefined,
|
|
503
|
+
});
|
|
504
|
+
}, context.signal);
|
|
505
|
+
},
|
|
506
|
+
enqueueFileOperation: enqueueMutation,
|
|
438
507
|
addAnchorResolver(registration): void {
|
|
439
508
|
if (!isTextAnchorResolverRegistration(registration)) {
|
|
440
509
|
throw new TypeError("Invalid text anchor resolver");
|
|
@@ -464,6 +533,9 @@ export function createTextEditorCore(
|
|
|
464
533
|
editCompletionListeners.add(listener);
|
|
465
534
|
return () => editCompletionListeners.delete(listener);
|
|
466
535
|
},
|
|
536
|
+
getScriptIndexOperation(name) {
|
|
537
|
+
return scriptIndexOperations.get(name);
|
|
538
|
+
},
|
|
467
539
|
getToolRenderer(tool): TextEditorToolRendererRegistration | undefined {
|
|
468
540
|
return toolRenderers.get(tool);
|
|
469
541
|
},
|
|
@@ -509,15 +581,19 @@ export function createTextEditorCore(
|
|
|
509
581
|
(left.registration.priority ?? 0) - (right.registration.priority ?? 0) ||
|
|
510
582
|
left.order - right.order,
|
|
511
583
|
);
|
|
512
|
-
return
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
584
|
+
return enqueueMutation(
|
|
585
|
+
() =>
|
|
586
|
+
editTextResource(
|
|
587
|
+
source,
|
|
588
|
+
context,
|
|
589
|
+
resolverSnapshot,
|
|
590
|
+
anchorRegistry.snapshot(),
|
|
591
|
+
presenterSnapshot,
|
|
592
|
+
[...postEditHandlers.values()],
|
|
593
|
+
[...editCompletionListeners],
|
|
594
|
+
operation,
|
|
595
|
+
),
|
|
596
|
+
context.signal,
|
|
521
597
|
);
|
|
522
598
|
},
|
|
523
599
|
editTexts<Result>(
|
|
@@ -536,16 +612,20 @@ export function createTextEditorCore(
|
|
|
536
612
|
(left.registration.priority ?? 0) - (right.registration.priority ?? 0) ||
|
|
537
613
|
left.order - right.order,
|
|
538
614
|
);
|
|
539
|
-
return
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
615
|
+
return enqueueMutation(
|
|
616
|
+
() =>
|
|
617
|
+
editTextResources(
|
|
618
|
+
sources,
|
|
619
|
+
context,
|
|
620
|
+
resolverSnapshot,
|
|
621
|
+
anchorRegistry.snapshot(),
|
|
622
|
+
presenterSnapshot,
|
|
623
|
+
[...postEditHandlers.values()],
|
|
624
|
+
[...editCompletionListeners],
|
|
625
|
+
[...mutationGuards],
|
|
626
|
+
operation,
|
|
627
|
+
),
|
|
628
|
+
context.signal,
|
|
549
629
|
);
|
|
550
630
|
},
|
|
551
631
|
previewTexts(sources, context, operation): Promise<TextMutationPreviewOutcome> {
|
|
@@ -687,7 +767,7 @@ export function createTextEditorCore(
|
|
|
687
767
|
recoveryContextLines(): number {
|
|
688
768
|
return projectConfig.contextLines;
|
|
689
769
|
},
|
|
690
|
-
renderGeneralPromptGuideline(): string | undefined {
|
|
770
|
+
renderGeneralPromptGuideline(kinds?: ReadonlySet<string>): string | undefined {
|
|
691
771
|
const sections: string[] = [];
|
|
692
772
|
const writableEntries: string[] = [];
|
|
693
773
|
|
|
@@ -717,7 +797,7 @@ export function createTextEditorCore(
|
|
|
717
797
|
);
|
|
718
798
|
}
|
|
719
799
|
|
|
720
|
-
const anchorSection = anchorRegistry.renderPromptSection();
|
|
800
|
+
const anchorSection = anchorRegistry.renderPromptSection(kinds);
|
|
721
801
|
|
|
722
802
|
if (anchorSection !== undefined) {
|
|
723
803
|
sections.push(anchorSection);
|
|
@@ -739,15 +819,11 @@ export function createTextEditorCore(
|
|
|
739
819
|
);
|
|
740
820
|
|
|
741
821
|
if (contribution !== undefined) {
|
|
742
|
-
entries.push(
|
|
822
|
+
entries.push(contribution.description);
|
|
743
823
|
}
|
|
744
824
|
}
|
|
745
825
|
|
|
746
|
-
return entries.length === 0
|
|
747
|
-
? undefined
|
|
748
|
-
: indentGuidelineContinuation(
|
|
749
|
-
[`${tool} supports these installed extensions:`, ...entries].join("\n"),
|
|
750
|
-
);
|
|
826
|
+
return entries.length === 0 ? undefined : entries.join("\n");
|
|
751
827
|
},
|
|
752
828
|
async waitForPendingPlugins(): Promise<void> {
|
|
753
829
|
await Promise.all(pendingPlugins);
|
|
@@ -885,7 +961,7 @@ async function previewTextResources(
|
|
|
885
961
|
const applied =
|
|
886
962
|
changes === undefined
|
|
887
963
|
? { content: item.before.content, changes: [] }
|
|
888
|
-
: applyTextChanges(item.before.content, changes);
|
|
964
|
+
: applyTextChanges(item.before.content, changes, !item.existed);
|
|
889
965
|
return {
|
|
890
966
|
path: source,
|
|
891
967
|
existed: item.existed,
|
|
@@ -990,7 +1066,7 @@ async function editTextResources<Result>(
|
|
|
990
1066
|
|
|
991
1067
|
for (const [source, changes] of mutation.changes) {
|
|
992
1068
|
const item = requiredValue(prepared.get(source));
|
|
993
|
-
applied.set(source, applyTextChanges(item.before.content, changes));
|
|
1069
|
+
applied.set(source, applyTextChanges(item.before.content, changes, !item.existed));
|
|
994
1070
|
}
|
|
995
1071
|
|
|
996
1072
|
const plan: TextMutationPlan = {
|
|
@@ -998,7 +1074,7 @@ async function editTextResources<Result>(
|
|
|
998
1074
|
const item = requiredValue(prepared.get(source));
|
|
999
1075
|
const result = applied.get(source);
|
|
1000
1076
|
|
|
1001
|
-
return result === undefined || result.content === item.before.content
|
|
1077
|
+
return result === undefined || (item.existed && result.content === item.before.content)
|
|
1002
1078
|
? []
|
|
1003
1079
|
: [
|
|
1004
1080
|
{
|
|
@@ -1051,7 +1127,7 @@ async function editTextResources<Result>(
|
|
|
1051
1127
|
const text = applied.get(source)?.content;
|
|
1052
1128
|
const item = requiredValue(prepared.get(source));
|
|
1053
1129
|
|
|
1054
|
-
if (text === undefined || text === item.before.content) {
|
|
1130
|
+
if (text === undefined || (item.existed && text === item.before.content)) {
|
|
1055
1131
|
continue;
|
|
1056
1132
|
}
|
|
1057
1133
|
|
|
@@ -1107,27 +1183,28 @@ async function editTextResources<Result>(
|
|
|
1107
1183
|
completed.push(source);
|
|
1108
1184
|
}
|
|
1109
1185
|
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1186
|
+
await collectPostEditNotifications(async () => {
|
|
1187
|
+
for (const source of written) {
|
|
1188
|
+
const text = requiredValue(applied.get(source)).content;
|
|
1189
|
+
const item = requiredValue(prepared.get(source));
|
|
1190
|
+
outcomes.push(
|
|
1191
|
+
await finalizeTextResource({
|
|
1192
|
+
requestedSource: item.requestedSource,
|
|
1193
|
+
outcomeSource: item.requestedSource,
|
|
1194
|
+
resource: item.resource,
|
|
1195
|
+
resolvedBy: item.resolverId,
|
|
1196
|
+
existed: item.existed,
|
|
1197
|
+
before: item.before,
|
|
1198
|
+
requestedText: text,
|
|
1199
|
+
context,
|
|
1200
|
+
presenters,
|
|
1201
|
+
postEditHandlers,
|
|
1202
|
+
editCompletionListeners,
|
|
1203
|
+
result: mutation.result,
|
|
1204
|
+
}),
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1131
1208
|
return { kind: "completed", resources: outcomes, result: mutation.result };
|
|
1132
1209
|
}
|
|
1133
1210
|
|
|
@@ -1257,6 +1334,7 @@ async function prepareTextResource(
|
|
|
1257
1334
|
}
|
|
1258
1335
|
|
|
1259
1336
|
interface FinalizeTextResourceRequest<Result> {
|
|
1337
|
+
readonly postProcessingFinal?: boolean;
|
|
1260
1338
|
readonly requestedSource: string;
|
|
1261
1339
|
readonly outcomeSource: string;
|
|
1262
1340
|
readonly resource: Resource;
|
|
@@ -1274,6 +1352,26 @@ interface FinalizeTextResourceRequest<Result> {
|
|
|
1274
1352
|
async function finalizeTextResource<Result>(
|
|
1275
1353
|
request: FinalizeTextResourceRequest<Result>,
|
|
1276
1354
|
): Promise<Exclude<TextResourceEditOutcome<Result>, { readonly kind: "failed" }>> {
|
|
1355
|
+
if (request.postProcessingFinal && !request.context.signal?.aborted && request.resource.read) {
|
|
1356
|
+
const current = await request.resource.read(
|
|
1357
|
+
request.context.signal ? { signal: request.context.signal } : {},
|
|
1358
|
+
);
|
|
1359
|
+
if (
|
|
1360
|
+
!isAgentContent(current) ||
|
|
1361
|
+
current.length !== 1 ||
|
|
1362
|
+
current[0].type !== "text" ||
|
|
1363
|
+
current[0].text !== request.requestedText
|
|
1364
|
+
)
|
|
1365
|
+
throw Object.assign(
|
|
1366
|
+
new Error(`Resource changed before final post-processing: ${request.resource.source}`),
|
|
1367
|
+
{ code: "POST_EDIT_STALE" },
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
const deferred =
|
|
1371
|
+
!request.postProcessingFinal &&
|
|
1372
|
+
deferPostEdit(request.resource.source, () =>
|
|
1373
|
+
finalizeTextResource({ ...request, postProcessingFinal: true }),
|
|
1374
|
+
);
|
|
1277
1375
|
const requestedAfter = createTextDocument(request.resource.source, request.requestedText);
|
|
1278
1376
|
const transaction: TextPostEditTransaction = {
|
|
1279
1377
|
source: request.requestedSource,
|
|
@@ -1284,9 +1382,13 @@ async function finalizeTextResource<Result>(
|
|
|
1284
1382
|
requestedAfter,
|
|
1285
1383
|
...(request.context.signal !== undefined && { signal: request.context.signal }),
|
|
1286
1384
|
};
|
|
1287
|
-
const postEditContributions: TextPostEditContribution[] =
|
|
1385
|
+
const postEditContributions: TextPostEditContribution[] = deferred
|
|
1386
|
+
? [{ id: "post-edit-scope", data: { formatting: { status: "deferred" } } }]
|
|
1387
|
+
: [];
|
|
1288
1388
|
|
|
1289
|
-
for (const registration of request.
|
|
1389
|
+
for (const registration of deferred || request.context.signal?.aborted
|
|
1390
|
+
? []
|
|
1391
|
+
: request.postEditHandlers) {
|
|
1290
1392
|
try {
|
|
1291
1393
|
const data = await registration.handler(transaction);
|
|
1292
1394
|
|
|
@@ -1321,9 +1423,10 @@ async function finalizeTextResource<Result>(
|
|
|
1321
1423
|
resolvedBy: request.resolvedBy,
|
|
1322
1424
|
cwd: request.context.cwd,
|
|
1323
1425
|
existed: request.existed,
|
|
1324
|
-
before: request.before,
|
|
1426
|
+
before: request.postProcessingFinal ? requestedAfter : request.before,
|
|
1325
1427
|
after: finalAfter,
|
|
1326
1428
|
intent: request.context.intent ?? "edit",
|
|
1429
|
+
postProcessing: deferred ? "deferred" : request.postProcessingFinal ? "final" : "complete",
|
|
1327
1430
|
};
|
|
1328
1431
|
|
|
1329
1432
|
for (const listener of request.editCompletionListeners) {
|
|
@@ -1343,7 +1446,7 @@ async function finalizeTextResource<Result>(
|
|
|
1343
1446
|
...(request.context.signal !== undefined && { signal: request.context.signal }),
|
|
1344
1447
|
};
|
|
1345
1448
|
|
|
1346
|
-
for (const { registration } of request.presenters) {
|
|
1449
|
+
for (const { registration } of request.context.signal?.aborted ? [] : request.presenters) {
|
|
1347
1450
|
after = await registration.presenter.present(after, presentationContext);
|
|
1348
1451
|
}
|
|
1349
1452
|
|
|
@@ -1625,7 +1728,7 @@ function pluginFailure(
|
|
|
1625
1728
|
pluginId,
|
|
1626
1729
|
tool,
|
|
1627
1730
|
stage,
|
|
1628
|
-
message: `Plugin ${pluginId} failed during ${stage}`,
|
|
1731
|
+
message: `Plugin ${pluginId} failed during ${stage}: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
1629
1732
|
cause,
|
|
1630
1733
|
};
|
|
1631
1734
|
}
|
|
@@ -1674,6 +1777,7 @@ function createPluginContributionController(
|
|
|
1674
1777
|
editCompletionListeners: [],
|
|
1675
1778
|
mutationGuards: [],
|
|
1676
1779
|
toolRenderers: [],
|
|
1780
|
+
scriptIndexOperations: [],
|
|
1677
1781
|
};
|
|
1678
1782
|
let state: "active" | "closed" | "setup" = "setup";
|
|
1679
1783
|
const assertAvailable = (): void => {
|
|
@@ -1750,6 +1854,22 @@ function createPluginContributionController(
|
|
|
1750
1854
|
mutationTools: [registration],
|
|
1751
1855
|
});
|
|
1752
1856
|
},
|
|
1857
|
+
addScriptIndexOperation(operation): void {
|
|
1858
|
+
assertAvailable();
|
|
1859
|
+
if (state === "setup") {
|
|
1860
|
+
requiredValue(setupDraft.scriptIndexOperations).push(operation);
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
registerContributions({
|
|
1864
|
+
resolvers: [],
|
|
1865
|
+
anchorResolvers: [],
|
|
1866
|
+
handlers: [],
|
|
1867
|
+
promptContributions: [],
|
|
1868
|
+
writablePromptContributions: [],
|
|
1869
|
+
tools: [],
|
|
1870
|
+
scriptIndexOperations: [operation],
|
|
1871
|
+
});
|
|
1872
|
+
},
|
|
1753
1873
|
addToolRenderer(registration): void {
|
|
1754
1874
|
assertAvailable();
|
|
1755
1875
|
|