pi-agent-ide 0.6.2 → 0.6.4
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 +66 -0
- package/README.md +8 -1
- package/dist/chunk-2P2OGO3G.js +2 -0
- package/dist/{chunk-5QQABP47.js → chunk-3BBJZSMS.js} +1 -1
- package/dist/chunk-5J43L2RL.js +11 -0
- package/dist/{chunk-ITSNK5YG.js → chunk-7AVXUV4A.js} +2 -2
- package/dist/chunk-BAYETTZZ.js +16 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-BSICWXMH.js} +1 -1
- package/dist/chunk-BVK5A7ED.js +28 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-L7JMDDSD.js → chunk-FBOW7XOV.js} +1 -1
- package/dist/{chunk-25CZ5ZIU.js → chunk-FUG2TEKI.js} +1 -1
- package/dist/chunk-FZBCKIJJ.js +1 -0
- package/dist/chunk-HPUAIWIH.js +25 -0
- package/dist/chunk-I5JLCFUX.js +1 -0
- package/dist/chunk-KUPHNMUK.js +2 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-MIZAFRDR.js +1 -0
- package/dist/chunk-PJPA5EEE.js +2 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-QEJGED4V.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/{chunk-VXD6FZP5.js → chunk-TQZBVOTT.js} +3 -3
- package/dist/chunk-VBICI5YA.js +1 -0
- package/dist/chunk-VWW3RLUX.js +12 -0
- package/dist/{chunk-O6LE42GK.js → chunk-WJTHY6AG.js} +1 -1
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/chunk-ZODCBFBL.js +2 -0
- package/dist/chunk-ZPT5D4VP.js +2 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +11 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +2 -2
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -12
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +4 -4
- package/dist/entry-51.js +9 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +0 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -315
- package/dist/entry-78.js +324 -25
- package/dist/entry-79.js +18 -2
- package/dist/entry-80.js +2 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +1 -3
- package/dist/entry-83.js +5 -3
- package/dist/entry-84.js +3 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/apply.md +1 -1
- package/docs/agent-guides/editing.md +16 -0
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +6 -0
- package/docs/agent-guides/search-code.md +5 -1
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +34 -0
- package/docs/development.md +15 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- package/docs/research/native-codemode-batch-decision.md +27 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +59 -0
- package/docs/tools.md +18 -2
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-documentation/src/index.ts +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +6 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -6
- package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +10 -10
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +17 -0
- package/node_modules/pi-agent-ide-changes/index.ts +3 -9
- package/node_modules/pi-agent-ide-changes/package.json +8 -7
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/tools/read.ts +31 -2
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +12 -0
- package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
- package/node_modules/pi-agent-search/package.json +5 -4
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/node_modules/pi-agent-search/src/api/search.ts +11 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +93 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +40 -14
- package/node_modules/pi-agent-search/src/core/search-core.ts +136 -77
- package/node_modules/pi-agent-search-text/index.ts +3 -0
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/resolvers.ts +17 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -8
- package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +37 -3
- package/node_modules/pi-agent-search-text/src/search-session.ts +21 -13
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-document.ts +15 -10
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/index.ts +4 -2
- package/node_modules/pi-agent-text-editor/package.json +21 -17
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +314 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +8 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +7 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-web/index.ts +20 -0
- package/node_modules/pi-agent-web/package.json +8 -7
- package/node_modules/pi-agent-web/src/search.ts +112 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +2 -0
- package/package.json +42 -36
- package/skills/capture-code-review-rule/SKILL.md +60 -0
- package/src/code-review/config.ts +68 -0
- package/src/code-review/extension.ts +105 -0
- package/src/code-review/fragments.ts +26 -0
- package/src/code-review/reviewer.ts +198 -0
- package/src/composite/host-version.ts +13 -0
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/tool-availability.ts +90 -0
- package/src/core/extension.ts +2 -0
- package/src/documentation/extension.ts +81 -145
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -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-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/plugins/pi-agent-web-text/runtime/entry-87.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +112 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +31 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -0
- 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/resolvers.ts +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +37 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +21 -13
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/src/extensions/pi-agent-search/src/api/search.ts +11 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +93 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +40 -14
- package/src/extensions/pi-agent-search/src/core/search-core.ts +136 -77
- package/src/extensions/pi-agent-text-editor/index.ts +4 -2
- package/src/extensions/pi-agent-text-editor/package.json +21 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +8 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- 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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +314 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/src/pi-agent-ide.ts +61 -2
- package/src/plugins/pi-agent-ide-ast/package.json +10 -10
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +17 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +3 -9
- package/src/plugins/pi-agent-ide-changes/package.json +8 -7
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
- package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
- package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +13 -8
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
- package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +97 -45
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +16 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-CEX3VOJ7.js +0 -2
- package/dist/chunk-FA6BKC5Y.js +0 -1
- package/dist/chunk-FEDVTZJG.js +0 -1
- package/dist/chunk-HMLH43ZS.js +0 -4
- package/dist/chunk-KII2JQC5.js +0 -1
- package/dist/chunk-LVWMWWWF.js +0 -28
- package/dist/chunk-P7XO5CIP.js +0 -2
- package/dist/chunk-PZFOOHY2.js +0 -15
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-YT42LKFV.js +0 -16
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- /package/dist/{chunk-4U2GUKNJ.js → chunk-F7NVAC4Q.js} +0 -0
- /package/dist/{chunk-ROXXK6TW.js → chunk-PXWDDBBC.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { formatApplySource } from "./format-source.js";
|
|
2
|
+
import { applyOutputSchema, structuredApply } from "./structured-result.js";
|
|
2
3
|
import { applyHelperGuide } from "#src/core/apply/prompt.js";
|
|
3
4
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
5
|
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
@@ -11,6 +12,7 @@ import { connectSearchPlugin } from "pi-agent-search/api/connect-plugin";
|
|
|
11
12
|
import { SEARCH_API_VERSION, SEARCH_PROTOCOL } from "pi-agent-search/api/plugin-protocol";
|
|
12
13
|
import type { SearchPluginApi } from "pi-agent-search/api/search";
|
|
13
14
|
import { Type } from "typebox";
|
|
15
|
+
import { EDITING_GUIDELINES } from "#src/core/editing-guidelines.js";
|
|
14
16
|
import {
|
|
15
17
|
getLastResolvedResource,
|
|
16
18
|
rememberLastResolvedResource,
|
|
@@ -48,6 +50,17 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
|
|
|
48
50
|
const operations = getApplyOperations();
|
|
49
51
|
pi.registerTool({
|
|
50
52
|
name: "apply",
|
|
53
|
+
exposure: "model-only",
|
|
54
|
+
namespace: {
|
|
55
|
+
name: "ide_edit",
|
|
56
|
+
description: "Edit files and live IDE resources with guarded operations.",
|
|
57
|
+
},
|
|
58
|
+
annotations: {
|
|
59
|
+
readOnlyHint: false,
|
|
60
|
+
destructiveHint: true,
|
|
61
|
+
idempotentHint: false,
|
|
62
|
+
openWorldHint: true,
|
|
63
|
+
},
|
|
51
64
|
label: "Apply",
|
|
52
65
|
renderShell: "self",
|
|
53
66
|
renderCall: (args, theme, context) => {
|
|
@@ -63,13 +76,14 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
|
|
|
63
76
|
description:
|
|
64
77
|
`Use apply to run read-only IDE operations and snapshot-guarded editor transactions in JavaScript. Output has one 2000-line/50KB budget. No shell, imports or resume.` +
|
|
65
78
|
applyHelperGuide(),
|
|
66
|
-
promptGuidelines: [],
|
|
79
|
+
promptGuidelines: [...EDITING_GUIDELINES],
|
|
67
80
|
parameters: Type.Object({
|
|
68
81
|
source: Type.String({
|
|
69
82
|
description:
|
|
70
83
|
"JavaScript function body. Call IDE functions directly without await; each call finishes before the next statement. Read-only results are recorded automatically. The UI may compact written tool calls or format a display copy; execution uses this source unchanged.",
|
|
71
84
|
}),
|
|
72
85
|
}),
|
|
86
|
+
outputSchema: applyOutputSchema,
|
|
73
87
|
async execute(_id, { source }, signal, _onUpdate, context) {
|
|
74
88
|
if (read === undefined || search === undefined)
|
|
75
89
|
throw new Error("Apply requires the read and search extensions");
|
|
@@ -120,18 +134,24 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
|
|
|
120
134
|
text: `Undo transaction: ${transaction}`,
|
|
121
135
|
})),
|
|
122
136
|
];
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
return structuredApply(
|
|
138
|
+
{
|
|
139
|
+
content,
|
|
140
|
+
details: {
|
|
141
|
+
failed,
|
|
142
|
+
displaySource: await displaySource,
|
|
143
|
+
outputLevel: output.level,
|
|
144
|
+
display: createApplyDisplay(execution.results, output, error, context.cwd),
|
|
145
|
+
temporarySource: output.temporarySource,
|
|
146
|
+
files: execution.results.select().files.map(({ source: file }) => file),
|
|
147
|
+
transactions,
|
|
148
|
+
},
|
|
133
149
|
},
|
|
134
|
-
|
|
150
|
+
execution.results,
|
|
151
|
+
read,
|
|
152
|
+
transactions,
|
|
153
|
+
error,
|
|
154
|
+
);
|
|
135
155
|
},
|
|
136
156
|
});
|
|
137
157
|
pi.on("tool_result", (event) => {
|
|
@@ -83,7 +83,7 @@ export interface ApplyOperationOutcome {
|
|
|
83
83
|
|
|
84
84
|
export type TransactionEditor = Pick<
|
|
85
85
|
TextEditorCore,
|
|
86
|
-
"editTexts" | "postProcessFile" | "recordApplyUndo"
|
|
86
|
+
"editTexts" | "postProcessFile" | "recordApplyUndo" | "enqueueFileOperation"
|
|
87
87
|
>;
|
|
88
88
|
|
|
89
89
|
/** Optional transaction execution dependencies for deterministic failure handling. */
|
|
@@ -105,143 +105,165 @@ export async function executeEditorTransaction(
|
|
|
105
105
|
const snapshots = new Map(request.snapshots.map((snapshot) => [snapshot.id, snapshot]));
|
|
106
106
|
if (snapshots.size !== request.snapshots.length) throw invalid("Duplicate editor snapshot id");
|
|
107
107
|
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
const reserved = [
|
|
109
|
+
...new Set(
|
|
110
|
+
request.operations.flatMap((operation) =>
|
|
111
|
+
operationResources(operation, snapshots, context.cwd),
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
];
|
|
115
|
+
return editor.enqueueFileOperation(
|
|
116
|
+
async (): Promise<ScriptMutationOutcome> => {
|
|
117
|
+
const accepted = new Map<string, TextChange[]>();
|
|
118
|
+
const unknown = new Set<string>();
|
|
119
|
+
const journal = new Map<string, SavedPath>();
|
|
120
|
+
const files: ScriptMutationFile[] = [];
|
|
121
|
+
const operations: ApplyOperationOutcome[] = [];
|
|
122
|
+
const cwd = context.cwd;
|
|
123
|
+
const batchedReplacements = new Set<number>();
|
|
115
124
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
index,
|
|
166
|
-
kind: operation.kind,
|
|
167
|
-
status: "blocked",
|
|
168
|
-
effect: "unknown",
|
|
169
|
-
resources,
|
|
170
|
-
error: {
|
|
171
|
-
code: "DEPENDENCY_UNKNOWN",
|
|
172
|
-
message: "A prior operation left a required resource in an unknown state.",
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (operation.kind === "replace") {
|
|
178
|
-
const snapshot = snapshots.get(operation.selection.document);
|
|
179
|
-
const prior = snapshot === undefined ? [] : (accepted.get(snapshot.source) ?? []);
|
|
180
|
-
if (prior.some((change) => overlaps(change, operation.selection))) {
|
|
181
|
-
operations.push(
|
|
182
|
-
failed(
|
|
125
|
+
for (const [index, operation] of request.operations.entries()) {
|
|
126
|
+
const resources = operationResources(operation, snapshots, cwd);
|
|
127
|
+
if (batchedReplacements.has(index)) continue;
|
|
128
|
+
if (operation.kind === "replace") {
|
|
129
|
+
const replacements: Array<{ index: number; operation: TextOperation }> = [];
|
|
130
|
+
for (
|
|
131
|
+
let candidateIndex = index;
|
|
132
|
+
candidateIndex < request.operations.length;
|
|
133
|
+
candidateIndex += 1
|
|
134
|
+
) {
|
|
135
|
+
const candidate = request.operations[candidateIndex];
|
|
136
|
+
if (
|
|
137
|
+
candidate?.kind !== "replace" ||
|
|
138
|
+
candidate.selection.document !== operation.selection.document
|
|
139
|
+
)
|
|
140
|
+
break;
|
|
141
|
+
replacements.push({ index: candidateIndex, operation: candidate });
|
|
142
|
+
}
|
|
143
|
+
if (replacements.length > 1) {
|
|
144
|
+
for (const replacement of replacements) batchedReplacements.add(replacement.index);
|
|
145
|
+
const outcome = await executeReplacementBatch(
|
|
146
|
+
replacements,
|
|
147
|
+
snapshots,
|
|
148
|
+
accepted,
|
|
149
|
+
editor,
|
|
150
|
+
cwd,
|
|
151
|
+
signal,
|
|
152
|
+
options,
|
|
153
|
+
);
|
|
154
|
+
for (const state of outcome.saved)
|
|
155
|
+
if (!journal.has(state.path)) journal.set(state.path, state);
|
|
156
|
+
files.push(...outcome.files);
|
|
157
|
+
operations.push(...outcome.operations);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (operation.kind === "warning") {
|
|
162
|
+
operations.push({
|
|
163
|
+
index,
|
|
164
|
+
kind: "warning",
|
|
165
|
+
status: "warning",
|
|
166
|
+
effect: "not-applied",
|
|
167
|
+
resources,
|
|
168
|
+
warning: warningDetails(operation),
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (resources.some((resource) => unknown.has(resource))) {
|
|
173
|
+
operations.push({
|
|
183
174
|
index,
|
|
175
|
+
kind: operation.kind,
|
|
176
|
+
status: "blocked",
|
|
177
|
+
effect: "unknown",
|
|
178
|
+
resources,
|
|
179
|
+
error: {
|
|
180
|
+
code: "DEPENDENCY_UNKNOWN",
|
|
181
|
+
message: "A prior operation left a required resource in an unknown state.",
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (operation.kind === "replace") {
|
|
187
|
+
const snapshot = snapshots.get(operation.selection.document);
|
|
188
|
+
const prior = snapshot === undefined ? [] : (accepted.get(snapshot.source) ?? []);
|
|
189
|
+
if (prior.some((change) => overlaps(change, operation.selection))) {
|
|
190
|
+
operations.push(
|
|
191
|
+
failed(
|
|
192
|
+
index,
|
|
193
|
+
operation,
|
|
194
|
+
resources,
|
|
195
|
+
invalid(`Overlapping selection in ${snapshot?.source ?? "unknown snapshot"}`),
|
|
196
|
+
),
|
|
197
|
+
);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
let saved: readonly SavedPath[] = [];
|
|
203
|
+
try {
|
|
204
|
+
await validateOperation(operation, snapshots, accepted, cwd);
|
|
205
|
+
saved = await Promise.all(resources.map(savePath));
|
|
206
|
+
const produced = await executeOperation(
|
|
184
207
|
operation,
|
|
208
|
+
snapshots,
|
|
209
|
+
accepted,
|
|
210
|
+
editor,
|
|
211
|
+
cwd,
|
|
212
|
+
signal,
|
|
213
|
+
);
|
|
214
|
+
for (const state of saved) if (!journal.has(state.path)) journal.set(state.path, state);
|
|
215
|
+
files.push(...produced);
|
|
216
|
+
operations.push({
|
|
217
|
+
index,
|
|
218
|
+
kind: operation.kind,
|
|
219
|
+
status: "applied",
|
|
220
|
+
effect: "applied",
|
|
185
221
|
resources,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
222
|
+
});
|
|
223
|
+
} catch (error) {
|
|
224
|
+
const rollbackErrors = await rollback(saved, options.restorePath);
|
|
225
|
+
if (rollbackErrors.length > 0) {
|
|
226
|
+
for (const resource of resources) unknown.add(resource);
|
|
227
|
+
operations.push({
|
|
228
|
+
index,
|
|
229
|
+
kind: operation.kind,
|
|
230
|
+
status: "unknown",
|
|
231
|
+
effect: "unknown",
|
|
232
|
+
resources,
|
|
233
|
+
error: codedError(error, rollbackErrors),
|
|
234
|
+
});
|
|
235
|
+
} else operations.push(failed(index, operation, resources, error));
|
|
236
|
+
}
|
|
190
237
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
let saved: readonly SavedPath[] = [];
|
|
194
|
-
try {
|
|
195
|
-
await validateOperation(operation, snapshots, accepted, cwd);
|
|
196
|
-
saved = await Promise.all(resources.map(savePath));
|
|
197
|
-
const produced = await executeOperation(operation, snapshots, accepted, editor, cwd, signal);
|
|
198
|
-
for (const state of saved) if (!journal.has(state.path)) journal.set(state.path, state);
|
|
199
|
-
files.push(...produced);
|
|
200
|
-
operations.push({
|
|
201
|
-
index,
|
|
202
|
-
kind: operation.kind,
|
|
203
|
-
status: "applied",
|
|
204
|
-
effect: "applied",
|
|
205
|
-
resources,
|
|
206
|
-
});
|
|
207
|
-
} catch (error) {
|
|
208
|
-
const rollbackErrors = await rollback(saved, options.restorePath);
|
|
209
|
-
if (rollbackErrors.length > 0) {
|
|
210
|
-
for (const resource of resources) unknown.add(resource);
|
|
211
|
-
operations.push({
|
|
212
|
-
index,
|
|
213
|
-
kind: operation.kind,
|
|
214
|
-
status: "unknown",
|
|
215
|
-
effect: "unknown",
|
|
216
|
-
resources,
|
|
217
|
-
error: codedError(error, rollbackErrors),
|
|
218
|
-
});
|
|
219
|
-
} else operations.push(failed(index, operation, resources, error));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
238
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
239
|
+
const successful = operations.some(({ effect }) => effect === "applied");
|
|
240
|
+
const transaction = successful
|
|
241
|
+
? await editor.recordApplyUndo([...journal.values()])
|
|
242
|
+
: undefined;
|
|
243
|
+
return {
|
|
244
|
+
operation: "apply",
|
|
245
|
+
ok: operations.length > 0 && operations.every(({ status }) => status === "applied"),
|
|
246
|
+
effect: unknown.size > 0 ? "unknown" : successful ? "applied" : "not-applied",
|
|
247
|
+
...(transaction === undefined ? {} : { transaction }),
|
|
248
|
+
files,
|
|
249
|
+
completed: [
|
|
250
|
+
...new Set(
|
|
251
|
+
operations
|
|
252
|
+
.filter(({ effect }) => effect === "applied")
|
|
253
|
+
.flatMap(({ resources }) => resources),
|
|
254
|
+
),
|
|
255
|
+
],
|
|
256
|
+
errors: operations.flatMap((item) =>
|
|
257
|
+
item.status === "warning" || item.error === undefined
|
|
258
|
+
? []
|
|
259
|
+
: [{ source: item.resources.join(", "), ...item.error }],
|
|
260
|
+
),
|
|
261
|
+
operations,
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
signal,
|
|
265
|
+
{ cwd: context.cwd, sources: reserved, allowNestedEdits: true },
|
|
266
|
+
);
|
|
245
267
|
}
|
|
246
268
|
|
|
247
269
|
async function executeReplacementBatch(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
/** Withdraws Pi's built-in edit from declarations, discovery and nested execution. */
|
|
5
|
+
export function hideBuiltinEdit(pi: ExtensionAPI): void {
|
|
6
|
+
pi.registerTool({
|
|
7
|
+
name: "edit",
|
|
8
|
+
label: "edit",
|
|
9
|
+
description: "",
|
|
10
|
+
exposure: "hidden",
|
|
11
|
+
parameters: Type.Object({}, { additionalProperties: false }),
|
|
12
|
+
execute() {
|
|
13
|
+
throw new Error("Hidden edit must never execute.");
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -17,6 +17,25 @@ import type { ReadPluginApi } from "pi-agent-read/api/plugin-protocol";
|
|
|
17
17
|
import type { TextEditorCore } from "#src/core/text-editor-core.js";
|
|
18
18
|
import { createUnifiedDiff, type DiffStats } from "#src/core/mutation-result/diff.js";
|
|
19
19
|
import { FileMutationResult } from "#src/core/mutation-result/file-mutation-result.js";
|
|
20
|
+
import { resultError, structuredResultSchema, withStructuredResult } from "pi-agent-resource";
|
|
21
|
+
const comparisonSourceSchema = Type.Object(
|
|
22
|
+
{ source: Type.String(), sources: Type.Array(Type.String()) },
|
|
23
|
+
{ additionalProperties: false },
|
|
24
|
+
);
|
|
25
|
+
export const diffDataSchema = Type.Object(
|
|
26
|
+
{
|
|
27
|
+
kind: Type.Literal("diff"),
|
|
28
|
+
equal: Type.Boolean(),
|
|
29
|
+
before: comparisonSourceSchema,
|
|
30
|
+
after: comparisonSourceSchema,
|
|
31
|
+
stats: Type.Object({ added: Type.Integer(), removed: Type.Integer() }),
|
|
32
|
+
diff: Type.String(),
|
|
33
|
+
truncated: Type.Boolean(),
|
|
34
|
+
fullResult: Type.Optional(Type.String()),
|
|
35
|
+
},
|
|
36
|
+
{ additionalProperties: false },
|
|
37
|
+
);
|
|
38
|
+
export const diffOutputSchema = structuredResultSchema(diffDataSchema);
|
|
20
39
|
|
|
21
40
|
const source = Type.Union([Type.String({ minLength: 1 }), readParameters]);
|
|
22
41
|
/** Each side accepts a source string or the same request object as read. */
|
|
@@ -153,8 +172,18 @@ export function registerDiff(
|
|
|
153
172
|
): void {
|
|
154
173
|
pi.registerTool({
|
|
155
174
|
name: "diff",
|
|
175
|
+
exposure: "direct",
|
|
176
|
+
namespace: { name: "ide_read", description: "Read resources and compare sources." },
|
|
177
|
+
// Inputs use the same polymorphic resource pipeline as Read.
|
|
178
|
+
annotations: {
|
|
179
|
+
readOnlyHint: false,
|
|
180
|
+
destructiveHint: true,
|
|
181
|
+
idempotentHint: false,
|
|
182
|
+
openWorldHint: true,
|
|
183
|
+
},
|
|
156
184
|
label: "Diff",
|
|
157
185
|
parameters: diffParameters,
|
|
186
|
+
outputSchema: diffOutputSchema,
|
|
158
187
|
promptSnippet: "Compare two text-readable sources",
|
|
159
188
|
description:
|
|
160
189
|
"Use diff to compare two sources. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference. The same diff function is available inside Apply.",
|
|
@@ -180,26 +209,53 @@ export function registerDiff(
|
|
|
180
209
|
async execute(_id, args, signal, _update, context) {
|
|
181
210
|
const read = getRead();
|
|
182
211
|
if (read === undefined) throw new Error("Diff requires the read extension");
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
try {
|
|
213
|
+
const comparison = await executeDiff(read, args, { cwd: context.cwd, signal });
|
|
214
|
+
const full = diffText(comparison);
|
|
215
|
+
const bounded = truncateHead(full);
|
|
216
|
+
const temporarySource = bounded.truncated ? await read.saveTemporary(full) : undefined;
|
|
217
|
+
const footer = temporarySource === undefined ? "" : `\nFull diff: ${temporarySource}`;
|
|
218
|
+
return withStructuredResult(
|
|
219
|
+
{
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: "text" as const,
|
|
223
|
+
text:
|
|
224
|
+
temporarySource === undefined
|
|
225
|
+
? full
|
|
226
|
+
: truncateHead(full, {
|
|
227
|
+
maxLines: DEFAULT_MAX_LINES - 2,
|
|
228
|
+
maxBytes: DEFAULT_MAX_BYTES - Buffer.byteLength(footer),
|
|
229
|
+
}).content + footer,
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
details: { ...diffPresentation(comparison, context.cwd), comparison, temporarySource },
|
|
233
|
+
},
|
|
234
|
+
diffDataSchema,
|
|
190
235
|
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
236
|
+
status: "success",
|
|
237
|
+
data: {
|
|
238
|
+
kind: "diff",
|
|
239
|
+
equal: comparison.equal,
|
|
240
|
+
before: { source: comparison.before.source, sources: comparison.before.sources },
|
|
241
|
+
after: { source: comparison.after.source, sources: comparison.after.sources },
|
|
242
|
+
stats: comparison.stats,
|
|
243
|
+
diff: bounded.content,
|
|
244
|
+
truncated: bounded.truncated,
|
|
245
|
+
...(temporarySource === undefined ? {} : { fullResult: temporarySource }),
|
|
246
|
+
},
|
|
247
|
+
errors: [],
|
|
199
248
|
},
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
249
|
+
);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
if (signal?.aborted) throw error;
|
|
252
|
+
const failure = resultError(error, "DIFF_FAILED");
|
|
253
|
+
return withStructuredResult(
|
|
254
|
+
{ content: [{ type: "text", text: failure.message }], details: {} },
|
|
255
|
+
diffDataSchema,
|
|
256
|
+
{ status: "error", errors: [failure] },
|
|
257
|
+
);
|
|
258
|
+
}
|
|
203
259
|
},
|
|
204
260
|
});
|
|
205
261
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Shared editing workflows owned by enabled mutation tools and Apply. */
|
|
2
|
+
export const EDITING_GUIDELINES = [
|
|
3
|
+
"Use the smallest useful source view: reuse sufficient content and anchors, search for known text, or inspect structure when locating a declaration. Read nearby context when boundaries are unclear; resolve ambiguity rather than guessing.",
|
|
4
|
+
"Use an available anchor when it selects exactly the intended text; otherwise use minimal unique exact text. Keep the edit limited to the intended content.",
|
|
5
|
+
"When search broadens to separate words, treat its results as location hints. Refine the query before using those matches for replacement.",
|
|
6
|
+
"Use standalone mutation tools in one assistant-response batch when each change is known in advance and does not depend on another change. This is the default for several independent edits in one file or across files. Every call is evaluated against the original file snapshots. Combine overlapping changes into one mutation. Use Apply only when edits require computation, conditions, selection composition, checkpoints, or one coherent cross-file transaction. Check each batch result and retry only unapplied changes.",
|
|
7
|
+
"Inside native Codemode, submit independent local text-edit calls on disjoint resource sets concurrently; await calls on overlapping sets in order. Check each result's status. Await tools.flush({}) when later script work needs a committed receipt. Check the parent result for automatic batch commits before retrying an accepted call. Read docs:editing for batch boundaries and dependent work.",
|
|
8
|
+
] as const;
|
|
@@ -31,6 +31,12 @@ export async function executeWholeFileTool(
|
|
|
31
31
|
const outcome = await core.enqueueFileOperation(
|
|
32
32
|
() => executeFileOperation(operation, input, context.cwd, signal),
|
|
33
33
|
signal,
|
|
34
|
+
{
|
|
35
|
+
cwd: context.cwd,
|
|
36
|
+
sources: [input.path, input.target].filter(
|
|
37
|
+
(value): value is string => typeof value === "string",
|
|
38
|
+
),
|
|
39
|
+
},
|
|
34
40
|
);
|
|
35
41
|
let postProcessingError: string | undefined;
|
|
36
42
|
if (outcome.ok && outcome.target !== undefined) {
|
|
@@ -267,6 +267,8 @@ export interface FileMutationData {
|
|
|
267
267
|
* Phases are batch-wide (gate runs once for all files), not per-FMR.
|
|
268
268
|
*/
|
|
269
269
|
export interface FileMutationBatchResult {
|
|
270
|
+
/** Observed effects of a failed execution, independent of its error state. */
|
|
271
|
+
readonly effect?: "applied" | "not-applied" | "unknown";
|
|
270
272
|
/** Structured contributions from configured IDE mutation handlers. */
|
|
271
273
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
272
274
|
/**
|