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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
+
import type { TextEditCompletion } from "#src/api/edit-completion.js";
|
|
5
|
+
import { Value } from "typebox/value";
|
|
3
6
|
import type {
|
|
4
7
|
TextAnchorRecoveryCandidateRange,
|
|
5
8
|
TextAnchorRecoveryRange,
|
|
@@ -71,6 +74,7 @@ import { renderTextAnchor, type TextAnchor } from "pi-agent-text";
|
|
|
71
74
|
import { TextSelectionAnchor } from "#src/api/text-selection-anchor.js";
|
|
72
75
|
import type { ToolCallAnchorRenderState } from "pi-agent-tool-call-interception";
|
|
73
76
|
import type { Static, TSchema } from "typebox";
|
|
77
|
+
import type { ScriptMutationOutcome } from "#src/core/apply/mutation-outcome.js";
|
|
74
78
|
|
|
75
79
|
export function createTextTool<TParameters extends TSchema>(
|
|
76
80
|
core: TextEditorCore,
|
|
@@ -80,6 +84,8 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
80
84
|
getLastResolvedSource: () => string | undefined,
|
|
81
85
|
): ToolDefinition<TParameters, FileMutationBatchResult> {
|
|
82
86
|
const renderer = core.getToolRenderer(definition.name);
|
|
87
|
+
const initialRenderCall = renderer?.renderCall;
|
|
88
|
+
const initialRenderResult = renderer?.renderResult;
|
|
83
89
|
|
|
84
90
|
const tool = withToolCallInterceptionRendering<TParameters, FileMutationBatchResult, unknown>(
|
|
85
91
|
defineTool<TParameters, FileMutationBatchResult, unknown>({
|
|
@@ -101,8 +107,16 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
101
107
|
definition.anchors ?? [],
|
|
102
108
|
),
|
|
103
109
|
...(renderer?.renderShell !== undefined && { renderShell: renderer.renderShell }),
|
|
104
|
-
...(
|
|
105
|
-
|
|
110
|
+
...(initialRenderCall !== undefined && {
|
|
111
|
+
renderCall: (...arguments_: Parameters<typeof initialRenderCall>) =>
|
|
112
|
+
(core.getToolRenderer(definition.name)?.renderCall ?? initialRenderCall)(...arguments_),
|
|
113
|
+
}),
|
|
114
|
+
...(initialRenderResult !== undefined && {
|
|
115
|
+
renderResult: (...arguments_: Parameters<typeof initialRenderResult>) =>
|
|
116
|
+
(core.getToolRenderer(definition.name)?.renderResult ?? initialRenderResult)(
|
|
117
|
+
...arguments_,
|
|
118
|
+
),
|
|
119
|
+
}),
|
|
106
120
|
async execute(toolCallId, parameters, signal, onUpdate, context) {
|
|
107
121
|
const directExecute = () =>
|
|
108
122
|
executeTextMutation(
|
|
@@ -372,9 +386,16 @@ function mergeTargets(left: readonly TextTarget[], right: readonly TextTarget[])
|
|
|
372
386
|
merged.set(target.source, target);
|
|
373
387
|
continue;
|
|
374
388
|
}
|
|
389
|
+
if (
|
|
390
|
+
previous.expectedContent !== undefined &&
|
|
391
|
+
target.expectedContent !== undefined &&
|
|
392
|
+
previous.expectedContent !== target.expectedContent
|
|
393
|
+
)
|
|
394
|
+
throw new Error("Selections refer to different source revisions. Read the source again.");
|
|
375
395
|
const ranges = [...(previous.ranges ?? []), ...(target.ranges ?? [])];
|
|
376
396
|
merged.set(target.source, {
|
|
377
397
|
source: target.source,
|
|
398
|
+
expectedContent: target.expectedContent ?? previous.expectedContent,
|
|
378
399
|
...(ranges.length > 0 && { ranges: deduplicateRanges(ranges) }),
|
|
379
400
|
});
|
|
380
401
|
}
|
|
@@ -715,6 +736,37 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
715
736
|
publishAnchorRenderState?: (field: string, state: ToolCallAnchorRenderState) => void,
|
|
716
737
|
lastResolvedSource?: string,
|
|
717
738
|
): Promise<AgentToolResult<FileMutationBatchResult>> {
|
|
739
|
+
const execution = await executeTextMutationPipeline(
|
|
740
|
+
core,
|
|
741
|
+
definition,
|
|
742
|
+
parameters,
|
|
743
|
+
signal,
|
|
744
|
+
context,
|
|
745
|
+
publishAnchorRenderState,
|
|
746
|
+
lastResolvedSource,
|
|
747
|
+
);
|
|
748
|
+
const result = await buildToolResult(
|
|
749
|
+
core,
|
|
750
|
+
execution.pipeline,
|
|
751
|
+
execution.source,
|
|
752
|
+
context,
|
|
753
|
+
definition.name,
|
|
754
|
+
);
|
|
755
|
+
return execution.pipeline.kind === "completed" && execution.pipeline.state.metadata !== undefined
|
|
756
|
+
? { ...result, details: { ...result.details, metadata: execution.pipeline.state.metadata } }
|
|
757
|
+
: result;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/** Runs configured mutation semantics without creating model-facing presentation. */
|
|
761
|
+
export async function executeTextMutationPipeline<TParameters extends TSchema>(
|
|
762
|
+
core: TextEditorCore,
|
|
763
|
+
definition: TextMutationToolRegistration<TParameters>,
|
|
764
|
+
parameters: Static<TParameters>,
|
|
765
|
+
signal: AbortSignal | undefined,
|
|
766
|
+
context: ExtensionContext,
|
|
767
|
+
publishAnchorRenderState?: (field: string, state: ToolCallAnchorRenderState) => void,
|
|
768
|
+
lastResolvedSource?: string,
|
|
769
|
+
): Promise<{ readonly pipeline: TextEditExecutionOutcome; readonly source: string }> {
|
|
718
770
|
const source = mutationSource(definition, parameters);
|
|
719
771
|
const pipeline = await core.executeEdit(
|
|
720
772
|
definition.name,
|
|
@@ -725,6 +777,46 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
725
777
|
},
|
|
726
778
|
async (state) => {
|
|
727
779
|
try {
|
|
780
|
+
if (state.editPlan !== undefined) {
|
|
781
|
+
const plan = state.editPlan;
|
|
782
|
+
if (
|
|
783
|
+
plan.files.length === 0 ||
|
|
784
|
+
new Set(plan.files.map((file) => file.source)).size !== plan.files.length
|
|
785
|
+
)
|
|
786
|
+
throw new Error("Semantic edit plan must contain distinct source files.");
|
|
787
|
+
const outcome = await core.editTexts(
|
|
788
|
+
plan.files.map((file) => ({ source: file.source, read: true })),
|
|
789
|
+
{
|
|
790
|
+
cwd: state.cwd,
|
|
791
|
+
intent: definition.intent ?? "edit",
|
|
792
|
+
...(state.signal !== undefined && { signal: state.signal }),
|
|
793
|
+
},
|
|
794
|
+
(texts) => {
|
|
795
|
+
for (const file of plan.files) {
|
|
796
|
+
if (texts.get(file.source) !== file.expectedContent)
|
|
797
|
+
throw new Error(
|
|
798
|
+
"A semantic edit source changed. Resolve the symbol again before retrying.",
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
const edits = new Map(
|
|
802
|
+
plan.files.map((file) => [
|
|
803
|
+
file.source,
|
|
804
|
+
{ changes: file.changes, action: "edited" as const },
|
|
805
|
+
]),
|
|
806
|
+
);
|
|
807
|
+
return Promise.resolve({
|
|
808
|
+
changes: new Map(plan.files.map((file) => [file.source, file.changes])),
|
|
809
|
+
result: {
|
|
810
|
+
edits,
|
|
811
|
+
resultPresentations: new Map(
|
|
812
|
+
plan.files.map((file) => [file.source, "plain" as const]),
|
|
813
|
+
),
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
},
|
|
817
|
+
);
|
|
818
|
+
return await completeTextMutation(outcome, requiredValue(plan.files[0]).source);
|
|
819
|
+
}
|
|
728
820
|
const sources = await resolveMutationSources(
|
|
729
821
|
core,
|
|
730
822
|
definition,
|
|
@@ -744,6 +836,15 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
744
836
|
...(state.signal !== undefined && { signal: state.signal }),
|
|
745
837
|
},
|
|
746
838
|
async (texts, resolveAnchor) => {
|
|
839
|
+
for (const target of sources.targets) {
|
|
840
|
+
if (
|
|
841
|
+
target.expectedContent !== undefined &&
|
|
842
|
+
texts.get(target.source) !== target.expectedContent
|
|
843
|
+
)
|
|
844
|
+
throw new Error(
|
|
845
|
+
"The selected source changed before editing. Resolve the symbol again.",
|
|
846
|
+
);
|
|
847
|
+
}
|
|
747
848
|
const mutationContext = createMutationContext(
|
|
748
849
|
definition,
|
|
749
850
|
state.input,
|
|
@@ -776,9 +877,142 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
776
877
|
},
|
|
777
878
|
);
|
|
778
879
|
|
|
779
|
-
return
|
|
880
|
+
return { pipeline, source };
|
|
780
881
|
}
|
|
781
882
|
|
|
883
|
+
const scriptMutationScope = new AsyncLocalStorage<TextEditCompletion[]>();
|
|
884
|
+
|
|
885
|
+
async function captureScriptMutation<T>(core: TextEditorCore, action: () => Promise<T>) {
|
|
886
|
+
const completions: TextEditCompletion[] = [];
|
|
887
|
+
const unsubscribe = core.onDidEdit((completion) => {
|
|
888
|
+
if (scriptMutationScope.getStore() === completions) completions.push(completion);
|
|
889
|
+
});
|
|
890
|
+
try {
|
|
891
|
+
const value = await scriptMutationScope.run(completions, action);
|
|
892
|
+
return { kind: "completed" as const, value, completions };
|
|
893
|
+
} catch (error) {
|
|
894
|
+
return { kind: "failed" as const, error, completions };
|
|
895
|
+
} finally {
|
|
896
|
+
unsubscribe();
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Runs the configured mutation pipeline and returns plain script data.
|
|
901
|
+
* onPresentation retains rich edit annotations on the host without sending classes to the guest.
|
|
902
|
+
*/
|
|
903
|
+
export async function executeScriptMutation<TParameters extends TSchema>(
|
|
904
|
+
core: TextEditorCore,
|
|
905
|
+
definition: TextMutationToolRegistration<TParameters>,
|
|
906
|
+
arguments_: unknown,
|
|
907
|
+
signal: AbortSignal | undefined,
|
|
908
|
+
context: ExtensionContext,
|
|
909
|
+
lastResolvedSource?: string,
|
|
910
|
+
onPresentation?: (source: string, result: FileMutationResult) => void,
|
|
911
|
+
): Promise<ScriptMutationOutcome> {
|
|
912
|
+
const parameters = prepareGuardedArguments(
|
|
913
|
+
definition.parameters,
|
|
914
|
+
arguments_,
|
|
915
|
+
definition.source.inherited ? definition.source.field : undefined,
|
|
916
|
+
lastResolvedSource,
|
|
917
|
+
definition.anchors ?? [],
|
|
918
|
+
);
|
|
919
|
+
if (!Value.Check(definition.parameters, parameters)) {
|
|
920
|
+
throw Object.assign(new Error(`Invalid arguments for ${definition.name}`), {
|
|
921
|
+
code: "INVALID_ARGUMENTS",
|
|
922
|
+
details: { operation: definition.name, effect: "not-applied" },
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
const captured = await captureScriptMutation(core, () =>
|
|
926
|
+
executeTextMutationPipeline(
|
|
927
|
+
core,
|
|
928
|
+
definition,
|
|
929
|
+
parameters,
|
|
930
|
+
signal,
|
|
931
|
+
context,
|
|
932
|
+
undefined,
|
|
933
|
+
lastResolvedSource,
|
|
934
|
+
),
|
|
935
|
+
);
|
|
936
|
+
const source =
|
|
937
|
+
captured.kind === "completed" ? captured.value.source : mutationSource(definition, parameters);
|
|
938
|
+
const observedFiles: ScriptMutationOutcome["files"] = captured.completions.map((completion) => ({
|
|
939
|
+
source: completion.resourceSource,
|
|
940
|
+
before: completion.existed ? completion.before.content : null,
|
|
941
|
+
after: completion.after.content,
|
|
942
|
+
action: definition.name === "write" ? "overwritten" : "edited",
|
|
943
|
+
changes: [],
|
|
944
|
+
formatting: { status: "not-reported" },
|
|
945
|
+
}));
|
|
946
|
+
const failed = (
|
|
947
|
+
code: string,
|
|
948
|
+
message: string,
|
|
949
|
+
effect: ScriptMutationOutcome["effect"],
|
|
950
|
+
completed: readonly string[] = [],
|
|
951
|
+
): ScriptMutationOutcome => ({
|
|
952
|
+
operation: definition.name,
|
|
953
|
+
ok: false,
|
|
954
|
+
effect: effect === "unknown" ? "unknown" : observedFiles.length > 0 ? "applied" : effect,
|
|
955
|
+
completed: [...new Set([...completed, ...observedFiles.map((file) => file.source)])],
|
|
956
|
+
files: observedFiles,
|
|
957
|
+
errors: [{ source, code, message }],
|
|
958
|
+
});
|
|
959
|
+
if (captured.kind === "failed")
|
|
960
|
+
return failed("EXECUTION_FAILED", errorMessage(captured.error), "unknown");
|
|
961
|
+
const { pipeline } = captured.value;
|
|
962
|
+
if (pipeline.kind === "failed")
|
|
963
|
+
return {
|
|
964
|
+
...failed(pipeline.failure.code, pipeline.failure.message, "not-applied"),
|
|
965
|
+
recoveries: await scriptAnchorRecoveries(pipeline.failure.cause),
|
|
966
|
+
};
|
|
967
|
+
const outcome = pipeline.state.result;
|
|
968
|
+
if (!isResourcesEditOutcome(outcome))
|
|
969
|
+
return failed("INVALID_RESULT", "Invalid mutation outcome", "unknown");
|
|
970
|
+
if (outcome.kind === "failed")
|
|
971
|
+
return {
|
|
972
|
+
...failed(
|
|
973
|
+
outcome.failure.code,
|
|
974
|
+
outcome.failure.message,
|
|
975
|
+
outcome.completed.length > 0 ? "unknown" : "not-applied",
|
|
976
|
+
outcome.completed,
|
|
977
|
+
),
|
|
978
|
+
recoveries: await scriptAnchorRecoveries(outcome.failure.cause),
|
|
979
|
+
};
|
|
980
|
+
const mutation = outcome.result as ExecutedTextMutation;
|
|
981
|
+
const files = outcome.resources.flatMap((resource) => {
|
|
982
|
+
const edit = mutation.edits.get(resource.source);
|
|
983
|
+
if (edit === undefined) return [];
|
|
984
|
+
const presentation = withPipelineStatuses(
|
|
985
|
+
buildSuccessfulTextMutationResult(resource, resource.source, edit),
|
|
986
|
+
pipeline.state.metadata,
|
|
987
|
+
);
|
|
988
|
+
onPresentation?.(resource.after.source, presentation);
|
|
989
|
+
const data = presentation.data;
|
|
990
|
+
return [
|
|
991
|
+
{
|
|
992
|
+
source: resource.after.source,
|
|
993
|
+
before:
|
|
994
|
+
captured.completions.find(
|
|
995
|
+
(completion) => completion.resourceSource === resource.after.source,
|
|
996
|
+
)?.existed === false
|
|
997
|
+
? null
|
|
998
|
+
: resource.before.content,
|
|
999
|
+
after: resource.after.content,
|
|
1000
|
+
action: edit.action,
|
|
1001
|
+
changes: data.rawChanges ?? [],
|
|
1002
|
+
formatting: data.formatting ?? { status: "not-reported" as const },
|
|
1003
|
+
},
|
|
1004
|
+
];
|
|
1005
|
+
});
|
|
1006
|
+
return {
|
|
1007
|
+
operation: definition.name,
|
|
1008
|
+
ok: true,
|
|
1009
|
+
effect: files.length > 0 ? "applied" : "not-applied",
|
|
1010
|
+
files,
|
|
1011
|
+
completed: files.map((file) => file.source),
|
|
1012
|
+
...(pipeline.state.metadata !== undefined && { metadata: pipeline.state.metadata }),
|
|
1013
|
+
errors: [],
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
782
1016
|
export function mutationSources(
|
|
783
1017
|
definition: TextMutationToolRegistration,
|
|
784
1018
|
parameters: Readonly<Record<string, unknown>>,
|
|
@@ -830,7 +1064,7 @@ export function buildSuccessfulTextMutationResult(
|
|
|
830
1064
|
): FileMutationResult {
|
|
831
1065
|
const before = resource.before.content;
|
|
832
1066
|
const finalAfter = resource.after.content;
|
|
833
|
-
const applied = applyTextChanges(before, edit.changes);
|
|
1067
|
+
const applied = applyTextChanges(before, edit.changes, before.length === 0);
|
|
834
1068
|
const unified = createUnifiedDiff(resultSource, before, diffAfterContent);
|
|
835
1069
|
const mutationResultData = resource.postEditContributions
|
|
836
1070
|
.map((contribution) => contribution.data)
|
|
@@ -857,7 +1091,7 @@ export function buildSuccessfulTextMutationResult(
|
|
|
857
1091
|
.flatMap((item) => item.diffStatuses),
|
|
858
1092
|
formatting: resource.postEditContributions
|
|
859
1093
|
.map((item) => item.data)
|
|
860
|
-
.
|
|
1094
|
+
.findLast(isFormattingContribution)?.formatting ?? { status: "not-reported" },
|
|
861
1095
|
ok: true,
|
|
862
1096
|
path: resultSource,
|
|
863
1097
|
diffs: [unified.diff],
|
|
@@ -960,12 +1194,43 @@ async function buildToolResult(
|
|
|
960
1194
|
];
|
|
961
1195
|
});
|
|
962
1196
|
|
|
1197
|
+
const presented = results.map((result) => withPipelineStatuses(result, pipeline.state.metadata));
|
|
963
1198
|
return {
|
|
964
|
-
content: [new FileMutationAgentResult(
|
|
965
|
-
details: { results },
|
|
1199
|
+
content: [new FileMutationAgentResult(presented).toTextContent()],
|
|
1200
|
+
details: { results: presented },
|
|
966
1201
|
};
|
|
967
1202
|
}
|
|
968
1203
|
|
|
1204
|
+
function withPipelineStatuses(result: FileMutationResult, metadata: unknown): FileMutationResult {
|
|
1205
|
+
if (!isDiffStatusContribution(metadata)) return result;
|
|
1206
|
+
return new FileMutationResult({
|
|
1207
|
+
...result.data,
|
|
1208
|
+
diffStatuses: [...(result.data.diffStatuses ?? []), ...metadata.diffStatuses],
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
async function resolveAnchorRecovery(error: TextMutationAnchorResolutionError) {
|
|
1212
|
+
if (error.resolution.recovery === undefined) await error.resolution.refreshRecovery();
|
|
1213
|
+
return error.resolution.recovery;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
async function scriptAnchorRecoveries(
|
|
1217
|
+
cause: unknown,
|
|
1218
|
+
): Promise<NonNullable<ScriptMutationOutcome["recoveries"]>> {
|
|
1219
|
+
if (cause instanceof TextMutationAnchorAggregateError)
|
|
1220
|
+
return (await Promise.all(cause.failures.map(scriptAnchorRecoveries))).flat();
|
|
1221
|
+
if (!(cause instanceof TextMutationAnchorResolutionError)) return [];
|
|
1222
|
+
const recovery = await resolveAnchorRecovery(cause);
|
|
1223
|
+
return [
|
|
1224
|
+
{
|
|
1225
|
+
path: cause.source,
|
|
1226
|
+
field: cause.field,
|
|
1227
|
+
anchor: cause.anchor,
|
|
1228
|
+
status: recovery?.kind ?? "unavailable",
|
|
1229
|
+
candidates: recovery?.kind === "candidates" ? recovery.candidates : [],
|
|
1230
|
+
total: recovery?.kind === "candidates" ? recovery.total : 0,
|
|
1231
|
+
},
|
|
1232
|
+
];
|
|
1233
|
+
}
|
|
969
1234
|
async function anchorFailureToolResult(
|
|
970
1235
|
core: TextEditorCore,
|
|
971
1236
|
failure: TextResourceEditFailure,
|
|
@@ -1006,10 +1271,7 @@ async function anchorFailureToolResult(
|
|
|
1006
1271
|
|
|
1007
1272
|
const contextual = failure.cause;
|
|
1008
1273
|
const resolution = contextual.resolution;
|
|
1009
|
-
|
|
1010
|
-
await resolution.refreshRecovery();
|
|
1011
|
-
}
|
|
1012
|
-
const recovery = resolution.recovery;
|
|
1274
|
+
const recovery = await resolveAnchorRecovery(contextual);
|
|
1013
1275
|
if (recovery?.kind === "timed-out") {
|
|
1014
1276
|
return failureToolResult(
|
|
1015
1277
|
contextual.source,
|
|
@@ -19,7 +19,7 @@ export const copySchema = Type.Object(
|
|
|
19
19
|
start: Type.Optional(
|
|
20
20
|
Type.String({
|
|
21
21
|
description:
|
|
22
|
-
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line.
|
|
22
|
+
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line. Omit when path already selects text through a supported resource reference. With end, selects a whole-line range.",
|
|
23
23
|
}),
|
|
24
24
|
),
|
|
25
25
|
end: Type.Optional(
|
|
@@ -21,7 +21,7 @@ export const deleteSchema = Type.Object(
|
|
|
21
21
|
start: Type.Optional(
|
|
22
22
|
Type.String({
|
|
23
23
|
description:
|
|
24
|
-
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line.
|
|
24
|
+
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line. Omit when path already selects text through a supported resource reference. With end, selects a whole-line range.",
|
|
25
25
|
}),
|
|
26
26
|
),
|
|
27
27
|
end: Type.Optional(
|
|
@@ -21,7 +21,7 @@ export const moveSchema = Type.Object(
|
|
|
21
21
|
start: Type.Optional(
|
|
22
22
|
Type.String({
|
|
23
23
|
description:
|
|
24
|
-
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line.
|
|
24
|
+
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line. Omit when path already selects text through a supported resource reference. With end, selects a whole-line range.",
|
|
25
25
|
}),
|
|
26
26
|
),
|
|
27
27
|
end: Type.Optional(
|
|
@@ -21,7 +21,7 @@ export const replaceSchema = Type.Object(
|
|
|
21
21
|
start: Type.Optional(
|
|
22
22
|
Type.String({
|
|
23
23
|
description:
|
|
24
|
-
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line.
|
|
24
|
+
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line. Omit when path already selects text through a supported resource reference. With end, selects a whole-line range.",
|
|
25
25
|
}),
|
|
26
26
|
),
|
|
27
27
|
end: Type.Optional(
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
3
|
+
import {
|
|
4
|
+
createApplyResultRenderer,
|
|
5
|
+
createApplyCallRenderer,
|
|
6
|
+
} from "pi-agent-text-editor/api/apply-renderer";
|
|
7
|
+
import type { AnyTextMutationToolRegistration } from "pi-agent-text-editor/api/mutation-tool";
|
|
8
|
+
import { MutationPanel } from "./src/mutation-panel.js";
|
|
9
|
+
import { resolveMutationResultResources } from "./src/mutation-result.js";
|
|
1
10
|
import { connectTextEditorPlugin } from "pi-agent-text-editor/api/connect-plugin";
|
|
2
11
|
import {
|
|
3
12
|
TEXT_EDITOR_API_VERSION,
|
|
@@ -6,7 +15,7 @@ import {
|
|
|
6
15
|
} from "pi-agent-text-editor/api/plugin-protocol";
|
|
7
16
|
|
|
8
17
|
import { createMutationAnimationPressure } from "./src/animation-pressure.js";
|
|
9
|
-
import { registerMutationRenderers } from "./src/renderer.js";
|
|
18
|
+
import { registerMutationRenderers, renderWrittenMutationHeader } from "./src/renderer.js";
|
|
10
19
|
|
|
11
20
|
import { compactMutationDetails } from "./src/persisted-result.js";
|
|
12
21
|
import type { FileMutationBatchResult } from "pi-agent-text-editor/api/mutation-result";
|
|
@@ -20,6 +29,84 @@ export default async function registerTextEditorRenderer(pi: ExtensionAPI): Prom
|
|
|
20
29
|
apiVersion: TEXT_EDITOR_API_VERSION,
|
|
21
30
|
id: "text-editor-renderer",
|
|
22
31
|
setup(api) {
|
|
32
|
+
const registrations = new Map<string, AnyTextMutationToolRegistration>();
|
|
33
|
+
api.onMutationTool((registration) => registrations.set(registration.name, registration));
|
|
34
|
+
api.addToolRenderer({
|
|
35
|
+
tool: "diff",
|
|
36
|
+
renderResult(result, options, theme, context) {
|
|
37
|
+
const details = result.details as FileMutationBatchResult | undefined;
|
|
38
|
+
if (context.isError || details?.results === undefined)
|
|
39
|
+
return new Text(
|
|
40
|
+
result.content
|
|
41
|
+
.filter((block) => block.type === "text")
|
|
42
|
+
.map((block) => block.text)
|
|
43
|
+
.join("\n"),
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
);
|
|
47
|
+
const panel = new MutationPanel(theme);
|
|
48
|
+
panel.setBackground("toolSuccessBg");
|
|
49
|
+
panel.setExpanded(options.expanded);
|
|
50
|
+
panel.setResourceLabelsVisible(true);
|
|
51
|
+
panel.setResultResources(resolveMutationResultResources(details, undefined));
|
|
52
|
+
return panel;
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
api.addToolRenderer({
|
|
56
|
+
tool: "apply",
|
|
57
|
+
renderCall: createApplyCallRenderer((call, theme) => {
|
|
58
|
+
const registration = registrations.get(call.name === "remove" ? "delete" : call.name);
|
|
59
|
+
const display = (argument: typeof call.path) =>
|
|
60
|
+
argument ? (argument.literal ? argument.text : `‹${argument.text}›`) : "…";
|
|
61
|
+
const source = display(
|
|
62
|
+
call.arguments[registration?.source.field ?? "path"] ?? call.arguments.file,
|
|
63
|
+
);
|
|
64
|
+
const identityKeys =
|
|
65
|
+
call.name === "diff"
|
|
66
|
+
? ["before", "after"]
|
|
67
|
+
: call.name === "search"
|
|
68
|
+
? ["path", "query"]
|
|
69
|
+
: [registration?.source.field ?? (call.arguments.file ? "file" : "path"), "target"];
|
|
70
|
+
const parameters = Object.entries(call.arguments)
|
|
71
|
+
.filter(([key]) => !identityKeys.includes(key))
|
|
72
|
+
.map(([key, value]) => `${key}: ${display(value)}`)
|
|
73
|
+
.join(" · ");
|
|
74
|
+
const suffix = parameters ? ` ${theme.fg("dim", parameters)}` : "";
|
|
75
|
+
if (registration)
|
|
76
|
+
return (
|
|
77
|
+
renderWrittenMutationHeader(
|
|
78
|
+
registration,
|
|
79
|
+
{
|
|
80
|
+
[registration.source.field]: source,
|
|
81
|
+
...(call.target ? { target: display(call.target) } : {}),
|
|
82
|
+
},
|
|
83
|
+
theme,
|
|
84
|
+
) + suffix
|
|
85
|
+
);
|
|
86
|
+
const identity =
|
|
87
|
+
call.name === "search"
|
|
88
|
+
? `${display(call.query)}${call.path ? ` · ${source}` : ""}`
|
|
89
|
+
: call.name === "diff"
|
|
90
|
+
? `${display(call.before)} → ${display(call.after)}`
|
|
91
|
+
: `${source}${call.target ? ` → ${display(call.target)}` : ""}`;
|
|
92
|
+
return `${theme.fg("toolTitle", theme.bold(call.name))} ${theme.fg("accent", identity)}${suffix}`;
|
|
93
|
+
}),
|
|
94
|
+
renderResult: createApplyResultRenderer((details, theme, expanded, cwd) => {
|
|
95
|
+
const panel = new MutationPanel(theme);
|
|
96
|
+
panel.setBackground("toolSuccessBg");
|
|
97
|
+
panel.setExpanded(expanded);
|
|
98
|
+
panel.setResourceLabelsVisible(true);
|
|
99
|
+
panel.setResultResources(
|
|
100
|
+
resolveMutationResultResources(details, undefined).map((resource) => ({
|
|
101
|
+
...resource,
|
|
102
|
+
path: path.isAbsolute(resource.path)
|
|
103
|
+
? path.relative(cwd, resource.path)
|
|
104
|
+
: resource.path,
|
|
105
|
+
})),
|
|
106
|
+
);
|
|
107
|
+
return panel;
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
23
110
|
const tools = new Set<string>();
|
|
24
111
|
api.onMutationTool(({ name }) => tools.add(name));
|
|
25
112
|
registerMutationRenderers(
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"diff": "^9.0.0",
|
|
10
|
-
"pi-agent-invariant": "0.
|
|
11
|
-
"pi-agent-text-editor": "0.
|
|
12
|
-
"pi-agent-tool-call-interception": "0.
|
|
13
|
-
"pi-agent-tool-ui": "0.
|
|
10
|
+
"pi-agent-invariant": "0.4.0",
|
|
11
|
+
"pi-agent-text-editor": "0.4.0",
|
|
12
|
+
"pi-agent-tool-call-interception": "0.4.0",
|
|
13
|
+
"pi-agent-tool-ui": "0.4.0"
|
|
14
14
|
},
|
|
15
15
|
"pi": {
|
|
16
16
|
"extensions": [
|
|
17
|
-
"./runtime/entry-
|
|
17
|
+
"./runtime/entry-71.js"
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
@@ -16,6 +16,7 @@ import { createDiffModel, type DiffModel, type DiffRow } from "./diff-model.js";
|
|
|
16
16
|
import { type DiffPanelResource, renderDiffPanel } from "./diff-renderer.js";
|
|
17
17
|
|
|
18
18
|
import type { MutationRenderResource } from "./render-resource.js";
|
|
19
|
+
import { summarizeStatuses } from "./status-summary.js";
|
|
19
20
|
|
|
20
21
|
type ToolBackground = "toolPendingBg" | "toolSuccessBg" | "toolErrorBg";
|
|
21
22
|
|
|
@@ -236,32 +237,48 @@ function renderTail(
|
|
|
236
237
|
width: number,
|
|
237
238
|
): string[] {
|
|
238
239
|
const counts = renderCounts(resources, theme);
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
240
|
+
const grouped = summarizeStatuses(
|
|
241
|
+
resources.map((resource) => ({
|
|
242
|
+
path: resource.path,
|
|
243
|
+
diffStatuses: [
|
|
244
|
+
...(resource.diffStatuses ?? []),
|
|
245
|
+
...(resource.model?.omittedChanges === undefined
|
|
246
|
+
? []
|
|
247
|
+
: [
|
|
248
|
+
{
|
|
249
|
+
text: resource.model.omittedChanges.unavailable
|
|
250
|
+
? "Local diff unavailable: alignment limit reached"
|
|
251
|
+
: [
|
|
252
|
+
...(resource.model.omittedChanges.outside > 0
|
|
253
|
+
? [
|
|
254
|
+
`${resource.model.omittedChanges.outside} changed rows outside this area`,
|
|
255
|
+
]
|
|
256
|
+
: []),
|
|
257
|
+
...(resource.model.omittedChanges.ambiguous > 0
|
|
258
|
+
? [`${resource.model.omittedChanges.ambiguous} changed rows unassigned`]
|
|
259
|
+
: []),
|
|
260
|
+
].join("; "),
|
|
261
|
+
tone: "warning" as const,
|
|
262
|
+
},
|
|
263
|
+
]),
|
|
264
|
+
],
|
|
265
|
+
})),
|
|
264
266
|
);
|
|
267
|
+
const statuses = grouped.statuses.map(({ status, paths }) => {
|
|
268
|
+
const label = resources.length > 1 ? `${paths.join(", ")}: ${status.text}` : status.text;
|
|
269
|
+
return theme.fg(status.tone ?? "muted", label.replace(/[\u0000-\u001f\u007f-\u009f]/g, " "));
|
|
270
|
+
});
|
|
271
|
+
if (grouped.formatted.length > 0) {
|
|
272
|
+
const by =
|
|
273
|
+
grouped.formatters.length === 1
|
|
274
|
+
? grouped.formatters[0]
|
|
275
|
+
: `${grouped.formatters.length} formatters`;
|
|
276
|
+
const label =
|
|
277
|
+
resources.length === 1
|
|
278
|
+
? `Formatted (${by})`
|
|
279
|
+
: `Formatted ${grouped.formatted.length} files by ${by}`;
|
|
280
|
+
statuses.unshift(theme.fg("success", label.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")));
|
|
281
|
+
}
|
|
265
282
|
const text = [counts, ...statuses]
|
|
266
283
|
.filter((item) => item !== undefined)
|
|
267
284
|
.join(theme.fg("dim", " · "));
|