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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_MAX_BYTES,
|
|
3
|
+
DEFAULT_MAX_LINES,
|
|
4
|
+
truncateHead,
|
|
5
|
+
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { isAgentContent } from "pi-agent-resource";
|
|
7
|
+
import type { ReadPluginApi } from "pi-agent-read/api/plugin-protocol";
|
|
8
|
+
import type { ReadToolResult, ReadResultDetails } from "pi-agent-read/api/tools/read";
|
|
9
|
+
import type { ResourceResolverContext } from "pi-agent-resource";
|
|
10
|
+
import type { ApplyResults } from "#src/core/apply/results.js";
|
|
11
|
+
import { FileMutationAgentResult } from "#src/core/mutation-result/file-mutation-agent-result.js";
|
|
12
|
+
import { finalApplyMutations } from "./final-mutations.js";
|
|
13
|
+
import { serializeApplyError } from "#src/core/apply/runtime.js";
|
|
14
|
+
|
|
15
|
+
type Content = ReadToolResult["content"];
|
|
16
|
+
/** Output level is presentation only; full data stays in the host ledger. */
|
|
17
|
+
export interface ApplyOutput {
|
|
18
|
+
readonly content: Content;
|
|
19
|
+
readonly level: "full" | "compact" | "summary";
|
|
20
|
+
readonly temporarySource?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Presents net file effects once, preserving native images and one combined text budget. */
|
|
24
|
+
export async function renderApplyOutput(
|
|
25
|
+
results: ApplyResults,
|
|
26
|
+
read: Pick<ReadPluginApi, "saveTemporary"> & Partial<Pick<ReadPluginApi, "reduceOutput">>,
|
|
27
|
+
error?: unknown,
|
|
28
|
+
context: ResourceResolverContext = { cwd: process.cwd() },
|
|
29
|
+
): Promise<ApplyOutput> {
|
|
30
|
+
const selected = results.select();
|
|
31
|
+
const sections: { content: Content; read?: ReadToolResult }[] = selected.explicit.map(
|
|
32
|
+
(entry) => ({
|
|
33
|
+
content: renderValue(
|
|
34
|
+
entry.kind === "operation" ? (entry.presentation ?? entry.value) : entry.value,
|
|
35
|
+
),
|
|
36
|
+
read:
|
|
37
|
+
entry.kind === "operation" ? (entry.presentation ?? asReadResult(entry.value)) : undefined,
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
const content: Content = sections.flatMap((section) => section.content);
|
|
41
|
+
const mutations = selected.automatic.filter(({ kind }) => kind === "mutation");
|
|
42
|
+
for (const operation of selected.automatic) {
|
|
43
|
+
if (
|
|
44
|
+
operation.kind === "read" ||
|
|
45
|
+
isFailure(operation.value) ||
|
|
46
|
+
(operation.value !== null &&
|
|
47
|
+
typeof operation.value === "object" &&
|
|
48
|
+
"kind" in operation.value &&
|
|
49
|
+
(operation.value.kind === "file-operation" || operation.value.kind === "index-operation"))
|
|
50
|
+
) {
|
|
51
|
+
const section = {
|
|
52
|
+
content: renderValue(operation.presentation ?? operation.value),
|
|
53
|
+
read:
|
|
54
|
+
operation.kind === "read"
|
|
55
|
+
? (operation.presentation ?? asReadResult(operation.value))
|
|
56
|
+
: undefined,
|
|
57
|
+
};
|
|
58
|
+
sections.push(section);
|
|
59
|
+
content.push(...section.content);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const operation of mutations) {
|
|
63
|
+
const value = operation.value;
|
|
64
|
+
if (!isFailure(value) && value !== null && typeof value === "object" && "metadata" in value) {
|
|
65
|
+
const section = { content: renderValue(value.metadata), read: undefined };
|
|
66
|
+
sections.push(section);
|
|
67
|
+
content.push(...section.content);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const suffixStart = content.length;
|
|
71
|
+
const finalMutations = finalApplyMutations(results);
|
|
72
|
+
if (finalMutations.length > 0)
|
|
73
|
+
content.push(new FileMutationAgentResult(finalMutations).toTextContent());
|
|
74
|
+
if (error !== undefined) content.push(text(formatError(error)));
|
|
75
|
+
if (content.length === 0) content.push(text("No operations or explicit results."));
|
|
76
|
+
const full = textContent(content);
|
|
77
|
+
if (!truncateHead(full).truncated) return { content, level: "full" };
|
|
78
|
+
const temporarySource = await read.saveTemporary(full);
|
|
79
|
+
const footer = `\n\nFull Apply output: ${temporarySource}. Read this reference with offset/limit for more.`;
|
|
80
|
+
if (read.reduceOutput !== undefined && !context.signal?.aborted) {
|
|
81
|
+
const compact: Content = [];
|
|
82
|
+
const reducibleSections = sections.flatMap(expandReadSection);
|
|
83
|
+
const quota = Math.max(
|
|
84
|
+
1,
|
|
85
|
+
reducibleSections.filter((section) => section.read !== undefined).length,
|
|
86
|
+
);
|
|
87
|
+
for (const section of reducibleSections) {
|
|
88
|
+
let reduced: ReadToolResult | undefined;
|
|
89
|
+
if (section.read !== undefined) {
|
|
90
|
+
try {
|
|
91
|
+
reduced = await read.reduceOutput(section.read, context, {
|
|
92
|
+
maxBytes: Math.floor((DEFAULT_MAX_BYTES - Buffer.byteLength(footer)) / quota),
|
|
93
|
+
maxLines: Math.floor((DEFAULT_MAX_LINES - 3) / quota),
|
|
94
|
+
});
|
|
95
|
+
} catch {
|
|
96
|
+
/* Reduction is optional; keep the recorded result when it fails. */
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
compact.push(...(reduced?.content ?? section.content));
|
|
100
|
+
}
|
|
101
|
+
compact.push(...content.slice(suffixStart));
|
|
102
|
+
compact.push(text(footer.trimStart()));
|
|
103
|
+
if (!truncateHead(textContent(compact)).truncated)
|
|
104
|
+
return { content: compact, level: "compact", temporarySource };
|
|
105
|
+
}
|
|
106
|
+
const summary = [
|
|
107
|
+
`Apply output reduced: ${selected.automatic.length} automatic results, ${selected.explicit.length} explicit results, ${selected.files.length} final files.`,
|
|
108
|
+
...(error === undefined ? [] : [formatError(error)]),
|
|
109
|
+
...selected.automatic
|
|
110
|
+
.filter(({ value }) => isFailure(value))
|
|
111
|
+
.map(({ value, presentation }) => textContent(renderValue(presentation ?? value))),
|
|
112
|
+
...selected.files.map(({ source }) => source),
|
|
113
|
+
].join("\n");
|
|
114
|
+
const bounded = truncateHead(summary, {
|
|
115
|
+
maxBytes: DEFAULT_MAX_BYTES - Buffer.byteLength(footer),
|
|
116
|
+
maxLines: DEFAULT_MAX_LINES - 3,
|
|
117
|
+
}).content;
|
|
118
|
+
return {
|
|
119
|
+
content: [text(bounded + footer), ...content.filter((block) => block.type === "image")],
|
|
120
|
+
level: "summary",
|
|
121
|
+
temporarySource,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function text(value: string): Content[number] {
|
|
126
|
+
return { type: "text", text: value };
|
|
127
|
+
}
|
|
128
|
+
function textContent(content: Content): string {
|
|
129
|
+
return content
|
|
130
|
+
.filter((block) => block.type === "text")
|
|
131
|
+
.map((block) => block.text)
|
|
132
|
+
.join("\n\n");
|
|
133
|
+
}
|
|
134
|
+
function expandReadSection(section: {
|
|
135
|
+
content: Content;
|
|
136
|
+
read?: ReadToolResult;
|
|
137
|
+
}): { content: Content; read?: ReadToolResult }[] {
|
|
138
|
+
const resources = section.read?.details.resources;
|
|
139
|
+
return resources?.length
|
|
140
|
+
? resources.flatMap((read) => expandReadSection({ content: read.content, read }))
|
|
141
|
+
: [section];
|
|
142
|
+
}
|
|
143
|
+
function isFailure(value: unknown): boolean {
|
|
144
|
+
return value !== null && typeof value === "object" && "ok" in value && value.ok === false;
|
|
145
|
+
}
|
|
146
|
+
function formatError(error: unknown): string {
|
|
147
|
+
const failure = serializeApplyError(error);
|
|
148
|
+
return `${failure.code}: ${failure.message}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function renderValue(value: unknown): Content {
|
|
152
|
+
if (isAgentContent(value))
|
|
153
|
+
return value.map((block) => (block.type === "custom" ? text(JSON.stringify(block)) : block));
|
|
154
|
+
if (
|
|
155
|
+
value !== null &&
|
|
156
|
+
typeof value === "object" &&
|
|
157
|
+
"operation" in value &&
|
|
158
|
+
typeof value.operation === "string"
|
|
159
|
+
) {
|
|
160
|
+
const lines = [
|
|
161
|
+
`${value.operation}: ${"effect" in value ? String(value.effect) : isFailure(value) ? "failed" : "completed"}`,
|
|
162
|
+
];
|
|
163
|
+
if ("path" in value && typeof value.path === "string") lines.push(value.path);
|
|
164
|
+
if ("target" in value && typeof value.target === "string")
|
|
165
|
+
lines.push(`Target: ${value.target}`);
|
|
166
|
+
if ("errors" in value && Array.isArray(value.errors))
|
|
167
|
+
lines.push(...value.errors.map(formatReceiptError));
|
|
168
|
+
if ("error" in value) lines.push(formatReceiptError(value.error));
|
|
169
|
+
if (
|
|
170
|
+
isFailure(value) &&
|
|
171
|
+
"completed" in value &&
|
|
172
|
+
Array.isArray(value.completed) &&
|
|
173
|
+
value.completed.length > 0
|
|
174
|
+
)
|
|
175
|
+
lines.push(`Affected resources: ${value.completed.join(", ")}`);
|
|
176
|
+
return [text(lines.join("\n")), ...("metadata" in value ? renderValue(value.metadata) : [])];
|
|
177
|
+
}
|
|
178
|
+
if (typeof value === "string") return [text(value)];
|
|
179
|
+
if (
|
|
180
|
+
value !== null &&
|
|
181
|
+
typeof value === "object" &&
|
|
182
|
+
"content" in value &&
|
|
183
|
+
isAgentContent(value.content)
|
|
184
|
+
) {
|
|
185
|
+
return value.content.map((block) =>
|
|
186
|
+
block.type === "custom" ? text(JSON.stringify(block)) : block,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return [text(value === undefined ? "undefined" : JSON.stringify(value, null, 2))];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function asReadResult(value: unknown): ReadToolResult | undefined {
|
|
193
|
+
if (
|
|
194
|
+
value === null ||
|
|
195
|
+
typeof value !== "object" ||
|
|
196
|
+
!("source" in value) ||
|
|
197
|
+
typeof value.source !== "string" ||
|
|
198
|
+
!("lines" in value) ||
|
|
199
|
+
!Array.isArray(value.lines) ||
|
|
200
|
+
!("content" in value) ||
|
|
201
|
+
!isAgentContent(value.content)
|
|
202
|
+
)
|
|
203
|
+
return undefined;
|
|
204
|
+
return { content: renderValue(value), details: value as ReadResultDetails };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function formatReceiptError(value: unknown): string {
|
|
208
|
+
if (value === null || typeof value !== "object") return String(value);
|
|
209
|
+
return [
|
|
210
|
+
"source" in value ? String(value.source) : undefined,
|
|
211
|
+
"code" in value ? String(value.code) : undefined,
|
|
212
|
+
"message" in value ? String(value.message) : undefined,
|
|
213
|
+
]
|
|
214
|
+
.filter(Boolean)
|
|
215
|
+
.join(": ");
|
|
216
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Standalone-independent guide for the JavaScript helpers exposed by Apply. */
|
|
2
|
+
export const applyHelperGuide = `
|
|
3
|
+
Helper arguments (one object per call; ? means optional):
|
|
4
|
+
read({path: string, offset?: number, limit?: number, views?: string[]})
|
|
5
|
+
search({query: string, path?: string, include?: string, exclude?: string, caseSensitive?: boolean, wholeWord?: boolean, limit?: number})
|
|
6
|
+
diff({before: string | {path: string, offset?: number, limit?: number, views?: string[]}, after: string | {path: string, offset?: number, limit?: number, views?: string[]}})
|
|
7
|
+
write({path: string, content: string})
|
|
8
|
+
replace({path?: string, start?: string, end?: string, text: string})
|
|
9
|
+
insert({path?: string, anchor?: string, text: string, before?: boolean})
|
|
10
|
+
remove({path?: string, start?: string, end?: string})
|
|
11
|
+
copy({path?: string, start?: string, end?: string, target?: string, targetStart?: string, targetEnd?: string})
|
|
12
|
+
move({path?: string, start?: string, end?: string, target?: string, targetStart?: string, targetEnd?: string})
|
|
13
|
+
delete_file({path: string})
|
|
14
|
+
copy_file({path: string, target: string, overwrite?: boolean})
|
|
15
|
+
move_file({path: string, target: string, overwrite?: boolean})
|
|
16
|
+
undo({file?: string, change: string})
|
|
17
|
+
stage({file: string, change: string})
|
|
18
|
+
unstage({file: string, change: string})
|
|
19
|
+
result(value)
|
|
20
|
+
|
|
21
|
+
Whole-file helpers operate on local regular files. Configured post-processing can format copied or moved UTF-8 text targets; binary contents remain unchanged. delete_file permanently deletes a file; copy_file copies it; move_file moves or renames it. Directories and symlinks are rejected. Existing targets require overwrite: true. Use the same names and arguments for standalone calls and inside Apply; only the text delete tool is named remove inside JavaScript. Receipts contain kind: "file-operation", operation, ok, effect, path, target?, error?. An unknown effect requires inspection before retry; no automatic rollback.
|
|
22
|
+
|
|
23
|
+
Writes take effect immediately. Final post-processing runs once per surviving changed file when Apply finishes, including after a script error; automatic diagnostics follow final processing. Reads inside the script see current, not yet finally formatted text. Re-read final anchors in a later call when needed. Stage captures the current bytes, before end-of-Apply formatting. Explicit diagnostic reads still request checks at their call site.
|
|
24
|
+
|
|
25
|
+
Use path, not file_path. Pass a source to read; offset/limit select lines, not character ranges, except raw: sources where they select bytes. Negative offsets start from the end. Use views such as anchors, ast, diagnostics or changes. Sources also accept file://, HTTP(S), temp:, SEARCH#, ast:, diagnostics:, symbol: and graph: forms supported by read. Explicit diagnostic requests wait; an ordinary read does not.
|
|
26
|
+
Use read({path: "raw:local-file", offset: 0, limit: 64}) to inspect original bytes without conversion. In raw: reads, offset is a zero-based byte position (negative from EOF) and limit is a non-negative byte count; omit limit for all remaining bytes in the script. Raw reads return {kind: "bytes", source, byteOffset, byteLength, totalBytes, bytes: number[], ok}. Use result(doc) to display hex + ASCII. No views, text anchors or byte editing are supported.
|
|
27
|
+
Search query accepts literal text, Boolean conditions, regex:, files:, ast: and symbols:. limit is 1–1000. Reuse returned SEARCH references; do not invent session IDs. Search returns {resolverId, data, details, ok}; details contains resolver-specific selection metadata.
|
|
28
|
+
Use ast:<pattern> search for structural edits. Pass its returned SEARCH#...:N:match as path to replace, copy, move or remove; the selection covers the exact node, including multiline boundaries. Single references become stale after file changes; all selections rerun the original AST query and require complete results. Use data.matches and their metaVariables to compute replacement text. These are text edits, not reference-aware refactors. Use path/include/exclude to scope symbols: searches before the result limit is applied.
|
|
29
|
+
Text read returns {kind: "text", source, content: string, lines, startLine, endLine, totalLines, ok}. Each line contains content, lineNumber, lineEnding, anchors and available metadata. Native reads return {kind: "native", source, blocks, ok}; multi-source reads return {kind: "resources", resources, ok}. Check kind before using text-only fields.
|
|
30
|
+
Use unique exact text or an anchor returned by read/search for start, end and anchor. A whole-line anchor selects its line; end includes its final line. Omit end for a single selected fragment. begin/end are file-boundary anchors. Omit path only when a previous read/edit or a SEARCH reference identifies the source. A SEARCH selection may also supply the range without start/end. Insert goes after the selected line unless before:true. Copy/move target defaults to source; targetStart selects the destination, and targetEnd replaces an inclusive target line range instead of inserting after targetStart. remove deletes selected text, not a file. write creates or replaces the entire file.
|
|
31
|
+
Use symbol:<file>#<selector> as a declaration selection for copy, move, remove or replace when the LSP plugin is available. For example, copy({path: "symbol:src/a.ts#Example", target: "src/b.ts", targetStart: "end"}). Select parent/child for ambiguous names. Supply an explicit target for copy/move. This declaration-text fallback does not update imports or references; metadata.semanticEdit reports that limitation. Semantic insert is unsupported. Do not treat declaration replacement as a semantic rename.
|
|
32
|
+
Use replace({path: "symbol:src/a.ts#Example#name", text: "NewName"}) for native LSP rename, including references. Omit start/end. The #name suffix selects semantic rename rather than declaration replacement. If the server cannot rename, handle the failure; no identifier-text fallback is applied.
|
|
33
|
+
Use result(doc) to explicitly keep a read result with its source and presentation. Do not use result(doc.content) merely to display a read: it adds a separate raw string and loses the source/view information. Read-only calls are shown automatically, so mass reads need no result calls. Use result(value) for additional computed data; explicit additions survive mutations. Mutations return {operation, ok, effect, files, completed, errors, recoveries?, metadata?}; files contain source, before, after, changes and formatting. They are reported automatically as final per-file changes.
|
|
34
|
+
|
|
35
|
+
Use diff to compare text-readable sources without editing them. Each side accepts a source string or read request. The result is {kind: "diff", ok, equal, before: {source, sources, content}, after: {source, sources, content}, diff, stats: {added, removed}}. Multiple resources are joined with one newline in resolver order. Patch line numbers are relative to the selected text. Comparisons are automatic read-only output; use result(comparison) to keep one when the script also edits files.
|
|
36
|
+
Use stage/unstage with a current CHANGE# anchor from read({path: file, views: ["changes"]}) to change only the Git index. These operations return {kind: "index-operation", operation, ok, effect: "index-only", file, change, state, unchanged} and keep worktree content. Use undo({file, change: "last"}) to restore that file before its latest text-editor transaction, not the entire Apply call. Use undo({file, change: "CHANGE#..."}) to restore a selected change to HEAD in both worktree and index. Git operations require the Git changes module. Re-read stale changes before retrying; completed operations survive later failures.
|
|
37
|
+
Examples:
|
|
38
|
+
const doc = read({path: "src/example.ts"});
|
|
39
|
+
const line = doc.lines.find(line => line.content.includes("oldValue"));
|
|
40
|
+
if (line) replace({path: doc.source, start: line.anchors[0], text: line.content.replace("oldValue", "newValue")});
|
|
41
|
+
|
|
42
|
+
for (const path of ["README.md", "package.json"]) read({path});
|
|
43
|
+
|
|
44
|
+
Do not retry by guessing different argument names. Catch errors and inspect code/details; distinguish invalid arguments, unavailable services and stale/ambiguous anchors. Already applied edits remain applied.
|
|
45
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Serializes one Apply invocation, including calls submitted through Promise.all. */
|
|
2
|
+
export class ApplyQueue {
|
|
3
|
+
#tail: Promise<void> = Promise.resolve();
|
|
4
|
+
#closed = false;
|
|
5
|
+
|
|
6
|
+
/** Runs after earlier operations settle; a refusal does not poison later calls. */
|
|
7
|
+
submit<T>(operation: () => Promise<T>): Promise<T> {
|
|
8
|
+
if (this.#closed) return Promise.reject(new Error("Apply execution has ended"));
|
|
9
|
+
const pending = this.#tail.then(() => {
|
|
10
|
+
if (this.#closed) throw new Error("Apply execution has ended");
|
|
11
|
+
return operation();
|
|
12
|
+
});
|
|
13
|
+
this.#tail = pending.then(
|
|
14
|
+
() => undefined,
|
|
15
|
+
() => undefined,
|
|
16
|
+
);
|
|
17
|
+
return pending;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Stops queued calls and waits for active host work before reporting final effects. */
|
|
21
|
+
async close(): Promise<void> {
|
|
22
|
+
this.#closed = true;
|
|
23
|
+
await this.#tail;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { isDiffOutcome, diffPresentation } from "#src/core/diff-tool.js";
|
|
2
|
+
import { createApplySourceProjection, type ApplyCallPreview } from "./mixed-source.js";
|
|
3
|
+
import { isFileOperationResult, formatFileOperation } from "#src/core/file-operations.js";
|
|
4
|
+
import { createReadResultRenderer } from "pi-agent-read/api/rendering";
|
|
5
|
+
import type { ReadToolResult } from "pi-agent-read/api/tools/read";
|
|
6
|
+
import { Text, type Component } from "@earendil-works/pi-tui";
|
|
7
|
+
import type { FileMutationBatchResult } from "#src/api/mutation-result.js";
|
|
8
|
+
import { finalApplyMutations } from "./final-mutations.js";
|
|
9
|
+
import { highlightCode, type Theme, type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
10
|
+
import { wrapTextWithAnsi, visibleWidth, truncateToWidth } from "@earendil-works/pi-tui";
|
|
11
|
+
import { preserveEnclosingBackground } from "pi-agent-tool-ui";
|
|
12
|
+
import type { ApplyResults } from "./results.js";
|
|
13
|
+
import type { ApplyOutput } from "./output.js";
|
|
14
|
+
|
|
15
|
+
/** Deliberate user presentation, separate from model-facing operation receipts. */
|
|
16
|
+
export interface ApplyDisplay {
|
|
17
|
+
readonly blocks: readonly { readonly text: string; readonly read?: ReadToolResult }[];
|
|
18
|
+
readonly mutations?: FileMutationBatchResult;
|
|
19
|
+
readonly comparisons?: readonly FileMutationBatchResult[];
|
|
20
|
+
readonly cwd?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Build readable result blocks without exposing internal mutation receipts. */
|
|
24
|
+
export function createApplyDisplay(
|
|
25
|
+
results: ApplyResults,
|
|
26
|
+
output: ApplyOutput,
|
|
27
|
+
error?: unknown,
|
|
28
|
+
cwd = process.cwd(),
|
|
29
|
+
): ApplyDisplay {
|
|
30
|
+
const selected = results.select();
|
|
31
|
+
const diffEntries = [
|
|
32
|
+
...selected.automatic,
|
|
33
|
+
...selected.explicit.filter((entry) => entry.kind === "operation"),
|
|
34
|
+
].filter((entry) => isDiffOutcome(entry.value) && !entry.value.equal);
|
|
35
|
+
const comparisons = diffEntries.flatMap((entry) =>
|
|
36
|
+
isDiffOutcome(entry.value) ? [diffPresentation(entry.value, cwd)] : [],
|
|
37
|
+
);
|
|
38
|
+
const diffBlocks = new Set(diffEntries.flatMap((entry) => entry.presentation?.content ?? []));
|
|
39
|
+
if (selected.files.length === 0) {
|
|
40
|
+
const reads = [
|
|
41
|
+
...selected.automatic.map((entry) => entry.presentation),
|
|
42
|
+
...selected.explicit.map((entry) =>
|
|
43
|
+
entry.kind === "operation" ? entry.presentation : undefined,
|
|
44
|
+
),
|
|
45
|
+
].filter((read): read is ReadToolResult => read !== undefined);
|
|
46
|
+
return {
|
|
47
|
+
comparisons,
|
|
48
|
+
cwd,
|
|
49
|
+
blocks: output.content
|
|
50
|
+
.filter((block) => !diffBlocks.has(block))
|
|
51
|
+
.flatMap((block) =>
|
|
52
|
+
block.type === "text"
|
|
53
|
+
? [
|
|
54
|
+
{
|
|
55
|
+
text: block.text,
|
|
56
|
+
read: reads.find((read) => read.content.includes(block)),
|
|
57
|
+
},
|
|
58
|
+
]
|
|
59
|
+
: [],
|
|
60
|
+
),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const mutations = finalApplyMutations(results);
|
|
64
|
+
return {
|
|
65
|
+
...(mutations.length > 0 ? { mutations: { results: mutations } } : {}),
|
|
66
|
+
comparisons,
|
|
67
|
+
cwd,
|
|
68
|
+
blocks: [
|
|
69
|
+
...selected.explicit.flatMap((entry) => {
|
|
70
|
+
if (entry.kind === "operation" && isDiffOutcome(entry.value) && !entry.value.equal)
|
|
71
|
+
return [];
|
|
72
|
+
if (isFileOperationResult(entry.value)) return [{ text: formatFileOperation(entry.value) }];
|
|
73
|
+
if (entry.kind === "operation")
|
|
74
|
+
return (
|
|
75
|
+
entry.presentation?.content.flatMap((block) =>
|
|
76
|
+
block.type === "text" ? [{ text: block.text, read: entry.presentation }] : [],
|
|
77
|
+
) ?? []
|
|
78
|
+
);
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
text:
|
|
82
|
+
typeof entry.value === "string"
|
|
83
|
+
? entry.value
|
|
84
|
+
: entry.value === undefined
|
|
85
|
+
? "undefined"
|
|
86
|
+
: JSON.stringify(entry.value, null, 2),
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}),
|
|
90
|
+
...selected.automatic.flatMap(({ value, presentation }) => {
|
|
91
|
+
if (isFileOperationResult(value)) return [{ text: formatFileOperation(value) }];
|
|
92
|
+
if (
|
|
93
|
+
value !== null &&
|
|
94
|
+
typeof value === "object" &&
|
|
95
|
+
"kind" in value &&
|
|
96
|
+
value.kind === "index-operation"
|
|
97
|
+
)
|
|
98
|
+
return (
|
|
99
|
+
presentation?.content.flatMap((block) =>
|
|
100
|
+
block.type === "text" ? [{ text: block.text }] : [],
|
|
101
|
+
) ?? []
|
|
102
|
+
);
|
|
103
|
+
if (
|
|
104
|
+
value === null ||
|
|
105
|
+
typeof value !== "object" ||
|
|
106
|
+
!("errors" in value) ||
|
|
107
|
+
!Array.isArray(value.errors)
|
|
108
|
+
)
|
|
109
|
+
return [];
|
|
110
|
+
return value.errors.flatMap((error: unknown) =>
|
|
111
|
+
error !== null &&
|
|
112
|
+
typeof error === "object" &&
|
|
113
|
+
"message" in error &&
|
|
114
|
+
typeof error.message === "string"
|
|
115
|
+
? [{ text: error.message }]
|
|
116
|
+
: [],
|
|
117
|
+
);
|
|
118
|
+
}),
|
|
119
|
+
...(error === undefined
|
|
120
|
+
? []
|
|
121
|
+
: [{ text: error instanceof Error ? error.message : JSON.stringify(error) }]),
|
|
122
|
+
],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
type RenderState = {
|
|
127
|
+
applyResultReady?: boolean;
|
|
128
|
+
displaySource?: string;
|
|
129
|
+
codeView?: boolean;
|
|
130
|
+
projectSource?: (source: string) => string;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/** Width-safe rows sharing one frame across the call and its appended result. */
|
|
134
|
+
export function applyFrameRows(
|
|
135
|
+
source: string,
|
|
136
|
+
theme: Theme,
|
|
137
|
+
width: number,
|
|
138
|
+
part: "call" | "result",
|
|
139
|
+
finish: boolean,
|
|
140
|
+
language?: string,
|
|
141
|
+
failed = false,
|
|
142
|
+
): string[] {
|
|
143
|
+
const size = Math.max(1, width);
|
|
144
|
+
if (size < 5) return source.split("\n").flatMap((line) => wrapTextWithAnsi(line, size));
|
|
145
|
+
const inner = size - 4;
|
|
146
|
+
const border = (value: string) => theme.fg("borderMuted", value);
|
|
147
|
+
const heading = part === "call" ? "Apply · JavaScript" : "Result";
|
|
148
|
+
const title = truncateToWidth(` ${heading} `, size - 4, "");
|
|
149
|
+
const rows = [
|
|
150
|
+
border(`${part === "call" ? "╭" : "├"}─`) +
|
|
151
|
+
theme.fg(failed ? "error" : "accent", title) +
|
|
152
|
+
border(
|
|
153
|
+
`${"─".repeat(Math.max(0, size - visibleWidth(title) - 3))}${part === "call" ? "╮" : "┤"}`,
|
|
154
|
+
),
|
|
155
|
+
];
|
|
156
|
+
const blank = `${border("│")}${" ".repeat(size - 2)}${border("│")}`;
|
|
157
|
+
for (const line of source.split("\n")) {
|
|
158
|
+
const highlighted =
|
|
159
|
+
language === "diff"
|
|
160
|
+
? theme.fg(
|
|
161
|
+
line.startsWith("+")
|
|
162
|
+
? "toolDiffAdded"
|
|
163
|
+
: line.startsWith("-")
|
|
164
|
+
? "toolDiffRemoved"
|
|
165
|
+
: "toolDiffContext",
|
|
166
|
+
line,
|
|
167
|
+
)
|
|
168
|
+
: language
|
|
169
|
+
? highlightCode(line, language).join("\n")
|
|
170
|
+
: theme.fg("toolOutput", line);
|
|
171
|
+
for (const wrapped of wrapTextWithAnsi(highlighted, inner))
|
|
172
|
+
rows.push(
|
|
173
|
+
`${border("│")} ${wrapped}${" ".repeat(Math.max(0, inner - visibleWidth(wrapped)))} ${border("│")}`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (part === "call") rows.push(blank);
|
|
177
|
+
if (finish) rows.push(border(`╰${"─".repeat(size - 2)}╯`));
|
|
178
|
+
const background = theme.getBgAnsi("toolPendingBg");
|
|
179
|
+
return rows.map((row) => background + preserveEnclosingBackground(row, background) + "\u001b[0m");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Compose compact written calls with a pure configured tool header renderer. */
|
|
183
|
+
export function createApplyCallRenderer(
|
|
184
|
+
renderWritten?: (call: ApplyCallPreview, theme: Theme) => string,
|
|
185
|
+
): NonNullable<ToolDefinition["renderCall"]> {
|
|
186
|
+
return (args, theme, context) => {
|
|
187
|
+
const state = context.state as RenderState;
|
|
188
|
+
const projectSource = (state.projectSource ??= createApplySourceProjection(
|
|
189
|
+
renderWritten ? (call) => renderWritten(call, theme) : undefined,
|
|
190
|
+
renderWritten ? (code) => highlightCode(code, "javascript").join("\n") : undefined,
|
|
191
|
+
));
|
|
192
|
+
const source =
|
|
193
|
+
args !== null &&
|
|
194
|
+
typeof args === "object" &&
|
|
195
|
+
"source" in args &&
|
|
196
|
+
typeof args.source === "string"
|
|
197
|
+
? args.source
|
|
198
|
+
: "";
|
|
199
|
+
return {
|
|
200
|
+
invalidate() {},
|
|
201
|
+
render(width) {
|
|
202
|
+
return applyFrameRows(
|
|
203
|
+
state.codeView || context.expanded
|
|
204
|
+
? (state.displaySource ?? source)
|
|
205
|
+
: projectSource(state.displaySource ?? source),
|
|
206
|
+
theme,
|
|
207
|
+
width,
|
|
208
|
+
"call",
|
|
209
|
+
!state.applyResultReady,
|
|
210
|
+
state.codeView || context.expanded || !renderWritten ? "javascript" : undefined,
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const renderApplyCall = createApplyCallRenderer();
|
|
218
|
+
|
|
219
|
+
/** Configured editor presentation for final mutations inside the Apply card. */
|
|
220
|
+
export type ApplyMutationPanel = (
|
|
221
|
+
details: FileMutationBatchResult,
|
|
222
|
+
theme: Theme,
|
|
223
|
+
expanded: boolean,
|
|
224
|
+
cwd: string,
|
|
225
|
+
) => Component;
|
|
226
|
+
|
|
227
|
+
/** Reuse the owning editor renderer without introducing a core-to-plugin dependency. */
|
|
228
|
+
export function createApplyResultRenderer(
|
|
229
|
+
panel?: ApplyMutationPanel,
|
|
230
|
+
): NonNullable<ToolDefinition["renderResult"]> {
|
|
231
|
+
return (result, options, theme, context) => {
|
|
232
|
+
(context.state as RenderState).applyResultReady = true;
|
|
233
|
+
const details = result.details as
|
|
234
|
+
| { display?: ApplyDisplay; displaySource?: string }
|
|
235
|
+
| undefined;
|
|
236
|
+
(context.state as RenderState).displaySource = details?.displaySource;
|
|
237
|
+
const display = details?.display;
|
|
238
|
+
const blocks: ApplyDisplay["blocks"] = display?.blocks ?? [
|
|
239
|
+
{ text: context.isError ? "Apply failed" : "Apply finished" },
|
|
240
|
+
];
|
|
241
|
+
const renderRead = createReadResultRenderer({ kind: "source" });
|
|
242
|
+
const readPanels = blocks.map((block) =>
|
|
243
|
+
renderRead(
|
|
244
|
+
block.read ?? {
|
|
245
|
+
content: [{ type: "text", text: block.text }],
|
|
246
|
+
details: jsonDetails(block.text),
|
|
247
|
+
},
|
|
248
|
+
options,
|
|
249
|
+
theme,
|
|
250
|
+
{ ...context, isError: false, lastComponent: undefined },
|
|
251
|
+
),
|
|
252
|
+
);
|
|
253
|
+
const mutations = display?.mutations;
|
|
254
|
+
const comparisonPanels = (display?.comparisons ?? []).flatMap((details) => {
|
|
255
|
+
const rendered = panel?.(details, theme, options.expanded, display?.cwd ?? process.cwd());
|
|
256
|
+
return [
|
|
257
|
+
rendered ??
|
|
258
|
+
new Text(
|
|
259
|
+
(details.results ?? []).flatMap((result) => result.data.diffs ?? []).join("\n"),
|
|
260
|
+
0,
|
|
261
|
+
0,
|
|
262
|
+
),
|
|
263
|
+
];
|
|
264
|
+
});
|
|
265
|
+
const mutationPanel =
|
|
266
|
+
mutations === undefined
|
|
267
|
+
? undefined
|
|
268
|
+
: panel?.(mutations, theme, options.expanded, display?.cwd ?? process.cwd());
|
|
269
|
+
return {
|
|
270
|
+
invalidate() {
|
|
271
|
+
mutationPanel?.invalidate();
|
|
272
|
+
for (const comparison of comparisonPanels) comparison.invalidate();
|
|
273
|
+
},
|
|
274
|
+
render(width) {
|
|
275
|
+
const body: string[] = [];
|
|
276
|
+
for (const panel of readPanels) {
|
|
277
|
+
const rows = panel.render(Math.max(1, width - 4));
|
|
278
|
+
if (rows.length === 0) continue;
|
|
279
|
+
if (body.length > 0) body.push("");
|
|
280
|
+
body.push(...rows);
|
|
281
|
+
}
|
|
282
|
+
for (const comparison of comparisonPanels) {
|
|
283
|
+
if (body.length > 0) body.push("");
|
|
284
|
+
body.push(...comparison.render(Math.max(1, width - 4)));
|
|
285
|
+
}
|
|
286
|
+
if (mutationPanel !== undefined) {
|
|
287
|
+
const rows = mutationPanel.render(Math.max(1, width - 4));
|
|
288
|
+
if (body.length > 0 && rows.length > 0) body.push("");
|
|
289
|
+
body.push(...rows);
|
|
290
|
+
} else if (mutations !== undefined)
|
|
291
|
+
body.push(...(mutations.results ?? []).map((file) => file.path ?? "Changed file"));
|
|
292
|
+
if (
|
|
293
|
+
body.length === 0 &&
|
|
294
|
+
blocks.length > 0 &&
|
|
295
|
+
blocks.every(
|
|
296
|
+
(block) =>
|
|
297
|
+
block.read?.details.diagnosticCheck?.complete &&
|
|
298
|
+
block.read.details.diagnosticCheck.count === 0,
|
|
299
|
+
)
|
|
300
|
+
)
|
|
301
|
+
return applyFrameRows("", theme, width, "result", true).slice(-1);
|
|
302
|
+
return applyFrameRows(
|
|
303
|
+
body.length === 0 ? "No output" : body.join("\n"),
|
|
304
|
+
theme,
|
|
305
|
+
width,
|
|
306
|
+
"result",
|
|
307
|
+
true,
|
|
308
|
+
undefined,
|
|
309
|
+
context.isError,
|
|
310
|
+
);
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function jsonDetails(text: string): { source?: string } {
|
|
317
|
+
try {
|
|
318
|
+
const value: unknown = JSON.parse(text);
|
|
319
|
+
return value !== null && typeof value === "object" ? { source: "result.json" } : {};
|
|
320
|
+
} catch {
|
|
321
|
+
return {};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export const renderApplyResult = createApplyResultRenderer();
|