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,10 +1,14 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { requiredValue } from "pi-agent-invariant";
|
|
2
3
|
import { ResourceScheduler, resourceAccesses } from "pi-agent-resource";
|
|
3
4
|
import type { TextResourceEditOutcome } from "./text-editor-core.js";
|
|
4
5
|
|
|
5
6
|
type Completed = Exclude<TextResourceEditOutcome<unknown>, { readonly kind: "failed" }>;
|
|
6
7
|
type Finalize = () => Promise<Completed>;
|
|
7
|
-
const active = new AsyncLocalStorage<
|
|
8
|
+
const active = new AsyncLocalStorage<{
|
|
9
|
+
readonly pending: Map<string, Finalize>;
|
|
10
|
+
readonly immediate: boolean;
|
|
11
|
+
}>();
|
|
8
12
|
const notifications = new AsyncLocalStorage<Array<() => void>>();
|
|
9
13
|
|
|
10
14
|
/** Schedule observers only after every file in the current finalization has settled. */
|
|
@@ -27,27 +31,32 @@ export async function collectPostEditNotifications<T>(work: () => Promise<T>): P
|
|
|
27
31
|
|
|
28
32
|
/** Replace intermediate post-processing with the latest written state of this resource. */
|
|
29
33
|
export function deferPostEdit(source: string, finalize: Finalize): boolean {
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
|
|
34
|
+
const scope = active.getStore();
|
|
35
|
+
if (!scope) return false;
|
|
36
|
+
if (scope.immediate) {
|
|
37
|
+
scope.pending.delete(source);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
scope.pending.set(source, finalize);
|
|
33
41
|
return true;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
/** Optional read enrichment must not start checks on an intermediate edited snapshot. */
|
|
37
45
|
export function hasDeferredPostEdit(source: string): boolean {
|
|
38
|
-
return active.getStore()?.has(source) ?? false;
|
|
46
|
+
return active.getStore()?.pending.has(source) ?? false;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
/** Stop deferred processing when a later operation removes or moves the resource. */
|
|
42
50
|
export function forgetDeferredPostEdit(source: string): void {
|
|
43
|
-
active.getStore()?.delete(source);
|
|
51
|
+
active.getStore()?.pending.delete(source);
|
|
44
52
|
}
|
|
45
53
|
/** Writes stay immediate; finishing drains each surviving final resource once. */
|
|
46
54
|
export function createPostEditScope(cwd = process.cwd()) {
|
|
47
55
|
const pending = new Map<string, Finalize>();
|
|
48
56
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
/** Immediate processing replaces older deferred work for the same written resource. */
|
|
58
|
+
run<T>(operation: () => T, immediate = false): T {
|
|
59
|
+
return active.run({ pending, immediate }, operation);
|
|
51
60
|
},
|
|
52
61
|
forget(source: string): void {
|
|
53
62
|
pending.delete(source);
|
|
@@ -56,7 +65,11 @@ export function createPostEditScope(cwd = process.cwd()) {
|
|
|
56
65
|
sources(): readonly string[] {
|
|
57
66
|
return [...pending.keys()];
|
|
58
67
|
},
|
|
59
|
-
|
|
68
|
+
/** Report each final resource outcome; a failed finalization does not undo its write. */
|
|
69
|
+
async finish(
|
|
70
|
+
onCompleted?: (outcome: Completed) => void,
|
|
71
|
+
onFailed?: (source: string, error: unknown) => void,
|
|
72
|
+
): Promise<Completed[]> {
|
|
60
73
|
const work = [...pending];
|
|
61
74
|
pending.clear();
|
|
62
75
|
const completed: Completed[] = [];
|
|
@@ -68,9 +81,15 @@ export function createPostEditScope(cwd = process.cwd()) {
|
|
|
68
81
|
scheduler.run(resourceAccesses(source, cwd, "write"), finalize),
|
|
69
82
|
),
|
|
70
83
|
);
|
|
71
|
-
for (const outcome of outcomes) {
|
|
84
|
+
for (const [index, outcome] of outcomes.entries()) {
|
|
85
|
+
const source = requiredValue(work[index])[0];
|
|
72
86
|
if (outcome.status === "rejected") {
|
|
73
87
|
errors.push(outcome.reason);
|
|
88
|
+
try {
|
|
89
|
+
onFailed?.(source, outcome.reason);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
errors.push(error);
|
|
92
|
+
}
|
|
74
93
|
continue;
|
|
75
94
|
}
|
|
76
95
|
completed.push(outcome.value);
|
|
@@ -78,6 +97,11 @@ export function createPostEditScope(cwd = process.cwd()) {
|
|
|
78
97
|
onCompleted?.(outcome.value);
|
|
79
98
|
} catch (error) {
|
|
80
99
|
errors.push(error);
|
|
100
|
+
try {
|
|
101
|
+
onFailed?.(source, error);
|
|
102
|
+
} catch (failure) {
|
|
103
|
+
errors.push(failure);
|
|
104
|
+
}
|
|
81
105
|
}
|
|
82
106
|
}
|
|
83
107
|
});
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import type { ResolvedResultTargets } from "pi-agent-resource";
|
|
2
2
|
import { TextChangeDocument } from "./text-change-engine.js";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const writePartialReason =
|
|
5
|
+
"Write received a partial file selection. Use replace to edit that selection, or Read the whole file before deliberately replacing all its contents.";
|
|
6
|
+
|
|
7
|
+
/** Require one complete file; name Write to provide its specific recovery instructions. */
|
|
8
|
+
export function wholeFileResultSource(
|
|
9
|
+
result: ResolvedResultTargets,
|
|
10
|
+
operation?: "write" | "undo",
|
|
11
|
+
): string {
|
|
6
12
|
const target = result.targets[0];
|
|
7
13
|
const range = target?.ranges[0];
|
|
8
|
-
if (result.targets.length !== 1 || target?.ranges.length !== 1 || range === undefined)
|
|
14
|
+
if (result.targets.length !== 1 || target?.ranges.length !== 1 || range === undefined) {
|
|
15
|
+
if (operation === "write") {
|
|
16
|
+
if (result.targets.length === 0)
|
|
17
|
+
throw new Error(
|
|
18
|
+
"Write received no file selection. Read the intended whole file before replacing it.",
|
|
19
|
+
);
|
|
20
|
+
if (result.targets.length > 1)
|
|
21
|
+
throw new Error(
|
|
22
|
+
"Write received multiple files. Choose one file and Read its whole contents before replacing it.",
|
|
23
|
+
);
|
|
24
|
+
throw new Error(writePartialReason);
|
|
25
|
+
}
|
|
9
26
|
throw new Error("This operation requires one whole-file result target.");
|
|
27
|
+
}
|
|
10
28
|
const document = new TextChangeDocument(target.expectedContent);
|
|
11
29
|
const selected = document.range(
|
|
12
30
|
range.start.lineNumber,
|
|
@@ -16,7 +34,9 @@ export function wholeFileResultSource(result: ResolvedResultTargets): string {
|
|
|
16
34
|
);
|
|
17
35
|
if (selected.from !== 0 || selected.to !== document.length)
|
|
18
36
|
throw new Error(
|
|
19
|
-
|
|
37
|
+
operation === "write"
|
|
38
|
+
? writePartialReason
|
|
39
|
+
: "This operation requires one whole-file result target; partial scopes are not widened.",
|
|
20
40
|
);
|
|
21
41
|
return target.source;
|
|
22
42
|
}
|
|
@@ -46,7 +46,7 @@ export async function prepareResultTransfer(
|
|
|
46
46
|
const selected = store.resolveOrdered(input[field], cwd);
|
|
47
47
|
if (!selected.complete)
|
|
48
48
|
throw new Error(
|
|
49
|
-
"Incomplete result targets cannot establish a complete transfer
|
|
49
|
+
"Incomplete result targets cannot establish a complete transfer. Run Search again with a higher limit or a narrower query, then use the complete result.",
|
|
50
50
|
);
|
|
51
51
|
await store.verify(selected, signal);
|
|
52
52
|
input[field] = store.register(selected.targets, cwd);
|
|
@@ -168,7 +168,12 @@ export async function prepareResultTransfer(
|
|
|
168
168
|
for (const span of sources)
|
|
169
169
|
append(span, { from: span.from, to: span.to, insert: "" }, false);
|
|
170
170
|
}
|
|
171
|
-
for (const transfer of planned)
|
|
171
|
+
for (const transfer of planned)
|
|
172
|
+
append(
|
|
173
|
+
transfer.target,
|
|
174
|
+
operation === "copy" ? { ...transfer.change, allowUnchanged: true } : transfer.change,
|
|
175
|
+
true,
|
|
176
|
+
);
|
|
172
177
|
return { edits };
|
|
173
178
|
},
|
|
174
179
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Type, type Static } from "typebox";
|
|
2
|
-
import { Value } from "typebox/value";
|
|
3
2
|
import {
|
|
4
|
-
MAX_STRUCTURED_BYTES,
|
|
5
3
|
resultError,
|
|
6
|
-
resultErrorSchema,
|
|
7
4
|
structuredResultSchema,
|
|
8
5
|
withStructuredResult,
|
|
9
6
|
type StructuredResult,
|
|
@@ -23,142 +20,56 @@ const file = Type.Object(
|
|
|
23
20
|
{
|
|
24
21
|
source: Type.String(),
|
|
25
22
|
effect,
|
|
26
|
-
action: Type.Optional(Type.String()),
|
|
27
23
|
state: Type.Optional(
|
|
28
24
|
Type.Union([Type.Literal("present"), Type.Literal("absent"), Type.Literal("unknown")]),
|
|
29
25
|
),
|
|
30
26
|
},
|
|
31
27
|
{ additionalProperties: false },
|
|
32
28
|
);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"Inclusive zero-based UTF-16 offset in the pre-edit snapshot; not a live selector.",
|
|
78
|
-
}),
|
|
79
|
-
to: Type.Integer({
|
|
80
|
-
description:
|
|
81
|
-
"Exclusive zero-based UTF-16 offset in the pre-edit snapshot; not a live selector.",
|
|
82
|
-
}),
|
|
83
|
-
removedText: Type.String(),
|
|
84
|
-
insertedText: Type.String(),
|
|
85
|
-
},
|
|
86
|
-
{ additionalProperties: false },
|
|
87
|
-
),
|
|
88
|
-
),
|
|
89
|
-
),
|
|
90
|
-
changesUnavailable: Type.Optional(
|
|
91
|
-
Type.String({
|
|
92
|
-
description: "Why the exact change record is omitted; applied effects remain reported.",
|
|
93
|
-
}),
|
|
94
|
-
),
|
|
95
|
-
operations: Type.Optional(Type.Array(operation)),
|
|
96
|
-
parentToolCallId: Type.Optional(Type.String()),
|
|
97
|
-
recovery: Type.Optional(
|
|
98
|
-
Type.Array(
|
|
99
|
-
Type.Object({
|
|
100
|
-
source: Type.String(),
|
|
101
|
-
field: Type.String(),
|
|
102
|
-
anchor: Type.String(),
|
|
103
|
-
total: Type.Integer(),
|
|
104
|
-
candidates: Type.Array(
|
|
105
|
-
Type.Object({
|
|
106
|
-
rank: Type.Integer(),
|
|
107
|
-
range: Type.Object({
|
|
108
|
-
start: Type.Object({ lineNumber: Type.Integer(), column: Type.Integer() }),
|
|
109
|
-
end: Type.Object({ lineNumber: Type.Integer(), column: Type.Integer() }),
|
|
110
|
-
}),
|
|
111
|
-
}),
|
|
112
|
-
),
|
|
113
|
-
}),
|
|
114
|
-
),
|
|
115
|
-
),
|
|
116
|
-
action: Type.Optional(
|
|
117
|
-
Type.Object(
|
|
118
|
-
{
|
|
119
|
-
source: Type.String(),
|
|
120
|
-
kind: Type.Optional(Type.String()),
|
|
121
|
-
status: Type.Optional(Type.String()),
|
|
122
|
-
command: Type.Optional(Type.String()),
|
|
123
|
-
deleted: Type.Optional(Type.Boolean()),
|
|
124
|
-
session: Type.Optional(Type.String()),
|
|
125
|
-
file: Type.Optional(Type.String()),
|
|
126
|
-
line: Type.Optional(Type.Integer()),
|
|
127
|
-
verified: Type.Optional(Type.Boolean()),
|
|
128
|
-
evaluation: Type.Optional(
|
|
129
|
-
Type.Object(
|
|
130
|
-
{
|
|
131
|
-
expression: Type.String(),
|
|
132
|
-
result: Type.String(),
|
|
133
|
-
type: Type.Optional(Type.String()),
|
|
134
|
-
variablesReference: Type.Integer(),
|
|
135
|
-
},
|
|
136
|
-
{ additionalProperties: false },
|
|
137
|
-
),
|
|
138
|
-
),
|
|
139
|
-
breakpoints: Type.Optional(
|
|
140
|
-
Type.Array(
|
|
141
|
-
Type.Object(
|
|
142
|
-
{
|
|
143
|
-
source: Type.String(),
|
|
144
|
-
file: Type.String(),
|
|
145
|
-
line: Type.Integer(),
|
|
146
|
-
verified: Type.Boolean(),
|
|
147
|
-
},
|
|
148
|
-
{ additionalProperties: false },
|
|
149
|
-
),
|
|
150
|
-
),
|
|
151
|
-
),
|
|
152
|
-
},
|
|
153
|
-
{ additionalProperties: false },
|
|
154
|
-
),
|
|
155
|
-
),
|
|
156
|
-
},
|
|
157
|
-
{ additionalProperties: false },
|
|
158
|
-
);
|
|
159
|
-
export const mutationOutputSchema = structuredResultSchema(mutationDataSchema);
|
|
160
|
-
/** Public receipt fields are defined by the native output schema. */
|
|
161
|
-
export type MutationData = Static<typeof mutationDataSchema>;
|
|
29
|
+
const receipt = { effect, files: Type.Array(file) };
|
|
30
|
+
|
|
31
|
+
/** Validate one file tool's result. Recovery, rendering and resource actions stay in details. */
|
|
32
|
+
export function mutationDataSchema(operation: string) {
|
|
33
|
+
return Type.Object(
|
|
34
|
+
{
|
|
35
|
+
operation: Type.Literal(operation),
|
|
36
|
+
...receipt,
|
|
37
|
+
operationId: Type.Optional(Type.String()),
|
|
38
|
+
...(operation === "delete"
|
|
39
|
+
? {}
|
|
40
|
+
: {
|
|
41
|
+
target: Type.Optional(Type.String()),
|
|
42
|
+
targetUnavailable: Type.Optional(Type.String()),
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
{ additionalProperties: false },
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
/** Internal validation schema for a single tool, not an agent-facing return declaration. */
|
|
49
|
+
export function mutationResultSchema(operation: string) {
|
|
50
|
+
return structuredResultSchema(mutationDataSchema(operation));
|
|
51
|
+
}
|
|
52
|
+
/** Observed file and operation effects retained on the parent native script. */
|
|
53
|
+
export interface BatchMutationData {
|
|
54
|
+
operation: "batch";
|
|
55
|
+
effect: MutationData["effect"];
|
|
56
|
+
files: MutationData["files"];
|
|
57
|
+
operations: {
|
|
58
|
+
id: string;
|
|
59
|
+
operation: string;
|
|
60
|
+
effect: MutationData["effect"];
|
|
61
|
+
errors: ResultError[];
|
|
62
|
+
}[];
|
|
63
|
+
}
|
|
64
|
+
/** Small internal receipt used to collect observed file effects. */
|
|
65
|
+
export interface MutationData {
|
|
66
|
+
operation: string;
|
|
67
|
+
effect: Static<typeof effect>;
|
|
68
|
+
files: Static<typeof file>[];
|
|
69
|
+
operationId?: string;
|
|
70
|
+
target?: string;
|
|
71
|
+
targetUnavailable?: string;
|
|
72
|
+
}
|
|
162
73
|
type MutationFile = MutationData["files"][number];
|
|
163
74
|
function record(value: unknown): value is Record<string, unknown> {
|
|
164
75
|
return typeof value === "object" && value !== null;
|
|
@@ -180,16 +91,13 @@ export function mutationOutcome(
|
|
|
180
91
|
data: {
|
|
181
92
|
operation,
|
|
182
93
|
effect: "pending",
|
|
183
|
-
...(typeof details.metadata?.resultTarget === "string"
|
|
94
|
+
...(operation !== "delete" && typeof details.metadata?.resultTarget === "string"
|
|
184
95
|
? { target: details.metadata.resultTarget }
|
|
185
96
|
: {}),
|
|
186
97
|
files:
|
|
187
98
|
typeof detailRecord.source === "string"
|
|
188
99
|
? [{ source: detailRecord.source, effect: "pending" }]
|
|
189
100
|
: [],
|
|
190
|
-
...(typeof native.parentToolCallId === "string"
|
|
191
|
-
? { parentToolCallId: native.parentToolCallId }
|
|
192
|
-
: {}),
|
|
193
101
|
},
|
|
194
102
|
};
|
|
195
103
|
const observed = new Set(completions.map((completion) => completion.resourceSource));
|
|
@@ -286,20 +194,6 @@ export function mutationOutcome(
|
|
|
286
194
|
const file = unique.find((file) => file.source === state.source);
|
|
287
195
|
if (file && (state.state === "present" || state.state === "absent")) file.state = state.state;
|
|
288
196
|
}
|
|
289
|
-
const changes = (results ?? [])
|
|
290
|
-
.filter((item) => item.data.ok)
|
|
291
|
-
.flatMap((item) => {
|
|
292
|
-
const source = item.data.path;
|
|
293
|
-
if (source === undefined) return [];
|
|
294
|
-
return (item.data.rawChanges ?? []).map((change) => ({
|
|
295
|
-
source,
|
|
296
|
-
from: change.fromA,
|
|
297
|
-
to: change.toA,
|
|
298
|
-
removedText: change.removedText,
|
|
299
|
-
insertedText: change.insertedText,
|
|
300
|
-
}));
|
|
301
|
-
});
|
|
302
|
-
const changesFit = Buffer.byteLength(JSON.stringify(changes)) <= MAX_STRUCTURED_BYTES / 2;
|
|
303
197
|
const known = unique.some((file) => file.effect === "applied");
|
|
304
198
|
if (result.isError && errors.length === 0)
|
|
305
199
|
errors.push({ code: "MUTATION_FAILED", message: "Mutation failed" });
|
|
@@ -312,52 +206,13 @@ export function mutationOutcome(
|
|
|
312
206
|
)
|
|
313
207
|
errors.push({ code: "UNKNOWN_RESULT", message: "Mutation effects were not reported" });
|
|
314
208
|
const effect =
|
|
209
|
+
details.effect === "unknown" ||
|
|
315
210
|
unique.some((file) => file.effect === "unknown") ||
|
|
316
211
|
errors.some((error) => error.code === "UNKNOWN_RESULT")
|
|
317
212
|
? "unknown"
|
|
318
213
|
: known
|
|
319
214
|
? "applied"
|
|
320
215
|
: "not-applied";
|
|
321
|
-
const action =
|
|
322
|
-
semantic && typeof semantic.source === "string"
|
|
323
|
-
? {
|
|
324
|
-
source: semantic.source,
|
|
325
|
-
...(typeof semantic.kind === "string" ? { kind: semantic.kind } : {}),
|
|
326
|
-
...(typeof semantic.status === "string" ? { status: semantic.status } : {}),
|
|
327
|
-
...(typeof semantic.command === "string" ? { command: semantic.command } : {}),
|
|
328
|
-
...(typeof semantic.deleted === "boolean" ? { deleted: semantic.deleted } : {}),
|
|
329
|
-
...(typeof semantic.session === "string" ? { session: semantic.session } : {}),
|
|
330
|
-
...(typeof semantic.file === "string" ? { file: semantic.file } : {}),
|
|
331
|
-
...(typeof semantic.line === "number" ? { line: semantic.line } : {}),
|
|
332
|
-
...(typeof semantic.verified === "boolean" ? { verified: semantic.verified } : {}),
|
|
333
|
-
...(record(semantic.evaluation)
|
|
334
|
-
? {
|
|
335
|
-
evaluation: {
|
|
336
|
-
expression: semantic.evaluation.expression,
|
|
337
|
-
result: semantic.evaluation.result,
|
|
338
|
-
variablesReference: semantic.evaluation.variablesReference,
|
|
339
|
-
...(typeof semantic.evaluation.type === "string"
|
|
340
|
-
? { type: semantic.evaluation.type }
|
|
341
|
-
: {}),
|
|
342
|
-
},
|
|
343
|
-
}
|
|
344
|
-
: {}),
|
|
345
|
-
...(Array.isArray(semantic.breakpoints)
|
|
346
|
-
? {
|
|
347
|
-
breakpoints: semantic.breakpoints.filter(record).map((breakpoint) => ({
|
|
348
|
-
source: breakpoint.source,
|
|
349
|
-
file: breakpoint.file,
|
|
350
|
-
line: breakpoint.line,
|
|
351
|
-
verified: breakpoint.verified,
|
|
352
|
-
})),
|
|
353
|
-
}
|
|
354
|
-
: {}),
|
|
355
|
-
}
|
|
356
|
-
: undefined;
|
|
357
|
-
const checkedAction =
|
|
358
|
-
action && Value.Check(mutationDataSchema.properties.action, action) ? action : undefined;
|
|
359
|
-
if (action && !checkedAction)
|
|
360
|
-
errors.push(resultError("Action adapter returned invalid fields", "INVALID_STRUCTURED_RESULT"));
|
|
361
216
|
return {
|
|
362
217
|
status:
|
|
363
218
|
errors.length === 0
|
|
@@ -369,32 +224,12 @@ export function mutationOutcome(
|
|
|
369
224
|
operation,
|
|
370
225
|
effect,
|
|
371
226
|
files: unique,
|
|
372
|
-
...(
|
|
373
|
-
? {}
|
|
374
|
-
: changesFit
|
|
375
|
-
? { changes }
|
|
376
|
-
: {
|
|
377
|
-
changesUnavailable:
|
|
378
|
-
"Exact change record exceeds the 512 KiB receipt budget; it was not clipped.",
|
|
379
|
-
}),
|
|
380
|
-
...(typeof details.metadata?.resultTarget === "string"
|
|
227
|
+
...(operation !== "delete" && typeof details.metadata?.resultTarget === "string"
|
|
381
228
|
? { target: details.metadata.resultTarget }
|
|
382
229
|
: {}),
|
|
383
|
-
...(typeof details.metadata?.targetUnavailable === "string"
|
|
230
|
+
...(operation !== "delete" && typeof details.metadata?.targetUnavailable === "string"
|
|
384
231
|
? { targetUnavailable: details.metadata.targetUnavailable }
|
|
385
232
|
: {}),
|
|
386
|
-
...(details.anchorRecoveries === undefined
|
|
387
|
-
? {}
|
|
388
|
-
: {
|
|
389
|
-
recovery: details.anchorRecoveries.map((item) => ({
|
|
390
|
-
source: item.path,
|
|
391
|
-
field: item.field,
|
|
392
|
-
anchor: item.anchor,
|
|
393
|
-
total: item.total,
|
|
394
|
-
candidates: [...item.candidates],
|
|
395
|
-
})),
|
|
396
|
-
}),
|
|
397
|
-
...(checkedAction ? { action: checkedAction } : {}),
|
|
398
233
|
},
|
|
399
234
|
errors,
|
|
400
235
|
};
|
|
@@ -408,5 +243,5 @@ export function structuredMutation(
|
|
|
408
243
|
) {
|
|
409
244
|
const outcome = mutationOutcome(result, operation, completions);
|
|
410
245
|
if (outcome.data && operationId !== undefined) outcome.data.operationId = operationId;
|
|
411
|
-
return withStructuredResult(result, mutationDataSchema, outcome);
|
|
246
|
+
return withStructuredResult(result, mutationDataSchema(operation), outcome);
|
|
412
247
|
}
|
|
@@ -8,6 +8,8 @@ export interface TextRange {
|
|
|
8
8
|
|
|
9
9
|
export interface TextChange extends TextRange {
|
|
10
10
|
readonly insert: string;
|
|
11
|
+
/** Copy may retain a destination range even when its text is already identical. */
|
|
12
|
+
readonly allowUnchanged?: true;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface AppliedTextChange {
|
|
@@ -220,7 +222,9 @@ export function applyTextChanges(
|
|
|
220
222
|
validateChanges(source.length, ordered);
|
|
221
223
|
if (
|
|
222
224
|
!(creating && source.length === 0) &&
|
|
223
|
-
ordered.some(
|
|
225
|
+
ordered.some(
|
|
226
|
+
(change) => !change.allowUnchanged && source.slice(change.from, change.to) === change.insert,
|
|
227
|
+
)
|
|
224
228
|
) {
|
|
225
229
|
throw new Error("Text changes must change the document.");
|
|
226
230
|
}
|