pi-agent-ide 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +12 -8
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/{chunk-WNMGUALD.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -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-KAB3AYA2.js +1 -0
- package/dist/{chunk-THSCUT2L.js → chunk-LRYE2WCN.js} +1 -1
- 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-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-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 +6 -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 +61 -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-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/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 +173 -49
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +261 -9
- 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 +19 -10
- 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 +38 -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 +4 -15
- package/src/composite/extensions-config.ts +41 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +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 +61 -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 +19 -10
- 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/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 +173 -49
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +261 -9
- 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 +42 -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/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-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,
|
|
@@ -372,9 +376,16 @@ function mergeTargets(left: readonly TextTarget[], right: readonly TextTarget[])
|
|
|
372
376
|
merged.set(target.source, target);
|
|
373
377
|
continue;
|
|
374
378
|
}
|
|
379
|
+
if (
|
|
380
|
+
previous.expectedContent !== undefined &&
|
|
381
|
+
target.expectedContent !== undefined &&
|
|
382
|
+
previous.expectedContent !== target.expectedContent
|
|
383
|
+
)
|
|
384
|
+
throw new Error("Selections refer to different source revisions. Read the source again.");
|
|
375
385
|
const ranges = [...(previous.ranges ?? []), ...(target.ranges ?? [])];
|
|
376
386
|
merged.set(target.source, {
|
|
377
387
|
source: target.source,
|
|
388
|
+
expectedContent: target.expectedContent ?? previous.expectedContent,
|
|
378
389
|
...(ranges.length > 0 && { ranges: deduplicateRanges(ranges) }),
|
|
379
390
|
});
|
|
380
391
|
}
|
|
@@ -715,6 +726,37 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
715
726
|
publishAnchorRenderState?: (field: string, state: ToolCallAnchorRenderState) => void,
|
|
716
727
|
lastResolvedSource?: string,
|
|
717
728
|
): Promise<AgentToolResult<FileMutationBatchResult>> {
|
|
729
|
+
const execution = await executeTextMutationPipeline(
|
|
730
|
+
core,
|
|
731
|
+
definition,
|
|
732
|
+
parameters,
|
|
733
|
+
signal,
|
|
734
|
+
context,
|
|
735
|
+
publishAnchorRenderState,
|
|
736
|
+
lastResolvedSource,
|
|
737
|
+
);
|
|
738
|
+
const result = await buildToolResult(
|
|
739
|
+
core,
|
|
740
|
+
execution.pipeline,
|
|
741
|
+
execution.source,
|
|
742
|
+
context,
|
|
743
|
+
definition.name,
|
|
744
|
+
);
|
|
745
|
+
return execution.pipeline.kind === "completed" && execution.pipeline.state.metadata !== undefined
|
|
746
|
+
? { ...result, details: { ...result.details, metadata: execution.pipeline.state.metadata } }
|
|
747
|
+
: result;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/** Runs configured mutation semantics without creating model-facing presentation. */
|
|
751
|
+
export async function executeTextMutationPipeline<TParameters extends TSchema>(
|
|
752
|
+
core: TextEditorCore,
|
|
753
|
+
definition: TextMutationToolRegistration<TParameters>,
|
|
754
|
+
parameters: Static<TParameters>,
|
|
755
|
+
signal: AbortSignal | undefined,
|
|
756
|
+
context: ExtensionContext,
|
|
757
|
+
publishAnchorRenderState?: (field: string, state: ToolCallAnchorRenderState) => void,
|
|
758
|
+
lastResolvedSource?: string,
|
|
759
|
+
): Promise<{ readonly pipeline: TextEditExecutionOutcome; readonly source: string }> {
|
|
718
760
|
const source = mutationSource(definition, parameters);
|
|
719
761
|
const pipeline = await core.executeEdit(
|
|
720
762
|
definition.name,
|
|
@@ -725,6 +767,46 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
725
767
|
},
|
|
726
768
|
async (state) => {
|
|
727
769
|
try {
|
|
770
|
+
if (state.editPlan !== undefined) {
|
|
771
|
+
const plan = state.editPlan;
|
|
772
|
+
if (
|
|
773
|
+
plan.files.length === 0 ||
|
|
774
|
+
new Set(plan.files.map((file) => file.source)).size !== plan.files.length
|
|
775
|
+
)
|
|
776
|
+
throw new Error("Semantic edit plan must contain distinct source files.");
|
|
777
|
+
const outcome = await core.editTexts(
|
|
778
|
+
plan.files.map((file) => ({ source: file.source, read: true })),
|
|
779
|
+
{
|
|
780
|
+
cwd: state.cwd,
|
|
781
|
+
intent: definition.intent ?? "edit",
|
|
782
|
+
...(state.signal !== undefined && { signal: state.signal }),
|
|
783
|
+
},
|
|
784
|
+
(texts) => {
|
|
785
|
+
for (const file of plan.files) {
|
|
786
|
+
if (texts.get(file.source) !== file.expectedContent)
|
|
787
|
+
throw new Error(
|
|
788
|
+
"A semantic edit source changed. Resolve the symbol again before retrying.",
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
const edits = new Map(
|
|
792
|
+
plan.files.map((file) => [
|
|
793
|
+
file.source,
|
|
794
|
+
{ changes: file.changes, action: "edited" as const },
|
|
795
|
+
]),
|
|
796
|
+
);
|
|
797
|
+
return Promise.resolve({
|
|
798
|
+
changes: new Map(plan.files.map((file) => [file.source, file.changes])),
|
|
799
|
+
result: {
|
|
800
|
+
edits,
|
|
801
|
+
resultPresentations: new Map(
|
|
802
|
+
plan.files.map((file) => [file.source, "plain" as const]),
|
|
803
|
+
),
|
|
804
|
+
},
|
|
805
|
+
});
|
|
806
|
+
},
|
|
807
|
+
);
|
|
808
|
+
return await completeTextMutation(outcome, requiredValue(plan.files[0]).source);
|
|
809
|
+
}
|
|
728
810
|
const sources = await resolveMutationSources(
|
|
729
811
|
core,
|
|
730
812
|
definition,
|
|
@@ -744,6 +826,15 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
744
826
|
...(state.signal !== undefined && { signal: state.signal }),
|
|
745
827
|
},
|
|
746
828
|
async (texts, resolveAnchor) => {
|
|
829
|
+
for (const target of sources.targets) {
|
|
830
|
+
if (
|
|
831
|
+
target.expectedContent !== undefined &&
|
|
832
|
+
texts.get(target.source) !== target.expectedContent
|
|
833
|
+
)
|
|
834
|
+
throw new Error(
|
|
835
|
+
"The selected source changed before editing. Resolve the symbol again.",
|
|
836
|
+
);
|
|
837
|
+
}
|
|
747
838
|
const mutationContext = createMutationContext(
|
|
748
839
|
definition,
|
|
749
840
|
state.input,
|
|
@@ -776,9 +867,142 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
776
867
|
},
|
|
777
868
|
);
|
|
778
869
|
|
|
779
|
-
return
|
|
870
|
+
return { pipeline, source };
|
|
780
871
|
}
|
|
781
872
|
|
|
873
|
+
const scriptMutationScope = new AsyncLocalStorage<TextEditCompletion[]>();
|
|
874
|
+
|
|
875
|
+
async function captureScriptMutation<T>(core: TextEditorCore, action: () => Promise<T>) {
|
|
876
|
+
const completions: TextEditCompletion[] = [];
|
|
877
|
+
const unsubscribe = core.onDidEdit((completion) => {
|
|
878
|
+
if (scriptMutationScope.getStore() === completions) completions.push(completion);
|
|
879
|
+
});
|
|
880
|
+
try {
|
|
881
|
+
const value = await scriptMutationScope.run(completions, action);
|
|
882
|
+
return { kind: "completed" as const, value, completions };
|
|
883
|
+
} catch (error) {
|
|
884
|
+
return { kind: "failed" as const, error, completions };
|
|
885
|
+
} finally {
|
|
886
|
+
unsubscribe();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Runs the configured mutation pipeline and returns plain script data.
|
|
891
|
+
* onPresentation retains rich edit annotations on the host without sending classes to the guest.
|
|
892
|
+
*/
|
|
893
|
+
export async function executeScriptMutation<TParameters extends TSchema>(
|
|
894
|
+
core: TextEditorCore,
|
|
895
|
+
definition: TextMutationToolRegistration<TParameters>,
|
|
896
|
+
arguments_: unknown,
|
|
897
|
+
signal: AbortSignal | undefined,
|
|
898
|
+
context: ExtensionContext,
|
|
899
|
+
lastResolvedSource?: string,
|
|
900
|
+
onPresentation?: (source: string, result: FileMutationResult) => void,
|
|
901
|
+
): Promise<ScriptMutationOutcome> {
|
|
902
|
+
const parameters = prepareGuardedArguments(
|
|
903
|
+
definition.parameters,
|
|
904
|
+
arguments_,
|
|
905
|
+
definition.source.inherited ? definition.source.field : undefined,
|
|
906
|
+
lastResolvedSource,
|
|
907
|
+
definition.anchors ?? [],
|
|
908
|
+
);
|
|
909
|
+
if (!Value.Check(definition.parameters, parameters)) {
|
|
910
|
+
throw Object.assign(new Error(`Invalid arguments for ${definition.name}`), {
|
|
911
|
+
code: "INVALID_ARGUMENTS",
|
|
912
|
+
details: { operation: definition.name, effect: "not-applied" },
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
const captured = await captureScriptMutation(core, () =>
|
|
916
|
+
executeTextMutationPipeline(
|
|
917
|
+
core,
|
|
918
|
+
definition,
|
|
919
|
+
parameters,
|
|
920
|
+
signal,
|
|
921
|
+
context,
|
|
922
|
+
undefined,
|
|
923
|
+
lastResolvedSource,
|
|
924
|
+
),
|
|
925
|
+
);
|
|
926
|
+
const source =
|
|
927
|
+
captured.kind === "completed" ? captured.value.source : mutationSource(definition, parameters);
|
|
928
|
+
const observedFiles: ScriptMutationOutcome["files"] = captured.completions.map((completion) => ({
|
|
929
|
+
source: completion.resourceSource,
|
|
930
|
+
before: completion.existed ? completion.before.content : null,
|
|
931
|
+
after: completion.after.content,
|
|
932
|
+
action: definition.name === "write" ? "overwritten" : "edited",
|
|
933
|
+
changes: [],
|
|
934
|
+
formatting: { status: "not-reported" },
|
|
935
|
+
}));
|
|
936
|
+
const failed = (
|
|
937
|
+
code: string,
|
|
938
|
+
message: string,
|
|
939
|
+
effect: ScriptMutationOutcome["effect"],
|
|
940
|
+
completed: readonly string[] = [],
|
|
941
|
+
): ScriptMutationOutcome => ({
|
|
942
|
+
operation: definition.name,
|
|
943
|
+
ok: false,
|
|
944
|
+
effect: effect === "unknown" ? "unknown" : observedFiles.length > 0 ? "applied" : effect,
|
|
945
|
+
completed: [...new Set([...completed, ...observedFiles.map((file) => file.source)])],
|
|
946
|
+
files: observedFiles,
|
|
947
|
+
errors: [{ source, code, message }],
|
|
948
|
+
});
|
|
949
|
+
if (captured.kind === "failed")
|
|
950
|
+
return failed("EXECUTION_FAILED", errorMessage(captured.error), "unknown");
|
|
951
|
+
const { pipeline } = captured.value;
|
|
952
|
+
if (pipeline.kind === "failed")
|
|
953
|
+
return {
|
|
954
|
+
...failed(pipeline.failure.code, pipeline.failure.message, "not-applied"),
|
|
955
|
+
recoveries: await scriptAnchorRecoveries(pipeline.failure.cause),
|
|
956
|
+
};
|
|
957
|
+
const outcome = pipeline.state.result;
|
|
958
|
+
if (!isResourcesEditOutcome(outcome))
|
|
959
|
+
return failed("INVALID_RESULT", "Invalid mutation outcome", "unknown");
|
|
960
|
+
if (outcome.kind === "failed")
|
|
961
|
+
return {
|
|
962
|
+
...failed(
|
|
963
|
+
outcome.failure.code,
|
|
964
|
+
outcome.failure.message,
|
|
965
|
+
outcome.completed.length > 0 ? "unknown" : "not-applied",
|
|
966
|
+
outcome.completed,
|
|
967
|
+
),
|
|
968
|
+
recoveries: await scriptAnchorRecoveries(outcome.failure.cause),
|
|
969
|
+
};
|
|
970
|
+
const mutation = outcome.result as ExecutedTextMutation;
|
|
971
|
+
const files = outcome.resources.flatMap((resource) => {
|
|
972
|
+
const edit = mutation.edits.get(resource.source);
|
|
973
|
+
if (edit === undefined) return [];
|
|
974
|
+
const presentation = withPipelineStatuses(
|
|
975
|
+
buildSuccessfulTextMutationResult(resource, resource.source, edit),
|
|
976
|
+
pipeline.state.metadata,
|
|
977
|
+
);
|
|
978
|
+
onPresentation?.(resource.after.source, presentation);
|
|
979
|
+
const data = presentation.data;
|
|
980
|
+
return [
|
|
981
|
+
{
|
|
982
|
+
source: resource.after.source,
|
|
983
|
+
before:
|
|
984
|
+
captured.completions.find(
|
|
985
|
+
(completion) => completion.resourceSource === resource.after.source,
|
|
986
|
+
)?.existed === false
|
|
987
|
+
? null
|
|
988
|
+
: resource.before.content,
|
|
989
|
+
after: resource.after.content,
|
|
990
|
+
action: edit.action,
|
|
991
|
+
changes: data.rawChanges ?? [],
|
|
992
|
+
formatting: data.formatting ?? { status: "not-reported" as const },
|
|
993
|
+
},
|
|
994
|
+
];
|
|
995
|
+
});
|
|
996
|
+
return {
|
|
997
|
+
operation: definition.name,
|
|
998
|
+
ok: true,
|
|
999
|
+
effect: files.length > 0 ? "applied" : "not-applied",
|
|
1000
|
+
files,
|
|
1001
|
+
completed: files.map((file) => file.source),
|
|
1002
|
+
...(pipeline.state.metadata !== undefined && { metadata: pipeline.state.metadata }),
|
|
1003
|
+
errors: [],
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
782
1006
|
export function mutationSources(
|
|
783
1007
|
definition: TextMutationToolRegistration,
|
|
784
1008
|
parameters: Readonly<Record<string, unknown>>,
|
|
@@ -830,7 +1054,7 @@ export function buildSuccessfulTextMutationResult(
|
|
|
830
1054
|
): FileMutationResult {
|
|
831
1055
|
const before = resource.before.content;
|
|
832
1056
|
const finalAfter = resource.after.content;
|
|
833
|
-
const applied = applyTextChanges(before, edit.changes);
|
|
1057
|
+
const applied = applyTextChanges(before, edit.changes, before.length === 0);
|
|
834
1058
|
const unified = createUnifiedDiff(resultSource, before, diffAfterContent);
|
|
835
1059
|
const mutationResultData = resource.postEditContributions
|
|
836
1060
|
.map((contribution) => contribution.data)
|
|
@@ -857,7 +1081,7 @@ export function buildSuccessfulTextMutationResult(
|
|
|
857
1081
|
.flatMap((item) => item.diffStatuses),
|
|
858
1082
|
formatting: resource.postEditContributions
|
|
859
1083
|
.map((item) => item.data)
|
|
860
|
-
.
|
|
1084
|
+
.findLast(isFormattingContribution)?.formatting ?? { status: "not-reported" },
|
|
861
1085
|
ok: true,
|
|
862
1086
|
path: resultSource,
|
|
863
1087
|
diffs: [unified.diff],
|
|
@@ -960,12 +1184,43 @@ async function buildToolResult(
|
|
|
960
1184
|
];
|
|
961
1185
|
});
|
|
962
1186
|
|
|
1187
|
+
const presented = results.map((result) => withPipelineStatuses(result, pipeline.state.metadata));
|
|
963
1188
|
return {
|
|
964
|
-
content: [new FileMutationAgentResult(
|
|
965
|
-
details: { results },
|
|
1189
|
+
content: [new FileMutationAgentResult(presented).toTextContent()],
|
|
1190
|
+
details: { results: presented },
|
|
966
1191
|
};
|
|
967
1192
|
}
|
|
968
1193
|
|
|
1194
|
+
function withPipelineStatuses(result: FileMutationResult, metadata: unknown): FileMutationResult {
|
|
1195
|
+
if (!isDiffStatusContribution(metadata)) return result;
|
|
1196
|
+
return new FileMutationResult({
|
|
1197
|
+
...result.data,
|
|
1198
|
+
diffStatuses: [...(result.data.diffStatuses ?? []), ...metadata.diffStatuses],
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
async function resolveAnchorRecovery(error: TextMutationAnchorResolutionError) {
|
|
1202
|
+
if (error.resolution.recovery === undefined) await error.resolution.refreshRecovery();
|
|
1203
|
+
return error.resolution.recovery;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
async function scriptAnchorRecoveries(
|
|
1207
|
+
cause: unknown,
|
|
1208
|
+
): Promise<NonNullable<ScriptMutationOutcome["recoveries"]>> {
|
|
1209
|
+
if (cause instanceof TextMutationAnchorAggregateError)
|
|
1210
|
+
return (await Promise.all(cause.failures.map(scriptAnchorRecoveries))).flat();
|
|
1211
|
+
if (!(cause instanceof TextMutationAnchorResolutionError)) return [];
|
|
1212
|
+
const recovery = await resolveAnchorRecovery(cause);
|
|
1213
|
+
return [
|
|
1214
|
+
{
|
|
1215
|
+
path: cause.source,
|
|
1216
|
+
field: cause.field,
|
|
1217
|
+
anchor: cause.anchor,
|
|
1218
|
+
status: recovery?.kind ?? "unavailable",
|
|
1219
|
+
candidates: recovery?.kind === "candidates" ? recovery.candidates : [],
|
|
1220
|
+
total: recovery?.kind === "candidates" ? recovery.total : 0,
|
|
1221
|
+
},
|
|
1222
|
+
];
|
|
1223
|
+
}
|
|
969
1224
|
async function anchorFailureToolResult(
|
|
970
1225
|
core: TextEditorCore,
|
|
971
1226
|
failure: TextResourceEditFailure,
|
|
@@ -1006,10 +1261,7 @@ async function anchorFailureToolResult(
|
|
|
1006
1261
|
|
|
1007
1262
|
const contextual = failure.cause;
|
|
1008
1263
|
const resolution = contextual.resolution;
|
|
1009
|
-
|
|
1010
|
-
await resolution.refreshRecovery();
|
|
1011
|
-
}
|
|
1012
|
-
const recovery = resolution.recovery;
|
|
1264
|
+
const recovery = await resolveAnchorRecovery(contextual);
|
|
1013
1265
|
if (recovery?.kind === "timed-out") {
|
|
1014
1266
|
return failureToolResult(
|
|
1015
1267
|
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(
|
package/src/pi-agent-ide.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
resolvePiAgentIdeExtensionsConfigPaths,
|
|
5
5
|
} from "#src/composite/extensions-config.js";
|
|
6
6
|
import { selectBuiltinExtensions } from "#src/composite/selection.js";
|
|
7
|
+
import { registerModuleSettings } from "#src/composite/module-settings.js";
|
|
8
|
+
import { createFeatureFlags } from "#src/composite/feature-flags.js";
|
|
7
9
|
|
|
8
10
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
9
11
|
|
|
@@ -21,17 +23,49 @@ export default async function registerUnifiedPiAgentIde(pi: ExtensionAPI): Promi
|
|
|
21
23
|
return systemPrompt === event.systemPrompt ? undefined : { systemPrompt };
|
|
22
24
|
});
|
|
23
25
|
const config = await readPiAgentIdeExtensionsConfig(resolvePiAgentIdeExtensionsConfigPaths());
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const flags = createFeatureFlags(pi, {
|
|
27
|
+
"pi-agent-ide-no-animations": config.noAnimations ?? false,
|
|
28
|
+
"pi-agent-ide-no-post-processing": config.noPostProcessing ?? false,
|
|
29
|
+
...config.flags,
|
|
28
30
|
});
|
|
29
|
-
|
|
31
|
+
flags.register({
|
|
32
|
+
id: "pi-agent-ide-no-animations",
|
|
33
|
+
name: "Static edit previews",
|
|
34
|
+
group: "ui",
|
|
35
|
+
description: "Show edit results immediately, without animated playback.",
|
|
36
|
+
default: false,
|
|
37
|
+
});
|
|
38
|
+
flags.register({
|
|
39
|
+
id: "pi-agent-ide-no-post-processing",
|
|
40
|
+
name: "Skip automatic post-processing",
|
|
41
|
+
description:
|
|
42
|
+
"Skip automatic formatting and diagnostics after edits. Explicit diagnostic reads still work.",
|
|
43
|
+
default: false,
|
|
44
|
+
});
|
|
45
|
+
flags.register({
|
|
46
|
+
id: "pi-agent-ide-no-apply",
|
|
47
|
+
name: "Disable Apply",
|
|
48
|
+
description: "Hide the Apply tool. Standalone read, search and editing tools remain available.",
|
|
49
|
+
default: false,
|
|
50
|
+
});
|
|
51
|
+
flags.register({
|
|
52
|
+
id: "pi-agent-ide-apply-code",
|
|
53
|
+
name: "Apply presentation",
|
|
54
|
+
description:
|
|
55
|
+
"Mixed compacts written tool calls during streaming. Code shows the full script. Expanded always exposes the source.",
|
|
56
|
+
group: "ui",
|
|
57
|
+
labels: { on: "Code", off: "Mixed" },
|
|
58
|
+
default: false,
|
|
59
|
+
});
|
|
60
|
+
flags.register({
|
|
61
|
+
id: "pi-agent-ide-no-diagnostic-buffer",
|
|
62
|
+
name: "Immediate diagnostic notices",
|
|
30
63
|
description:
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
default:
|
|
64
|
+
"Send findings immediately instead of combining reports received over five seconds.",
|
|
65
|
+
group: "ui",
|
|
66
|
+
default: false,
|
|
34
67
|
});
|
|
68
|
+
registerModuleSettings(pi, flags.definitions);
|
|
35
69
|
const { enabled } = selectBuiltinExtensions(BUILTIN_EXTENSIONS, config.disabled, config.enabled);
|
|
36
70
|
|
|
37
71
|
for (const extension of enabled) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-ast",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@tree-sitter-grammars/tree-sitter-toml": "^0.7.0",
|
|
16
16
|
"@tree-sitter-grammars/tree-sitter-yaml": "^0.7.1",
|
|
17
|
-
"pi-agent-doctor": "0.
|
|
18
|
-
"pi-agent-invariant": "0.
|
|
19
|
-
"pi-agent-read": "0.
|
|
20
|
-
"pi-agent-resource": "0.
|
|
21
|
-
"pi-agent-search": "0.
|
|
22
|
-
"pi-agent-text": "0.
|
|
23
|
-
"pi-agent-text-editor": "0.
|
|
17
|
+
"pi-agent-doctor": "0.3.0",
|
|
18
|
+
"pi-agent-invariant": "0.3.0",
|
|
19
|
+
"pi-agent-read": "0.3.0",
|
|
20
|
+
"pi-agent-resource": "0.3.0",
|
|
21
|
+
"pi-agent-search": "0.3.0",
|
|
22
|
+
"pi-agent-text": "0.3.0",
|
|
23
|
+
"pi-agent-text-editor": "0.3.0",
|
|
24
24
|
"tree-sitter-cpp": "^0.23.4",
|
|
25
25
|
"tree-sitter-javascript": "^0.25.0",
|
|
26
26
|
"tree-sitter-json": "^0.24.8",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@earendil-works/pi-coding-agent": "*",
|
|
39
|
-
"pi-agent-ide": "0.
|
|
39
|
+
"pi-agent-ide": "0.3.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import { AstScopeManager } from "./ast/manager.js";
|
|
22
22
|
import { astDoctorPlugin } from "./doctor-plugin.js";
|
|
23
23
|
import { createAstOutlineResolver } from "./outline-resolver.js";
|
|
24
|
-
import { createAstOverflowHandler } from "./overflow-handler.js";
|
|
24
|
+
import { createAstOverflowHandler, reduceAstReadOutput } from "./overflow-handler.js";
|
|
25
25
|
import { createAstScopePostReadHandler, createAstScopePresenter } from "./scope-handler.js";
|
|
26
26
|
import { createAstScopeAnchorResolver } from "./scope-resolver.js";
|
|
27
27
|
import { createAstSearchResolver } from "./search-resolver.js";
|
|
@@ -45,6 +45,7 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
45
45
|
});
|
|
46
46
|
api.addView({ view: "ast", presenter });
|
|
47
47
|
const overflow = createAstOverflowHandler();
|
|
48
|
+
api.addOutputReducer(reduceAstReadOutput);
|
|
48
49
|
const scopes = createAstScopePostReadHandler();
|
|
49
50
|
api.addHandler({
|
|
50
51
|
stage: "post-read",
|
|
@@ -81,9 +82,9 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
81
82
|
apiVersion: SEARCH_API_VERSION,
|
|
82
83
|
id: "ast-search",
|
|
83
84
|
setup(api): void {
|
|
84
|
-
api.addResolver({ resolver: createAstSearchResolver() });
|
|
85
|
+
api.addResolver({ resolver: createAstSearchResolver(api.registerSelection) });
|
|
85
86
|
api.describe(
|
|
86
|
-
"Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search.",
|
|
87
|
+
"Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.",
|
|
87
88
|
);
|
|
88
89
|
},
|
|
89
90
|
}),
|
|
@@ -1,60 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_MAX_BYTES,
|
|
3
|
+
DEFAULT_MAX_LINES,
|
|
4
|
+
truncateHead,
|
|
5
|
+
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import type { ReadOutputReducer, ReadPostReadHandler } from "pi-agent-read/api/tools/read";
|
|
3
7
|
import type { SourceViewBlock } from "pi-agent-ide/api/code-view";
|
|
4
8
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
/** Builds a compact source view from recorded text, never from a newer filesystem snapshot. */
|
|
10
|
+
export const reduceAstReadOutput: ReadOutputReducer = async (result, context, budget) => {
|
|
11
|
+
const { source, resolvedBy, lines, totalLines, startLine } = result.details;
|
|
12
|
+
if (
|
|
13
|
+
source === undefined ||
|
|
14
|
+
resolvedBy !== "filesystem" ||
|
|
15
|
+
lines === undefined ||
|
|
16
|
+
lines.length !== totalLines ||
|
|
17
|
+
(startLine !== undefined && startLine !== 1)
|
|
18
|
+
)
|
|
19
|
+
return undefined;
|
|
20
|
+
try {
|
|
21
|
+
const { AstOutlineManager, isSupportedOutlinePath } = await import("./ast/outline.js");
|
|
22
|
+
if (!isSupportedOutlinePath(source)) return undefined;
|
|
23
|
+
const format = (outline: SourceViewBlock): string =>
|
|
24
|
+
[
|
|
25
|
+
`AST overview of ${outline.path}, source lines 1-${outline.totalLines}: the requested text exceeded the read buffer.`,
|
|
26
|
+
"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",
|
|
27
|
+
...outline.renderedLines.map(
|
|
28
|
+
(line) => `${line.sourceLine?.lineNumber ?? "…"} | ${line.text}`,
|
|
29
|
+
),
|
|
30
|
+
].join("\n");
|
|
31
|
+
context.signal?.throwIfAborted();
|
|
32
|
+
const outline = await new AstOutlineManager(12).readDocumentOutline(
|
|
33
|
+
source,
|
|
34
|
+
context.cwd,
|
|
35
|
+
lines.map((line) => line.content),
|
|
36
|
+
(candidate) => {
|
|
37
|
+
context.signal?.throwIfAborted();
|
|
38
|
+
return !truncateHead(format(candidate), budget).truncated;
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
const text = format(outline);
|
|
42
|
+
if (truncateHead(text, budget).truncated) return undefined;
|
|
43
|
+
return { content: [{ type: "text", text }], details: { source, resolvedBy: "ast-overflow" } };
|
|
44
|
+
} catch {
|
|
45
|
+
context.signal?.throwIfAborted();
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Replace an overflowing read window with a source-numbered whole-file outline. */
|
|
8
51
|
export function createAstOverflowHandler(): ReadPostReadHandler {
|
|
9
52
|
return async (context) => {
|
|
10
53
|
const { state, result } = context;
|
|
11
54
|
const block = result?.content.length === 1 ? result.content[0] : undefined;
|
|
12
55
|
if (
|
|
56
|
+
context.audience === "script" ||
|
|
57
|
+
result === undefined ||
|
|
13
58
|
state?.contentKind !== "text" ||
|
|
14
59
|
state.resolvedBy !== "filesystem" ||
|
|
15
60
|
block?.type !== "text" ||
|
|
16
61
|
!truncateHead(block.text).truncated
|
|
17
|
-
)
|
|
62
|
+
)
|
|
18
63
|
return { kind: "continue", context };
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
...outline.renderedLines.map(
|
|
30
|
-
(line) => `${line.sourceLine?.lineNumber ?? "…"} | ${line.text}`,
|
|
31
|
-
),
|
|
32
|
-
].join("\n");
|
|
33
|
-
context.resolverContext.signal?.throwIfAborted();
|
|
34
|
-
const outline = await new AstOutlineManager(12).readDocumentOutline(
|
|
35
|
-
state.source,
|
|
36
|
-
context.resolverContext.cwd,
|
|
37
|
-
state.text.lines.map((line) => line.content),
|
|
38
|
-
(candidate) => {
|
|
39
|
-
context.resolverContext.signal?.throwIfAborted();
|
|
40
|
-
return !truncateHead(format(candidate)).truncated;
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
const text = format(outline);
|
|
44
|
-
// Even a pathological source label must respect the output budget.
|
|
45
|
-
if (truncateHead(text).truncated) {
|
|
46
|
-
return { kind: "continue", context };
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
kind: "return",
|
|
50
|
-
result: {
|
|
51
|
-
content: [{ type: "text", text }],
|
|
52
|
-
details: { source: state.source, resolvedBy: "ast-overflow" },
|
|
64
|
+
const reduced = await reduceAstReadOutput(
|
|
65
|
+
{
|
|
66
|
+
...result,
|
|
67
|
+
details: {
|
|
68
|
+
...result.details,
|
|
69
|
+
source: state.source,
|
|
70
|
+
resolvedBy: state.resolvedBy,
|
|
71
|
+
lines: state.text.lines,
|
|
72
|
+
startLine: 1,
|
|
73
|
+
totalLines: state.text.lines.length,
|
|
53
74
|
},
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
},
|
|
76
|
+
context.resolverContext,
|
|
77
|
+
{ maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES },
|
|
78
|
+
);
|
|
79
|
+
return reduced === undefined
|
|
80
|
+
? { kind: "continue", context }
|
|
81
|
+
: { kind: "return", result: reduced };
|
|
59
82
|
};
|
|
60
83
|
}
|