pi-agent-ide 0.6.4 → 0.7.1
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 +45 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-2TRHFMCZ.js +11 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-4GCWGE2C.js} +1 -1
- package/dist/chunk-4XMY4H4V.js +1 -0
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-76ZK5ODR.js} +2 -2
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-CWD4O5PM.js +3 -0
- package/dist/chunk-D3WTDA6V.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/chunk-GXEGY7GV.js +1 -0
- package/dist/chunk-HZEY4GT4.js +2 -0
- package/dist/chunk-LEEQIQ7D.js +28 -0
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OMVRLWMX.js +5 -0
- package/dist/{chunk-VBICI5YA.js → chunk-PGIVHICI.js} +1 -1
- package/dist/{chunk-FBOW7XOV.js → chunk-PKKDDIWW.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-VMTR74FF.js +2 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-WMO6RNE2.js} +1 -1
- package/dist/chunk-WU6ZK6YD.js +1 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/chunk-YP46DVVP.js +2 -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-30.js +1 -1
- package/dist/entry-31.js +12 -9
- package/dist/entry-33.js +1 -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 +13 -14
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +3 -6
- package/dist/entry-51.js +11 -9
- 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-61.js +0 -1
- package/dist/entry-62.js +1 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +0 -1
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +66 -1
- package/dist/entry-78.js +14 -325
- package/dist/entry-79.js +2 -18
- package/dist/entry-80.js +1 -2
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -1
- package/dist/entry-83.js +3 -5
- package/dist/entry-84.js +1 -3
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +14 -9
- package/docs/agent-guides/editing.md +38 -33
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +8 -4
- package/docs/agent-guides/search-code.md +34 -2
- package/docs/agent-guides/select-code.md +115 -0
- package/docs/configuration.md +12 -17
- package/docs/development.md +2 -1
- package/docs/releases.md +1 -1
- package/docs/research/apply-native-capability-matrix.md +174 -0
- package/docs/research/apply-read-latency.md +2 -0
- package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
- package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
- package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/research/native-codemode-batching.md +1 -1
- package/docs/structured-results.md +30 -38
- package/docs/tools.md +11 -11
- package/docs/user-hooks.md +1 -1
- 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-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 +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +10 -5
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +142 -27
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +268 -0
- package/node_modules/pi-agent-ide-changes/index.ts +6 -21
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- 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 +5 -5
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +92 -45
- 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 +40 -3
- package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +18 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +5 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +17 -3
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +10 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +407 -0
- 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 +208 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +28 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
- package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
- package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
- package/node_modules/pi-agent-search-text/index.ts +3 -1
- package/node_modules/pi-agent-search-text/package.json +7 -6
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
- 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/index.ts +0 -5
- package/node_modules/pi-agent-text-editor/package.json +26 -31
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +22 -5
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -14
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +217 -30
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +86 -154
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +238 -244
- 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 +9 -11
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
- package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
- package/node_modules/pi-agent-web/index.ts +7 -3
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web/src/search.ts +111 -2
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +35 -36
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/preferences.ts +0 -5
- package/src/composite/text-results.ts +221 -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-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 +7 -3
- 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-html/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
- 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 +40 -3
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +18 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +5 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +17 -3
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
- package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
- package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/index.ts +0 -5
- package/src/extensions/pi-agent-text-editor/package.json +26 -31
- 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/index.ts +1 -72
- 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-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +22 -5
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -14
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +217 -30
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +86 -154
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +238 -244
- 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 +9 -11
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +4 -7
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +10 -5
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +142 -27
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +268 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +6 -21
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -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 +5 -5
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +92 -45
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +31 -4
- package/dist/chunk-2P2OGO3G.js +0 -2
- package/dist/chunk-5J43L2RL.js +0 -11
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7AVXUV4A.js +0 -7
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-BAYETTZZ.js +0 -16
- package/dist/chunk-BVK5A7ED.js +0 -28
- package/dist/chunk-F7NVAC4Q.js +0 -0
- package/dist/chunk-FZBCKIJJ.js +0 -1
- package/dist/chunk-I5JLCFUX.js +0 -1
- package/dist/chunk-KUPHNMUK.js +0 -2
- package/dist/chunk-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- package/dist/chunk-SILJ3OL4.js +0 -9
- package/dist/chunk-TQZBVOTT.js +0 -5
- package/dist/chunk-VWW3RLUX.js +0 -12
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-ZODCBFBL.js +0 -2
- package/dist/entry-87.js +0 -1
- package/docs/agent-guides/apply.md +0 -333
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ResolvedResultTargets } from "pi-agent-resource";
|
|
2
|
+
import { TextChangeDocument } from "./text-change-engine.js";
|
|
3
|
+
|
|
4
|
+
/** Require a verified selection of one complete file before a whole-file operation. */
|
|
5
|
+
export function wholeFileResultSource(result: ResolvedResultTargets): string {
|
|
6
|
+
const target = result.targets[0];
|
|
7
|
+
const range = target?.ranges[0];
|
|
8
|
+
if (result.targets.length !== 1 || target?.ranges.length !== 1 || range === undefined)
|
|
9
|
+
throw new Error("This operation requires one whole-file result target.");
|
|
10
|
+
const document = new TextChangeDocument(target.expectedContent);
|
|
11
|
+
const selected = document.range(
|
|
12
|
+
range.start.lineNumber,
|
|
13
|
+
range.start.column,
|
|
14
|
+
range.end.lineNumber,
|
|
15
|
+
range.end.column,
|
|
16
|
+
);
|
|
17
|
+
if (selected.from !== 0 || selected.to !== document.length)
|
|
18
|
+
throw new Error(
|
|
19
|
+
"This operation requires one whole-file result target; partial scopes are not widened.",
|
|
20
|
+
);
|
|
21
|
+
return target.source;
|
|
22
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ResultTargetStore } from "pi-agent-resource";
|
|
2
|
+
import { TextSelectionAnchor } from "#src/api/text-selection-anchor.js";
|
|
3
|
+
import {
|
|
4
|
+
TEXT_SEARCH_ANCHOR_KIND,
|
|
5
|
+
type TextAnchorResolverRegistration,
|
|
6
|
+
} from "#src/api/plugin-protocol.js";
|
|
7
|
+
|
|
8
|
+
/** Resolve registered snapshot targets through the editor's normal source and anchor guards. */
|
|
9
|
+
export function createResultTargetAnchors(
|
|
10
|
+
store: ResultTargetStore,
|
|
11
|
+
): TextAnchorResolverRegistration {
|
|
12
|
+
return {
|
|
13
|
+
kind: TEXT_SEARCH_ANCHOR_KIND,
|
|
14
|
+
type: "auxiliary",
|
|
15
|
+
describeInPrompt: false,
|
|
16
|
+
resolver: {
|
|
17
|
+
id: "result-targets",
|
|
18
|
+
description: "Use returned RESULT# references to target exact source snapshots.",
|
|
19
|
+
renderFull: (value) => value,
|
|
20
|
+
renderCompact: () => "result targets",
|
|
21
|
+
async tryResolve(value, context) {
|
|
22
|
+
if (!value.startsWith("RESULT#")) return { kind: "not-handled" };
|
|
23
|
+
try {
|
|
24
|
+
const target = store
|
|
25
|
+
.resolve(value, context.cwd)
|
|
26
|
+
.targets.find((target) => target.source === context.source);
|
|
27
|
+
if (target === undefined)
|
|
28
|
+
return {
|
|
29
|
+
kind: "rejected",
|
|
30
|
+
rejection: { code: "missing", reason: "Result does not select this source." },
|
|
31
|
+
};
|
|
32
|
+
if (target.expectedContent !== context.content)
|
|
33
|
+
return {
|
|
34
|
+
kind: "rejected",
|
|
35
|
+
rejection: { code: "stale", reason: "Result target is stale; repeat Read/Search." },
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
kind: "resolved",
|
|
39
|
+
anchor: new TextSelectionAnchor(value, target.source, target.ranges),
|
|
40
|
+
};
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "rejected",
|
|
44
|
+
rejection: {
|
|
45
|
+
code: "invalid",
|
|
46
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
resources: {
|
|
53
|
+
id: "result-target-sources",
|
|
54
|
+
async tryResolve(value, context) {
|
|
55
|
+
if (!value.startsWith("RESULT#")) return { kind: "not-handled" };
|
|
56
|
+
try {
|
|
57
|
+
const selected = store.resolve(value, context.cwd);
|
|
58
|
+
await store.verify(selected, context.signal);
|
|
59
|
+
return selected.targets.length === 0
|
|
60
|
+
? {
|
|
61
|
+
kind: "rejected",
|
|
62
|
+
rejection: { code: "missing", reason: "Empty result target set." },
|
|
63
|
+
}
|
|
64
|
+
: { kind: "resolved", targets: selected.targets };
|
|
65
|
+
} catch (error) {
|
|
66
|
+
context.signal?.throwIfAborted();
|
|
67
|
+
return {
|
|
68
|
+
kind: "rejected",
|
|
69
|
+
rejection: {
|
|
70
|
+
code: "stale",
|
|
71
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { ResolvedResultTargets, ResultTargetStore } from "pi-agent-resource";
|
|
2
|
+
import type {
|
|
3
|
+
TextMutation,
|
|
4
|
+
TextMutationContext,
|
|
5
|
+
TextMutationEdit,
|
|
6
|
+
} from "#src/api/mutation-tool.js";
|
|
7
|
+
import type { TextChange } from "./text-change-engine.js";
|
|
8
|
+
import {
|
|
9
|
+
anchorSpanRange,
|
|
10
|
+
insertionAfterAnchor,
|
|
11
|
+
replaceAnchorSpan,
|
|
12
|
+
} from "#src/tools/text-selection.js";
|
|
13
|
+
import { wholeFileResultSource } from "./result-input.js";
|
|
14
|
+
|
|
15
|
+
/** Distinguish structured source authority from ordinary paths and legacy anchors. */
|
|
16
|
+
export function isResultInput(value: unknown): boolean {
|
|
17
|
+
return value !== undefined && (typeof value !== "string" || value.startsWith("RESULT#"));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface TransferSpan {
|
|
21
|
+
readonly source: string;
|
|
22
|
+
readonly from: number;
|
|
23
|
+
readonly to: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface PreparedTransfer {
|
|
27
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
28
|
+
readonly empty: boolean;
|
|
29
|
+
readonly verifyFileSource?: () => Promise<void>;
|
|
30
|
+
readonly mutate?: (context: TextMutationContext) => Promise<TextMutation>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Resolve ordered pairs once; execute them inside the editor's existing guarded snapshots. */
|
|
34
|
+
export async function prepareResultTransfer(
|
|
35
|
+
operation: "copy" | "move",
|
|
36
|
+
parameters: Readonly<Record<string, unknown>>,
|
|
37
|
+
store: ResultTargetStore,
|
|
38
|
+
cwd: string,
|
|
39
|
+
signal?: AbortSignal,
|
|
40
|
+
): Promise<PreparedTransfer> {
|
|
41
|
+
const input = { ...parameters };
|
|
42
|
+
const resolve = async (field: "path" | "target", start: string, end: string) => {
|
|
43
|
+
if (!isResultInput(input[field])) return undefined;
|
|
44
|
+
if (input[start] !== undefined || input[end] !== undefined)
|
|
45
|
+
throw new Error(`Do not combine structured ${field} with ${start}/${end}.`);
|
|
46
|
+
const selected = store.resolveOrdered(input[field], cwd);
|
|
47
|
+
if (!selected.complete)
|
|
48
|
+
throw new Error(
|
|
49
|
+
"Incomplete result targets cannot establish a complete transfer; repeat Search.",
|
|
50
|
+
);
|
|
51
|
+
await store.verify(selected, signal);
|
|
52
|
+
input[field] = store.register(selected.targets, cwd);
|
|
53
|
+
return selected;
|
|
54
|
+
};
|
|
55
|
+
const source = await resolve("path", "start", "end");
|
|
56
|
+
const destination = await resolve("target", "targetStart", "targetEnd");
|
|
57
|
+
if (source === undefined && destination === undefined) return { input, empty: false };
|
|
58
|
+
if (
|
|
59
|
+
source !== undefined &&
|
|
60
|
+
destination === undefined &&
|
|
61
|
+
input.targetStart === undefined &&
|
|
62
|
+
input.targetEnd === undefined
|
|
63
|
+
) {
|
|
64
|
+
// A structured source may use the byte-preserving file operation only when it really selects a whole file.
|
|
65
|
+
input.path = wholeFileResultSource(store.resolve(parameters.path, cwd));
|
|
66
|
+
return { input, empty: false, verifyFileSource: () => store.verify(source, signal) };
|
|
67
|
+
}
|
|
68
|
+
if (
|
|
69
|
+
source !== undefined &&
|
|
70
|
+
destination !== undefined &&
|
|
71
|
+
source.targets.length !== destination.targets.length
|
|
72
|
+
)
|
|
73
|
+
throw new Error(
|
|
74
|
+
"Transfer source and destination selection counts must match; no broadcast or concatenation.",
|
|
75
|
+
);
|
|
76
|
+
const empty = source?.targets.length === 0 || destination?.targets.length === 0;
|
|
77
|
+
return {
|
|
78
|
+
input,
|
|
79
|
+
empty,
|
|
80
|
+
async mutate(context) {
|
|
81
|
+
const spans = (selected: ResolvedResultTargets): TransferSpan[] =>
|
|
82
|
+
selected.targets.map((target) => {
|
|
83
|
+
const document = context.documentFor(target.source);
|
|
84
|
+
if (document.content !== target.expectedContent)
|
|
85
|
+
throw new Error("Transfer result target is stale; repeat Read/Search.");
|
|
86
|
+
const range = target.ranges[0];
|
|
87
|
+
if (range === undefined) throw new Error("Transfer selection has no range.");
|
|
88
|
+
return {
|
|
89
|
+
source: target.source,
|
|
90
|
+
...document.range(
|
|
91
|
+
range.start.lineNumber,
|
|
92
|
+
range.start.column,
|
|
93
|
+
range.end.lineNumber,
|
|
94
|
+
range.end.column,
|
|
95
|
+
),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
const sources =
|
|
99
|
+
source === undefined
|
|
100
|
+
? [
|
|
101
|
+
input.start === undefined
|
|
102
|
+
? { source: context.sourceFor("path"), from: 0, to: context.sourceDocument.length }
|
|
103
|
+
: anchorSpanRange(
|
|
104
|
+
context,
|
|
105
|
+
await context.resolveAnchors("start"),
|
|
106
|
+
input.end === undefined ? undefined : await context.resolveAnchors("end"),
|
|
107
|
+
"start",
|
|
108
|
+
"end",
|
|
109
|
+
),
|
|
110
|
+
]
|
|
111
|
+
: spans(source);
|
|
112
|
+
const destinations = destination === undefined ? undefined : spans(destination);
|
|
113
|
+
if (sources.length !== (destinations?.length ?? 1))
|
|
114
|
+
throw new Error(
|
|
115
|
+
"Transfer source and destination selection counts must match; no broadcast or concatenation.",
|
|
116
|
+
);
|
|
117
|
+
const edits = new Map<string, TextMutationEdit>();
|
|
118
|
+
const append = (span: TransferSpan, change: TextChange, producesTarget: boolean) => {
|
|
119
|
+
const edit = edits.get(span.source);
|
|
120
|
+
const changes = [...(edit?.changes ?? []), change];
|
|
121
|
+
const resultChanges = [
|
|
122
|
+
...(edit?.resultChanges ?? []),
|
|
123
|
+
...(producesTarget ? [changes.length - 1] : []),
|
|
124
|
+
];
|
|
125
|
+
edits.set(span.source, { action: "edited", changes, resultChanges });
|
|
126
|
+
};
|
|
127
|
+
const planned: { target: TransferSpan; change: TextChange }[] = [];
|
|
128
|
+
for (const [index, span] of sources.entries()) {
|
|
129
|
+
const copied = context.documentFor(span.source).text(span);
|
|
130
|
+
const destinationSpan = destinations?.[index];
|
|
131
|
+
if (destinationSpan !== undefined) {
|
|
132
|
+
planned.push({
|
|
133
|
+
target: destinationSpan,
|
|
134
|
+
change: { from: destinationSpan.from, to: destinationSpan.to, insert: copied },
|
|
135
|
+
});
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const starts = await context.resolveAnchors("targetStart");
|
|
139
|
+
if (input.targetEnd === undefined) {
|
|
140
|
+
const [target, change] = insertionAfterAnchor(context, starts, "targetStart", copied);
|
|
141
|
+
planned.push({
|
|
142
|
+
target: { source: target, from: change.from, to: change.to },
|
|
143
|
+
change,
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
const target = anchorSpanRange(
|
|
147
|
+
context,
|
|
148
|
+
starts,
|
|
149
|
+
await context.resolveAnchors("targetEnd"),
|
|
150
|
+
"targetStart",
|
|
151
|
+
"targetEnd",
|
|
152
|
+
);
|
|
153
|
+
planned.push({
|
|
154
|
+
target,
|
|
155
|
+
change: replaceAnchorSpan(context, target, copied),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (operation === "move") {
|
|
160
|
+
for (const sourceSpan of sources)
|
|
161
|
+
for (const transfer of planned)
|
|
162
|
+
if (
|
|
163
|
+
sourceSpan.source === transfer.target.source &&
|
|
164
|
+
sourceSpan.from <= transfer.target.to &&
|
|
165
|
+
transfer.target.from <= sourceSpan.to
|
|
166
|
+
)
|
|
167
|
+
throw new Error("Move target must not overlap or touch any source range.");
|
|
168
|
+
for (const span of sources)
|
|
169
|
+
append(span, { from: span.from, to: span.to, insert: "" }, false);
|
|
170
|
+
}
|
|
171
|
+
for (const transfer of planned) append(transfer.target, transfer.change, true);
|
|
172
|
+
return { edits };
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Type, type Static } from "typebox";
|
|
2
|
-
import { Value } from "typebox/value";
|
|
3
2
|
import {
|
|
4
3
|
resultError,
|
|
5
4
|
resultErrorSchema,
|
|
@@ -19,103 +18,58 @@ const effect = Type.Union([
|
|
|
19
18
|
Type.Literal("unknown"),
|
|
20
19
|
]);
|
|
21
20
|
const file = Type.Object(
|
|
22
|
-
{ source: Type.String(), effect, action: Type.Optional(Type.String()) },
|
|
23
|
-
{ additionalProperties: false },
|
|
24
|
-
);
|
|
25
|
-
const operation = Type.Object(
|
|
26
21
|
{
|
|
27
|
-
|
|
28
|
-
operation: Type.String(),
|
|
22
|
+
source: Type.String(),
|
|
29
23
|
effect,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Type.Union([
|
|
33
|
-
Type.Literal("success"),
|
|
34
|
-
Type.Literal("error"),
|
|
35
|
-
Type.Literal("warning"),
|
|
36
|
-
Type.Literal("unknown"),
|
|
37
|
-
]),
|
|
24
|
+
state: Type.Optional(
|
|
25
|
+
Type.Union([Type.Literal("present"), Type.Literal("absent"), Type.Literal("unknown")]),
|
|
38
26
|
),
|
|
39
|
-
sources: Type.Optional(Type.Array(Type.String())),
|
|
40
|
-
warnings: Type.Optional(Type.Array(resultErrorSchema)),
|
|
41
27
|
},
|
|
42
28
|
{ additionalProperties: false },
|
|
43
29
|
);
|
|
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
|
-
Type.Object(
|
|
75
|
-
{
|
|
76
|
-
source: Type.String(),
|
|
77
|
-
kind: Type.Optional(Type.String()),
|
|
78
|
-
status: Type.Optional(Type.String()),
|
|
79
|
-
command: Type.Optional(Type.String()),
|
|
80
|
-
deleted: Type.Optional(Type.Boolean()),
|
|
81
|
-
session: Type.Optional(Type.String()),
|
|
82
|
-
file: Type.Optional(Type.String()),
|
|
83
|
-
line: Type.Optional(Type.Integer()),
|
|
84
|
-
verified: Type.Optional(Type.Boolean()),
|
|
85
|
-
evaluation: Type.Optional(
|
|
86
|
-
Type.Object(
|
|
87
|
-
{
|
|
88
|
-
expression: Type.String(),
|
|
89
|
-
result: Type.String(),
|
|
90
|
-
type: Type.Optional(Type.String()),
|
|
91
|
-
variablesReference: Type.Integer(),
|
|
92
|
-
},
|
|
93
|
-
{ additionalProperties: false },
|
|
94
|
-
),
|
|
95
|
-
),
|
|
96
|
-
breakpoints: Type.Optional(
|
|
97
|
-
Type.Array(
|
|
98
|
-
Type.Object(
|
|
99
|
-
{
|
|
100
|
-
source: Type.String(),
|
|
101
|
-
file: Type.String(),
|
|
102
|
-
line: Type.Integer(),
|
|
103
|
-
verified: Type.Boolean(),
|
|
104
|
-
},
|
|
105
|
-
{ additionalProperties: false },
|
|
106
|
-
),
|
|
107
|
-
),
|
|
108
|
-
),
|
|
109
|
-
},
|
|
110
|
-
{ additionalProperties: false },
|
|
111
|
-
),
|
|
112
|
-
),
|
|
113
|
-
},
|
|
30
|
+
const receipt = { effect, files: Type.Array(file) };
|
|
31
|
+
|
|
32
|
+
/** Validate one file tool's result. Recovery, rendering and resource actions stay in details. */
|
|
33
|
+
export function mutationDataSchema(operation: string) {
|
|
34
|
+
return Type.Object(
|
|
35
|
+
{
|
|
36
|
+
operation: Type.Literal(operation),
|
|
37
|
+
...receipt,
|
|
38
|
+
operationId: Type.Optional(Type.String()),
|
|
39
|
+
...(operation === "delete" || operation === "flush"
|
|
40
|
+
? {}
|
|
41
|
+
: {
|
|
42
|
+
target: Type.Optional(Type.String()),
|
|
43
|
+
targetUnavailable: Type.Optional(Type.String()),
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
{ additionalProperties: false },
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
/** Internal validation schema for a single tool, not an agent-facing return declaration. */
|
|
50
|
+
export function mutationResultSchema(operation: string) {
|
|
51
|
+
return structuredResultSchema(mutationDataSchema(operation));
|
|
52
|
+
}
|
|
53
|
+
const batchOperation = Type.Object(
|
|
54
|
+
{ id: Type.String(), operation: Type.String(), effect, errors: Type.Array(resultErrorSchema) },
|
|
55
|
+
{ additionalProperties: false },
|
|
56
|
+
);
|
|
57
|
+
/** Flush owns the batch journal; individual file tools do not carry it. */
|
|
58
|
+
export const flushDataSchema = Type.Object(
|
|
59
|
+
{ operation: Type.Literal("flush"), ...receipt, operations: Type.Array(batchOperation) },
|
|
114
60
|
{ additionalProperties: false },
|
|
115
61
|
);
|
|
116
|
-
export const
|
|
117
|
-
|
|
118
|
-
|
|
62
|
+
export const flushOutputSchema = structuredResultSchema(flushDataSchema);
|
|
63
|
+
export type FlushData = Static<typeof flushDataSchema>;
|
|
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
|
+
}
|
|
119
73
|
type MutationFile = MutationData["files"][number];
|
|
120
74
|
function record(value: unknown): value is Record<string, unknown> {
|
|
121
75
|
return typeof value === "object" && value !== null;
|
|
@@ -137,13 +91,13 @@ export function mutationOutcome(
|
|
|
137
91
|
data: {
|
|
138
92
|
operation,
|
|
139
93
|
effect: "pending",
|
|
94
|
+
...(operation !== "delete" && typeof details.metadata?.resultTarget === "string"
|
|
95
|
+
? { target: details.metadata.resultTarget }
|
|
96
|
+
: {}),
|
|
140
97
|
files:
|
|
141
98
|
typeof detailRecord.source === "string"
|
|
142
99
|
? [{ source: detailRecord.source, effect: "pending" }]
|
|
143
100
|
: [],
|
|
144
|
-
...(typeof native.parentToolCallId === "string"
|
|
145
|
-
? { parentToolCallId: native.parentToolCallId }
|
|
146
|
-
: {}),
|
|
147
101
|
},
|
|
148
102
|
};
|
|
149
103
|
const observed = new Set(completions.map((completion) => completion.resourceSource));
|
|
@@ -161,6 +115,7 @@ export function mutationOutcome(
|
|
|
161
115
|
for (const source of sources)
|
|
162
116
|
files.push({
|
|
163
117
|
source,
|
|
118
|
+
...(observed.has(source) ? { state: "present" as const } : {}),
|
|
164
119
|
effect:
|
|
165
120
|
observed.has(source) ||
|
|
166
121
|
(data.ok === true && data.files?.some((file) => file.path === source))
|
|
@@ -181,7 +136,8 @@ export function mutationOutcome(
|
|
|
181
136
|
});
|
|
182
137
|
}
|
|
183
138
|
for (const source of observed)
|
|
184
|
-
if (!files.some((file) => file.source === source))
|
|
139
|
+
if (!files.some((file) => file.source === source))
|
|
140
|
+
files.push({ source, effect: "applied", state: "present" });
|
|
185
141
|
const semantic =
|
|
186
142
|
record(details.metadata) && record(details.metadata.semanticAction)
|
|
187
143
|
? details.metadata.semanticAction
|
|
@@ -194,19 +150,30 @@ export function mutationOutcome(
|
|
|
194
150
|
? "unknown"
|
|
195
151
|
: "applied";
|
|
196
152
|
const source = typeof semantic.source === "string" ? semantic.source : undefined;
|
|
197
|
-
if (source
|
|
153
|
+
if (source)
|
|
198
154
|
files.push({
|
|
199
155
|
source,
|
|
156
|
+
...(semantic.kind === "file-operation" && semantic.ok === true
|
|
157
|
+
? {
|
|
158
|
+
state:
|
|
159
|
+
operation === "delete" || operation === "move"
|
|
160
|
+
? ("absent" as const)
|
|
161
|
+
: ("present" as const),
|
|
162
|
+
}
|
|
163
|
+
: {}),
|
|
200
164
|
effect:
|
|
201
165
|
operation === "copy" && typeof semantic.target === "string" && semantic.target !== source
|
|
202
166
|
? "not-applied"
|
|
203
167
|
: semanticEffect,
|
|
204
168
|
});
|
|
205
|
-
if (Array.isArray(semantic.restored))
|
|
206
|
-
for (const source of semantic.restored)
|
|
207
|
-
if (typeof source === "string") files.push({ source, effect: semanticEffect });
|
|
208
169
|
if (typeof semantic.target === "string")
|
|
209
|
-
files.push({
|
|
170
|
+
files.push({
|
|
171
|
+
source: semantic.target,
|
|
172
|
+
effect: semanticEffect,
|
|
173
|
+
...(semantic.kind === "file-operation" && semantic.ok === true
|
|
174
|
+
? { state: "present" as const }
|
|
175
|
+
: {}),
|
|
176
|
+
});
|
|
210
177
|
if (record(semantic.error))
|
|
211
178
|
errors.push(
|
|
212
179
|
resultError(
|
|
@@ -221,10 +188,22 @@ export function mutationOutcome(
|
|
|
221
188
|
errors.push(resultError("Resource operation failed", "MUTATION_FAILED", source));
|
|
222
189
|
}
|
|
223
190
|
const unique = [...new Map(files.map((file) => [file.source, file])).values()];
|
|
191
|
+
if (Array.isArray(details.metadata?.resultFileStates))
|
|
192
|
+
for (const state of details.metadata.resultFileStates) {
|
|
193
|
+
if (!record(state)) continue;
|
|
194
|
+
const file = unique.find((file) => file.source === state.source);
|
|
195
|
+
if (file && (state.state === "present" || state.state === "absent")) file.state = state.state;
|
|
196
|
+
}
|
|
224
197
|
const known = unique.some((file) => file.effect === "applied");
|
|
225
198
|
if (result.isError && errors.length === 0)
|
|
226
199
|
errors.push({ code: "MUTATION_FAILED", message: "Mutation failed" });
|
|
227
|
-
if (
|
|
200
|
+
if (
|
|
201
|
+
(results?.length ?? 0) === 0 &&
|
|
202
|
+
!semantic &&
|
|
203
|
+
observed.size === 0 &&
|
|
204
|
+
errors.length === 0 &&
|
|
205
|
+
details.effect !== "not-applied"
|
|
206
|
+
)
|
|
228
207
|
errors.push({ code: "UNKNOWN_RESULT", message: "Mutation effects were not reported" });
|
|
229
208
|
const effect =
|
|
230
209
|
unique.some((file) => file.effect === "unknown") ||
|
|
@@ -233,46 +212,6 @@ export function mutationOutcome(
|
|
|
233
212
|
: known
|
|
234
213
|
? "applied"
|
|
235
214
|
: "not-applied";
|
|
236
|
-
const action =
|
|
237
|
-
semantic && typeof semantic.source === "string"
|
|
238
|
-
? {
|
|
239
|
-
source: semantic.source,
|
|
240
|
-
...(typeof semantic.kind === "string" ? { kind: semantic.kind } : {}),
|
|
241
|
-
...(typeof semantic.status === "string" ? { status: semantic.status } : {}),
|
|
242
|
-
...(typeof semantic.command === "string" ? { command: semantic.command } : {}),
|
|
243
|
-
...(typeof semantic.deleted === "boolean" ? { deleted: semantic.deleted } : {}),
|
|
244
|
-
...(typeof semantic.session === "string" ? { session: semantic.session } : {}),
|
|
245
|
-
...(typeof semantic.file === "string" ? { file: semantic.file } : {}),
|
|
246
|
-
...(typeof semantic.line === "number" ? { line: semantic.line } : {}),
|
|
247
|
-
...(typeof semantic.verified === "boolean" ? { verified: semantic.verified } : {}),
|
|
248
|
-
...(record(semantic.evaluation)
|
|
249
|
-
? {
|
|
250
|
-
evaluation: {
|
|
251
|
-
expression: semantic.evaluation.expression,
|
|
252
|
-
result: semantic.evaluation.result,
|
|
253
|
-
variablesReference: semantic.evaluation.variablesReference,
|
|
254
|
-
...(typeof semantic.evaluation.type === "string"
|
|
255
|
-
? { type: semantic.evaluation.type }
|
|
256
|
-
: {}),
|
|
257
|
-
},
|
|
258
|
-
}
|
|
259
|
-
: {}),
|
|
260
|
-
...(Array.isArray(semantic.breakpoints)
|
|
261
|
-
? {
|
|
262
|
-
breakpoints: semantic.breakpoints.filter(record).map((breakpoint) => ({
|
|
263
|
-
source: breakpoint.source,
|
|
264
|
-
file: breakpoint.file,
|
|
265
|
-
line: breakpoint.line,
|
|
266
|
-
verified: breakpoint.verified,
|
|
267
|
-
})),
|
|
268
|
-
}
|
|
269
|
-
: {}),
|
|
270
|
-
}
|
|
271
|
-
: undefined;
|
|
272
|
-
const checkedAction =
|
|
273
|
-
action && Value.Check(mutationDataSchema.properties.action, action) ? action : undefined;
|
|
274
|
-
if (action && !checkedAction)
|
|
275
|
-
errors.push(resultError("Action adapter returned invalid fields", "INVALID_STRUCTURED_RESULT"));
|
|
276
215
|
return {
|
|
277
216
|
status:
|
|
278
217
|
errors.length === 0
|
|
@@ -284,19 +223,12 @@ export function mutationOutcome(
|
|
|
284
223
|
operation,
|
|
285
224
|
effect,
|
|
286
225
|
files: unique,
|
|
287
|
-
...(details.
|
|
288
|
-
? {}
|
|
289
|
-
: {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
anchor: item.anchor,
|
|
294
|
-
total: item.total,
|
|
295
|
-
candidates: [...item.candidates],
|
|
296
|
-
})),
|
|
297
|
-
}),
|
|
298
|
-
...(typeof semantic?.transaction === "string" ? { transaction: semantic.transaction } : {}),
|
|
299
|
-
...(checkedAction ? { action: checkedAction } : {}),
|
|
226
|
+
...(operation !== "delete" && typeof details.metadata?.resultTarget === "string"
|
|
227
|
+
? { target: details.metadata.resultTarget }
|
|
228
|
+
: {}),
|
|
229
|
+
...(operation !== "delete" && typeof details.metadata?.targetUnavailable === "string"
|
|
230
|
+
? { targetUnavailable: details.metadata.targetUnavailable }
|
|
231
|
+
: {}),
|
|
300
232
|
},
|
|
301
233
|
errors,
|
|
302
234
|
};
|
|
@@ -310,5 +242,5 @@ export function structuredMutation(
|
|
|
310
242
|
) {
|
|
311
243
|
const outcome = mutationOutcome(result, operation, completions);
|
|
312
244
|
if (outcome.data && operationId !== undefined) outcome.data.operationId = operationId;
|
|
313
|
-
return withStructuredResult(result, mutationDataSchema, outcome);
|
|
245
|
+
return withStructuredResult(result, mutationDataSchema(operation), outcome);
|
|
314
246
|
}
|
|
@@ -418,7 +418,12 @@ export async function executeRegisteredTextBatch(
|
|
|
418
418
|
return [];
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
|
|
421
|
+
// The core already validated the write; a created empty resource has no text delta.
|
|
422
|
+
const ownAfter = applyTextChanges(
|
|
423
|
+
resource.before.content,
|
|
424
|
+
edit.changes,
|
|
425
|
+
resource.before.content.length === 0,
|
|
426
|
+
).content;
|
|
422
427
|
return [
|
|
423
428
|
buildSuccessfulTextMutationResult(
|
|
424
429
|
resource,
|