pi-agent-ide 0.2.2 → 0.4.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 +46 -0
- package/README.md +13 -8
- package/dist/chunk-3SE372WC.js +3 -0
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6DZA4CLO.js +4 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/chunk-7JYQMAEL.js +14 -0
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-DQF5QMJ2.js +1 -0
- package/dist/chunk-EJ5OACQM.js +1 -0
- package/dist/chunk-GFW5QPQV.js +2 -0
- package/dist/{chunk-LQYZG62K.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-J34VKQGJ.js +1 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/{chunk-WNMGUALD.js → chunk-TI5GMJ7Q.js} +1 -1
- package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
- package/dist/chunk-XSTHESNR.js +25 -0
- package/dist/{chunk-THSCUT2L.js → chunk-Y7ZMR4LT.js} +1 -1
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-ZXN3TWWW.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-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 +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +10 -5
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +3 -3
- package/dist/entry-32.js +6 -5
- 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 +12 -8
- 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 +4 -4
- package/dist/entry-46.js +10 -10
- 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 -59
- package/dist/entry-70.js +123 -4
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -29
- package/dist/entry-73.js +1 -2
- 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 -3
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -2
- package/docs/configuration.md +32 -11
- package/docs/tools.md +17 -0
- package/node_modules/pi-agent-doctor/package.json +1 -1
- 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/extension.ts +4 -3
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +21 -5
- 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 +4 -2
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
- 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 +46 -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 +126 -8
- 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 +18 -3
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
- 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-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- 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/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
- 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 +64 -14
- 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 +73 -44
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-resource/src/resource.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 +2 -23
- package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
- package/node_modules/pi-agent-search-text/index.ts +44 -4
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
- package/node_modules/pi-agent-text/package.json +2 -2
- 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/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/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- 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/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
- 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 +1 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
- 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-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
- 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-ui/package.json +2 -2
- 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-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 +41 -38
- package/src/api/plugin-protocol.ts +10 -2
- package/src/api/tool-config.ts +73 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +10 -15
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +59 -0
- package/src/composite/module-settings-store.ts +60 -0
- package/src/composite/module-settings.ts +162 -0
- package/src/composite/preferences.ts +26 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +103 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +51 -3
- package/src/core/diagnostic-store.ts +56 -5
- package/src/core/extension.ts +34 -33
- 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/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-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/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
- 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 +64 -14
- 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 +73 -44
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
- 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/search-session.ts +65 -25
- 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 +2 -23
- package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -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/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 +88 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
- 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/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- 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/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
- 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 +1 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
- 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-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/src/pi-agent-ide.ts +43 -8
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
- 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 +4 -2
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
- 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 +46 -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 +126 -8
- 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 +18 -3
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
- 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/plugins/pi-agent-ide-terminal/index.ts +34 -0
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +238 -0
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +461 -0
- package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +127 -0
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +159 -0
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +529 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +56 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +157 -0
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +66 -0
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +336 -0
- package/src/post-edit/gate.ts +15 -2
- package/dist/chunk-4U6KGABH.js +0 -1
- package/dist/chunk-6ACQQBUY.js +0 -7
- package/dist/chunk-GFWDXTOB.js +0 -4
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-JJVXUL5U.js +0 -2
- package/dist/chunk-KCEOTU5Z.js +0 -3
- package/dist/chunk-KVGQG43U.js +0 -1
- package/dist/chunk-QJFRAMK7.js +0 -2
- package/dist/chunk-RAZOACDD.js +0 -2
- package/dist/chunk-RIGRP3FD.js +0 -1
- package/dist/chunk-VCCMVQXU.js +0 -1
- package/dist/chunk-X6MPU7UO.js +0 -3
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/entry-80.js +0 -1
- 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-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
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts
CHANGED
|
@@ -106,9 +106,8 @@ function createRenderer(
|
|
|
106
106
|
return {
|
|
107
107
|
tool,
|
|
108
108
|
fallback: true,
|
|
109
|
-
...(tool === "write" && { renderShell: "self" as const }),
|
|
110
109
|
renderCall(arguments_, theme, context) {
|
|
111
|
-
const component = panel(context.lastComponent, theme,
|
|
110
|
+
const component = panel(context.lastComponent, theme, false);
|
|
112
111
|
const input = asInput(arguments_);
|
|
113
112
|
const state = context.state as RenderState;
|
|
114
113
|
state.registration = registration;
|
|
@@ -702,6 +701,14 @@ function mutationCallDetails(
|
|
|
702
701
|
});
|
|
703
702
|
}
|
|
704
703
|
|
|
704
|
+
/** Render a written call header without preparing previews or reading files. */
|
|
705
|
+
export function renderWrittenMutationHeader(
|
|
706
|
+
registration: AnyTextMutationToolRegistration,
|
|
707
|
+
input: Readonly<Record<string, unknown>>,
|
|
708
|
+
theme: Theme,
|
|
709
|
+
): string {
|
|
710
|
+
return renderHeader(registration, input, undefined, theme, undefined, false);
|
|
711
|
+
}
|
|
705
712
|
function renderHeader(
|
|
706
713
|
registration: AnyTextMutationToolRegistration,
|
|
707
714
|
input: Readonly<Record<string, unknown>>,
|
|
@@ -770,18 +777,19 @@ function renderAnchorRange(
|
|
|
770
777
|
if (field === undefined) {
|
|
771
778
|
return undefined;
|
|
772
779
|
}
|
|
773
|
-
const state = anchorRenderPatch?.[field];
|
|
774
|
-
if (state?.kind === "resolved") {
|
|
775
|
-
return singleLine(expanded ? state.full : state.compact);
|
|
776
|
-
}
|
|
777
|
-
if (state?.kind === "failed") {
|
|
778
|
-
return "selected range";
|
|
779
|
-
}
|
|
780
780
|
const raw = stringValue(input[field]);
|
|
781
|
-
if (raw
|
|
782
|
-
|
|
781
|
+
if (raw !== undefined) {
|
|
782
|
+
const displayed = singleLine(raw);
|
|
783
|
+
const structured =
|
|
784
|
+
/^(?:\d+#[0-9A-F]+|CHANGE#[0-9A-F]+|SEARCH#|scope-(?:begin|end)-|begin$|end$)/.test(raw);
|
|
785
|
+
return expanded || structured || displayed.length <= 100
|
|
786
|
+
? displayed
|
|
787
|
+
: `${displayed.slice(0, 60)}…${displayed.slice(-30)} (${raw.length} chars)`;
|
|
783
788
|
}
|
|
784
|
-
|
|
789
|
+
const state = anchorRenderPatch?.[field];
|
|
790
|
+
return state?.kind === "resolved"
|
|
791
|
+
? singleLine(expanded ? state.full : state.compact)
|
|
792
|
+
: undefined;
|
|
785
793
|
};
|
|
786
794
|
return range(renderField(fields.at(0)), renderField(fields.at(1)), theme);
|
|
787
795
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MutationDiffStatus } from "pi-agent-text-editor/api/mutation-result";
|
|
2
|
+
|
|
3
|
+
/** Aggregate successful formatting by unique file and tool; leave failures identifiable. */
|
|
4
|
+
export function summarizeStatuses(
|
|
5
|
+
resources: readonly {
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly diffStatuses?: readonly MutationDiffStatus[];
|
|
8
|
+
}[],
|
|
9
|
+
) {
|
|
10
|
+
const formatted = new Set<string>();
|
|
11
|
+
const formatters = new Set<string>();
|
|
12
|
+
const remaining = new Map<string, { status: MutationDiffStatus; paths: Set<string> }>();
|
|
13
|
+
for (const resource of resources)
|
|
14
|
+
for (const status of resource.diffStatuses ?? []) {
|
|
15
|
+
if (status.formatter !== undefined && status.tone === "success") {
|
|
16
|
+
formatted.add(resource.path);
|
|
17
|
+
formatters.add(status.formatter);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const key = JSON.stringify([status.text, status.tone]);
|
|
21
|
+
let group = remaining.get(key);
|
|
22
|
+
if (!group) {
|
|
23
|
+
group = { status, paths: new Set() };
|
|
24
|
+
remaining.set(key, group);
|
|
25
|
+
}
|
|
26
|
+
group.paths.add(resource.path);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
formatted: [...formatted],
|
|
30
|
+
formatters: [...formatters],
|
|
31
|
+
statuses: [...remaining.values()].map(({ status, paths }) => ({ status, paths: [...paths] })),
|
|
32
|
+
};
|
|
33
|
+
}
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.
|
|
7
|
-
"pi-agent-read": "0.
|
|
8
|
-
"pi-agent-text-editor": "0.
|
|
6
|
+
"pi-agent-invariant": "0.4.0",
|
|
7
|
+
"pi-agent-read": "0.4.0",
|
|
8
|
+
"pi-agent-text-editor": "0.4.0"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
12
|
-
"./runtime/entry-
|
|
12
|
+
"./runtime/entry-72.js"
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
@@ -3,6 +3,8 @@ import type { TextDocument } from "pi-agent-text";
|
|
|
3
3
|
export type TextEditIntent = "edit" | "restore" | "mixed";
|
|
4
4
|
|
|
5
5
|
export interface TextEditCompletion {
|
|
6
|
+
/** Deferred writes remain observable; final updates reconcile formatting without another edit. */
|
|
7
|
+
readonly postProcessing?: "deferred" | "final" | "complete";
|
|
6
8
|
readonly source: string;
|
|
7
9
|
readonly resourceSource: string;
|
|
8
10
|
readonly resolvedBy: string;
|
|
@@ -5,10 +5,25 @@ import type { TextEditorToolId } from "#src/api/plugin-protocol.js";
|
|
|
5
5
|
|
|
6
6
|
export type TextEditPipelineStage = "text-pre-edit" | "text-edit" | "text-post-edit";
|
|
7
7
|
|
|
8
|
+
/** Host-plugin edit plan, checked against exact snapshots before any writes. */
|
|
9
|
+
export interface TextEditPlan {
|
|
10
|
+
readonly files: readonly {
|
|
11
|
+
readonly source: string;
|
|
12
|
+
readonly expectedContent: string;
|
|
13
|
+
readonly changes: readonly {
|
|
14
|
+
readonly from: number;
|
|
15
|
+
readonly to: number;
|
|
16
|
+
readonly insert: string;
|
|
17
|
+
}[];
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
8
20
|
export interface TextPreEditState<Input = unknown> {
|
|
9
21
|
readonly cwd: string;
|
|
10
22
|
readonly input: Input;
|
|
23
|
+
/** Optional native semantic edits supplied by the owning plugin, not by tool arguments. */
|
|
24
|
+
readonly editPlan?: TextEditPlan;
|
|
11
25
|
readonly signal?: AbortSignal;
|
|
26
|
+
/** A validated diffStatuses contribution is added to each completed file's presentation. */
|
|
12
27
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
13
28
|
}
|
|
14
29
|
|
|
@@ -16,6 +16,11 @@ export function rememberLastResolvedResource(pi: ExtensionAPI, details: unknown)
|
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
if (Array.isArray(details.resources)) {
|
|
20
|
+
for (const resource of details.resources) {
|
|
21
|
+
if (isRecord(resource)) rememberLastResolvedResource(pi, resource.details);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
19
24
|
const source = details.source;
|
|
20
25
|
const resolverId = details.resolvedBy;
|
|
21
26
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AgentToolResult, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { TSchema } from "typebox";
|
|
1
3
|
import { isResourceResolver, type ResourceResolver } from "pi-agent-resource";
|
|
2
4
|
import {
|
|
3
5
|
isTextAnchorResolver,
|
|
@@ -26,9 +28,19 @@ import type {
|
|
|
26
28
|
} from "#src/api/mutation-tool.js";
|
|
27
29
|
import type { TextEditorToolRendererRegistration } from "#src/api/tool-renderer.js";
|
|
28
30
|
|
|
31
|
+
/** Shared index operations; Apply uses the same implementation and guards as standalone tools. */
|
|
32
|
+
export interface ScriptIndexOperation {
|
|
33
|
+
readonly name: "stage" | "unstage";
|
|
34
|
+
readonly parameters: TSchema;
|
|
35
|
+
execute(
|
|
36
|
+
input: unknown,
|
|
37
|
+
signal: AbortSignal,
|
|
38
|
+
context: ExtensionContext,
|
|
39
|
+
): Promise<AgentToolResult<unknown>>;
|
|
40
|
+
}
|
|
29
41
|
export const TEXT_EDITOR_PROTOCOL = "pi-agent-text-editor";
|
|
30
42
|
|
|
31
|
-
export const TEXT_EDITOR_API_VERSION =
|
|
43
|
+
export const TEXT_EDITOR_API_VERSION = 21;
|
|
32
44
|
|
|
33
45
|
export const TEXT_POSITION_ANCHOR_KIND = "pi-agent-text-editor/position";
|
|
34
46
|
|
|
@@ -89,6 +101,8 @@ export interface TextEditorPluginApi {
|
|
|
89
101
|
addMutationTool(registration: TextMutationToolRegistration): void;
|
|
90
102
|
addMutationGuard(registration: TextMutationGuardRegistration): void;
|
|
91
103
|
addToolRenderer(registration: TextEditorToolRendererRegistration): void;
|
|
104
|
+
/** Register an index operation for Apply without exposing unrelated Pi tools. */
|
|
105
|
+
addScriptIndexOperation(operation: ScriptIndexOperation): void;
|
|
92
106
|
onMutationTool(listener: TextMutationToolListener): () => void;
|
|
93
107
|
onDidEdit(listener: TextEditCompletionListener): () => void;
|
|
94
108
|
previewMutation(request: TextMutationPreviewRequest): Promise<TextMutationPreviewOutcome>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { hasDeferredPostEdit, afterPostEditScope } from "#src/core/post-edit-scope.js";
|
|
1
2
|
import { Type } from "typebox";
|
|
2
3
|
import { Value } from "typebox/value";
|
|
3
4
|
|
|
@@ -58,6 +59,7 @@ export function isFormattingContribution(
|
|
|
58
59
|
"changed",
|
|
59
60
|
"failed",
|
|
60
61
|
"not-reported",
|
|
62
|
+
"deferred",
|
|
61
63
|
].map((status) => Type.Literal(status)),
|
|
62
64
|
),
|
|
63
65
|
formatter: Type.Optional(Type.String()),
|
|
@@ -89,6 +91,7 @@ export function isDiffStatusContribution(value: unknown): value is TextPostEditS
|
|
|
89
91
|
diffStatuses: Type.Array(
|
|
90
92
|
Type.Object({
|
|
91
93
|
text: Type.String({ minLength: 1 }),
|
|
94
|
+
formatter: Type.Optional(Type.String()),
|
|
92
95
|
tone: Type.Optional(
|
|
93
96
|
Type.Union(["muted", "success", "warning", "error"].map((tone) => Type.Literal(tone))),
|
|
94
97
|
),
|
|
@@ -13,12 +13,15 @@ export type TextEditorToolRendererRegistration = Pick<
|
|
|
13
13
|
> & {
|
|
14
14
|
readonly tool: TextEditorToolId;
|
|
15
15
|
readonly fallback?: boolean;
|
|
16
|
+
/** Select this renderer for matching tool arguments or results; unmatched values use the previous renderer. */
|
|
17
|
+
readonly matches?: (value: unknown, phase: "call" | "result") => boolean;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
const rendererFunctionSchema = Type.Function([], Type.Unknown());
|
|
19
21
|
const toolRendererRegistrationSchema = Type.Object({
|
|
20
22
|
tool: Type.String({ pattern: "\\S" }),
|
|
21
23
|
fallback: Type.Optional(Type.Boolean()),
|
|
24
|
+
matches: Type.Optional(rendererFunctionSchema),
|
|
22
25
|
renderCall: Type.Optional(rendererFunctionSchema),
|
|
23
26
|
renderResult: Type.Optional(rendererFunctionSchema),
|
|
24
27
|
renderShell: Type.Optional(Type.Union([Type.Literal("default"), Type.Literal("self")])),
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { createPostEditScope } from "#src/core/post-edit-scope.js";
|
|
2
|
+
import { FileMutationResult } from "#src/core/mutation-result/file-mutation-result.js";
|
|
3
|
+
import { isFormattingContribution, isDiffStatusContribution } from "#src/api/post-edit.js";
|
|
4
|
+
import { executeDiff, diffReadResult } from "#src/core/diff-tool.js";
|
|
5
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import type { ReadPluginApi } from "pi-agent-read/api/plugin-protocol";
|
|
7
|
+
import { readParameters, type ReadToolResult } from "pi-agent-read/api/tools/read";
|
|
8
|
+
import { searchSchema, type SearchPluginApi, type SearchRequest } from "pi-agent-search/api/search";
|
|
9
|
+
import { Value } from "typebox/value";
|
|
10
|
+
import type { TextEditorCore } from "#src/core/text-editor-core.js";
|
|
11
|
+
import { executeScriptMutation } from "#src/core/text-mutation.js";
|
|
12
|
+
import { ApplyResults } from "#src/core/apply/results.js";
|
|
13
|
+
import {
|
|
14
|
+
executeFileOperation,
|
|
15
|
+
fileOperations,
|
|
16
|
+
type FileOperation,
|
|
17
|
+
} from "#src/core/file-operations.js";
|
|
18
|
+
import { serializeApplyError, type ApplyRuntimeHost } from "#src/core/apply/runtime.js";
|
|
19
|
+
|
|
20
|
+
/** Configured IDE services and ordinary tool schemas, shared with the standalone tools. */
|
|
21
|
+
export interface ApplyServices {
|
|
22
|
+
readonly editor: TextEditorCore;
|
|
23
|
+
readonly read: ReadPluginApi;
|
|
24
|
+
readonly search: SearchPluginApi;
|
|
25
|
+
readonly lastResolvedSource?: string;
|
|
26
|
+
readonly rememberRead?: (outcome: ReadToolResult) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One invocation's host-owned receipts, with guest errors independent of output selection. */
|
|
30
|
+
export function createApplyExecution(
|
|
31
|
+
services: ApplyServices,
|
|
32
|
+
context: ExtensionContext,
|
|
33
|
+
): {
|
|
34
|
+
readonly host: ApplyRuntimeHost;
|
|
35
|
+
readonly results: ApplyResults;
|
|
36
|
+
finish(): Promise<void>;
|
|
37
|
+
} {
|
|
38
|
+
const results = new ApplyResults();
|
|
39
|
+
const scope = createPostEditScope();
|
|
40
|
+
let lastSource = services.lastResolvedSource;
|
|
41
|
+
const host: ApplyRuntimeHost = {
|
|
42
|
+
async execute(operation, arguments_, signal, id) {
|
|
43
|
+
const tool = operation === "remove" ? "delete" : operation;
|
|
44
|
+
const kind = tool === "read" || tool === "search" || tool === "diff" ? "read" : "mutation";
|
|
45
|
+
let recorded = false;
|
|
46
|
+
try {
|
|
47
|
+
if (tool === "stage" || tool === "unstage") {
|
|
48
|
+
const operation = services.editor.getScriptIndexOperation(tool);
|
|
49
|
+
if (!operation)
|
|
50
|
+
throw failure("OPERATION_UNAVAILABLE", `${tool} requires the Git changes module`);
|
|
51
|
+
if (!Value.Check(operation.parameters, arguments_))
|
|
52
|
+
throw failure("INVALID_ARGUMENTS", `Invalid ${tool} arguments`);
|
|
53
|
+
const outcome = await operation.execute(arguments_, signal, context);
|
|
54
|
+
const value = {
|
|
55
|
+
operation: tool,
|
|
56
|
+
ok: true,
|
|
57
|
+
effect: "index-only",
|
|
58
|
+
kind: "index-operation",
|
|
59
|
+
...(outcome.details as object),
|
|
60
|
+
};
|
|
61
|
+
results.record(id, "mutation", value, { content: outcome.content, details: {} });
|
|
62
|
+
recorded = true;
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
if (tool === "diff") {
|
|
66
|
+
const value = await executeDiff(services.read, arguments_, { cwd: context.cwd, signal });
|
|
67
|
+
results.record(id, "read", value, diffReadResult(value));
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
if ((fileOperations as readonly string[]).includes(operation)) {
|
|
71
|
+
const value = await services.editor.enqueueFileOperation(
|
|
72
|
+
() => executeFileOperation(operation as FileOperation, arguments_, context.cwd, signal),
|
|
73
|
+
signal,
|
|
74
|
+
);
|
|
75
|
+
results.record(id, "mutation", value);
|
|
76
|
+
recorded = true;
|
|
77
|
+
if (value.effect !== "not-applied") {
|
|
78
|
+
if (value.path !== undefined && operation !== "copy_file") {
|
|
79
|
+
results.forgetFile(value.path);
|
|
80
|
+
scope.forget(value.path);
|
|
81
|
+
}
|
|
82
|
+
if (value.target !== undefined) {
|
|
83
|
+
results.forgetFile(value.target);
|
|
84
|
+
scope.forget(value.target);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (value.ok && value.target !== undefined)
|
|
88
|
+
await services.editor.postProcessFile(value.target, { cwd: context.cwd, signal });
|
|
89
|
+
if (!value.ok)
|
|
90
|
+
throw failure(
|
|
91
|
+
value.error?.code ?? "FILE_OPERATION_FAILED",
|
|
92
|
+
value.error?.message ?? "File operation failed",
|
|
93
|
+
value,
|
|
94
|
+
);
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
if (kind === "mutation") {
|
|
98
|
+
const definition = services.editor
|
|
99
|
+
.getMutationTools()
|
|
100
|
+
.find((candidate) => candidate.name === tool);
|
|
101
|
+
if (definition === undefined)
|
|
102
|
+
throw failure("UNAVAILABLE_OPERATION", `IDE operation ${tool} is unavailable`);
|
|
103
|
+
const value = await executeScriptMutation(
|
|
104
|
+
services.editor,
|
|
105
|
+
definition,
|
|
106
|
+
arguments_,
|
|
107
|
+
signal,
|
|
108
|
+
context,
|
|
109
|
+
lastSource,
|
|
110
|
+
(source, presentation) => results.rememberMutation(source, presentation),
|
|
111
|
+
);
|
|
112
|
+
results.record(id, kind, value);
|
|
113
|
+
recorded = true;
|
|
114
|
+
for (const file of value.files) {
|
|
115
|
+
results.updateFile(file.source, file.before, file.after);
|
|
116
|
+
lastSource = file.source;
|
|
117
|
+
}
|
|
118
|
+
if (!value.ok)
|
|
119
|
+
throw failure(
|
|
120
|
+
value.errors[0]?.code ?? "OPERATION_FAILED",
|
|
121
|
+
value.errors[0]?.message ?? "Mutation failed",
|
|
122
|
+
value,
|
|
123
|
+
);
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
const schema = tool === "read" ? readParameters : searchSchema;
|
|
127
|
+
if (!Value.Check(schema, arguments_))
|
|
128
|
+
throw failure("INVALID_ARGUMENTS", `Invalid arguments for ${tool}`);
|
|
129
|
+
if (tool === "read") {
|
|
130
|
+
const outcome = await services.read.read(
|
|
131
|
+
arguments_,
|
|
132
|
+
{ cwd: context.cwd, signal },
|
|
133
|
+
"script",
|
|
134
|
+
);
|
|
135
|
+
const value = {
|
|
136
|
+
...(outcome.script ?? {
|
|
137
|
+
kind: "native",
|
|
138
|
+
source: outcome.details.source,
|
|
139
|
+
blocks: outcome.content,
|
|
140
|
+
}),
|
|
141
|
+
ok: !outcome.isError && outcome.details.failure === undefined,
|
|
142
|
+
};
|
|
143
|
+
results.record(id, kind, value, outcome);
|
|
144
|
+
recorded = true;
|
|
145
|
+
if (outcome.isError || outcome.details.failure)
|
|
146
|
+
throw failure(
|
|
147
|
+
readFailureCode(outcome.details.failure),
|
|
148
|
+
outcome.details.failure?.message ?? "Read failed",
|
|
149
|
+
value,
|
|
150
|
+
);
|
|
151
|
+
lastSource = outcome.details.source ?? lastSource;
|
|
152
|
+
services.rememberRead?.(outcome);
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
const outcome = await services.search.search(
|
|
156
|
+
arguments_ as SearchRequest,
|
|
157
|
+
{
|
|
158
|
+
cwd: context.cwd,
|
|
159
|
+
signal,
|
|
160
|
+
},
|
|
161
|
+
"script",
|
|
162
|
+
);
|
|
163
|
+
const searchFailure = outcome.details.failure;
|
|
164
|
+
const value = {
|
|
165
|
+
...outcome.script,
|
|
166
|
+
ok: searchFailure === undefined,
|
|
167
|
+
...(searchFailure && { error: searchFailure }),
|
|
168
|
+
};
|
|
169
|
+
results.record(id, kind, value, { content: outcome.content, details: {} });
|
|
170
|
+
recorded = true;
|
|
171
|
+
if (searchFailure !== undefined)
|
|
172
|
+
throw failure("SEARCH_FAILED", "Search failed", searchFailure);
|
|
173
|
+
return value;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (!recorded)
|
|
176
|
+
results.record(id, kind, { operation, ok: false, error: serializeApplyError(error) });
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
async result(value, id) {
|
|
181
|
+
results.add(value, id);
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
host: { ...host, execute: (...args) => scope.run(() => host.execute(...args)) },
|
|
186
|
+
results,
|
|
187
|
+
async finish() {
|
|
188
|
+
await services.editor.enqueueFileOperation(() =>
|
|
189
|
+
scope.finish((outcome) => {
|
|
190
|
+
const source = outcome.after.source;
|
|
191
|
+
const previous = results.mutationPresentation(source)?.data;
|
|
192
|
+
const formatting = outcome.postEditContributions
|
|
193
|
+
.map((item) => item.data)
|
|
194
|
+
.findLast(isFormattingContribution)?.formatting;
|
|
195
|
+
if (
|
|
196
|
+
!previous &&
|
|
197
|
+
outcome.before.content === outcome.after.content &&
|
|
198
|
+
!formatting?.formatter
|
|
199
|
+
)
|
|
200
|
+
return;
|
|
201
|
+
results.updateFile(source, outcome.before.content, outcome.after.content);
|
|
202
|
+
results.rememberMutation(
|
|
203
|
+
source,
|
|
204
|
+
new FileMutationResult({
|
|
205
|
+
ok: true,
|
|
206
|
+
path: source,
|
|
207
|
+
...previous,
|
|
208
|
+
afterContent: outcome.after.content,
|
|
209
|
+
afterDocument: outcome.after,
|
|
210
|
+
diffStatuses: outcome.postEditContributions
|
|
211
|
+
.map((item) => item.data)
|
|
212
|
+
.filter(isDiffStatusContribution)
|
|
213
|
+
.flatMap((item) => item.diffStatuses),
|
|
214
|
+
formatting: formatting ?? { status: "not-reported" },
|
|
215
|
+
}),
|
|
216
|
+
);
|
|
217
|
+
}),
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function failure(code: string, message: string, details?: unknown): Error {
|
|
224
|
+
return Object.assign(new Error(message), { code, details });
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function readFailureCode(
|
|
228
|
+
failure: { readonly code: string; readonly cause?: unknown } | undefined,
|
|
229
|
+
): string {
|
|
230
|
+
const cause = failure?.cause;
|
|
231
|
+
return cause !== null &&
|
|
232
|
+
typeof cause === "object" &&
|
|
233
|
+
"code" in cause &&
|
|
234
|
+
typeof cause.code === "string"
|
|
235
|
+
? cause.code
|
|
236
|
+
: (failure?.code ?? "READ_FAILED");
|
|
237
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FileMutationResult } from "#src/core/mutation-result/file-mutation-result.js";
|
|
2
|
+
import { createUnifiedDiff } from "#src/core/mutation-result/diff.js";
|
|
3
|
+
import type { ApplyResults } from "./results.js";
|
|
4
|
+
import type { ScriptMutationOutcome } from "./mutation-outcome.js";
|
|
5
|
+
|
|
6
|
+
/** Project recorded net effects into the same presentation model as standalone edits. */
|
|
7
|
+
export function finalApplyMutations(results: ApplyResults): FileMutationResult[] {
|
|
8
|
+
const selected = results.select();
|
|
9
|
+
const mutations = results.mutationValues().filter(isMutation);
|
|
10
|
+
return selected.files.map((file) => {
|
|
11
|
+
const receipts = mutations.flatMap((outcome) =>
|
|
12
|
+
outcome.files
|
|
13
|
+
.filter((changed) => changed.source === file.source)
|
|
14
|
+
.map((changed) => ({ outcome, changed })),
|
|
15
|
+
);
|
|
16
|
+
const presentation = results.mutationPresentation(file.source)?.data;
|
|
17
|
+
const latest = presentation?.afterContent === file.after ? presentation : undefined;
|
|
18
|
+
return new FileMutationResult({
|
|
19
|
+
ok: true,
|
|
20
|
+
path: file.source,
|
|
21
|
+
files: [{ path: file.source, action: file.before === null ? "created" : "edited" }],
|
|
22
|
+
snapshot: { content: file.before ?? "" },
|
|
23
|
+
beforeContentMap: { [file.source]: file.before },
|
|
24
|
+
afterContent: file.after ?? "",
|
|
25
|
+
afterDocument: latest?.afterDocument,
|
|
26
|
+
resultPresentation: latest?.resultPresentation,
|
|
27
|
+
scopeMarkers: latest?.scopeMarkers,
|
|
28
|
+
hints: latest?.hints,
|
|
29
|
+
warnings: latest?.warnings,
|
|
30
|
+
diffStatuses: latest?.diffStatuses,
|
|
31
|
+
diffs: [createUnifiedDiff(file.source, file.before ?? "", file.after ?? "").diff],
|
|
32
|
+
operations: receipts.map(({ outcome, changed }) => ({
|
|
33
|
+
operation: outcome.operation === "remove" ? "delete" : outcome.operation,
|
|
34
|
+
changes: changed.changes.length,
|
|
35
|
+
})),
|
|
36
|
+
formatting: latest?.formatting ?? receipts.at(-1)?.changed.formatting,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isMutation(value: unknown): value is ScriptMutationOutcome {
|
|
42
|
+
return (
|
|
43
|
+
value !== null &&
|
|
44
|
+
typeof value === "object" &&
|
|
45
|
+
"operation" in value &&
|
|
46
|
+
"files" in value &&
|
|
47
|
+
Array.isArray(value.files) &&
|
|
48
|
+
"effect" in value
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { format } from "oxfmt";
|
|
2
|
+
|
|
3
|
+
/** Format only the completed display copy; execution always receives the original source. */
|
|
4
|
+
export async function formatApplySource(source: string): Promise<string> {
|
|
5
|
+
try {
|
|
6
|
+
const formatted = await format("apply.js", source, { printWidth: 90 });
|
|
7
|
+
return formatted.errors.length === 0 ? formatted.code.trimEnd() : source;
|
|
8
|
+
} catch {
|
|
9
|
+
return source;
|
|
10
|
+
}
|
|
11
|
+
}
|