pi-agent-ide 0.2.1 → 0.3.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 +56 -0
- package/README.md +12 -8
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/{chunk-MTTKFJV6.js → chunk-GUTQ3PWL.js} +1 -1
- package/dist/chunk-HGPUI7F3.js +1 -0
- package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
- package/dist/chunk-ITSNK5YG.js +7 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/chunk-M5L42DWE.js +7 -0
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/chunk-TPIHQYK2.js +14 -0
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZM4L5AGN.js} +1 -1
- package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-2.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 +12 -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 +9 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +18 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +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-54.js +1 -0
- package/dist/entry-55.js +0 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -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 +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -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 +123 -1
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +3 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -13
- package/docs/configuration.md +57 -11
- package/docs/extensions.md +4 -2
- package/docs/tools.md +7 -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 +11 -15
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +22 -10
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- 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 +36 -13
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +49 -17
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +127 -20
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- 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/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +32 -28
- 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/output-truncation.ts +1 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- 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-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/node_modules/pi-agent-search/src/api/search.ts +55 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +8 -27
- package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
- package/node_modules/pi-agent-search-text/index.ts +82 -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 +112 -24
- 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/src/text-document.ts +5 -0
- package/node_modules/pi-agent-text/src/text-target.ts +4 -0
- 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-anchor-line-hash/src/read-handler.ts +1 -0
- package/node_modules/pi-agent-text-editor/index.ts +1 -3
- package/node_modules/pi-agent-text-editor/package.json +34 -24
- package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -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/post-edit-scope.ts +73 -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-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- 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-renderer/index.ts +93 -2
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- 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 +69 -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 +24 -13
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +38 -38
- package/src/api/plugin-protocol.ts +12 -2
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +77 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +138 -67
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +142 -0
- package/src/core/diagnostic-store.ts +96 -23
- package/src/core/extension.ts +45 -22
- 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 +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
- 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 +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +32 -28
- 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/output-truncation.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -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 +112 -24
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
- package/src/extensions/pi-agent-search/src/core/extension.ts +8 -27
- package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -3
- package/src/extensions/pi-agent-text-editor/index.ts +1 -3
- package/src/extensions/pi-agent-text-editor/package.json +34 -24
- 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-anchor-line-hash/src/read-handler.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +93 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/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 +69 -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 +24 -13
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -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/post-edit-scope.ts +73 -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-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- 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 +45 -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 +11 -15
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +49 -17
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +127 -20
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/src/post-edit/gate.ts +57 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2SKAED2I.js +0 -2
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-2ZMYT6ZC.js +0 -1
- 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-JASLOB2X.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KNMWCDDK.js +0 -7
- 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/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/chunk-ZIHEF6K3.js +0 -3
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
|
@@ -134,6 +134,9 @@ export function formatAstOutline(block: SourceViewBlock): SourceMappedTextConten
|
|
|
134
134
|
export class AstOutlineManager {
|
|
135
135
|
private readonly fallbackScopeManager = new AstScopeManager();
|
|
136
136
|
|
|
137
|
+
/** Limit syntax-tree nesting for automatic overviews; explicit outlines keep their existing depth. */
|
|
138
|
+
public constructor(private readonly maxDepth = Number.POSITIVE_INFINITY) {}
|
|
139
|
+
|
|
137
140
|
public async readFileOutline(filePath: string, cwd: string): Promise<SourceViewBlock> {
|
|
138
141
|
const absolutePath = resolvePath(filePath, cwd);
|
|
139
142
|
const displayPath = path.relative(cwd, absolutePath) || absolutePath;
|
|
@@ -143,21 +146,50 @@ export class AstOutlineManager {
|
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
const snapshot = await readTextFile(absolutePath);
|
|
146
|
-
|
|
149
|
+
return this.readDocumentOutline(absolutePath, cwd, snapshot.lines);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Build an outline from the read snapshot. With a finite depth and a budget
|
|
153
|
+
* predicate, reduce nesting until it fits or reaches file-only detail. Parse once.
|
|
154
|
+
*/
|
|
155
|
+
public async readDocumentOutline(
|
|
156
|
+
filePath: string,
|
|
157
|
+
cwd: string,
|
|
158
|
+
lines: readonly string[],
|
|
159
|
+
fits?: (outline: SourceViewBlock) => boolean,
|
|
160
|
+
): Promise<SourceViewBlock> {
|
|
161
|
+
const absolutePath = resolvePath(filePath, cwd);
|
|
162
|
+
const displayPath = path.relative(cwd, absolutePath) || absolutePath;
|
|
163
|
+
if (!isSupportedOutlinePath(absolutePath)) {
|
|
164
|
+
throw new Error(`AST outline is not supported for ${displayPath}.`);
|
|
165
|
+
}
|
|
166
|
+
const tree = await parseDocument(absolutePath, cwd, lines);
|
|
147
167
|
|
|
148
168
|
if (!tree) {
|
|
149
169
|
throw new Error(`No AST parser is available for ${displayPath}.`);
|
|
150
170
|
}
|
|
171
|
+
if (Number.isFinite(this.maxDepth) && tree.rootNode.hasError) {
|
|
172
|
+
throw new Error(`Cannot build an automatic outline from invalid syntax in ${displayPath}.`);
|
|
173
|
+
}
|
|
151
174
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
const content = lines.join("\n");
|
|
176
|
+
for (let depth = this.maxDepth; ; depth -= 1) {
|
|
177
|
+
const outline = await this.createSourceViewBlock(
|
|
178
|
+
tree.rootNode,
|
|
179
|
+
absolutePath,
|
|
180
|
+
displayPath,
|
|
181
|
+
cwd,
|
|
182
|
+
lines,
|
|
183
|
+
content,
|
|
184
|
+
path.extname(absolutePath).toLowerCase(),
|
|
185
|
+
undefined,
|
|
186
|
+
undefined,
|
|
187
|
+
depth,
|
|
188
|
+
);
|
|
189
|
+
if (fits === undefined || fits(outline) || depth <= 0 || !Number.isFinite(depth)) {
|
|
190
|
+
return outline;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
161
193
|
}
|
|
162
194
|
|
|
163
195
|
public async formatFile(filePath: string, cwd: string): Promise<SourceMappedTextContent> {
|
|
@@ -248,8 +280,9 @@ export class AstOutlineManager {
|
|
|
248
280
|
extension: string,
|
|
249
281
|
heading?: string,
|
|
250
282
|
details?: readonly string[],
|
|
283
|
+
maxDepth = this.maxDepth,
|
|
251
284
|
): Promise<SourceViewBlock> {
|
|
252
|
-
const projectedLines = renderNodeLines(node, source, extension);
|
|
285
|
+
const projectedLines = renderNodeLines(node, source, extension, maxDepth);
|
|
253
286
|
const scopes = await getOutlineScopes(this.fallbackScopeManager, filePath, cwd, sourceLines);
|
|
254
287
|
const markersByLine = buildScopeMarkers(scopes);
|
|
255
288
|
const renderedLines = projectedLines.map((line) => {
|
|
@@ -439,13 +472,18 @@ interface MappedCharacter {
|
|
|
439
472
|
readonly sourceLine?: number;
|
|
440
473
|
}
|
|
441
474
|
|
|
442
|
-
function renderNodeLines(
|
|
475
|
+
function renderNodeLines(
|
|
476
|
+
node: WTS.Node,
|
|
477
|
+
source: string,
|
|
478
|
+
extension: string,
|
|
479
|
+
maxDepth: number,
|
|
480
|
+
): ProjectedLine[] {
|
|
443
481
|
const replacements: Replacement[] = [];
|
|
444
482
|
|
|
445
483
|
if (DATA_EXTENSIONS.has(extension)) {
|
|
446
|
-
collectDataReplacements(node, extension, replacements);
|
|
484
|
+
collectDataReplacements(node, extension, replacements, maxDepth);
|
|
447
485
|
} else {
|
|
448
|
-
collectReplacements(node, extension, replacements);
|
|
486
|
+
collectReplacements(node, extension, replacements, false, maxDepth);
|
|
449
487
|
}
|
|
450
488
|
|
|
451
489
|
const start = lineStartAt(source, node.startIndex);
|
|
@@ -501,7 +539,10 @@ function mapSourceRange(source: string, start: number, end: number): MappedChara
|
|
|
501
539
|
let sourceLine = source.slice(0, start).split("\n").length;
|
|
502
540
|
const mapped: MappedCharacter[] = [];
|
|
503
541
|
|
|
504
|
-
|
|
542
|
+
// Tree-sitter offsets use UTF-16 code units, just like String.slice/splice offsets.
|
|
543
|
+
// Iterating code points would shift replacements after supplementary characters.
|
|
544
|
+
for (let index = start; index < end; index += 1) {
|
|
545
|
+
const char = requiredValue(source[index]);
|
|
505
546
|
mapped.push({ char, sourceLine });
|
|
506
547
|
|
|
507
548
|
if (char === "\n") {
|
|
@@ -531,11 +572,29 @@ function mapReplacement(replacement: Replacement): MappedCharacter[] {
|
|
|
531
572
|
return mapped;
|
|
532
573
|
}
|
|
533
574
|
|
|
575
|
+
function collapseDeepNode(
|
|
576
|
+
node: WTS.Node,
|
|
577
|
+
replacements: Replacement[],
|
|
578
|
+
depth: number,
|
|
579
|
+
maxDepth: number,
|
|
580
|
+
): boolean {
|
|
581
|
+
if (depth < maxDepth || node.namedChildCount === 0) return false;
|
|
582
|
+
replacements.push({
|
|
583
|
+
start: node.startIndex,
|
|
584
|
+
end: node.endIndex,
|
|
585
|
+
text: "…",
|
|
586
|
+
lineSourceLines: [node.startPosition.row + 1],
|
|
587
|
+
});
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
534
590
|
function collectDataReplacements(
|
|
535
591
|
node: WTS.Node,
|
|
536
592
|
extension: string,
|
|
537
593
|
replacements: Replacement[],
|
|
594
|
+
maxDepth: number,
|
|
595
|
+
depth = 0,
|
|
538
596
|
): void {
|
|
597
|
+
if (collapseDeepNode(node, replacements, depth, maxDepth)) return;
|
|
539
598
|
for (const child of node.namedChildren) {
|
|
540
599
|
if (isDataScalar(child, extension)) {
|
|
541
600
|
if (!isDataKey(child)) {
|
|
@@ -550,7 +609,7 @@ function collectDataReplacements(
|
|
|
550
609
|
continue;
|
|
551
610
|
}
|
|
552
611
|
|
|
553
|
-
collectDataReplacements(child, extension, replacements);
|
|
612
|
+
collectDataReplacements(child, extension, replacements, maxDepth, depth + 1);
|
|
554
613
|
}
|
|
555
614
|
}
|
|
556
615
|
|
|
@@ -602,9 +661,13 @@ function collectReplacements(
|
|
|
602
661
|
node: WTS.Node,
|
|
603
662
|
extension: string,
|
|
604
663
|
replacements: Replacement[],
|
|
605
|
-
topLevel
|
|
664
|
+
topLevel: boolean,
|
|
665
|
+
maxDepth: number,
|
|
666
|
+
depth = 0,
|
|
606
667
|
): void {
|
|
607
|
-
if (
|
|
668
|
+
if (collapseDeepNode(node, replacements, depth, maxDepth)) return;
|
|
669
|
+
const keepCall = Number.isFinite(maxDepth) && node.type === "expression_statement";
|
|
670
|
+
if (topLevel && !isTopLevelInterfaceNode(node) && !keepCall) {
|
|
608
671
|
replacements.push({
|
|
609
672
|
start: node.startIndex,
|
|
610
673
|
end: node.endIndex,
|
|
@@ -644,7 +707,14 @@ function collectReplacements(
|
|
|
644
707
|
}
|
|
645
708
|
|
|
646
709
|
for (const child of node.namedChildren) {
|
|
647
|
-
collectReplacements(
|
|
710
|
+
collectReplacements(
|
|
711
|
+
child,
|
|
712
|
+
extension,
|
|
713
|
+
replacements,
|
|
714
|
+
ROOT_TYPES.has(node.type),
|
|
715
|
+
maxDepth,
|
|
716
|
+
depth + 1,
|
|
717
|
+
);
|
|
648
718
|
}
|
|
649
719
|
}
|
|
650
720
|
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { AstScopeManager } from "./ast/manager.js";
|
|
22
22
|
import { astDoctorPlugin } from "./doctor-plugin.js";
|
|
23
23
|
import { createAstOutlineResolver } from "./outline-resolver.js";
|
|
24
|
+
import { createAstOverflowHandler, reduceAstReadOutput } from "./overflow-handler.js";
|
|
24
25
|
import { createAstScopePostReadHandler, createAstScopePresenter } from "./scope-handler.js";
|
|
25
26
|
import { createAstScopeAnchorResolver } from "./scope-resolver.js";
|
|
26
27
|
import { createAstSearchResolver } from "./search-resolver.js";
|
|
@@ -43,19 +44,18 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
43
44
|
handler: createSourceMappedTextReadHandler(),
|
|
44
45
|
});
|
|
45
46
|
api.addView({ view: "ast", presenter });
|
|
47
|
+
const overflow = createAstOverflowHandler();
|
|
48
|
+
api.addOutputReducer(reduceAstReadOutput);
|
|
49
|
+
const scopes = createAstScopePostReadHandler();
|
|
46
50
|
api.addHandler({
|
|
47
51
|
stage: "post-read",
|
|
48
|
-
handler
|
|
52
|
+
async handler(context) {
|
|
53
|
+
const result = await overflow(context);
|
|
54
|
+
return result.kind === "return" ? result : scopes(result.context);
|
|
55
|
+
},
|
|
49
56
|
});
|
|
50
57
|
api.describe(
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
-
api.addPromptGuideline(
|
|
54
|
-
"You can use read with `ast:<path>` for a compact structural overview of a source file, including its classes, functions, signatures, and other declarations.",
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
api.addPromptGuideline(
|
|
58
|
-
'You can use read with `views: ["ast"]` to add scope boundaries alongside the file\'s source text.',
|
|
58
|
+
'ast:<path> — compact declaration outline. views: ["ast"] — scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.',
|
|
59
59
|
);
|
|
60
60
|
},
|
|
61
61
|
} satisfies ReadPlugin;
|
|
@@ -82,13 +82,9 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
82
82
|
apiVersion: SEARCH_API_VERSION,
|
|
83
83
|
id: "ast-search",
|
|
84
84
|
setup(api): void {
|
|
85
|
-
api.addResolver({ resolver: createAstSearchResolver() });
|
|
85
|
+
api.addResolver({ resolver: createAstSearchResolver(api.registerSelection) });
|
|
86
86
|
api.describe(
|
|
87
|
-
"
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
api.addPromptGuideline(
|
|
91
|
-
"You can use search with `ast:<pattern>` for structural code search. You can limit it with `path`, `include`, and `exclude`.",
|
|
87
|
+
"Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.",
|
|
92
88
|
);
|
|
93
89
|
},
|
|
94
90
|
}),
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_MAX_BYTES,
|
|
3
|
+
DEFAULT_MAX_LINES,
|
|
4
|
+
truncateHead,
|
|
5
|
+
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import type { ReadOutputReducer, ReadPostReadHandler } from "pi-agent-read/api/tools/read";
|
|
7
|
+
import type { SourceViewBlock } from "pi-agent-ide/api/code-view";
|
|
8
|
+
|
|
9
|
+
/** Builds a compact source view from recorded text, never from a newer filesystem snapshot. */
|
|
10
|
+
export const reduceAstReadOutput: ReadOutputReducer = async (result, context, budget) => {
|
|
11
|
+
const { source, resolvedBy, lines, totalLines, startLine } = result.details;
|
|
12
|
+
if (
|
|
13
|
+
source === undefined ||
|
|
14
|
+
resolvedBy !== "filesystem" ||
|
|
15
|
+
lines === undefined ||
|
|
16
|
+
lines.length !== totalLines ||
|
|
17
|
+
(startLine !== undefined && startLine !== 1)
|
|
18
|
+
)
|
|
19
|
+
return undefined;
|
|
20
|
+
try {
|
|
21
|
+
const { AstOutlineManager, isSupportedOutlinePath } = await import("./ast/outline.js");
|
|
22
|
+
if (!isSupportedOutlinePath(source)) return undefined;
|
|
23
|
+
const format = (outline: SourceViewBlock): string =>
|
|
24
|
+
[
|
|
25
|
+
`AST overview of ${outline.path}, source lines 1-${outline.totalLines}: the requested text exceeded the read buffer.`,
|
|
26
|
+
"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",
|
|
27
|
+
...outline.renderedLines.map(
|
|
28
|
+
(line) => `${line.sourceLine?.lineNumber ?? "…"} | ${line.text}`,
|
|
29
|
+
),
|
|
30
|
+
].join("\n");
|
|
31
|
+
context.signal?.throwIfAborted();
|
|
32
|
+
const outline = await new AstOutlineManager(12).readDocumentOutline(
|
|
33
|
+
source,
|
|
34
|
+
context.cwd,
|
|
35
|
+
lines.map((line) => line.content),
|
|
36
|
+
(candidate) => {
|
|
37
|
+
context.signal?.throwIfAborted();
|
|
38
|
+
return !truncateHead(format(candidate), budget).truncated;
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
const text = format(outline);
|
|
42
|
+
if (truncateHead(text, budget).truncated) return undefined;
|
|
43
|
+
return { content: [{ type: "text", text }], details: { source, resolvedBy: "ast-overflow" } };
|
|
44
|
+
} catch {
|
|
45
|
+
context.signal?.throwIfAborted();
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Replace an overflowing read window with a source-numbered whole-file outline. */
|
|
51
|
+
export function createAstOverflowHandler(): ReadPostReadHandler {
|
|
52
|
+
return async (context) => {
|
|
53
|
+
const { state, result } = context;
|
|
54
|
+
const block = result?.content.length === 1 ? result.content[0] : undefined;
|
|
55
|
+
if (
|
|
56
|
+
context.audience === "script" ||
|
|
57
|
+
result === undefined ||
|
|
58
|
+
state?.contentKind !== "text" ||
|
|
59
|
+
state.resolvedBy !== "filesystem" ||
|
|
60
|
+
block?.type !== "text" ||
|
|
61
|
+
!truncateHead(block.text).truncated
|
|
62
|
+
)
|
|
63
|
+
return { kind: "continue", context };
|
|
64
|
+
const reduced = await reduceAstReadOutput(
|
|
65
|
+
{
|
|
66
|
+
...result,
|
|
67
|
+
details: {
|
|
68
|
+
...result.details,
|
|
69
|
+
source: state.source,
|
|
70
|
+
resolvedBy: state.resolvedBy,
|
|
71
|
+
lines: state.text.lines,
|
|
72
|
+
startLine: 1,
|
|
73
|
+
totalLines: state.text.lines.length,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
context.resolverContext,
|
|
77
|
+
{ maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES },
|
|
78
|
+
);
|
|
79
|
+
return reduced === undefined
|
|
80
|
+
? { kind: "continue", context }
|
|
81
|
+
: { kind: "return", result: reduced };
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -9,6 +9,8 @@ import type { TextLinePresenter } from "pi-agent-text";
|
|
|
9
9
|
const AST_SCOPE_METADATA = "pi-agent-ast";
|
|
10
10
|
|
|
11
11
|
interface AstScopeBoundary {
|
|
12
|
+
readonly beginAnchor: string;
|
|
13
|
+
readonly endAnchor: string;
|
|
12
14
|
readonly endLine: number;
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -106,7 +108,11 @@ function addScopeMarkers(
|
|
|
106
108
|
markersByLine.set(scope.startLine, begin);
|
|
107
109
|
|
|
108
110
|
const boundaries = boundariesByLine.get(scope.startLine) ?? [];
|
|
109
|
-
boundaries.push({
|
|
111
|
+
boundaries.push({
|
|
112
|
+
endLine: scope.endLine,
|
|
113
|
+
beginAnchor: scope.beginAnchor.value,
|
|
114
|
+
endAnchor: scope.endScopeAnchor.value,
|
|
115
|
+
});
|
|
110
116
|
boundariesByLine.set(scope.startLine, boundaries);
|
|
111
117
|
|
|
112
118
|
const end = markersByLine.get(scope.endLine) ?? [];
|
|
@@ -125,6 +131,7 @@ function addScopeMarkers(
|
|
|
125
131
|
return {
|
|
126
132
|
...line,
|
|
127
133
|
...(markers !== undefined && {
|
|
134
|
+
anchors: [...new Set([...(line.anchors ?? []), ...markers])],
|
|
128
135
|
presentation: {
|
|
129
136
|
...line.presentation,
|
|
130
137
|
suffix: `${line.presentation?.suffix ?? ""}${markers
|
|
@@ -7,7 +7,7 @@ export function createAstScopeAnchorResolver(manager: AstScopeManager): TextAnch
|
|
|
7
7
|
return {
|
|
8
8
|
id: "ast-scope",
|
|
9
9
|
description:
|
|
10
|
-
|
|
10
|
+
'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] — first/last lines of a scope. Any numeric suffix is part of the anchor.',
|
|
11
11
|
renderFull(value) {
|
|
12
12
|
return value;
|
|
13
13
|
},
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { readFile, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import type { SearchPluginApi, SearchSelectionMatch } from "pi-agent-search/api/search";
|
|
2
5
|
|
|
3
6
|
import type { SearchRequest, SearchResolver } from "pi-agent-search/api/search";
|
|
4
7
|
|
|
@@ -8,13 +11,16 @@ interface AstGrepMatch {
|
|
|
8
11
|
readonly lines: string;
|
|
9
12
|
readonly language: string;
|
|
10
13
|
readonly range: {
|
|
14
|
+
readonly byteOffset: { readonly start: number; readonly end: number };
|
|
11
15
|
readonly start: { readonly line: number; readonly column: number };
|
|
12
16
|
readonly end: { readonly line: number; readonly column: number };
|
|
13
17
|
};
|
|
14
18
|
readonly metaVariables?: unknown;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
export function createAstSearchResolver(
|
|
21
|
+
export function createAstSearchResolver(
|
|
22
|
+
registerSelection: SearchPluginApi["registerSelection"],
|
|
23
|
+
): SearchResolver {
|
|
18
24
|
return {
|
|
19
25
|
id: "ast",
|
|
20
26
|
async tryResolve(request, context) {
|
|
@@ -28,16 +34,41 @@ export function createAstSearchResolver(): SearchResolver {
|
|
|
28
34
|
return { kind: "failed", error: new Error("ast: pattern must not be empty") };
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
const
|
|
32
|
-
|
|
37
|
+
const collect = async (signal?: AbortSignal) => {
|
|
38
|
+
const started = Date.now();
|
|
39
|
+
const found = await runAstGrep(pattern, request, context.cwd, signal);
|
|
40
|
+
found.sort(
|
|
41
|
+
(a, b) =>
|
|
42
|
+
path.resolve(context.cwd, a.file).localeCompare(path.resolve(context.cwd, b.file)) ||
|
|
43
|
+
a.range.byteOffset.start - b.range.byteOffset.start ||
|
|
44
|
+
a.range.byteOffset.end - b.range.byteOffset.end,
|
|
45
|
+
);
|
|
46
|
+
const raw = found.slice(0, request.limit ?? 100);
|
|
47
|
+
return {
|
|
48
|
+
raw,
|
|
49
|
+
matches: await selectionMatches(raw, context.cwd, started, signal),
|
|
50
|
+
complete: found.length <= (request.limit ?? 100),
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const selected = await collect(context.signal);
|
|
54
|
+
const session = await registerSelection(
|
|
55
|
+
{ request, matches: selected.matches, complete: selected.complete, refresh: collect },
|
|
56
|
+
context,
|
|
57
|
+
);
|
|
33
58
|
return {
|
|
34
59
|
kind: "resolved",
|
|
35
|
-
payload: {
|
|
60
|
+
payload: {
|
|
61
|
+
pattern,
|
|
62
|
+
matches: selected.raw,
|
|
63
|
+
complete: selected.complete,
|
|
64
|
+
sessionId: session.id,
|
|
65
|
+
},
|
|
36
66
|
};
|
|
37
67
|
},
|
|
38
68
|
format(payload) {
|
|
39
69
|
const result = payload as {
|
|
40
70
|
readonly pattern: string;
|
|
71
|
+
readonly sessionId: string;
|
|
41
72
|
readonly matches: readonly AstGrepMatch[];
|
|
42
73
|
readonly complete: boolean;
|
|
43
74
|
};
|
|
@@ -47,12 +78,14 @@ export function createAstSearchResolver(): SearchResolver {
|
|
|
47
78
|
}
|
|
48
79
|
|
|
49
80
|
const lines = result.matches.flatMap((match, index) => [
|
|
50
|
-
|
|
81
|
+
`SEARCH#${result.sessionId}:${String(index + 1)}:match ${match.file}:${String(match.range.start.line + 1)}:${String(
|
|
51
82
|
match.range.start.column + 1,
|
|
52
83
|
)} ${match.language}`,
|
|
53
84
|
` ${match.lines.trim()}`,
|
|
54
85
|
]);
|
|
55
86
|
|
|
87
|
+
if (result.complete)
|
|
88
|
+
lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact AST matches.`);
|
|
56
89
|
if (!result.complete) {
|
|
57
90
|
lines.push("Result limit reached.");
|
|
58
91
|
}
|
|
@@ -62,6 +95,51 @@ export function createAstSearchResolver(): SearchResolver {
|
|
|
62
95
|
};
|
|
63
96
|
}
|
|
64
97
|
|
|
98
|
+
async function selectionMatches(
|
|
99
|
+
matches: readonly AstGrepMatch[],
|
|
100
|
+
cwd: string,
|
|
101
|
+
started: number,
|
|
102
|
+
signal?: AbortSignal,
|
|
103
|
+
): Promise<SearchSelectionMatch[]> {
|
|
104
|
+
const sources = new Map<string, Buffer>();
|
|
105
|
+
for (const match of matches) {
|
|
106
|
+
const source = path.resolve(cwd, match.file);
|
|
107
|
+
if (sources.has(source)) continue;
|
|
108
|
+
const before = await stat(source);
|
|
109
|
+
const bytes = await readFile(source, { signal });
|
|
110
|
+
const after = await stat(source);
|
|
111
|
+
if (before.mtimeMs > started || before.mtimeMs !== after.mtimeMs || before.size !== after.size)
|
|
112
|
+
throw new Error("AST source changed during search. Run the structural query again.");
|
|
113
|
+
sources.set(source, bytes);
|
|
114
|
+
}
|
|
115
|
+
return matches.map((match) => {
|
|
116
|
+
const source = path.resolve(cwd, match.file);
|
|
117
|
+
const bytes = sources.get(source);
|
|
118
|
+
if (bytes === undefined) throw new Error("Missing AST source snapshot");
|
|
119
|
+
const { start, end } = match.range.byteOffset;
|
|
120
|
+
if (
|
|
121
|
+
!Number.isInteger(start) ||
|
|
122
|
+
!Number.isInteger(end) ||
|
|
123
|
+
start < 0 ||
|
|
124
|
+
end < start ||
|
|
125
|
+
end > bytes.length ||
|
|
126
|
+
bytes.subarray(start, end).toString("utf8") !== match.text
|
|
127
|
+
)
|
|
128
|
+
throw new Error("AST range does not match its source snapshot. Search again.");
|
|
129
|
+
const prefix = bytes.subarray(0, start).toString("utf8");
|
|
130
|
+
const throughEnd = bytes.subarray(0, end).toString("utf8");
|
|
131
|
+
const lineNumber = prefix.split("\n").length;
|
|
132
|
+
return {
|
|
133
|
+
source,
|
|
134
|
+
lineNumber,
|
|
135
|
+
endLineNumber: throughEnd.split("\n").length,
|
|
136
|
+
startColumn: prefix.length - prefix.lastIndexOf("\n") - 1,
|
|
137
|
+
endColumn: throughEnd.length - throughEnd.lastIndexOf("\n") - 1,
|
|
138
|
+
matchedText: match.text,
|
|
139
|
+
lineText: bytes.toString("utf8").split("\n")[lineNumber - 1]?.replace(/\r$/u, "") ?? "",
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
65
143
|
function runAstGrep(
|
|
66
144
|
pattern: string,
|
|
67
145
|
request: SearchRequest,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Value } from "typebox/value";
|
|
1
2
|
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
|
|
3
4
|
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
@@ -19,14 +20,14 @@ import { extensionGitExecutor } from "#src/changes/git-changes-backend.js";
|
|
|
19
20
|
import { createCurrentChangePresenter } from "#src/current-change-presenter.js";
|
|
20
21
|
import { IndexMutationQueue } from "#src/index-mutation-queue.js";
|
|
21
22
|
import { LastTextTransactionStore } from "#src/last-text-transaction-store.js";
|
|
22
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
registerIndexChangeTools,
|
|
25
|
+
createIndexChangeTool,
|
|
26
|
+
indexChangeSchema,
|
|
27
|
+
} from "#src/tool-index-change.js";
|
|
23
28
|
import { createUndoMutationTool } from "#src/tool-text-undo.js";
|
|
24
29
|
|
|
25
30
|
export default async function registerGitChanges(pi: ExtensionAPI): Promise<void> {
|
|
26
|
-
if (process.argv.includes("--old-tools")) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
31
|
const executor = extensionGitExecutor(pi);
|
|
31
32
|
const transactions = new LastTextTransactionStore();
|
|
32
33
|
const indexQueue = new IndexMutationQueue();
|
|
@@ -39,11 +40,7 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
|
|
|
39
40
|
setup(api) {
|
|
40
41
|
api.addView({ view: "changes", presenter });
|
|
41
42
|
api.describe(
|
|
42
|
-
"
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
api.addPromptGuideline(
|
|
46
|
-
'You can use read with `views: ["changes"]` to add `CHANGE#...` anchors and Git index state for current file changes.',
|
|
43
|
+
'views: ["changes"] — uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.',
|
|
47
44
|
);
|
|
48
45
|
},
|
|
49
46
|
} satisfies ReadPlugin;
|
|
@@ -61,6 +58,21 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
|
|
|
61
58
|
transactions.observe(completion);
|
|
62
59
|
});
|
|
63
60
|
api.addMutationTool(createUndoMutationTool(executor, transactions, indexQueue));
|
|
61
|
+
for (const action of ["stage", "unstage"] as const) {
|
|
62
|
+
const tool = createIndexChangeTool(action, executor, indexQueue);
|
|
63
|
+
api.addScriptIndexOperation({
|
|
64
|
+
name: action,
|
|
65
|
+
parameters: indexChangeSchema,
|
|
66
|
+
execute: (input, signal, context) =>
|
|
67
|
+
tool.execute(
|
|
68
|
+
`apply-${action}`,
|
|
69
|
+
Value.Decode(indexChangeSchema, input),
|
|
70
|
+
signal,
|
|
71
|
+
undefined,
|
|
72
|
+
context,
|
|
73
|
+
),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
64
76
|
api.addTextPresenter({ presenter });
|
|
65
77
|
},
|
|
66
78
|
} satisfies TextEditorPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-changes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"diff": "^9.0.0",
|
|
16
|
-
"pi-agent-doctor": "0.
|
|
17
|
-
"pi-agent-invariant": "0.
|
|
18
|
-
"pi-agent-read": "0.
|
|
19
|
-
"pi-agent-text": "0.
|
|
20
|
-
"pi-agent-text-editor": "0.
|
|
16
|
+
"pi-agent-doctor": "0.3.0",
|
|
17
|
+
"pi-agent-invariant": "0.3.0",
|
|
18
|
+
"pi-agent-read": "0.3.0",
|
|
19
|
+
"pi-agent-text": "0.3.0",
|
|
20
|
+
"pi-agent-text-editor": "0.3.0"
|
|
21
21
|
},
|
|
22
22
|
"pi": {
|
|
23
23
|
"extensions": [
|
|
@@ -15,6 +15,16 @@ export class LastTextTransactionStore {
|
|
|
15
15
|
|
|
16
16
|
public observe(completion: TextEditCompletion): void {
|
|
17
17
|
const key = sourceKey(completion.resourceSource, completion.cwd);
|
|
18
|
+
if (completion.postProcessing === "final") {
|
|
19
|
+
const previous = this.#transactions.get(key);
|
|
20
|
+
if (previous && previous.afterDigest === textDigest(completion.before.content))
|
|
21
|
+
this.#transactions.set(key, {
|
|
22
|
+
...previous,
|
|
23
|
+
afterDigest: textDigest(completion.after.content),
|
|
24
|
+
});
|
|
25
|
+
else this.#transactions.delete(key);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
if (
|
|
20
30
|
completion.intent !== "edit" ||
|
|
@@ -14,7 +14,8 @@ import type { ChangeIndexAction } from "#src/changes/change-types.js";
|
|
|
14
14
|
import type { GitCommandExecutor } from "#src/changes/git-changes-backend.js";
|
|
15
15
|
import type { IndexMutationQueue } from "#src/index-mutation-queue.js";
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/** Shared validation for standalone and composed index changes. */
|
|
18
|
+
export const indexChangeSchema = Type.Object(
|
|
18
19
|
{
|
|
19
20
|
file: Type.String({ description: "Path to the tracked text file" }),
|
|
20
21
|
change: Type.String({
|
|
@@ -42,7 +43,8 @@ export function registerIndexChangeTools(
|
|
|
42
43
|
pi.registerTool(createIndexChangeTool("unstage", executor, queue));
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
/** Build one guarded index change shared by standalone tools and Apply. */
|
|
47
|
+
export function createIndexChangeTool(
|
|
46
48
|
action: ChangeIndexAction,
|
|
47
49
|
executor: GitCommandExecutor,
|
|
48
50
|
queue: IndexMutationQueue,
|
|
@@ -55,13 +57,7 @@ function createIndexChangeTool(
|
|
|
55
57
|
label: action,
|
|
56
58
|
|
|
57
59
|
promptSnippet: `${pastTense.slice(0, -1)} a selected Git change`,
|
|
58
|
-
description:
|
|
59
|
-
0,
|
|
60
|
-
-1,
|
|
61
|
-
)} one current Git change selected by a CHANGE# anchor without changing the worktree.`,
|
|
62
|
-
promptGuidelines: [
|
|
63
|
-
`You can use ${action} with a complete \`CHANGE#...\` anchor to ${action} only that current Git change without changing the worktree.`,
|
|
64
|
-
],
|
|
60
|
+
description: `Use ${action} to ${action === "stage" ? "add one current Git change to the index" : "remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,
|
|
65
61
|
parameters: indexChangeSchema,
|
|
66
62
|
async execute(_toolCallId, parameters, signal, _onUpdate, context) {
|
|
67
63
|
const file = resolveFile(parameters.file, context.cwd);
|
|
@@ -38,13 +38,9 @@ export function createUndoMutationTool(
|
|
|
38
38
|
return {
|
|
39
39
|
name: "undo",
|
|
40
40
|
description:
|
|
41
|
-
"
|
|
41
|
+
"Use undo to revert a selected uncommitted Git change or the latest text-editor transaction for one file. A CHANGE# anchor restores that change to HEAD in both worktree and index; last restores the file's state before its latest text-editor transaction.",
|
|
42
42
|
|
|
43
43
|
promptSnippet: "Restore a Git change or the latest text edit",
|
|
44
|
-
promptGuidelines: [
|
|
45
|
-
"You can use undo with a complete `CHANGE#...` anchor to restore that current Git change to HEAD in both the worktree and index.",
|
|
46
|
-
'You can use undo with `change: "last"` to restore a file to its state before its latest text-editor transaction.',
|
|
47
|
-
],
|
|
48
44
|
parameters: undoSchema,
|
|
49
45
|
intent: "restore",
|
|
50
46
|
source: { field: "file", inherited: true },
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-formatter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.
|
|
6
|
+
"pi-agent-doctor": "0.3.0"
|
|
7
7
|
},
|
|
8
8
|
"pi": {
|
|
9
9
|
"extensions": [
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@earendil-works/pi-coding-agent": "*",
|
|
15
|
-
"pi-agent-ide": "0.
|
|
15
|
+
"pi-agent-ide": "0.3.0"
|
|
16
16
|
}
|
|
17
17
|
}
|