pi-agent-ide 0.6.4 → 0.7.0
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 +38 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-3HYXQ4YA.js} +1 -1
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/{chunk-5J43L2RL.js → chunk-4NIFBFFR.js} +1 -1
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/{chunk-KUPHNMUK.js → chunk-KBP3QUDT.js} +1 -1
- package/dist/{chunk-VBICI5YA.js → chunk-KR36BT5E.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-PYPPV2F5.js} +1 -1
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/{chunk-FBOW7XOV.js → chunk-YRF7OATP.js} +1 -1
- 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 +1 -1
- package/dist/entry-26.js +1 -1
- 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 +13 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -13
- 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-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 +67 -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 +5 -5
- package/docs/agent-guides/editing.md +20 -4
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +9 -1
- package/docs/agent-guides/search-code.md +38 -1
- package/docs/agent-guides/select-code.md +194 -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 +32 -5
- package/docs/tools.md +6 -2
- 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/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -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 +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- 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 +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -18
- 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 +2 -2
- 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 +88 -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/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- 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 +2 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- 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 +233 -0
- 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/package.json +3 -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-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 +12 -2
- 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 +1 -1
- 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 +199 -19
- 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 +109 -11
- 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 +211 -223
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- 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-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 +3 -0
- 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/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/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 +3 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-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/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- 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 +2 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- 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/package.json +3 -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-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 +12 -2
- 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 +1 -1
- 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 +199 -19
- 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 +109 -11
- 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 +211 -223
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- 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 +0 -6
- 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 +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- 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 +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -18
- 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-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 +2 -2
- 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 +88 -45
- 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 +19 -0
- package/dist/chunk-2P2OGO3G.js +0 -2
- 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-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- 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
87
|
import { mutationOutputSchema, 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;
|
|
@@ -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,24 @@ 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
|
+
"Local data.target selects this call's resulting text; empty replacement selects the resulting position, not the removed text.",
|
|
352
|
+
insert:
|
|
353
|
+
"Local data.target selects this call's inserted text, including supplied line separators.",
|
|
354
|
+
write: "Local data.target selects the whole written file, not only its changed span.",
|
|
355
|
+
copy: "Local data.target selects only the destination text; a whole-file copy selects the whole destination. The source is unchanged.",
|
|
356
|
+
move: "Local data.target selects only the destination text; a whole-file move selects the whole destination. Source removals never become output targets.",
|
|
357
|
+
delete:
|
|
358
|
+
"Deletion returns a change record and file state, never a live target or an empty-position target.",
|
|
359
|
+
undo: "Local data.target selects whole restored text files, not only reversed spans. Restored absence is reported in files[].state without a live target.",
|
|
360
|
+
} as Record<string, string>
|
|
361
|
+
)[definition.name] ?? "",
|
|
362
|
+
["replace", "insert", "write", "copy", "move", "undo"].includes(definition.name)
|
|
363
|
+
? "A pending data.target requires confirmed writing. Successful changes without a verified text mapping expose data.targetUnavailable; inspect effects separately."
|
|
229
364
|
: "",
|
|
230
365
|
definition.source.inherited
|
|
231
366
|
? definition.wholeFileOperation === undefined
|
|
@@ -318,7 +453,11 @@ async function resolveMutationSources(
|
|
|
318
453
|
source: string,
|
|
319
454
|
): Promise<readonly TextTarget[] | undefined> => {
|
|
320
455
|
try {
|
|
321
|
-
return await core.resolveTextAnchorResources(
|
|
456
|
+
return await core.resolveTextAnchorResources(
|
|
457
|
+
value,
|
|
458
|
+
value.startsWith("RESULT#") ? [...allKinds, TEXT_SEARCH_ANCHOR_KIND] : allKinds,
|
|
459
|
+
context,
|
|
460
|
+
);
|
|
322
461
|
} catch (error) {
|
|
323
462
|
throw contextualizeTextMutationAnchorError(error, definition.name, field, source, value);
|
|
324
463
|
}
|
|
@@ -415,6 +554,7 @@ async function resolveMutationSources(
|
|
|
415
554
|
if (
|
|
416
555
|
targets !== undefined &&
|
|
417
556
|
hasImplicitSourceSelection &&
|
|
557
|
+
definition.name !== "undo" &&
|
|
418
558
|
descriptor.field === firstAnchor?.field
|
|
419
559
|
) {
|
|
420
560
|
implicitTargets.set(descriptor.field, targets);
|
|
@@ -1038,140 +1178,6 @@ export async function captureScriptMutation<T>(core: TextEditorCore, action: ()
|
|
|
1038
1178
|
unsubscribe();
|
|
1039
1179
|
}
|
|
1040
1180
|
}
|
|
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
1181
|
export function mutationSources(
|
|
1176
1182
|
definition: TextMutationToolRegistration,
|
|
1177
1183
|
parameters: Readonly<Record<string, unknown>>,
|
|
@@ -1386,24 +1392,6 @@ async function resolveAnchorRecovery(error: TextMutationAnchorResolutionError) {
|
|
|
1386
1392
|
return error.resolution.recovery;
|
|
1387
1393
|
}
|
|
1388
1394
|
|
|
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
1395
|
async function anchorFailureToolResult(
|
|
1408
1396
|
core: TextEditorCore,
|
|
1409
1397
|
failure: TextResourceEditFailure,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import { resultInputSchema } from "pi-agent-resource";
|
|
3
|
+
|
|
4
|
+
/** Build a structured source selector without changing legacy path semantics. */
|
|
5
|
+
export function resultSourceProperty(description: string) {
|
|
6
|
+
return Type.Optional({ ...resultInputSchema, description });
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
/** Build the source selector shared by text mutation schemas. */
|
|
4
10
|
export function sourcePathProperty(description: string) {
|
|
@@ -26,16 +32,13 @@ export function sourceRangeProperties() {
|
|
|
26
32
|
/** Build the destination selectors shared by copy and move schemas. */
|
|
27
33
|
export function targetProperties() {
|
|
28
34
|
return {
|
|
29
|
-
target:
|
|
30
|
-
|
|
31
|
-
description:
|
|
32
|
-
"Target resource reference or file path. Required for a whole-file operation; defaults to the source for selected text.",
|
|
33
|
-
}),
|
|
35
|
+
target: resultSourceProperty(
|
|
36
|
+
"Destination file path or source result. A structured result replaces its exact ranges (zero-width ranges insert); omit targetStart/targetEnd. Source and destination selections pair in declared order with equal counts. A string target keeps its existing anchor semantics.",
|
|
34
37
|
),
|
|
35
38
|
targetStart: Type.Optional(
|
|
36
39
|
Type.String({
|
|
37
40
|
description:
|
|
38
|
-
"Registered anchor or unique exact text in the destination. Required
|
|
41
|
+
"Registered anchor or unique exact text in the destination. Required for text transfers with a string target; omit for whole-file transfers or a structured target. Without targetEnd, inserts after the last containing line, keeping the selected text. With targetEnd, replacement starts at the first containing line. SEARCH :match also uses these line boundaries.",
|
|
39
42
|
}),
|
|
40
43
|
),
|
|
41
44
|
targetEnd: Type.Optional(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
resultSourceProperty,
|
|
5
5
|
sourceRangeProperties,
|
|
6
6
|
targetProperties,
|
|
7
7
|
} from "#src/tools/text-tool-schema-properties.js";
|
|
@@ -17,8 +17,8 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
17
17
|
|
|
18
18
|
export const copySchema = Type.Object(
|
|
19
19
|
{
|
|
20
|
-
path:
|
|
21
|
-
"Source file path
|
|
20
|
+
path: resultSourceProperty(
|
|
21
|
+
"Source file path or structured source selection; omit start/end for structured inputs. Use one whole-file result when target is a string without text selectors. Structured source/destination selections pair in declared order, with equal counts and duplicate ranges removed.",
|
|
22
22
|
),
|
|
23
23
|
...sourceRangeProperties(),
|
|
24
24
|
...targetProperties(),
|
|
@@ -26,10 +26,10 @@ export const copySchema = Type.Object(
|
|
|
26
26
|
{ additionalProperties: false },
|
|
27
27
|
);
|
|
28
28
|
interface CopyParameters {
|
|
29
|
-
readonly path?:
|
|
29
|
+
readonly path?: unknown;
|
|
30
30
|
readonly start?: string;
|
|
31
31
|
readonly end?: string;
|
|
32
|
-
readonly target?:
|
|
32
|
+
readonly target?: unknown;
|
|
33
33
|
readonly targetStart?: string;
|
|
34
34
|
readonly targetEnd?: string;
|
|
35
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
resultSourceProperty,
|
|
5
5
|
sourceRangeProperties,
|
|
6
6
|
} from "#src/tools/text-tool-schema-properties.js";
|
|
7
7
|
|
|
@@ -17,15 +17,15 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
17
17
|
|
|
18
18
|
export const deleteSchema = Type.Object(
|
|
19
19
|
{
|
|
20
|
-
path:
|
|
21
|
-
"
|
|
20
|
+
path: resultSourceProperty(
|
|
21
|
+
"File path or structured source selection. A structured input deletes only its exact text ranges, even if it selects a whole file; omit start/end.",
|
|
22
22
|
),
|
|
23
23
|
...sourceRangeProperties(),
|
|
24
24
|
},
|
|
25
25
|
{ additionalProperties: false },
|
|
26
26
|
);
|
|
27
27
|
interface DeleteParameters {
|
|
28
|
-
readonly path?:
|
|
28
|
+
readonly path?: unknown;
|
|
29
29
|
readonly start?: string;
|
|
30
30
|
readonly end?: string;
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchem
|
|
|
34
34
|
name: "delete",
|
|
35
35
|
wholeFileOperation: "delete",
|
|
36
36
|
description:
|
|
37
|
-
"Use delete to permanently delete one regular file when path is supplied without text selectors, or to remove selected text. Whole-file deletion rejects directories and symlinks.",
|
|
37
|
+
"Use delete to permanently delete one regular file when an ordinary string path is supplied without text selectors, or to remove selected text. Structured path removes only its text ranges and keeps the file, even for a whole-file selection. Whole-file deletion rejects directories and symlinks.",
|
|
38
38
|
|
|
39
39
|
promptSnippet: "Delete regular files, or delete selected text using exact matches or anchors",
|
|
40
40
|
parameters: deleteSchema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
resultSourceProperty,
|
|
5
5
|
sourceRangeProperties,
|
|
6
6
|
targetProperties,
|
|
7
7
|
} from "#src/tools/text-tool-schema-properties.js";
|
|
@@ -19,8 +19,8 @@ import type { TextChange } from "#src/core/text-change-engine.js";
|
|
|
19
19
|
|
|
20
20
|
export const moveSchema = Type.Object(
|
|
21
21
|
{
|
|
22
|
-
path:
|
|
23
|
-
"Source file path
|
|
22
|
+
path: resultSourceProperty(
|
|
23
|
+
"Source file path or structured source selection; omit start/end for structured inputs. Use one whole-file result when target is a string without text selectors. Structured source/destination selections pair in declared order, with equal counts and duplicate ranges removed. Destinations must not overlap or touch source ranges.",
|
|
24
24
|
),
|
|
25
25
|
...sourceRangeProperties(),
|
|
26
26
|
...targetProperties(),
|
|
@@ -28,10 +28,10 @@ export const moveSchema = Type.Object(
|
|
|
28
28
|
{ additionalProperties: false },
|
|
29
29
|
);
|
|
30
30
|
interface MoveParameters {
|
|
31
|
-
readonly path?:
|
|
31
|
+
readonly path?: unknown;
|
|
32
32
|
readonly start?: string;
|
|
33
33
|
readonly end?: string;
|
|
34
|
-
readonly target?:
|
|
34
|
+
readonly target?: unknown;
|
|
35
35
|
readonly targetStart?: string;
|
|
36
36
|
readonly targetEnd?: string;
|
|
37
37
|
}
|
|
@@ -101,13 +101,15 @@ export const moveMutationTool: TextMutationToolRegistration<typeof moveSchema> =
|
|
|
101
101
|
|
|
102
102
|
if (sourceSpan.source === target) {
|
|
103
103
|
return {
|
|
104
|
-
edits: new Map([
|
|
104
|
+
edits: new Map([
|
|
105
|
+
[target, { changes: [deletion, targetChange], action: "edited", resultChanges: [1] }],
|
|
106
|
+
]),
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
return {
|
|
109
111
|
edits: new Map([
|
|
110
|
-
[sourceSpan.source, { changes: [deletion], action: "edited" }],
|
|
112
|
+
[sourceSpan.source, { changes: [deletion], action: "edited", resultChanges: [] }],
|
|
111
113
|
[target, { changes: [targetChange], action: "edited" }],
|
|
112
114
|
]),
|
|
113
115
|
};
|