pi-agent-ide 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/{chunk-2ZMYT6ZC.js → chunk-4U6KGABH.js} +1 -1
- package/dist/chunk-4ZTEPMJO.js +14 -0
- package/dist/{chunk-KNMWCDDK.js → chunk-6ACQQBUY.js} +1 -1
- package/dist/chunk-76WHES5H.js +7 -0
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/chunk-GFWDXTOB.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/chunk-JJVXUL5U.js +2 -0
- package/dist/chunk-KCEOTU5Z.js +3 -0
- package/dist/chunk-KVGQG43U.js +1 -0
- package/dist/{chunk-MTTKFJV6.js → chunk-LQYZG62K.js} +1 -1
- package/dist/{chunk-PETQCA7G.js → chunk-P6T3Q7LB.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-QJFRAMK7.js +2 -0
- package/dist/{chunk-2SKAED2I.js → chunk-RAZOACDD.js} +2 -2
- package/dist/chunk-RIGRP3FD.js +1 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/{chunk-266RH77Z.js → chunk-THSCUT2L.js} +1 -1
- package/dist/{chunk-EEH4WYI7.js → chunk-WNMGUALD.js} +1 -1
- package/dist/{chunk-ZIHEF6K3.js → chunk-X6MPU7UO.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-XF5PVZOS.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZXN3TWWW.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-10.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-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +7 -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 +4 -1
- package/dist/entry-32.js +8 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +14 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-69.js +59 -1
- package/dist/entry-70.js +4 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +29 -1
- package/dist/entry-73.js +2 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/pi-agent-ide.js +2 -13
- package/docs/configuration.md +25 -0
- package/docs/extensions.md +4 -2
- package/docs/tools.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- 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 +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -14
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-changes/index.ts +1 -5
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +4 -1
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +1 -12
- package/node_modules/pi-agent-ide-lsp/package.json +8 -8
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +7 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +8 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- 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-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -26
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/core/extension.ts +7 -5
- package/node_modules/pi-agent-search/src/core/search-core.ts +10 -0
- package/node_modules/pi-agent-search-text/index.ts +42 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +48 -0
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- 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/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +6 -6
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-argument-order/package.json +2 -2
- package/node_modules/pi-agent-text-editor-overwrite/package.json +3 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +6 -6
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/api/plugin-protocol.ts +2 -0
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +4 -0
- package/src/composite/builtin-extensions.ts +148 -66
- package/src/composite/extensions-config.ts +18 -0
- package/src/core/diagnostic-entry.ts +94 -0
- package/src/core/diagnostic-store.ts +43 -21
- package/src/core/extension.ts +39 -17
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -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-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 +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +6 -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-html/src/html-converter.ts +1 -1
- 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/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -26
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +42 -33
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +48 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +7 -5
- package/src/extensions/pi-agent-search/src/core/search-core.ts +10 -0
- package/src/extensions/pi-agent-text-editor/package.json +6 -6
- 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/index.ts +2 -6
- 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-argument-order/package.json +2 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -14
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +1 -5
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +1 -16
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +4 -1
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +1 -12
- package/src/plugins/pi-agent-ide-lsp/package.json +8 -8
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +7 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +8 -1
- package/src/post-edit/gate.ts +44 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
|
@@ -7,12 +7,19 @@ import {
|
|
|
7
7
|
TEXT_EDITOR_PROTOCOL,
|
|
8
8
|
} from "#src/api/plugin-protocol.js";
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
DiagnosticHint,
|
|
12
|
+
MutationFormatting,
|
|
13
|
+
MutationDiffStatus,
|
|
14
|
+
SyntaxErrorSummary,
|
|
15
|
+
Warning,
|
|
16
|
+
} from "#src/api/mutation-result.js";
|
|
11
17
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
18
|
import type { TextDocument } from "pi-agent-text";
|
|
13
19
|
|
|
14
20
|
export const TEXT_EDITOR_POST_EDIT_REGISTER_EVENT = `${TEXT_EDITOR_PROTOCOL}/post-edit/register`;
|
|
15
21
|
|
|
22
|
+
/** The saved edit before post-processing; handlers run inside the file's mutation queue. */
|
|
16
23
|
export interface TextPostEditTransaction {
|
|
17
24
|
readonly source: string;
|
|
18
25
|
readonly resourceSource: string;
|
|
@@ -35,6 +42,63 @@ export interface TextMutationResultContributionData {
|
|
|
35
42
|
readonly syntaxErrorSummary?: SyntaxErrorSummary;
|
|
36
43
|
}
|
|
37
44
|
|
|
45
|
+
/** Validates formatter metadata supplied by a post-edit integration. */
|
|
46
|
+
export function isFormattingContribution(
|
|
47
|
+
value: unknown,
|
|
48
|
+
): value is { formatting: MutationFormatting } {
|
|
49
|
+
return Value.Check(
|
|
50
|
+
Type.Object({
|
|
51
|
+
formatting: Type.Object({
|
|
52
|
+
status: Type.Union(
|
|
53
|
+
[
|
|
54
|
+
"disabled",
|
|
55
|
+
"unavailable",
|
|
56
|
+
"skipped-syntax",
|
|
57
|
+
"unchanged",
|
|
58
|
+
"changed",
|
|
59
|
+
"failed",
|
|
60
|
+
"not-reported",
|
|
61
|
+
].map((status) => Type.Literal(status)),
|
|
62
|
+
),
|
|
63
|
+
formatter: Type.Optional(Type.String()),
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
value,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Return this data from a post-edit handler to add statuses to that file's diff.
|
|
72
|
+
* All handlers contribute in registration order. Use plain text, not ANSI or Markdown.
|
|
73
|
+
* Statuses are display-only and persist with the completed result, including on resume.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* connectTextEditorPostEditHandler(pi, {
|
|
77
|
+
* id: "my-check",
|
|
78
|
+
* handler: () => ({ diffStatuses: [{ text: "Checked", tone: "success" }] }),
|
|
79
|
+
* });
|
|
80
|
+
*/
|
|
81
|
+
export interface TextPostEditStatusContribution {
|
|
82
|
+
readonly diffStatuses: readonly MutationDiffStatus[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Validate display data before it enters the diff result. */
|
|
86
|
+
export function isDiffStatusContribution(value: unknown): value is TextPostEditStatusContribution {
|
|
87
|
+
return Value.Check(
|
|
88
|
+
Type.Object({
|
|
89
|
+
diffStatuses: Type.Array(
|
|
90
|
+
Type.Object({
|
|
91
|
+
text: Type.String({ minLength: 1 }),
|
|
92
|
+
tone: Type.Optional(
|
|
93
|
+
Type.Union(["muted", "success", "warning", "error"].map((tone) => Type.Literal(tone))),
|
|
94
|
+
),
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
}),
|
|
98
|
+
value,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
38
102
|
export type TextPostEditHandler = (transaction: TextPostEditTransaction) => unknown;
|
|
39
103
|
|
|
40
104
|
export interface TextPostEditHandlerRegistration {
|
|
@@ -86,6 +150,12 @@ export function isTextMutationResultContributionData(
|
|
|
86
150
|
);
|
|
87
151
|
}
|
|
88
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Register a session-owned post-edit handler, regardless of extension load order.
|
|
155
|
+
* Pi awaits handlers in registration order before finalizing the file result.
|
|
156
|
+
* Return a TextPostEditStatusContribution to add diff statuses; keep slow analysis
|
|
157
|
+
* in background diagnostic sources instead. Registration is removed on shutdown.
|
|
158
|
+
*/
|
|
89
159
|
export function connectTextEditorPostEditHandler(
|
|
90
160
|
pi: ExtensionAPI,
|
|
91
161
|
registration: TextPostEditHandlerRegistration,
|
|
@@ -29,18 +29,10 @@ export function registerBuiltinEditFilter(pi: ExtensionAPI): void {
|
|
|
29
29
|
label: "edit",
|
|
30
30
|
description: "",
|
|
31
31
|
promptGuidelines: [
|
|
32
|
-
"Use
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
" - Use text that matches the file exactly and occurs only once.",
|
|
37
|
-
" - Keep it as small as possible while still unique. Do not pad it with large unchanged regions.",
|
|
38
|
-
" - Plain text is matched against the original file contents, not after earlier mutations are applied.",
|
|
39
|
-
].join("\n"),
|
|
40
|
-
"Do not emit overlapping or nested mutations in one tool-call block. Merge nearby changes into one mutation.",
|
|
41
|
-
|
|
42
|
-
"A mutation that overlaps an earlier accepted mutation is rejected. Check each call's result before retrying; do not repeat edits that already applied.",
|
|
43
|
-
"You can omit a mutation source to reuse the last resolved resource or the previous source in the same tool-call block. Write requires a path; copy and move default their target to the source.",
|
|
32
|
+
"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.",
|
|
33
|
+
"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.",
|
|
34
|
+
"When search broadens to separate words, treat its results as location hints. Refine the query before using those matches for replacement.",
|
|
35
|
+
"Submit independent mutations together in one tool-call block. They are evaluated against the original file contents. Combine overlapping changes into one mutation. A rejected mutation does not cancel other valid mutations; check each result and retry only changes that were not applied.",
|
|
44
36
|
],
|
|
45
37
|
parameters: Type.Object({}, { additionalProperties: false }),
|
|
46
38
|
execute() {
|
|
@@ -55,7 +55,11 @@ export default async function registerTextEditorCore(
|
|
|
55
55
|
interceptionRendering,
|
|
56
56
|
() =>
|
|
57
57
|
[
|
|
58
|
-
|
|
58
|
+
(registration.anchors?.length ?? 0) > 0
|
|
59
|
+
? editor.renderGeneralPromptGuideline(
|
|
60
|
+
new Set(registration.anchors?.flatMap((anchor) => anchor.kinds)),
|
|
61
|
+
)
|
|
62
|
+
: undefined,
|
|
59
63
|
editor.renderToolPromptGuideline(registration.name),
|
|
60
64
|
]
|
|
61
65
|
.filter((guideline): guideline is string => guideline !== undefined)
|
|
@@ -84,14 +88,8 @@ export default async function registerTextEditorCore(
|
|
|
84
88
|
api.addTargetResolver({ resolver: core.textTargetResolver() });
|
|
85
89
|
api.addFragmentResolver(createReadFragmentResolver(core));
|
|
86
90
|
|
|
87
|
-
api.
|
|
88
|
-
"
|
|
89
|
-
);
|
|
90
|
-
api.addPromptGuideline(
|
|
91
|
-
"For an anchored read, omitted `offset`, `offset: 0`, and `offset: 1` all start at the anchor line; positive offsets greater than one count forward, while negative offsets count upward.",
|
|
92
|
-
);
|
|
93
|
-
api.addPromptGuideline(
|
|
94
|
-
"After search finds a relevant result, you can use read with the returned `SEARCH#...` source, `offset`, and `limit` to inspect only the surrounding context you need.",
|
|
91
|
+
api.describe(
|
|
92
|
+
"path#anchor — source around a returned line or scope anchor, e.g. notes.txt#12#A4F0. SEARCH# references go directly in path, without a file prefix. offset/limit select context relative to each location; output keeps original line numbers.",
|
|
95
93
|
);
|
|
96
94
|
},
|
|
97
95
|
});
|
package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderAgentDiff } from "./agent-diff.js";
|
|
2
|
+
import { groupReplacements, renderGroupedReplacements } from "./grouped-replacements.js";
|
|
2
3
|
import { renderFinalStateFragment } from "./final-state-fragment.js";
|
|
3
4
|
import { type FileMutationResult } from "./file-mutation-result.js";
|
|
4
5
|
|
|
@@ -23,6 +24,8 @@ export class FileMutationAgentResult {
|
|
|
23
24
|
* Returned string is suitable for content[0].text in a tool response.
|
|
24
25
|
*/
|
|
25
26
|
public toText(): string {
|
|
27
|
+
const grouped = groupReplacements(this.results);
|
|
28
|
+
if (grouped !== undefined) return renderGroupedReplacements(grouped);
|
|
26
29
|
const parts: string[] = Array.from(this.results, (fmr) => this.formatSingle(fmr));
|
|
27
30
|
|
|
28
31
|
return parts.join("\n\n");
|
|
@@ -285,14 +288,36 @@ export class FileMutationAgentResult {
|
|
|
285
288
|
// ── Success formatting ────────────────────────────────────────────────
|
|
286
289
|
|
|
287
290
|
private formatSuccess(fmr: FileMutationResult): string {
|
|
288
|
-
const
|
|
291
|
+
const operations = fmr.data.operations ?? [];
|
|
292
|
+
const verbs: Record<string, string> = {
|
|
293
|
+
replace: "Replaced selected text",
|
|
294
|
+
insert: "Inserted new text",
|
|
295
|
+
delete: "Deleted selected text",
|
|
296
|
+
copy: "Copied selected text",
|
|
297
|
+
move: "Moved selected text",
|
|
298
|
+
write: "Wrote file content",
|
|
299
|
+
undo: "Restored file content",
|
|
300
|
+
stage: "Staged selected changes",
|
|
301
|
+
unstage: "Unstaged selected changes",
|
|
302
|
+
};
|
|
303
|
+
const blocks: string[] = [
|
|
304
|
+
operations.length === 0
|
|
305
|
+
? "Changes applied."
|
|
306
|
+
: operations
|
|
307
|
+
.map(
|
|
308
|
+
({ operation, changes }) =>
|
|
309
|
+
`${verbs[operation] ?? `Applied ${operation}`}: ${changes} text change(s) in this file.`,
|
|
310
|
+
)
|
|
311
|
+
.join("\n"),
|
|
312
|
+
`Formatting: ${fmr.data.formatting?.status ?? "not-reported"}${fmr.data.formatting?.formatter === undefined ? "" : ` (${fmr.data.formatting.formatter})`}.`,
|
|
313
|
+
];
|
|
289
314
|
|
|
290
315
|
for (const diff of fmr.diffs) {
|
|
291
316
|
const path = /^--- (.+)$/m.exec(diff)?.[1] ?? fmr.path ?? "<unknown file>";
|
|
292
317
|
blocks.push(renderFinalStateFragment(fmr, path).join("\n"));
|
|
293
318
|
}
|
|
294
319
|
|
|
295
|
-
if (
|
|
320
|
+
if (fmr.diffs.length === 0) {
|
|
296
321
|
for (const file of fmr.files) {
|
|
297
322
|
blocks.push(file.path);
|
|
298
323
|
}
|
package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts
CHANGED
|
@@ -11,6 +11,31 @@ export interface MutationAnchor {
|
|
|
11
11
|
/** Successful mutation output style selected from the anchors used by the edit. */
|
|
12
12
|
export type MutationResultPresentation = "plain" | "major-anchor";
|
|
13
13
|
|
|
14
|
+
/** Observed formatter outcome; it does not imply diagnostics or tests passed. */
|
|
15
|
+
export interface MutationFormatting {
|
|
16
|
+
readonly status:
|
|
17
|
+
| "disabled"
|
|
18
|
+
| "unavailable"
|
|
19
|
+
| "skipped-syntax"
|
|
20
|
+
| "unchanged"
|
|
21
|
+
| "changed"
|
|
22
|
+
| "failed"
|
|
23
|
+
| "not-reported";
|
|
24
|
+
readonly formatter?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Plain-text, per-file status shown beside diff counts and retained in history. */
|
|
28
|
+
export interface MutationDiffStatus {
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly tone?: "muted" | "success" | "warning" | "error";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** One successful operation contributing changes to this file. */
|
|
34
|
+
export interface MutationOperationReceipt {
|
|
35
|
+
readonly operation: string;
|
|
36
|
+
readonly changes: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
14
39
|
export interface MutationSnapshot {
|
|
15
40
|
readonly content: string;
|
|
16
41
|
}
|
|
@@ -164,6 +189,19 @@ export interface FileMutationData {
|
|
|
164
189
|
isPartial?: boolean | undefined;
|
|
165
190
|
|
|
166
191
|
// ── Result fields ──
|
|
192
|
+
|
|
193
|
+
/** Successful operations represented by this result, including batched calls. */
|
|
194
|
+
operations?: readonly MutationOperationReceipt[] | undefined;
|
|
195
|
+
/** Formatter outcome reported by the post-edit integration. */
|
|
196
|
+
formatting?: MutationFormatting | undefined;
|
|
197
|
+
|
|
198
|
+
/** Display-only status contributions from post-edit handlers, in registration order. */
|
|
199
|
+
diffStatuses?: readonly MutationDiffStatus[] | undefined;
|
|
200
|
+
|
|
201
|
+
/** Original character spans owned by other calls in the same batch; display only. */
|
|
202
|
+
diffPeerRanges?:
|
|
203
|
+
| readonly { readonly from: number; readonly to: number; readonly insert: string }[]
|
|
204
|
+
| undefined;
|
|
167
205
|
diffs?: string[] | undefined;
|
|
168
206
|
files?: FileChange[] | undefined;
|
|
169
207
|
warnings?: Warning[] | undefined;
|
package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts
CHANGED
|
@@ -48,6 +48,8 @@ export function renderFinalStateFragment(fmr: FileMutationResult, path: string):
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const range = requiredValue(ranges[rangeIndex]);
|
|
51
|
+
|
|
52
|
+
result.push(`Final text, lines ${range.start}–${range.end}:`);
|
|
51
53
|
for (let lineNumber = range.start; lineNumber <= range.end; lineNumber += 1) {
|
|
52
54
|
const content = lines[lineNumber - 1] ?? "";
|
|
53
55
|
const metadata = metadataForLine(lineNumber, fmr.hints, visibleRanges, allowedSyntaxHints);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { FileMutationResult } from "./file-mutation-result.js";
|
|
2
|
+
|
|
3
|
+
/** Exact applied replacement pairs and complete per-file counts, before formatting. */
|
|
4
|
+
export interface GroupedReplacements {
|
|
5
|
+
readonly groups: readonly { removedText: string; insertedText: string; count: number }[];
|
|
6
|
+
readonly files: readonly { path: string; groups: readonly number[]; formatting: string }[];
|
|
7
|
+
readonly changes: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Groups successful replacements only when every result has complete applied-change evidence. */
|
|
11
|
+
export function groupReplacements(
|
|
12
|
+
results: readonly FileMutationResult[],
|
|
13
|
+
): GroupedReplacements | undefined {
|
|
14
|
+
if (results.length === 0) return;
|
|
15
|
+
const groups: { removedText: string; insertedText: string; count: number }[] = [];
|
|
16
|
+
const indexes = new Map<string, number>();
|
|
17
|
+
const files: { path: string; groups: number[]; formatting: string }[] = [];
|
|
18
|
+
let changes = 0;
|
|
19
|
+
for (const result of results) {
|
|
20
|
+
const operations = result.data.operations;
|
|
21
|
+
const raw = result.data.rawChanges;
|
|
22
|
+
if (
|
|
23
|
+
!result.ok ||
|
|
24
|
+
result.isPartial ||
|
|
25
|
+
result.warnings.length > 0 ||
|
|
26
|
+
result.errors.length > 0 ||
|
|
27
|
+
(result.data.hints?.length ?? 0) > 0 ||
|
|
28
|
+
(result.data.diffStatuses?.length ?? 0) > 0 ||
|
|
29
|
+
!result.path ||
|
|
30
|
+
!operations?.length ||
|
|
31
|
+
operations.some((operation) => operation.operation !== "replace") ||
|
|
32
|
+
!raw?.length ||
|
|
33
|
+
operations.reduce((sum, operation) => sum + operation.changes, 0) !== raw.length
|
|
34
|
+
)
|
|
35
|
+
return;
|
|
36
|
+
const counts: number[] = [];
|
|
37
|
+
for (const change of raw) {
|
|
38
|
+
const key = JSON.stringify([change.removedText, change.insertedText]);
|
|
39
|
+
let index = indexes.get(key);
|
|
40
|
+
if (index === undefined) {
|
|
41
|
+
index = groups.length;
|
|
42
|
+
indexes.set(key, index);
|
|
43
|
+
groups.push({
|
|
44
|
+
removedText: change.removedText,
|
|
45
|
+
insertedText: change.insertedText,
|
|
46
|
+
count: 0,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const group = groups[index];
|
|
50
|
+
if (group === undefined) throw new Error("Missing replacement group");
|
|
51
|
+
group.count++;
|
|
52
|
+
counts[index] = (counts[index] ?? 0) + 1;
|
|
53
|
+
changes++;
|
|
54
|
+
}
|
|
55
|
+
files.push({
|
|
56
|
+
path: result.path,
|
|
57
|
+
groups: counts,
|
|
58
|
+
formatting: result.data.formatting?.status ?? "not-reported",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// Keep ordinary final-state output when there is nothing repeated to compress.
|
|
62
|
+
if (groups.length === changes) return;
|
|
63
|
+
return { groups, files, changes };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Renders all unique pairs and every affected file without repeating surrounding source text. */
|
|
67
|
+
export function renderGroupedReplacements(receipt: GroupedReplacements): string {
|
|
68
|
+
return [
|
|
69
|
+
`Applied ${receipt.changes} replacements in ${receipt.files.length} files.`,
|
|
70
|
+
"Exact applied replacements (before any additional formatting; not a full final-file view):",
|
|
71
|
+
...receipt.groups.map(
|
|
72
|
+
(group, index) =>
|
|
73
|
+
`G${index + 1}: ${JSON.stringify(group.removedText)} -> ${JSON.stringify(group.insertedText)} (${group.count} replacements)`,
|
|
74
|
+
),
|
|
75
|
+
"Files (complete):",
|
|
76
|
+
...receipt.files.map(
|
|
77
|
+
(file) =>
|
|
78
|
+
`${file.path}: ${file.groups.flatMap((count, index) => (count ? [`G${index + 1} x ${count}`] : [])).join(", ")}; formatting: ${file.formatting}`,
|
|
79
|
+
),
|
|
80
|
+
].join("\n");
|
|
81
|
+
}
|
|
@@ -124,9 +124,12 @@ export class TextAnchorRegistry {
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
public renderPromptSection(): string | undefined {
|
|
127
|
+
public renderPromptSection(kinds?: ReadonlySet<string>): string | undefined {
|
|
128
128
|
const entries = this.#resolvers
|
|
129
|
-
.filter(
|
|
129
|
+
.filter(
|
|
130
|
+
({ describeInPrompt, kind }) =>
|
|
131
|
+
describeInPrompt && (kinds === undefined || kinds.has(kind)),
|
|
132
|
+
)
|
|
130
133
|
.map(({ resolver }) => renderResolverDescription(resolver))
|
|
131
134
|
.filter((entry): entry is string => entry !== undefined);
|
|
132
135
|
|
|
@@ -57,6 +57,7 @@ interface TextBatchState {
|
|
|
57
57
|
readonly registration: AnyTextMutationToolRegistration;
|
|
58
58
|
}
|
|
59
59
|
interface PlannedTextMutation extends TextMutation {
|
|
60
|
+
readonly operation: string;
|
|
60
61
|
readonly resultPresentations: ReadonlyMap<string, MutationResultPresentation>;
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -303,6 +304,8 @@ export async function executeRegisteredTextBatch(
|
|
|
303
304
|
callId: item.callId,
|
|
304
305
|
mutation: {
|
|
305
306
|
...mutation,
|
|
307
|
+
|
|
308
|
+
operation: item.registration.name,
|
|
306
309
|
resultPresentations: new Map(
|
|
307
310
|
[...mutation.edits.keys()].map((source) => [
|
|
308
311
|
source,
|
|
@@ -390,6 +393,19 @@ export async function executeRegisteredTextBatch(
|
|
|
390
393
|
edit,
|
|
391
394
|
ownAfter,
|
|
392
395
|
mutation.resultPresentations.get(source) ?? "plain",
|
|
396
|
+
|
|
397
|
+
1,
|
|
398
|
+
[{ operation: mutation.operation, changes: edit.changes.length }],
|
|
399
|
+
|
|
400
|
+
completedMutations.flatMap((peer) =>
|
|
401
|
+
peer.callId === callId
|
|
402
|
+
? []
|
|
403
|
+
: (peer.mutation.edits.get(source)?.changes ?? []).map(({ from, to, insert }) => ({
|
|
404
|
+
from,
|
|
405
|
+
to,
|
|
406
|
+
insert,
|
|
407
|
+
})),
|
|
408
|
+
),
|
|
393
409
|
),
|
|
394
410
|
];
|
|
395
411
|
});
|
|
@@ -424,6 +440,13 @@ export async function executeRegisteredTextBatch(
|
|
|
424
440
|
resource.after.content,
|
|
425
441
|
finalPresentationBySource.get(source) ?? "plain",
|
|
426
442
|
edits.length,
|
|
443
|
+
|
|
444
|
+
completedMutations.flatMap(({ mutation }) => {
|
|
445
|
+
const edit = mutation.edits.get(source);
|
|
446
|
+
return edit === undefined
|
|
447
|
+
? []
|
|
448
|
+
: [{ operation: mutation.operation, changes: edit.changes.length }];
|
|
449
|
+
}),
|
|
427
450
|
);
|
|
428
451
|
resultsByCallId.get(finalCallId)?.push(result);
|
|
429
452
|
results.push(result);
|
|
@@ -309,7 +309,7 @@ export interface TextEditorCore {
|
|
|
309
309
|
registerPostEditHandler(registration: TextPostEditHandlerRegistration): () => void;
|
|
310
310
|
registerTool(tool: TextEditorToolId): void;
|
|
311
311
|
waitForPendingPlugins(): Promise<void>;
|
|
312
|
-
renderGeneralPromptGuideline(): string | undefined;
|
|
312
|
+
renderGeneralPromptGuideline(kinds?: ReadonlySet<string>): string | undefined;
|
|
313
313
|
/** Returns the configured number of lines around recovery candidates. */
|
|
314
314
|
recoveryContextLines(): number;
|
|
315
315
|
renderToolPromptGuideline(tool: TextEditorToolId): string | undefined;
|
|
@@ -687,7 +687,7 @@ export function createTextEditorCore(
|
|
|
687
687
|
recoveryContextLines(): number {
|
|
688
688
|
return projectConfig.contextLines;
|
|
689
689
|
},
|
|
690
|
-
renderGeneralPromptGuideline(): string | undefined {
|
|
690
|
+
renderGeneralPromptGuideline(kinds?: ReadonlySet<string>): string | undefined {
|
|
691
691
|
const sections: string[] = [];
|
|
692
692
|
const writableEntries: string[] = [];
|
|
693
693
|
|
|
@@ -717,7 +717,7 @@ export function createTextEditorCore(
|
|
|
717
717
|
);
|
|
718
718
|
}
|
|
719
719
|
|
|
720
|
-
const anchorSection = anchorRegistry.renderPromptSection();
|
|
720
|
+
const anchorSection = anchorRegistry.renderPromptSection(kinds);
|
|
721
721
|
|
|
722
722
|
if (anchorSection !== undefined) {
|
|
723
723
|
sections.push(anchorSection);
|
|
@@ -739,15 +739,11 @@ export function createTextEditorCore(
|
|
|
739
739
|
);
|
|
740
740
|
|
|
741
741
|
if (contribution !== undefined) {
|
|
742
|
-
entries.push(
|
|
742
|
+
entries.push(contribution.description);
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
-
return entries.length === 0
|
|
747
|
-
? undefined
|
|
748
|
-
: indentGuidelineContinuation(
|
|
749
|
-
[`${tool} supports these installed extensions:`, ...entries].join("\n"),
|
|
750
|
-
);
|
|
746
|
+
return entries.length === 0 ? undefined : entries.join("\n");
|
|
751
747
|
},
|
|
752
748
|
async waitForPendingPlugins(): Promise<void> {
|
|
753
749
|
await Promise.all(pendingPlugins);
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
type FileMutationBatchResult,
|
|
20
20
|
FileMutationResult,
|
|
21
21
|
type MutationResultPresentation,
|
|
22
|
+
type MutationOperationReceipt,
|
|
22
23
|
} from "#src/api/mutation-result.js";
|
|
23
24
|
import {
|
|
24
25
|
isMutationAnchorValue,
|
|
@@ -28,7 +29,11 @@ import {
|
|
|
28
29
|
type TextMutationEdit,
|
|
29
30
|
type TextMutationToolRegistration,
|
|
30
31
|
} from "#src/api/mutation-tool.js";
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
isFormattingContribution,
|
|
34
|
+
isDiffStatusContribution,
|
|
35
|
+
isTextMutationResultContributionData,
|
|
36
|
+
} from "#src/api/post-edit.js";
|
|
32
37
|
import {
|
|
33
38
|
formatStaleAnchorMessage,
|
|
34
39
|
type StaleAnchorMessageDetails,
|
|
@@ -49,7 +54,6 @@ import {
|
|
|
49
54
|
type ToolCallInterceptionRenderStore,
|
|
50
55
|
withToolCallInterceptionRendering,
|
|
51
56
|
} from "#src/core/tool-call-interceptor/rendering.js";
|
|
52
|
-
import { appendSchemaFieldOrder } from "#src/core/tool-description.js";
|
|
53
57
|
|
|
54
58
|
import type { TextEditExecutionOutcome } from "#src/api/edit-pipeline.js";
|
|
55
59
|
import type {
|
|
@@ -83,7 +87,9 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
83
87
|
label: definition.name,
|
|
84
88
|
|
|
85
89
|
promptSnippet: definition.promptSnippet,
|
|
86
|
-
|
|
90
|
+
promptGuidelines:
|
|
91
|
+
definition.promptGuidelines === undefined ? undefined : [...definition.promptGuidelines],
|
|
92
|
+
description: definition.description,
|
|
87
93
|
parameters: definition.parameters,
|
|
88
94
|
prepareArguments: (arguments_) =>
|
|
89
95
|
// oxlint-disable-next-line typescript/no-unsafe-return -- TypeBox resolves only concrete tool schemas.
|
|
@@ -116,15 +122,18 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
116
122
|
}),
|
|
117
123
|
annotations,
|
|
118
124
|
);
|
|
119
|
-
Object.defineProperty(tool, "
|
|
125
|
+
Object.defineProperty(tool, "description", {
|
|
120
126
|
enumerable: true,
|
|
121
|
-
get(): string
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
get(): string {
|
|
128
|
+
return [
|
|
129
|
+
definition.description,
|
|
130
|
+
definition.source.inherited
|
|
131
|
+
? `When ${definition.source.field} is omitted, the tool can reuse the file identified by the supplied anchor, the last read, or the preceding edit in the same batch.`
|
|
132
|
+
: "",
|
|
133
|
+
pluginPromptGuideline() ?? "",
|
|
134
|
+
]
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.join("\n");
|
|
128
137
|
},
|
|
129
138
|
});
|
|
130
139
|
return tool;
|
|
@@ -195,6 +204,7 @@ async function resolveMutationSources(
|
|
|
195
204
|
const expandedByAnchor = new Map<string, readonly TextTarget[]>();
|
|
196
205
|
const expandedBySourceField = new Map<string, readonly TextTarget[]>();
|
|
197
206
|
const expandedFromExplicitSource = new Set<string>();
|
|
207
|
+
const sourceSelections = new Map<string, readonly TextTarget[]>();
|
|
198
208
|
const explicitlyScopedSourceFields = new Set<string>();
|
|
199
209
|
const allKinds = [
|
|
200
210
|
...new Set((definition.anchors ?? []).flatMap((descriptor) => descriptor.kinds)),
|
|
@@ -239,6 +249,7 @@ async function resolveMutationSources(
|
|
|
239
249
|
const expanded = await resolveTargets(explicit, descriptor.field, explicit);
|
|
240
250
|
if (expanded !== undefined) {
|
|
241
251
|
expandedFromExplicitSource.add(descriptor.field);
|
|
252
|
+
sourceSelections.set(descriptor.field, expanded);
|
|
242
253
|
expandedBySourceField.set(
|
|
243
254
|
descriptor.field,
|
|
244
255
|
mergeTargets(expandedBySourceField.get(descriptor.field) ?? [], expanded),
|
|
@@ -288,14 +299,20 @@ async function resolveMutationSources(
|
|
|
288
299
|
const anchors = new Map<string, readonly string[]>();
|
|
289
300
|
const implicitTargets = new Map<string, readonly TextTarget[]>();
|
|
290
301
|
for (const descriptor of definition.anchors ?? []) {
|
|
291
|
-
const targets =
|
|
302
|
+
const targets = sourceSelections.get(descriptor.sourceField);
|
|
303
|
+
const firstAnchor = definition.anchors?.find(
|
|
304
|
+
(anchor) => anchor.sourceField === descriptor.sourceField,
|
|
305
|
+
);
|
|
292
306
|
|
|
293
307
|
const hasExplicitAnchor = isMutationAnchorValue(descriptor, input[descriptor.field]);
|
|
294
308
|
const hasImplicitSourceSelection = expandedFromExplicitSource.has(descriptor.sourceField);
|
|
295
309
|
if (!hasExplicitAnchor && !hasImplicitSourceSelection) continue;
|
|
310
|
+
// A sibling endpoint can identify the file, but must not contribute its
|
|
311
|
+
// selected ranges to this endpoint. Only a typed source supplies a selection.
|
|
296
312
|
if (
|
|
297
313
|
targets !== undefined &&
|
|
298
|
-
|
|
314
|
+
hasImplicitSourceSelection &&
|
|
315
|
+
descriptor.field === firstAnchor?.field
|
|
299
316
|
) {
|
|
300
317
|
implicitTargets.set(descriptor.field, targets);
|
|
301
318
|
}
|
|
@@ -759,7 +776,7 @@ export async function executeTextMutation<TParameters extends TSchema>(
|
|
|
759
776
|
},
|
|
760
777
|
);
|
|
761
778
|
|
|
762
|
-
return buildToolResult(core, pipeline, source, context);
|
|
779
|
+
return buildToolResult(core, pipeline, source, context, definition.name);
|
|
763
780
|
}
|
|
764
781
|
|
|
765
782
|
export function mutationSources(
|
|
@@ -795,6 +812,7 @@ type CompletedTextResource = Extract<
|
|
|
795
812
|
{ readonly kind: "completed" }
|
|
796
813
|
>;
|
|
797
814
|
|
|
815
|
+
/** Builds a mutation receipt; peer ranges are supplied only for per-call batch display results. */
|
|
798
816
|
export function buildSuccessfulTextMutationResult(
|
|
799
817
|
resource: CompletedTextResource,
|
|
800
818
|
resultSource: string,
|
|
@@ -802,6 +820,13 @@ export function buildSuccessfulTextMutationResult(
|
|
|
802
820
|
diffAfterContent = resource.after.content,
|
|
803
821
|
resultPresentation: MutationResultPresentation = "plain",
|
|
804
822
|
editCount = 1,
|
|
823
|
+
operations: readonly MutationOperationReceipt[] = [],
|
|
824
|
+
|
|
825
|
+
diffPeerRanges?: readonly {
|
|
826
|
+
readonly from: number;
|
|
827
|
+
readonly to: number;
|
|
828
|
+
readonly insert: string;
|
|
829
|
+
}[],
|
|
805
830
|
): FileMutationResult {
|
|
806
831
|
const before = resource.before.content;
|
|
807
832
|
const finalAfter = resource.after.content;
|
|
@@ -822,6 +847,17 @@ export function buildSuccessfulTextMutationResult(
|
|
|
822
847
|
|
|
823
848
|
return new FileMutationResult({
|
|
824
849
|
...mutationResultData,
|
|
850
|
+
|
|
851
|
+
...(diffPeerRanges === undefined ? {} : { diffPeerRanges }),
|
|
852
|
+
|
|
853
|
+
operations,
|
|
854
|
+
diffStatuses: resource.postEditContributions
|
|
855
|
+
.map((item) => item.data)
|
|
856
|
+
.filter(isDiffStatusContribution)
|
|
857
|
+
.flatMap((item) => item.diffStatuses),
|
|
858
|
+
formatting: resource.postEditContributions
|
|
859
|
+
.map((item) => item.data)
|
|
860
|
+
.find(isFormattingContribution)?.formatting ?? { status: "not-reported" },
|
|
825
861
|
ok: true,
|
|
826
862
|
path: resultSource,
|
|
827
863
|
diffs: [unified.diff],
|
|
@@ -868,6 +904,7 @@ async function buildToolResult(
|
|
|
868
904
|
pipeline: TextEditExecutionOutcome,
|
|
869
905
|
source: string,
|
|
870
906
|
context: ExtensionContext,
|
|
907
|
+
operation: string,
|
|
871
908
|
): Promise<AgentToolResult<FileMutationBatchResult>> {
|
|
872
909
|
if (pipeline.kind === "failed") {
|
|
873
910
|
return failureToolResult(
|
|
@@ -916,6 +953,9 @@ async function buildToolResult(
|
|
|
916
953
|
edit,
|
|
917
954
|
undefined,
|
|
918
955
|
mutation.resultPresentations.get(resultSource) ?? "plain",
|
|
956
|
+
|
|
957
|
+
1,
|
|
958
|
+
[{ operation, changes: edit.changes.length }],
|
|
919
959
|
),
|
|
920
960
|
];
|
|
921
961
|
});
|