pi-agent-ide 0.8.1 → 0.8.3
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 +50 -0
- package/README.md +5 -3
- package/dist/{chunk-TGC2ZACO.js → chunk-235QMMVA.js} +1 -1
- package/dist/{chunk-OI3HBIPK.js → chunk-4DIUPEDF.js} +1 -1
- package/dist/{chunk-2ITKAXHO.js → chunk-6FGLAVPJ.js} +1 -1
- package/dist/{chunk-7LOVUWNI.js → chunk-6H32W35W.js} +1 -1
- package/dist/{chunk-YHREORHH.js → chunk-6OJ565FL.js} +1 -1
- package/dist/{chunk-E2PHA4SQ.js → chunk-6R3Y4AD3.js} +1 -1
- package/dist/{chunk-VNTY7BKC.js → chunk-6T7PSDQW.js} +1 -1
- package/dist/{chunk-D4IA2MTA.js → chunk-6TJPMBUQ.js} +1 -1
- package/dist/{chunk-JKMXND6V.js → chunk-6XFUICD7.js} +1 -1
- package/dist/{chunk-A64JRDZK.js → chunk-AAC77UD4.js} +1 -1
- package/dist/{chunk-HFJGCYFO.js → chunk-ANM3Y5FO.js} +5 -5
- package/dist/{chunk-Q5X6OXNS.js → chunk-CPELC6JE.js} +1 -1
- package/dist/chunk-GBUJOR6V.js +28 -0
- package/dist/{chunk-3WO2NOEQ.js → chunk-GSOYVIQS.js} +1 -1
- package/dist/{chunk-AIT3YWR5.js → chunk-HSRH76JN.js} +1 -1
- package/dist/{chunk-ID4RJIVZ.js → chunk-HSZ4AQ6L.js} +1 -1
- package/dist/chunk-I6NPILT5.js +1 -0
- package/dist/chunk-K7SRNBIV.js +1 -0
- package/dist/{chunk-DXONCYWF.js → chunk-LCWBVOII.js} +3 -3
- package/dist/{chunk-EMRJP6EM.js → chunk-LEJKDYCK.js} +1 -1
- package/dist/{chunk-HCK7OIQ3.js → chunk-NJ7C4KMA.js} +1 -1
- package/dist/{chunk-BQAKA3FU.js → chunk-NUM3YQGK.js} +1 -1
- package/dist/chunk-OJEIX7OZ.js +1 -0
- package/dist/chunk-PBQDHYNX.js +1 -0
- package/dist/{chunk-4HWKBCBH.js → chunk-PJL3UVMJ.js} +1 -1
- package/dist/chunk-PT35ZFLH.js +33 -0
- package/dist/{chunk-AKNHSDGV.js → chunk-QT3EAHOG.js} +1 -1
- package/dist/{chunk-LLRUJD62.js → chunk-RIJMXO43.js} +1 -1
- package/dist/chunk-RMI3NMQY.js +23 -0
- package/dist/chunk-RQ7JJ7GV.js +4 -0
- package/dist/{chunk-AUL5FGGK.js → chunk-RVU73VKN.js} +1 -1
- package/dist/{chunk-WPBQ45ZL.js → chunk-RW2GTYQI.js} +1 -1
- package/dist/{chunk-BR7GRH4A.js → chunk-SDAH3ECM.js} +1 -1
- package/dist/chunk-SGQWRIRJ.js +10 -0
- package/dist/{chunk-N56WAVYA.js → chunk-SMIFCAAX.js} +1 -1
- package/dist/chunk-SWBJS3U4.js +1 -0
- package/dist/{chunk-WXGTU2M6.js → chunk-VMTOFEXF.js} +1 -1
- package/dist/{chunk-GEMDU6XW.js → chunk-VXP5BMW7.js} +1 -1
- package/dist/{chunk-LAJQSHEI.js → chunk-XAHU42FP.js} +3 -3
- package/dist/{chunk-ZV5ETNLQ.js → chunk-XBQR74IK.js} +1 -1
- package/dist/{chunk-TXG2H7YQ.js → chunk-XG7QNAKW.js} +1 -1
- package/dist/{chunk-PRLIHLCS.js → chunk-XLWCSJMR.js} +1 -1
- package/dist/{chunk-M4TVRCMZ.js → chunk-XXLLY66B.js} +1 -1
- package/dist/chunk-YFP4P2FV.js +1 -0
- package/dist/{chunk-SWA5B5B2.js → chunk-YIXP2ALP.js} +1 -1
- package/dist/{chunk-246NTPOS.js → chunk-ZJQRLVVV.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-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -0
- package/dist/entry-2.js +1 -1
- package/dist/entry-20.js +1 -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 +1 -1
- package/dist/entry-27.js +1 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +2 -4
- package/dist/entry-3.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -18
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +18 -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 +1 -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 +1 -1
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +1 -25
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +25 -1
- package/dist/entry-5.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -3
- package/dist/entry-53.js +1 -13
- package/dist/entry-54.js +3 -1
- package/dist/entry-55.js +13 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-6.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 +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +0 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-7.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +1 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +0 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -80
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +1 -22
- package/dist/entry-81.js +80 -2
- package/dist/entry-82.js +22 -1
- package/dist/entry-83.js +2 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -3
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -1
- package/dist/entry-88.js +3 -1
- package/dist/entry-89.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/entry-90.js +1 -0
- package/dist/entry-91.js +1 -0
- package/dist/pi-agent-ide.js +29 -36
- package/docs/agent-guides/debugger.md +2 -0
- package/docs/agent-guides/editing.md +3 -3
- package/docs/agent-guides/search-code.md +2 -2
- package/docs/agent-guides/select-code.md +9 -6
- package/docs/code-review.md +5 -0
- package/docs/configuration.md +36 -4
- package/docs/development.md +8 -0
- package/docs/directory-operations.md +1 -1
- package/docs/extensions.md +98 -1
- package/docs/structured-results.md +11 -6
- package/docs/user-hooks.md +2 -2
- package/node_modules/pi-agent-doctor/package.json +7 -7
- package/node_modules/pi-agent-doctor/runtime/entry-27.js +1 -0
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-28.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +8 -8
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/package.json +6 -6
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-32.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-ide-ast/package.json +15 -15
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +6 -5
- package/node_modules/pi-agent-ide-changes/package.json +10 -10
- package/node_modules/pi-agent-ide-changes/runtime/entry-36.js +1 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-40.js +2 -0
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-read/package.json +12 -12
- package/node_modules/pi-agent-read/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-49.js +2 -0
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/resource-error.ts +11 -0
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-54.js +2 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/node_modules/pi-agent-search-text/package.json +14 -14
- package/node_modules/pi-agent-search-text/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
- package/node_modules/pi-agent-text-editor/index.ts +2 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-79.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +45 -44
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +27 -18
- package/node_modules/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +29 -6
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +14 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +17 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +6 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +1 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-86.js +1 -0
- package/node_modules/pi-agent-tool-ui/src/operation-approval.ts +271 -0
- package/node_modules/pi-agent-web/package.json +8 -8
- 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-image/runtime/entry-89.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-90.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-91.js +2 -0
- package/package.json +62 -54
- package/src/api/approval.ts +5 -0
- package/src/api/settings.ts +198 -0
- package/src/backend/debugger-registration.ts +5 -1
- package/src/code-review/extension.ts +10 -4
- package/src/code-review/reviewer.ts +8 -0
- package/src/composite/host-version.ts +29 -5
- package/src/composite/ide-alias-rendering.ts +97 -0
- package/src/composite/nested-tool-rendering.ts +74 -4
- package/src/composite/search-facts.ts +45 -0
- package/src/composite/settings-documentation.ts +32 -23
- package/src/composite/settings-registry.ts +94 -0
- package/src/composite/text-results.ts +120 -8
- package/src/composite/tool-availability.ts +11 -2
- package/src/core/diagnostic-entry.ts +31 -8
- package/src/core/diagnostic-store.ts +19 -3
- package/src/core/extension.ts +7 -2
- package/src/core/reload-resource-store.ts +23 -3
- package/src/documentation/registry.ts +10 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-32.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-33.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- 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-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +2 -0
- 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-pdf/runtime/entry-90.js +2 -0
- 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/plugins/pi-agent-web-text/runtime/entry-91.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-49.js +2 -0
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-54.js +2 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/src/extensions/pi-agent-text-editor/index.ts +2 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-63.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
- 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/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +14 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +17 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-80.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +45 -44
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +27 -18
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +29 -6
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
- package/src/pi-agent-ide.ts +61 -14
- package/src/plugins/pi-agent-ide-ast/package.json +15 -15
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +6 -5
- package/src/plugins/pi-agent-ide-changes/package.json +10 -10
- package/src/plugins/pi-agent-ide-changes/runtime/entry-36.js +1 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
- package/src/plugins/pi-agent-ide-debugger/index.ts +159 -60
- package/src/plugins/pi-agent-ide-debugger/src/debugmcp-client.ts +118 -0
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +47 -0
- package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +2 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +146 -1
- package/src/plugins/pi-agent-ide-debugger/src/ui.ts +12 -0
- package/src/plugins/pi-agent-ide-debugger/src/vscode-backend.ts +497 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-40.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +3 -2
- package/src/plugins/pi-agent-ide-terminal/src/origin.ts +30 -0
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +34 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +11 -2
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +9 -0
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +72 -26
- package/dist/chunk-ESPNEJHK.js +0 -1
- package/dist/chunk-GNACBJM3.js +0 -1
- package/dist/chunk-VMGZMXEM.js +0 -10
- package/dist/chunk-W3YFF6OO.js +0 -1
- package/dist/chunk-W7M3V7FR.js +0 -28
- package/dist/chunk-WMHSVEIT.js +0 -29
- package/dist/chunk-XSIKDVAR.js +0 -25
- package/dist/chunk-YTYLS2UM.js +0 -1
- package/dist/chunk-Z2QGNTGQ.js +0 -1
- package/dist/entry-21.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-20.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-21.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-27.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-28.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
- package/node_modules/pi-agent-ide-formatter/runtime/entry-36.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-40.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-41.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-49.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-53.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-64.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-84.js +0 -2
- package/node_modules/pi-agent-web-html/runtime/entry-85.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-86.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-28.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-29.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-85.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-86.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-43.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-44.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +0 -2
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-36.js +0 -2
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-26.js +0 -0
- /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-50.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-60.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-61.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-62.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-63.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-87.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-88.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-31.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-88.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-60.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-61.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-62.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-34.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-39.js +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { withTextEditOrigin } from "./text-edit-origin.js";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { requiredValue } from "pi-agent-invariant";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -518,7 +519,11 @@ class NativeTextEditBatchCoordinator {
|
|
|
518
519
|
...presentation,
|
|
519
520
|
result: {
|
|
520
521
|
...presentation.result,
|
|
521
|
-
|
|
522
|
+
// Refresh file text after post-edit work; results without files (provider actions) keep their own text.
|
|
523
|
+
content:
|
|
524
|
+
results.length === 0
|
|
525
|
+
? presentation.result.content
|
|
526
|
+
: [new FileMutationAgentResult(results).toTextContent()],
|
|
522
527
|
},
|
|
523
528
|
} satisfies NativeEditBatchEvent);
|
|
524
529
|
}
|
|
@@ -914,22 +919,24 @@ class NativeTextEditBatchCoordinator {
|
|
|
914
919
|
};
|
|
915
920
|
try {
|
|
916
921
|
signal.throwIfAborted();
|
|
917
|
-
const captured = await script.
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
922
|
+
const captured = await withTextEditOrigin(this.core, script.id, () =>
|
|
923
|
+
script.postEdits.run(() =>
|
|
924
|
+
captureScriptMutation(this.core, () =>
|
|
925
|
+
executeRegisteredTextBatch(
|
|
926
|
+
this.core,
|
|
927
|
+
registrations,
|
|
928
|
+
{
|
|
929
|
+
edits: batch.entries,
|
|
930
|
+
expectedContent: batch.snapshots,
|
|
931
|
+
expectedExistence: batch.existence,
|
|
932
|
+
},
|
|
933
|
+
signal,
|
|
934
|
+
undefined,
|
|
935
|
+
script.context,
|
|
936
|
+
journal.reporter(),
|
|
937
|
+
() => {},
|
|
938
|
+
batch.plan,
|
|
939
|
+
),
|
|
933
940
|
),
|
|
934
941
|
),
|
|
935
942
|
);
|
|
@@ -986,7 +993,9 @@ export function runNativePostEditScope<T>(
|
|
|
986
993
|
immediate = false,
|
|
987
994
|
): T {
|
|
988
995
|
const coordinator = coordinators.get(core);
|
|
989
|
-
return
|
|
996
|
+
return withTextEditOrigin(core, id, () =>
|
|
997
|
+
coordinator ? coordinator.runPostEdits(id, work, immediate) : work(),
|
|
998
|
+
);
|
|
990
999
|
}
|
|
991
1000
|
|
|
992
1001
|
/** Retain immediate child results for final user panels and deferred processing failures. */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { TextEditorCore } from "./text-editor-core.js";
|
|
4
|
+
|
|
5
|
+
const activeOrigin = new AsyncLocalStorage<string>();
|
|
6
|
+
const executionRoots = new WeakMap<TextEditorCore, Map<string, string>>();
|
|
7
|
+
|
|
8
|
+
/** Retain native execution ancestry, never infer ownership from paths or current activity. */
|
|
9
|
+
export function registerTextEditOrigins(pi: ExtensionAPI, core: TextEditorCore): void {
|
|
10
|
+
const roots = new Map<string, string>();
|
|
11
|
+
executionRoots.set(core, roots);
|
|
12
|
+
pi.on("tool_call", (event) => {
|
|
13
|
+
const parent = event.parentToolCallId;
|
|
14
|
+
roots.set(
|
|
15
|
+
event.toolCallId,
|
|
16
|
+
parent === undefined ? event.toolCallId : (roots.get(parent) ?? parent),
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
pi.on("tool_result", (event) => {
|
|
20
|
+
roots.delete(event.toolCallId);
|
|
21
|
+
});
|
|
22
|
+
pi.on("agent_end", () => {
|
|
23
|
+
roots.clear();
|
|
24
|
+
});
|
|
25
|
+
pi.on("session_shutdown", () => {
|
|
26
|
+
roots.clear();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Execute an edit or its delayed batch with the original visible tool-call identity. */
|
|
31
|
+
export function withTextEditOrigin<T>(core: TextEditorCore, toolCallId: string, work: () => T): T {
|
|
32
|
+
return activeOrigin.run(executionRoots.get(core)?.get(toolCallId) ?? toolCallId, work);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Snapshot this identity before deferring final processing outside its originating call. */
|
|
36
|
+
export function currentTextEditOrigin(): string | undefined {
|
|
37
|
+
return activeOrigin.getStore();
|
|
38
|
+
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type Resource,
|
|
26
26
|
type ResourceResolver,
|
|
27
27
|
type ResourceResolverContext,
|
|
28
|
+
type ResultTargetStore,
|
|
28
29
|
} from "pi-agent-resource";
|
|
29
30
|
import {
|
|
30
31
|
createTextDocument,
|
|
@@ -95,6 +96,7 @@ import type {
|
|
|
95
96
|
TextAnchorInspectionOutcome,
|
|
96
97
|
TextAnchorInspectionRequest,
|
|
97
98
|
} from "#src/api/anchor-inspection.js";
|
|
99
|
+
import { currentTextEditOrigin } from "./text-edit-origin.js";
|
|
98
100
|
import type {
|
|
99
101
|
TextEditCompletion,
|
|
100
102
|
TextEditCompletionListener,
|
|
@@ -442,11 +444,13 @@ export interface TextEditorCore {
|
|
|
442
444
|
renderToolPromptGuideline(tool: TextEditorToolId): string | undefined;
|
|
443
445
|
}
|
|
444
446
|
|
|
447
|
+
/** Share issued-result authority with streamed anchor inspection, before tool-call normalization. */
|
|
445
448
|
export function createTextEditorCore(
|
|
446
449
|
registerMutationTool?: (
|
|
447
450
|
registration: AnyTextMutationToolRegistration,
|
|
448
451
|
core: TextEditorCore,
|
|
449
452
|
) => void,
|
|
453
|
+
resultTargets?: ResultTargetStore,
|
|
450
454
|
): TextEditorCore {
|
|
451
455
|
const projectConfig = loadTextEditorConfig(process.cwd());
|
|
452
456
|
const resolvers: RegisteredResolver[] = [];
|
|
@@ -784,7 +788,7 @@ export function createTextEditorCore(
|
|
|
784
788
|
return toolRenderers.get(tool);
|
|
785
789
|
},
|
|
786
790
|
inspectTextAnchors(request): Promise<TextAnchorInspectionOutcome> {
|
|
787
|
-
return inspectTextResource(request, [...resolvers], anchorRegistry.snapshot());
|
|
791
|
+
return inspectTextResource(request, [...resolvers], anchorRegistry.snapshot(), resultTargets);
|
|
788
792
|
},
|
|
789
793
|
resolveTextAnchorResources(value, kinds, context): Promise<readonly TextTarget[] | undefined> {
|
|
790
794
|
return anchorRegistry.snapshot().resolveResources(value, context, new Set(kinds));
|
|
@@ -993,7 +997,7 @@ export function createTextEditorCore(
|
|
|
993
997
|
const contributions = createPluginContributionController(
|
|
994
998
|
plugin.id,
|
|
995
999
|
registerContributions,
|
|
996
|
-
(request) =>
|
|
1000
|
+
(request) => core.inspectTextAnchors(request),
|
|
997
1001
|
(listener) => core.onMutationTool(listener),
|
|
998
1002
|
(listener) => core.onDidEdit(listener),
|
|
999
1003
|
(request) => previewTextMutation(core, request),
|
|
@@ -1110,7 +1114,35 @@ async function inspectTextResource(
|
|
|
1110
1114
|
request: TextAnchorInspectionRequest,
|
|
1111
1115
|
resolvers: readonly RegisteredResolver[],
|
|
1112
1116
|
anchors: TextAnchorRegistrySnapshot,
|
|
1117
|
+
resultTargets?: ResultTargetStore,
|
|
1113
1118
|
): Promise<TextAnchorInspectionOutcome> {
|
|
1119
|
+
if (resultTargets !== undefined) {
|
|
1120
|
+
try {
|
|
1121
|
+
const source = resultTargets.source(request.source, request.cwd);
|
|
1122
|
+
if (Array.isArray(source) || (typeof source === "string" && source.startsWith("RESULT#"))) {
|
|
1123
|
+
const selected = resultTargets.resolve(source, request.cwd);
|
|
1124
|
+
if (!selected.complete)
|
|
1125
|
+
return { kind: "failed", reason: "Incomplete result selections cannot authorize edits." };
|
|
1126
|
+
await resultTargets.verify(selected, request.signal);
|
|
1127
|
+
for (const target of selected.targets) {
|
|
1128
|
+
const inspected = await inspectTextResource(
|
|
1129
|
+
{ ...request, source: target.source },
|
|
1130
|
+
resolvers,
|
|
1131
|
+
anchors,
|
|
1132
|
+
);
|
|
1133
|
+
if (inspected.kind !== "valid") return inspected;
|
|
1134
|
+
}
|
|
1135
|
+
return { kind: "valid" };
|
|
1136
|
+
}
|
|
1137
|
+
} catch (error) {
|
|
1138
|
+
request.signal?.throwIfAborted();
|
|
1139
|
+
return {
|
|
1140
|
+
kind: "failed",
|
|
1141
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1142
|
+
cause: error,
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1114
1146
|
const context: ResourceResolverContext = {
|
|
1115
1147
|
cwd: request.cwd,
|
|
1116
1148
|
...(request.signal !== undefined && { signal: request.signal }),
|
|
@@ -1791,7 +1823,9 @@ async function prepareTextResource(
|
|
|
1791
1823
|
}
|
|
1792
1824
|
|
|
1793
1825
|
interface FinalizeTextResourceRequest<Result> {
|
|
1826
|
+
readonly parentToolCallId?: string;
|
|
1794
1827
|
readonly postProcessingFinal?: boolean;
|
|
1828
|
+
readonly savedText?: string;
|
|
1795
1829
|
readonly requestedSource: string;
|
|
1796
1830
|
readonly outcomeSource: string;
|
|
1797
1831
|
readonly resource: Resource;
|
|
@@ -1806,37 +1840,58 @@ interface FinalizeTextResourceRequest<Result> {
|
|
|
1806
1840
|
readonly result: Result;
|
|
1807
1841
|
}
|
|
1808
1842
|
|
|
1843
|
+
async function readSavedText(
|
|
1844
|
+
resource: Resource,
|
|
1845
|
+
context: ResourceResolverContext,
|
|
1846
|
+
): Promise<string> {
|
|
1847
|
+
try {
|
|
1848
|
+
const content = await requiredValue(resource.read)(
|
|
1849
|
+
context.signal === undefined ? {} : { signal: context.signal },
|
|
1850
|
+
);
|
|
1851
|
+
if (isAgentContent(content) && content.length === 1 && content[0].type === "text")
|
|
1852
|
+
return content[0].text;
|
|
1853
|
+
throw new ResourceError("INVALID_RESOURCE_READBACK", resource.source, "applied");
|
|
1854
|
+
} catch (error) {
|
|
1855
|
+
if (error instanceof ResourceError) {
|
|
1856
|
+
if (error.effect === "applied") throw error;
|
|
1857
|
+
throw new ResourceError(error.code, resource.source, "applied", { cause: error });
|
|
1858
|
+
}
|
|
1859
|
+
throw new ResourceError("RESOURCE_READBACK_FAILED", resource.source, "applied");
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1809
1862
|
async function finalizeTextResource<Result>(
|
|
1810
1863
|
request: FinalizeTextResourceRequest<Result>,
|
|
1811
1864
|
): Promise<Exclude<TextResourceEditOutcome<Result>, { readonly kind: "failed" }>> {
|
|
1812
1865
|
const skipPostEdit = request.resource.skipPostEdit === true;
|
|
1866
|
+
const savedText =
|
|
1867
|
+
!skipPostEdit && request.resource.read
|
|
1868
|
+
? await readSavedText(request.resource, request.context)
|
|
1869
|
+
: request.requestedText;
|
|
1813
1870
|
if (
|
|
1814
1871
|
!skipPostEdit &&
|
|
1815
1872
|
request.postProcessingFinal &&
|
|
1816
1873
|
!request.context.signal?.aborted &&
|
|
1817
|
-
request.
|
|
1818
|
-
)
|
|
1819
|
-
|
|
1820
|
-
|
|
1874
|
+
savedText !== (request.savedText ?? request.requestedText)
|
|
1875
|
+
)
|
|
1876
|
+
throw Object.assign(
|
|
1877
|
+
new Error(`Resource changed before final post-processing: ${request.resource.source}`),
|
|
1878
|
+
{ code: "POST_EDIT_STALE", effect: "applied" as const },
|
|
1821
1879
|
);
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
current[0].type !== "text" ||
|
|
1826
|
-
current[0].text !== request.requestedText
|
|
1827
|
-
)
|
|
1828
|
-
throw Object.assign(
|
|
1829
|
-
new Error(`Resource changed before final post-processing: ${request.resource.source}`),
|
|
1830
|
-
{ code: "POST_EDIT_STALE" },
|
|
1831
|
-
);
|
|
1832
|
-
}
|
|
1880
|
+
const parentToolCallId = request.postProcessingFinal
|
|
1881
|
+
? request.parentToolCallId
|
|
1882
|
+
: currentTextEditOrigin();
|
|
1833
1883
|
const deferred =
|
|
1834
1884
|
!skipPostEdit &&
|
|
1835
1885
|
!request.postProcessingFinal &&
|
|
1836
1886
|
deferPostEdit(request.resource.source, () =>
|
|
1837
|
-
finalizeTextResource({
|
|
1887
|
+
finalizeTextResource({
|
|
1888
|
+
...request,
|
|
1889
|
+
savedText,
|
|
1890
|
+
...(parentToolCallId === undefined ? {} : { parentToolCallId }),
|
|
1891
|
+
postProcessingFinal: true,
|
|
1892
|
+
}),
|
|
1838
1893
|
);
|
|
1839
|
-
const requestedAfter = createTextDocument(request.resource.source,
|
|
1894
|
+
const requestedAfter = createTextDocument(request.resource.source, savedText);
|
|
1840
1895
|
const transaction: TextPostEditTransaction = {
|
|
1841
1896
|
source: request.requestedSource,
|
|
1842
1897
|
resourceSource: request.resource.source,
|
|
@@ -1876,24 +1931,14 @@ async function finalizeTextResource<Result>(
|
|
|
1876
1931
|
],
|
|
1877
1932
|
},
|
|
1878
1933
|
});
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
const reread = await request.resource.read(
|
|
1884
|
-
request.context.signal === undefined ? {} : { signal: request.context.signal },
|
|
1885
|
-
);
|
|
1886
|
-
|
|
1887
|
-
if (isAgentContent(reread) && reread.length === 1 && reread[0].type === "text") {
|
|
1888
|
-
finalText = reread[0].text;
|
|
1889
|
-
}
|
|
1890
|
-
} catch {
|
|
1891
|
-
// The requested mutation remains the successful fallback when a final reread fails.
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1934
|
+
const finalText =
|
|
1935
|
+
!skipPostEdit && !deferred && request.resource.read
|
|
1936
|
+
? await readSavedText(request.resource, request.context)
|
|
1937
|
+
: savedText;
|
|
1894
1938
|
|
|
1895
1939
|
const finalAfter = createTextDocument(request.resource.source, finalText);
|
|
1896
1940
|
const completion: TextEditCompletion = {
|
|
1941
|
+
...(parentToolCallId === undefined ? {} : { parentToolCallId }),
|
|
1897
1942
|
source: request.requestedSource,
|
|
1898
1943
|
resourceSource: request.resource.source,
|
|
1899
1944
|
resolvedBy: request.resolvedBy,
|
|
@@ -2145,20 +2190,33 @@ async function editTextResource<Result>(
|
|
|
2145
2190
|
};
|
|
2146
2191
|
}
|
|
2147
2192
|
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2193
|
+
try {
|
|
2194
|
+
return await finalizeTextResource({
|
|
2195
|
+
requestedSource: source,
|
|
2196
|
+
outcomeSource: resource.source,
|
|
2197
|
+
resource,
|
|
2198
|
+
resolvedBy: resolver.id,
|
|
2199
|
+
existed: true,
|
|
2200
|
+
before,
|
|
2201
|
+
requestedText: mutation.text,
|
|
2202
|
+
context,
|
|
2203
|
+
presenters,
|
|
2204
|
+
postEditHandlers,
|
|
2205
|
+
editCompletionListeners,
|
|
2206
|
+
result: mutation.result,
|
|
2207
|
+
});
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
return {
|
|
2210
|
+
kind: "failed",
|
|
2211
|
+
failure: {
|
|
2212
|
+
code: "POST_WRITE_FAILED",
|
|
2213
|
+
source: resource.source,
|
|
2214
|
+
resolverId: resolver.id,
|
|
2215
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2216
|
+
cause: error,
|
|
2217
|
+
},
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2162
2220
|
}
|
|
2163
2221
|
|
|
2164
2222
|
return {
|
|
@@ -304,7 +304,13 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
304
304
|
content: [{ type: "text", text: action.summary }],
|
|
305
305
|
details: {
|
|
306
306
|
results: [],
|
|
307
|
-
metadata: {
|
|
307
|
+
metadata: {
|
|
308
|
+
semanticAction: {
|
|
309
|
+
...action.data,
|
|
310
|
+
source: action.source,
|
|
311
|
+
...(action.script !== undefined && { script: action.script }),
|
|
312
|
+
},
|
|
313
|
+
},
|
|
308
314
|
},
|
|
309
315
|
};
|
|
310
316
|
} catch (error) {
|
|
@@ -364,6 +370,7 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
364
370
|
errorMessage(captured.error),
|
|
365
371
|
"unknown",
|
|
366
372
|
undefined,
|
|
373
|
+
undefined,
|
|
367
374
|
definition.name === "copy",
|
|
368
375
|
);
|
|
369
376
|
return structuredMutation(
|
|
@@ -1496,7 +1503,14 @@ async function buildToolResult(
|
|
|
1496
1503
|
const message = `${reason.replace(/[.!?]+$/u, "")}.${completed}`;
|
|
1497
1504
|
return safe === undefined
|
|
1498
1505
|
? buildFailedTextMutationResult(core, { ...outcome.failure, message }, context, effect)
|
|
1499
|
-
: failureToolResult(
|
|
1506
|
+
: failureToolResult(
|
|
1507
|
+
source,
|
|
1508
|
+
safe.code,
|
|
1509
|
+
message,
|
|
1510
|
+
effect,
|
|
1511
|
+
outcome.failure.rollback,
|
|
1512
|
+
outcome.failure.code,
|
|
1513
|
+
);
|
|
1500
1514
|
}
|
|
1501
1515
|
|
|
1502
1516
|
const mutation = outcome.result as ExecutedTextMutation;
|
|
@@ -1509,6 +1523,9 @@ async function buildToolResult(
|
|
|
1509
1523
|
semanticAction: {
|
|
1510
1524
|
...mutation.semanticAction.data,
|
|
1511
1525
|
source: mutation.semanticAction.source,
|
|
1526
|
+
...(mutation.semanticAction.script !== undefined && {
|
|
1527
|
+
script: mutation.semanticAction.script,
|
|
1528
|
+
}),
|
|
1512
1529
|
},
|
|
1513
1530
|
},
|
|
1514
1531
|
},
|
|
@@ -1699,9 +1716,14 @@ async function anchorFailureToolResult(
|
|
|
1699
1716
|
results: [result],
|
|
1700
1717
|
effect: "not-applied",
|
|
1701
1718
|
anchorRecovery: true,
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1719
|
+
// A Copy destination failure must not block otherwise valid source selectors.
|
|
1720
|
+
...(resolution.resolverId === "exact-text" &&
|
|
1721
|
+
!(
|
|
1722
|
+
contextual.toolName === "copy" &&
|
|
1723
|
+
(contextual.field === "targetStart" || contextual.field === "targetEnd")
|
|
1724
|
+
) && {
|
|
1725
|
+
metadata: { exactTextFailures: [contextual.source] },
|
|
1726
|
+
}),
|
|
1705
1727
|
...(recovery?.kind === "candidates" && {
|
|
1706
1728
|
anchorRecoveries: [
|
|
1707
1729
|
{
|
|
@@ -1839,6 +1861,7 @@ function failureToolResult(
|
|
|
1839
1861
|
reason: string,
|
|
1840
1862
|
effect: "not-applied" | "applied" | "unknown",
|
|
1841
1863
|
rollback?: TextResourceEditFailure["rollback"],
|
|
1864
|
+
stage?: string,
|
|
1842
1865
|
copyExecutionFailure = false,
|
|
1843
1866
|
): { content: [{ type: "text"; text: string }]; details: FileMutationBatchResult } {
|
|
1844
1867
|
const uncertain =
|
|
@@ -1866,7 +1889,7 @@ function failureToolResult(
|
|
|
1866
1889
|
const result = new FileMutationResult({
|
|
1867
1890
|
ok: false,
|
|
1868
1891
|
path: source,
|
|
1869
|
-
errors: [{ path: source, code, reason }],
|
|
1892
|
+
errors: [{ path: source, code, reason, ...(stage === undefined ? {} : { stage }) }],
|
|
1870
1893
|
...(fileChangedStatement === undefined
|
|
1871
1894
|
? {}
|
|
1872
1895
|
: {
|
package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
createAssistantMessageEventStream,
|
|
9
9
|
type Model,
|
|
10
10
|
type SimpleStreamOptions,
|
|
11
|
+
type Provider,
|
|
11
12
|
} from "@earendil-works/pi-ai";
|
|
12
13
|
|
|
13
14
|
import type { GuardInterception } from "./coordinator.js";
|
|
@@ -39,7 +40,7 @@ interface StreamingSubscriber {
|
|
|
39
40
|
|
|
40
41
|
interface SharedProviderState {
|
|
41
42
|
api: string;
|
|
42
|
-
readonly
|
|
43
|
+
readonly originalStreamSimple: StreamSimple;
|
|
43
44
|
readonly wrapper: WrappedStreamSimple;
|
|
44
45
|
readonly subscribers: Set<StreamingSubscriber>;
|
|
45
46
|
}
|
|
@@ -50,7 +51,7 @@ type WrappedStreamSimple = StreamSimple & { [streamingInterceptorState]?: Shared
|
|
|
50
51
|
Install one shared stream wrapper for all interceptors using each active provider.
|
|
51
52
|
*/
|
|
52
53
|
export function registerStreamingInterceptorProvider(
|
|
53
|
-
pi: ExtensionAPI,
|
|
54
|
+
pi: Pick<ExtensionAPI, "on" | "registerProvider" | "unregisterProvider">,
|
|
54
55
|
processStreamEvent: ProcessStreamEvent,
|
|
55
56
|
markStreamEventProcessed: MarkStreamEventProcessed,
|
|
56
57
|
finalizeStreamInterception: FinalizeStreamInterception,
|
|
@@ -64,52 +65,36 @@ export function registerStreamingInterceptorProvider(
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
const install = (model: Model<Api> | undefined, context: ExtensionContext): void => {
|
|
67
|
-
if (!model)
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
68
|
+
if (!model) return;
|
|
71
69
|
const provider = context.modelRegistry.getProvider(model.provider);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
if (!provider) return;
|
|
71
|
+
|
|
72
|
+
const register = (wrapper: WrappedStreamSimple): void => {
|
|
73
|
+
const native = context.modelRegistry.getRegisteredNativeProvider(model.provider);
|
|
74
|
+
if (native) {
|
|
75
|
+
// Registering by name removes native authentication and discovery in Pi.
|
|
76
|
+
pi.registerProvider(withStreamSimple(native, wrapper));
|
|
77
|
+
} else {
|
|
78
|
+
const config = context.modelRegistry.getRegisteredProviderConfig(model.provider);
|
|
79
|
+
pi.registerProvider(model.provider, { ...config, api: model.api, streamSimple: wrapper });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
77
82
|
const active = installed.get(model.provider);
|
|
78
|
-
|
|
79
83
|
if (active) {
|
|
80
84
|
active.subscribers.add(subscriber);
|
|
81
|
-
|
|
82
|
-
if (active.api === model.api && provider.streamSimple === active.wrapper) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
85
|
+
if (active.api === model.api && provider.streamSimple === active.wrapper) return;
|
|
86
86
|
active.api = model.api;
|
|
87
|
-
|
|
88
|
-
pi.registerProvider(model.provider, {
|
|
89
|
-
...config,
|
|
90
|
-
api: model.api,
|
|
91
|
-
streamSimple: active.wrapper,
|
|
92
|
-
});
|
|
87
|
+
register(active.wrapper);
|
|
93
88
|
return;
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
const shared = (provider.streamSimple as WrappedStreamSimple)[streamingInterceptorState];
|
|
97
|
-
|
|
98
92
|
if (shared) {
|
|
99
93
|
shared.subscribers.add(subscriber);
|
|
100
94
|
installed.set(model.provider, shared);
|
|
101
|
-
|
|
102
|
-
if (shared.api === model.api) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
95
|
+
if (shared.api === model.api) return;
|
|
106
96
|
shared.api = model.api;
|
|
107
|
-
|
|
108
|
-
pi.registerProvider(model.provider, {
|
|
109
|
-
...config,
|
|
110
|
-
api: model.api,
|
|
111
|
-
streamSimple: shared.wrapper,
|
|
112
|
-
});
|
|
97
|
+
register(shared.wrapper);
|
|
113
98
|
return;
|
|
114
99
|
}
|
|
115
100
|
|
|
@@ -119,18 +104,12 @@ export function registerStreamingInterceptorProvider(
|
|
|
119
104
|
wrapStream(delegate, currentModel, context, options, subscribers);
|
|
120
105
|
const state: SharedProviderState = {
|
|
121
106
|
api: model.api,
|
|
122
|
-
|
|
107
|
+
originalStreamSimple: provider.streamSimple,
|
|
123
108
|
wrapper,
|
|
124
109
|
subscribers,
|
|
125
110
|
};
|
|
126
111
|
wrapper[streamingInterceptorState] = state;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
pi.registerProvider(model.provider, {
|
|
130
|
-
...config,
|
|
131
|
-
api: model.api,
|
|
132
|
-
streamSimple: wrapper,
|
|
133
|
-
});
|
|
112
|
+
register(wrapper);
|
|
134
113
|
installed.set(model.provider, state);
|
|
135
114
|
};
|
|
136
115
|
|
|
@@ -162,7 +141,15 @@ export function registerStreamingInterceptorProvider(
|
|
|
162
141
|
for (const [provider, state] of installed) {
|
|
163
142
|
state.subscribers.delete(subscriber);
|
|
164
143
|
|
|
165
|
-
if (state.subscribers.size
|
|
144
|
+
if (state.subscribers.size !== 0) continue;
|
|
145
|
+
const registry = subscriber.context?.modelRegistry;
|
|
146
|
+
const current = registry?.getProvider(provider);
|
|
147
|
+
if (current?.streamSimple !== state.wrapper) continue;
|
|
148
|
+
const native = registry?.getRegisteredNativeProvider(provider);
|
|
149
|
+
if (native) {
|
|
150
|
+
// Restore only our stream hook, retaining later auth/catalog updates.
|
|
151
|
+
pi.registerProvider(withStreamSimple(native, state.originalStreamSimple));
|
|
152
|
+
} else {
|
|
166
153
|
pi.unregisterProvider(provider);
|
|
167
154
|
}
|
|
168
155
|
}
|
|
@@ -172,6 +159,14 @@ export function registerStreamingInterceptorProvider(
|
|
|
172
159
|
});
|
|
173
160
|
}
|
|
174
161
|
|
|
162
|
+
/** Preserve prototype methods and non-enumerable native provider fields. */
|
|
163
|
+
function withStreamSimple(provider: Provider, streamSimple: StreamSimple): Provider {
|
|
164
|
+
return Object.create(Object.getPrototypeOf(provider) as object | null, {
|
|
165
|
+
...Object.getOwnPropertyDescriptors(provider),
|
|
166
|
+
streamSimple: { value: streamSimple, writable: true, enumerable: true, configurable: true },
|
|
167
|
+
}) as Provider;
|
|
168
|
+
}
|
|
169
|
+
|
|
175
170
|
function wrapStream(
|
|
176
171
|
delegate: StreamSimple,
|
|
177
172
|
model: Model<Api>,
|
|
@@ -36,8 +36,10 @@ export function writeAgentResult(
|
|
|
36
36
|
completions: readonly TextEditCompletion[],
|
|
37
37
|
requestedPath: unknown,
|
|
38
38
|
): AgentToolResult<FileMutationBatchResult> {
|
|
39
|
-
//
|
|
39
|
+
// Semantic providers own their action receipts and need not emit file completions.
|
|
40
|
+
// Terminal input and other live resources also keep their own action receipts.
|
|
40
41
|
if (
|
|
42
|
+
result.details.metadata?.semanticAction !== undefined ||
|
|
41
43
|
(typeof requestedPath === "string" && requestedPath.startsWith("shell:")) ||
|
|
42
44
|
completions.some((completion) => completion.resolvedBy !== "filesystem")
|
|
43
45
|
)
|
|
@@ -3,7 +3,7 @@ import { resultInputSchema } from "pi-agent-resource";
|
|
|
3
3
|
|
|
4
4
|
/** Build a structured source selector without changing legacy path semantics. */
|
|
5
5
|
export function resultSourceProperty(description: string) {
|
|
6
|
-
return Type.Optional(
|
|
6
|
+
return Type.Optional(Type.Union(resultInputSchema.anyOf, { description }));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/** Build the source selector shared by text mutation schemas. */
|
|
@@ -15,11 +15,12 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
15
15
|
|
|
16
16
|
export const replaceSchema = Type.Object(
|
|
17
17
|
{
|
|
18
|
-
path: Type.Optional(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
path: Type.Optional(
|
|
19
|
+
Type.Union(resultInputSchema.anyOf, {
|
|
20
|
+
description:
|
|
21
|
+
"Source path, SEARCH# selector, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Omit start/end when the result selects the intended text. Changed or expired results are rejected without writing.",
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
23
24
|
...sourceRangeProperties(),
|
|
24
25
|
text: Type.String({
|
|
25
26
|
description:
|