pi-agent-ide 0.6.0 → 0.6.1
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 +29 -0
- package/README.md +79 -53
- package/assets/social-preview.png +0 -0
- package/dist/chunk-4KUFOHWP.js +2 -0
- package/dist/chunk-4LDOV7QS.js +28 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/{chunk-HSM6R7IB.js → chunk-I6Y3W4X6.js} +13 -13
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
- package/dist/chunk-T7I2VX3J.js +1 -0
- package/dist/chunk-VCTK4JSN.js +3 -0
- package/dist/chunk-W7CASEO3.js +1 -0
- package/dist/chunk-YEQOQMU7.js +5 -0
- package/dist/chunk-YT42LKFV.js +16 -0
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -0
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -2
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +2 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -1
- package/dist/entry-28.js +1 -12
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +12 -1
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -4
- package/dist/entry-34.js +1 -9
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +4 -1
- package/dist/entry-37.js +9 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -18
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +17 -1
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +1 -7
- package/dist/entry-48.js +1 -11
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +6 -1
- package/dist/entry-51.js +11 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -0
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -0
- package/dist/entry-60.js +0 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +0 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -0
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -0
- package/dist/entry-69.js +0 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -259
- package/dist/entry-73.js +1 -30
- package/dist/entry-74.js +1 -2
- package/dist/entry-75.js +315 -1
- package/dist/entry-76.js +30 -1
- package/dist/entry-77.js +2 -3
- package/dist/entry-78.js +1 -3
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +3 -1
- package/dist/entry-81.js +3 -1
- package/dist/entry-82.js +1 -0
- package/dist/entry-83.js +1 -0
- package/dist/entry-84.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/pi-agent-ide.js +3 -3
- package/docs/agent-guides/apply.md +333 -0
- package/docs/agent-guides/debugger.md +5 -0
- package/docs/agent-guides/diagnostics.md +5 -0
- package/docs/agent-guides/editing.md +44 -0
- package/docs/agent-guides/git-changes.md +5 -0
- package/docs/agent-guides/json-reading.md +41 -0
- package/docs/agent-guides/read-resources.md +44 -0
- package/docs/agent-guides/search-code.md +29 -0
- package/docs/agent-guides/terminal.md +7 -0
- package/docs/agent-guides/vision.md +5 -0
- package/docs/configuration.md +6 -14
- package/docs/research/apply-read-latency.md +219 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
- package/node_modules/pi-agent-documentation/package.json +15 -0
- package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
- package/node_modules/pi-agent-documentation/src/index.ts +69 -0
- package/node_modules/pi-agent-filesystem/index.ts +0 -4
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
- package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
- package/node_modules/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +11 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-changes/index.ts +8 -0
- package/node_modules/pi-agent-ide-changes/package.json +9 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/node_modules/pi-agent-ide-lint/index.ts +1 -1
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +17 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-read/package.json +12 -11
- package/node_modules/pi-agent-read/runtime/entry-42.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
- package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +19 -12
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +8 -7
- package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-50.js +2 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-54.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/node_modules/pi-agent-text-editor/index.ts +15 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-72.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-76.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- 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-image/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-84.js +2 -0
- package/package.json +108 -44
- package/src/api/documentation.ts +2 -0
- package/src/composite/builtin-extensions.ts +7 -0
- package/src/composite/extensions-config.ts +6 -0
- package/src/composite/module-labels.ts +5 -0
- package/src/composite/module-settings-store.ts +3 -0
- package/src/composite/module-settings.ts +39 -5
- package/src/composite/preferences.ts +37 -0
- package/src/composite/presentation.ts +14 -0
- package/src/composite/presets.ts +57 -0
- package/src/documentation/extension.ts +295 -0
- package/src/documentation/registry.ts +98 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +2 -0
- 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-pdf/runtime/entry-83.js +2 -0
- 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-84.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -11
- package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-43.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
- package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +19 -12
- package/src/extensions/pi-agent-search/package.json +8 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
- package/src/extensions/pi-agent-text-editor/index.ts +15 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-54.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/src/pi-agent-ide.ts +7 -10
- package/src/plugins/pi-agent-ide-ast/package.json +11 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
- package/src/plugins/pi-agent-ide-changes/package.json +9 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/src/plugins/pi-agent-ide-debugger/index.ts +12 -4
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +17 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +1 -4
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +7 -4
- package/src/plugins/pi-agent-ide-vision/index.ts +8 -6
- package/dist/chunk-22CLOM2D.js +0 -1
- package/dist/chunk-3XJ3KDPZ.js +0 -16
- package/dist/chunk-526E364R.js +0 -3
- package/dist/chunk-DDKHZZDO.js +0 -5
- package/dist/chunk-EJ5OACQM.js +0 -1
- package/dist/chunk-PCZH7GOX.js +0 -26
- package/dist/chunk-SQ7ZTGOP.js +0 -2
- package/dist/entry-18.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-23.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-30.js +0 -2
- package/node_modules/pi-agent-ide-languages/runtime/entry-32.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-35.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-36.js +0 -1
- package/node_modules/pi-agent-pdf/runtime/entry-37.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-48.js +0 -2
- package/node_modules/pi-agent-text/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-76.js +0 -1
- package/node_modules/pi-agent-web-html/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +0 -2
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-30.js +0 -2
- package/src/plugins/pi-agent-ide-languages/runtime/entry-32.js +0 -2
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search-text}/runtime/entry-51.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-52.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-80.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-81.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-81.js +0 -0
- /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-constant → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-51.js +0 -0
- /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-52.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
|
@@ -152,25 +152,31 @@ export function createApplyExecution(
|
|
|
152
152
|
}
|
|
153
153
|
const requestedSnapshots =
|
|
154
154
|
(arguments_ as { snapshots?: readonly EditorSnapshot[] }).snapshots ?? [];
|
|
155
|
+
const changedSources = new Set([
|
|
156
|
+
...value.files.map((file) => file.source),
|
|
157
|
+
...value.completed,
|
|
158
|
+
]);
|
|
155
159
|
const refreshed = await Promise.all(
|
|
156
|
-
requestedSnapshots
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
script
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
requestedSnapshots
|
|
161
|
+
.filter((snapshot) => changedSources.has(snapshot.source))
|
|
162
|
+
.map(async (snapshot) => {
|
|
163
|
+
const outcome = await services.read.read(
|
|
164
|
+
{ path: snapshot.source },
|
|
165
|
+
{ cwd: context.cwd, signal },
|
|
166
|
+
"script",
|
|
167
|
+
);
|
|
168
|
+
const script = outcome.script;
|
|
169
|
+
return !outcome.isError &&
|
|
170
|
+
script?.kind === "text" &&
|
|
171
|
+
typeof script.content === "string"
|
|
172
|
+
? {
|
|
173
|
+
id: snapshot.id,
|
|
174
|
+
source: outcome.details.source ?? script.source,
|
|
175
|
+
content: script.content,
|
|
176
|
+
lines: script.lines,
|
|
177
|
+
}
|
|
178
|
+
: { id: snapshot.id, unavailable: true };
|
|
179
|
+
}),
|
|
174
180
|
);
|
|
175
181
|
const response = { ...value, snapshots: refreshed };
|
|
176
182
|
results.record(id, "mutation", response);
|
|
@@ -18,6 +18,7 @@ export interface ApplyOutput {
|
|
|
18
18
|
readonly content: Content;
|
|
19
19
|
readonly level: "full" | "compact" | "summary";
|
|
20
20
|
readonly temporarySource?: string;
|
|
21
|
+
readonly mutations?: ReturnType<typeof finalApplyMutations>;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/** Presents net file effects once, preserving native images and one combined text budget. */
|
|
@@ -75,7 +76,7 @@ export async function renderApplyOutput(
|
|
|
75
76
|
if (error !== undefined) content.push(text(formatError(error)));
|
|
76
77
|
if (content.length === 0) content.push(text("No operations or explicit results."));
|
|
77
78
|
const full = textContent(content);
|
|
78
|
-
if (!truncateHead(full).truncated) return { content, level: "full" };
|
|
79
|
+
if (!truncateHead(full).truncated) return { content, level: "full", mutations: finalMutations };
|
|
79
80
|
const temporarySource = await read.saveTemporary(full);
|
|
80
81
|
const footer = `\n\nFull Apply output: ${temporarySource}. Read this reference with offset/limit for more.`;
|
|
81
82
|
if (read.reduceOutput !== undefined && !context.signal?.aborted) {
|
|
@@ -102,7 +103,7 @@ export async function renderApplyOutput(
|
|
|
102
103
|
compact.push(...content.slice(suffixStart));
|
|
103
104
|
compact.push(text(footer.trimStart()));
|
|
104
105
|
if (!truncateHead(textContent(compact)).truncated)
|
|
105
|
-
return { content: compact, level: "compact", temporarySource };
|
|
106
|
+
return { content: compact, level: "compact", temporarySource, mutations: finalMutations };
|
|
106
107
|
}
|
|
107
108
|
const summary = [
|
|
108
109
|
`Apply output reduced: ${selected.automatic.length} automatic results, ${selected.explicit.length} explicit results, ${selected.files.length} final files.`,
|
|
@@ -120,6 +121,7 @@ export async function renderApplyOutput(
|
|
|
120
121
|
content: [text(bounded + footer), ...content.filter((block) => block.type === "image")],
|
|
121
122
|
level: "summary",
|
|
122
123
|
temporarySource,
|
|
124
|
+
mutations: finalMutations,
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
127
|
|
|
@@ -1,52 +1,13 @@
|
|
|
1
1
|
const editorGuide = `
|
|
2
|
-
Read-only helpers
|
|
3
|
-
read({path, offset?, limit?, views?})
|
|
4
|
-
search({query, path?, include?, exclude?, caseSensitive?, wholeWord?, limit?})
|
|
5
|
-
diff({before, after})
|
|
6
|
-
result(value)
|
|
2
|
+
Read-only helpers use the standalone-tool arguments: read({...}), search({...}), and diff({before, after}). Their results are recorded automatically.
|
|
7
3
|
|
|
8
|
-
Transactional
|
|
9
|
-
|
|
10
|
-
file.source; file.content; file.lines
|
|
11
|
-
file.find(text) // immutable SelectionSet with every exact match, including zero
|
|
12
|
-
file.select(searchMatch) // one-range SelectionSet
|
|
13
|
-
file.between(start, end, {inside?: boolean}) // every sequential non-overlapping pair
|
|
14
|
-
file.line(first, last?) // one-range SelectionSet
|
|
15
|
-
file.replace(textOrSet, replacement)
|
|
16
|
-
file.remove(textOrSet)
|
|
17
|
-
file.insertBefore(textOrSet, text)
|
|
18
|
-
file.insertAfter(textOrSet, text)
|
|
19
|
-
copy(sourceSet, destinationSet)
|
|
20
|
-
move(sourceSet, destinationSet)
|
|
21
|
-
createFile(path, content)
|
|
22
|
-
deleteFile(path)
|
|
23
|
-
copyFile(path, target, {overwrite?: boolean})
|
|
24
|
-
moveFile(path, target, {overwrite?: boolean})
|
|
25
|
-
flush()
|
|
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().
|
|
26
6
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
All selections in one transaction refer to the current opened snapshots, so earlier staged edits never shift later selections. After each checkpoint, opened file handles refresh to actual post-outcome contents and lines; SelectionSets created before that checkpoint become stale. copy() and move() concatenate source ranges in document order and replicate that payload at every destination range. move() stages destination effects before source removals. Whole-file copyFile() and moveFile() remain separate.
|
|
30
|
-
|
|
31
|
-
Pending operations commit once when the JavaScript completes normally. If the script throws, pending operations do not commit. Use flush() as an optional mid-script checkpoint. Operations run in staging order: the first valid overlapping operation wins, and later conflicts fail without undoing independent work. Check every per-operation outcome and retry only failed or blocked work. When a checkpoint changes a file, it creates one session-scoped APPLY# receipt. Explicit flush() returns it; automatic finalization reports it in the tool result. Pass the receipt to undo({ transaction: "APPLY#..." }) before any successfully changed path changes to restore all successful effects. After flush(), reuse the same opened handles and create fresh SelectionSets. Every checkpoint clears all staged operations, including failed operations and warnings. With no pending mutations, completion creates no transaction or receipt.
|
|
32
|
-
|
|
33
|
-
Before each operation the host verifies snapshots, resource types, ranges, overlaps, source existence, and destination conflicts. A failed operation changes nothing when rollback completes. If rollback is incomplete, its effect is unknown and later dependent operations are blocked. Do not describe an unknown effect as success.
|
|
34
|
-
|
|
35
|
-
Use find() for all exact occurrences, between() for sequential delimited ranges, select() for search results, and line() only when line identity is part of the task. Use direct strings when a configured anchor or unique exact-text fallback should select one target within the opened snapshot. Generate replacement text with ordinary JavaScript.
|
|
36
|
-
|
|
37
|
-
Example:
|
|
38
|
-
const config = open("src/config.ts");
|
|
39
|
-
const test = open("tests/config.test.ts");
|
|
40
|
-
config.replace("legacyMode", "stableMode");
|
|
41
|
-
test.replace(test.find("legacyMode"), "stableMode");
|
|
42
|
-
// Normal completion commits both staged edits.
|
|
43
|
-
|
|
44
|
-
Read accepts file paths, URLs, temp/search/debug/shell/diagnostics/symbol/graph resources, and supported views. Search accepts literal, regex:, files:, ast:, and symbols: queries. File changes and read-only calls are shown automatically. Use result(value) only to expose additional calculated data; do not call it merely to display committed changes.
|
|
45
|
-
|
|
46
|
-
Do not retry by guessing argument names. Inspect structured error codes such as EMPTY_SELECTION, STALE_SNAPSHOT, INVALID_TRANSACTION, and TRANSACTION_FAILED.
|
|
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.
|
|
47
8
|
`;
|
|
48
9
|
|
|
49
|
-
/**
|
|
10
|
+
/** Compact callable contract for the guarded Apply editor. */
|
|
50
11
|
export function applyHelperGuide(): string {
|
|
51
12
|
return editorGuide;
|
|
52
13
|
}
|
|
@@ -12,6 +12,7 @@ import { preserveEnclosingBackground } from "pi-agent-tool-ui";
|
|
|
12
12
|
import type { ApplyResults } from "./results.js";
|
|
13
13
|
import type { ApplyOutput } from "./output.js";
|
|
14
14
|
|
|
15
|
+
type ToolPresentation = "full" | "compact" | "disabled";
|
|
15
16
|
/** Deliberate user presentation, separate from model-facing operation receipts. */
|
|
16
17
|
export interface ApplyDisplay {
|
|
17
18
|
readonly blocks: readonly { readonly text: string; readonly read?: ReadToolResult }[];
|
|
@@ -62,7 +63,7 @@ export function createApplyDisplay(
|
|
|
62
63
|
],
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
|
-
const mutations = finalApplyMutations(results);
|
|
66
|
+
const mutations = output.mutations ?? finalApplyMutations(results);
|
|
66
67
|
return {
|
|
67
68
|
...(mutations.length > 0 ? { mutations: { results: mutations } } : {}),
|
|
68
69
|
comparisons,
|
|
@@ -154,7 +155,7 @@ export function createApplyDisplay(
|
|
|
154
155
|
type RenderState = {
|
|
155
156
|
applyResultReady?: boolean;
|
|
156
157
|
displaySource?: string;
|
|
157
|
-
|
|
158
|
+
|
|
158
159
|
projectSource?: (source: string) => string;
|
|
159
160
|
};
|
|
160
161
|
|
|
@@ -210,8 +211,11 @@ export function applyFrameRows(
|
|
|
210
211
|
/** Compose compact written calls with a pure configured tool header renderer. */
|
|
211
212
|
export function createApplyCallRenderer(
|
|
212
213
|
renderWritten?: (call: ApplyCallPreview, theme: Theme) => string,
|
|
214
|
+
presentation: ToolPresentation = "compact",
|
|
213
215
|
): NonNullable<ToolDefinition["renderCall"]> {
|
|
214
216
|
return (args, theme, context) => {
|
|
217
|
+
if (!context.expanded && presentation === "disabled")
|
|
218
|
+
return new Text(theme.fg("toolTitle", "apply"), 0, 0);
|
|
215
219
|
const state = context.state as RenderState;
|
|
216
220
|
const projectSource = (state.projectSource ??= createApplySourceProjection(
|
|
217
221
|
renderWritten ? (call) => renderWritten(call, theme) : undefined,
|
|
@@ -228,14 +232,16 @@ export function createApplyCallRenderer(
|
|
|
228
232
|
invalidate() {},
|
|
229
233
|
render(width) {
|
|
230
234
|
return applyFrameRows(
|
|
231
|
-
|
|
235
|
+
context.expanded || presentation === "full"
|
|
232
236
|
? (state.displaySource ?? source)
|
|
233
|
-
:
|
|
237
|
+
: presentation === "disabled"
|
|
238
|
+
? ""
|
|
239
|
+
: compactApplyPreview(projectSource(state.displaySource ?? source)),
|
|
234
240
|
theme,
|
|
235
241
|
width,
|
|
236
242
|
"call",
|
|
237
243
|
!state.applyResultReady,
|
|
238
|
-
|
|
244
|
+
context.expanded || presentation === "full" || !renderWritten ? "javascript" : undefined,
|
|
239
245
|
);
|
|
240
246
|
},
|
|
241
247
|
};
|
|
@@ -328,6 +334,8 @@ export function createApplyResultRenderer(
|
|
|
328
334
|
const rows = mutationPanel.render(Math.max(1, width - 4));
|
|
329
335
|
if (body.length > 0 && rows.length > 0) body.push("");
|
|
330
336
|
body.push(...rows);
|
|
337
|
+
if (rows.length === 0)
|
|
338
|
+
body.push(...(mutations?.results ?? []).map((file) => file.path ?? "Changed file"));
|
|
331
339
|
} else if (mutations !== undefined)
|
|
332
340
|
body.push(...(mutations.results ?? []).map((file) => file.path ?? "Changed file"));
|
|
333
341
|
if (
|
|
@@ -111,6 +111,10 @@ function applyGuestErrorCode(message: string): string {
|
|
|
111
111
|
if (message === "No matches") return "NOT_FOUND";
|
|
112
112
|
if (message === "Search match is stale") return "STALE_SELECTION";
|
|
113
113
|
if (message === "Editor handle belongs to a committed transaction") return "STALE_EDITOR";
|
|
114
|
+
if (message === "union() selections overlap" || message === "Expected a SelectionSet")
|
|
115
|
+
return "INVALID_SELECTION";
|
|
116
|
+
if (message === "SelectionSet belongs to another file") return "CROSS_FILE_SELECTION";
|
|
117
|
+
if (message === "SelectionSet belongs to a stale snapshot") return "STALE_SELECTION";
|
|
114
118
|
if (/^(?:Invalid line range|Line range is outside document)$/u.test(message))
|
|
115
119
|
return "INVALID_SELECTION";
|
|
116
120
|
return "RUN_USER_SOURCE_ERROR";
|
|
@@ -119,12 +123,12 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
119
123
|
const readOperations = enabledOperations.filter(
|
|
120
124
|
(name) => name === "read" || name === "search" || name === "diff",
|
|
121
125
|
);
|
|
122
|
-
return `const { ${readOperations.join(", ")}, open, createFile, deleteFile, copyFile, moveFile, copy, move, flush,
|
|
123
|
-
|
|
126
|
+
return `const { ${readOperations.join(", ")}, open, createFile, deleteFile, copyFile, moveFile, replace, remove, insertBefore, insertAfter, copy, move, flush, __finishApplyScript } = (() => {
|
|
127
|
+
|
|
124
128
|
const invoke = (name, args) => {
|
|
125
129
|
const response = __apply[name](args);
|
|
126
130
|
if (!response.ok) throw Object.assign(new Error(response.error.message), response.error);
|
|
127
|
-
|
|
131
|
+
|
|
128
132
|
return response.value;
|
|
129
133
|
};
|
|
130
134
|
let snapshots = new Map();
|
|
@@ -144,6 +148,23 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
144
148
|
for (let from = content.indexOf(needle); from >= 0; from = content.indexOf(needle, from + needle.length)) found.push(from);
|
|
145
149
|
return found;
|
|
146
150
|
};
|
|
151
|
+
const selectionError = (code, message) => Object.assign(new Error(message), {code});
|
|
152
|
+
const assertSet = (document, set) => {
|
|
153
|
+
if (!Array.isArray(set)) throw selectionError("INVALID_SELECTION", "Expected a SelectionSet");
|
|
154
|
+
if (set.document !== document.id) throw selectionError("CROSS_FILE_SELECTION", "SelectionSet belongs to another file");
|
|
155
|
+
if (set.generation !== document.generation) throw selectionError("STALE_SELECTION", "SelectionSet belongs to a stale snapshot");
|
|
156
|
+
return set;
|
|
157
|
+
};
|
|
158
|
+
const boundarySet = (document, value) => {
|
|
159
|
+
if (typeof value !== "string") return assertSet(document, value);
|
|
160
|
+
const ranges = occurrences(document.content, value).map((from) => ({from, to: from + value.length}));
|
|
161
|
+
return selectionSet(document, ranges, {kind: "exact", query: value});
|
|
162
|
+
};
|
|
163
|
+
const lineRange = (document, item) => {
|
|
164
|
+
const from = document.content.lastIndexOf("\\n", Math.max(0, item.from - 1)) + 1;
|
|
165
|
+
const newline = document.content.indexOf("\\n", Math.max(item.from, item.to - 1));
|
|
166
|
+
return {from, to: newline < 0 ? document.content.length : newline + 1, linewise: true};
|
|
167
|
+
};
|
|
147
168
|
const targetSet = (document, target) => {
|
|
148
169
|
if (typeof target !== "string") return target;
|
|
149
170
|
const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: target});
|
|
@@ -175,6 +196,47 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
175
196
|
if (empty !== undefined) { operations.push({kind:"warning", document:empty.document, query:empty.provenance?.query, warning:empty.provenance?.warning}); return; }
|
|
176
197
|
operations.push({kind, sources:[...source], destinations:[...destination], text:source.map((item) => item.text).join("")});
|
|
177
198
|
};
|
|
199
|
+
const stageSet = (target, text, edge) => {
|
|
200
|
+
const document = snapshots.get(target?.document);
|
|
201
|
+
if (document === undefined) throw selectionError("STALE_SELECTION", "SelectionSet belongs to a stale or unopened snapshot");
|
|
202
|
+
stage(document, target, text, edge);
|
|
203
|
+
};
|
|
204
|
+
const refreshSnapshots = (value) => {
|
|
205
|
+
for (const refreshed of value?.snapshots ?? []) {
|
|
206
|
+
const document = snapshots.get(refreshed.id);
|
|
207
|
+
if (document !== undefined && refreshed.unavailable === true) snapshots.delete(refreshed.id);
|
|
208
|
+
else if (document !== undefined) {
|
|
209
|
+
document.source = refreshed.source;
|
|
210
|
+
document.content = refreshed.content;
|
|
211
|
+
document.lines = refreshed.lines;
|
|
212
|
+
document.generation += 1;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const commit = (selected) => {
|
|
217
|
+
if (selected.length === 0) return undefined;
|
|
218
|
+
const value = invoke("editorApply", {snapshots: [...snapshots.values()].map(({id, source, content}) => ({id, source, content})), operations: selected});
|
|
219
|
+
refreshSnapshots(value);
|
|
220
|
+
return value;
|
|
221
|
+
};
|
|
222
|
+
const flushDocument = (document) => {
|
|
223
|
+
assertCurrent(document);
|
|
224
|
+
const participatesInTransfer = operations.some((operation) =>
|
|
225
|
+
(operation.kind === "text-copy" || operation.kind === "text-move") &&
|
|
226
|
+
[...operation.sources, ...operation.destinations].some((item) => item.document === document.id));
|
|
227
|
+
if (participatesInTransfer) return undefined;
|
|
228
|
+
const selected = [];
|
|
229
|
+
const remaining = [];
|
|
230
|
+
for (const operation of operations) {
|
|
231
|
+
const belongs =
|
|
232
|
+
(operation.kind === "replace" && operation.selection.document === document.id) ||
|
|
233
|
+
(operation.kind === "warning" && operation.document === document.id) ||
|
|
234
|
+
(operation.kind === "delete" && operation.path === document.source);
|
|
235
|
+
(belongs ? selected : remaining).push(operation);
|
|
236
|
+
}
|
|
237
|
+
operations = remaining;
|
|
238
|
+
return commit(selected);
|
|
239
|
+
};
|
|
178
240
|
const makeDocument = (snapshot) => {
|
|
179
241
|
const document = {id: snapshot.id, source: snapshot.source, content: snapshot.content, lines: snapshot.lines, generation: 0};
|
|
180
242
|
snapshots.set(document.id, document);
|
|
@@ -185,19 +247,56 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
185
247
|
find: (text) => { assertCurrent(document); const ranges = occurrences(document.content, text).map((from) => ({from, to: from + text.length})); if (ranges.length > 0) return selectionSet(document, ranges, {kind: "exact", query: text}); const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: text}); return selectionSet(document, [], {kind: "exact", query: text, warning: resolved.warning}); },
|
|
186
248
|
between: (start, end, options = {}) => {
|
|
187
249
|
assertCurrent(document);
|
|
250
|
+
if (options.inside === true && options.lines === true) throw selectionError("INVALID_SELECTION", "between() cannot combine inside and lines");
|
|
251
|
+
const starts = boundarySet(document, start);
|
|
252
|
+
const ends = boundarySet(document, end);
|
|
188
253
|
const ranges = [];
|
|
189
254
|
let cursor = 0;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
255
|
+
for (const left of starts) {
|
|
256
|
+
if (left.from < cursor) continue;
|
|
257
|
+
const right = ends.find((candidate) => candidate.from >= left.to);
|
|
258
|
+
if (right === undefined) break;
|
|
259
|
+
const range = options.lines === true
|
|
260
|
+
? {from: lineRange(document, left).from, to: lineRange(document, right).to, linewise: true}
|
|
261
|
+
: {
|
|
262
|
+
from: options.inside === true ? left.to : left.from,
|
|
263
|
+
to: options.inside === true ? right.from : right.to,
|
|
264
|
+
linewise: options.inside !== true && left.linewise === true && right.linewise === true,
|
|
265
|
+
};
|
|
266
|
+
ranges.push(range);
|
|
267
|
+
cursor = right.to;
|
|
197
268
|
}
|
|
198
|
-
return selectionSet(document, ranges, {kind: "between"
|
|
269
|
+
return selectionSet(document, ranges, {kind: "between"});
|
|
199
270
|
},
|
|
200
|
-
|
|
271
|
+
slice: (set, start, end) => {
|
|
272
|
+
assertCurrent(document);
|
|
273
|
+
const selected = assertSet(document, set);
|
|
274
|
+
return selectionSet(document, selected.slice(start, end), {kind: "slice", source: selected.provenance, start, end, warning: selected.provenance?.warning});
|
|
275
|
+
},
|
|
276
|
+
union: (...sets) => {
|
|
277
|
+
assertCurrent(document);
|
|
278
|
+
const ranges = sets.flatMap((set) => [...assertSet(document, set)]).sort((left, right) => left.from - right.from || left.to - right.to);
|
|
279
|
+
const unique = ranges.filter((range, index) => index === 0 || range.from !== ranges[index - 1].from || range.to !== ranges[index - 1].to);
|
|
280
|
+
for (let index = 1; index < unique.length; index += 1) {
|
|
281
|
+
if (unique[index].from < unique[index - 1].to) throw selectionError("INVALID_SELECTION", "union() selections overlap");
|
|
282
|
+
}
|
|
283
|
+
return selectionSet(document, unique, {kind: "union", sources: sets.map((set) => set.provenance), warning: sets.find((set) => set.provenance?.warning)?.provenance.warning});
|
|
284
|
+
},
|
|
285
|
+
within: (candidates, scopes) => {
|
|
286
|
+
assertCurrent(document);
|
|
287
|
+
const selected = assertSet(document, candidates);
|
|
288
|
+
const containers = assertSet(document, scopes);
|
|
289
|
+
const ranges = selected.filter((candidate) => containers.some((scope) => scope.from <= candidate.from && candidate.to <= scope.to));
|
|
290
|
+
return selectionSet(document, ranges, {kind: "within", source: selected.provenance, scopes: containers.provenance, warning: selected.provenance?.warning ?? containers.provenance?.warning});
|
|
291
|
+
},
|
|
292
|
+
linesOf: (set) => {
|
|
293
|
+
assertCurrent(document);
|
|
294
|
+
const selected = assertSet(document, set);
|
|
295
|
+
const ranges = selected.map((item) => lineRange(document, item)).sort((left, right) => left.from - right.from);
|
|
296
|
+
const unique = ranges.filter((range, index) => index === 0 || range.from !== ranges[index - 1].from || range.to !== ranges[index - 1].to);
|
|
297
|
+
return selectionSet(document, unique, {kind: "linesOf", source: selected.provenance, warning: selected.provenance?.warning});
|
|
298
|
+
},
|
|
299
|
+
select: (match) => {
|
|
201
300
|
assertCurrent(document);
|
|
202
301
|
const candidate = match?.selection ?? match;
|
|
203
302
|
if (!candidate || typeof candidate !== "object") throw new Error("select() requires a search match");
|
|
@@ -219,12 +318,18 @@ select: (match) => {
|
|
|
219
318
|
const starts = [0];
|
|
220
319
|
for (let index = 0; index < document.content.length; index += 1) if (document.content[index] === "\\n") starts.push(index + 1);
|
|
221
320
|
if (last > starts.length) throw new RangeError("Line range is outside document");
|
|
222
|
-
return selectionSet(document, [{from: starts[first - 1], to: starts[last] === undefined ? document.content.length : starts[last]}]);
|
|
321
|
+
return selectionSet(document, [{from: starts[first - 1], to: starts[last] === undefined ? document.content.length : starts[last], linewise: true}], {kind: "line", first, last});
|
|
223
322
|
},
|
|
323
|
+
start: () => { assertCurrent(document); return selectionSet(document, [{from: 0, to: 0, linewise: true}], {kind: "start"}); },
|
|
324
|
+
end: () => { assertCurrent(document); const point = document.content.length; return selectionSet(document, [{from: point, to: point, linewise: true}], {kind: "end"}); },
|
|
325
|
+
before: (set) => { assertCurrent(document); const selected = assertSet(document, set); return selectionSet(document, selected.map((item) => ({from: item.from, to: item.from, linewise: item.linewise === true})), {kind: "before", source: selected.provenance}); },
|
|
326
|
+
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}); },
|
|
224
327
|
replace: (target, text) => { assertCurrent(document); stage(document, target, String(text)); },
|
|
225
328
|
remove: (target) => { assertCurrent(document); stage(document, target, ""); },
|
|
226
329
|
insertBefore: (target, text) => { assertCurrent(document); stage(document, target, String(text), "before"); },
|
|
227
330
|
insertAfter: (target, text) => { assertCurrent(document); stage(document, target, String(text), "after"); },
|
|
331
|
+
flush: () => flushDocument(document),
|
|
332
|
+
delete: () => { assertCurrent(document); operations.push({kind: "delete", path: document.source}); },
|
|
228
333
|
};
|
|
229
334
|
return Object.freeze(api);
|
|
230
335
|
};
|
|
@@ -235,26 +340,19 @@ select: (match) => {
|
|
|
235
340
|
deleteFile: (path) => operations.push({kind: "delete", path}),
|
|
236
341
|
copyFile: (path, target, options = {}) => operations.push({kind: "copy", path, target, overwrite: options.overwrite === true}),
|
|
237
342
|
moveFile: (path, target, options = {}) => operations.push({kind: "move", path, target, overwrite: options.overwrite === true}),
|
|
343
|
+
replace: (target, text) => stageSet(target, String(text)),
|
|
344
|
+
remove: (target) => stageSet(target, ""),
|
|
345
|
+
insertBefore: (target, text) => stageSet(target, String(text), "before"),
|
|
346
|
+
insertAfter: (target, text) => stageSet(target, String(text), "after"),
|
|
238
347
|
copy: (source, destination) => stageTransfer("text-copy", source, destination),
|
|
239
348
|
move: (source, destination) => stageTransfer("text-move", source, destination),
|
|
240
349
|
flush: () => {
|
|
241
350
|
if (operations.length === 0) return undefined;
|
|
242
351
|
const pending = operations;
|
|
243
352
|
operations = [];
|
|
244
|
-
|
|
245
|
-
for (const refreshed of value?.snapshots ?? []) {
|
|
246
|
-
const document = snapshots.get(refreshed.id);
|
|
247
|
-
if (document !== undefined && refreshed.unavailable === true) snapshots.delete(refreshed.id);
|
|
248
|
-
else if (document !== undefined) {
|
|
249
|
-
document.source = refreshed.source;
|
|
250
|
-
document.content = refreshed.content;
|
|
251
|
-
document.lines = refreshed.lines;
|
|
252
|
-
document.generation += 1;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return value;
|
|
353
|
+
return commit(pending);
|
|
256
354
|
},
|
|
257
|
-
|
|
355
|
+
|
|
258
356
|
__finishApplyScript: () => { if (operations.length > 0) return api.flush(); },
|
|
259
357
|
};
|
|
260
358
|
return api;
|
|
@@ -51,8 +51,6 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
|
|
|
51
51
|
label: "Apply",
|
|
52
52
|
renderShell: "self",
|
|
53
53
|
renderCall: (args, theme, context) => {
|
|
54
|
-
(context.state as { codeView?: boolean }).codeView =
|
|
55
|
-
pi.getFlag("pi-agent-ide-apply-code") === true;
|
|
56
54
|
const render = editor.getToolRenderer("apply")?.renderCall ?? renderApplyCall;
|
|
57
55
|
return render(args, theme, context);
|
|
58
56
|
},
|
|
@@ -65,13 +63,11 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
|
|
|
65
63
|
description:
|
|
66
64
|
`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.` +
|
|
67
65
|
applyHelperGuide(),
|
|
68
|
-
promptGuidelines: [
|
|
69
|
-
"Use Apply for complex, multi-file changes and standalone editor tools for small precise edits.",
|
|
70
|
-
],
|
|
66
|
+
promptGuidelines: [],
|
|
71
67
|
parameters: Type.Object({
|
|
72
68
|
source: Type.String({
|
|
73
69
|
description:
|
|
74
|
-
"JavaScript function body. Call IDE functions directly without await; each call finishes before the next statement.
|
|
70
|
+
"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.",
|
|
75
71
|
}),
|
|
76
72
|
}),
|
|
77
73
|
async execute(_id, { source }, signal, _onUpdate, context) {
|