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,6 +1,7 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
2
|
import {
|
|
3
3
|
createDiffModel,
|
|
4
|
+
compareInlineText,
|
|
4
5
|
DIFF_CONTEXT_LINES,
|
|
5
6
|
type DiffModel,
|
|
6
7
|
type DiffRow,
|
|
@@ -204,7 +205,7 @@ function advanceTypingProjectionResource(
|
|
|
204
205
|
);
|
|
205
206
|
const row = model.rows[rowIndex];
|
|
206
207
|
|
|
207
|
-
if (row === undefined || row.kind === "omitted") {
|
|
208
|
+
if (row === undefined || row.kind === "omitted" || row.beforeLine !== undefined) {
|
|
208
209
|
return undefined;
|
|
209
210
|
}
|
|
210
211
|
|
|
@@ -222,7 +223,7 @@ function advanceTypingProjectionResource(
|
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
const rows = [...model.rows];
|
|
225
|
-
const kind =
|
|
226
|
+
const kind = "added";
|
|
226
227
|
rows[rowIndex] = {
|
|
227
228
|
...row,
|
|
228
229
|
kind,
|
|
@@ -237,8 +238,8 @@ function advanceTypingProjectionResource(
|
|
|
237
238
|
model: {
|
|
238
239
|
...model,
|
|
239
240
|
rows,
|
|
240
|
-
added: model.added +
|
|
241
|
-
modified: model.modified
|
|
241
|
+
added: model.added + 1 - (row.kind === "added" ? 1 : 0),
|
|
242
|
+
modified: model.modified - (row.kind === "modified" ? 1 : 0),
|
|
242
243
|
focusRow: rowIndex,
|
|
243
244
|
},
|
|
244
245
|
};
|
|
@@ -272,6 +273,7 @@ function advanceFullFileTypingResource(
|
|
|
272
273
|
let added = model.added;
|
|
273
274
|
let modified = model.modified;
|
|
274
275
|
const isAfterNewline = previousVisibleText.endsWith("\n");
|
|
276
|
+
const deadline = performance.now() + 100;
|
|
275
277
|
const active = rows.at(-1);
|
|
276
278
|
const suffix = [...fullFileLines(isAfterNewline ? appended : `${active?.text ?? ""}${appended}`)];
|
|
277
279
|
|
|
@@ -281,8 +283,14 @@ function advanceFullFileTypingResource(
|
|
|
281
283
|
requiredValue(suffix[0]),
|
|
282
284
|
rows.length - 1,
|
|
283
285
|
visibleText.endsWith("\n") && suffix.length === 1 && requiredValue(suffix[0]).length === 0,
|
|
286
|
+
suffix.length > 1,
|
|
287
|
+
deadline,
|
|
284
288
|
);
|
|
285
|
-
if (
|
|
289
|
+
if (
|
|
290
|
+
active.text !== next.text ||
|
|
291
|
+
active.kind !== next.kind ||
|
|
292
|
+
active.deletedOffsets?.join(",") !== next.deletedOffsets?.join(",")
|
|
293
|
+
) {
|
|
286
294
|
added += (next.kind === "added" ? 1 : 0) - (active.kind === "added" ? 1 : 0);
|
|
287
295
|
modified += (next.kind === "modified" ? 1 : 0) - (active.kind === "modified" ? 1 : 0);
|
|
288
296
|
rows[rows.length - 1] = next;
|
|
@@ -296,6 +304,8 @@ function advanceFullFileTypingResource(
|
|
|
296
304
|
text,
|
|
297
305
|
rows.length,
|
|
298
306
|
offset === suffix.length - 1 && visibleText.endsWith("\n"),
|
|
307
|
+
offset < suffix.length - 1,
|
|
308
|
+
deadline,
|
|
299
309
|
);
|
|
300
310
|
rows.push(row);
|
|
301
311
|
modified += row.kind === "modified" ? 1 : 0;
|
|
@@ -326,6 +336,8 @@ function createTypingLine(
|
|
|
326
336
|
text: string,
|
|
327
337
|
index: number,
|
|
328
338
|
isTrailingCursorRow = false,
|
|
339
|
+
complete = false,
|
|
340
|
+
deadline = performance.now() + 100,
|
|
329
341
|
): DiffRow {
|
|
330
342
|
const beforeText = beforeLines[index];
|
|
331
343
|
if (isTrailingCursorRow || beforeText?.trim() === text.trim()) {
|
|
@@ -344,7 +356,7 @@ function createTypingLine(
|
|
|
344
356
|
...(beforeText !== undefined && { beforeLine: index + 1 }),
|
|
345
357
|
afterLine: index + 1,
|
|
346
358
|
changed: true,
|
|
347
|
-
|
|
359
|
+
...typingChanges(beforeText, text, complete, deadline),
|
|
348
360
|
};
|
|
349
361
|
}
|
|
350
362
|
|
|
@@ -462,9 +474,8 @@ function createTypingModel(
|
|
|
462
474
|
project: false,
|
|
463
475
|
focusAfterLine: cursorLine,
|
|
464
476
|
} as const;
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
);
|
|
477
|
+
const visibleModel = createDiffModel(beforeWindow, afterWindow, [], modelOptions);
|
|
478
|
+
const rows = visibleModel.rows.flatMap(projectTypingRow);
|
|
468
479
|
const focusRow = typingFocusRow(rows, cursorLine);
|
|
469
480
|
const finalAfterWindow =
|
|
470
481
|
resource.beforeContent.slice(windowFrom, beforeRange.from) +
|
|
@@ -483,6 +494,9 @@ function createTypingModel(
|
|
|
483
494
|
|
|
484
495
|
return {
|
|
485
496
|
rows: canonicalRows,
|
|
497
|
+
...(visibleModel.omittedChanges !== undefined && {
|
|
498
|
+
omittedChanges: visibleModel.omittedChanges,
|
|
499
|
+
}),
|
|
486
500
|
added: canonicalRows.filter(({ kind }) => kind === "added").length,
|
|
487
501
|
modified: canonicalRows.filter(({ kind }) => kind === "modified").length,
|
|
488
502
|
removed: 0,
|
|
@@ -510,6 +524,7 @@ function createFullFileTypingModel(
|
|
|
510
524
|
): DiffModel {
|
|
511
525
|
const beforeLines = fullFileLines(beforeContent);
|
|
512
526
|
const visibleLines = fullFileLines(visibleContent);
|
|
527
|
+
const deadline = performance.now() + 100;
|
|
513
528
|
const cursorLine = lineAtOffset(visibleContent, cursorOffset);
|
|
514
529
|
const rows: DiffRow[] = visibleLines.map((text, index) => {
|
|
515
530
|
const line = index + 1;
|
|
@@ -536,7 +551,7 @@ function createFullFileTypingModel(
|
|
|
536
551
|
...(beforeText !== undefined && { beforeLine: line }),
|
|
537
552
|
afterLine: line,
|
|
538
553
|
changed: true,
|
|
539
|
-
|
|
554
|
+
...typingChanges(beforeText, text, index < visibleLines.length - 1, deadline),
|
|
540
555
|
};
|
|
541
556
|
});
|
|
542
557
|
|
|
@@ -565,6 +580,21 @@ function projectTypingRow(row: DiffRow): readonly DiffRow[] {
|
|
|
565
580
|
return row.kind === "added" ? [{ ...row, addedRanges: typingTextRanges(row.text) }] : [row];
|
|
566
581
|
}
|
|
567
582
|
|
|
583
|
+
function typingChanges(
|
|
584
|
+
before: string | undefined,
|
|
585
|
+
after: string,
|
|
586
|
+
complete: boolean,
|
|
587
|
+
deadline: number,
|
|
588
|
+
) {
|
|
589
|
+
if (before === undefined) return { addedRanges: typingTextRanges(after) };
|
|
590
|
+
const changes = compareInlineText(before, after, deadline);
|
|
591
|
+
return changes === undefined
|
|
592
|
+
? { addedRanges: [], inlineUnavailable: true }
|
|
593
|
+
: {
|
|
594
|
+
...changes,
|
|
595
|
+
deletedOffsets: complete ? changes.deletedOffsets : [],
|
|
596
|
+
};
|
|
597
|
+
}
|
|
568
598
|
function typingTextRanges(text: string): readonly DiffTextRange[] {
|
|
569
599
|
const from = text.length - text.trimStart().length;
|
|
570
600
|
const to = text.trimEnd().length;
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ function createHandler(
|
|
|
77
77
|
const toolNames: string[] = [];
|
|
78
78
|
const knownPaths = new Map<number, string>();
|
|
79
79
|
const checks = new Map<number, Map<string, TextAnchorInspectionOutcome>>();
|
|
80
|
+
const blocks = new Map<number, Map<string, InterceptResult>>();
|
|
80
81
|
|
|
81
82
|
const handler: ToolCallInterceptorHandler = {
|
|
82
83
|
name: "text-editor-stale-anchor-inspection",
|
|
@@ -110,6 +111,7 @@ function createHandler(
|
|
|
110
111
|
arguments_,
|
|
111
112
|
source,
|
|
112
113
|
checks,
|
|
114
|
+
blocks,
|
|
113
115
|
);
|
|
114
116
|
|
|
115
117
|
if (pairBlock !== undefined) {
|
|
@@ -146,6 +148,7 @@ function createHandler(
|
|
|
146
148
|
[anchor],
|
|
147
149
|
[descriptor.kinds],
|
|
148
150
|
checks,
|
|
151
|
+
blocks,
|
|
149
152
|
);
|
|
150
153
|
|
|
151
154
|
if (block !== undefined) {
|
|
@@ -157,13 +160,16 @@ function createHandler(
|
|
|
157
160
|
},
|
|
158
161
|
onContentEnd(contentIndex) {
|
|
159
162
|
checks.delete(contentIndex);
|
|
163
|
+
blocks.delete(contentIndex);
|
|
160
164
|
},
|
|
161
165
|
onAbort(contentIndex) {
|
|
162
166
|
checks.delete(contentIndex);
|
|
167
|
+
blocks.delete(contentIndex);
|
|
163
168
|
knownPaths.delete(contentIndex);
|
|
164
169
|
},
|
|
165
170
|
onAgentEnd() {
|
|
166
171
|
checks.clear();
|
|
172
|
+
blocks.clear();
|
|
167
173
|
knownPaths.clear();
|
|
168
174
|
},
|
|
169
175
|
};
|
|
@@ -225,6 +231,7 @@ async function inspectAnchorPair(
|
|
|
225
231
|
arguments_: Record<string, unknown>,
|
|
226
232
|
source: string,
|
|
227
233
|
checks: Map<number, Map<string, TextAnchorInspectionOutcome>>,
|
|
234
|
+
blocks: Map<number, Map<string, InterceptResult>>,
|
|
228
235
|
): Promise<InterceptResult | undefined> {
|
|
229
236
|
if (schema.pair === undefined) {
|
|
230
237
|
return undefined;
|
|
@@ -261,6 +268,7 @@ async function inspectAnchorPair(
|
|
|
261
268
|
[start, end],
|
|
262
269
|
[startDescriptor.kinds, endDescriptor.kinds],
|
|
263
270
|
checks,
|
|
271
|
+
blocks,
|
|
264
272
|
);
|
|
265
273
|
}
|
|
266
274
|
|
|
@@ -273,6 +281,7 @@ async function inspectAnchors(
|
|
|
273
281
|
anchors: readonly [string] | readonly [string, string],
|
|
274
282
|
kinds: readonly [readonly string[]] | readonly [readonly string[], readonly string[]],
|
|
275
283
|
checks: Map<number, Map<string, TextAnchorInspectionOutcome>>,
|
|
284
|
+
blocks: Map<number, Map<string, InterceptResult>>,
|
|
276
285
|
): Promise<InterceptResult | undefined> {
|
|
277
286
|
const contentIndex = context.contentIndex ?? -1;
|
|
278
287
|
const key = `${source}${CACHE_KEY_PART_SEPARATOR}${anchors.join(
|
|
@@ -280,6 +289,8 @@ async function inspectAnchors(
|
|
|
280
289
|
)}${CACHE_KEY_PART_SEPARATOR}${kinds
|
|
281
290
|
.map((accepted) => accepted.join(CACHE_KEY_LIST_SEPARATOR))
|
|
282
291
|
.join(CACHE_KEY_PART_SEPARATOR)}`;
|
|
292
|
+
const cachedBlock = blocks.get(contentIndex)?.get(key);
|
|
293
|
+
if (cachedBlock !== undefined) return cachedBlock;
|
|
283
294
|
let result = checks.get(contentIndex)?.get(key);
|
|
284
295
|
|
|
285
296
|
if (result === undefined) {
|
|
@@ -337,7 +348,11 @@ async function inspectAnchors(
|
|
|
337
348
|
...(!(readContext === undefined || readContext.length === 0) && { context: readContext }),
|
|
338
349
|
};
|
|
339
350
|
|
|
340
|
-
|
|
351
|
+
const block = makeBlockResult(details, result.reason);
|
|
352
|
+
const contentBlocks = blocks.get(contentIndex) ?? new Map<string, InterceptResult>();
|
|
353
|
+
contentBlocks.set(key, block);
|
|
354
|
+
blocks.set(contentIndex, contentBlocks);
|
|
355
|
+
return block;
|
|
341
356
|
}
|
|
342
357
|
|
|
343
358
|
function makeResolverBlockResult(
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.6.
|
|
7
|
-
"pi-agent-read": "0.6.
|
|
8
|
-
"pi-agent-text-editor": "0.6.
|
|
6
|
+
"pi-agent-invariant": "0.6.4",
|
|
7
|
+
"pi-agent-read": "0.6.4",
|
|
8
|
+
"pi-agent-text-editor": "0.6.4"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
12
|
-
"./runtime/entry-
|
|
12
|
+
"./runtime/entry-80.js"
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
@@ -15,6 +15,8 @@ export type TextMutationPreviewRanges = readonly TextMutationPreviewRange[];
|
|
|
15
15
|
export interface TextMutationPreviewResource {
|
|
16
16
|
readonly path: string;
|
|
17
17
|
readonly existed?: boolean;
|
|
18
|
+
/** Resolver that owns this snapshot and its write policy. */
|
|
19
|
+
readonly resolvedBy?: string;
|
|
18
20
|
readonly beforeRanges?: TextMutationPreviewRanges;
|
|
19
21
|
readonly link?: string;
|
|
20
22
|
readonly ranges: readonly TextMutationPreviewRange[];
|
|
@@ -25,3 +25,9 @@ export {
|
|
|
25
25
|
} from "#src/core/mutation-result/file-mutation-result.js";
|
|
26
26
|
|
|
27
27
|
export { type ChangedRange, computeChangedRanges } from "#src/core/mutation-result/diff.js";
|
|
28
|
+
export {
|
|
29
|
+
mutationDataSchema,
|
|
30
|
+
mutationOutputSchema,
|
|
31
|
+
structuredMutation,
|
|
32
|
+
type MutationData,
|
|
33
|
+
} from "#src/core/structured-result.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { FileMutationBatchResult } from "./mutation-result.js";
|
|
3
|
+
|
|
4
|
+
/** A finished native editor batch, sent through Pi's event bus without saving raw snapshots. */
|
|
5
|
+
export interface NativeEditBatchEvent {
|
|
6
|
+
readonly parentToolCallId: string;
|
|
7
|
+
readonly calls: readonly string[];
|
|
8
|
+
readonly result: AgentToolResult<FileMutationBatchResult>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Presentation listeners must compact the result before retaining it in history. */
|
|
12
|
+
export const NATIVE_EDIT_BATCH_EVENT = "pi-agent-text-editor:native-batch-finished";
|
|
@@ -72,6 +72,10 @@ export class ApplyUndoStore {
|
|
|
72
72
|
return this.#receipts.has(transaction);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/** Paths reserved by a receipt; unavailable receipts cannot restore any paths. */
|
|
76
|
+
public sources(transaction: string): readonly string[] {
|
|
77
|
+
return this.#receipts.get(transaction)?.paths.map((state) => state.path) ?? [];
|
|
78
|
+
}
|
|
75
79
|
public async restore(transaction: string): Promise<ApplyUndoResult> {
|
|
76
80
|
const receipt = this.#receipts.get(transaction);
|
|
77
81
|
if (receipt === undefined)
|
|
@@ -16,6 +16,9 @@ import { TextAnchorResolutionError } from "#src/core/text-anchor-registry.js";
|
|
|
16
16
|
import { buildFailedTextMutationResult } from "#src/core/text-mutation.js";
|
|
17
17
|
import { TextMutationAnchorResolutionError } from "#src/core/text-mutation-anchor-error.js";
|
|
18
18
|
|
|
19
|
+
// Leave room for the runner envelope below its 4 MB host-result limit.
|
|
20
|
+
const MAX_APPLY_BRIDGE_BYTES = 3 * 1024 * 1024;
|
|
21
|
+
|
|
19
22
|
/** Configured IDE services and ordinary tool schemas, shared with the standalone tools. */
|
|
20
23
|
export interface ApplyServices {
|
|
21
24
|
readonly editor: TextEditorCore;
|
|
@@ -35,7 +38,7 @@ export function createApplyExecution(
|
|
|
35
38
|
finish(): Promise<void>;
|
|
36
39
|
} {
|
|
37
40
|
const results = new ApplyResults();
|
|
38
|
-
const scope = createPostEditScope();
|
|
41
|
+
const scope = createPostEditScope(context.cwd);
|
|
39
42
|
let lastSource = services.lastResolvedSource;
|
|
40
43
|
const host: ApplyRuntimeHost = {
|
|
41
44
|
async execute(operation, arguments_, signal, id) {
|
|
@@ -185,7 +188,61 @@ export function createApplyExecution(
|
|
|
185
188
|
results.updateFile(file.source, file.before, file.after);
|
|
186
189
|
lastSource = file.source;
|
|
187
190
|
}
|
|
188
|
-
|
|
191
|
+
const fullResultBytes = Buffer.byteLength(JSON.stringify(response));
|
|
192
|
+
if (fullResultBytes <= MAX_APPLY_BRIDGE_BYTES) return response;
|
|
193
|
+
const fullResult = await services.read.saveTemporary(JSON.stringify(response, null, 2));
|
|
194
|
+
Object.assign(response, { truncated: true, fullResult, fullResultBytes });
|
|
195
|
+
const reduced = {
|
|
196
|
+
...response,
|
|
197
|
+
files: response.files.map(({ source, action }) => ({ source, action })),
|
|
198
|
+
truncated: true,
|
|
199
|
+
fullResult,
|
|
200
|
+
};
|
|
201
|
+
if (Buffer.byteLength(JSON.stringify(reduced)) <= MAX_APPLY_BRIDGE_BYTES) {
|
|
202
|
+
return reduced;
|
|
203
|
+
}
|
|
204
|
+
// Keep committed effects readable even when refreshed snapshots are too large.
|
|
205
|
+
const summary = {
|
|
206
|
+
operation: response.operation,
|
|
207
|
+
ok: response.ok,
|
|
208
|
+
effect: response.effect,
|
|
209
|
+
files: reduced.files,
|
|
210
|
+
completed: response.completed,
|
|
211
|
+
transaction: response.transaction,
|
|
212
|
+
errors: response.errors,
|
|
213
|
+
operations: response.operations,
|
|
214
|
+
snapshots: refreshed.map(({ id }) => ({ id, unavailable: true })),
|
|
215
|
+
truncated: true,
|
|
216
|
+
fullResult,
|
|
217
|
+
};
|
|
218
|
+
// Omitted entries remain available in fullResult; never invent effects for them.
|
|
219
|
+
const counts = {
|
|
220
|
+
operationCount: summary.operations?.length ?? 0,
|
|
221
|
+
fileCount: summary.files.length,
|
|
222
|
+
completedCount: summary.completed.length,
|
|
223
|
+
errorCount: summary.errors.length,
|
|
224
|
+
snapshotCount: summary.snapshots.length,
|
|
225
|
+
};
|
|
226
|
+
while (
|
|
227
|
+
Buffer.byteLength(JSON.stringify({ ...summary, ...counts })) > MAX_APPLY_BRIDGE_BYTES
|
|
228
|
+
) {
|
|
229
|
+
summary.operations = summary.operations?.slice(
|
|
230
|
+
0,
|
|
231
|
+
Math.floor(summary.operations.length / 2),
|
|
232
|
+
);
|
|
233
|
+
summary.files = summary.files.slice(0, Math.floor(summary.files.length / 2));
|
|
234
|
+
summary.completed = summary.completed.slice(
|
|
235
|
+
0,
|
|
236
|
+
Math.floor(summary.completed.length / 2),
|
|
237
|
+
);
|
|
238
|
+
summary.errors = summary.errors.slice(0, Math.floor(summary.errors.length / 2));
|
|
239
|
+
summary.snapshots = summary.snapshots.slice(
|
|
240
|
+
0,
|
|
241
|
+
Math.floor(summary.snapshots.length / 2),
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
Object.assign(summary, counts);
|
|
245
|
+
return summary;
|
|
189
246
|
}
|
|
190
247
|
if (tool === "editorOpen") {
|
|
191
248
|
if (!Value.Check(readParameters, arguments_))
|
|
@@ -260,12 +317,13 @@ export function createApplyExecution(
|
|
|
260
317
|
const searchFailure = outcome.details.failure;
|
|
261
318
|
const value = {
|
|
262
319
|
...outcome.script,
|
|
263
|
-
|
|
320
|
+
structured: outcome.structuredContent,
|
|
321
|
+
ok: !outcome.isError && searchFailure === undefined,
|
|
264
322
|
...(searchFailure && { error: searchFailure }),
|
|
265
323
|
};
|
|
266
324
|
results.record(id, kind, value, { content: outcome.content, details: {} });
|
|
267
325
|
recorded = true;
|
|
268
|
-
if (searchFailure !== undefined)
|
|
326
|
+
if (outcome.isError || searchFailure !== undefined)
|
|
269
327
|
throw failure("SEARCH_FAILED", "Search failed", searchFailure);
|
|
270
328
|
return value;
|
|
271
329
|
} catch (error) {
|
|
@@ -282,36 +340,39 @@ export function createApplyExecution(
|
|
|
282
340
|
host: { ...host, execute: (...args) => scope.run(() => host.execute(...args)) },
|
|
283
341
|
results,
|
|
284
342
|
async finish() {
|
|
285
|
-
await services.editor.enqueueFileOperation(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
343
|
+
await services.editor.enqueueFileOperation(
|
|
344
|
+
() =>
|
|
345
|
+
scope.finish((outcome) => {
|
|
346
|
+
const source = outcome.after.source;
|
|
347
|
+
const previous = results.mutationPresentation(source)?.data;
|
|
348
|
+
const formatting = outcome.postEditContributions
|
|
349
|
+
.map((item) => item.data)
|
|
350
|
+
.findLast(isFormattingContribution)?.formatting;
|
|
351
|
+
if (
|
|
352
|
+
!previous &&
|
|
353
|
+
outcome.before.content === outcome.after.content &&
|
|
354
|
+
!formatting?.formatter
|
|
355
|
+
)
|
|
356
|
+
return;
|
|
357
|
+
results.updateFile(source, outcome.before.content, outcome.after.content);
|
|
358
|
+
results.rememberMutation(
|
|
359
|
+
source,
|
|
360
|
+
new FileMutationResult({
|
|
361
|
+
ok: true,
|
|
362
|
+
path: source,
|
|
363
|
+
...previous,
|
|
364
|
+
afterContent: outcome.after.content,
|
|
365
|
+
afterDocument: outcome.after,
|
|
366
|
+
diffStatuses: outcome.postEditContributions
|
|
367
|
+
.map((item) => item.data)
|
|
368
|
+
.filter(isDiffStatusContribution)
|
|
369
|
+
.flatMap((item) => item.diffStatuses),
|
|
370
|
+
formatting: formatting ?? { status: "not-reported" },
|
|
371
|
+
}),
|
|
372
|
+
);
|
|
373
|
+
}),
|
|
374
|
+
undefined,
|
|
375
|
+
{ cwd: context.cwd, sources: scope.sources() },
|
|
315
376
|
);
|
|
316
377
|
},
|
|
317
378
|
};
|
|
@@ -2,7 +2,7 @@ const editorGuide = `
|
|
|
2
2
|
Read-only helpers use the standalone-tool arguments: read({...}), search({...}), and diff({before, after}). Their results are recorded automatically.
|
|
3
3
|
|
|
4
4
|
Transactional helpers:
|
|
5
|
-
open(path | {path, views?}); file.find(text); file.select(searchMatch); file.between(start, end, {inside?, lines?}); file.line(first, last?); file.start(); file.end(); file.before(selection); file.after(selection); file.slice(selection, start?, end?); file.union(...selections); file.within(candidates, scopes); file.linesOf(selection); file.replace(selection, text); file.remove(selection); file.insertBefore(selection, text); file.insertAfter(selection, text); file.flush(); file.delete(); replace(selection, text); remove(selection); insertBefore(selection, text); insertAfter(selection, text); copy(source, destination); move(source, destination); createFile(path, content); deleteFile(path); copyFile(path, target, {overwrite?}); moveFile(path, target, {overwrite?}); flush().
|
|
5
|
+
open(path | {path, views?}); file.find(text); file.select(searchMatch); file.between(start, end, {inside?, lines?}); file.line(first, last?); file.start(); file.end(); file.before(selection); file.after(selection); file.slice(selection, start?, end?); file.union(...selections); file.within(candidates, scopes); file.linesOf(selection); file.replace(selection, text); file.remove(selection); file.insertBefore(selection, text, {separation?: "line" | "blank-line"}); file.insertAfter(selection, text, {separation?: "line" | "blank-line"}); file.flush(); file.delete(); replace(selection, text); remove(selection); insertBefore(selection, text, {separation?: "line" | "blank-line"}); insertAfter(selection, text, {separation?: "line" | "blank-line"}); copy(source, destination); move(source, destination); createFile(path, content); deleteFile(path); copyFile(path, target, {overwrite?}); moveFile(path, target, {overwrite?}); flush().
|
|
6
6
|
|
|
7
7
|
Selections are immutable and snapshot-bound. Use slice to select occurrences by position, union to combine non-overlapping sets, within to keep candidates contained by scopes, and linesOf to expand matches to whole lines. between accepts strings or SelectionSets as either boundary; {lines:true} expands through both containing lines. Prefer it for blocks identified by content; use line(first,last) only for exact verified line bounds. Use start/end or before/after as zero-width destinations when copy or move should insert instead of replace. Normal completion commits staged operations once; a thrown script commits none. flush() commits every staged operation; file.flush() commits only independent operations for that file while cross-file transfers stay pending. Successful checkpoints can return an APPLY# receipt. Failed operations report structured errors and do not silently guess a recovery.
|
|
8
8
|
`;
|
|
@@ -119,6 +119,10 @@ export class ApplyResults {
|
|
|
119
119
|
this.#files.delete(source);
|
|
120
120
|
this.#mutationPresentations.delete(source);
|
|
121
121
|
}
|
|
122
|
+
/** Every recorded operation, including work hidden by final-state presentation. */
|
|
123
|
+
operations(): readonly OperationResult[] {
|
|
124
|
+
return [...this.#operations.values()];
|
|
125
|
+
}
|
|
122
126
|
/** Selects output without deleting the underlying operation receipts. */
|
|
123
127
|
select(): SelectedResults {
|
|
124
128
|
return {
|
|
@@ -170,7 +170,9 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
170
170
|
const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: target});
|
|
171
171
|
return selectionSet(document, resolved.selections, {kind: "exact", query: target, warning: resolved.warning});
|
|
172
172
|
};
|
|
173
|
-
const stage = (document, target, text, edge) => {
|
|
173
|
+
const stage = (document, target, text, edge, options = {}) => {
|
|
174
|
+
if (edge !== undefined && text.length === 0) throw new Error("Insert text must not be empty.");
|
|
175
|
+
if (options.separation !== undefined && options.separation !== "line" && options.separation !== "blank-line") throw new Error("Invalid separation mode.");
|
|
174
176
|
const selected = targetSet(document, target);
|
|
175
177
|
if (!Array.isArray(selected) || selected.document !== document.id) throw new Error("SelectionSet belongs to another file");
|
|
176
178
|
if (selected.generation !== document.generation) throw Object.assign(new Error("SelectionSet belongs to a stale snapshot"), {code:"STALE_SELECTION"});
|
|
@@ -179,10 +181,17 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
179
181
|
const point = edge === "before" ? range.from : edge === "after" ? range.to : undefined;
|
|
180
182
|
let insert = text;
|
|
181
183
|
if (point !== undefined && range.linewise === true) {
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
const separator = document.content.includes("\\r\\n") ? "\\r\\n" : "\\n";
|
|
185
|
+
const before = document.content.slice(0, point);
|
|
186
|
+
const after = document.content.slice(point);
|
|
187
|
+
const prefix = edge === "after" && before.length > 0 && !before.endsWith("\\n") ? separator : "";
|
|
188
|
+
const following = after.length > 0;
|
|
189
|
+
insert = prefix + insert;
|
|
190
|
+
if (options.separation === "blank-line") {
|
|
191
|
+
if (before.length > 0 && !before.endsWith(separator + separator) && !insert.slice(prefix.length).startsWith(separator)) insert = separator + insert;
|
|
192
|
+
if (following && !insert.endsWith(separator + separator) && !after.startsWith(separator)) insert += insert.endsWith(separator) ? separator : separator + separator;
|
|
193
|
+
}
|
|
194
|
+
if (following && !insert.endsWith("\\n")) insert += separator;
|
|
186
195
|
}
|
|
187
196
|
operations.push({kind: "replace", selection: point === undefined ? range : selection(document, point, point), text: insert});
|
|
188
197
|
}
|
|
@@ -196,10 +205,10 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
196
205
|
if (empty !== undefined) { operations.push({kind:"warning", document:empty.document, query:empty.provenance?.query, warning:empty.provenance?.warning}); return; }
|
|
197
206
|
operations.push({kind, sources:[...source], destinations:[...destination], text:source.map((item) => item.text).join("")});
|
|
198
207
|
};
|
|
199
|
-
const stageSet = (target, text, edge) => {
|
|
208
|
+
const stageSet = (target, text, edge, options) => {
|
|
200
209
|
const document = snapshots.get(target?.document);
|
|
201
210
|
if (document === undefined) throw selectionError("STALE_SELECTION", "SelectionSet belongs to a stale or unopened snapshot");
|
|
202
|
-
stage(document, target, text, edge);
|
|
211
|
+
stage(document, target, text, edge, options);
|
|
203
212
|
};
|
|
204
213
|
const refreshSnapshots = (value) => {
|
|
205
214
|
for (const refreshed of value?.snapshots ?? []) {
|
|
@@ -326,8 +335,8 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
326
335
|
after: (set) => { assertCurrent(document); const selected = assertSet(document, set); return selectionSet(document, selected.map((item) => ({from: item.to, to: item.to, linewise: item.linewise === true})), {kind: "after", source: selected.provenance}); },
|
|
327
336
|
replace: (target, text) => { assertCurrent(document); stage(document, target, String(text)); },
|
|
328
337
|
remove: (target) => { assertCurrent(document); stage(document, target, ""); },
|
|
329
|
-
insertBefore: (target, text) => { assertCurrent(document); stage(document, target, String(text), "before"); },
|
|
330
|
-
insertAfter: (target, text) => { assertCurrent(document); stage(document, target, String(text), "after"); },
|
|
338
|
+
insertBefore: (target, text, options) => { assertCurrent(document); stage(document, target, String(text), "before", options); },
|
|
339
|
+
insertAfter: (target, text, options) => { assertCurrent(document); stage(document, target, String(text), "after", options); },
|
|
331
340
|
flush: () => flushDocument(document),
|
|
332
341
|
delete: () => { assertCurrent(document); operations.push({kind: "delete", path: document.source}); },
|
|
333
342
|
};
|
|
@@ -342,8 +351,8 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
342
351
|
moveFile: (path, target, options = {}) => operations.push({kind: "move", path, target, overwrite: options.overwrite === true}),
|
|
343
352
|
replace: (target, text) => stageSet(target, String(text)),
|
|
344
353
|
remove: (target) => stageSet(target, ""),
|
|
345
|
-
insertBefore: (target, text) => stageSet(target, String(text), "before"),
|
|
346
|
-
insertAfter: (target, text) => stageSet(target, String(text), "after"),
|
|
354
|
+
insertBefore: (target, text, options) => stageSet(target, String(text), "before", options),
|
|
355
|
+
insertAfter: (target, text, options) => stageSet(target, String(text), "after", options),
|
|
347
356
|
copy: (source, destination) => stageTransfer("text-copy", source, destination),
|
|
348
357
|
move: (source, destination) => stageTransfer("text-move", source, destination),
|
|
349
358
|
flush: () => {
|