pi-agent-ide 0.5.1 → 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 +71 -0
- package/README.md +82 -50
- package/assets/social-preview.png +0 -0
- package/dist/{chunk-LY6U5EAD.js → chunk-2527OQ4Y.js} +1 -1
- package/dist/chunk-4KUFOHWP.js +2 -0
- package/dist/chunk-4LDOV7QS.js +28 -0
- package/dist/chunk-5JELU6RV.js +7 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/chunk-FEDVTZJG.js +1 -0
- package/dist/chunk-I6Y3W4X6.js +27 -0
- package/dist/chunk-K5G4FDXD.js +1 -0
- package/dist/chunk-M5IVSCR2.js +1 -0
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/chunk-S6QRG3TQ.js +1 -0
- 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 -0
- package/dist/entry-17.js +1 -1
- 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 -2
- package/dist/entry-23.js +1 -1
- 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 -12
- 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 +12 -1
- package/dist/entry-32.js +1 -4
- package/dist/entry-33.js +1 -9
- package/dist/entry-34.js +1 -1
- 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 -18
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +17 -1
- package/dist/entry-46.js +1 -7
- package/dist/entry-47.js +1 -11
- package/dist/entry-48.js +1 -1
- 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 -0
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -0
- package/dist/entry-59.js +1 -1
- 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 -0
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +0 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -203
- package/dist/entry-72.js +1 -30
- package/dist/entry-73.js +1 -2
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +315 -1
- package/dist/entry-76.js +30 -3
- package/dist/entry-77.js +2 -3
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +3 -1
- package/dist/entry-81.js +3 -0
- 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 +9 -15
- package/docs/research/apply-read-latency.md +219 -0
- package/docs/tools.md +12 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-22.js +1 -0
- 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-image/runtime/entry-26.js +2 -0
- 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/src/jq.ts +107 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-ide-ast/package.json +12 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- 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/runtime/entry-34.js +2 -0
- 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 +20 -2
- 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-41.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 +4 -4
- 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 +29 -17
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/runtime/entry-46.js +1 -0
- package/node_modules/pi-agent-search/package.json +8 -7
- package/node_modules/pi-agent-search/runtime/entry-47.js +1 -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-search-text/runtime/entry-51.js +2 -0
- package/node_modules/pi-agent-search-text/runtime/entry-52.js +1 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/index.ts +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/config.ts +2 -2
- 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-71.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-72.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-73.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 +131 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +36 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -42
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +50 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +187 -38
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +3 -8
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +770 -237
- 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/post-edit-scope.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +4 -4
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- 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/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-html/runtime/entry-81.js +2 -0
- 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 +112 -43
- package/src/api/documentation.ts +2 -0
- package/src/api/path-identity.ts +15 -0
- package/src/composite/builtin-extensions.ts +14 -2
- package/src/composite/extensions-config.ts +6 -0
- package/src/composite/module-labels.ts +9 -0
- package/src/composite/module-settings-store.ts +3 -0
- package/src/composite/module-settings.ts +71 -17
- package/src/composite/preferences.ts +83 -3
- package/src/composite/presentation.ts +14 -0
- package/src/composite/presets.ts +57 -0
- package/src/composite/selection.ts +5 -1
- package/src/doctor/inventory.ts +7 -2
- 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-image/runtime/entry-26.js +2 -0
- 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-html/runtime/entry-81.js +2 -0
- 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-41.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-42.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 +4 -4
- 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 +29 -17
- 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/plugins/pi-agent-search-text/runtime/entry-51.js +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-47.js +1 -0
- 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-exact/index.ts +3 -3
- 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-exact/src/config.ts +2 -2
- 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/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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-77.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +1 -0
- 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 +131 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +36 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -42
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +50 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +187 -38
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +3 -8
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +770 -237
- 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/post-edit-scope.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +4 -4
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/src/pi-agent-ide.ts +21 -11
- package/src/plugins/pi-agent-ide-ast/package.json +12 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- 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 +13 -11
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +31 -0
- package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +24 -23
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -2
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +55 -17
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -22
- 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/runtime/entry-34.js +2 -0
- 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 +20 -2
- 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-processes/src/registry.ts +4 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +18 -9
- package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +1 -0
- 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/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +8 -5
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +1 -0
- package/src/plugins/pi-agent-ide-vision/index.ts +234 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +530 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +30 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +33 -0
- package/dist/chunk-526E364R.js +0 -3
- package/dist/chunk-5PLV4HLG.js +0 -1
- package/dist/chunk-7ALCBKCW.js +0 -26
- package/dist/chunk-DQXPQOF7.js +0 -2
- package/dist/chunk-EJ5OACQM.js +0 -1
- package/dist/chunk-G725MARR.js +0 -16
- package/dist/chunk-HKXDP2FD.js +0 -7
- package/dist/chunk-IRECDTJG.js +0 -27
- package/dist/chunk-J4RTW44E.js +0 -1
- package/dist/chunk-NZYDMBM6.js +0 -1
- package/dist/chunk-WGGIQ7IJ.js +0 -1
- package/dist/entry-18.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-17.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-24.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/node_modules/pi-agent-ide-formatter/runtime/entry-30.js +0 -2
- package/node_modules/pi-agent-ide-lint/runtime/entry-32.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-34.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-35.js +0 -1
- package/node_modules/pi-agent-pdf/runtime/entry-36.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-37.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-46.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-47.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.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-72.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-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-image/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-web-pdf/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-24.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-37.js +0 -1
- 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-47.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.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 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.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-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +0 -1
- 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-26.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -2
- package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -2
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-30.js +0 -2
- package/src/plugins/pi-agent-ide-lint/runtime/entry-32.js +0 -2
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-jq}/runtime/entry-27.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-filesystem-text}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-changes}/runtime/entry-33.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-42.js +0 -0
- /package/node_modules/{pi-agent-search → 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-text → pi-agent-search}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search}/runtime/entry-50.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text}/runtime/entry-53.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-constant}/runtime/entry-54.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-55.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-tool-call-interception → pi-agent-text-editor}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-renderer}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-80.js +0 -0
- /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-43.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-line-hash → pi-agent-text-anchor-constant}/runtime/entry-54.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-renderer}/runtime/entry-76.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
|
@@ -7,6 +7,7 @@ export const defaultApplyOperations = [
|
|
|
7
7
|
"search",
|
|
8
8
|
"diff",
|
|
9
9
|
"editorOpen",
|
|
10
|
+
"editorResolve",
|
|
10
11
|
"editorApply",
|
|
11
12
|
] as const;
|
|
12
13
|
export type ApplyOperation = (typeof defaultApplyOperations)[number];
|
|
@@ -77,7 +78,7 @@ export async function executeApplySource(
|
|
|
77
78
|
},
|
|
78
79
|
});
|
|
79
80
|
await runner.run({
|
|
80
|
-
source: `${guestBindings(enabledOperations)}\n${source}\n__finishApplyScript();`,
|
|
81
|
+
source: `${guestBindings(enabledOperations)}\nawait (async () => {\n${source}\n})();\n__finishApplyScript();`,
|
|
81
82
|
abortSignal: signal,
|
|
82
83
|
limits: { ...limits, timeoutMs: limits?.timeoutMs ?? APPLY_EXECUTION_TIMEOUT_MS },
|
|
83
84
|
});
|
|
@@ -110,6 +111,10 @@ function applyGuestErrorCode(message: string): string {
|
|
|
110
111
|
if (message === "No matches") return "NOT_FOUND";
|
|
111
112
|
if (message === "Search match is stale") return "STALE_SELECTION";
|
|
112
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";
|
|
113
118
|
if (/^(?:Invalid line range|Line range is outside document)$/u.test(message))
|
|
114
119
|
return "INVALID_SELECTION";
|
|
115
120
|
return "RUN_USER_SOURCE_ERROR";
|
|
@@ -118,50 +123,180 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
118
123
|
const readOperations = enabledOperations.filter(
|
|
119
124
|
(name) => name === "read" || name === "search" || name === "diff",
|
|
120
125
|
);
|
|
121
|
-
return `const { ${readOperations.join(", ")}, open, createFile, deleteFile, copyFile, moveFile,
|
|
122
|
-
|
|
126
|
+
return `const { ${readOperations.join(", ")}, open, createFile, deleteFile, copyFile, moveFile, replace, remove, insertBefore, insertAfter, copy, move, flush, __finishApplyScript } = (() => {
|
|
127
|
+
|
|
123
128
|
const invoke = (name, args) => {
|
|
124
129
|
const response = __apply[name](args);
|
|
125
130
|
if (!response.ok) throw Object.assign(new Error(response.error.message), response.error);
|
|
126
|
-
|
|
131
|
+
|
|
127
132
|
return response.value;
|
|
128
133
|
};
|
|
129
|
-
let generation = 0;
|
|
130
134
|
let snapshots = new Map();
|
|
131
135
|
let operations = [];
|
|
132
136
|
const assertCurrent = (document) => {
|
|
133
|
-
if (document.
|
|
137
|
+
if (!snapshots.has(document.id)) throw Object.assign(new Error("Editor handle belongs to an unavailable snapshot"), {code: "STALE_EDITOR"});
|
|
138
|
+
};
|
|
139
|
+
const selection = (document, from, to, linewise = false) => Object.freeze({document: document.id, from, to, text: document.content.slice(from, to), ...(linewise && {linewise: true})});
|
|
140
|
+
const selectionSet = (document, ranges, provenance) => {
|
|
141
|
+
const set = ranges.map(({from, to, linewise}) => selection(document, from, to, linewise === true));
|
|
142
|
+
Object.defineProperties(set, {document: {value: document.id}, generation: {value: document.generation}, provenance: {value: provenance}, text: {value: set.map((item) => item.text).join("")}});
|
|
143
|
+
return Object.freeze(set);
|
|
134
144
|
};
|
|
135
|
-
const selection = (document, from, to) => Object.freeze({document: document.id, from, to, text: document.content.slice(from, to)});
|
|
136
145
|
const occurrences = (content, needle) => {
|
|
137
146
|
if (typeof needle !== "string" || needle.length === 0) throw new Error("Find text must be non-empty");
|
|
138
147
|
const found = [];
|
|
139
148
|
for (let from = content.indexOf(needle); from >= 0; from = content.indexOf(needle, from + needle.length)) found.push(from);
|
|
140
149
|
return found;
|
|
141
150
|
};
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
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
|
+
};
|
|
168
|
+
const targetSet = (document, target) => {
|
|
169
|
+
if (typeof target !== "string") return target;
|
|
170
|
+
const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: target});
|
|
171
|
+
return selectionSet(document, resolved.selections, {kind: "exact", query: target, warning: resolved.warning});
|
|
172
|
+
};
|
|
173
|
+
const stage = (document, target, text, edge) => {
|
|
174
|
+
const selected = targetSet(document, target);
|
|
175
|
+
if (!Array.isArray(selected) || selected.document !== document.id) throw new Error("SelectionSet belongs to another file");
|
|
176
|
+
if (selected.generation !== document.generation) throw Object.assign(new Error("SelectionSet belongs to a stale snapshot"), {code:"STALE_SELECTION"});
|
|
177
|
+
if (selected.length === 0) { operations.push({kind: "warning", document: document.id, query: selected.provenance?.query, warning: selected.provenance?.warning}); return; }
|
|
178
|
+
for (const range of selected) {
|
|
179
|
+
const point = edge === "before" ? range.from : edge === "after" ? range.to : undefined;
|
|
180
|
+
let insert = text;
|
|
181
|
+
if (point !== undefined && range.linewise === true) {
|
|
182
|
+
const ending = /(?:\\r\\n|\\r|\\n)$/u.exec(range.text)?.[0];
|
|
183
|
+
const separator = ending ?? (document.content.includes("\\r\\n") ? "\\r\\n" : "\\n");
|
|
184
|
+
if (edge === "after" && ending === undefined) insert = separator + insert;
|
|
185
|
+
else if (!/(?:\\r\\n|\\r|\\n)$/u.test(insert)) insert += separator;
|
|
186
|
+
}
|
|
187
|
+
operations.push({kind: "replace", selection: point === undefined ? range : selection(document, point, point), text: insert});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const stageTransfer = (kind, source, destination) => {
|
|
191
|
+
for (const set of [source, destination]) {
|
|
192
|
+
const document = snapshots.get(set?.document);
|
|
193
|
+
if (!Array.isArray(set) || document === undefined || set.generation !== document.generation) throw Object.assign(new Error("SelectionSet belongs to a stale or unopened snapshot"), {code:"STALE_SELECTION"});
|
|
194
|
+
}
|
|
195
|
+
const empty = source.length === 0 ? source : destination.length === 0 ? destination : undefined;
|
|
196
|
+
if (empty !== undefined) { operations.push({kind:"warning", document:empty.document, query:empty.provenance?.query, warning:empty.provenance?.warning}); return; }
|
|
197
|
+
operations.push({kind, sources:[...source], destinations:[...destination], text:source.map((item) => item.text).join("")});
|
|
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);
|
|
146
239
|
};
|
|
147
240
|
const makeDocument = (snapshot) => {
|
|
148
|
-
const document = {id: snapshot.id, source: snapshot.source, content: snapshot.content, lines: snapshot.lines, generation};
|
|
241
|
+
const document = {id: snapshot.id, source: snapshot.source, content: snapshot.content, lines: snapshot.lines, generation: 0};
|
|
242
|
+
snapshots.set(document.id, document);
|
|
149
243
|
const api = {
|
|
150
|
-
source
|
|
151
|
-
content
|
|
152
|
-
lines
|
|
153
|
-
find: (text) => { assertCurrent(document); return
|
|
154
|
-
findAll: (text) => { assertCurrent(document); return occurrences(document.content, text).map((from) => selection(document, from, from + text.length)); },
|
|
244
|
+
get source() { return document.source; },
|
|
245
|
+
get content() { return document.content; },
|
|
246
|
+
get lines() { return document.lines; },
|
|
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}); },
|
|
155
248
|
between: (start, end, options = {}) => {
|
|
156
249
|
assertCurrent(document);
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
const ends =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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);
|
|
253
|
+
const ranges = [];
|
|
254
|
+
let cursor = 0;
|
|
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;
|
|
268
|
+
}
|
|
269
|
+
return selectionSet(document, ranges, {kind: "between"});
|
|
270
|
+
},
|
|
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});
|
|
163
291
|
},
|
|
164
|
-
|
|
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) => {
|
|
165
300
|
assertCurrent(document);
|
|
166
301
|
const candidate = match?.selection ?? match;
|
|
167
302
|
if (!candidate || typeof candidate !== "object") throw new Error("select() requires a search match");
|
|
@@ -175,7 +310,7 @@ select: (match) => {
|
|
|
175
310
|
const to = starts[endLine - 1] + candidate.endColumn;
|
|
176
311
|
const selected = selection(document, from, to);
|
|
177
312
|
if (typeof candidate.matchedText === "string" && selected.text !== candidate.matchedText) throw Object.assign(new Error("Search match is stale"), {code: "STALE_SELECTION"});
|
|
178
|
-
return selected;
|
|
313
|
+
return selectionSet(document, [selected]);
|
|
179
314
|
},
|
|
180
315
|
line: (first, last = first) => {
|
|
181
316
|
assertCurrent(document);
|
|
@@ -183,29 +318,43 @@ select: (match) => {
|
|
|
183
318
|
const starts = [0];
|
|
184
319
|
for (let index = 0; index < document.content.length; index += 1) if (document.content[index] === "\\n") starts.push(index + 1);
|
|
185
320
|
if (last > starts.length) throw new RangeError("Line range is outside document");
|
|
186
|
-
return
|
|
321
|
+
return selectionSet(document, [{from: starts[first - 1], to: starts[last] === undefined ? document.content.length : starts[last], linewise: true}], {kind: "line", first, last});
|
|
187
322
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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}); },
|
|
327
|
+
replace: (target, text) => { assertCurrent(document); stage(document, target, String(text)); },
|
|
328
|
+
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"); },
|
|
331
|
+
flush: () => flushDocument(document),
|
|
332
|
+
delete: () => { assertCurrent(document); operations.push({kind: "delete", path: document.source}); },
|
|
193
333
|
};
|
|
194
334
|
return Object.freeze(api);
|
|
195
335
|
};
|
|
196
|
-
|
|
336
|
+
const api = {
|
|
197
337
|
${readOperations.map((name) => `${name}: (args) => invoke(${JSON.stringify(name)}, args)`).join(",\n")},
|
|
198
|
-
open: (path) =>
|
|
338
|
+
open: (path) => makeDocument(invoke("editorOpen", typeof path === "string" ? {path} : path)),
|
|
199
339
|
createFile: (path, content) => operations.push({kind: "create", path, content: String(content)}),
|
|
200
340
|
deleteFile: (path) => operations.push({kind: "delete", path}),
|
|
201
341
|
copyFile: (path, target, options = {}) => operations.push({kind: "copy", path, target, overwrite: options.overwrite === true}),
|
|
202
342
|
moveFile: (path, target, options = {}) => operations.push({kind: "move", path, target, overwrite: options.overwrite === true}),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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"),
|
|
347
|
+
copy: (source, destination) => stageTransfer("text-copy", source, destination),
|
|
348
|
+
move: (source, destination) => stageTransfer("text-move", source, destination),
|
|
349
|
+
flush: () => {
|
|
350
|
+
if (operations.length === 0) return undefined;
|
|
351
|
+
const pending = operations;
|
|
352
|
+
operations = [];
|
|
353
|
+
return commit(pending);
|
|
206
354
|
},
|
|
207
|
-
|
|
208
|
-
__finishApplyScript: () => { if (operations.length > 0)
|
|
355
|
+
|
|
356
|
+
__finishApplyScript: () => { if (operations.length > 0) return api.flush(); },
|
|
209
357
|
};
|
|
358
|
+
return api;
|
|
210
359
|
})();`;
|
|
211
360
|
}
|
|
@@ -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
|
},
|
|
@@ -63,16 +61,13 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
|
|
|
63
61
|
},
|
|
64
62
|
promptSnippet: "Compose guarded multi-file editor transactions with JavaScript",
|
|
65
63
|
description:
|
|
66
|
-
`Use apply to
|
|
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. Open immutable file snapshots, select exact text or lines, stage guarded operations, then call apply() explicitly. Use standalone editor tools for small precise edits.",
|
|
70
|
-
"Do not call result() merely to display reads or committed file changes; Apply reports them automatically. Use result(value) only for additional calculated data.",
|
|
71
|
-
],
|
|
66
|
+
promptGuidelines: [],
|
|
72
67
|
parameters: Type.Object({
|
|
73
68
|
source: Type.String({
|
|
74
69
|
description:
|
|
75
|
-
"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.",
|
|
76
71
|
}),
|
|
77
72
|
}),
|
|
78
73
|
async execute(_id, { source }, signal, _onUpdate, context) {
|