pi-agent-ide 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +12 -8
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/{chunk-MTTKFJV6.js → chunk-GUTQ3PWL.js} +1 -1
- package/dist/chunk-HGPUI7F3.js +1 -0
- package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
- package/dist/chunk-ITSNK5YG.js +7 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/chunk-M5L42DWE.js +7 -0
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/chunk-TPIHQYK2.js +14 -0
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZM4L5AGN.js} +1 -1
- package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +12 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +9 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +18 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +123 -1
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +3 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -13
- package/docs/configuration.md +57 -11
- package/docs/extensions.md +4 -2
- package/docs/tools.md +7 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +11 -15
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +22 -10
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +49 -17
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +127 -20
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +32 -28
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/node_modules/pi-agent-search/src/api/search.ts +55 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +8 -27
- package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
- package/node_modules/pi-agent-search-text/index.ts +82 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +112 -24
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text/src/text-document.ts +5 -0
- package/node_modules/pi-agent-text/src/text-target.ts +4 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/node_modules/pi-agent-text-editor/index.ts +1 -3
- package/node_modules/pi-agent-text-editor/package.json +34 -24
- package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +93 -2
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +38 -38
- package/src/api/plugin-protocol.ts +12 -2
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +77 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +138 -67
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +142 -0
- package/src/core/diagnostic-store.ts +96 -23
- package/src/core/extension.ts +45 -22
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +32 -28
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -33
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +112 -24
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
- package/src/extensions/pi-agent-search/src/core/extension.ts +8 -27
- package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -3
- package/src/extensions/pi-agent-text-editor/index.ts +1 -3
- package/src/extensions/pi-agent-text-editor/package.json +34 -24
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +93 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +11 -15
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +49 -17
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +127 -20
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/src/post-edit/gate.ts +57 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2SKAED2I.js +0 -2
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-2ZMYT6ZC.js +0 -1
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KNMWCDDK.js +0 -7
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/chunk-ZIHEF6K3.js +0 -3
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { FileMutationResult } from "#src/api/mutation-result.js";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { requiredValue } from "pi-agent-invariant";
|
|
4
|
+
import type { ReadToolResult } from "pi-agent-read/api/tools/read";
|
|
5
|
+
|
|
6
|
+
/** Host-owned outcome; identity refers to one call, not equal result contents. */
|
|
7
|
+
interface OperationResult {
|
|
8
|
+
readonly presentation?: ReadToolResult;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly kind: "read" | "mutation";
|
|
11
|
+
readonly value: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type ExplicitResult =
|
|
15
|
+
| {
|
|
16
|
+
readonly kind: "operation";
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly value: unknown;
|
|
19
|
+
readonly presentation?: ReadToolResult;
|
|
20
|
+
}
|
|
21
|
+
| { readonly kind: "value"; readonly value: unknown };
|
|
22
|
+
|
|
23
|
+
/** Final observed contents for one canonical resource; null means absent. */
|
|
24
|
+
interface FileState {
|
|
25
|
+
readonly source: string;
|
|
26
|
+
readonly before: string | null;
|
|
27
|
+
readonly after: string | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Collected data for the formatter; operation receipts are not intermediate file views. */
|
|
31
|
+
interface SelectedResults {
|
|
32
|
+
readonly explicit: readonly ExplicitResult[];
|
|
33
|
+
readonly automatic: readonly OperationResult[];
|
|
34
|
+
readonly files: readonly FileState[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Per-invocation output selection and file-state consolidation, independent of guest return. */
|
|
38
|
+
export class ApplyResults {
|
|
39
|
+
readonly #operations = new Map<string, OperationResult>();
|
|
40
|
+
readonly #explicit: ExplicitResult[] = [];
|
|
41
|
+
readonly #explicitOperations = new Set<string>();
|
|
42
|
+
readonly #files = new Map<string, FileState>();
|
|
43
|
+
#hasMutation = false;
|
|
44
|
+
readonly #mutationPresentations = new Map<string, FileMutationResult>();
|
|
45
|
+
|
|
46
|
+
/** Retain configured post-edit annotations on the host, outside guest serialization. */
|
|
47
|
+
rememberMutation(source: string, presentation: FileMutationResult): void {
|
|
48
|
+
this.#mutationPresentations.set(source, presentation);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Latest observed presentation for a canonical file. */
|
|
52
|
+
mutationPresentation(source: string): FileMutationResult | undefined {
|
|
53
|
+
return this.#mutationPresentations.get(source);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Mutation receipts in execution order, including explicitly selected operations. */
|
|
57
|
+
mutationValues(): readonly unknown[] {
|
|
58
|
+
return [...this.#operations.values()]
|
|
59
|
+
.filter(({ kind }) => kind === "mutation")
|
|
60
|
+
.map(({ value }) => value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Records even refused mutations so they take precedence over automatic reads. */
|
|
64
|
+
record(
|
|
65
|
+
id: string,
|
|
66
|
+
kind: OperationResult["kind"],
|
|
67
|
+
value: unknown,
|
|
68
|
+
presentation?: ReadToolResult,
|
|
69
|
+
): void {
|
|
70
|
+
if (this.#operations.has(id)) throw new Error(`Duplicate operation identity: ${id}`);
|
|
71
|
+
this.#operations.set(id, {
|
|
72
|
+
id,
|
|
73
|
+
kind,
|
|
74
|
+
value,
|
|
75
|
+
...(presentation === undefined ? {} : { presentation }),
|
|
76
|
+
});
|
|
77
|
+
this.#hasMutation ||= kind === "mutation";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Adds a known operation once, preserving explicit selection order. */
|
|
81
|
+
addOperation(id: string): void {
|
|
82
|
+
const operation = requiredValue(this.#operations.get(id));
|
|
83
|
+
if (this.#explicitOperations.has(id)) return;
|
|
84
|
+
this.#explicitOperations.add(id);
|
|
85
|
+
this.#explicit.push({
|
|
86
|
+
kind: "operation",
|
|
87
|
+
id,
|
|
88
|
+
value: operation.value,
|
|
89
|
+
...(operation.presentation === undefined ? {} : { presentation: operation.presentation }),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Checks guest provenance against host data; edited values remain explicit additions. */
|
|
94
|
+
add(value: unknown, operationId?: string): void {
|
|
95
|
+
const operation = operationId === undefined ? undefined : this.#operations.get(operationId);
|
|
96
|
+
if (operation !== undefined && isDeepStrictEqual(operation.value, value)) {
|
|
97
|
+
this.addOperation(operation.id);
|
|
98
|
+
} else {
|
|
99
|
+
this.addValue(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Adds arbitrary script output; equal values are not assumed to be duplicate calls. */
|
|
103
|
+
addValue(value: unknown): void {
|
|
104
|
+
this.#explicit.push({ kind: "value", value });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Records final observed text after an operation, retaining the first pre-edit state. */
|
|
108
|
+
updateFile(source: string, before: string | null, after: string | null): void {
|
|
109
|
+
const previous = this.#files.get(source);
|
|
110
|
+
this.#files.set(source, {
|
|
111
|
+
source,
|
|
112
|
+
before: previous === undefined ? before : previous.before,
|
|
113
|
+
after,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A whole-file operation supersedes any previously recorded text snapshot. */
|
|
118
|
+
forgetFile(source: string): void {
|
|
119
|
+
this.#files.delete(source);
|
|
120
|
+
this.#mutationPresentations.delete(source);
|
|
121
|
+
}
|
|
122
|
+
/** Selects output without deleting the underlying operation receipts. */
|
|
123
|
+
select(): SelectedResults {
|
|
124
|
+
return {
|
|
125
|
+
explicit: [...this.#explicit],
|
|
126
|
+
automatic: [...this.#operations.values()].filter(
|
|
127
|
+
({ id, kind }) =>
|
|
128
|
+
!this.#explicitOperations.has(id) && (!this.#hasMutation || kind === "mutation"),
|
|
129
|
+
),
|
|
130
|
+
files: [...this.#files.values()],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { RunLimits } from "run";
|
|
2
|
+
import { fileOperations } from "#src/core/file-operations.js";
|
|
3
|
+
import { ApplyQueue } from "#src/core/apply/queue.js";
|
|
4
|
+
|
|
5
|
+
/** Only IDE operations approved for the guest; remove maps to the standalone delete tool. */
|
|
6
|
+
export const applyOperations = [
|
|
7
|
+
"read",
|
|
8
|
+
"search",
|
|
9
|
+
"diff",
|
|
10
|
+
"write",
|
|
11
|
+
"replace",
|
|
12
|
+
"insert",
|
|
13
|
+
"remove",
|
|
14
|
+
"copy",
|
|
15
|
+
"move",
|
|
16
|
+
"undo",
|
|
17
|
+
"stage",
|
|
18
|
+
"unstage",
|
|
19
|
+
...fileOperations,
|
|
20
|
+
] as const;
|
|
21
|
+
export type ApplyOperation = (typeof applyOperations)[number];
|
|
22
|
+
|
|
23
|
+
/** The host records outcomes before returning them across the guest bridge. */
|
|
24
|
+
export interface ApplyRuntimeHost {
|
|
25
|
+
execute(
|
|
26
|
+
operation: ApplyOperation,
|
|
27
|
+
arguments_: unknown,
|
|
28
|
+
signal: AbortSignal,
|
|
29
|
+
id: string,
|
|
30
|
+
): Promise<unknown>;
|
|
31
|
+
result(value: unknown, operationId?: string): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Runs a fresh composition and drains host work on success, failure, or cancellation. */
|
|
35
|
+
export async function executeApplySource(
|
|
36
|
+
source: string,
|
|
37
|
+
host: ApplyRuntimeHost,
|
|
38
|
+
signal?: AbortSignal,
|
|
39
|
+
limits?: RunLimits,
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
const { createRunner, getHostFunctionContext } = await import("run");
|
|
42
|
+
const queue = new ApplyQueue();
|
|
43
|
+
const operations = Object.fromEntries(
|
|
44
|
+
applyOperations.map((operation) => [
|
|
45
|
+
operation,
|
|
46
|
+
(arguments_: unknown) => {
|
|
47
|
+
const context = getHostFunctionContext();
|
|
48
|
+
return queue.submit(async () => {
|
|
49
|
+
context.abortSignal.throwIfAborted();
|
|
50
|
+
try {
|
|
51
|
+
return {
|
|
52
|
+
ok: true,
|
|
53
|
+
value: await host.execute(
|
|
54
|
+
operation,
|
|
55
|
+
arguments_,
|
|
56
|
+
context.abortSignal,
|
|
57
|
+
context.requestId,
|
|
58
|
+
),
|
|
59
|
+
id: context.requestId,
|
|
60
|
+
};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return { ok: false, error: serializeApplyError(error) };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
]),
|
|
67
|
+
);
|
|
68
|
+
try {
|
|
69
|
+
const runner = createRunner({
|
|
70
|
+
syncHostFunctions: {
|
|
71
|
+
__apply: {
|
|
72
|
+
...operations,
|
|
73
|
+
result: (value: unknown, operationId?: string) =>
|
|
74
|
+
queue.submit(() => host.result(value, operationId)),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
await runner.run({ source: `${guestBindings()}\n${source}`, abortSignal: signal, limits });
|
|
79
|
+
} finally {
|
|
80
|
+
await queue.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Preserves operation error fields without sending host Error instances across the bridge. */
|
|
85
|
+
export function serializeApplyError(error: unknown): {
|
|
86
|
+
code: string;
|
|
87
|
+
message: string;
|
|
88
|
+
details?: unknown;
|
|
89
|
+
} {
|
|
90
|
+
if (!(error instanceof Error)) return { code: "OPERATION_FAILED", message: String(error) };
|
|
91
|
+
return {
|
|
92
|
+
code: "code" in error && typeof error.code === "string" ? error.code : "OPERATION_FAILED",
|
|
93
|
+
message: error.message,
|
|
94
|
+
...("details" in error ? { details: error.details } : {}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function guestBindings(): string {
|
|
99
|
+
return `const { ${applyOperations.join(", ")}, result } = (() => {
|
|
100
|
+
const origins = new WeakMap();
|
|
101
|
+
const invoke = (name, args) => {
|
|
102
|
+
const response = __apply[name](args);
|
|
103
|
+
if (!response.ok) throw Object.assign(new Error(response.error.message), response.error);
|
|
104
|
+
if (response.value !== null && typeof response.value === "object") origins.set(response.value, response.id);
|
|
105
|
+
return response.value;
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
${applyOperations.map((name) => `${name}: (args) => invoke(${JSON.stringify(name)}, args)`).join(",\n")},
|
|
109
|
+
result: (value) => __apply.result(value, value !== null && typeof value === "object" ? origins.get(value) : undefined),
|
|
110
|
+
};
|
|
111
|
+
})();`;
|
|
112
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { formatApplySource } from "./format-source.js";
|
|
2
|
+
import { applyHelperGuide } from "#src/core/apply/prompt.js";
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
5
|
+
import {
|
|
6
|
+
READ_API_VERSION,
|
|
7
|
+
READ_PROTOCOL,
|
|
8
|
+
type ReadPluginApi,
|
|
9
|
+
} from "pi-agent-read/api/plugin-protocol";
|
|
10
|
+
import { connectSearchPlugin } from "pi-agent-search/api/connect-plugin";
|
|
11
|
+
import { SEARCH_API_VERSION, SEARCH_PROTOCOL } from "pi-agent-search/api/plugin-protocol";
|
|
12
|
+
import type { SearchPluginApi } from "pi-agent-search/api/search";
|
|
13
|
+
import { Type } from "typebox";
|
|
14
|
+
import {
|
|
15
|
+
getLastResolvedResource,
|
|
16
|
+
rememberLastResolvedResource,
|
|
17
|
+
} from "#src/api/last-resolved-resource.js";
|
|
18
|
+
import type { TextEditorCore } from "#src/core/text-editor-core.js";
|
|
19
|
+
import { createApplyExecution } from "#src/core/apply/execution.js";
|
|
20
|
+
import { executeApplySource } from "#src/core/apply/runtime.js";
|
|
21
|
+
import { renderApplyOutput } from "#src/core/apply/output.js";
|
|
22
|
+
import {
|
|
23
|
+
createApplyDisplay,
|
|
24
|
+
renderApplyCall,
|
|
25
|
+
renderApplyResult,
|
|
26
|
+
} from "#src/core/apply/renderer.js";
|
|
27
|
+
|
|
28
|
+
/** Registers composed IDE operations using the owning extensions' configured services. */
|
|
29
|
+
export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): Promise<void> {
|
|
30
|
+
let read: ReadPluginApi | undefined;
|
|
31
|
+
let search: SearchPluginApi | undefined;
|
|
32
|
+
await connectReadPlugin(pi, {
|
|
33
|
+
id: "apply",
|
|
34
|
+
protocol: READ_PROTOCOL,
|
|
35
|
+
apiVersion: READ_API_VERSION,
|
|
36
|
+
setup(api) {
|
|
37
|
+
read = api;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
await connectSearchPlugin(pi, {
|
|
41
|
+
id: "apply",
|
|
42
|
+
protocol: SEARCH_PROTOCOL,
|
|
43
|
+
apiVersion: SEARCH_API_VERSION,
|
|
44
|
+
setup(api) {
|
|
45
|
+
search = api;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
pi.registerTool({
|
|
49
|
+
name: "apply",
|
|
50
|
+
label: "Apply",
|
|
51
|
+
renderShell: "self",
|
|
52
|
+
renderCall: (args, theme, context) => {
|
|
53
|
+
(context.state as { codeView?: boolean }).codeView =
|
|
54
|
+
pi.getFlag("pi-agent-ide-apply-code") === true;
|
|
55
|
+
const render = editor.getToolRenderer("apply")?.renderCall ?? renderApplyCall;
|
|
56
|
+
return render(args, theme, context);
|
|
57
|
+
},
|
|
58
|
+
renderResult: (...args) => {
|
|
59
|
+
const render = (editor.getToolRenderer("apply")?.renderResult ??
|
|
60
|
+
renderApplyResult) as typeof renderApplyResult;
|
|
61
|
+
return render(...args);
|
|
62
|
+
},
|
|
63
|
+
promptSnippet: "Compose dependent IDE reads and edits in one JavaScript call",
|
|
64
|
+
description:
|
|
65
|
+
"Use apply to combine IDE operations with JavaScript loops and conditions. Direct synchronous functions (no await): read, search, diff, write, replace, insert, remove (delete), copy, move, delete_file, copy_file, move_file, undo, stage, unstage. Pass the same argument objects as standalone tools. Calls execute sequentially, including Promise.all. Text reads return source, raw content and lines with anchors and view metadata. Multi-resource reads return resources; native reads return blocks. Search returns resolverId, raw data and registered selection details. Ordinary reads do not wait for diagnostics; explicit diagnostics requests wait for completed checks and throw if unavailable or timed out. Mutations return final file data. Use result(value) to select extra output; return is not required. Mutations suppress automatic read output. Final per-file changes use the same result format as standalone edits. Applied changes survive errors; catch operation errors by code/details. Output has one 2000-line/50KB budget. Overflow uses compact source views or a summary with a full temp reference. No shell, imports or resume. Undo restores one selected file transaction or Git change, never the whole Apply call." +
|
|
66
|
+
applyHelperGuide,
|
|
67
|
+
promptGuidelines: [
|
|
68
|
+
"Use apply for dependent combinations of IDE operations. Use standalone tools for a single operation. Check reported effects before retrying a failed apply; earlier edits are not rolled back.",
|
|
69
|
+
],
|
|
70
|
+
parameters: Type.Object({
|
|
71
|
+
source: Type.String({
|
|
72
|
+
description:
|
|
73
|
+
"JavaScript function body. Call IDE functions directly without await; each call finishes before the next statement. Use result(value) for explicit output. The UI may compact written tool calls or format a display copy; execution uses this source unchanged.",
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
async execute(_id, { source }, signal, _onUpdate, context) {
|
|
77
|
+
if (read === undefined || search === undefined)
|
|
78
|
+
throw new Error("Apply requires the read and search extensions");
|
|
79
|
+
const execution = createApplyExecution(
|
|
80
|
+
{
|
|
81
|
+
editor,
|
|
82
|
+
read,
|
|
83
|
+
search,
|
|
84
|
+
lastResolvedSource: getLastResolvedResource(pi)?.source,
|
|
85
|
+
rememberRead: (outcome) => rememberLastResolvedResource(pi, outcome.details),
|
|
86
|
+
},
|
|
87
|
+
context,
|
|
88
|
+
);
|
|
89
|
+
const displaySource = formatApplySource(source);
|
|
90
|
+
let failed = false;
|
|
91
|
+
let error: unknown;
|
|
92
|
+
try {
|
|
93
|
+
await executeApplySource(source, execution.host, signal);
|
|
94
|
+
} catch (cause) {
|
|
95
|
+
failed = true;
|
|
96
|
+
error = cause;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await execution.finish();
|
|
100
|
+
} catch (cause) {
|
|
101
|
+
failed = true;
|
|
102
|
+
error ??= cause;
|
|
103
|
+
}
|
|
104
|
+
const output = await renderApplyOutput(execution.results, read, error, {
|
|
105
|
+
cwd: context.cwd,
|
|
106
|
+
signal,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
content: output.content,
|
|
110
|
+
details: {
|
|
111
|
+
failed,
|
|
112
|
+
displaySource: await displaySource,
|
|
113
|
+
outputLevel: output.level,
|
|
114
|
+
display: createApplyDisplay(execution.results, output, error, context.cwd),
|
|
115
|
+
temporarySource: output.temporarySource,
|
|
116
|
+
files: execution.results.select().files.map(({ source: file }) => file),
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
pi.on("tool_result", (event) => {
|
|
122
|
+
if (
|
|
123
|
+
event.toolName === "apply" &&
|
|
124
|
+
event.details &&
|
|
125
|
+
typeof event.details === "object" &&
|
|
126
|
+
"failed" in event.details &&
|
|
127
|
+
event.details.failed
|
|
128
|
+
)
|
|
129
|
+
return { isError: true };
|
|
130
|
+
return;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
@@ -29,18 +29,10 @@ export function registerBuiltinEditFilter(pi: ExtensionAPI): void {
|
|
|
29
29
|
label: "edit",
|
|
30
30
|
description: "",
|
|
31
31
|
promptGuidelines: [
|
|
32
|
-
"Use
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
" - Use text that matches the file exactly and occurs only once.",
|
|
37
|
-
" - Keep it as small as possible while still unique. Do not pad it with large unchanged regions.",
|
|
38
|
-
" - Plain text is matched against the original file contents, not after earlier mutations are applied.",
|
|
39
|
-
].join("\n"),
|
|
40
|
-
"Do not emit overlapping or nested mutations in one tool-call block. Merge nearby changes into one mutation.",
|
|
41
|
-
|
|
42
|
-
"A mutation that overlaps an earlier accepted mutation is rejected. Check each call's result before retrying; do not repeat edits that already applied.",
|
|
43
|
-
"You can omit a mutation source to reuse the last resolved resource or the previous source in the same tool-call block. Write requires a path; copy and move default their target to the source.",
|
|
32
|
+
"Use the smallest useful source view: reuse sufficient content and anchors, search for known text, or inspect structure when locating a declaration. Read nearby context when boundaries are unclear; resolve ambiguity rather than guessing.",
|
|
33
|
+
"Use an available anchor when it selects exactly the intended text; otherwise use minimal unique exact text. Keep the edit limited to the intended content.",
|
|
34
|
+
"When search broadens to separate words, treat its results as location hints. Refine the query before using those matches for replacement.",
|
|
35
|
+
"Submit independent mutations together in one tool-call block. They are evaluated against the original file contents. Combine overlapping changes into one mutation. A rejected mutation does not cancel other valid mutations; check each result and retry only changes that were not applied.",
|
|
44
36
|
],
|
|
45
37
|
parameters: Type.Object({}, { additionalProperties: false }),
|
|
46
38
|
execute() {
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import type { ExtensionAPI, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import {
|
|
4
|
+
truncateHead,
|
|
5
|
+
DEFAULT_MAX_BYTES,
|
|
6
|
+
DEFAULT_MAX_LINES,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
9
|
+
import { Type, type Static } from "typebox";
|
|
10
|
+
import { Value } from "typebox/value";
|
|
11
|
+
import {
|
|
12
|
+
readParameters,
|
|
13
|
+
type ReadScriptData,
|
|
14
|
+
type ReadToolResult,
|
|
15
|
+
} from "pi-agent-read/api/tools/read";
|
|
16
|
+
import type { ReadPluginApi } from "pi-agent-read/api/plugin-protocol";
|
|
17
|
+
import type { TextEditorCore } from "#src/core/text-editor-core.js";
|
|
18
|
+
import { createUnifiedDiff, type DiffStats } from "#src/core/mutation-result/diff.js";
|
|
19
|
+
import { FileMutationResult } from "#src/core/mutation-result/file-mutation-result.js";
|
|
20
|
+
|
|
21
|
+
const source = Type.Union([Type.String({ minLength: 1 }), readParameters]);
|
|
22
|
+
/** Each side accepts a source string or the same request object as read. */
|
|
23
|
+
export const diffParameters = Type.Object(
|
|
24
|
+
{ before: source, after: source },
|
|
25
|
+
{ additionalProperties: false },
|
|
26
|
+
);
|
|
27
|
+
export type DiffRequest = Static<typeof diffParameters>;
|
|
28
|
+
interface ComparisonText {
|
|
29
|
+
readonly source: string;
|
|
30
|
+
readonly sources: readonly string[];
|
|
31
|
+
readonly content: string;
|
|
32
|
+
}
|
|
33
|
+
/** Full comparison data for Apply; this is not an edit receipt. */
|
|
34
|
+
export interface DiffOutcome {
|
|
35
|
+
readonly kind: "diff";
|
|
36
|
+
readonly ok: true;
|
|
37
|
+
readonly equal: boolean;
|
|
38
|
+
readonly before: ComparisonText;
|
|
39
|
+
readonly after: ComparisonText;
|
|
40
|
+
readonly diff: string;
|
|
41
|
+
readonly stats: DiffStats;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Read both sides through the configured read pipeline without presentation clipping. */
|
|
45
|
+
export async function executeDiff(
|
|
46
|
+
read: ReadPluginApi,
|
|
47
|
+
input: unknown,
|
|
48
|
+
context: { cwd: string; signal?: AbortSignal },
|
|
49
|
+
): Promise<DiffOutcome> {
|
|
50
|
+
if (!Value.Check(diffParameters, input))
|
|
51
|
+
throw Object.assign(new Error("Use before and after source strings or read request objects"), {
|
|
52
|
+
code: "INVALID_ARGUMENTS",
|
|
53
|
+
});
|
|
54
|
+
const request = input;
|
|
55
|
+
const resolve = async (side: DiffRequest["before"]) => {
|
|
56
|
+
const request = typeof side === "string" ? { path: side } : side;
|
|
57
|
+
const outcome = await read.read(request, context, "script");
|
|
58
|
+
if (outcome.isError || outcome.details.failure)
|
|
59
|
+
throw Object.assign(new Error(outcome.details.failure?.message ?? "Comparison read failed"), {
|
|
60
|
+
code: outcome.details.failure?.code ?? "READ_FAILED",
|
|
61
|
+
details: outcome.details.failure,
|
|
62
|
+
});
|
|
63
|
+
if (outcome.script === undefined)
|
|
64
|
+
throw Object.assign(new Error("Source has no comparable text data"), {
|
|
65
|
+
code: "UNSUPPORTED_CONTENT",
|
|
66
|
+
});
|
|
67
|
+
return comparisonText(outcome.script, request.path ?? "source");
|
|
68
|
+
};
|
|
69
|
+
const before = await resolve(request.before);
|
|
70
|
+
const after = await resolve(request.after);
|
|
71
|
+
const result = createUnifiedDiff(before.source, before.content, after.content, after.source);
|
|
72
|
+
return {
|
|
73
|
+
kind: "diff",
|
|
74
|
+
ok: true,
|
|
75
|
+
equal: before.content === after.content,
|
|
76
|
+
before,
|
|
77
|
+
after,
|
|
78
|
+
...result,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Preserve canonical text, joining multiple resolved resources with one newline separator. */
|
|
83
|
+
export function comparisonText(data: ReadScriptData, requested: string): ComparisonText {
|
|
84
|
+
if (data.kind === "text")
|
|
85
|
+
return { source: data.source, sources: [data.source], content: data.content };
|
|
86
|
+
if (data.kind === "resources") {
|
|
87
|
+
const texts = data.resources.map((resource) => comparisonText(resource, requested));
|
|
88
|
+
return {
|
|
89
|
+
source: data.source ?? requested,
|
|
90
|
+
sources: texts.flatMap((text) => text.sources),
|
|
91
|
+
content: texts.map((text) => text.content).join("\n"),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (data.kind === "bytes")
|
|
95
|
+
throw Object.assign(new Error(`Byte sources are not text: ${data.source}`), {
|
|
96
|
+
code: "UNSUPPORTED_CONTENT",
|
|
97
|
+
});
|
|
98
|
+
if (data.blocks.length === 0 || data.blocks.some((block) => block.type !== "text"))
|
|
99
|
+
throw Object.assign(new Error(`Source is not text: ${data.source}`), {
|
|
100
|
+
code: "UNSUPPORTED_CONTENT",
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
source: data.source,
|
|
104
|
+
sources: [data.source],
|
|
105
|
+
content: data.blocks.flatMap((block) => (block.type === "text" ? [block.text] : [])).join("\n"),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Recognize comparison results without confusing them with mutations. */
|
|
110
|
+
export function isDiffOutcome(value: unknown): value is DiffOutcome {
|
|
111
|
+
return (
|
|
112
|
+
value !== null &&
|
|
113
|
+
typeof value === "object" &&
|
|
114
|
+
"kind" in value &&
|
|
115
|
+
value.kind === "diff" &&
|
|
116
|
+
"ok" in value &&
|
|
117
|
+
value.ok === true
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
/** Reuse the editor panel's existing before/after presentation contract, without executing edits. */
|
|
121
|
+
export function diffPresentation(value: DiffOutcome, cwd = process.cwd()) {
|
|
122
|
+
const displaySource = (source: string) =>
|
|
123
|
+
path.isAbsolute(source) ? path.relative(cwd, source) || "." : source;
|
|
124
|
+
const label = `Diff: ${displaySource(value.before.source)} → ${displaySource(value.after.source)}`;
|
|
125
|
+
return {
|
|
126
|
+
results: [
|
|
127
|
+
new FileMutationResult({
|
|
128
|
+
ok: true,
|
|
129
|
+
path: label,
|
|
130
|
+
beforeContentMap: { [label]: value.before.content },
|
|
131
|
+
afterContent: value.after.content,
|
|
132
|
+
diffs: [value.diff],
|
|
133
|
+
}),
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** The agent sees the existing unified text diff with both source names. */
|
|
138
|
+
export function diffText(value: DiffOutcome): string {
|
|
139
|
+
return value.equal
|
|
140
|
+
? `No differences: ${value.before.source} → ${value.after.source}`
|
|
141
|
+
: value.diff;
|
|
142
|
+
}
|
|
143
|
+
/** Presentation remains separate from complete comparison data. */
|
|
144
|
+
export function diffReadResult(value: DiffOutcome): ReadToolResult {
|
|
145
|
+
return { content: [{ type: "text", text: diffText(value) }], details: {} };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Standalone diff uses the same read service and configured editor renderer as Apply. */
|
|
149
|
+
export function registerDiff(
|
|
150
|
+
pi: ExtensionAPI,
|
|
151
|
+
editor: TextEditorCore,
|
|
152
|
+
getRead: () => ReadPluginApi | undefined,
|
|
153
|
+
): void {
|
|
154
|
+
pi.registerTool({
|
|
155
|
+
name: "diff",
|
|
156
|
+
label: "Diff",
|
|
157
|
+
parameters: diffParameters,
|
|
158
|
+
promptSnippet: "Compare two text-readable sources without changing them",
|
|
159
|
+
description:
|
|
160
|
+
"Use diff to compare two sources without modifying them. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference. The same diff function is available inside Apply.",
|
|
161
|
+
renderCall(_args, theme) {
|
|
162
|
+
return new Text(theme.fg("toolTitle", theme.bold("Diff")), 0, 0);
|
|
163
|
+
},
|
|
164
|
+
renderResult(result, options, theme, context) {
|
|
165
|
+
const details = result.details as { comparison?: DiffOutcome } | undefined;
|
|
166
|
+
if (details?.comparison?.equal) return new Text(diffText(details.comparison), 0, 0);
|
|
167
|
+
const renderer = editor.getToolRenderer("diff")
|
|
168
|
+
?.renderResult as ToolDefinition["renderResult"];
|
|
169
|
+
return renderer
|
|
170
|
+
? renderer(result, options, theme, context)
|
|
171
|
+
: new Text(
|
|
172
|
+
result.content
|
|
173
|
+
.filter((block) => block.type === "text")
|
|
174
|
+
.map((block) => block.text)
|
|
175
|
+
.join("\n"),
|
|
176
|
+
0,
|
|
177
|
+
0,
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
async execute(_id, args, signal, _update, context) {
|
|
181
|
+
const read = getRead();
|
|
182
|
+
if (read === undefined) throw new Error("Diff requires the read extension");
|
|
183
|
+
const comparison = await executeDiff(read, args, { cwd: context.cwd, signal });
|
|
184
|
+
const full = diffText(comparison);
|
|
185
|
+
const bounded = truncateHead(full);
|
|
186
|
+
const temporarySource = bounded.truncated ? await read.saveTemporary(full) : undefined;
|
|
187
|
+
const footer = temporarySource === undefined ? "" : `\nFull diff: ${temporarySource}`;
|
|
188
|
+
return {
|
|
189
|
+
content: [
|
|
190
|
+
{
|
|
191
|
+
type: "text" as const,
|
|
192
|
+
text:
|
|
193
|
+
temporarySource === undefined
|
|
194
|
+
? full
|
|
195
|
+
: truncateHead(full, {
|
|
196
|
+
maxLines: DEFAULT_MAX_LINES - 2,
|
|
197
|
+
maxBytes: DEFAULT_MAX_BYTES - Buffer.byteLength(footer),
|
|
198
|
+
}).content + footer,
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
details: { ...diffPresentation(comparison, context.cwd), comparison, temporarySource },
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
@@ -27,6 +27,9 @@ import { setTextEditBatchRenderArgumentSink } from "#src/core/text-edit-batch-re
|
|
|
27
27
|
import { createTextEditorCore } from "#src/core/text-editor-core.js";
|
|
28
28
|
import { createReadFragmentResolver } from "#src/core/read-fragment-resolver.js";
|
|
29
29
|
import { createTextTool } from "#src/core/text-mutation.js";
|
|
30
|
+
import { registerApply } from "#src/core/apply/tool.js";
|
|
31
|
+
import { registerDiff } from "#src/core/diff-tool.js";
|
|
32
|
+
import { registerFileOperationTools } from "#src/core/file-operation-tools.js";
|
|
30
33
|
import { ToolCallInterceptionRenderStore } from "#src/core/tool-call-interceptor/rendering.js";
|
|
31
34
|
import { registerToolCallAnnotationSink } from "pi-agent-text-editor/api/tool-call-interceptor";
|
|
32
35
|
|
|
@@ -55,7 +58,11 @@ export default async function registerTextEditorCore(
|
|
|
55
58
|
interceptionRendering,
|
|
56
59
|
() =>
|
|
57
60
|
[
|
|
58
|
-
|
|
61
|
+
(registration.anchors?.length ?? 0) > 0
|
|
62
|
+
? editor.renderGeneralPromptGuideline(
|
|
63
|
+
new Set(registration.anchors?.flatMap((anchor) => anchor.kinds)),
|
|
64
|
+
)
|
|
65
|
+
: undefined,
|
|
59
66
|
editor.renderToolPromptGuideline(registration.name),
|
|
60
67
|
]
|
|
61
68
|
.filter((guideline): guideline is string => guideline !== undefined)
|
|
@@ -84,14 +91,8 @@ export default async function registerTextEditorCore(
|
|
|
84
91
|
api.addTargetResolver({ resolver: core.textTargetResolver() });
|
|
85
92
|
api.addFragmentResolver(createReadFragmentResolver(core));
|
|
86
93
|
|
|
87
|
-
api.
|
|
88
|
-
"
|
|
89
|
-
);
|
|
90
|
-
api.addPromptGuideline(
|
|
91
|
-
"For an anchored read, omitted `offset`, `offset: 0`, and `offset: 1` all start at the anchor line; positive offsets greater than one count forward, while negative offsets count upward.",
|
|
92
|
-
);
|
|
93
|
-
api.addPromptGuideline(
|
|
94
|
-
"After search finds a relevant result, you can use read with the returned `SEARCH#...` source, `offset`, and `limit` to inspect only the surrounding context you need.",
|
|
94
|
+
api.describe(
|
|
95
|
+
"path#anchor — source around a returned line or scope anchor, e.g. notes.txt#12#A4F0. SEARCH# references go directly in path, without a file prefix. offset/limit select context relative to each location; output keeps original line numbers.",
|
|
95
96
|
);
|
|
96
97
|
},
|
|
97
98
|
});
|
|
@@ -126,6 +127,9 @@ export default async function registerTextEditorCore(
|
|
|
126
127
|
});
|
|
127
128
|
|
|
128
129
|
await core.waitForPendingPlugins();
|
|
130
|
+
if (pi.getFlag("pi-agent-ide-no-apply") !== true) await registerApply(pi, core);
|
|
131
|
+
registerFileOperationTools(pi, core);
|
|
132
|
+
registerDiff(pi, core, () => readApi);
|
|
129
133
|
return core;
|
|
130
134
|
}
|
|
131
135
|
|