pi-agent-ide 0.7.0 → 0.7.2
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 +44 -0
- package/dist/chunk-6U5OU77O.js +3 -0
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-EURHXLN3.js +2 -0
- package/dist/{chunk-PYPPV2F5.js → chunk-F6IWZKOG.js} +6 -6
- package/dist/{chunk-GBLKIB6O.js → chunk-H445SHSJ.js} +2 -2
- package/dist/chunk-IG56UGSO.js +2 -0
- package/dist/chunk-IICJXZBU.js +6 -0
- package/dist/{chunk-XYS4FSCC.js → chunk-IM24DB3K.js} +1 -1
- package/dist/{chunk-YRF7OATP.js → chunk-KOVPDKSJ.js} +1 -1
- package/dist/chunk-MXLSGMRZ.js +3 -0
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OB46OPMZ.js +1 -0
- package/dist/chunk-PKSQT6TC.js +1 -0
- package/dist/{chunk-PNU3E7IO.js → chunk-Q6CZ6GBR.js} +2 -2
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/chunk-QUYXINGZ.js +7 -0
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-SBP3ABH4.js +5 -0
- package/dist/{chunk-FXNKMNSJ.js → chunk-SJ4UZ4GU.js} +1 -1
- package/dist/chunk-SNF7PDDX.js +11 -0
- package/dist/{chunk-AJRIASPQ.js → chunk-STBJO3Z3.js} +1 -1
- package/dist/{chunk-3HYXQ4YA.js → chunk-TQGE7RH6.js} +13 -13
- package/dist/{chunk-S5LXX32D.js → chunk-XDG7EQRN.js} +3 -3
- package/dist/{chunk-F5YZG77W.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/chunk-YWQS33DF.js +1 -0
- package/dist/chunk-ZIWPKIBZ.js +1 -0
- package/dist/entry-11.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-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +15 -13
- package/dist/entry-33.js +2 -1
- package/dist/entry-37.js +6 -6
- 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 +20 -13
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +8 -7
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -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-60.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +51 -43
- package/dist/entry-78.js +14 -14
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-82.js +5 -5
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +37 -9
- package/docs/agent-guides/editing.md +35 -46
- package/docs/agent-guides/git-changes.md +10 -0
- package/docs/agent-guides/read-resources.md +9 -50
- package/docs/agent-guides/search-code.md +18 -17
- package/docs/agent-guides/select-code.md +62 -140
- package/docs/agent-guides/terminal.md +9 -1
- package/docs/configuration.md +1 -1
- package/docs/releases.md +4 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/structured-results.md +27 -62
- package/docs/tools.md +15 -11
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +7 -6
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/index.ts +4 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +4 -1
- 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 +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +5 -4
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +35 -9
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +10 -8
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +28 -3
- package/node_modules/pi-agent-ide-changes/index.ts +4 -3
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +66 -4
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +3 -3
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/node_modules/pi-agent-read/src/api/tools/read.ts +18 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +8 -2
- package/node_modules/pi-agent-read/src/core/read-core.ts +54 -35
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +108 -46
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +1 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +186 -9
- package/node_modules/{pi-agent-read/src/core/tools/read → pi-agent-resource/src}/temp-resource-store.ts +17 -7
- package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +5 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +3 -3
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -1
- package/node_modules/pi-agent-search/src/core/search-core.ts +13 -4
- package/node_modules/pi-agent-search-text/index.ts +1 -1
- package/node_modules/pi-agent-search-text/package.json +7 -7
- package/node_modules/pi-agent-search-text/src/resolvers.ts +11 -1
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +42 -32
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +6 -0
- package/node_modules/pi-agent-search-text/src/search-result.ts +17 -3
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/index.ts +65 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +2 -1
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +35 -6
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +232 -144
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +24 -4
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +7 -2
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +49 -214
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +152 -22
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +76 -32
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +409 -209
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -9
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +10 -3
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +54 -5
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +4 -3
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/src/resolver.ts +11 -13
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/composite/nested-tool-rendering.ts +64 -6
- package/src/composite/output-limits.ts +125 -0
- package/src/composite/responses-tools.ts +25 -0
- package/src/composite/text-results.ts +372 -0
- package/src/documentation/extension.ts +11 -9
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- 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-jq/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +4 -1
- 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 +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +11 -13
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +18 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +8 -2
- package/src/extensions/pi-agent-read/src/core/read-core.ts +54 -35
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +108 -46
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +11 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +42 -32
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +6 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +17 -3
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +5 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +3 -3
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -1
- package/src/extensions/pi-agent-search/src/core/search-core.ts +13 -4
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- 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/index.ts +65 -4
- 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-exact/src/anchor.ts +12 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +54 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +2 -1
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +35 -6
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +232 -144
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +24 -4
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +7 -2
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +49 -214
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +152 -22
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +76 -32
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +409 -209
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -9
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +10 -3
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
- package/src/pi-agent-ide.ts +15 -1
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +5 -4
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +35 -9
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +10 -8
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +28 -3
- package/src/plugins/pi-agent-ide-changes/index.ts +4 -3
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +66 -4
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
- package/src/plugins/pi-agent-ide-debugger/index.ts +22 -10
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +93 -38
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +6 -3
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +3 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -2
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +3 -3
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +3 -3
- package/src/plugins/pi-agent-ide-vision/index.ts +13 -4
- package/src/post-edit/gate.ts +13 -2
- package/dist/chunk-3JO7QFIL.js +0 -1
- package/dist/chunk-4NIFBFFR.js +0 -11
- package/dist/chunk-64M3SQPG.js +0 -3
- package/dist/chunk-7LZKOHH2.js +0 -1
- package/dist/chunk-EAZGN5ND.js +0 -7
- package/dist/chunk-FK42RSF4.js +0 -1
- package/dist/chunk-KBP3QUDT.js +0 -2
- package/dist/chunk-KR36BT5E.js +0 -1
- package/dist/chunk-MBUXFKIW.js +0 -3
- package/dist/chunk-OE7QVAI2.js +0 -5
- package/dist/chunk-SILJ3OL4.js +0 -9
- package/dist/chunk-SQKAXYIR.js +0 -2
- package/dist/chunk-VCGNVTXQ.js +0 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +0 -105
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { requiredValue } from "pi-agent-invariant";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -21,19 +22,18 @@ import {
|
|
|
21
22
|
} from "./text-edit-batch-registrar.js";
|
|
22
23
|
import { buildFailedTextMutationResult, mutationSources } from "./text-mutation.js";
|
|
23
24
|
import { isWholeFileInvocation } from "./file-operation-tools.js";
|
|
25
|
+
import { isResultInput } from "./result-transfer.js";
|
|
24
26
|
import { FileMutationAgentResult } from "./mutation-result/file-mutation-agent-result.js";
|
|
25
|
-
import { Type } from "typebox";
|
|
26
27
|
import {
|
|
27
28
|
ResourceScheduler,
|
|
28
29
|
resourceAccesses,
|
|
29
30
|
connectResultTargets,
|
|
30
31
|
resultError,
|
|
31
|
-
withStructuredResult,
|
|
32
32
|
type ResultTargetStore,
|
|
33
33
|
type StructuredResult,
|
|
34
34
|
} from "pi-agent-resource";
|
|
35
35
|
import { createPostEditScope } from "./post-edit-scope.js";
|
|
36
|
-
import { committedMutationTargets } from "./mutation-result-targets.js";
|
|
36
|
+
import { committedMutationTargets, unchangedCopySources } from "./mutation-result-targets.js";
|
|
37
37
|
import { FileMutationResult as MutationPresentation } from "./mutation-result/file-mutation-result.js";
|
|
38
38
|
import { isFormattingContribution, isDiffStatusContribution } from "#src/api/post-edit.js";
|
|
39
39
|
import { captureScriptMutation } from "./text-mutation.js";
|
|
@@ -41,12 +41,7 @@ import {
|
|
|
41
41
|
NATIVE_EDIT_BATCH_EVENT,
|
|
42
42
|
type NativeEditBatchEvent,
|
|
43
43
|
} from "#src/api/native-edit-batch-event.js";
|
|
44
|
-
import {
|
|
45
|
-
mutationDataSchema,
|
|
46
|
-
mutationOutputSchema,
|
|
47
|
-
mutationOutcome,
|
|
48
|
-
type MutationData,
|
|
49
|
-
} from "./structured-result.js";
|
|
44
|
+
import { mutationOutcome, type MutationData, type BatchMutationData } from "./structured-result.js";
|
|
50
45
|
|
|
51
46
|
interface PendingBatch {
|
|
52
47
|
readonly entries: TextBatchEntry[];
|
|
@@ -62,8 +57,7 @@ interface BatchSummary {
|
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
interface ScriptBatch {
|
|
65
|
-
readonly reports: StructuredResult<
|
|
66
|
-
reportCursor: number;
|
|
60
|
+
readonly reports: StructuredResult<BatchMutationData>[];
|
|
67
61
|
readonly id: string;
|
|
68
62
|
readonly context: ExtensionContext;
|
|
69
63
|
readonly summaries: BatchSummary[];
|
|
@@ -76,10 +70,33 @@ interface ScriptBatch {
|
|
|
76
70
|
tail: Promise<void>;
|
|
77
71
|
readonly scheduler: ResourceScheduler;
|
|
78
72
|
readonly callOrder: Map<string, number>;
|
|
73
|
+
readonly unfinishedCalls: Map<string, string>;
|
|
79
74
|
pending: PendingBatch;
|
|
80
75
|
closed: boolean;
|
|
81
76
|
}
|
|
82
77
|
|
|
78
|
+
function replaceScriptResult(
|
|
79
|
+
script: ScriptBatch,
|
|
80
|
+
previous: FileMutationResult,
|
|
81
|
+
updated: FileMutationResult,
|
|
82
|
+
): void {
|
|
83
|
+
const index = script.results.indexOf(previous);
|
|
84
|
+
if (index >= 0) script.results[index] = updated;
|
|
85
|
+
for (const [slot, presentation] of script.presentations.entries()) {
|
|
86
|
+
const results = presentation.result.details.results;
|
|
87
|
+
if (!results?.includes(previous)) continue;
|
|
88
|
+
script.presentations[slot] = {
|
|
89
|
+
...presentation,
|
|
90
|
+
result: {
|
|
91
|
+
...presentation.result,
|
|
92
|
+
details: {
|
|
93
|
+
...presentation.result.details,
|
|
94
|
+
results: results.map((result) => (result === previous ? updated : result)),
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
83
100
|
function mergedFiles(files: MutationData["files"]): MutationData["files"] {
|
|
84
101
|
const merged = new Map<string, MutationData["files"][number]>();
|
|
85
102
|
for (const file of files) {
|
|
@@ -103,10 +120,7 @@ function receiptEffect(files: MutationData["files"]): MutationData["effect"] {
|
|
|
103
120
|
: "not-applied";
|
|
104
121
|
}
|
|
105
122
|
|
|
106
|
-
function receiptStatus(
|
|
107
|
-
errors: readonly unknown[],
|
|
108
|
-
operations: NonNullable<MutationData["operations"]>,
|
|
109
|
-
) {
|
|
123
|
+
function receiptStatus(errors: readonly unknown[], operations: BatchMutationData["operations"]) {
|
|
110
124
|
return errors.length === 0
|
|
111
125
|
? ("success" as const)
|
|
112
126
|
: operations.some(
|
|
@@ -138,6 +152,7 @@ function isBatchable(
|
|
|
138
152
|
input: Readonly<Record<string, unknown>>,
|
|
139
153
|
): boolean {
|
|
140
154
|
if (
|
|
155
|
+
registration.name === "write" ||
|
|
141
156
|
registration.direct?.matches(input) ||
|
|
142
157
|
registration.intent === "restore" ||
|
|
143
158
|
isWholeFileInvocation(registration.wholeFileOperation, input) ||
|
|
@@ -174,64 +189,6 @@ class NativeTextEditBatchCoordinator {
|
|
|
174
189
|
private readonly pi: ExtensionAPI,
|
|
175
190
|
) {
|
|
176
191
|
this.resultTargets = connectResultTargets(pi);
|
|
177
|
-
pi.registerTool({
|
|
178
|
-
name: "flush",
|
|
179
|
-
exposure: "codemode",
|
|
180
|
-
namespace: {
|
|
181
|
-
name: "ide_edit",
|
|
182
|
-
description: "Edit files and live IDE resources with guarded operations.",
|
|
183
|
-
},
|
|
184
|
-
annotations: {
|
|
185
|
-
readOnlyHint: false,
|
|
186
|
-
destructiveHint: true,
|
|
187
|
-
idempotentHint: false,
|
|
188
|
-
openWorldHint: false,
|
|
189
|
-
},
|
|
190
|
-
label: "Flush",
|
|
191
|
-
description:
|
|
192
|
-
"Use flush to commit pending native Codemode text edits and return their observed effects. Await tools.flush({}) before depending on a completed write. A failed flush retains applied effects and does not replay edits. Call it only inside native Codemode.",
|
|
193
|
-
promptSnippet: "Commit pending native editor changes and inspect their effects",
|
|
194
|
-
parameters: Type.Object({}, { additionalProperties: false }),
|
|
195
|
-
outputSchema: mutationOutputSchema,
|
|
196
|
-
execute: async (id) => {
|
|
197
|
-
const script = this.invocations.get(id);
|
|
198
|
-
if (!script) throw new Error("Flush requires an active native Codemode script");
|
|
199
|
-
const work = script.scheduler.run(undefined, async () => {
|
|
200
|
-
await this.commit(script);
|
|
201
|
-
const reports = script.reports.slice(script.reportCursor);
|
|
202
|
-
script.reportCursor = script.reports.length;
|
|
203
|
-
const files = mergedFiles(reports.flatMap((report) => report.data?.files ?? []));
|
|
204
|
-
const errors = reports.flatMap((report) => report.errors);
|
|
205
|
-
const operations = reports.flatMap((report) => report.data?.operations ?? []);
|
|
206
|
-
const effect = receiptEffect(files);
|
|
207
|
-
return withStructuredResult(
|
|
208
|
-
{
|
|
209
|
-
content: [
|
|
210
|
-
{
|
|
211
|
-
type: "text",
|
|
212
|
-
text:
|
|
213
|
-
errors.length === 0
|
|
214
|
-
? `Flushed ${operations.length} editor operations; ${effect}.`
|
|
215
|
-
: `Editor flush failed; ${effect}.\n${errors.map((error) => error.message).join("\n")}`,
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
details: { results: [] },
|
|
219
|
-
},
|
|
220
|
-
mutationDataSchema,
|
|
221
|
-
{
|
|
222
|
-
status: receiptStatus(errors, operations),
|
|
223
|
-
data: { operation: "flush", effect, files, operations },
|
|
224
|
-
errors,
|
|
225
|
-
},
|
|
226
|
-
);
|
|
227
|
-
});
|
|
228
|
-
script.tail = work.then(
|
|
229
|
-
() => undefined,
|
|
230
|
-
() => undefined,
|
|
231
|
-
);
|
|
232
|
-
return work;
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
192
|
pi.on("tool_call", async (event, context) => {
|
|
236
193
|
if (event.toolName === "codemode" && event.parentToolCallId === undefined) {
|
|
237
194
|
this.scripts.set(event.toolCallId, {
|
|
@@ -239,7 +196,6 @@ class NativeTextEditBatchCoordinator {
|
|
|
239
196
|
context,
|
|
240
197
|
summaries: [],
|
|
241
198
|
reports: [],
|
|
242
|
-
reportCursor: 0,
|
|
243
199
|
presentations: [],
|
|
244
200
|
results: [],
|
|
245
201
|
errors: [],
|
|
@@ -249,6 +205,7 @@ class NativeTextEditBatchCoordinator {
|
|
|
249
205
|
tail: Promise.resolve(),
|
|
250
206
|
scheduler: new ResourceScheduler(),
|
|
251
207
|
callOrder: new Map(),
|
|
208
|
+
unfinishedCalls: new Map(),
|
|
252
209
|
pending: pendingBatch(),
|
|
253
210
|
closed: false,
|
|
254
211
|
});
|
|
@@ -257,15 +214,18 @@ class NativeTextEditBatchCoordinator {
|
|
|
257
214
|
const script =
|
|
258
215
|
event.parentToolCallId === undefined ? undefined : this.scripts.get(event.parentToolCallId);
|
|
259
216
|
if (!script) return;
|
|
260
|
-
if (event.toolName === "flush") {
|
|
261
|
-
this.invocations.set(event.toolCallId, script);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
217
|
const registration = this.core
|
|
265
218
|
.getMutationTools()
|
|
266
219
|
.find((tool) => tool.name === event.toolName);
|
|
267
|
-
if (registration) this.scopedInvocations.set(event.toolCallId, script);
|
|
268
220
|
const input: Record<string, unknown> = event.input;
|
|
221
|
+
if (registration) {
|
|
222
|
+
this.scopedInvocations.set(event.toolCallId, script);
|
|
223
|
+
const source = input[registration.source.field];
|
|
224
|
+
script.unfinishedCalls.set(
|
|
225
|
+
event.toolCallId,
|
|
226
|
+
typeof source === "string" && !isResultInput(source) ? source : "",
|
|
227
|
+
);
|
|
228
|
+
}
|
|
269
229
|
let ownsSource = false;
|
|
270
230
|
if (registration && !isWholeFileInvocation(registration.wholeFileOperation, input)) {
|
|
271
231
|
const resolverContext = {
|
|
@@ -276,7 +236,9 @@ class NativeTextEditBatchCoordinator {
|
|
|
276
236
|
const value = input[descriptor.field];
|
|
277
237
|
if (typeof value === "string" && value.length > 0) {
|
|
278
238
|
if (
|
|
279
|
-
["replace", "write", "copy", "move", "delete", "undo"].includes(
|
|
239
|
+
["replace", "write", "copy", "move", "delete", "undo", "insert"].includes(
|
|
240
|
+
registration.name,
|
|
241
|
+
) &&
|
|
280
242
|
value.startsWith("RESULT#")
|
|
281
243
|
) {
|
|
282
244
|
// The executor validates result handles and returns a structured rejection.
|
|
@@ -319,25 +281,51 @@ class NativeTextEditBatchCoordinator {
|
|
|
319
281
|
return;
|
|
320
282
|
});
|
|
321
283
|
pi.on("tool_result", async (event) => {
|
|
284
|
+
this.scopedInvocations.get(event.toolCallId)?.unfinishedCalls.delete(event.toolCallId);
|
|
322
285
|
this.invocations.delete(event.toolCallId);
|
|
323
286
|
this.scopedInvocations.delete(event.toolCallId);
|
|
324
287
|
const script = this.scripts.get(event.toolCallId);
|
|
325
288
|
if (!script) return;
|
|
326
289
|
script.closed = true;
|
|
290
|
+
const texts = event.content
|
|
291
|
+
.filter((block) => block.type === "text")
|
|
292
|
+
.map((block) => block.text);
|
|
293
|
+
let executionError = texts.findLast((text) => text.startsWith("Script error:\n")) ?? "";
|
|
294
|
+
const executionDetails = event.details;
|
|
295
|
+
if (
|
|
296
|
+
event.isError &&
|
|
297
|
+
executionDetails !== null &&
|
|
298
|
+
typeof executionDetails === "object" &&
|
|
299
|
+
"fullOutputPath" in executionDetails &&
|
|
300
|
+
typeof executionDetails.fullOutputPath === "string"
|
|
301
|
+
) {
|
|
302
|
+
try {
|
|
303
|
+
const output = await readFile(executionDetails.fullOutputPath, "utf8");
|
|
304
|
+
// A timeout has one engine error line followed by the call summary, not a JavaScript stack.
|
|
305
|
+
const matches = [
|
|
306
|
+
...output.matchAll(
|
|
307
|
+
/(?:^|\n)(Script error:\nScript (?:aborted|timed out):[^\n]*\n\n(?:Tool calls made before the failure[^\n]*|No tool calls were made\.))/gu,
|
|
308
|
+
),
|
|
309
|
+
];
|
|
310
|
+
const match = matches.at(-1);
|
|
311
|
+
executionError =
|
|
312
|
+
match !== undefined &&
|
|
313
|
+
!output.slice(match.index + match[0].length).includes("Script error:\n")
|
|
314
|
+
? (match[1] ?? "")
|
|
315
|
+
: "";
|
|
316
|
+
} catch {
|
|
317
|
+
// Use the returned output when its complete artifact is unavailable.
|
|
318
|
+
}
|
|
319
|
+
}
|
|
327
320
|
const interrupted =
|
|
328
321
|
script.context.signal?.aborted ||
|
|
329
|
-
(event.isError &&
|
|
330
|
-
event.content.some(
|
|
331
|
-
(block) =>
|
|
332
|
-
block.type === "text" &&
|
|
333
|
-
/^Script error:\nScript (?:aborted|timed out):/u.test(block.text),
|
|
334
|
-
));
|
|
322
|
+
(event.isError && /^Script error:\nScript (?:aborted|timed out):/u.test(executionError));
|
|
335
323
|
if (interrupted) script.cancellation.abort();
|
|
336
324
|
await script.tail;
|
|
337
325
|
if (interrupted) {
|
|
338
326
|
if (script.pending.entries.length > 0) {
|
|
339
327
|
const error = resultError(
|
|
340
|
-
"
|
|
328
|
+
"The operation was interrupted before writing. No file was changed.",
|
|
341
329
|
"CANCELLED",
|
|
342
330
|
);
|
|
343
331
|
const operations = script.pending.entries.map((entry) => ({
|
|
@@ -350,7 +338,7 @@ class NativeTextEditBatchCoordinator {
|
|
|
350
338
|
status: "error",
|
|
351
339
|
errors: [error],
|
|
352
340
|
data: {
|
|
353
|
-
operation: "
|
|
341
|
+
operation: "batch",
|
|
354
342
|
effect: "not-applied",
|
|
355
343
|
operations,
|
|
356
344
|
files: [...script.pending.snapshots.keys()].map((source) => ({
|
|
@@ -367,46 +355,85 @@ class NativeTextEditBatchCoordinator {
|
|
|
367
355
|
script.pending = pendingBatch();
|
|
368
356
|
}
|
|
369
357
|
} else await this.commit(script);
|
|
358
|
+
if (interrupted) {
|
|
359
|
+
for (const [id, source] of script.unfinishedCalls) {
|
|
360
|
+
if (
|
|
361
|
+
script.presentations.some((presentation) => presentation.calls.includes(id)) ||
|
|
362
|
+
script.reports.some((report) =>
|
|
363
|
+
report.data?.operations.some((operation) => operation.id === id),
|
|
364
|
+
)
|
|
365
|
+
)
|
|
366
|
+
continue;
|
|
367
|
+
// Cancellation is not a result. Do not guess whether a resolver already wrote.
|
|
368
|
+
const message =
|
|
369
|
+
"The operation was interrupted. Its file effects are unknown.\nRead the affected files before retrying.";
|
|
370
|
+
const presentation = new MutationPresentation({
|
|
371
|
+
ok: false,
|
|
372
|
+
path: source,
|
|
373
|
+
fileChangedStatement: message,
|
|
374
|
+
errors: [{ path: source, code: "CANCELLED" }],
|
|
375
|
+
});
|
|
376
|
+
const result: AgentToolResult<FileMutationBatchResult> = {
|
|
377
|
+
content: [new FileMutationAgentResult(presentation).toTextContent()],
|
|
378
|
+
details: { results: [presentation], effect: "unknown" },
|
|
379
|
+
isError: true,
|
|
380
|
+
};
|
|
381
|
+
script.results.push(presentation);
|
|
382
|
+
script.presentations.push({ parentToolCallId: script.id, calls: [id], result });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
370
385
|
try {
|
|
371
386
|
await this.core.enqueueFileOperation(
|
|
372
387
|
() =>
|
|
373
|
-
script.postEdits.finish(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
result
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
388
|
+
script.postEdits.finish(
|
|
389
|
+
(outcome) => {
|
|
390
|
+
const index = script.results.findLastIndex(
|
|
391
|
+
(item) => item.data.path === outcome.after.source,
|
|
392
|
+
);
|
|
393
|
+
if (index < 0) return;
|
|
394
|
+
const previous = requiredValue(script.results[index]).data;
|
|
395
|
+
const updated = new MutationPresentation({
|
|
396
|
+
...previous,
|
|
397
|
+
afterContent: outcome.after.content,
|
|
398
|
+
afterDocument: outcome.after,
|
|
399
|
+
formatting: outcome.postEditContributions
|
|
400
|
+
.map((item) => item.data)
|
|
401
|
+
.findLast(isFormattingContribution)?.formatting ?? { status: "not-reported" },
|
|
402
|
+
diffStatuses: outcome.postEditContributions
|
|
403
|
+
.map((item) => item.data)
|
|
404
|
+
.filter(isDiffStatusContribution)
|
|
405
|
+
.flatMap((item) => item.diffStatuses),
|
|
406
|
+
});
|
|
407
|
+
replaceScriptResult(script, requiredValue(script.results[index]), updated);
|
|
408
|
+
},
|
|
409
|
+
(source, error) => {
|
|
410
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
411
|
+
const failure = { code: "POST_EDIT_FAILED", message: reason, source };
|
|
412
|
+
for (const previous of script.results.filter(
|
|
413
|
+
(result) => result.data.path === source,
|
|
414
|
+
)) {
|
|
415
|
+
replaceScriptResult(
|
|
416
|
+
script,
|
|
417
|
+
previous,
|
|
418
|
+
new MutationPresentation({
|
|
419
|
+
ok: false,
|
|
420
|
+
path: source,
|
|
421
|
+
errors: [{ path: source, code: failure.code, reason }],
|
|
422
|
+
fileChangedStatement:
|
|
423
|
+
"The edit was saved, but final processing failed. Final text is not confirmed. Run Read/Search before editing this resource again.",
|
|
424
|
+
}),
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
for (const [index, report] of script.reports.entries()) {
|
|
428
|
+
if (!report.data?.files.some((file) => file.source === source)) continue;
|
|
429
|
+
script.reports[index] = {
|
|
430
|
+
...report,
|
|
431
|
+
status: report.status === "success" ? "partial" : report.status,
|
|
432
|
+
errors: [...report.errors, failure],
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
),
|
|
410
437
|
undefined,
|
|
411
438
|
{ cwd: script.context.cwd, sources: script.postEdits.sources() },
|
|
412
439
|
);
|
|
@@ -471,16 +498,23 @@ class NativeTextEditBatchCoordinator {
|
|
|
471
498
|
pi.on("session_shutdown", clear);
|
|
472
499
|
}
|
|
473
500
|
|
|
474
|
-
/**
|
|
475
|
-
runPostEdits<T>(id: string, work: () => T): T {
|
|
501
|
+
/** Share post-edit state while allowing Write to finish its own processing immediately. */
|
|
502
|
+
runPostEdits<T>(id: string, work: () => T, immediate: boolean): T {
|
|
476
503
|
const script = this.scopedInvocations.get(id);
|
|
477
|
-
return script ? script.postEdits.run(work) : work();
|
|
504
|
+
return script ? script.postEdits.run(work, immediate) : work();
|
|
478
505
|
}
|
|
479
506
|
|
|
480
|
-
/** Include non-batched mutations in the script's final post-edit presentation. */
|
|
507
|
+
/** Include applied, non-batched mutations in the script's final post-edit presentation. */
|
|
481
508
|
recordMutation(id: string, result: AgentToolResult<FileMutationBatchResult>): void {
|
|
482
509
|
const script = this.scopedInvocations.get(id);
|
|
483
|
-
if (
|
|
510
|
+
if (script && !script.closed) script.unfinishedCalls.delete(id);
|
|
511
|
+
if (
|
|
512
|
+
!script ||
|
|
513
|
+
script.closed ||
|
|
514
|
+
result.details.effect === "not-applied" ||
|
|
515
|
+
!result.details.results?.some((item) => item.data.ok === true)
|
|
516
|
+
)
|
|
517
|
+
return;
|
|
484
518
|
script.results.push(...result.details.results);
|
|
485
519
|
script.presentations.push({ parentToolCallId: script.id, calls: [id], result });
|
|
486
520
|
}
|
|
@@ -608,6 +642,13 @@ class NativeTextEditBatchCoordinator {
|
|
|
608
642
|
? this.resultTargets.reserve(context.cwd)
|
|
609
643
|
: undefined;
|
|
610
644
|
if (target) script.targets.set(id, target);
|
|
645
|
+
const unchangedCopy =
|
|
646
|
+
registration.name === "copy" &&
|
|
647
|
+
planning.plan.mutations.every(
|
|
648
|
+
({ mutation }) =>
|
|
649
|
+
mutation.edits.size > 0 &&
|
|
650
|
+
unchangedCopySources(mutation, batch.snapshots).size === mutation.edits.size,
|
|
651
|
+
);
|
|
611
652
|
const details = {
|
|
612
653
|
results: [],
|
|
613
654
|
source: entry.path,
|
|
@@ -619,7 +660,12 @@ class NativeTextEditBatchCoordinator {
|
|
|
619
660
|
content: [
|
|
620
661
|
{
|
|
621
662
|
type: "text",
|
|
622
|
-
text:
|
|
663
|
+
text:
|
|
664
|
+
registration.name === "copy"
|
|
665
|
+
? unchangedCopy
|
|
666
|
+
? "No changes: destination already has this text."
|
|
667
|
+
: `Copy destination: ${typeof normalized.target === "string" ? normalized.target : entry.path}`
|
|
668
|
+
: `Accepted ${registration.name} for ${entry.path}. Check the final Codemode result for applied changes.`,
|
|
623
669
|
},
|
|
624
670
|
],
|
|
625
671
|
details,
|
|
@@ -638,6 +684,7 @@ class NativeTextEditBatchCoordinator {
|
|
|
638
684
|
mapped = committedMutationTargets(
|
|
639
685
|
batch.plan.mutations.map(({ callId, mutation }) => ({ callId, edits: mutation.edits })),
|
|
640
686
|
completions,
|
|
687
|
+
batch.snapshots,
|
|
641
688
|
);
|
|
642
689
|
} catch (error) {
|
|
643
690
|
for (const entry of batch.entries) {
|
|
@@ -681,6 +728,17 @@ class NativeTextEditBatchCoordinator {
|
|
|
681
728
|
script.context.signal === undefined
|
|
682
729
|
? script.cancellation.signal
|
|
683
730
|
: AbortSignal.any([script.context.signal, script.cancellation.signal]);
|
|
731
|
+
const unchangedCopies = new Map(
|
|
732
|
+
batch.plan.mutations
|
|
733
|
+
.filter(({ mutation }) => mutation.operation === "copy")
|
|
734
|
+
.map(({ callId, mutation }) => {
|
|
735
|
+
const sources = unchangedCopySources(mutation, batch.snapshots);
|
|
736
|
+
return [
|
|
737
|
+
callId,
|
|
738
|
+
{ sources, all: sources.size > 0 && sources.size === mutation.edits.size },
|
|
739
|
+
] as const;
|
|
740
|
+
}),
|
|
741
|
+
);
|
|
684
742
|
let observedSources: string[] = [];
|
|
685
743
|
const record = (outcome: StructuredResult<MutationData>): boolean => {
|
|
686
744
|
const calls = journal.snapshot();
|
|
@@ -688,11 +746,13 @@ class NativeTextEditBatchCoordinator {
|
|
|
688
746
|
id: call.callId,
|
|
689
747
|
operation: requiredValue(batch.entries.find((entry) => entry.callId === call.callId)).op,
|
|
690
748
|
effect:
|
|
691
|
-
call.state === "completed"
|
|
692
|
-
? ("applied" as const)
|
|
693
|
-
: call.state === "
|
|
694
|
-
? ("
|
|
695
|
-
:
|
|
749
|
+
call.state === "completed" && unchangedCopies.get(call.callId)?.all
|
|
750
|
+
? ("not-applied" as const)
|
|
751
|
+
: call.state === "completed" || call.state === "failed-applied"
|
|
752
|
+
? ("applied" as const)
|
|
753
|
+
: call.state === "failed-unknown" || call.state === "running"
|
|
754
|
+
? ("unknown" as const)
|
|
755
|
+
: ("not-applied" as const),
|
|
696
756
|
errors: call.failure === undefined ? [] : [resultError(call.failure.error)],
|
|
697
757
|
}));
|
|
698
758
|
const files = mergedFiles([
|
|
@@ -705,7 +765,10 @@ class NativeTextEditBatchCoordinator {
|
|
|
705
765
|
return [...mutationSources(registration, entry).values()].map((source) => ({
|
|
706
766
|
source,
|
|
707
767
|
effect:
|
|
708
|
-
mutation?.edits.has(source) === false
|
|
768
|
+
mutation?.edits.has(source) === false ||
|
|
769
|
+
unchangedCopies.get(operation.id)?.sources.has(source) === true
|
|
770
|
+
? ("not-applied" as const)
|
|
771
|
+
: operation.effect,
|
|
709
772
|
}));
|
|
710
773
|
}),
|
|
711
774
|
...observedSources.map((source) => ({ source, effect: "applied" as const })),
|
|
@@ -727,7 +790,7 @@ class NativeTextEditBatchCoordinator {
|
|
|
727
790
|
errors,
|
|
728
791
|
data: {
|
|
729
792
|
...outcome.data,
|
|
730
|
-
operation: "
|
|
793
|
+
operation: "batch",
|
|
731
794
|
effect: receiptEffect(files),
|
|
732
795
|
files,
|
|
733
796
|
operations,
|
|
@@ -768,16 +831,36 @@ class NativeTextEditBatchCoordinator {
|
|
|
768
831
|
);
|
|
769
832
|
observedSources = captured.completions.map((completion) => completion.resourceSource);
|
|
770
833
|
if (captured.kind === "failed") throw captured.error;
|
|
771
|
-
|
|
834
|
+
const value =
|
|
835
|
+
captured.completions.length === 0 &&
|
|
836
|
+
journal
|
|
837
|
+
.snapshot()
|
|
838
|
+
.every((call) => call.state === "completed" && unchangedCopies.get(call.callId)?.all)
|
|
839
|
+
? {
|
|
840
|
+
...captured.value,
|
|
841
|
+
content: [
|
|
842
|
+
{ type: "text" as const, text: "No changes: destination already has this text." },
|
|
843
|
+
],
|
|
844
|
+
details: { ...captured.value.details, effect: "not-applied" as const },
|
|
845
|
+
}
|
|
846
|
+
: captured.value;
|
|
847
|
+
script.results.push(...(value.details.results ?? []));
|
|
772
848
|
await this.settleTargets(script, batch, journal, captured.completions, signal);
|
|
773
849
|
const presentation = {
|
|
774
850
|
parentToolCallId: script.id,
|
|
775
851
|
calls: batch.entries.map((entry) => entry.callId),
|
|
776
|
-
|
|
852
|
+
unchangedCopyCalls: journal
|
|
853
|
+
.snapshot()
|
|
854
|
+
.filter((call) => call.state === "completed" && unchangedCopies.get(call.callId)?.all)
|
|
855
|
+
.map((call) => call.callId),
|
|
856
|
+
...(value.details.copyResults === undefined
|
|
857
|
+
? {}
|
|
858
|
+
: { copyResults: value.details.copyResults }),
|
|
859
|
+
result: value,
|
|
777
860
|
} satisfies NativeEditBatchEvent;
|
|
778
861
|
script.presentations.push(presentation);
|
|
779
862
|
this.pi.events.emit(NATIVE_EDIT_BATCH_EVENT, presentation);
|
|
780
|
-
return record(mutationOutcome(
|
|
863
|
+
return record(mutationOutcome(value, "batch", captured.completions));
|
|
781
864
|
} catch (error) {
|
|
782
865
|
journal.markRunningUnknown(error);
|
|
783
866
|
await this.settleTargets(script, batch, journal, [], signal);
|
|
@@ -788,10 +871,15 @@ class NativeTextEditBatchCoordinator {
|
|
|
788
871
|
|
|
789
872
|
const coordinators = new WeakMap<TextEditorCore, NativeTextEditBatchCoordinator>();
|
|
790
873
|
|
|
791
|
-
/**
|
|
792
|
-
export function runNativePostEditScope<T>(
|
|
874
|
+
/** Share deferred post-edit state, or finish this operation's processing before return. */
|
|
875
|
+
export function runNativePostEditScope<T>(
|
|
876
|
+
core: TextEditorCore,
|
|
877
|
+
id: string,
|
|
878
|
+
work: () => T,
|
|
879
|
+
immediate = false,
|
|
880
|
+
): T {
|
|
793
881
|
const coordinator = coordinators.get(core);
|
|
794
|
-
return coordinator ? coordinator.runPostEdits(id, work) : work();
|
|
882
|
+
return coordinator ? coordinator.runPostEdits(id, work, immediate) : work();
|
|
795
883
|
}
|
|
796
884
|
|
|
797
885
|
/** Retain immediate child results so final formatting is visible on the parent script. */
|