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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1 — 2026-09-17
|
|
4
|
+
|
|
5
|
+
### Progressive guidance
|
|
6
|
+
|
|
7
|
+
- Add addressable `docs:` resources for focused debugger, diagnostics, editing, Git, JSON, reading, search, terminal, and vision guidance.
|
|
8
|
+
- Stop the first matching tool call before execution, return its complete guide, and let the agent retry with the required instructions in context. Explicitly reading the guide first skips this gate.
|
|
9
|
+
- Keep shell commands for execution and direct agents to guarded editing tools instead of shell-based file edits.
|
|
10
|
+
|
|
11
|
+
### JSON reading
|
|
12
|
+
|
|
13
|
+
- Add parameterized `jq:` views for filtering and transforming filesystem JSON with the real `jq` executable.
|
|
14
|
+
- Apply normal Read pagination to transformed JSON output and return clear parser and execution failures.
|
|
15
|
+
|
|
16
|
+
### Apply
|
|
17
|
+
|
|
18
|
+
- Add composable selection sets for slicing occurrences, combining non-overlapping ranges, limiting candidates to scopes, and expanding matches to complete lines.
|
|
19
|
+
- Add zero-width start, end, before, and after destinations for inserting copied or moved text without replacing existing content.
|
|
20
|
+
- Add symmetric global and document mutation forms, document-scoped flush checkpoints, and deletion through opened document handles.
|
|
21
|
+
- Separate the complete Apply scripting reference from the lighter standalone editing guide and prefer content boundaries over unverified line ranges.
|
|
22
|
+
- Make batched standalone edits the default for independent, predetermined changes in one or several files; reserve Apply scripts for computed, conditional, or transactional workflows.
|
|
23
|
+
- Speed up large Apply transactions by batching text operations while preserving snapshot guards and per-operation outcomes.
|
|
24
|
+
|
|
25
|
+
### Tool behavior and presentation
|
|
26
|
+
|
|
27
|
+
- Require project evidence before running built-in formatters, so an installed formatter no longer changes files in an otherwise unconfigured workspace.
|
|
28
|
+
- Add Full IDE and Text Editor capability presets, with explicit module choices layered on top.
|
|
29
|
+
- Add Full, Compact, and Disabled presentation modes for Apply previews, diffs, Read, Search, and terminal output.
|
|
30
|
+
- Bound compact Read rendering for large results so the terminal stays responsive without reducing the content available to the agent.
|
|
31
|
+
|
|
32
|
+
## 0.6.0 — 2026-09-16
|
|
33
|
+
|
|
34
|
+
### Agent vision
|
|
35
|
+
|
|
36
|
+
- Let agents discover running processes and read process metadata.
|
|
37
|
+
- Let agents inspect application windows, full displays, and rendered web pages as images. Agent-owned windows are available by default; arbitrary windows and full displays require separate opt-in settings.
|
|
38
|
+
- Add image sequences for observing changing interfaces and media over time.
|
|
39
|
+
- Let agents choose sequence duration, frame interval, image scale, normalized image regions, and grid cells.
|
|
40
|
+
- Add executable allowlists for desktop applications that agents may inspect without unrestricted window access.
|
|
41
|
+
- Support Linux and macOS capture through `node-screenshots`, plus visible Windows-host windows and displays from WSL.
|
|
42
|
+
|
|
43
|
+
### Apply
|
|
44
|
+
|
|
45
|
+
- Keep successful independent changes when another operation in the same transaction fails, and report the outcome of each operation.
|
|
46
|
+
- Add selection-set replacements, removals, copies, and moves for exact matches and structural-search results.
|
|
47
|
+
- Add whole-file create, copy, move, and delete operations to Apply scripts.
|
|
48
|
+
- Refresh open files after `flush()`, preserve line endings for line-based edits, and skip post-processing for files that were subsequently moved or deleted.
|
|
49
|
+
|
|
50
|
+
### Windows
|
|
51
|
+
|
|
52
|
+
- Add native Windows support for Agent IDE debugger workflows, filesystem identity, language detection, command launchers, and executable discovery.
|
|
53
|
+
- Improve debugger support across the Windows language toolchains that are available on the machine.
|
|
54
|
+
|
|
55
|
+
### Settings
|
|
56
|
+
|
|
57
|
+
- Add editable settings for sequence duration, frame interval, image scale, and allowed executable names.
|
|
58
|
+
|
|
59
|
+
## 0.5.1 — 2026-09-14
|
|
60
|
+
|
|
61
|
+
### Sessions and processes
|
|
62
|
+
|
|
63
|
+
- Keep active terminal and debugger resources alive across extension reloads, so agents can reconnect to the same `shell:` and `debug:` sessions.
|
|
64
|
+
- Add terminal input mode to the process panel. Press `i` in a terminal detail view to send text and keys, and press Escape to return to the normal view.
|
|
65
|
+
- Keep foreground terminal waits running in the background when an agent turn is interrupted instead of reporting them as aborted.
|
|
66
|
+
- Bound terminal-search output in the TUI while keeping the complete search result available to the agent.
|
|
67
|
+
|
|
68
|
+
### Reading and search
|
|
69
|
+
|
|
70
|
+
- Return a bounded hex and ASCII preview for unsupported HTTP binary responses instead of downloading the full body or failing without useful content.
|
|
71
|
+
- Preserve native image reads when a server reports a generic binary content type for a known image URL.
|
|
72
|
+
- Keep search results when a file or terminal log changes during the search. Stale results remain visible, but unsafe anchors are omitted.
|
|
73
|
+
|
|
3
74
|
## 0.5.0 — 2026-09-13
|
|
4
75
|
|
|
5
76
|
### Debugging
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Pi Agent IDE</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center">IDE
|
|
7
|
+
<p align="center">Give your Pi agent a real IDE: one semantic interface for understanding, changing, running, debugging, and observing software.</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/pi-agent-ide"><img src="https://img.shields.io/npm/v/pi-agent-ide" alt="npm version"></a>
|
|
@@ -12,95 +12,111 @@
|
|
|
12
12
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status"></a>
|
|
13
13
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Funit.json" alt="Unit test count"></a>
|
|
14
14
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Fintegration.json" alt="Integration test count"></a>
|
|
15
|
-
<a href="https://alexshpunt
|
|
15
|
+
<a href="https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Falexshpunt%2Fexplicit-edit-benchmark%2Fresolve%2Fmain%2Fbadges%2Fpi-agent-ide.json" alt="Explicit Edit Benchmark score"></a>
|
|
16
16
|
<a href="./LICENSE"><img src="https://img.shields.io/npm/l/pi-agent-ide" alt="MIT license"></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
## Summary
|
|
20
20
|
|
|
21
|
-
Pi Agent IDE
|
|
21
|
+
Pi Agent IDE gives the [Pi coding agent](https://pi.dev/) a unified set of first-class development tools. Each tool represents an intent instead of one particular implementation. The agent uses the same small set of semantic interfaces across files, source code, terminals, debuggers, web pages, images, processes, application windows, and displays.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
The interfaces are designed to combine. A search result can become an edit selection. A running process can become a terminal, debugger, or visual resource. A source read can expose anchors, syntax, diagnostics, or language-server information without sending the agent through a separate workflow for each capability.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### Read anything through `read`
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
`read` is one interface for inspecting:
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|  |  |
|
|
29
|
+
- files, directories, source code, and raw bytes;
|
|
30
|
+
- JSON transformed through real `jq` filters;
|
|
31
|
+
- web pages, PDFs, images, and image sequences;
|
|
32
|
+
- diagnostics and Git changes;
|
|
33
|
+
- terminal and debugger sessions;
|
|
34
|
+
- running processes, application windows, and full displays.
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
Views change how the same resource is presented. The agent can request source structure, editable anchors, diagnostics, an image, a sequence, or another supported projection without learning a separate tool for every source.
|
|
38
37
|
|
|
39
|
-
###
|
|
38
|
+
### Find anything through `search`
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
`search` provides one interface for paths, exact text, regular expressions, AST patterns, symbols, references, code relationships, process discovery, and retained terminal output. Results are reusable guarded references, so the agent can find an intended target once and pass that selection directly to `read` or an editing tool.
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
### Express edits as intentions
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
Editing uses direct semantic operations:
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
- `write` creates a file or deliberately replaces its complete contents;
|
|
47
|
+
- `replace` changes selected text;
|
|
48
|
+
- `insert` adds text around a selection;
|
|
49
|
+
- `delete` removes selected text or a resource;
|
|
50
|
+
- `copy` and `move` duplicate or relocate text and files;
|
|
51
|
+
- `undo` restores an edit or a complete transaction.
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
Independent edits can be submitted together as a tool-call batch. Conditional and multi-file work uses Apply, a code mode that exposes the same guarded operations through transactional JavaScript. Diffing and staging are first-class tools too.
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
Selections can come from exact text, anchors, search results, AST matches, or language-server symbols. Stale, ambiguous, and failed operations do not apply silently. If one selection method is a poor fit, the agent can recover through another without throwing away the rest of its work.
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
### Run and debug through persistent sessions
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
The terminal is a first-class cross-platform interface. The agent can run commands, keep interactive sessions and background tasks alive across turns and extension reloads, read retained output, send exact input or named keys, and inspect terminal applications through images and sequences.
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
Debugger sessions use the same resource model. The agent can set breakpoints, inspect stack frames and variables, evaluate expressions, step through execution, and return to a running session later.
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
### See the environment
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
The agent can render websites as images, observe changing interfaces over time, and inspect windows opened by its own processes. Arbitrary windows and full displays require separate explicit opt-in settings. Images can be downscaled, limited to normalized regions, or divided into grid cells so the model receives the useful area instead of every source pixel.
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
### Keep context focused through progressive disclosure
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
Pi Agent IDE does not load every capability guide into the system prompt. Detailed instructions are disclosed when the agent first uses the relevant tool and remain available as readable documentation through `read`.
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
The agent receives the complete contract when it needs it. Unrelated capabilities do not consume context throughout the rest of the task, and large results remain progressively readable instead of flooding the context or terminal.
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
### Extend the interfaces through protocols
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
Filesystem and HTTP reads, resource views, content converters, search backends, anchors, formatters, diagnostics, terminals, and debugger resources are independent protocols behind the public tools. Extensions can add or replace those capabilities without creating another one-off interface for the agent. See [Writing extensions](./docs/extensions.md).
|
|
72
76
|
|
|
73
|
-
###
|
|
77
|
+
### Observe the work and recover cheaply
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
A person can see the agent's edits, diffs, diagnostics, running processes, debugger state, and failures. Bounded presentation keeps live output readable without discarding the underlying result. Guarded snapshots and first-class undo make mistakes visible and recovery inexpensive.
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
### Work across languages and platforms
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
Built-in debugger recipes cover C, C++, C#, Dart, Elixir, Go, Java, JavaScript, Julia, Kotlin, Lua, PHP, PowerShell, Python, R, Ruby, Rust, shell scripts, Swift, TypeScript, and Zig. Formatting, linting, AST, language-server, and debugger support follows the tools and configuration available in each project.
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
Windows and WSL are first-class supported environments alongside Linux. Run doctor to see the exact capabilities available on the current machine.
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
### Built through data-driven development
|
|
84
88
|
|
|
85
|
-
Pi Agent IDE
|
|
89
|
+
Pi Agent IDE is developed through daily use on real software and measured with the [Explicit Edit Benchmark](https://github.com/alexshpunt/explicit-edit-benchmark). Every release is exercised against real editing tasks, and the measured result becomes part of the release evidence. The badge above links to the [latest accepted observation](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest), with its score and run details; the underlying observations are available in the [published dataset](https://huggingface.co/datasets/alexshpunt/explicit-edit-benchmark).
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
The project is also used to develop itself. Weak interactions, missing affordances, and agent failure modes appear in real work instead of remaining theoretical. Problems are fixed as they are found, and the tools evolve through regular releases.
|
|
92
|
+
|
|
93
|
+
Pi Agent IDE is experimental and under active development. Interfaces and behavior may change.
|
|
90
94
|
|
|
91
95
|
## Installation
|
|
92
96
|
|
|
93
|
-
Install [Pi](https://pi.dev/) first, then install Pi Agent IDE:
|
|
97
|
+
Install [Pi](https://pi.dev/) first, then install Pi Agent IDE from npm:
|
|
94
98
|
|
|
95
99
|
```bash
|
|
96
100
|
pi install npm:pi-agent-ide
|
|
97
101
|
```
|
|
98
102
|
|
|
103
|
+
Or install it directly from GitHub:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pi install git:github.com/alexshpunt/pi-agent-ide
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To pin a Git installation, append a release tag or commit. To try the package for one session without adding it to your settings:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pi -e npm:pi-agent-ide
|
|
113
|
+
```
|
|
114
|
+
|
|
99
115
|
Pi packages run with your full system permissions. Review the package before installing it.
|
|
100
116
|
|
|
101
117
|
## Check project tools
|
|
102
118
|
|
|
103
|
-
Pi Agent IDE includes formatter, linter, LSP, and debugger mappings. It
|
|
119
|
+
Pi Agent IDE includes formatter, linter, LSP, and debugger mappings. It discovers each tool from the project that owns the file, including project-local binaries and commands on your `PATH`. Settings from one project do not leak into another.
|
|
104
120
|
|
|
105
121
|
Start Pi in your project directory, then run:
|
|
106
122
|
|
|
@@ -108,29 +124,45 @@ Start Pi in your project directory, then run:
|
|
|
108
124
|
/pi-agent-ide-doctor
|
|
109
125
|
```
|
|
110
126
|
|
|
111
|
-
Doctor
|
|
127
|
+
Doctor reports the effective project, global, and built-in mappings, their source layers and commands, and the real probe results. It also checks AST support, search, Git, and optional Chrome or Chromium support for browser-rendered web reads.
|
|
112
128
|
|
|
113
129
|
Doctor shows its report before changing anything. If project evidence points to a different installed tool, it can write a project-only override under `.pi/pi-agent-ide/`. It never changes global or built-in configuration. Native files such as `eslint.config.js`, `.clang-format`, and `pyproject.toml` remain unchanged.
|
|
114
130
|
|
|
115
|
-
Doctor also reports optional system Chrome/Chromium support for browser-rendered web reads. When setup still needs work, you can ask the agent to finish it; doctor runs the checks again afterward.
|
|
116
|
-
|
|
117
131
|
Run doctor again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
|
|
118
132
|
|
|
133
|
+
## Gallery
|
|
134
|
+
|
|
135
|
+
| Read and guarded tool editing | Transactional Apply |
|
|
136
|
+
| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
137
|
+
|  |  |
|
|
138
|
+
| Web reading | Search and replace |
|
|
139
|
+
|  |  |
|
|
140
|
+
| Background processes | Source-level debugging |
|
|
141
|
+
|  |  |
|
|
142
|
+
|
|
143
|
+
## Customization
|
|
144
|
+
|
|
145
|
+
Pi Agent IDE follows Pi's permissive, YOLO-style default: the agent can use the tools without asking for approval at every step. You can make it as strict as your work requires.
|
|
146
|
+
|
|
147
|
+
- [Settings](./docs/configuration.md) control built-in tools, project mappings, search, vision, and presentation.
|
|
148
|
+
- [File hooks](./docs/user-hooks.md) can inspect, change, or deny reads and edits.
|
|
149
|
+
- [Extensions](./docs/extensions.md) can add or replace protocols, resolvers, views, anchors, search backends, and other behavior.
|
|
150
|
+
|
|
119
151
|
## Feedback and contributions
|
|
120
152
|
|
|
121
|
-
Pi Agent IDE is used actively in real development, but I can only reproduce the models, tools, environments, and workflows available to me. Everyone works differently, and I cannot find or cover every case on my own.
|
|
153
|
+
Pi Agent IDE is used actively in real development, but I can only reproduce the models, tools, environments, and workflows available to me. Everyone works differently, and I cannot find or cover every case on my own.
|
|
122
154
|
|
|
123
|
-
If something breaks, behaves badly, or does not fit your workflow, please [open an issue](https://github.com/alexshpunt/pi-agent-ide/issues). Bug reports, ideas,
|
|
155
|
+
If something breaks, behaves badly, or does not fit your workflow, please [open an issue](https://github.com/alexshpunt/pi-agent-ide/issues). Bug reports, ideas, questions, and pull requests are welcome.
|
|
124
156
|
|
|
125
157
|
## Documentation
|
|
126
158
|
|
|
127
159
|
| Document | Contents |
|
|
128
160
|
| ------------------------------------------ | -------------------------------------------------------------------- |
|
|
129
|
-
| [Tools and workflow](./docs/tools.md) | Read, search, editing, anchors, and feedback
|
|
161
|
+
| [Tools and workflow](./docs/tools.md) | Read, vision, search, editing, anchors, and feedback |
|
|
130
162
|
| [Architecture](./docs/architecture.md) | Module boundaries, protocols, and the umbrella extension |
|
|
131
163
|
| [Configuration](./docs/configuration.md) | Run doctor, configure project tools and search, or disable built-ins |
|
|
132
164
|
| [File hooks](./docs/user-hooks.md) | Inspect, change, or deny reads and edits |
|
|
133
|
-
| [Writing extensions](./docs/extensions.md) | Add resolvers, anchors, search backends, and IDE plugins
|
|
165
|
+
| [Writing extensions](./docs/extensions.md) | Add resolvers, views, anchors, search backends, and IDE plugins |
|
|
134
166
|
| [Development](./docs/development.md) | Work from a checkout, test, and run modular mode |
|
|
135
167
|
|
|
136
168
|
## License
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,
|
|
1
|
+
import{a as j,m as M}from"./chunk-FEDVTZJG.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-Z3VC3S2T.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var h=[],y=[],P=[];function b(n,t,e){if(t.some(i=>i.name===e))throw new Error(`[pi-agent-ide] ${n} "${e}" is already registered. Use a unique name.`)}c(b,"assertUniqueName");function q(n){let t=new Set;for(let e of n){let i=`${e.kind}:${e.name}`;if(t.has(i))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(i),e.kind){case"compiler":{b(e.kind,y,e.name);break}case"formatter":{b(e.kind,h,e.name);break}case"linter":{b(e.kind,P,e.name);break}}}for(let e of n)switch(e.kind){case"compiler":{y.push(e);break}case"formatter":{h.push(e);break}case"linter":{P.push(e);break}}}c(q,"registerTools");async function L(n,t){let e=[];for(let i of n)try{await i.detect(t)&&e.push(i)}catch(o){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,o)}return e.sort((i,o)=>o.priority-i.priority),H(e),e}c(L,"filterActive");function H(n){let t=new Map;for(let e of n)for(let i of e.extensions){let o=`${i}@${e.priority}`,a=t.get(o);if(a!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${a}" and "${e.name}" both claim "${i}" at priority ${e.priority}.`);t.set(o,e.name)}}c(H,"assertNoPriorityConflicts");async function G(n){let[t,e]=await Promise.all([L(h,n),L(y.filter(i=>i.syntaxOnly===!0),n)]);return{ctx:n,formatters:t,compilers:e,linters:[]}}c(G,"warmupFormatting");function T(){h.length=0,y.length=0,P.length=0}c(T,"resetRegistry");import{readFile as D}from"node:fs/promises";import g from"node:path";var v=class{constructor(t,e={}){this.sources=t;this.options=e}static{c(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:i}){this.disposed||this.ensure(t,e,i)}async read(t,{cwd:e,mode:i,signal:o}){o?.throwIfAborted(),this.assertActive();let a=g.resolve(e,t),s=await D(a,"utf8");this.assertActive();let r=this.ensure(a,s,e);i==="complete"?await this.waitComplete(r,o):i!=="snapshot"&&await K(Promise.all(r.jobs),this.options.readWaitMs??5e3),o?.throwIfAborted(),this.assertActive();let d=await D(a,"utf8");this.assertActive();let l=this.ensure(a,d,e);if(i==="complete"&&l!==r)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:a,content:l.content,results:[...l.results.values()]}}async waitComplete(t,e){let i=e?AbortSignal.any([e,t.controller.signal]):t.controller.signal;i.throwIfAborted();let o=[];await new Promise((a,s)=>{let r=c(m=>s(Object.assign(new Error(m),{code:m,details:[...t.results.values()]})),"fail"),d=c(()=>{let m=[...t.results.values()];m.some(w=>w.status==="unavailable")?r("DIAGNOSTICS_UNAVAILABLE"):m.every(w=>w.status==="ready")&&a()},"check"),l=c(()=>s(i.reason),"abort"),f=this.onDidChange(d),u=setTimeout(()=>r("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",l,{once:!0});let p=c(()=>{clearTimeout(u),f(),i.removeEventListener("abort",l)},"cleanup");Promise.resolve().then(d),o.push(p)}).finally(()=>{for(let a of o)a()})}async takeNotifications(t){let e=[];for(let i of[...this.dirty]){if(i.cwd!==g.resolve(t)||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let o=[...i.results.values()].filter(d=>d.status!=="pending"&&d.status!=="unavailable"&&d.diagnostics.length>0),a=this.key(i.filePath,i.cwd),s=JSON.stringify(o);if(this.sent.get(a)===s||(this.sent.set(a,s),o.length===0))continue;let r=o.map(d=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=d.diagnostics.filter(p=>p.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${d.source} ${l.join(", ")}${d.status==="snapshot"?" (snapshot; completion unknown)":d.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,i.filePath),results:o,text:`${JSON.stringify(g.relative(t,i.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,i){let o=this.key(t,i),a=this.files.get(o);if(a?.content===e)return a;a?.controller.abort(),a&&this.dirty.delete(a);let s={cwd:g.resolve(i),filePath:g.resolve(i,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let d=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(d)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await D(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,i){let o=(t.publications.get(e)??0)+1;if(t.publications.set(e,o),!await this.isCurrent(t)||t.publications.get(e)!==o)return;let a={...i,source:i.source??e};if(JSON.stringify(t.results.get(e))===JSON.stringify(a))return;t.results.set(e,a),this.dirty.add(t);let s=[...t.results.values()].some(r=>r.status!=="pending"&&r.status!=="unavailable"&&r.diagnostics.length>0);s||this.sent.delete(this.key(t.filePath,t.cwd));for(let r of this.changeListeners)r(t.cwd,s)}async check(t,e){if(!await this.isCurrent(t))return;let i=new AbortController,o=AbortSignal.any([i.signal,t.controller.signal]);if(o.aborted)return;let a,s;try{let r=new Promise((l,f)=>{s=c(()=>f(o.reason),"onAbort"),o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:o,publish:c(l=>{o.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,d)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(a),s&&o.removeEventListener("abort",s)}}};async function K(n,t){let e;try{await Promise.race([n,new Promise(i=>{e=setTimeout(i,t)})])}finally{clearTimeout(e)}}c(K,"waitAtMost");function V(){let n=new Map,t=[],e=new v(t),i=Promise.resolve();return{diagnostics:e,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=n.get(o.id);if(a!==void 0)return a;let s=i.then(async()=>{let r=[],d=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);Z(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);tt(u),d.push(u)},readDiagnostics(u,p){return e.read(u,p)}};try{await o.setup(f)}catch(u){throw l=!1,u}l=!1,Q(t,d),q(r),t.push(...d)});return n.set(o.id,s),i=s.catch(()=>{}),s.catch(()=>{n.delete(o.id)}),s},async waitForPendingPlugins(){await Promise.all(n.values())}}}c(V,"createIdeCore");function Q(n,t){let e=new Set(n.map(i=>i.id));for(let i of t){if(e.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);e.add(i.id)}}c(Q,"assertUniqueDiagnosticSources");function Z(n){if(!U(n))throw new TypeError("IDE tool must be an object");let t=n.kind,e=t==="compiler"?n.compile:t==="formatter"?n.format:t==="linter"?n.lint:void 0;if(e===void 0||typeof e!="function"||typeof n.detect!="function"||typeof n.name!="string"||n.name.trim().length===0||typeof n.priority!="number"||!Number.isFinite(n.priority)||!Array.isArray(n.extensions)||n.extensions.length===0||n.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}c(Z,"assertIdeTool");function tt(n){if(!U(n)||typeof n.id!="string"||n.id.trim().length===0||typeof n.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}c(tt,"assertDiagnosticSource");function U(n){return typeof n=="object"&&n!==null}c(U,"isRecord");function J(n,t,e=console.error){let i=new Map,o=!1,a=Promise.resolve();return{schedule(s){if(o||i.has(s))return;let r=setTimeout(()=>{i.delete(s),a=a.then(async()=>{o||await n(s)}).catch(e)},t);i.set(s,r)},dispose(){o=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}c(J,"createDiagnosticDelivery");import{Text as Y}from"@earendil-works/pi-tui";var S="ide-diagnostic-summary";function W(n){return{filePath:n.filePath,sources:n.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let i of t.diagnostics)e[i.severity]++;return{source:t.source,status:t.status,counts:e}})}}c(W,"diagnosticEntryData");function E(n,t,e=!1){return{render(i){let o=n.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(d=>d>0));if(o.length===0)return[];let a=o.map(r=>`${x(r.counts,t)} ${t.fg("dim",`(${I(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",I(n.filePath))} \xB7 ${a}`];if(e)for(let r of o)s.push(` ${t.fg("dim",I(r.source))} \xB7 ${x(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new Y(s.join(`
|
|
2
2
|
`),0,0).render(i)},invalidate(){}}}c(E,"renderDiagnosticEntry");function B(n){n.registerEntryRenderer(S,(t,e,i)=>{let o=k(t.data);return"files"in o?et(o.files,i,e.expanded):E(o,i,e.expanded)})}c(B,"registerDiagnosticEntryRenderer");function et(n,t,e=!1){return{render(i){let o=n.filter(d=>d.sources.some(l=>l.status!=="pending"&&l.status!=="unavailable"&&Object.values(l.counts).some(f=>f>0)));if(o.length===1&&o[0])return E(o[0],t,e).render(i);if(o.length===0)return[];let a={error:0,warning:0,info:0,hint:0},s=new Set;for(let d of o)for(let l of d.sources)if(!(l.status==="pending"||l.status==="unavailable")){s.add(l.source);for(let f of["error","warning","info","hint"])a[f]+=l.counts[f]}let r=new Y(`${t.fg("accent","Diagnostics")} \xB7 ${o.length} files \xB7 ${x(a,t)} \xB7 ${s.size} tools`,0,0).render(i);return e?[...r,...o.flatMap(d=>E(d,t,!0).render(i))]:r},invalidate(){}}}c(et,"renderDiagnosticBatch");function x(n,t){return["error","warning","info","hint"].filter(e=>n[e]>0).map(e=>{let i=n[e],o=e==="info"||i===1?e:`${e}s`,a=i>0&&(e==="error"||e==="warning")?e:"muted";return t.fg(a,`${i} ${o}`)}).join(", ")}c(x,"renderCounts");function I(n){return n.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}c(I,"plain");import X from"node:path";async function z(n){if(!X.isAbsolute(n.resourceSource))return{formatting:{status:"unavailable"}};let t;try{let e=await G({cwd:n.cwd}),i=X.extname(n.resourceSource).toLowerCase(),o=c(d=>d.extensions.includes(i)||d.extensions.includes("*"),"matches"),a=e.compilers.find(o);if(a&&(await a.compile({filePath:n.resourceSource},e.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=e.formatters.find(o);if(!s)return{formatting:{status:"unavailable"}};t=s.name;let r=await s.format({filePath:n.resourceSource},e.ctx);return r.formatter===null?{formatting:{status:"unavailable"}}:(t=r.formatter??s.name,{formatting:{status:r.ok?r.edits>0?"changed":"unchanged":"failed",formatter:t},...r.ok?{diffStatuses:[{text:`Formatted (${t})`,tone:"success",formatter:t}]}:{diffStatuses:[{text:`Formatting failed (${t})`,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error"}],formatting:{status:"failed",...t===void 0?{}:{formatter:t}}}}}c(z,"runIdePostEditGate");import it from"node:path";async function nt(n){T();let t=V();B(n);let e=n.events.on($,s=>{if(!F(s))throw new Error("Invalid pi-agent-ide plugin registration request");s.accept(t.registerPlugin(s.plugin))});n.on("session_shutdown",()=>{e(),t.diagnostics.dispose(),T()}),M(n,{id:"pi-agent-ide",handler:c(s=>n.getFlag("pi-agent-ide-no-post-processing")===!0?Promise.resolve({formatting:{status:"disabled"}}):z(s),"handler")}),n.events.emit(A,{protocol:C,apiVersion:4}),await _(n,{protocol:N,apiVersion:O,id:"ide-diagnostics",setup(s){s.onDidEdit(r=>{n.getFlag("pi-agent-ide-no-post-processing")===!0||r.postProcessing==="deferred"||it.isAbsolute(r.resourceSource)&&j(()=>t.diagnostics.schedule(r.resourceSource,r.after.content,{cwd:r.cwd}))})}});let i=!1,o=J(async s=>{let r=await t.diagnostics.takeNotifications(s);i||r.length===0||(n.sendMessage({customType:"ide-diagnostics",display:!1,content:`File diagnostics:
|
|
3
3
|
${r.map(d=>d.text).join(`
|
|
4
4
|
`)}`},{triggerTurn:!0,deliverAs:"steer"}),n.appendEntry(S,{files:r.map(W)}))},n.getFlag("pi-agent-ide-no-diagnostic-buffer")===!0?0:5e3),a=t.diagnostics.onDidChange((s,r)=>{r&&o.schedule(s)});n.on("session_shutdown",()=>{i=!0,o.dispose(),a()}),await t.waitForPendingPlugins()}c(nt,"registerPiAgentIde");export{nt as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as A,f as E}from"./chunk-T7I2VX3J.js";import{d as q}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as T}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as O}from"./chunk-6CZO43OH.js";import{a as b,b as N}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{e as m,f as h,g as w,h as P,i as k,l as y}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as C}from"./chunk-HKMBQLEK.js";import{a as I,b as v}from"./chunk-Z3VC3S2T.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import W from"node:path";var M="diagnostics",_=T({kind:"code-view",label:"Diagnostics"});async function S(r){E(r,[await A({id:"diagnostics",description:"Diagnostic resources, readiness, and verification",triggers:[{tool:"read",resourcePrefixes:["diagnostics:"]}]})]);let n,t=l((c,f,e)=>{if(n===void 0)throw new Error("IDE diagnostics are not connected");return n(c,{cwd:f,...e})},"collect"),s={protocol:I,apiVersion:4,id:"diagnostics",setup(c){n=c.readDiagnostics}},o=new WeakMap,i=new WeakMap,a=new WeakMap,d=new WeakMap,V={protocol:b,apiVersion:N,id:"diagnostics",setup(c){c.addResolver({resolver:H(t,i),renderResult:_});let f=y();c.addView({view:"diagnostics",priority:100,presenter:j(t,d)}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let g=e.state.content[0],u=i.get(g);return u&&o.set(e.request,u),f(e)}return e.state?.contentKind==="text"&&e.request.views?.includes("diagnostics")&&a.set(e.request,e.state.text),{kind:"continue",context:e}}}),c.addHandler({stage:"post-read",handler(e){let g=o.get(e.request);if(g&&e.result)return{kind:"continue",context:{...e,result:{...e.result,details:{...e.result.details,diagnosticCheck:g}}}};let u=a.get(e.request),D=u&&d.get(u),p=e.result,R=p?.content[0];return!D||!p||R?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:{...e,result:{...p,content:[{...R,text:`${D}
|
|
2
|
+
${R.text}`},...p.content.slice(1)]}}}}}),c.describe('diagnostics:<path> \u2014 lint and language-server diagnostics. views: ["diagnostics"] \u2014 diagnostics alongside source text. Results identify their reporting tool and readiness; pending results and snapshots are not completed checks.')}};await Promise.all([C(r,s),O(r,V)])}l(S,"registerDiagnostics");function H(r,n){return{id:"diagnostics",tryResolve(t,s){return Promise.resolve(L(t,s.cwd,r,n,{signal:s.signal,...s.audience==="script"&&{mode:"complete"}}))}}}l(H,"createDiagnosticResolver");function L(r,n,t,s,o){let i;try{i=m(r,M,n)}catch(a){return{kind:"failed",error:a}}return i===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:h(M,i),async read(){let a=await t(i,n,o),d=w(i,a.content,a.results);return s.set(d,d.diagnosticCheck),[d]}}}}l(L,"resolveDiagnosticSource");function j(r,n){return{id:"diagnostics",async present(t,s){if(s.purpose!=="read"||!W.isAbsolute(t.source))return t;let o=s.audience==="script"&&!s.requestedViews?.includes("diagnostics");if(o&&q(t.source))return t;let i=await r(t.source,s.cwd,{signal:s.signal,...s.audience==="script"&&{mode:o?"snapshot":"complete"}}).catch(a=>{if(s.signal?.throwIfAborted(),!o)throw a});if(i===void 0||o&&i.content!==t.content)return t;if(i.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,k(i.results)),P(t,i.results)}}}l(j,"createDiagnosticPresenter");export{S as default};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{a as oe,b as se,c as ae}from"./chunk-ESPNEJHK.js";import{a as ie}from"./chunk-M5IVSCR2.js";import{e as Y,f as V}from"./chunk-T7I2VX3J.js";import{a as ee}from"./chunk-L7JMDDSD.js";import{a as Z,b as Q}from"./chunk-O6LE42GK.js";import{b as x}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as J}from"./chunk-6CZO43OH.js";import{a as K,b as z}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as re}from"./chunk-ZTYWHL2F.js";import{a as te,b as ne}from"./chunk-7UGNGK7Y.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Be from"node:path";import{stripVTControlCharacters as qe}from"node:util";import{truncateLine as Xe}from"@earendil-works/pi-coding-agent";import{Text as T}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as le,DEFAULT_MAX_LINES as ue,formatSize as He,truncateTail as Ge}from"@earendil-works/pi-coding-agent";function _(t){return Ge(t,{maxBytes:le-4096,maxLines:ue-32})}a(_,"terminalOutputTail");function $(t){let e=_(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.waitReason===void 0?void 0:`next: Read ${t.source} to inspect it, then use write or insert to send input.`,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
|
|
2
|
+
`)}
|
|
3
|
+
output:${r.length===0?" (empty)":`
|
|
4
|
+
${r}`}`;let i=e.truncatedBy==="lines"?`${ue} line output budget`:`${He(le)} output budget`,s=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
output:
|
|
7
|
+
${s}${r.length===0?"":`
|
|
8
|
+
${r}`}`}a($,"formatAgentTerminalSnapshot");var Ye=500;function ce(t,e,n,r,i){let s=e?"background":"wait",o=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${C(n)} \xB7 ${s}`)}`;return new T(`${o}
|
|
9
|
+
${i.fg("accent",O(r.family))} ${t}`,0,0)}a(ce,"renderRunCall");function de(t,e,n){let r=e.map(i=>` ${n.fg("dim",i)}`);return r.push(n.fg("success",t==="delete"?"\u2713 stopped":"\u2713 sent")),new T(r.join(`
|
|
10
|
+
`),0,0)}a(de,"renderTerminalActionResult");function A(t,e,n,r,i){let s=[ze(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&s.push(...r.map(o=>` ${i.fg("dim",o)}`)),new T(s.join(`
|
|
11
|
+
`),0,0)}a(A,"renderTerminalAction");function S(t,e,n,r){let i=fe(t,x,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),new T(i.join(`
|
|
12
|
+
`),0,0)}a(S,"renderTerminalResult");function me(t,e,n){if(e===!0?e="full":e===!1&&(e="compact"),e==="disabled"){if(!(t.status!==void 0&&!["running","completed"].includes(t.status)||t.exitCode!==void 0&&t.exitCode!==0||t.error!==void 0))return new T(P(t,(u,c)=>n.fg(u,c)),0,0);let o=v(t.output??"",x),l=[...o.omission===void 0?[]:[` ${n.fg("muted",o.omission)}`],...o.lines.map(u=>` ${n.fg("dim",u)}`),...t.error===void 0?[]:[` ${n.fg("error",t.error)}`],P(t,(u,c)=>n.fg(u,c))];return new T(l.join(`
|
|
13
|
+
`),0,0)}if(e==="full"){let s=fe(t,Number.POSITIVE_INFINITY,n).slice(2);return new T(s.join(`
|
|
14
|
+
`),0,0)}let r=v(t.output??"",x),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(s=>` ${n.fg("dim",s)}`)];return i.push(P(t,(s,o)=>n.fg(s,o))),new T(i.join(`
|
|
15
|
+
`),0,0)}a(me,"renderRunResult");function pe(t,e){let n=a((o,l)=>e?.fg(o,l)??l,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${C(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",O(t.shellFamily))} ${D(t.command,84)}`],s=Ve(t.output,2);return s.length>0&&i.push(...s.map(o=>` ${n("dim",D(o,90))}`)),i.push(P(t,n)),i.join(`
|
|
16
|
+
`)}a(pe,"renderActiveTerminal");function fe(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",s=t.cwd===void 0?"workspace":C(t.cwd),o=t.shellFamily??"posix",l=[`${n.fg("accent",r)} ${n.fg("muted",`\xB7 ${s} \xB7 ${i}`)}`,`${n.fg("accent",O(o))} ${t.command??""}`],u=v(t.output??"",e);return u.omission!==void 0&&l.push(` ${n.fg("muted",u.omission)}`),u.lines.length>0&&l.push(...u.lines.map(c=>` ${n.fg("dim",c)}`)),l.push(P(t,(c,d)=>n.fg(c,d))),l}a(fe,"terminalCardLines");function Ve(t,e){return v(t,e).lines}a(Ve,"outputTail");function v(t,e){let n=_(qe(t).replaceAll("\r","")),r=n.content.split(`
|
|
17
|
+
`).map(u=>Xe(u.trimEnd(),Ye).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,s=Math.max(0,r.length-i),o=Math.max(0,n.totalLines-n.outputLines),l=s+o;return{lines:r.slice(s),...n.truncated||l>0?{omission:l>0?`\u2026 ${l} earlier lines`:"\u2026 earlier output omitted"}:{}}}a(v,"outputWindow");function P(t,e){let n=t.status??"running",r=Ke(n),i=n==="completed"?"success":n==="running"?"accent":"error",s=[`${r} ${n}`,Je(t.elapsedMs??0)];return t.waitReason!==void 0&&s.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&s.push(`reason ${t.completionReason}`),t.exitCode!==void 0?s.push(`exit ${t.exitCode}`):t.signal!==void 0&&s.push(`signal ${t.signal}`),e(i,s.join(" \xB7 "))}a(P,"statusLine");function Ke(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}a(Ke,"statusIcon");function O(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}a(O,"promptMarker");function ze(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":C(t.cwd),i=t.background===!0?"background":"wait",s=D(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${s}`)}`}a(ze,"terminalIdentity");function C(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${Be.sep}`))?`~${t.slice(e.length)}`:t}a(C,"shortCwd");function D(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}a(D,"oneLine");function Je(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(Je,"formatElapsed");function ge(t){return{id:"terminal",onDidChange:a(e=>t.onDidChange(e),"onDidChange"),list:a(()=>t.list().filter(e=>e.status==="running"||e.status==="stopping").map(e=>({source:e.source,kind:"terminal",title:e.shell.toLocaleLowerCase(),description:e.command,status:e.status==="stopping"?"stopping":"running",...e.pid===void 0?{}:{pid:e.pid,owned:!0},renderSummary:a(n=>pe(e,n).split(`
|
|
18
|
+
`),"renderSummary"),renderDetail:a(n=>S(e,!0,n),"renderDetail"),sendInput:a(n=>t.write(e.source,n),"sendInput"),stop:a(()=>t.delete(e.source),"stop")})),"list")}}a(ge,"terminalProcessProvider");var Ze="#d8dee9",N="#111418",Qe=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function W(t,e,n){let r=t.get(e);if(r===void 0)throw new Error(`Unknown terminal session ${e}`);await r.screenReady;let{createCanvas:i}=await import("@napi-rs/canvas"),s=Math.max(0,Math.min(r.rows-1,n?.start??0)),o=Math.max(1,Math.min(r.rows-s,n?.count??r.rows)),l=i(r.cols*9+24,o*18+24),u=l.getContext("2d");u.fillStyle=N,u.fillRect(0,0,l.width,l.height),u.textBaseline="top";let c=r.screen.buffer.active,d=Math.max(0,c.baseY);for(let m=0;m<o;m+=1){let p=c.getLine(d+s+m);if(p!==void 0)for(let f=0;f<r.cols;f+=1){let h=p.getCell(f);h===void 0||h.getWidth()===0||et(u,h,f,m)}}return r.status==="running"&&c.cursorY>=s&&c.cursorY<s+o&&(u.fillStyle="rgba(216, 222, 233, 0.75)",u.fillRect(12+c.cursorX*9,12+(c.cursorY-s)*18+18-2,9,2)),l.toBuffer("image/png").toString("base64")}a(W,"renderTerminalScreen");function et(t,e,n,r){let i=he(e,"foreground"),s=he(e,"background");e.isInverse()&&([i,s]=[s,i]);let o=12+n*9,l=12+r*18;s!==N&&(t.fillStyle=s,t.fillRect(o,l,9*Math.max(1,e.getWidth()),18));let u=e.getChars();u.length!==0&&(t.font=`${e.isBold()?"bold ":""}14px monospace`,t.fillStyle=i,t.fillText(u,o,l),e.isUnderline()&&t.fillRect(o,l+18-2,9*Math.max(1,e.getWidth()),1))}a(et,"drawCell");function he(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?Ze:N;let i=n?t.isFgRGB():t.isBgRGB(),s=n?t.getFgColor():t.getBgColor();return i?`#${s.toString(16).padStart(6,"0")}`:tt(s)}a(he,"cellColor");function tt(t){let e=Qe[t];if(e!==void 0)return e;if(t>=232){let l=8+(t-232)*10;return ye(l,l,l)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),s=n%6,o=a(l=>l===0?0:55+l*40,"channel");return ye(o(r),o(i),o(s))}a(tt,"ansiColor");function ye(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}a(ye,"rgb");var F="\0pi-terminal-write\0",j="\0pi-terminal-keys\0";async function xe(t,e){let n=new Map,r=new Map,i={protocol:K,apiVersion:z,id:"terminal",setup(o){o.addResolver({resolver:nt(e),preserveTruncatedOutput:!0,renderResult(l,u,c){let d=l.details,m=d.source===void 0?void 0:e.get(d.source),p=m===void 0?{}:e.snapshot(m);return S(m===void 0?p:{...p,output:e.screenTail(m).join(`
|
|
19
|
+
`)},u.expanded,c,"read terminal")}}),o.addHandler({stage:"pre-read",async handler(l){let u=l.request.path;if(u===void 0||!y(u)||l.request.views?.includes("image")!==!0)return{kind:"continue",context:l};let c=e.get(u);if(c===void 0)return{kind:"return",result:we(u,`Unknown terminal session ${u}`)};try{return e.markInspected(u),{kind:"return",result:{content:[{type:"image",data:await W(e,u),mimeType:"image/png"}],details:{source:c.source,resolvedBy:"terminal"}}}}catch(d){return{kind:"return",result:we(u,d instanceof Error?d.message:String(d))}}}}),o.describe('shell:<session> \u2014 terminal status and a bounded output tail with a full-log path when truncated. views: ["image"] returns the virtual terminal screen as a PNG.')}},s={protocol:Z,apiVersion:Q,id:"terminal",setup(o){o.addResolver({resolver:rt(e)}),o.tool("write").addHandler({stage:"text-pre-edit",handler:a(async l=>(Se(l.input,e,n),await Te(l.input,e,r),it(l,F)),"handler")}),o.tool("insert").addHandler({stage:"text-pre-edit",handler:a(async l=>(await Te(l.input,e,r),Se(l.input,e,n),ot(l)),"handler")});for(let l of["write","insert","delete"])o.addToolRenderer({tool:l,matches:a((u,c)=>ut(u,c),"matches"),renderCall(u,c,d){let m=u,p=typeof m.path=="string"?e.get(m.path):void 0,f=d.state;return p!==void 0&&(f.snapshot=e.snapshot(p)),A(f.snapshot??{},l,be(l,m),[],c)},renderResult(u,c,d){let m=lt(u.details);return de(m.action,m.changedLines,d)}});o.describe("For shell:<session> resources, write sends exact terminal input, insert sends named keys at end, and delete terminates and removes the session. replace is unsupported."),o.tool("write").describe("When path is shell:<session>, send content exactly as terminal input without adding Enter."),o.tool("insert").describe("When path is shell:<session>, omit anchor or use end, keep before false, and put whitespace- or comma-separated named keys and chords such as Enter, Ctrl+C, Ctrl+Left, Ctrl+Shift+Left, Up, or Backspace in text. Use Unix caret forms such as ^C and ^U for control characters.")}};await Promise.all([J(t,i),ee(t,s)]),t.on("tool_result",async(o,l)=>{if(!w(o.input))return;let u=o.input.path;if(o.toolName==="replace"&&typeof u=="string"&&y(u))return{content:[{type:"text",text:`replace is unsupported for ${u}; use write for text, insert for keys, or delete to terminate and remove the session.`}],details:o.details,isError:!0};if(o.toolName==="delete"&&typeof u=="string"&&y(u)){let X=e.get(u);if(X===void 0)return;let Ue=e.snapshot(X);return e.delete(u).then(()=>({content:[{type:"text",text:`Deleted terminal session ${u}.`}],details:{source:u,deleted:!0,snapshot:Ue,action:"delete",input:"session",changedLines:[]},isError:!1}),M=>({content:[{type:"text",text:M instanceof Error?M.message:String(M)}],details:{source:u,deleted:!1},isError:!0}))}if(o.toolName!=="write"&&o.toolName!=="insert"||o.isError)return;let c=o.input.path;if(typeof c!="string"||!y(c))return;let d=e.get(c);if(d===void 0)return;let m=r.get(c)??e.screenRows(d);r.delete(c);let p=n.get(c)??d.outputStart+d.output.length;n.delete(c),await e.waitForOutputAfter(d,p);let f=e.snapshot(d),h=o.toolName,E=be(h,o.input),R=e.screenChangeRegion(d,m,6),q=[{type:"text",text:`Sent ${E} to ${d.source}.`}];return l.model?.input.includes("image")===!0&&q.push({type:"image",data:await W(e,c,{start:R.startRow,count:R.lines.length}),mimeType:"image/png"}),{content:q,details:{source:d.source,action:h,status:d.status,snapshot:f,input:E,changedLines:R.lines},isError:o.isError}})}a(xe,"registerTerminalResources");function nt(t){return{id:"terminal",async tryResolve(e){if(!y(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,async read(){t.markInspected(n.source);let r=t.snapshot(n);return[{type:"text",text:st(r)}]}}}}}}a(nt,"createReadResolver");function rt(t){return{id:"terminal-input",async tryResolve(e){if(!y(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,skipPostEdit:!0,async read(){return[{type:"text",text:"terminal input"}]},async write(r){let i=at(r),s=i.indexOf(F),o=i.indexOf(j);if(s>=0){t.write(n.source,i.slice(s+F.length));return}if(o>=0){t.sendKeys(n.source,i.slice(o+j.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}a(rt,"createInputResolver");function it(t,e){return!w(t.input)||!Re(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}a(it,"transformWriteInput");function ot(t){if(!w(t.input)||!Re(t.input.path))return t;if(t.input.before===!0)throw new Error("Shell keys can only be inserted after the active input position");return{...t,input:{...t.input,anchor:"end",before:!1,text:`${j}${typeof t.input.text=="string"?t.input.text:""}`}}}a(ot,"transformInsertInput");function st(t){return $(t)}a(st,"formatSnapshot");function at(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}a(at,"singleText");function we(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}a(we,"failure");function y(t){return/^shell:[a-f\d]{12}$/u.test(t)}a(y,"isShellSource");function Re(t){return typeof t=="string"&&y(t)}a(Re,"isShellSourceValue");function lt(t){if(!w(t)||!w(t.snapshot))throw new TypeError("Invalid terminal action result");let e=t.snapshot,n=t.action;if(n!=="write"&&n!=="insert"&&n!=="delete")throw new TypeError("Invalid terminal action");return{source:typeof t.source=="string"?t.source:"shell:unknown",action:n,input:typeof t.input=="string"?t.input:"",changedLines:Array.isArray(t.changedLines)?t.changedLines.filter(r=>typeof r=="string"):[],snapshot:{...typeof e.shell=="string"?{shell:e.shell}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.background=="boolean"?{background:e.background}:{},...typeof e.status=="string"?{status:e.status}:{}}}}a(lt,"terminalActionDetails");async function Te(t,e,n){if(!w(t)||typeof t.path!="string"||!y(t.path))return;let r=e.get(t.path);r!==void 0&&await r.screenReady,r!==void 0&&n.set(t.path,e.screenRows(r))}a(Te,"rememberScreen");function Se(t,e,n){if(!w(t)||typeof t.path!="string"||!y(t.path))return;let r=e.get(t.path);r!==void 0&&n.set(t.path,r.outputStart+r.output.length)}a(Se,"rememberOutputEnd");function be(t,e){if(t==="delete")return"session";let n=t==="write"?e.content:e.text,r=typeof n=="string"?n:"";return t==="write"?`text ${JSON.stringify(r)}`:`keys ${r}`}a(be,"terminalInputLabel");function ut(t,e){if(!w(t))return!1;if(e==="call")return typeof t.path=="string"&&y(t.path);let n=t.details;return w(n)&&typeof n.source=="string"&&y(n.source)}a(ut,"isTerminalRenderValue");function w(t){return typeof t=="object"&&t!==null}a(w,"isRecord");async function Ee(t,e){await re(t,{protocol:te,apiVersion:ne,id:"terminal",setup(r){r.addResolver({resolver:ct(e),priority:100}),r.describe("path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.")}})}a(Ee,"registerTerminalSearch");function ct(t){return{id:"terminal",async tryResolve(e){if(e.path===void 0||!e.path.startsWith("shell:"))return{kind:"not-handled"};let n=t.get(e.path);if(n===void 0)return{kind:"failed",error:new Error(`Unknown terminal session ${e.path}`)};let r=t.snapshot(n),i=dt(r,e);return{kind:"resolved",payload:{snapshot:r,query:e.query,matches:i}}},format(e){let n=U(e),r=n.matches.map(i=>`${n.snapshot.source}:${i.lineNumber}: ${i.lineText}`);return{content:[{type:"text",text:r.length===0?`No matches in ${n.snapshot.source}`:`${r.join(`
|
|
20
|
+
`)}
|
|
21
|
+
|
|
22
|
+
${r.length} match${r.length===1?"":"es"} in ${n.snapshot.source}`}],details:{source:n.snapshot.source,payload:n}}},renderResult(e,n,r){let i=e.details,s=G(i)?U(i.payload):U(void 0),o=A(s.snapshot,"search",JSON.stringify(s.query),s.matches.slice(-6).map(l=>`${l.lineNumber}: ${l.lineText}`),r);return new H(o,n.expanded===!0,r)}}}a(ct,"terminalSearchResolver");var Pe=12,H=class{constructor(e,n,r){this.content=e;this.expanded=n;this.theme=r}static{a(this,"TerminalSearchPanel")}render(e){let n=this.content.render(e);if(this.expanded||n.length<=Pe)return n;let r=Pe-1;return[...n.slice(0,r),this.theme.fg("muted",`\u2026 ${String(n.length-r)} visual rows omitted \xB7 ctrl+o to expand`)]}invalidate(){this.content.invalidate()}};function dt(t,e){let n=e.caseSensitive===!0?e.query:e.query.toLocaleLowerCase();if(n.length===0)return[];let r=[],i=e.limit??100;for(let[s,o]of t.output.replaceAll("\r","").split(`
|
|
23
|
+
`).entries()){let l=e.caseSensitive===!0?o:o.toLocaleLowerCase(),u=0;for(;r.length<i;){let c=l.indexOf(n,u);if(c<0)break;let d=c+n.length;(e.wholeWord!==!0||mt(l,c,d))&&r.push({source:t.source,lineNumber:s+1,startColumn:c,endColumn:d,matchedText:o.slice(c,d),lineText:o}),u=Math.max(d,c+1)}if(r.length>=i)break}return r}a(dt,"findTerminalMatches");function mt(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}a(mt,"isWordBoundary");function U(t){if(!pt(t))throw new TypeError("Invalid terminal search result");return t}a(U,"parsePayload");function pt(t){return G(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&G(t.snapshot)&&typeof t.snapshot.source=="string"}a(pt,"isTerminalSearchPayload");function G(t){return typeof t=="object"&&t!==null}a(G,"isRecord");import{spawn as ft}from"node:child_process";import{closeSync as gt,mkdirSync as ht,openSync as yt,rmSync as wt,writeSync as Tt}from"node:fs";import St from"node:os";import $e from"node:path";import{createRequire as bt}from"node:module";import{randomUUID as xt}from"node:crypto";import{stripVTControlCharacters as Rt}from"node:util";var Ce=bt(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),ve=1e6,Pt=100,Et=30,$t=2e3,k=class{static{a(this,"TerminalSessionManager")}#a;#e=new Map;#t=new Set;#r=new Set;#i=new Map;#o=!1;constructor(e=Ct){this.#a=e}onDidChange(e){return this.#t.add(e),()=>this.#t.delete(e)}onDidComplete(e){return this.#r.add(e),()=>this.#r.delete(e)}list(){return[...this.#e.values()].sort((e,n)=>n.startedAt-e.startedAt).map(e=>this.snapshot(e))}get(e){return this.#e.get(kt(e))}snapshot(e,n=Date.now()){return{id:e.id,source:e.source,command:e.command,cwd:e.cwd,shell:e.shell.displayName,shellFamily:e.shell.family,...e.process===void 0?{}:{pid:e.process.pid},background:e.background,status:e.status,...e.waitReason===void 0?{}:{waitReason:e.waitReason},...e.completionReason===void 0?{}:{completionReason:e.completionReason},lastActivityAt:e.lastActivityAt,idleMs:Math.max(0,n-e.lastActivityAt),startedAt:e.startedAt,...e.endedAt===void 0?{}:{endedAt:e.endedAt},elapsedMs:(e.endedAt??n)-e.startedAt,...e.exitCode===void 0?{}:{exitCode:e.exitCode},...e.signal===void 0?{}:{signal:e.signal},...e.error===void 0?{}:{error:e.error},output:e.output,outputStart:e.outputStart,outputEnd:e.outputStart+e.output.length,truncated:e.outputStart>0,fullOutputPath:e.fullOutputPath,cols:e.cols,rows:e.rows}}start(e){if(this.#o)throw new Error("Terminal session manager is closed");let n=this.#a();if(!/^[a-f\d]{12}$/u.test(n)||this.#e.has(n))throw new Error("Terminal session IDs must be unique 12-character hexadecimal values");let r=Ot(n);this.#i.set(n,yt(r,"a",384));let i=e.cols??Pt,s=e.rows??Et,o=At(i,s),l=a(p=>{},"resolveCompletion"),u=new Promise(p=>{l=p}),c={id:n,source:`shell:${n}`,command:e.command,background:e.background,cwd:e.cwd,shell:e.shell,startedAt:Date.now(),lastActivityAt:Date.now(),cols:i,rows:s,fullOutputPath:r,screen:o,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:u,resolveCompletion:l,completionDelivered:!1},d;try{let p=Ce("node-pty"),f={name:"xterm-256color",cols:i,rows:s,cwd:e.cwd,env:It(Lt())};d=p.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],f)}catch(p){let f={...c,status:"failed",endedAt:Date.now(),error:Dt(p)};return this.#e.set(n,f),this.#s(n),l(f),queueMicrotask(()=>this.#l(f)),f}let m={...c,process:d};return this.#e.set(n,m),d.onData(p=>this.#u(m,p)),d.onExit(({exitCode:p,signal:f})=>{b(m.status)||(m.endedAt=Date.now(),m.exitCode=p,f!==0&&(m.signal=f),m.status=m.status==="stopping"?"stopped":p===0?"completed":"failed",(p===124||p===137)&&(m.completionReason="timeout"),this.#s(m.id),m.resolveCompletion(m),this.#n(m),this.#l(m))}),this.#n(m),m}async wait(e,n){let r=this.required(e);return b(r.status)?r:n?.aborted===!0?(await this.stop(r.source,"cancelled"),r):await new Promise((i,s)=>{let o=a(()=>{this.stop(r.source,"cancelled").then(i,s)},"onAbort");n?.addEventListener("abort",o,{once:!0}),r.completion.then(l=>{n?.removeEventListener("abort",o),i(l)},s)})}async waitForForeground(e,n){let r=this.required(e);if(b(r.status))return{session:r};let i=n.interactiveDelayMs??3e3;return await new Promise(s=>{let o=!1,l,u=a(p=>{o||(p!==void 0&&b(r.status)&&(p=void 0),o=!0,clearTimeout(d),clearInterval(m),n.signal?.removeEventListener("abort",c),p!==void 0&&(r.background=!0,p!=="aborted"&&(r.waitReason=p),this.#n(r)),s({session:r,...p===void 0?{}:{reason:p}}))},"finish"),c=a(()=>u("aborted"),"onAbort"),d=setTimeout(()=>u("timeout"),n.timeoutMs),m=setInterval(()=>{if(!vt(r)){l=void 0;return}l??=Date.now(),Date.now()-l>=i&&u("interactive")},Math.min(100,Math.max(10,i/2)));n.signal?.addEventListener("abort",c,{once:!0}),n.signal?.aborted===!0&&c(),r.completion.then(()=>u())})}async waitForOutputAfter(e,n){let r=Date.now()+300,i=n,s;for(;Date.now()<r;){let o=e.outputStart+e.output.length;if(o!==i)i=o,s=Date.now(),await e.screenReady;else if(s!==void 0&&Date.now()-s>=40)return;await B(10)}await e.screenReady}screenRows(e){let n=e.screen.buffer.active;return Array.from({length:e.rows},(r,i)=>(n.getLine(n.baseY+i)?.translateToString(!0)??"").trimEnd())}screenChangeRegion(e,n,r=6){let i=this.screenRows(e),s=Math.max(1,Math.min(e.rows,r)),o=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(s/2)),l=-1;for(let d=0;d<=e.rows-s;d+=1){let m=0;for(let p=d;p<d+s;p+=1){let f=n[p]??"",h=i[p]??"",E=h.length>0&&!n.includes(h),R=f.length>0&&h.length===0;f!==h&&(E||R)&&(m+=1)}m>l&&(l=m,o=d)}let u=e.screen.buffer.active;return{lines:i.slice(o,o+s).map((d,m)=>{if(o+m!==u.cursorY)return d;let f=d.padEnd(u.cursorX," ");return`${f.slice(0,u.cursorX)}\u258C${f.slice(u.cursorX)}`}),startRow:o}}screenChangeWindow(e,n,r=6){return this.screenChangeRegion(e,n,r).lines}screenTail(e,n=e.rows){let r=e.screen.buffer.active,i=Math.max(0,r.baseY),s=[];for(let o=0;o<e.rows;o+=1){let l=r.getLine(i+o)?.translateToString(!0).trimEnd();l!==void 0&&l.length>0&&s.push(l)}return s.slice(-Math.max(0,n))}markInspected(e){let n=this.required(e);n.status==="running"&&(n.lastActivityAt=Date.now(),this.#n(n))}write(e,n){this.requiredRunning(e).process?.write(n)}sendKeys(e,n){this.requiredRunning(e).process?.write(Mt(n))}async stop(e,n="stopped"){let r=this.required(e);return b(r.status)||(r.status="stopping",this.#n(r),await Ae(r,!1),await Promise.race([r.completion.then(()=>!0),B($t).then(()=>!1)])||(await Ae(r,!0),await Promise.race([r.completion,B(1e3)])),b(r.status)||(r.status=n,r.endedAt=Date.now(),this.#s(r.id),r.resolveCompletion(r),this.#l(r)),n==="cancelled"&&(r.status="cancelled"),this.#n(r)),r}async delete(e){let n=this.required(e);n.completionDelivered=!0,await this.stop(n.source),n.screen.dispose(),this.#s(n.id),wt(n.fullOutputPath,{force:!0}),this.#e.delete(n.id),this.#n(n)}async screenLines(e){let n=this.required(e);await n.screenReady;let r=n.screen.buffer.active,i=[],s=Math.max(0,r.baseY);for(let o=s;o<s+n.rows;o+=1)i.push(r.getLine(o)?.translateToString(!0)??"");return i}cursor(e){let n=this.required(e);return{x:n.screen.buffer.active.cursorX,y:n.screen.buffer.active.cursorY}}async dispose(){if(!this.#o){this.#o=!0,await Promise.all([...this.#e.values()].filter(e=>!b(e.status)).map(e=>this.stop(e.source)));for(let e of this.#e.values())e.screen.dispose(),this.#s(e.id);this.#t.clear(),this.#r.clear()}}required(e){let n=this.get(e);if(n===void 0)throw new Error(`Unknown terminal session ${e}`);return n}requiredRunning(e){let n=this.required(e);if(n.status!=="running")throw new Error(`Terminal session ${n.source} is ${n.status}; input is unavailable`);return n}#u(e,n){e.lastActivityAt=Date.now();let r=Rt(n),i=this.#i.get(e.id);if(i!==void 0&&Tt(i,r),e.output+=r,e.output.length>ve){let s=e.output.length-ve;e.output=e.output.slice(s),e.outputStart+=s}e.screenReady=e.screenReady.then(()=>new Promise(s=>{e.screen.write(n,s)})),this.#n(e)}#s(e){let n=this.#i.get(e);n!==void 0&&(gt(n),this.#i.delete(e))}#n(e){for(let n of this.#t)n(e)}#l(e){for(let n of this.#r)n(e)}};function vt(t){if(t.status!=="running")return!1;let e=t.screen.buffer.active,n=e.getLine(e.baseY+e.cursorY)?.translateToString(!0).trimEnd()??"";return/\[[^\]\n]{1,20}(?:\/[^\]\n]{1,20})+\]\s*[:?>]?\s*$/iu.test(n)||/(?:choose|select|enter|password|confirm|continue|proceed)[^\n]{0,60}[:?]\s*$/iu.test(n)||/^(?:❯|›)\s+\S/u.test(n)}a(vt,"looksInteractive");function At(t,e){let{Terminal:n}=Ce("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}a(At,"createScreen");function Ct(){return xt().replaceAll("-","").slice(0,12)}a(Ct,"defaultSessionId");function kt(t){return t.startsWith("shell:")?t.slice(6):t}a(kt,"normalizeSessionId");function b(t){return t!=="running"&&t!=="stopping"}a(b,"isTerminalStatus");function Lt(){return process.env}a(Lt,"processEnvironment");function It(t){return{...Object.fromEntries(Object.entries(t).filter(e=>e[1]!==void 0)),PAGER:"cat",GIT_PAGER:"cat",SYSTEMD_PAGER:"cat",GH_PAGER:"cat"}}a(It,"cleanEnvironment");function Mt(t){return t.split(/[\s,]+/u).filter(Boolean).map(_t).join("")}a(Mt,"encodeTerminalKeys");function _t(t){if(/^\^[?@A-Z[\\\]^_]$/iu.test(t)){let d=t.slice(1).toUpperCase();return d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31)}let e=t.toLowerCase().split("+"),n=e.pop()??"",r=new Set(e);if([...r].some(d=>!["ctrl","control","alt","meta","shift"].includes(d)))throw new Error(`Unsupported terminal key ${t}`);let i=r.has("ctrl")||r.has("control"),s=r.has("alt")||r.has("meta"),o=r.has("shift");if(i&&n.length===1&&/[a-z@[\\\]^_?]/u.test(n)){let d=n.toUpperCase(),m=d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31);return s?`\x1B${m}`:m}let l={enter:"\r",tab:" ",escape:"\x1B",esc:"\x1B",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",delete:"\x1B[3~"};if(!i&&!s&&!o&&l[n]!==void 0)return l[n];if(s&&!i&&!o&&l[n]!==void 0)return`\x1B${l[n]}`;let c={up:"A",down:"B",right:"C",left:"D",home:"H",end:"F"}[n];if(c!==void 0)return!i&&!s&&!o?`\x1B[${c}`:`\x1B[1;${1+(o?1:0)+(s?2:0)+(i?4:0)}${c}`;if(s&&!i&&n.length===1)return`\x1B${o?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}a(_t,"encodeTerminalKey");async function Ae(t,e){let n=t.process;if(n!==void 0){if(globalThis.process.platform!=="win32")try{globalThis.process.kill(-n.pid,e?"SIGKILL":"SIGTERM");return}catch{try{n.kill(e?"SIGKILL":"SIGTERM")}catch{}return}await new Promise(r=>{let i=ft("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}a(Ae,"terminateProcessTree");function B(t){return new Promise(e=>setTimeout(e,t))}a(B,"delay");function Dt(t){return t instanceof Error?t.message:String(t)}a(Dt,"errorMessage");function Ot(t){let e=$e.join(St.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return ht(e,{recursive:!0,mode:448}),$e.join(e,`${t}.log`)}a(Ot,"createOutputLog");import Nt from"node:os";import ke from"node:path";function Le(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",s=ke.win32.basename(i).toLowerCase();return s==="cmd"||s==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:a(o=>["/d","/s","/c",o],"commandArgs")}:{executable:i,displayName:s.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:a(o=>["-NoLogo","-NoProfile","-Command",o],"commandArgs")}}let n=e.SHELL?.trim()||Nt.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=ke.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:a(i=>["-c",i],"commandArgs")}}a(Le,"resolveShellProfile");function Ie(t){switch(t.family){case"powershell":return"Write PowerShell syntax. Use PowerShell cmdlets, `$env:NAME` for environment variables, and `;` or pipelines to compose commands.";case"cmd":return"Write Command Prompt syntax. Use `%NAME%` for environment variables and `&&` to chain successful commands.";case"posix":return`Write ${t.displayName} syntax. Use POSIX-style paths, \`$NAME\` for environment variables, and \`&&\` or pipelines to compose commands.`}}a(Ie,"shellSyntaxGuidance");import Me from"node:path";import{stripVTControlCharacters as Wt}from"node:util";import{defineTool as Ft}from"@earendil-works/pi-coding-agent";import{Type as g}from"typebox";import{Text as jt}from"@earendil-works/pi-tui";var Ut=g.Object({command:g.String({minLength:1,description:"Command written in the syntax of the configured system shell"}),background:g.Optional(g.Boolean({description:"Return immediately while the terminal session continues. Defaults to false."})),timeoutSeconds:g.Optional(g.Number({minimum:.1,maximum:86400,description:"Maximum foreground wait in seconds before returning the live session as background. Defaults to 60."})),cwd:g.Optional(g.String({description:"Working directory. Relative paths resolve from the current workspace."})),cols:g.Optional(g.Integer({minimum:20,maximum:300,description:"Virtual terminal width in cells"})),rows:g.Optional(g.Integer({minimum:5,maximum:120,description:"Virtual terminal height in cells"}))},{additionalProperties:!1});function _e(t,e,n,r,i="compact"){let s=process.platform==="win32"?"powershell":"bash";t.registerTool(Ft({name:s,label:n.displayName,promptSnippet:`Execute ${n.displayName} commands in synchronous or background terminal sessions`,promptGuidelines:[`Do not use ${s} commands or scripts to edit files. Use Apply or the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`],description:`Use ${s} to execute a command in the user's configured ${n.displayName} shell (${n.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions are treated as potentially stale after two minutes and wake an idle agent for inspection. Sessions survive extension reloads and keep the same shell: source. Output uses the shared Read limits, keeps the tail, and links a complete log file when truncated. ${Ie(n)}`,parameters:Ut,async execute(o,l,u,c,d){r.bind(d);let m=l.cwd===void 0?d.cwd:Me.resolve(d.cwd,l.cwd),p=e.start({command:l.command,background:l.background??!1,cwd:m,shell:n,...l.cols===void 0?{}:{cols:l.cols},...l.rows===void 0?{}:{rows:l.rows}});if(l.background===!0&&p.status!=="failed")return await Ht(e,p,c),p.status!=="running"&&(p.completionDelivered=!0),L(e.snapshot(p));if(p.status==="failed")return L(e.snapshot(p));let f=await e.waitForForeground(p.source,{signal:u,timeoutMs:(l.timeoutSeconds??60)*1e3});return f.reason==="aborted"&&r.notifyWaitTransition(f.session),L(e.snapshot(f.session))},renderCall(o,l,u){if((u.expanded?"full":i)==="disabled")return new jt(l.fg("toolTitle",s),0,0);let d=typeof o.command=="string"?o.command:"",m=typeof o.cwd=="string"?Me.resolve(process.cwd(),o.cwd):process.cwd();return ce(d,o.background===!0,m,n,l)},renderResult(o,l,u){return me(o.details,l.expanded?"full":i,u)}}))}a(_e,"registerTerminalTools");function L(t){return{content:[{type:"text",text:$(t)}],details:t,isError:t.status==="failed"||t.status==="lost"}}a(L,"terminalResult");async function Ht(t,e,n){await new Promise(r=>{let i=!1,s,o=a(()=>{},"unsubscribe"),l=a(()=>{i||(i=!0,clearTimeout(s),o(),r())},"finish"),u=a(()=>{let c=t.snapshot(e);n?.(L(c)),(Wt(c.output).replaceAll("\r","").split(`
|
|
24
|
+
`).filter(m=>m.length>0).length>=x||c.status!=="running")&&l()},"publish");o=t.onDidChange(c=>{c.id===e.id&&u()}),s=setTimeout(l,2e3),u()})}a(Ht,"captureInitialBackgroundPreview");import{Box as De,Container as Oe}from"@earendil-works/pi-tui";var Gt=120,Bt=12e4,I=class{constructor(e,n,r=Bt){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:s},o)=>{let l=Ne(i.details)?i.details:void 0,u=new Oe;l!==void 0&&u.addChild(S(l,s,o,"stale \xB7 inspect session"));let c=new De(1,1,d=>o.bg("toolPendingBg",d));return c.addChild(u),c}),e.registerMessageRenderer("terminal-completion",(i,{expanded:s},o)=>{let l=new Oe;for(let c of qt(i.details))l.addChild(S(c,s,o));let u=new De(1,1,c=>o.bg("toolSuccessBg",c));return u.addChild(l),u}),this.#u=[n.onDidChange(i=>this.#s(i)),n.onDidComplete(i=>{this.#l(i.id),i.background&&this.#c(i)})]}static{a(this,"TerminalUi")}#a=new Map;#e;#t=new Map;#r=new Set;#i;#o=!1;#u;bind(e){this.#i=e}onAgentSettled(e){this.#i=e;for(let n of[...this.#r]){this.#r.delete(n);let r=this.manager.get(n);r!==void 0&&this.#s(r,!0)}}notifyWaitTransition(e){let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-wait-transition",display:!1,content:`Terminal wait ended; ${n.source} is still running in background. Read it to inspect output, then use write or insert to send input.`,details:n},{triggerTurn:!0,deliverAs:"steer"})}dispose(){this.#o=!0,this.#e!==void 0&&clearTimeout(this.#e),this.#e=void 0,this.#a.clear();for(let e of this.#t.values())clearTimeout(e);this.#t.clear(),this.#r.clear(),this.#i=void 0;for(let e of this.#u)e()}#s(e,n=!1){if(this.#l(e.id),this.#o||!e.background||e.status!=="running")return;let r=this.manager.snapshot(e),i=Math.max(0,this.staleIntervalMs-r.idleMs);if(n&&i===0){this.#n(e);return}this.#t.set(e.id,setTimeout(()=>this.#n(e),i))}#n(e){if(this.#t.delete(e.id),this.#o||e.status!=="running"||!e.background)return;if(this.#i?.isIdle()!==!0){this.#r.add(e.id);return}let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-stale",display:!0,content:Yt(n),details:n},{triggerTurn:!0,deliverAs:"followUp"}),this.#t.set(e.id,setTimeout(()=>this.#n(e),this.staleIntervalMs))}#l(e){let n=this.#t.get(e);n!==void 0&&clearTimeout(n),this.#t.delete(e),this.#r.delete(e)}#c(e){this.#o||e.completionDelivered||(this.#a.set(e.id,e),this.#e===void 0&&(this.#e=setTimeout(()=>{this.#e=void 0;let n=[...this.#a.values()].filter(i=>!i.completionDelivered);if(this.#a.clear(),this.#o||n.length===0)return;for(let i of n)i.completionDelivered=!0;let r=n.map(i=>this.manager.snapshot(i));this.pi.sendMessage({customType:"terminal-completion",display:!0,content:Xt(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"})},Gt)))}};function qt(t){return!Fe(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(Ne)}a(qt,"completionSnapshots");function Ne(t){return Fe(t)&&typeof t.id=="string"&&typeof t.source=="string"&&typeof t.command=="string"&&typeof t.cwd=="string"&&typeof t.shell=="string"&&typeof t.background=="boolean"&&typeof t.status=="string"&&typeof t.startedAt=="number"&&typeof t.elapsedMs=="number"&&typeof t.output=="string"}a(Ne,"isTerminalSessionSnapshot");function Xt(t){return`${t.length===1?"Background terminal completed:":"Background terminals completed:"}
|
|
25
|
+
${t.map(n=>{let r=n.exitCode===void 0?"":`, exit ${n.exitCode}`,i=n.completionReason===void 0?"":`, reason ${n.completionReason}`,s=n.output.trimEnd().slice(-2e3);return`- ${n.source}: ${n.status}${r}${i}, ${We(n.elapsedMs)}
|
|
26
|
+
${s||"(no output)"}`}).join(`
|
|
27
|
+
`)}`}a(Xt,"formatCompletionMessage");function Yt(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${We(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
28
|
+
${e||"(no output)"}`}a(Yt,"formatStaleMessage");function We(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(We,"formatElapsed");function Fe(t){return typeof t=="object"&&t!==null}a(Fe,"isRecord");function je(t){return t==="full"||t==="disabled"?t:"compact"}a(je,"toolPresentation");async function Vt(t,e){V(t,[await Y({id:"terminal",description:"Foreground and background commands, shell resources, and processes",triggers:[{tool:"bash"},...["read","write","insert","delete"].map(o=>({tool:o,resourcePrefixes:["shell:","process:"]}))]})]);let n=se("terminal")??new k,r=Le(),i=new I(t,n),s=ie(t).add(ge(n));await Promise.all([xe(t,n),Ee(t,n)]),_e(t,n,r,i,je(e?.preferences["ui.terminal"])),t.on("session_start",(o,l)=>i.bind(l)),t.on("agent_settled",(o,l)=>i.onAgentSettled(l)),t.on("session_shutdown",async o=>{if(i.dispose(),s(),o.reason!=="quit"){oe("terminal",n);return}ae("terminal",n),await n.dispose()})}a(Vt,"registerTerminal");export{Vt as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import"./chunk-3YK4XMWB.js";import{a as J,b as V,c as z,d as U,f as q}from"./chunk-T6LX2RX5.js";import{d as L,e as h}from"./chunk-M5MJP7Z2.js";import{a as E}from"./chunk-WZI4YC2O.js";import{d as N}from"./chunk-N34ATN52.js";import{a as O}from"./chunk-ZC65Z3CK.js";import{a as _,b as F,c as M}from"./chunk-JMVDFOTQ.js";import{a as d}from"./chunk-EI7MMDWY.js";import{mkdir as ie,readFile as B,writeFile as re}from"node:fs/promises";async function G(n,t){await ie(L(n),{recursive:!0});let e=[],o=t.filter(s=>s.recipe.formatter!==void 0),i=t.filter(s=>s.recipe.linter!==void 0),r=t.filter(s=>s.recipe.lsp!==void 0);if(o.length>0){let s=h(n,"formatters"),c=await S(s,{version:1,formatters:{}}),u=P(c,"formatters");for(let l of o)u[l.recipe.id]??=l.recipe.formatter;await R(s,c)&&e.push(s)}if(i.length>0){let s=h(n,"linters"),c=await S(s,{version:1,linters:{}}),u=P(c,"linters");for(let l of i)u[l.recipe.id]??=l.recipe.linter;await R(s,c)&&e.push(s)}if(r.length>0){let s=h(n,"lsp-servers"),c=await S(s,{version:1,servers:{}}),u=P(c,"servers");for(let l of r){let a=O(l.recipe.lsp);u[l.recipe.id]??={command:a.command,transport:"stdio",rootMarkers:a.rootMarkers,...a.initializationOptions!==void 0&&{initializationOptions:a.initializationOptions},...a.settings!==void 0&&{settings:a.settings},...a.requireRootMarker!==void 0&&{requireRootMarker:a.requireRootMarker},languages:Object.fromEntries(Object.entries(a.languageIds).map(([p,f])=>[p,{extensions:f,...a.fileNames?.[p]&&{fileNames:a.fileNames[p]}}])),capabilities:["diagnostics"]}}await R(s,c)&&e.push(s)}return e}d(G,"writeSuggestedConfigs");async function S(n,t){try{let e=JSON.parse(await B(n,"utf8"));if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must contain an object`);return e}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return t;throw e}}d(S,"readObject");function P(n,t){let e=n[t];if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} must be an object`);return e}d(P,"objectMember");async function R(n,t){let e=`${JSON.stringify(t,null,2)}
|
|
2
|
+
`;return await B(n,"utf8").catch(()=>{})===e?!1:(await re(n,e,"utf8"),!0)}d(R,"writeJson");var C=class{static{d(this,"DoctorCore")}plugins=new Map;languages=[];recipes=[];setupChecks=[];checks=[];queue=Promise.resolve();registerPlugin(t){let e=this.plugins.get(t.id);if(e!==void 0)return e;let o=this.queue.then(async()=>{let i=!0,r=[],s=[],c=[],u=[],l={addLanguage:d(a=>{b(a,r,t.id,"language",()=>i)},"addLanguage"),addToolRecipe:d(a=>{b(a,s,t.id,"tool recipe",()=>i)},"addToolRecipe"),addSetupCheck:d(a=>{b(a,c,t.id,"setup check",()=>i)},"addSetupCheck"),addCheck:d(a=>{b(a,u,t.id,"check",()=>i)},"addCheck")};try{await t.setup(l)}finally{i=!1}W(this.languages,r,"language"),W(this.recipes,s,"tool recipe"),this.languages.push(...r),this.recipes.push(...s),this.setupChecks.push(...c),this.checks.push(...u)});return this.plugins.set(t.id,o),this.queue=o.catch(()=>{}),o.catch(()=>{this.plugins.delete(t.id)}),o}async waitForPlugins(){await Promise.all(this.plugins.values())}snapshot(){return{languages:[...this.languages],recipes:[...this.recipes],setupChecks:[...this.setupChecks],checks:[...this.checks]}}};async function H(n,t){let e=[],o=[];for(let i of n.setupChecks)try{let r=await i.value.inspect(t);e.push(...(r.selections??[]).map(s=>({...s,pluginId:i.pluginId}))),o.push(...(r.actions??[]).map(s=>({...s,pluginId:i.pluginId})))}catch{}return{selections:e,actions:o}}d(H,"runContributedSetupChecks");async function X(n,t){let e=[];for(let o of n.checks)try{e.push({pluginId:o.pluginId,title:o.value.title,findings:await o.value.run(t)})}catch(i){e.push({pluginId:o.pluginId,title:o.value.title,findings:[{status:"fail",message:i instanceof Error?i.message:String(i)}]})}return e}d(X,"runContributedChecks");function W(n,t,e){for(let o of t){let i=n.find(r=>r.value.id===o.value.id)?.pluginId;if(i!==void 0)throw new Error(`${e} ${o.value.id} is already owned by doctor plugin ${i}`)}}d(W,"assertAvailable");function b(n,t,e,o,i){if(!i())throw new Error(`Doctor plugin ${e} setup is complete`);if(!/^[a-z0-9][a-z0-9.-]*$/u.test(n.id))throw new Error(`Invalid ${o} ID: ${n.id}`);if(t.some(r=>r.value.id===n.id))throw new Error(`Doctor plugin ${e} registered ${o} ${n.id} twice`);t.push({pluginId:e,value:n})}d(b,"add");import fe from"node:path";import{readFile as se}from"node:fs/promises";async function Y(n,t,e,o=process.env){let i=await E(n,e.map(c=>c.value)),r=await ce(n),s=[];for(let c of e){let u=c.value;if(u.languages.every(v=>!t.has(v)))continue;let l=[],a=1,p=i.get(u.id),f=p?.config;f!==void 0&&(a+=6,l.push(`project config: ${f}`)),r.has(`${u.kind}:${u.id}`)&&(a+=6,l.push("Pi Agent IDE config"));let w=p?.dependency;w!==void 0&&(a+=4,l.push(`project dependency: ${w}`));let m=await ae(n,u.executables,o);m!==void 0&&(a+=3,l.push(`executable: ${m}`)),s.push({pluginId:c.pluginId,recipe:u,score:a,evidence:l,...m&&{executable:m}})}return s.sort((c,u)=>u.score-c.score||c.recipe.id.localeCompare(u.recipe.id))}d(Y,"discoverRecipeCandidates");function K(n,t,e=[]){let o=new Map,i=new Map(e.map(r=>[`${r.kind}:${r.languageId}`,r.toolId]));for(let r of t)for(let s of["formatter","linter","lsp"]){let c=i.get(`${s}:${r}`),u=c===void 0?4:7,l=n.filter(p=>p.recipe.kind===s&&p.recipe.languages.includes(r)&&p.executable!==void 0&&p.recipe.id!==c&&p.score>=u),a=l[0];a!==void 0&&(l.filter(p=>p.score===a.score).length>1||o.set(`${a.recipe.kind}:${a.recipe.id}`,a))}return[...o.values()]}d(K,"selectSuggestedRecipes");async function ae(n,t,e){for(let o of t)if(await N(o,n,e))return o}d(ae,"firstExecutable");async function ce(n){let t=new Set;for(let[e,o,i]of[["formatters","formatters","formatter"],["linters","linters","linter"],["lsp-servers","servers","lsp"]])try{let r=JSON.parse(await se(h(n,e),"utf8"));if(typeof r!="object"||r===null||Array.isArray(r))continue;let c=r[o];if(typeof c=="object"&&c!==null&&!Array.isArray(c))for(let u of Object.keys(c))t.add(`${i}:${u}`)}catch{}return t}d(ce,"managedRecipeIds");import{execFile as de}from"node:child_process";import{readdir as ue}from"node:fs/promises";import y from"node:path";import{promisify as le}from"node:util";var pe=le(de),ge=new Set([".git",".hg",".svn","node_modules","vendor","build","dist","coverage",".cache",".next","target"]);async function Q(n,t){t?.throwIfAborted();try{let o=(await pe("git",["ls-files","--cached","--others","--exclude-standard","-z"],{cwd:n,encoding:"utf8",maxBuffer:16777216,signal:t})).stdout.split("\0").filter(Boolean).map(i=>y.resolve(n,i)).filter(i=>!ee(i));return t?.throwIfAborted(),o.length>0?o:await k(n,t)}catch{return t?.throwIfAborted(),k(n,t)}}d(Q,"collectProjectFiles");function Z(n,t,e=process.platform){let o=new Map,i=e==="win32"?y.win32:y;for(let r of t){let s=new Set(r.extensions.map(a=>a.toLowerCase())),c=d(a=>e==="win32"?a.toLowerCase():a,"normalizeName"),u=new Set(r.fileNames?.map(c)),l=n.filter(a=>!a.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")&&(s.has(i.extname(a).toLowerCase())||u.has(c(i.basename(a)))));l.length>0&&o.set(r.id,l)}return o}d(Z,"detectProjectLanguages");async function k(n,t){t?.throwIfAborted();let e=[];for(let o of await ue(n,{withFileTypes:!0})){if(o.isDirectory()&&ge.has(o.name))continue;let i=y.join(n,o.name);ee(i)||(o.isDirectory()?e.push(...await k(i,t)):o.isFile()&&e.push(i))}return e}d(k,"walk");function ee(n){return n.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")}d(ee,"isManagedIdeConfig");async function $(n,t,e=process.env,o){o?.throwIfAborted();let i=await Q(t,o);o?.throwIfAborted();let r=Z(i,n.languages.map(p=>p.value)),s=new Set(r.keys()),c={cwd:t,files:i,detectedLanguageIds:s,detectedLanguages:r,env:e},[u,l]=await Promise.all([Y(t,s,n.recipes,e),H(n,c)]),a=new Map;for(let p of s)for(let f of["formatter","linter","lsp"]){if(l.selections.some(g=>g.languageId===p&&g.kind===f))continue;let w=u.filter(g=>g.recipe.kind===f&&g.recipe.languages.includes(p)),m=d(g=>g.score-(g.executable===void 0?0:3),"nativeScore"),v=Math.max(1,...w.map(m));for(let g of w){if(g.executable!==void 0||m(g)!==v||v<=1)continue;let T=`${f}-${g.recipe.id}-unavailable`;a.set(T,{id:T,pluginId:g.pluginId,message:`Native project setup selects ${g.recipe.id}, but its executable is unavailable. Install ${g.recipe.executables.join(" or ")} and run Doctor again.`})}}return{cwd:t,files:i,detectedLanguages:r,candidates:u,selections:l.selections,actions:[...l.actions,...a.values()],suggestions:K(u,s,l.selections)}}d($,"inspectDoctorSetup");async function I(n,t,e=process.env){let o=await $(n,t,e),i=new Set(o.detectedLanguages.keys()),r={cwd:t,files:o.files,detectedLanguageIds:i,detectedLanguages:o.detectedLanguages,env:e},s=await X(n,r),c=[{status:"pass",message:`Project: ${t}`},o.files.length>0?{status:"pass",message:`${o.files.length} project files inspected`}:{status:"warn",message:"No project files found"},i.size>0?{status:"pass",message:`Detected: ${[...i].join(", ")}`}:{status:"warn",message:"No registered project languages detected"}];return{...o,sections:[{title:"Project",pluginId:"doctor",findings:c},...s]}}d(I,"runDoctor");function D(n){let t=["Pi Agent IDE doctor",""];for(let e of n.sections){t.push(`${e.title} (${e.pluginId})`);for(let o of e.findings)t.push(` ${o.status.toUpperCase().padEnd(4)} ${o.message}`),o.detail!==void 0&&t.push(` \`${o.detail}\``);t.push("")}if(n.actions.length>0){t.push("Setup needs attention");for(let e of n.actions)t.push(` ${e.message} [${e.pluginId}]`);t.push("")}if(n.suggestions.length>0){t.push("Suggested configuration");for(let e of n.suggestions){let o=e.evidence.length>0?` \u2014 ${e.evidence.join(", ")}`:"";t.push(` ${e.recipe.kind.padEnd(9)} ${e.recipe.id} [${e.pluginId}]${o}`)}t.push("")}return t.join(`
|
|
3
|
+
`).trimEnd()}d(D,"formatDoctorReport");function j(n){return n.actions.length>0||n.suggestions.length>0||n.sections.some(t=>t.findings.some(e=>e.status==="fail"))}d(j,"doctorNeedsWork");function te(n){let t=n.candidates.map(e=>({owner:e.pluginId,id:e.recipe.id,kind:e.recipe.kind,languages:e.recipe.languages,evidence:e.evidence,documentation:e.recipe.documentation}));return["Finish configuring Pi Agent IDE for this project.","Preserve existing formatter, linter, compiler, and style rules. Do not invent or replace native project settings.","Do not install packages, write credentials, or change source files without the user's normal confirmation.","Pi Agent IDE project configs live in .pi/pi-agent-ide/.","Use only the relevant plugin contributions listed below; each owner remains responsible for its own scope.","",D(n),"","Relevant registered recipes:",JSON.stringify(t,null,2),"",`Project root: ${fe.resolve(n.cwd)}`].join(`
|
|
4
|
+
`)}d(te,"buildDoctorAgentPrompt");import{createHash as me}from"node:crypto";var he="doctor",x=3;function ne(n,t){let e=_(n,ye(t));e!==void 0&&e.catch(()=>{})}d(ne,"registerDoctorTipProvider");function ye(n){return{protocol:F,apiVersion:M,id:he,async getTip(t){let e=await n(t),o=we(e);if(o.length===0)return;let i=o.slice(0,x).map(r=>`\u2022 ${r.message}`);return o.length>x&&i.push(`\u2022 ${o.length-x} more`),{id:`doctor-setup-${De(o)}`,title:o.length===1?"Project setup needs attention":`${o.length} project setup items`,body:[...i,"Run /pi-agent-ide-doctor"].join(`
|
|
5
|
+
`)}}}}d(ye,"createDoctorTipProvider");function we(n){let t=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),e=n.suggestions.map(o=>{let i=o.recipe.languages.filter(s=>n.detectedLanguages.has(s)).join(", "),r={debugger:"debugging",formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${i} ${r}`}});return[...t,...e].sort((o,i)=>o.id.localeCompare(i.id))}d(we,"setupItems");function De(n){return me("sha256").update(n.map(t=>`${t.id}\0${t.message}`).join("\0")).digest("hex").slice(0,12)}d(De,"fingerprint");async function oe(n){let t=new C;ne(n,async i=>(await t.waitForPlugins(),$(t.snapshot(),i.cwd,process.env,i.signal)));let e,o=n.events.on(U,i=>{if(!q(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",o),n.registerCommand("pi-agent-ide-doctor",{description:"Check and configure Pi Agent IDE for this project",handler:d(async(i,r)=>{await t.waitForPlugins();let s=await I(t.snapshot(),r.cwd);A(n,D(s));let c=new Set(i.trim().split(/\s+/u).filter(Boolean));if(s.suggestions.length>0&&!c.has("--no-apply")&&(c.has("--apply")||r.hasUI&&await r.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let a=await G(r.cwd,s.suggestions),p=a.length===0?"Pi Agent IDE configs are already up to date":`Updated ${a.length} Pi Agent IDE config ${a.length===1?"file":"files"}`;r.ui.notify(p,"info"),s=await I(t.snapshot(),r.cwd),A(n,D(s))}if(!j(s)&&!c.has("--agent"))return;(c.has("--agent")||r.hasUI&&await r.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(e=r.cwd,n.sendUserMessage(te(s)))},"handler")}),n.on("agent_end",async(i,r)=>{let s=e;if(s===void 0)return;e=void 0;let c=await I(t.snapshot(),s,process.env);A(n,`Doctor recheck after agent setup
|
|
6
|
+
|
|
7
|
+
${D(c)}`),j(c)?r.ui.notify("Pi Agent IDE setup still needs attention","warning"):r.ui.notify("Pi Agent IDE setup is ready","info")}),n.events.emit(z,{protocol:J,apiVersion:1}),await t.waitForPlugins()}d(oe,"registerDoctor");function A(n,t){n.sendMessage({customType:"pi-agent-ide-doctor",content:t,display:!0},{triggerTurn:!1})}d(A,"sendReport");export{oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as s}from"./chunk-S3ZPXWX7.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";import{Type as n}from"typebox";var l=n.Object({path:n.Optional(n.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:n.Optional(n.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or a SEARCH selection, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:n.Optional(n.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:n.Optional(n.Array(n.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))});var a=e.Function([],e.Unknown()),u=e.Object({resolver:e.Unknown(),matchesCall:e.Optional(a),renderCall:e.Optional(a),priority:e.Optional(e.Number()),renderResult:e.Optional(a),preserveTruncatedOutput:e.Optional(e.Boolean())}),R=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),c=e.Object({id:e.String({pattern:"\\S"}),priority:e.Optional(e.Number()),resolve:a}),y=e.Object({view:e.String({pattern:"\\S"}),includes:e.Optional(e.Array(e.String({pattern:"\\S"}))),presenter:e.Object({id:e.String(),present:a}),priority:e.Optional(e.Number())}),p=e.Object({resolvedBy:e.String({pattern:"\\S"}),contentKind:e.Union([e.Literal("text"),e.Literal("any")])}),g=e.Union([e.Object({stage:e.Literal("pre-read"),handler:a}),e.Object({stage:e.Literal("read"),when:p,handler:a}),e.Object({stage:e.Literal("post-read"),handler:a})]);function h(r){if(!i.Check(R,r))return!1;let t=r,d=t.resolver;return typeof d.id=="string"&&d.id.length>0&&typeof d.tryResolve=="function"&&(!("priority"in t)||typeof t.priority=="number")}o(h,"isTextTargetResolverRegistration");function O(r){if(!i.Check(u,r))return!1;let t=r;return s(t.resolver)?t.resolver.id!=="any"&&(!("priority"in t)||typeof t.priority=="number")&&(!("matchesCall"in t)||typeof t.matchesCall=="function")&&(!("renderCall"in t)||typeof t.renderCall=="function")&&"matchesCall"in t=="renderCall"in t&&(!("renderResult"in t)||typeof t.renderResult=="function"):!1}o(O,"isResourceResolverRegistration");function S(r){return i.Check(g,r)}o(S,"isReadHandlerRegistration");function C(r){return i.Check(y,r)}o(C,"isReadViewRegistration");function k(r){return i.Check(c,r)}o(k,"isFragmentResolverRegistration");function P(r){return m(r)?r.kind==="not-handled"?!0:r.kind==="failed"?typeof r.message=="string"&&r.message.length>0:r.kind==="resolved"&&typeof r.originLine=="number":!1}o(P,"isReadFragmentResolution");function m(r){return typeof r=="object"&&r!==null}o(m,"isRecord");export{l as a,h as b,O as c,S as d,C as e,k as f,P as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p,e as f,k as g}from"./chunk-O6LE42GK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as m}from"node:async_hooks";var c=new m,l=new m;function E(t){let e=l.getStore();e?e.push(t):t()}o(E,"afterPostEditScope");async function T(t){if(l.getStore())return t();let e=[];try{return await l.run(e,t)}finally{for(let r of e)r()}}o(T,"collectPostEditNotifications");function b(t,e){let r=c.getStore();return r?(r.set(t,e),!0):!1}o(b,"deferPostEdit");function h(t){return c.getStore()?.has(t)??!1}o(h,"hasDeferredPostEdit");function v(t){c.getStore()?.delete(t)}o(v,"forgetDeferredPostEdit");function k(){let t=new Map;return{run(e){return c.run(t,e)},forget(e){t.delete(e)},async finish(e){let r=[...t.values()];t.clear();let d=[],i=[];if(await T(async()=>{for(let a of r)try{let s=await a();d.push(s),e?.(s)}catch(s){i.push(s)}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(a=>a instanceof Error?a.message:String(a)).join("; ")}`);return d}}}o(k,"createPostEditScope");import{Type as n}from"typebox";import{Value as u}from"typebox/value";var w=`${p}/post-edit/register`;function M(t){return u.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o(M,"isFormattingContribution");function _(t){return u.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(_,"isDiffStatusContribution");var x=n.Function([],n.Unknown()),y=n.Object({id:n.String({minLength:1}),handler:x}),P=n.Object({registration:y,accept:x});function S(t){return u.Check(y,t)}o(S,"isTextPostEditHandlerRegistration");function j(t){return u.Check(P,t)}o(j,"isTextPostEditHandlerRegistrationRequest");function I(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(I,"isTextMutationResultContributionData");function F(t,e){if(!S(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,d=o(()=>{let a={registration:e,accept(s){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=s}};return t.events.emit(w,a),r!==void 0},"announce"),i=o(()=>{},"unsubscribeReady");i=t.events.on(f,a=>{if(!g(a))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!d())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");i()}),t.on("session_shutdown",()=>{i(),r?.()}),d()&&i()}o(F,"connectTextEditorPostEditHandler");export{E as a,T as b,b as c,h as d,v as e,k as f,w as g,M as h,_ as i,S as j,j as k,I as l,F as m};
|