pi-agent-ide 0.6.3 → 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 +97 -0
- package/README.md +10 -3
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-3HYXQ4YA.js +28 -0
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/chunk-4NIFBFFR.js +11 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-5QQABP47.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-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-O6LE42GK.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/chunk-KBP3QUDT.js +2 -0
- package/dist/chunk-KR36BT5E.js +1 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/chunk-PYPPV2F5.js +25 -0
- package/dist/{chunk-25CZ5ZIU.js → chunk-QFTBY67N.js} +3 -3
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -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-YGGKGZO2.js +1 -0
- package/dist/{chunk-L7JMDDSD.js → chunk-YRF7OATP.js} +1 -1
- package/dist/chunk-ZPT5D4VP.js +2 -0
- package/dist/entry-0.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-16.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 +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 +11 -9
- 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 +12 -11
- 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-55.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-59.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-72.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +50 -307
- package/dist/entry-78.js +14 -26
- package/dist/entry-79.js +2 -2
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -3
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/editing.md +31 -3
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +15 -1
- package/docs/agent-guides/search-code.md +43 -2
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +36 -7
- package/docs/development.md +16 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- 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 +29 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +86 -0
- package/docs/tools.md +24 -4
- 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-documentation/src/index.ts +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +6 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -6
- package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
- 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/overflow-handler.ts +6 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +110 -7
- 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 -24
- package/node_modules/pi-agent-ide-changes/package.json +8 -7
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +126 -48
- 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 +92 -30
- 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 +35 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- 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 +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +22 -0
- package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
- package/node_modules/pi-agent-search/package.json +5 -4
- 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 +13 -6
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +39 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +148 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +90 -24
- package/node_modules/pi-agent-search/src/core/search-core.ts +145 -78
- package/node_modules/pi-agent-search-text/index.ts +6 -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 +174 -26
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +201 -18
- package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +90 -259
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +110 -17
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-document.ts +15 -10
- 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-exact/src/anchor.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 +4 -7
- package/node_modules/pi-agent-text-editor/package.json +20 -21
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +78 -41
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- 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 +35 -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 +2 -0
- 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 +820 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- 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 +412 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +236 -185
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- 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 +9 -73
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +276 -129
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- 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 +23 -0
- package/node_modules/pi-agent-web/package.json +7 -6
- package/node_modules/pi-agent-web/src/search.ts +221 -0
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +42 -37
- package/skills/capture-code-review-rule/SKILL.md +60 -0
- package/src/code-review/config.ts +68 -0
- package/src/code-review/extension.ts +105 -0
- package/src/code-review/fragments.ts +26 -0
- package/src/code-review/reviewer.ts +198 -0
- package/src/composite/host-version.ts +13 -0
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/preferences.ts +0 -5
- package/src/composite/tool-availability.ts +90 -0
- package/src/core/extension.ts +2 -0
- package/src/documentation/extension.ts +81 -145
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
- 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-filesystem/src/path-recovery.ts +109 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +221 -0
- 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 +35 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- 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 +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +6 -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 +174 -26
- 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 +201 -18
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +90 -259
- 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 +110 -17
- 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 +13 -6
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +39 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +148 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +90 -24
- package/src/extensions/pi-agent-search/src/core/search-core.ts +145 -78
- package/src/extensions/pi-agent-text-editor/index.ts +4 -7
- package/src/extensions/pi-agent-text-editor/package.json +20 -21
- 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-exact/src/anchor.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 +9 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +276 -129
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- 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/index.ts +16 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +78 -41
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- 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 +35 -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 +2 -0
- 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 +820 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- 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 +412 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +236 -185
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- 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 +61 -8
- 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/overflow-handler.ts +6 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +110 -7
- 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 -24
- package/src/plugins/pi-agent-ide-changes/package.json +8 -7
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +126 -48
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
- package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
- 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 +92 -30
- package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +16 -37
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
- package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +98 -46
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +35 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-4U2GUKNJ.js +0 -0
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-CEX3VOJ7.js +0 -2
- package/dist/chunk-FA6BKC5Y.js +0 -1
- package/dist/chunk-FEDVTZJG.js +0 -1
- package/dist/chunk-HMLH43ZS.js +0 -4
- package/dist/chunk-ITSNK5YG.js +0 -7
- package/dist/chunk-KII2JQC5.js +0 -1
- package/dist/chunk-LVWMWWWF.js +0 -28
- package/dist/chunk-P7XO5CIP.js +0 -2
- package/dist/chunk-PZFOOHY2.js +0 -15
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-VXD6FZP5.js +0 -5
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-YT42LKFV.js +0 -16
- 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 -155
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- 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 -133
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- 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 -155
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- 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 -133
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
2
|
import {
|
|
3
3
|
createDiffModel,
|
|
4
|
+
compareInlineText,
|
|
4
5
|
DIFF_CONTEXT_LINES,
|
|
5
6
|
type DiffModel,
|
|
6
7
|
type DiffRow,
|
|
@@ -204,7 +205,7 @@ function advanceTypingProjectionResource(
|
|
|
204
205
|
);
|
|
205
206
|
const row = model.rows[rowIndex];
|
|
206
207
|
|
|
207
|
-
if (row === undefined || row.kind === "omitted") {
|
|
208
|
+
if (row === undefined || row.kind === "omitted" || row.beforeLine !== undefined) {
|
|
208
209
|
return undefined;
|
|
209
210
|
}
|
|
210
211
|
|
|
@@ -222,7 +223,7 @@ function advanceTypingProjectionResource(
|
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
const rows = [...model.rows];
|
|
225
|
-
const kind =
|
|
226
|
+
const kind = "added";
|
|
226
227
|
rows[rowIndex] = {
|
|
227
228
|
...row,
|
|
228
229
|
kind,
|
|
@@ -237,8 +238,8 @@ function advanceTypingProjectionResource(
|
|
|
237
238
|
model: {
|
|
238
239
|
...model,
|
|
239
240
|
rows,
|
|
240
|
-
added: model.added +
|
|
241
|
-
modified: model.modified
|
|
241
|
+
added: model.added + 1 - (row.kind === "added" ? 1 : 0),
|
|
242
|
+
modified: model.modified - (row.kind === "modified" ? 1 : 0),
|
|
242
243
|
focusRow: rowIndex,
|
|
243
244
|
},
|
|
244
245
|
};
|
|
@@ -272,6 +273,7 @@ function advanceFullFileTypingResource(
|
|
|
272
273
|
let added = model.added;
|
|
273
274
|
let modified = model.modified;
|
|
274
275
|
const isAfterNewline = previousVisibleText.endsWith("\n");
|
|
276
|
+
const deadline = performance.now() + 100;
|
|
275
277
|
const active = rows.at(-1);
|
|
276
278
|
const suffix = [...fullFileLines(isAfterNewline ? appended : `${active?.text ?? ""}${appended}`)];
|
|
277
279
|
|
|
@@ -281,8 +283,14 @@ function advanceFullFileTypingResource(
|
|
|
281
283
|
requiredValue(suffix[0]),
|
|
282
284
|
rows.length - 1,
|
|
283
285
|
visibleText.endsWith("\n") && suffix.length === 1 && requiredValue(suffix[0]).length === 0,
|
|
286
|
+
suffix.length > 1,
|
|
287
|
+
deadline,
|
|
284
288
|
);
|
|
285
|
-
if (
|
|
289
|
+
if (
|
|
290
|
+
active.text !== next.text ||
|
|
291
|
+
active.kind !== next.kind ||
|
|
292
|
+
active.deletedOffsets?.join(",") !== next.deletedOffsets?.join(",")
|
|
293
|
+
) {
|
|
286
294
|
added += (next.kind === "added" ? 1 : 0) - (active.kind === "added" ? 1 : 0);
|
|
287
295
|
modified += (next.kind === "modified" ? 1 : 0) - (active.kind === "modified" ? 1 : 0);
|
|
288
296
|
rows[rows.length - 1] = next;
|
|
@@ -296,6 +304,8 @@ function advanceFullFileTypingResource(
|
|
|
296
304
|
text,
|
|
297
305
|
rows.length,
|
|
298
306
|
offset === suffix.length - 1 && visibleText.endsWith("\n"),
|
|
307
|
+
offset < suffix.length - 1,
|
|
308
|
+
deadline,
|
|
299
309
|
);
|
|
300
310
|
rows.push(row);
|
|
301
311
|
modified += row.kind === "modified" ? 1 : 0;
|
|
@@ -326,6 +336,8 @@ function createTypingLine(
|
|
|
326
336
|
text: string,
|
|
327
337
|
index: number,
|
|
328
338
|
isTrailingCursorRow = false,
|
|
339
|
+
complete = false,
|
|
340
|
+
deadline = performance.now() + 100,
|
|
329
341
|
): DiffRow {
|
|
330
342
|
const beforeText = beforeLines[index];
|
|
331
343
|
if (isTrailingCursorRow || beforeText?.trim() === text.trim()) {
|
|
@@ -344,7 +356,7 @@ function createTypingLine(
|
|
|
344
356
|
...(beforeText !== undefined && { beforeLine: index + 1 }),
|
|
345
357
|
afterLine: index + 1,
|
|
346
358
|
changed: true,
|
|
347
|
-
|
|
359
|
+
...typingChanges(beforeText, text, complete, deadline),
|
|
348
360
|
};
|
|
349
361
|
}
|
|
350
362
|
|
|
@@ -462,9 +474,8 @@ function createTypingModel(
|
|
|
462
474
|
project: false,
|
|
463
475
|
focusAfterLine: cursorLine,
|
|
464
476
|
} as const;
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
);
|
|
477
|
+
const visibleModel = createDiffModel(beforeWindow, afterWindow, [], modelOptions);
|
|
478
|
+
const rows = visibleModel.rows.flatMap(projectTypingRow);
|
|
468
479
|
const focusRow = typingFocusRow(rows, cursorLine);
|
|
469
480
|
const finalAfterWindow =
|
|
470
481
|
resource.beforeContent.slice(windowFrom, beforeRange.from) +
|
|
@@ -483,6 +494,9 @@ function createTypingModel(
|
|
|
483
494
|
|
|
484
495
|
return {
|
|
485
496
|
rows: canonicalRows,
|
|
497
|
+
...(visibleModel.omittedChanges !== undefined && {
|
|
498
|
+
omittedChanges: visibleModel.omittedChanges,
|
|
499
|
+
}),
|
|
486
500
|
added: canonicalRows.filter(({ kind }) => kind === "added").length,
|
|
487
501
|
modified: canonicalRows.filter(({ kind }) => kind === "modified").length,
|
|
488
502
|
removed: 0,
|
|
@@ -510,6 +524,7 @@ function createFullFileTypingModel(
|
|
|
510
524
|
): DiffModel {
|
|
511
525
|
const beforeLines = fullFileLines(beforeContent);
|
|
512
526
|
const visibleLines = fullFileLines(visibleContent);
|
|
527
|
+
const deadline = performance.now() + 100;
|
|
513
528
|
const cursorLine = lineAtOffset(visibleContent, cursorOffset);
|
|
514
529
|
const rows: DiffRow[] = visibleLines.map((text, index) => {
|
|
515
530
|
const line = index + 1;
|
|
@@ -536,7 +551,7 @@ function createFullFileTypingModel(
|
|
|
536
551
|
...(beforeText !== undefined && { beforeLine: line }),
|
|
537
552
|
afterLine: line,
|
|
538
553
|
changed: true,
|
|
539
|
-
|
|
554
|
+
...typingChanges(beforeText, text, index < visibleLines.length - 1, deadline),
|
|
540
555
|
};
|
|
541
556
|
});
|
|
542
557
|
|
|
@@ -565,6 +580,21 @@ function projectTypingRow(row: DiffRow): readonly DiffRow[] {
|
|
|
565
580
|
return row.kind === "added" ? [{ ...row, addedRanges: typingTextRanges(row.text) }] : [row];
|
|
566
581
|
}
|
|
567
582
|
|
|
583
|
+
function typingChanges(
|
|
584
|
+
before: string | undefined,
|
|
585
|
+
after: string,
|
|
586
|
+
complete: boolean,
|
|
587
|
+
deadline: number,
|
|
588
|
+
) {
|
|
589
|
+
if (before === undefined) return { addedRanges: typingTextRanges(after) };
|
|
590
|
+
const changes = compareInlineText(before, after, deadline);
|
|
591
|
+
return changes === undefined
|
|
592
|
+
? { addedRanges: [], inlineUnavailable: true }
|
|
593
|
+
: {
|
|
594
|
+
...changes,
|
|
595
|
+
deletedOffsets: complete ? changes.deletedOffsets : [],
|
|
596
|
+
};
|
|
597
|
+
}
|
|
568
598
|
function typingTextRanges(text: string): readonly DiffTextRange[] {
|
|
569
599
|
const from = text.length - text.trimStart().length;
|
|
570
600
|
const to = text.trimEnd().length;
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts
CHANGED
|
@@ -271,21 +271,9 @@ function createRenderer(
|
|
|
271
271
|
);
|
|
272
272
|
state.panel?.setPreviewResources([]);
|
|
273
273
|
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
const succeeded = restored !== undefined && !context.isError;
|
|
277
|
-
return new Text(
|
|
278
|
-
theme.fg(
|
|
279
|
-
succeeded ? "success" : "error",
|
|
280
|
-
succeeded
|
|
281
|
-
? `✓ Undo applied · ${String(restored)} ${restored === 1 ? "file" : "files"}`
|
|
282
|
-
: "✗ Undo not applied",
|
|
283
|
-
),
|
|
284
|
-
0,
|
|
285
|
-
0,
|
|
286
|
-
);
|
|
274
|
+
if (!context.isError && result.details.metadata?.emptyTargets === true) {
|
|
275
|
+
return new Text(theme.fg("muted", "No changes · empty target set"), 0, 0);
|
|
287
276
|
}
|
|
288
|
-
|
|
289
277
|
const wholeFileSucceeded = wholeFileOperationSucceeded(result.details);
|
|
290
278
|
if (wholeFileSucceeded !== undefined) {
|
|
291
279
|
return new Text(
|
|
@@ -721,7 +709,14 @@ function mutationCallDetails(
|
|
|
721
709
|
|
|
722
710
|
const generated = generatedField(tool);
|
|
723
711
|
return Object.entries(input).map(([label, value]) => {
|
|
724
|
-
const encoded =
|
|
712
|
+
const encoded =
|
|
713
|
+
["path", "file", "target"].includes(label) && value !== null && typeof value === "object"
|
|
714
|
+
? Array.isArray(value)
|
|
715
|
+
? `${value.length} returned targets`
|
|
716
|
+
: "result scope"
|
|
717
|
+
: typeof value === "string"
|
|
718
|
+
? value
|
|
719
|
+
: JSON.stringify(value);
|
|
725
720
|
const exact = typeof encoded === "string" ? encoded : String(value);
|
|
726
721
|
return {
|
|
727
722
|
label,
|
|
@@ -733,14 +728,13 @@ function mutationCallDetails(
|
|
|
733
728
|
});
|
|
734
729
|
}
|
|
735
730
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
): string {
|
|
742
|
-
return renderHeader(registration, input, undefined, theme, undefined, false);
|
|
731
|
+
function sourceLabel(value: unknown): string | undefined {
|
|
732
|
+
if (typeof value === "string" && value.startsWith("RESULT#")) return "result scope";
|
|
733
|
+
return (
|
|
734
|
+
stringValue(value) ?? (value !== null && typeof value === "object" ? "result scope" : undefined)
|
|
735
|
+
);
|
|
743
736
|
}
|
|
737
|
+
|
|
744
738
|
function renderHeader(
|
|
745
739
|
registration: AnyTextMutationToolRegistration,
|
|
746
740
|
input: Readonly<Record<string, unknown>>,
|
|
@@ -750,9 +744,7 @@ function renderHeader(
|
|
|
750
744
|
expanded: boolean,
|
|
751
745
|
): string {
|
|
752
746
|
const source = registration.source;
|
|
753
|
-
|
|
754
|
-
return `${theme.fg("toolTitle", theme.bold("undo"))} ${theme.fg("muted", "· Apply transaction")}`;
|
|
755
|
-
const path = stringValue(input[source.field]);
|
|
747
|
+
const path = sourceLabel(input[source.field]);
|
|
756
748
|
const previewResources = preview?.kind === "completed" ? preview.resources : [];
|
|
757
749
|
const displayedPath =
|
|
758
750
|
path ??
|
|
@@ -766,10 +758,10 @@ function renderHeader(
|
|
|
766
758
|
? requiredValue(previewResources[0]).link
|
|
767
759
|
: resourceLink(preview, path);
|
|
768
760
|
const targets = (source.targets ?? [])
|
|
769
|
-
.map(({ field }) => ({ field, path:
|
|
761
|
+
.map(({ field }) => ({ field, path: sourceLabel(input[field]) }))
|
|
770
762
|
.filter(
|
|
771
763
|
(target): target is { readonly field: string; readonly path: string } =>
|
|
772
|
-
target.path !== undefined && target.path !== path,
|
|
764
|
+
target.path !== undefined && (target.path === "result scope" || target.path !== path),
|
|
773
765
|
);
|
|
774
766
|
let header = `${theme.fg("toolTitle", theme.bold(registration.name))} ${renderPath(
|
|
775
767
|
displayedPath,
|
|
@@ -864,24 +856,6 @@ function semanticRange(start: string, end: string): string {
|
|
|
864
856
|
: `${start}–${end}`;
|
|
865
857
|
}
|
|
866
858
|
|
|
867
|
-
function restoredApplyPathCount(details: unknown): number | undefined {
|
|
868
|
-
if (details === null || typeof details !== "object" || !("metadata" in details)) return undefined;
|
|
869
|
-
const metadata = details.metadata;
|
|
870
|
-
if (metadata === null || typeof metadata !== "object" || !("semanticAction" in metadata))
|
|
871
|
-
return undefined;
|
|
872
|
-
const action = metadata.semanticAction;
|
|
873
|
-
if (
|
|
874
|
-
action === null ||
|
|
875
|
-
typeof action !== "object" ||
|
|
876
|
-
!("kind" in action) ||
|
|
877
|
-
action.kind !== "apply-undo" ||
|
|
878
|
-
!("restored" in action) ||
|
|
879
|
-
!Array.isArray(action.restored)
|
|
880
|
-
)
|
|
881
|
-
return undefined;
|
|
882
|
-
return action.restored.length;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
859
|
function wholeFileOperationSucceeded(details: unknown): boolean | undefined {
|
|
886
860
|
if (details === null || typeof details !== "object" || !("metadata" in details)) return undefined;
|
|
887
861
|
const metadata = details.metadata;
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ function createHandler(
|
|
|
77
77
|
const toolNames: string[] = [];
|
|
78
78
|
const knownPaths = new Map<number, string>();
|
|
79
79
|
const checks = new Map<number, Map<string, TextAnchorInspectionOutcome>>();
|
|
80
|
+
const blocks = new Map<number, Map<string, InterceptResult>>();
|
|
80
81
|
|
|
81
82
|
const handler: ToolCallInterceptorHandler = {
|
|
82
83
|
name: "text-editor-stale-anchor-inspection",
|
|
@@ -110,6 +111,7 @@ function createHandler(
|
|
|
110
111
|
arguments_,
|
|
111
112
|
source,
|
|
112
113
|
checks,
|
|
114
|
+
blocks,
|
|
113
115
|
);
|
|
114
116
|
|
|
115
117
|
if (pairBlock !== undefined) {
|
|
@@ -146,6 +148,7 @@ function createHandler(
|
|
|
146
148
|
[anchor],
|
|
147
149
|
[descriptor.kinds],
|
|
148
150
|
checks,
|
|
151
|
+
blocks,
|
|
149
152
|
);
|
|
150
153
|
|
|
151
154
|
if (block !== undefined) {
|
|
@@ -157,13 +160,16 @@ function createHandler(
|
|
|
157
160
|
},
|
|
158
161
|
onContentEnd(contentIndex) {
|
|
159
162
|
checks.delete(contentIndex);
|
|
163
|
+
blocks.delete(contentIndex);
|
|
160
164
|
},
|
|
161
165
|
onAbort(contentIndex) {
|
|
162
166
|
checks.delete(contentIndex);
|
|
167
|
+
blocks.delete(contentIndex);
|
|
163
168
|
knownPaths.delete(contentIndex);
|
|
164
169
|
},
|
|
165
170
|
onAgentEnd() {
|
|
166
171
|
checks.clear();
|
|
172
|
+
blocks.clear();
|
|
167
173
|
knownPaths.clear();
|
|
168
174
|
},
|
|
169
175
|
};
|
|
@@ -225,6 +231,7 @@ async function inspectAnchorPair(
|
|
|
225
231
|
arguments_: Record<string, unknown>,
|
|
226
232
|
source: string,
|
|
227
233
|
checks: Map<number, Map<string, TextAnchorInspectionOutcome>>,
|
|
234
|
+
blocks: Map<number, Map<string, InterceptResult>>,
|
|
228
235
|
): Promise<InterceptResult | undefined> {
|
|
229
236
|
if (schema.pair === undefined) {
|
|
230
237
|
return undefined;
|
|
@@ -261,6 +268,7 @@ async function inspectAnchorPair(
|
|
|
261
268
|
[start, end],
|
|
262
269
|
[startDescriptor.kinds, endDescriptor.kinds],
|
|
263
270
|
checks,
|
|
271
|
+
blocks,
|
|
264
272
|
);
|
|
265
273
|
}
|
|
266
274
|
|
|
@@ -273,6 +281,7 @@ async function inspectAnchors(
|
|
|
273
281
|
anchors: readonly [string] | readonly [string, string],
|
|
274
282
|
kinds: readonly [readonly string[]] | readonly [readonly string[], readonly string[]],
|
|
275
283
|
checks: Map<number, Map<string, TextAnchorInspectionOutcome>>,
|
|
284
|
+
blocks: Map<number, Map<string, InterceptResult>>,
|
|
276
285
|
): Promise<InterceptResult | undefined> {
|
|
277
286
|
const contentIndex = context.contentIndex ?? -1;
|
|
278
287
|
const key = `${source}${CACHE_KEY_PART_SEPARATOR}${anchors.join(
|
|
@@ -280,6 +289,8 @@ async function inspectAnchors(
|
|
|
280
289
|
)}${CACHE_KEY_PART_SEPARATOR}${kinds
|
|
281
290
|
.map((accepted) => accepted.join(CACHE_KEY_LIST_SEPARATOR))
|
|
282
291
|
.join(CACHE_KEY_PART_SEPARATOR)}`;
|
|
292
|
+
const cachedBlock = blocks.get(contentIndex)?.get(key);
|
|
293
|
+
if (cachedBlock !== undefined) return cachedBlock;
|
|
283
294
|
let result = checks.get(contentIndex)?.get(key);
|
|
284
295
|
|
|
285
296
|
if (result === undefined) {
|
|
@@ -337,7 +348,11 @@ async function inspectAnchors(
|
|
|
337
348
|
...(!(readContext === undefined || readContext.length === 0) && { context: readContext }),
|
|
338
349
|
};
|
|
339
350
|
|
|
340
|
-
|
|
351
|
+
const block = makeBlockResult(details, result.reason);
|
|
352
|
+
const contentBlocks = blocks.get(contentIndex) ?? new Map<string, InterceptResult>();
|
|
353
|
+
contentBlocks.set(key, block);
|
|
354
|
+
blocks.set(contentIndex, contentBlocks);
|
|
355
|
+
return block;
|
|
341
356
|
}
|
|
342
357
|
|
|
343
358
|
function makeResolverBlockResult(
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.
|
|
7
|
-
"pi-agent-read": "0.
|
|
8
|
-
"pi-agent-text-editor": "0.
|
|
6
|
+
"pi-agent-invariant": "0.7.0",
|
|
7
|
+
"pi-agent-read": "0.7.0",
|
|
8
|
+
"pi-agent-text-editor": "0.7.0"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
@@ -15,6 +15,8 @@ export type TextMutationPreviewRanges = readonly TextMutationPreviewRange[];
|
|
|
15
15
|
export interface TextMutationPreviewResource {
|
|
16
16
|
readonly path: string;
|
|
17
17
|
readonly existed?: boolean;
|
|
18
|
+
/** Resolver that owns this snapshot and its write policy. */
|
|
19
|
+
readonly resolvedBy?: string;
|
|
18
20
|
readonly beforeRanges?: TextMutationPreviewRanges;
|
|
19
21
|
readonly link?: string;
|
|
20
22
|
readonly ranges: readonly TextMutationPreviewRange[];
|
|
@@ -25,3 +25,9 @@ export {
|
|
|
25
25
|
} from "#src/core/mutation-result/file-mutation-result.js";
|
|
26
26
|
|
|
27
27
|
export { type ChangedRange, computeChangedRanges } from "#src/core/mutation-result/diff.js";
|
|
28
|
+
export {
|
|
29
|
+
mutationDataSchema,
|
|
30
|
+
mutationOutputSchema,
|
|
31
|
+
structuredMutation,
|
|
32
|
+
type MutationData,
|
|
33
|
+
} from "#src/core/structured-result.js";
|
|
@@ -6,6 +6,8 @@ import type { Static, TSchema } from "typebox";
|
|
|
6
6
|
export interface TextMutationEdit {
|
|
7
7
|
readonly changes: readonly TextChange[];
|
|
8
8
|
readonly action: "edited" | "overwritten";
|
|
9
|
+
/** Indices of changes that produce live output targets; omit to select all, or use [] for removals. */
|
|
10
|
+
readonly resultChanges?: readonly number[];
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export interface TextMutation {
|
|
@@ -64,7 +66,7 @@ export interface TextSemanticMutationResult {
|
|
|
64
66
|
readonly source: string;
|
|
65
67
|
/** Compact agent-facing outcome. */
|
|
66
68
|
readonly summary: string;
|
|
67
|
-
/** Structured receipt
|
|
69
|
+
/** Structured receipt for standalone tools and native Codemode. */
|
|
68
70
|
readonly data: Readonly<Record<string, unknown>>;
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { FileMutationBatchResult } from "./mutation-result.js";
|
|
3
|
+
|
|
4
|
+
/** A finished native editor batch, sent through Pi's event bus without saving raw snapshots. */
|
|
5
|
+
export interface NativeEditBatchEvent {
|
|
6
|
+
readonly parentToolCallId: string;
|
|
7
|
+
readonly calls: readonly string[];
|
|
8
|
+
readonly result: AgentToolResult<FileMutationBatchResult>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Presentation listeners must compact the result before retaining it in history. */
|
|
12
|
+
export const NATIVE_EDIT_BATCH_EVENT = "pi-agent-text-editor:native-batch-finished";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { AgentToolResult, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { TSchema } from "typebox";
|
|
3
1
|
import { isResourceResolver, type ResourceResolver } from "pi-agent-resource";
|
|
4
2
|
import {
|
|
5
3
|
isTextAnchorResolver,
|
|
@@ -28,19 +26,9 @@ import type {
|
|
|
28
26
|
} from "#src/api/mutation-tool.js";
|
|
29
27
|
import type { TextEditorToolRendererRegistration } from "#src/api/tool-renderer.js";
|
|
30
28
|
|
|
31
|
-
/** Shared index operations; Apply uses the same implementation and guards as standalone tools. */
|
|
32
|
-
export interface ScriptIndexOperation {
|
|
33
|
-
readonly name: "stage" | "unstage";
|
|
34
|
-
readonly parameters: TSchema;
|
|
35
|
-
execute(
|
|
36
|
-
input: unknown,
|
|
37
|
-
signal: AbortSignal,
|
|
38
|
-
context: ExtensionContext,
|
|
39
|
-
): Promise<AgentToolResult<unknown>>;
|
|
40
|
-
}
|
|
41
29
|
export const TEXT_EDITOR_PROTOCOL = "pi-agent-text-editor";
|
|
42
30
|
|
|
43
|
-
export const TEXT_EDITOR_API_VERSION =
|
|
31
|
+
export const TEXT_EDITOR_API_VERSION = 23;
|
|
44
32
|
|
|
45
33
|
export const TEXT_POSITION_ANCHOR_KIND = "pi-agent-text-editor/position";
|
|
46
34
|
|
|
@@ -92,11 +80,6 @@ export interface TextEditorRecoveryConfigSection {
|
|
|
92
80
|
readonly settings: unknown;
|
|
93
81
|
}
|
|
94
82
|
export interface TextEditorPluginApi {
|
|
95
|
-
/** Restore a session-scoped Apply transaction receipt atomically. */
|
|
96
|
-
restoreApplyUndo(
|
|
97
|
-
transaction: string,
|
|
98
|
-
signal?: AbortSignal,
|
|
99
|
-
): Promise<{ readonly transaction: string; readonly restored: readonly string[] }>;
|
|
100
83
|
addResolver(registration: ResourceResolverRegistration): void;
|
|
101
84
|
inspectTextAnchors(request: TextAnchorInspectionRequest): Promise<TextAnchorInspectionOutcome>;
|
|
102
85
|
addAnchorResolver(registration: TextAnchorResolverRegistration): void;
|
|
@@ -106,8 +89,6 @@ export interface TextEditorPluginApi {
|
|
|
106
89
|
addMutationTool(registration: TextMutationToolRegistration): void;
|
|
107
90
|
addMutationGuard(registration: TextMutationGuardRegistration): void;
|
|
108
91
|
addToolRenderer(registration: TextEditorToolRendererRegistration): void;
|
|
109
|
-
/** Register an index operation for Apply without exposing unrelated Pi tools. */
|
|
110
|
-
addScriptIndexOperation(operation: ScriptIndexOperation): void;
|
|
111
92
|
onMutationTool(listener: TextMutationToolListener): () => void;
|
|
112
93
|
onDidEdit(listener: TextEditCompletionListener): () => void;
|
|
113
94
|
previewMutation(request: TextMutationPreviewRequest): Promise<TextMutationPreviewOutcome>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
/** Withdraws Pi's built-in edit from declarations, discovery and nested execution. */
|
|
5
|
+
export function hideBuiltinEdit(pi: ExtensionAPI): void {
|
|
6
|
+
pi.registerTool({
|
|
7
|
+
name: "edit",
|
|
8
|
+
label: "edit",
|
|
9
|
+
description: "",
|
|
10
|
+
exposure: "hidden",
|
|
11
|
+
parameters: Type.Object({}, { additionalProperties: false }),
|
|
12
|
+
execute() {
|
|
13
|
+
throw new Error("Hidden edit must never execute.");
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -8,15 +8,30 @@ import {
|
|
|
8
8
|
import { Text } from "@earendil-works/pi-tui";
|
|
9
9
|
import { Type, type Static } from "typebox";
|
|
10
10
|
import { Value } from "typebox/value";
|
|
11
|
-
import {
|
|
12
|
-
readParameters,
|
|
13
|
-
type ReadScriptData,
|
|
14
|
-
type ReadToolResult,
|
|
15
|
-
} from "pi-agent-read/api/tools/read";
|
|
11
|
+
import { readParameters, type ReadScriptData } from "pi-agent-read/api/tools/read";
|
|
16
12
|
import type { ReadPluginApi } from "pi-agent-read/api/plugin-protocol";
|
|
17
13
|
import type { TextEditorCore } from "#src/core/text-editor-core.js";
|
|
18
14
|
import { createUnifiedDiff, type DiffStats } from "#src/core/mutation-result/diff.js";
|
|
19
15
|
import { FileMutationResult } from "#src/core/mutation-result/file-mutation-result.js";
|
|
16
|
+
import { resultError, structuredResultSchema, withStructuredResult } from "pi-agent-resource";
|
|
17
|
+
const comparisonSourceSchema = Type.Object(
|
|
18
|
+
{ source: Type.String(), sources: Type.Array(Type.String()) },
|
|
19
|
+
{ additionalProperties: false },
|
|
20
|
+
);
|
|
21
|
+
export const diffDataSchema = Type.Object(
|
|
22
|
+
{
|
|
23
|
+
kind: Type.Literal("diff"),
|
|
24
|
+
equal: Type.Boolean(),
|
|
25
|
+
before: comparisonSourceSchema,
|
|
26
|
+
after: comparisonSourceSchema,
|
|
27
|
+
stats: Type.Object({ added: Type.Integer(), removed: Type.Integer() }),
|
|
28
|
+
diff: Type.String(),
|
|
29
|
+
truncated: Type.Boolean(),
|
|
30
|
+
fullResult: Type.Optional(Type.String()),
|
|
31
|
+
},
|
|
32
|
+
{ additionalProperties: false },
|
|
33
|
+
);
|
|
34
|
+
export const diffOutputSchema = structuredResultSchema(diffDataSchema);
|
|
20
35
|
|
|
21
36
|
const source = Type.Union([Type.String({ minLength: 1 }), readParameters]);
|
|
22
37
|
/** Each side accepts a source string or the same request object as read. */
|
|
@@ -30,7 +45,7 @@ interface ComparisonText {
|
|
|
30
45
|
readonly sources: readonly string[];
|
|
31
46
|
readonly content: string;
|
|
32
47
|
}
|
|
33
|
-
/** Full comparison data
|
|
48
|
+
/** Full comparison data; this is not an edit receipt. */
|
|
34
49
|
export interface DiffOutcome {
|
|
35
50
|
readonly kind: "diff";
|
|
36
51
|
readonly ok: true;
|
|
@@ -106,17 +121,6 @@ export function comparisonText(data: ReadScriptData, requested: string): Compari
|
|
|
106
121
|
};
|
|
107
122
|
}
|
|
108
123
|
|
|
109
|
-
/** Recognize comparison results without confusing them with mutations. */
|
|
110
|
-
export function isDiffOutcome(value: unknown): value is DiffOutcome {
|
|
111
|
-
return (
|
|
112
|
-
value !== null &&
|
|
113
|
-
typeof value === "object" &&
|
|
114
|
-
"kind" in value &&
|
|
115
|
-
value.kind === "diff" &&
|
|
116
|
-
"ok" in value &&
|
|
117
|
-
value.ok === true
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
124
|
/** Reuse the editor panel's existing before/after presentation contract, without executing edits. */
|
|
121
125
|
export function diffPresentation(value: DiffOutcome, cwd = process.cwd()) {
|
|
122
126
|
const displaySource = (source: string) =>
|
|
@@ -140,12 +144,8 @@ export function diffText(value: DiffOutcome): string {
|
|
|
140
144
|
? `No differences: ${value.before.source} → ${value.after.source}`
|
|
141
145
|
: value.diff;
|
|
142
146
|
}
|
|
143
|
-
/** Presentation remains separate from complete comparison data. */
|
|
144
|
-
export function diffReadResult(value: DiffOutcome): ReadToolResult {
|
|
145
|
-
return { content: [{ type: "text", text: diffText(value) }], details: {} };
|
|
146
|
-
}
|
|
147
147
|
|
|
148
|
-
/**
|
|
148
|
+
/** Compare sources through the shared read service and configured editor renderer. */
|
|
149
149
|
export function registerDiff(
|
|
150
150
|
pi: ExtensionAPI,
|
|
151
151
|
editor: TextEditorCore,
|
|
@@ -153,11 +153,21 @@ export function registerDiff(
|
|
|
153
153
|
): void {
|
|
154
154
|
pi.registerTool({
|
|
155
155
|
name: "diff",
|
|
156
|
+
exposure: "direct",
|
|
157
|
+
namespace: { name: "ide_read", description: "Read resources and compare sources." },
|
|
158
|
+
// Inputs use the same polymorphic resource pipeline as Read.
|
|
159
|
+
annotations: {
|
|
160
|
+
readOnlyHint: false,
|
|
161
|
+
destructiveHint: true,
|
|
162
|
+
idempotentHint: false,
|
|
163
|
+
openWorldHint: true,
|
|
164
|
+
},
|
|
156
165
|
label: "Diff",
|
|
157
166
|
parameters: diffParameters,
|
|
167
|
+
outputSchema: diffOutputSchema,
|
|
158
168
|
promptSnippet: "Compare two text-readable sources",
|
|
159
169
|
description:
|
|
160
|
-
"Use diff to compare two sources. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference.
|
|
170
|
+
"Use diff to compare two sources. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference.",
|
|
161
171
|
renderCall(_args, theme) {
|
|
162
172
|
return new Text(theme.fg("toolTitle", theme.bold("Diff")), 0, 0);
|
|
163
173
|
},
|
|
@@ -180,26 +190,53 @@ export function registerDiff(
|
|
|
180
190
|
async execute(_id, args, signal, _update, context) {
|
|
181
191
|
const read = getRead();
|
|
182
192
|
if (read === undefined) throw new Error("Diff requires the read extension");
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
try {
|
|
194
|
+
const comparison = await executeDiff(read, args, { cwd: context.cwd, signal });
|
|
195
|
+
const full = diffText(comparison);
|
|
196
|
+
const bounded = truncateHead(full);
|
|
197
|
+
const temporarySource = bounded.truncated ? await read.saveTemporary(full) : undefined;
|
|
198
|
+
const footer = temporarySource === undefined ? "" : `\nFull diff: ${temporarySource}`;
|
|
199
|
+
return withStructuredResult(
|
|
200
|
+
{
|
|
201
|
+
content: [
|
|
202
|
+
{
|
|
203
|
+
type: "text" as const,
|
|
204
|
+
text:
|
|
205
|
+
temporarySource === undefined
|
|
206
|
+
? full
|
|
207
|
+
: truncateHead(full, {
|
|
208
|
+
maxLines: DEFAULT_MAX_LINES - 2,
|
|
209
|
+
maxBytes: DEFAULT_MAX_BYTES - Buffer.byteLength(footer),
|
|
210
|
+
}).content + footer,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
details: { ...diffPresentation(comparison, context.cwd), comparison, temporarySource },
|
|
214
|
+
},
|
|
215
|
+
diffDataSchema,
|
|
190
216
|
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
217
|
+
status: "success",
|
|
218
|
+
data: {
|
|
219
|
+
kind: "diff",
|
|
220
|
+
equal: comparison.equal,
|
|
221
|
+
before: { source: comparison.before.source, sources: comparison.before.sources },
|
|
222
|
+
after: { source: comparison.after.source, sources: comparison.after.sources },
|
|
223
|
+
stats: comparison.stats,
|
|
224
|
+
diff: bounded.content,
|
|
225
|
+
truncated: bounded.truncated,
|
|
226
|
+
...(temporarySource === undefined ? {} : { fullResult: temporarySource }),
|
|
227
|
+
},
|
|
228
|
+
errors: [],
|
|
199
229
|
},
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
230
|
+
);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (signal?.aborted) throw error;
|
|
233
|
+
const failure = resultError(error, "DIFF_FAILED");
|
|
234
|
+
return withStructuredResult(
|
|
235
|
+
{ content: [{ type: "text", text: failure.message }], details: {} },
|
|
236
|
+
diffDataSchema,
|
|
237
|
+
{ status: "error", errors: [failure] },
|
|
238
|
+
);
|
|
239
|
+
}
|
|
203
240
|
},
|
|
204
241
|
});
|
|
205
242
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Shared editing workflows owned by enabled mutation tools. */
|
|
2
|
+
export const EDITING_GUIDELINES = [
|
|
3
|
+
"Use the smallest useful source view: reuse sufficient content and anchors, search for known text, or inspect structure when locating a declaration. Read nearby context when boundaries are unclear; resolve ambiguity rather than guessing.",
|
|
4
|
+
"Use an available anchor when it selects exactly the intended text; otherwise use minimal unique exact text. Keep the edit limited to the intended content.",
|
|
5
|
+
"When search broadens to separate words, treat its results as location hints. Refine the query before using those matches for replacement.",
|
|
6
|
+
"Use standalone mutation tools in one assistant-response batch when each change is known in advance and does not depend on another change. This is the default for several independent edits in one file or across files. Every call is evaluated against the original file snapshots. Combine overlapping changes into one mutation. Use native Codemode for computed or dependent tool composition; it keeps the same tool contracts and does not add grouped rollback. Check each batch result and retry only unapplied changes.",
|
|
7
|
+
"Inside native Codemode, submit independent local text-edit calls on disjoint resource sets concurrently; await calls on overlapping sets in order. Check each result's status. Await tools.flush({}) when later script work needs a committed receipt. Check the parent result for automatic batch commits before retrying an accepted call. Read docs:editing for batch boundaries and dependent work.",
|
|
8
|
+
] as const;
|