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
|
@@ -2,7 +2,6 @@ import { requiredValue } from "pi-agent-invariant";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import type { TextEditCompletion } from "#src/api/edit-completion.js";
|
|
5
|
-
import { Value } from "typebox/value";
|
|
6
5
|
import type {
|
|
7
6
|
TextAnchorRecoveryCandidateRange,
|
|
8
7
|
TextAnchorRecoveryRange,
|
|
@@ -47,7 +46,15 @@ import { readTextAnchorRecovery } from "#src/core/text-anchor-recovery.js";
|
|
|
47
46
|
import { applyTextChanges, TextChangeDocument } from "#src/core/text-change-engine.js";
|
|
48
47
|
import { resolvedTextAnchorType } from "#src/core/text-anchor-registry.js";
|
|
49
48
|
import { executeTextToolWithBatch } from "#src/core/text-edit-batch-registrar.js";
|
|
50
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
executeNativeTextEditBatch,
|
|
51
|
+
runNativePostEditScope,
|
|
52
|
+
recordNativeTextMutation,
|
|
53
|
+
} from "#src/core/native-text-edit-batch.js";
|
|
54
|
+
import { attachCommittedMutationTarget } from "./mutation-result-targets.js";
|
|
55
|
+
import { wholeFileResultSource } from "./result-input.js";
|
|
56
|
+
import { TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
|
|
57
|
+
import { isResultInput, prepareResultTransfer } from "./result-transfer.js";
|
|
51
58
|
import {
|
|
52
59
|
contextualizeTextMutationAnchorError,
|
|
53
60
|
TextMutationAnchorAggregateError,
|
|
@@ -75,16 +82,17 @@ import { renderTextAnchor, type TextAnchor } from "pi-agent-text";
|
|
|
75
82
|
import { TextSelectionAnchor } from "#src/api/text-selection-anchor.js";
|
|
76
83
|
import type { ToolCallAnchorRenderState } from "pi-agent-tool-call-interception";
|
|
77
84
|
import type { Static, TSchema } from "typebox";
|
|
78
|
-
import type { ScriptMutationOutcome } from "#src/core/apply/mutation-outcome.js";
|
|
79
85
|
import { executeWholeFileTool, isWholeFileInvocation } from "#src/core/file-operation-tools.js";
|
|
80
86
|
import { EDITING_GUIDELINES } from "#src/core/editing-guidelines.js";
|
|
81
|
-
import {
|
|
87
|
+
import { mutationResultSchema, structuredMutation } from "./structured-result.js";
|
|
88
|
+
import type { ResultTargetStore } from "pi-agent-resource";
|
|
82
89
|
|
|
83
90
|
export function createTextTool<TParameters extends TSchema>(
|
|
84
91
|
core: TextEditorCore,
|
|
85
92
|
definition: TextMutationToolRegistration<TParameters>,
|
|
86
93
|
annotations: ToolCallInterceptionRenderStore,
|
|
87
94
|
getLastResolvedSource: () => string | undefined,
|
|
95
|
+
resultTargets?: ResultTargetStore,
|
|
88
96
|
): ToolDefinition<TParameters, FileMutationBatchResult> {
|
|
89
97
|
const renderer = core.getToolRenderer(definition.name);
|
|
90
98
|
const initialRenderCall = renderer?.renderCall;
|
|
@@ -110,7 +118,7 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
110
118
|
promptGuidelines: [...EDITING_GUIDELINES, ...(definition.promptGuidelines ?? [])],
|
|
111
119
|
description: definition.description,
|
|
112
120
|
parameters: definition.parameters,
|
|
113
|
-
outputSchema:
|
|
121
|
+
outputSchema: mutationResultSchema(definition.name),
|
|
114
122
|
prepareArguments: (arguments_) =>
|
|
115
123
|
// oxlint-disable-next-line typescript/no-unsafe-return -- TypeBox resolves only concrete tool schemas.
|
|
116
124
|
prepareGuardedArguments(
|
|
@@ -133,73 +141,172 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
133
141
|
),
|
|
134
142
|
}),
|
|
135
143
|
async execute(toolCallId, parameters, signal, onUpdate, context) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
144
|
+
let plannedEdits: ReadonlyMap<string, TextMutationEdit> | undefined;
|
|
145
|
+
const captured = await runNativePostEditScope(core, toolCallId, () =>
|
|
146
|
+
captureScriptMutation(core, async () => {
|
|
147
|
+
const execute = async (): Promise<AgentToolResult<FileMutationBatchResult>> => {
|
|
148
|
+
let input = asMutationParameters<TParameters>(parameters);
|
|
149
|
+
if (
|
|
150
|
+
["replace", "write", "delete", "undo"].includes(definition.name) &&
|
|
151
|
+
isResultInput(input[definition.source.field])
|
|
152
|
+
) {
|
|
153
|
+
try {
|
|
154
|
+
if (resultTargets === undefined)
|
|
155
|
+
throw new Error("Result targets are unavailable.");
|
|
156
|
+
if (input.start !== undefined || input.end !== undefined)
|
|
157
|
+
throw new Error("Do not combine result targets with start/end.");
|
|
158
|
+
const selected = resultTargets.resolve(
|
|
159
|
+
input[definition.source.field],
|
|
160
|
+
context.cwd,
|
|
161
|
+
);
|
|
162
|
+
if (!selected.complete)
|
|
163
|
+
throw new Error(
|
|
164
|
+
"Incomplete result targets cannot establish a complete edit; repeat Search.",
|
|
165
|
+
);
|
|
166
|
+
await resultTargets.verify(selected, signal);
|
|
167
|
+
if (definition.name === "write" || definition.name === "undo")
|
|
168
|
+
wholeFileResultSource(selected);
|
|
169
|
+
if (selected.targets.length === 0)
|
|
170
|
+
return {
|
|
171
|
+
content: [{ type: "text", text: "Empty result target set; no changes." }],
|
|
172
|
+
details: {
|
|
173
|
+
results: [],
|
|
174
|
+
effect: "not-applied",
|
|
175
|
+
metadata: { emptyTargets: true },
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
input = {
|
|
179
|
+
...input,
|
|
180
|
+
[definition.source.field]: resultTargets.register(
|
|
181
|
+
selected.targets,
|
|
182
|
+
context.cwd,
|
|
183
|
+
selected.complete,
|
|
184
|
+
),
|
|
185
|
+
};
|
|
186
|
+
} catch (error) {
|
|
187
|
+
signal?.throwIfAborted();
|
|
188
|
+
return failureToolResult(
|
|
189
|
+
"",
|
|
190
|
+
"RESULT_INPUT_REJECTED",
|
|
191
|
+
errorMessage(error),
|
|
192
|
+
"not-applied",
|
|
193
|
+
);
|
|
194
|
+
}
|
|
172
195
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
let executionDefinition = definition;
|
|
197
|
+
let verifyFileSource: (() => Promise<void>) | undefined;
|
|
198
|
+
if (
|
|
199
|
+
(definition.name === "copy" || definition.name === "move") &&
|
|
200
|
+
(isResultInput(input.path) || isResultInput(input.target))
|
|
201
|
+
) {
|
|
202
|
+
try {
|
|
203
|
+
if (resultTargets === undefined)
|
|
204
|
+
throw new Error("Result targets are unavailable.");
|
|
205
|
+
const prepared = await prepareResultTransfer(
|
|
206
|
+
definition.name,
|
|
207
|
+
input,
|
|
208
|
+
resultTargets,
|
|
209
|
+
context.cwd,
|
|
210
|
+
signal,
|
|
211
|
+
);
|
|
212
|
+
input = asMutationParameters<TParameters>(prepared.input);
|
|
213
|
+
verifyFileSource = prepared.verifyFileSource;
|
|
214
|
+
if (prepared.empty)
|
|
215
|
+
return {
|
|
216
|
+
content: [{ type: "text", text: "Empty result target set; no changes." }],
|
|
217
|
+
details: {
|
|
218
|
+
results: [],
|
|
219
|
+
effect: "not-applied",
|
|
220
|
+
metadata: { emptyTargets: true },
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
if (prepared.mutate !== undefined)
|
|
224
|
+
executionDefinition = { ...definition, mutate: prepared.mutate };
|
|
225
|
+
} catch (error) {
|
|
226
|
+
signal?.throwIfAborted();
|
|
227
|
+
return failureToolResult(
|
|
228
|
+
"",
|
|
229
|
+
"RESULT_INPUT_REJECTED",
|
|
230
|
+
errorMessage(error),
|
|
231
|
+
"not-applied",
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const directDefinition = executionDefinition;
|
|
236
|
+
executionDefinition = {
|
|
237
|
+
...directDefinition,
|
|
238
|
+
mutate: async (mutationContext, arguments_) => {
|
|
239
|
+
const mutation = await directDefinition.mutate(mutationContext, arguments_);
|
|
240
|
+
plannedEdits = mutation.edits;
|
|
241
|
+
return mutation;
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
const queued = executeNativeTextEditBatch(
|
|
188
245
|
core,
|
|
246
|
+
toolCallId,
|
|
189
247
|
definition,
|
|
190
248
|
input,
|
|
191
249
|
signal,
|
|
192
250
|
context,
|
|
193
|
-
(field, state) =>
|
|
194
|
-
annotations.resolveArguments(toolCallId, {
|
|
195
|
-
[TOOL_CALL_INTERCEPTION_ANCHOR_RENDER_PATCH]: { [field]: state },
|
|
196
|
-
}),
|
|
197
|
-
getLastResolvedSource(),
|
|
198
251
|
);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
252
|
+
if (queued !== undefined) return queued;
|
|
253
|
+
if (definition.direct?.matches(input) === true) {
|
|
254
|
+
try {
|
|
255
|
+
const action = await definition.direct.execute(
|
|
256
|
+
{ cwd: context.cwd, ...(signal !== undefined && { signal }) },
|
|
257
|
+
input,
|
|
258
|
+
);
|
|
259
|
+
return {
|
|
260
|
+
content: [{ type: "text", text: action.summary }],
|
|
261
|
+
details: {
|
|
262
|
+
results: [],
|
|
263
|
+
metadata: { semanticAction: { ...action.data, source: action.source } },
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
} catch (error) {
|
|
267
|
+
const code =
|
|
268
|
+
error !== null && typeof error === "object" && "code" in error
|
|
269
|
+
? String(error.code)
|
|
270
|
+
: "DIRECT_MUTATION_FAILED";
|
|
271
|
+
return failureToolResult(
|
|
272
|
+
"transaction" in input ? String(input.transaction) : "",
|
|
273
|
+
code,
|
|
274
|
+
error instanceof Error ? error.message : String(error),
|
|
275
|
+
"unknown",
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (
|
|
280
|
+
isWholeFileInvocation(definition.wholeFileOperation, input) &&
|
|
281
|
+
core.getSemanticMutationHandler(definition.name, input) === undefined
|
|
282
|
+
) {
|
|
283
|
+
return executeWholeFileTool(
|
|
284
|
+
core,
|
|
285
|
+
definition.wholeFileOperation,
|
|
286
|
+
input,
|
|
287
|
+
signal,
|
|
288
|
+
context,
|
|
289
|
+
verifyFileSource,
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
const directExecute = () =>
|
|
293
|
+
executeTextMutation(
|
|
294
|
+
core,
|
|
295
|
+
executionDefinition,
|
|
296
|
+
input,
|
|
297
|
+
signal,
|
|
298
|
+
context,
|
|
299
|
+
(field, state) =>
|
|
300
|
+
annotations.resolveArguments(toolCallId, {
|
|
301
|
+
[TOOL_CALL_INTERCEPTION_ANCHOR_RENDER_PATCH]: { [field]: state },
|
|
302
|
+
}),
|
|
303
|
+
getLastResolvedSource(),
|
|
304
|
+
);
|
|
305
|
+
return executeTextToolWithBatch(toolCallId, directExecute, signal, onUpdate, context);
|
|
306
|
+
};
|
|
307
|
+
return execute();
|
|
308
|
+
}),
|
|
309
|
+
);
|
|
203
310
|
if (captured.kind === "failed") {
|
|
204
311
|
const failed = failureToolResult(
|
|
205
312
|
"",
|
|
@@ -209,12 +316,23 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
209
316
|
);
|
|
210
317
|
return structuredMutation(failed, definition.name, captured.completions, toolCallId);
|
|
211
318
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
319
|
+
recordNativeTextMutation(core, toolCallId, captured.value);
|
|
320
|
+
const value =
|
|
321
|
+
resultTargets &&
|
|
322
|
+
["replace", "insert", "write", "copy", "move", "undo"].includes(definition.name)
|
|
323
|
+
? await attachCommittedMutationTarget(
|
|
324
|
+
captured.value,
|
|
325
|
+
captured.completions,
|
|
326
|
+
resultTargets,
|
|
327
|
+
toolCallId,
|
|
328
|
+
context.cwd,
|
|
329
|
+
signal,
|
|
330
|
+
definition.name === "write" || definition.name === "undo",
|
|
331
|
+
plannedEdits,
|
|
332
|
+
definition.name === "copy" || definition.name === "move",
|
|
333
|
+
)
|
|
334
|
+
: captured.value;
|
|
335
|
+
return structuredMutation(value, definition.name, captured.completions, toolCallId);
|
|
218
336
|
},
|
|
219
337
|
}),
|
|
220
338
|
annotations,
|
|
@@ -225,7 +343,22 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
225
343
|
return [
|
|
226
344
|
definition.description,
|
|
227
345
|
definition.intent !== "restore"
|
|
228
|
-
? "In native Codemode, local text edits share original snapshots and return acceptance before writing. Another tool, whole-file operation, or resource-owned selector
|
|
346
|
+
? "In native Codemode, local text edits share original snapshots and return acceptance before writing. Another tool, whole-file operation, or resource-owned selector commits the batch first; script completion also commits it. Formatting and registered resource post-edit handlers run at script end, not at flush or dependency boundaries. Earlier targets become stale if final processing changes bytes. Ordinary script errors keep accepted edits; aborts and deadlines discard pending edits."
|
|
347
|
+
: "",
|
|
348
|
+
(
|
|
349
|
+
{
|
|
350
|
+
replace:
|
|
351
|
+
"This result selects the resulting text; empty replacement selects the resulting position, not the removed text.",
|
|
352
|
+
insert: "This result selects the inserted text, including supplied line separators.",
|
|
353
|
+
write: "This result selects the whole written file, not only its changed span.",
|
|
354
|
+
copy: "This result selects only destination text; a whole-file copy selects the whole destination. The source is unchanged.",
|
|
355
|
+
move: "This result selects only destination text; a whole-file move selects the whole destination. Source removals never become output targets.",
|
|
356
|
+
delete: "Deletion reports file effects but provides no reusable text selection.",
|
|
357
|
+
undo: "This result selects whole restored text files, not only reversed spans. Deleted files provide no text selection.",
|
|
358
|
+
} as Record<string, string>
|
|
359
|
+
)[definition.name] ?? "",
|
|
360
|
+
["replace", "insert", "write", "copy", "move", "undo"].includes(definition.name)
|
|
361
|
+
? "Pass this unchanged result to another source tool for dependent work. Pending edits commit before the next tool consumes them. If the result reports no verified text selection, inspect the file instead."
|
|
229
362
|
: "",
|
|
230
363
|
definition.source.inherited
|
|
231
364
|
? definition.wholeFileOperation === undefined
|
|
@@ -318,7 +451,11 @@ async function resolveMutationSources(
|
|
|
318
451
|
source: string,
|
|
319
452
|
): Promise<readonly TextTarget[] | undefined> => {
|
|
320
453
|
try {
|
|
321
|
-
return await core.resolveTextAnchorResources(
|
|
454
|
+
return await core.resolveTextAnchorResources(
|
|
455
|
+
value,
|
|
456
|
+
value.startsWith("RESULT#") ? [...allKinds, TEXT_SEARCH_ANCHOR_KIND] : allKinds,
|
|
457
|
+
context,
|
|
458
|
+
);
|
|
322
459
|
} catch (error) {
|
|
323
460
|
throw contextualizeTextMutationAnchorError(error, definition.name, field, source, value);
|
|
324
461
|
}
|
|
@@ -415,6 +552,7 @@ async function resolveMutationSources(
|
|
|
415
552
|
if (
|
|
416
553
|
targets !== undefined &&
|
|
417
554
|
hasImplicitSourceSelection &&
|
|
555
|
+
definition.name !== "undo" &&
|
|
418
556
|
descriptor.field === firstAnchor?.field
|
|
419
557
|
) {
|
|
420
558
|
implicitTargets.set(descriptor.field, targets);
|
|
@@ -1038,140 +1176,6 @@ export async function captureScriptMutation<T>(core: TextEditorCore, action: ()
|
|
|
1038
1176
|
unsubscribe();
|
|
1039
1177
|
}
|
|
1040
1178
|
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Runs the configured mutation pipeline and returns plain script data.
|
|
1043
|
-
* onPresentation retains rich edit annotations on the host without sending classes to the guest.
|
|
1044
|
-
*/
|
|
1045
|
-
export async function executeScriptMutation<TParameters extends TSchema>(
|
|
1046
|
-
core: TextEditorCore,
|
|
1047
|
-
definition: TextMutationToolRegistration<TParameters>,
|
|
1048
|
-
arguments_: unknown,
|
|
1049
|
-
signal: AbortSignal | undefined,
|
|
1050
|
-
context: ExtensionContext,
|
|
1051
|
-
lastResolvedSource?: string,
|
|
1052
|
-
onPresentation?: (source: string, result: FileMutationResult) => void,
|
|
1053
|
-
): Promise<ScriptMutationOutcome> {
|
|
1054
|
-
const parameters = prepareGuardedArguments(
|
|
1055
|
-
definition.parameters,
|
|
1056
|
-
arguments_,
|
|
1057
|
-
definition.source.inherited ? definition.source.field : undefined,
|
|
1058
|
-
lastResolvedSource,
|
|
1059
|
-
definition.anchors ?? [],
|
|
1060
|
-
definition.wholeFileOperation !== undefined,
|
|
1061
|
-
);
|
|
1062
|
-
if (!Value.Check(definition.parameters, parameters)) {
|
|
1063
|
-
throw Object.assign(new Error(`Invalid arguments for ${definition.name}`), {
|
|
1064
|
-
code: "INVALID_ARGUMENTS",
|
|
1065
|
-
details: { operation: definition.name, effect: "not-applied" },
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
const captured = await captureScriptMutation(core, () =>
|
|
1069
|
-
executeTextMutationPipeline(
|
|
1070
|
-
core,
|
|
1071
|
-
definition,
|
|
1072
|
-
parameters,
|
|
1073
|
-
signal,
|
|
1074
|
-
context,
|
|
1075
|
-
undefined,
|
|
1076
|
-
lastResolvedSource,
|
|
1077
|
-
),
|
|
1078
|
-
);
|
|
1079
|
-
const source =
|
|
1080
|
-
captured.kind === "completed" ? captured.value.source : mutationSource(definition, parameters);
|
|
1081
|
-
const observedFiles: ScriptMutationOutcome["files"] = captured.completions.map((completion) => ({
|
|
1082
|
-
source: completion.resourceSource,
|
|
1083
|
-
before: completion.existed ? completion.before.content : null,
|
|
1084
|
-
after: completion.after.content,
|
|
1085
|
-
action: definition.name === "write" ? "overwritten" : "edited",
|
|
1086
|
-
changes: [],
|
|
1087
|
-
formatting: { status: "not-reported" },
|
|
1088
|
-
}));
|
|
1089
|
-
const failed = (
|
|
1090
|
-
code: string,
|
|
1091
|
-
message: string,
|
|
1092
|
-
effect: ScriptMutationOutcome["effect"],
|
|
1093
|
-
completed: readonly string[] = [],
|
|
1094
|
-
): ScriptMutationOutcome => ({
|
|
1095
|
-
operation: definition.name,
|
|
1096
|
-
ok: false,
|
|
1097
|
-
effect: effect === "unknown" ? "unknown" : observedFiles.length > 0 ? "applied" : effect,
|
|
1098
|
-
completed: [...new Set([...completed, ...observedFiles.map((file) => file.source)])],
|
|
1099
|
-
files: observedFiles,
|
|
1100
|
-
errors: [{ source, code, message }],
|
|
1101
|
-
});
|
|
1102
|
-
if (captured.kind === "failed")
|
|
1103
|
-
return failed("EXECUTION_FAILED", errorMessage(captured.error), "unknown");
|
|
1104
|
-
const { pipeline } = captured.value;
|
|
1105
|
-
if (pipeline.kind === "failed")
|
|
1106
|
-
return {
|
|
1107
|
-
...failed(pipeline.failure.code, pipeline.failure.message, "not-applied"),
|
|
1108
|
-
recoveries: await scriptAnchorRecoveries(pipeline.failure.cause),
|
|
1109
|
-
};
|
|
1110
|
-
const outcome = pipeline.state.result;
|
|
1111
|
-
if (!isResourcesEditOutcome(outcome))
|
|
1112
|
-
return failed("INVALID_RESULT", "Invalid mutation outcome", "unknown");
|
|
1113
|
-
if (outcome.kind === "failed")
|
|
1114
|
-
return {
|
|
1115
|
-
...failed(
|
|
1116
|
-
outcome.failure.code,
|
|
1117
|
-
outcome.failure.message,
|
|
1118
|
-
outcome.completed.length > 0 ? "unknown" : "not-applied",
|
|
1119
|
-
outcome.completed,
|
|
1120
|
-
),
|
|
1121
|
-
recoveries: await scriptAnchorRecoveries(outcome.failure.cause),
|
|
1122
|
-
};
|
|
1123
|
-
const mutation = outcome.result as ExecutedTextMutation;
|
|
1124
|
-
if (mutation.semanticAction !== undefined) {
|
|
1125
|
-
return {
|
|
1126
|
-
operation: definition.name,
|
|
1127
|
-
ok: true,
|
|
1128
|
-
effect: "applied",
|
|
1129
|
-
files: [],
|
|
1130
|
-
completed: [mutation.semanticAction.source],
|
|
1131
|
-
metadata: {
|
|
1132
|
-
semanticAction: {
|
|
1133
|
-
...mutation.semanticAction.data,
|
|
1134
|
-
source: mutation.semanticAction.source,
|
|
1135
|
-
},
|
|
1136
|
-
},
|
|
1137
|
-
errors: [],
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
const files = outcome.resources.flatMap((resource) => {
|
|
1141
|
-
const edit = mutation.edits.get(resource.source);
|
|
1142
|
-
if (edit === undefined) return [];
|
|
1143
|
-
const presentation = withPipelineStatuses(
|
|
1144
|
-
buildSuccessfulTextMutationResult(resource, resource.source, edit),
|
|
1145
|
-
pipeline.state.metadata,
|
|
1146
|
-
);
|
|
1147
|
-
onPresentation?.(resource.after.source, presentation);
|
|
1148
|
-
const data = presentation.data;
|
|
1149
|
-
return [
|
|
1150
|
-
{
|
|
1151
|
-
source: resource.after.source,
|
|
1152
|
-
before:
|
|
1153
|
-
captured.completions.find(
|
|
1154
|
-
(completion) => completion.resourceSource === resource.after.source,
|
|
1155
|
-
)?.existed === false
|
|
1156
|
-
? null
|
|
1157
|
-
: resource.before.content,
|
|
1158
|
-
after: resource.after.content,
|
|
1159
|
-
action: edit.action,
|
|
1160
|
-
changes: data.rawChanges ?? [],
|
|
1161
|
-
formatting: data.formatting ?? { status: "not-reported" as const },
|
|
1162
|
-
},
|
|
1163
|
-
];
|
|
1164
|
-
});
|
|
1165
|
-
return {
|
|
1166
|
-
operation: definition.name,
|
|
1167
|
-
ok: true,
|
|
1168
|
-
effect: files.length > 0 ? "applied" : "not-applied",
|
|
1169
|
-
files,
|
|
1170
|
-
completed: files.map((file) => file.source),
|
|
1171
|
-
...(pipeline.state.metadata !== undefined && { metadata: pipeline.state.metadata }),
|
|
1172
|
-
errors: [],
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
1179
|
export function mutationSources(
|
|
1176
1180
|
definition: TextMutationToolRegistration,
|
|
1177
1181
|
parameters: Readonly<Record<string, unknown>>,
|
|
@@ -1386,24 +1390,6 @@ async function resolveAnchorRecovery(error: TextMutationAnchorResolutionError) {
|
|
|
1386
1390
|
return error.resolution.recovery;
|
|
1387
1391
|
}
|
|
1388
1392
|
|
|
1389
|
-
async function scriptAnchorRecoveries(
|
|
1390
|
-
cause: unknown,
|
|
1391
|
-
): Promise<NonNullable<ScriptMutationOutcome["recoveries"]>> {
|
|
1392
|
-
if (cause instanceof TextMutationAnchorAggregateError)
|
|
1393
|
-
return (await Promise.all(cause.failures.map(scriptAnchorRecoveries))).flat();
|
|
1394
|
-
if (!(cause instanceof TextMutationAnchorResolutionError)) return [];
|
|
1395
|
-
const recovery = await resolveAnchorRecovery(cause);
|
|
1396
|
-
return [
|
|
1397
|
-
{
|
|
1398
|
-
path: cause.source,
|
|
1399
|
-
field: cause.field,
|
|
1400
|
-
anchor: cause.anchor,
|
|
1401
|
-
status: recovery?.kind ?? "unavailable",
|
|
1402
|
-
candidates: recovery?.kind === "candidates" ? recovery.candidates : [],
|
|
1403
|
-
total: recovery?.kind === "candidates" ? recovery.total : 0,
|
|
1404
|
-
},
|
|
1405
|
-
];
|
|
1406
|
-
}
|
|
1407
1393
|
async function anchorFailureToolResult(
|
|
1408
1394
|
core: TextEditorCore,
|
|
1409
1395
|
failure: TextResourceEditFailure,
|
|
@@ -1418,12 +1404,18 @@ async function anchorFailureToolResult(
|
|
|
1418
1404
|
const results: FileMutationResult[] = [];
|
|
1419
1405
|
const anchorRecoveries: NonNullable<FileMutationBatchResult["anchorRecoveries"]>[number][] = [];
|
|
1420
1406
|
const messages: string[] = [];
|
|
1407
|
+
const exactTextFailures: string[] = [];
|
|
1421
1408
|
for (const item of recovered) {
|
|
1422
1409
|
if (item === undefined) {
|
|
1423
1410
|
continue;
|
|
1424
1411
|
}
|
|
1425
1412
|
results.push(...(item.details.results ?? []));
|
|
1426
1413
|
anchorRecoveries.push(...(item.details.anchorRecoveries ?? []));
|
|
1414
|
+
const failed = item.details.metadata?.exactTextFailures;
|
|
1415
|
+
if (Array.isArray(failed))
|
|
1416
|
+
exactTextFailures.push(
|
|
1417
|
+
...failed.filter((source): source is string => typeof source === "string"),
|
|
1418
|
+
);
|
|
1427
1419
|
for (const block of item.content) {
|
|
1428
1420
|
if (block.type === "text") {
|
|
1429
1421
|
messages.push(block.text);
|
|
@@ -1435,7 +1427,12 @@ async function anchorFailureToolResult(
|
|
|
1435
1427
|
}
|
|
1436
1428
|
return {
|
|
1437
1429
|
content: [{ type: "text", text: messages.join("\n\n") }],
|
|
1438
|
-
details: {
|
|
1430
|
+
details: {
|
|
1431
|
+
results,
|
|
1432
|
+
anchorRecoveries,
|
|
1433
|
+
effect: "not-applied",
|
|
1434
|
+
metadata: { exactTextFailures },
|
|
1435
|
+
},
|
|
1439
1436
|
};
|
|
1440
1437
|
}
|
|
1441
1438
|
if (!(failure.cause instanceof TextMutationAnchorResolutionError)) {
|
|
@@ -1444,15 +1441,10 @@ async function anchorFailureToolResult(
|
|
|
1444
1441
|
|
|
1445
1442
|
const contextual = failure.cause;
|
|
1446
1443
|
const resolution = contextual.resolution;
|
|
1447
|
-
const recovery = await resolveAnchorRecovery(contextual)
|
|
1448
|
-
|
|
1449
|
-
return
|
|
1450
|
-
|
|
1451
|
-
failure.code,
|
|
1452
|
-
`${failure.message}; recovery timed out`,
|
|
1453
|
-
"not-applied",
|
|
1454
|
-
);
|
|
1455
|
-
}
|
|
1444
|
+
const recovery = await resolveAnchorRecovery(contextual).catch(() => {
|
|
1445
|
+
context.signal?.throwIfAborted();
|
|
1446
|
+
return undefined;
|
|
1447
|
+
});
|
|
1456
1448
|
|
|
1457
1449
|
const windows =
|
|
1458
1450
|
recovery?.kind === "candidates"
|
|
@@ -1463,9 +1455,7 @@ async function anchorFailureToolResult(
|
|
|
1463
1455
|
: resolution.rejection?.contextRange === undefined
|
|
1464
1456
|
? []
|
|
1465
1457
|
: [resolution.rejection.contextRange];
|
|
1466
|
-
if (windows.length === 0) {
|
|
1467
|
-
return undefined;
|
|
1468
|
-
}
|
|
1458
|
+
if (windows.length === 0) windows.push({ offset: 1, limit: 40 });
|
|
1469
1459
|
|
|
1470
1460
|
const reads = await Promise.all(
|
|
1471
1461
|
windows.map((range) =>
|
|
@@ -1476,14 +1466,15 @@ async function anchorFailureToolResult(
|
|
|
1476
1466
|
cwd: context.cwd,
|
|
1477
1467
|
...(context.signal !== undefined && { signal: context.signal }),
|
|
1478
1468
|
},
|
|
1479
|
-
)
|
|
1469
|
+
)?.catch(() => {
|
|
1470
|
+
context.signal?.throwIfAborted();
|
|
1471
|
+
return undefined;
|
|
1472
|
+
}),
|
|
1480
1473
|
),
|
|
1481
1474
|
);
|
|
1482
1475
|
const recoveryTexts: string[] = [];
|
|
1483
1476
|
for (const read of reads) {
|
|
1484
|
-
if (read === undefined || read.isError === true)
|
|
1485
|
-
return undefined;
|
|
1486
|
-
}
|
|
1477
|
+
if (read === undefined || read.isError === true) continue;
|
|
1487
1478
|
recoveryTexts.push(
|
|
1488
1479
|
...read.content.filter((block) => block.type === "text").map((block) => block.text),
|
|
1489
1480
|
);
|
|
@@ -1524,6 +1515,9 @@ async function anchorFailureToolResult(
|
|
|
1524
1515
|
results: [result],
|
|
1525
1516
|
effect: "not-applied",
|
|
1526
1517
|
anchorRecovery: true,
|
|
1518
|
+
...(resolution.resolverId === "exact-text" && {
|
|
1519
|
+
metadata: { exactTextFailures: [contextual.source] },
|
|
1520
|
+
}),
|
|
1527
1521
|
...(recovery?.kind === "candidates" && {
|
|
1528
1522
|
anchorRecoveries: [
|
|
1529
1523
|
{
|
|
@@ -1554,8 +1548,8 @@ function formatRejectedAnchorMessage(
|
|
|
1554
1548
|
? "is invalid"
|
|
1555
1549
|
: "could not be resolved";
|
|
1556
1550
|
const guidance =
|
|
1557
|
-
|
|
1558
|
-
? "
|
|
1551
|
+
failure.resolution.resolverId === "exact-text"
|
|
1552
|
+
? "Exact-text editing is now blocked for this file until an anchor-based edit succeeds. Find the intended location among the current anchors below, or use Read/Search for another section, and use its anchor. After that edit, exact text is available again."
|
|
1559
1553
|
: "If the intended text is represented below, use its candidate anchor. Otherwise, reread the relevant section and choose a current anchor.";
|
|
1560
1554
|
const context = recoveryContext.length === 0 ? "" : `\n\n${recoveryContext}`;
|
|
1561
1555
|
return `[SYSTEM] ${failure.toolName} blocked: ${failure.field} anchor "${failure.anchor}" ${state}. ${guidance} (${reason})${context}`;
|