pi-agent-ide 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +79 -53
- package/assets/social-preview.png +0 -0
- package/dist/chunk-4KUFOHWP.js +2 -0
- package/dist/chunk-4LDOV7QS.js +28 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/{chunk-HSM6R7IB.js → chunk-I6Y3W4X6.js} +13 -13
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
- package/dist/chunk-T7I2VX3J.js +1 -0
- package/dist/chunk-VCTK4JSN.js +3 -0
- package/dist/chunk-W7CASEO3.js +1 -0
- package/dist/chunk-YEQOQMU7.js +5 -0
- package/dist/chunk-YT42LKFV.js +16 -0
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -0
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -2
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +2 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -1
- package/dist/entry-28.js +1 -12
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +12 -1
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -4
- package/dist/entry-34.js +1 -9
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +4 -1
- package/dist/entry-37.js +9 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -18
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +17 -1
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +1 -7
- package/dist/entry-48.js +1 -11
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +6 -1
- package/dist/entry-51.js +11 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -0
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -0
- package/dist/entry-60.js +0 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +0 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -0
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -0
- package/dist/entry-69.js +0 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -259
- package/dist/entry-73.js +1 -30
- package/dist/entry-74.js +1 -2
- package/dist/entry-75.js +315 -1
- package/dist/entry-76.js +30 -1
- package/dist/entry-77.js +2 -3
- package/dist/entry-78.js +1 -3
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +3 -1
- package/dist/entry-81.js +3 -1
- package/dist/entry-82.js +1 -0
- package/dist/entry-83.js +1 -0
- package/dist/entry-84.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/pi-agent-ide.js +3 -3
- package/docs/agent-guides/apply.md +333 -0
- package/docs/agent-guides/debugger.md +5 -0
- package/docs/agent-guides/diagnostics.md +5 -0
- package/docs/agent-guides/editing.md +44 -0
- package/docs/agent-guides/git-changes.md +5 -0
- package/docs/agent-guides/json-reading.md +41 -0
- package/docs/agent-guides/read-resources.md +44 -0
- package/docs/agent-guides/search-code.md +29 -0
- package/docs/agent-guides/terminal.md +7 -0
- package/docs/agent-guides/vision.md +5 -0
- package/docs/configuration.md +6 -14
- package/docs/research/apply-read-latency.md +219 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
- package/node_modules/pi-agent-documentation/package.json +15 -0
- package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
- package/node_modules/pi-agent-documentation/src/index.ts +69 -0
- package/node_modules/pi-agent-filesystem/index.ts +0 -4
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
- package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
- package/node_modules/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +11 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-changes/index.ts +8 -0
- package/node_modules/pi-agent-ide-changes/package.json +9 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/node_modules/pi-agent-ide-lint/index.ts +1 -1
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +17 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-read/package.json +12 -11
- package/node_modules/pi-agent-read/runtime/entry-42.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
- package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +19 -12
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +8 -7
- package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-50.js +2 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-54.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/node_modules/pi-agent-text-editor/index.ts +15 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-72.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-76.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-84.js +2 -0
- package/package.json +108 -44
- package/src/api/documentation.ts +2 -0
- package/src/composite/builtin-extensions.ts +7 -0
- package/src/composite/extensions-config.ts +6 -0
- package/src/composite/module-labels.ts +5 -0
- package/src/composite/module-settings-store.ts +3 -0
- package/src/composite/module-settings.ts +39 -5
- package/src/composite/preferences.ts +37 -0
- package/src/composite/presentation.ts +14 -0
- package/src/composite/presets.ts +57 -0
- package/src/documentation/extension.ts +295 -0
- package/src/documentation/registry.ts +98 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-84.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -11
- package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-43.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
- package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +19 -12
- package/src/extensions/pi-agent-search/package.json +8 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
- package/src/extensions/pi-agent-text-editor/index.ts +15 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-54.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/src/pi-agent-ide.ts +7 -10
- package/src/plugins/pi-agent-ide-ast/package.json +11 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
- package/src/plugins/pi-agent-ide-changes/package.json +9 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/src/plugins/pi-agent-ide-debugger/index.ts +12 -4
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +17 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +1 -4
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +7 -4
- package/src/plugins/pi-agent-ide-vision/index.ts +8 -6
- package/dist/chunk-22CLOM2D.js +0 -1
- package/dist/chunk-3XJ3KDPZ.js +0 -16
- package/dist/chunk-526E364R.js +0 -3
- package/dist/chunk-DDKHZZDO.js +0 -5
- package/dist/chunk-EJ5OACQM.js +0 -1
- package/dist/chunk-PCZH7GOX.js +0 -26
- package/dist/chunk-SQ7ZTGOP.js +0 -2
- package/dist/entry-18.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-23.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-30.js +0 -2
- package/node_modules/pi-agent-ide-languages/runtime/entry-32.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-35.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-36.js +0 -1
- package/node_modules/pi-agent-pdf/runtime/entry-37.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-48.js +0 -2
- package/node_modules/pi-agent-text/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-76.js +0 -1
- package/node_modules/pi-agent-web-html/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +0 -2
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-30.js +0 -2
- package/src/plugins/pi-agent-ide-languages/runtime/entry-32.js +0 -2
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search-text}/runtime/entry-51.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-52.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-80.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-81.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-81.js +0 -0
- /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-constant → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-51.js +0 -0
- /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-52.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
|
@@ -115,9 +115,6 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
115
115
|
api.describe(
|
|
116
116
|
"symbol:<file>#<selector> — declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> — top-level declarations, references and calls; members include selectors. graph:<file>#<selector> — references and incoming/outgoing calls for that declaration or member.",
|
|
117
117
|
);
|
|
118
|
-
api.addPromptGuideline(
|
|
119
|
-
"Use semantic code views first when exploring code supported by a configured language server. Use `symbols:<query>` to locate named declaration and reference candidates when the file is unknown. Use `graph:<file>` to map the declarations and relationships in a known file before reading implementation bodies. Use `graph:<file>#<selector>` to inspect references and incoming/outgoing calls for one declaration. Use `symbol:<file>#<selector>` to read that declaration’s source. Use text search for exact text, non-code files, or when semantic views are unavailable.",
|
|
120
|
-
);
|
|
121
118
|
},
|
|
122
119
|
} satisfies ReadPlugin;
|
|
123
120
|
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lsp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"cross-spawn": "^7.0.6",
|
|
7
|
-
"pi-agent-doctor": "0.6.
|
|
8
|
-
"pi-agent-invariant": "0.6.
|
|
9
|
-
"pi-agent-read": "0.6.
|
|
10
|
-
"pi-agent-resource": "0.6.
|
|
11
|
-
"pi-agent-search": "0.6.
|
|
12
|
-
"pi-agent-text": "0.6.
|
|
13
|
-
"pi-agent-text-editor": "0.6.
|
|
7
|
+
"pi-agent-doctor": "0.6.1",
|
|
8
|
+
"pi-agent-invariant": "0.6.1",
|
|
9
|
+
"pi-agent-read": "0.6.1",
|
|
10
|
+
"pi-agent-resource": "0.6.1",
|
|
11
|
+
"pi-agent-search": "0.6.1",
|
|
12
|
+
"pi-agent-text": "0.6.1",
|
|
13
|
+
"pi-agent-text-editor": "0.6.1",
|
|
14
14
|
"vscode-jsonrpc": "^9.0.0",
|
|
15
15
|
"vscode-uri": "^3.1.0"
|
|
16
16
|
},
|
|
17
17
|
"pi": {
|
|
18
18
|
"extensions": [
|
|
19
|
-
"./runtime/entry-
|
|
19
|
+
"./runtime/entry-37.js"
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@earendil-works/pi-coding-agent": "*",
|
|
24
|
-
"pi-agent-ide": "0.6.
|
|
24
|
+
"pi-agent-ide": "0.6.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependenciesMeta": {
|
|
27
27
|
"pi-agent-ide": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
|
|
2
3
|
import {
|
|
3
4
|
forgetReloadResource,
|
|
4
5
|
retainReloadResource,
|
|
@@ -12,9 +13,27 @@ import { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/s
|
|
|
12
13
|
import { resolveShellProfile } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
|
|
13
14
|
import { registerTerminalTools } from "#src/plugins/pi-agent-ide-terminal/src/tools.js";
|
|
14
15
|
import { TerminalUi } from "#src/plugins/pi-agent-ide-terminal/src/ui.js";
|
|
16
|
+
import { toolPresentation } from "#src/composite/presentation.js";
|
|
17
|
+
import type { BuiltinExtensionContext } from "#src/composite/selection.js";
|
|
15
18
|
|
|
16
19
|
/** Register the platform-aware terminal runner and shell session resources. */
|
|
17
|
-
export default async function registerTerminal(
|
|
20
|
+
export default async function registerTerminal(
|
|
21
|
+
pi: ExtensionAPI,
|
|
22
|
+
context?: BuiltinExtensionContext,
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
connectAgentDocumentation(pi, [
|
|
25
|
+
await loadPackagedAgentGuide({
|
|
26
|
+
id: "terminal",
|
|
27
|
+
description: "Foreground and background commands, shell resources, and processes",
|
|
28
|
+
triggers: [
|
|
29
|
+
{ tool: "bash" },
|
|
30
|
+
...["read", "write", "insert", "delete"].map((tool) => ({
|
|
31
|
+
tool,
|
|
32
|
+
resourcePrefixes: ["shell:", "process:"],
|
|
33
|
+
})),
|
|
34
|
+
],
|
|
35
|
+
}),
|
|
36
|
+
]);
|
|
18
37
|
const manager =
|
|
19
38
|
(takeReloadResource("terminal") as TerminalSessionManager | undefined) ??
|
|
20
39
|
new TerminalSessionManager();
|
|
@@ -23,7 +42,13 @@ export default async function registerTerminal(pi: ExtensionAPI): Promise<void>
|
|
|
23
42
|
const removeProcessProvider = agentIdeProcessRegistry(pi).add(terminalProcessProvider(manager));
|
|
24
43
|
|
|
25
44
|
await Promise.all([registerTerminalResources(pi, manager), registerTerminalSearch(pi, manager)]);
|
|
26
|
-
registerTerminalTools(
|
|
45
|
+
registerTerminalTools(
|
|
46
|
+
pi,
|
|
47
|
+
manager,
|
|
48
|
+
profile,
|
|
49
|
+
ui,
|
|
50
|
+
toolPresentation(context?.preferences["ui.terminal"]),
|
|
51
|
+
);
|
|
27
52
|
|
|
28
53
|
pi.on("session_start", (_event, context) => ui.bind(context));
|
|
29
54
|
pi.on("agent_settled", (_event, context) => ui.onAgentSettled(context));
|
|
@@ -72,10 +72,35 @@ export function renderTerminalResult(
|
|
|
72
72
|
/** Render the result beneath the already-visible run prompt without repeating the command. */
|
|
73
73
|
export function renderRunResult(
|
|
74
74
|
snapshot: Partial<TerminalSessionSnapshot>,
|
|
75
|
-
|
|
75
|
+
presentation: "full" | "compact" | "disabled" | boolean,
|
|
76
76
|
theme: TerminalTheme,
|
|
77
77
|
): Component {
|
|
78
|
-
if (
|
|
78
|
+
if (presentation === true) presentation = "full";
|
|
79
|
+
else if (presentation === false) presentation = "compact";
|
|
80
|
+
if (presentation === "disabled") {
|
|
81
|
+
const failed =
|
|
82
|
+
(snapshot.status !== undefined && !["running", "completed"].includes(snapshot.status)) ||
|
|
83
|
+
(snapshot.exitCode !== undefined && snapshot.exitCode !== 0) ||
|
|
84
|
+
snapshot.error !== undefined;
|
|
85
|
+
if (!failed)
|
|
86
|
+
return new Text(
|
|
87
|
+
statusLine(snapshot, (name, text) => theme.fg(name, text)),
|
|
88
|
+
0,
|
|
89
|
+
0,
|
|
90
|
+
);
|
|
91
|
+
const window = outputWindow(snapshot.output ?? "", COMPACT_READ_ROWS);
|
|
92
|
+
const lines = [
|
|
93
|
+
...(window.omission === undefined ? [] : [` ${theme.fg("muted", window.omission)}`]),
|
|
94
|
+
...window.lines.map((line) => ` ${theme.fg("dim", line)}`),
|
|
95
|
+
...(snapshot.error === undefined ? [] : [` ${theme.fg("error", snapshot.error)}`]),
|
|
96
|
+
statusLine(snapshot, (name, text) => theme.fg(name, text)),
|
|
97
|
+
];
|
|
98
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
99
|
+
}
|
|
100
|
+
if (presentation === "full") {
|
|
101
|
+
const lines = terminalCardLines(snapshot, Number.POSITIVE_INFINITY, theme).slice(2);
|
|
102
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
103
|
+
}
|
|
79
104
|
const window = outputWindow(snapshot.output ?? "", COMPACT_READ_ROWS);
|
|
80
105
|
const lines = [
|
|
81
106
|
...(window.omission === undefined ? [] : [` ${theme.fg("muted", window.omission)}`]),
|
|
@@ -104,10 +104,7 @@ export async function registerTerminalResources(
|
|
|
104
104
|
},
|
|
105
105
|
});
|
|
106
106
|
api.describe(
|
|
107
|
-
'shell:<session> — terminal
|
|
108
|
-
);
|
|
109
|
-
api.addPromptGuideline(
|
|
110
|
-
"Use read with a returned shell:<session> source to inspect terminal status and output. Add the image view when cursor movement, ANSI layout, or a full-screen terminal interface matters.",
|
|
107
|
+
'shell:<session> — terminal status and a bounded output tail with a full-log path when truncated. views: ["image"] returns the virtual terminal screen as a PNG.',
|
|
111
108
|
);
|
|
112
109
|
},
|
|
113
110
|
} satisfies ReadPlugin;
|
|
@@ -33,9 +33,6 @@ export async function registerTerminalSearch(
|
|
|
33
33
|
api.describe(
|
|
34
34
|
"path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.",
|
|
35
35
|
);
|
|
36
|
-
api.addPromptGuideline(
|
|
37
|
-
"Use search with path shell:<session> to find text in retained terminal output. Read the same shell source with the returned line number when more context is needed.",
|
|
38
|
-
);
|
|
39
36
|
},
|
|
40
37
|
} satisfies SearchPlugin;
|
|
41
38
|
await connectSearchPlugin(pi, plugin);
|
|
@@ -3,6 +3,7 @@ import { stripVTControlCharacters } from "node:util";
|
|
|
3
3
|
|
|
4
4
|
import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
6
7
|
|
|
7
8
|
import { COMPACT_READ_ROWS } from "#src/extensions/pi-agent-read/src/core/tools/read/read-renderer.js";
|
|
8
9
|
import { formatAgentTerminalSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/output-limits.js";
|
|
@@ -56,6 +57,7 @@ export function registerTerminalTools(
|
|
|
56
57
|
manager: TerminalSessionManager,
|
|
57
58
|
profile: ShellProfile,
|
|
58
59
|
ui: Pick<TerminalUi, "bind" | "notifyWaitTransition">,
|
|
60
|
+
presentation: "full" | "compact" | "disabled" = "compact",
|
|
59
61
|
): void {
|
|
60
62
|
const toolName = process.platform === "win32" ? "powershell" : "bash";
|
|
61
63
|
pi.registerTool(
|
|
@@ -64,8 +66,7 @@ export function registerTerminalTools(
|
|
|
64
66
|
label: profile.displayName,
|
|
65
67
|
promptSnippet: `Execute ${profile.displayName} commands in synchronous or background terminal sessions`,
|
|
66
68
|
promptGuidelines: [
|
|
67
|
-
`
|
|
68
|
-
`Use ${toolName} with background for servers, watchers, and long builds. After a session enters background, do not poll it continuously; continue other work or wait for completion. Keep short tasks in the foreground. Enable periodic or verbose output for long-running commands. Use the returned shell: source with read, write, insert, and delete.`,
|
|
69
|
+
`Do not use ${toolName} 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.`,
|
|
69
70
|
],
|
|
70
71
|
description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.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. ${shellSyntaxGuidance(profile)}`,
|
|
71
72
|
parameters: runParameters,
|
|
@@ -93,7 +94,9 @@ export function registerTerminalTools(
|
|
|
93
94
|
if (outcome.reason === "aborted") ui.notifyWaitTransition(outcome.session);
|
|
94
95
|
return terminalResult(manager.snapshot(outcome.session));
|
|
95
96
|
},
|
|
96
|
-
renderCall(args, theme) {
|
|
97
|
+
renderCall(args, theme, context) {
|
|
98
|
+
const mode = context.expanded ? "full" : presentation;
|
|
99
|
+
if (mode === "disabled") return new Text(theme.fg("toolTitle", toolName), 0, 0);
|
|
97
100
|
const command = typeof args.command === "string" ? args.command : "";
|
|
98
101
|
const cwd =
|
|
99
102
|
typeof args.cwd === "string" ? path.resolve(process.cwd(), args.cwd) : process.cwd();
|
|
@@ -102,7 +105,7 @@ export function registerTerminalTools(
|
|
|
102
105
|
renderResult(result, options, theme) {
|
|
103
106
|
return renderRunResult(
|
|
104
107
|
result.details as Partial<TerminalSessionSnapshot>,
|
|
105
|
-
options.expanded,
|
|
108
|
+
options.expanded ? "full" : presentation,
|
|
106
109
|
theme,
|
|
107
110
|
);
|
|
108
111
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
|
|
2
3
|
|
|
3
4
|
import type { BuiltinExtensionContext } from "#src/composite/selection.js";
|
|
4
5
|
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
@@ -26,6 +27,13 @@ export default async function registerVision(
|
|
|
26
27
|
pi: ExtensionAPI,
|
|
27
28
|
context?: BuiltinExtensionContext,
|
|
28
29
|
): Promise<void> {
|
|
30
|
+
connectAgentDocumentation(pi, [
|
|
31
|
+
await loadPackagedAgentGuide({
|
|
32
|
+
id: "vision",
|
|
33
|
+
description: "Window, display, image, and sequence capture",
|
|
34
|
+
triggers: [{ tool: "read", resourcePrefixes: ["window:", "display:"] }],
|
|
35
|
+
}),
|
|
36
|
+
]);
|
|
29
37
|
const preferences = context?.preferences ?? {};
|
|
30
38
|
configureVision({
|
|
31
39
|
durationSeconds: preferences["vision.sequenceDurationSeconds"],
|
|
@@ -121,9 +129,6 @@ export default async function registerVision(
|
|
|
121
129
|
api.describe(
|
|
122
130
|
`Process metadata: process:PID. Visual capture: window:PID and display: or display:#N. HTTP(S) sources accept image and sequence screenshots. Use named view parameters such as sequence:duration=2,interval=0.5,scale=0.5 and image:scale=0.5,region=0.25,0.25,0.5,0.5. Duration is limited to 10 seconds and sequences to 20 frames. Defaults: duration=${defaults.durationSeconds}, interval=${defaults.intervalSeconds}, scale=${defaults.scale}. Region uses normalized x,y,width,height and runs before scaling. For captures, limit is a square grid cell size in output pixels and offset is one zero-based row-major cell index; limit without offset selects cell 0, while offset without limit is invalid. Omit both for the bounded transformed image.`,
|
|
123
131
|
);
|
|
124
|
-
api.addPromptGuideline(
|
|
125
|
-
"Use search with process:<query> before reading process:PID or window:PID. Capture arbitrary desktop windows and full displays only when their dedicated flags are enabled; Agent IDE-owned terminal processes are allowed by default. Use a bounded sequence view only when one image is insufficient; set named duration, interval, scale and region parameters when the defaults do not fit. Use limit and offset to select one image grid cell.",
|
|
126
|
-
);
|
|
127
132
|
},
|
|
128
133
|
}),
|
|
129
134
|
connectSearchPlugin(pi, {
|
|
@@ -169,9 +174,6 @@ export default async function registerVision(
|
|
|
169
174
|
api.describe(
|
|
170
175
|
"process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture.",
|
|
171
176
|
);
|
|
172
|
-
api.addPromptGuideline(
|
|
173
|
-
"Use process:<query> to discover a PID before selecting a process or window source.",
|
|
174
|
-
);
|
|
175
177
|
},
|
|
176
178
|
}),
|
|
177
179
|
]);
|
package/dist/chunk-22CLOM2D.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 file or directory path, URL, returned temp: or SEARCH# reference, or one of the source forms listed in the description. 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 additions to the returned text. Use the views listed in the tool description. Combine views when needed, for example ["anchors", "ast"] for source text with editable line references and scope boundaries. 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 T(t){if(!i.Check(R,t))return!1;let r=t,d=r.resolver;return typeof d.id=="string"&&d.id.length>0&&typeof d.tryResolve=="function"&&(!("priority"in r)||typeof r.priority=="number")}o(T,"isTextTargetResolverRegistration");function O(t){if(!i.Check(u,t))return!1;let r=t;return s(r.resolver)?r.resolver.id!=="any"&&(!("priority"in r)||typeof r.priority=="number")&&(!("matchesCall"in r)||typeof r.matchesCall=="function")&&(!("renderCall"in r)||typeof r.renderCall=="function")&&"matchesCall"in r=="renderCall"in r&&(!("renderResult"in r)||typeof r.renderResult=="function"):!1}o(O,"isResourceResolverRegistration");function S(t){return i.Check(g,t)}o(S,"isReadHandlerRegistration");function C(t){return i.Check(y,t)}o(C,"isReadViewRegistration");function k(t){return i.Check(c,t)}o(k,"isFragmentResolverRegistration");function w(t){return m(t)?t.kind==="not-handled"?!0:t.kind==="failed"?typeof t.message=="string"&&t.message.length>0:t.kind==="resolved"&&typeof t.originLine=="number":!1}o(w,"isReadFragmentResolution");function m(t){return typeof t=="object"&&t!==null}o(m,"isRecord");export{l as a,T as b,O as c,S as d,C as e,k as f,w as g};
|
package/dist/chunk-3XJ3KDPZ.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{a as b,d as A}from"./chunk-ITSNK5YG.js";import{a as N}from"./chunk-22CLOM2D.js";import{b as F,d as $}from"./chunk-526E364R.js";import{f as M}from"./chunk-YHUTTZC6.js";import{a as u}from"./chunk-EI7MMDWY.js";import L from"node:path";import{truncateHead as _,DEFAULT_MAX_BYTES as ee,DEFAULT_MAX_LINES as te}from"@earendil-works/pi-coding-agent";import{Text as S}from"@earendil-works/pi-tui";import{Type as O}from"typebox";import{Value as re}from"typebox/value";var I=O.Union([O.String({minLength:1}),N]),v=O.Object({before:I,after:I},{additionalProperties:!1});async function ne(e,o,c){if(!re.Check(v,o))throw Object.assign(new Error("Use before and after source strings or read request objects"),{code:"INVALID_ARGUMENTS"});let n=o,r=u(async l=>{let t=typeof l=="string"?{path:l}:l,p=await e.read(t,c,"script");if(p.isError||p.details.failure)throw Object.assign(new Error(p.details.failure?.message??"Comparison read failed"),{code:p.details.failure?.code??"READ_FAILED",details:p.details.failure});if(p.script===void 0)throw Object.assign(new Error("Source has no comparable text data"),{code:"UNSUPPORTED_CONTENT"});return B(p.script,t.path??"source")},"resolve"),s=await r(n.before),a=await r(n.after),i=b(s.source,s.content,a.content,a.source);return{kind:"diff",ok:!0,equal:s.content===a.content,before:s,after:a,...i}}u(ne,"executeDiff");function B(e,o){if(e.kind==="text")return{source:e.source,sources:[e.source],content:e.content};if(e.kind==="resources"){let c=e.resources.map(n=>B(n,o));return{source:e.source??o,sources:c.flatMap(n=>n.sources),content:c.map(n=>n.content).join(`
|
|
2
|
-
`)}}if(e.kind==="bytes")throw Object.assign(new Error(`Byte sources are not text: ${e.source}`),{code:"UNSUPPORTED_CONTENT"});if(e.blocks.length===0||e.blocks.some(c=>c.type!=="text"))throw Object.assign(new Error(`Source is not text: ${e.source}`),{code:"UNSUPPORTED_CONTENT"});return{source:e.source,sources:[e.source],content:e.blocks.flatMap(c=>c.type==="text"?[c.text]:[]).join(`
|
|
3
|
-
`)}}u(B,"comparisonText");function R(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="diff"&&"ok"in e&&e.ok===!0}u(R,"isDiffOutcome");function j(e,o=process.cwd()){let c=u(r=>L.isAbsolute(r)?L.relative(o,r)||".":r,"displaySource"),n=`Diff: ${c(e.before.source)} \u2192 ${c(e.after.source)}`;return{results:[new A({ok:!0,path:n,beforeContentMap:{[n]:e.before.content},afterContent:e.after.content,diffs:[e.diff]})]}}u(j,"diffPresentation");function k(e){return e.equal?`No differences: ${e.before.source} \u2192 ${e.after.source}`:e.diff}u(k,"diffText");function Ee(e){return{content:[{type:"text",text:k(e)}],details:{}}}u(Ee,"diffReadResult");function De(e,o,c){e.registerTool({name:"diff",label:"Diff",parameters:v,promptSnippet:"Compare two text-readable sources without changing them",description:"Use diff to compare two sources without modifying them. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference. The same diff function is available inside Apply.",renderCall(n,r){return new S(r.fg("toolTitle",r.bold("Diff")),0,0)},renderResult(n,r,s,a){let i=n.details;if(i?.comparison?.equal)return new S(k(i.comparison),0,0);let l=o.getToolRenderer("diff")?.renderResult;return l?l(n,r,s,a):new S(n.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
4
|
-
`),0,0)},async execute(n,r,s,a,i){let l=c();if(l===void 0)throw new Error("Diff requires the read extension");let t=await ne(l,r,{cwd:i.cwd,signal:s}),p=k(t),y=_(p).truncated?await l.saveTemporary(p):void 0,f=y===void 0?"":`
|
|
5
|
-
Full diff: ${y}`;return{content:[{type:"text",text:y===void 0?p:_(p,{maxLines:te-2,maxBytes:ee-Buffer.byteLength(f)}).content+f}],details:{...j(t,i.cwd),comparison:t,temporarySource:y}}}})}u(De,"registerDiff");import{parser as q}from"@lezer/javascript";import{TreeFragment as U}from"@lezer/common";var oe=new Set(["read","search","diff","open","createFile","deleteFile","copyFile","moveFile","flush","result"]);function V(e,o=q.parse(e)){let c=[];o.iterate({enter(r){if(r.name==="AssignmentExpression"){let t=r.node.firstChild;t?.name==="VariableName"&&c.push({name:e.slice(t.from,t.to),from:0,to:e.length})}if(r.name!=="VariableDefinition")return;let s=r.node.parent;for(;s?.parent&&!["VariableDeclaration","ParamList","Block","Script"].includes(s.name);)s=s.parent;let a=s?.name==="VariableDeclaration"&&s.firstChild?.name==="var",i=new Set(["Script","FunctionDeclaration","FunctionExpression","ArrowFunction",...a?[]:["Block"]]),l=r.node.parent;for(l?.name==="FunctionDeclaration"&&(l=l.parent);l?.parent&&!i.has(l.name);)l=l.parent;c.push({name:e.slice(r.from,r.to),from:l?.from??0,to:l?.to??e.length})}});let n=[];return o.iterate({enter(r){if(r.name!=="CallExpression")return;let s=r.node.firstChild;if(s?.name!=="VariableName")return;let a=e.slice(s.from,s.to);if(!oe.has(a)||c.some(t=>t.name===a&&t.from<=r.from&&t.to>=r.to))return;let i=r.node.getChild("ArgList")?.getChild("ObjectExpression"),l=Object.create(null);if(!i){let t=r.node.getChild("ArgList"),p=t?e.slice(t.from+1,t.to).replace(/\)$/,""):"";p&&(l.arguments={text:p.length>160?p.slice(0,120)+"\u2026":p,literal:!1})}for(let t of i?.getChildren("Property")??[]){let p=t.firstChild,y=(p?e.slice(p.from,p.to):"").replace(/^["']|["']$/g,"");if(!/^[a-zA-Z_$][\w$]*$/.test(y)){for(let Q of["path","query","target","before","after"])delete l[Q];let w=e.slice(t.from,t.to);l[`argument@${t.from}`]={text:w.length>160?w.slice(0,160)+"\u2026":w,literal:!1};continue}let f=t.lastChild;if(!f||f.type.isError||f.name===":")continue;let g=e.slice(f.from,f.to),d=g.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t"),h=/^(?:["'])(?:\d+#[0-9A-F]+|CHANGE#[0-9A-F]+|begin|end|scope-(?:begin|end)-[^"']+)["']$/.test(g);l[y]={text:d.length>160&&!h?`${d.slice(0,100)}\u2026${d.slice(-40)} (${g.length} source chars)`:d,literal:["String","Number","BooleanLiteral","Null"].includes(f.name)&&f.lastChild?.type.isError!==!0}}return n.push({name:a,from:r.from,to:r.to,path:l.path,query:l.query,target:l.target,before:l.before,after:l.after,arguments:l}),!1}}),n}u(V,"parseApplyCalls");function ie(e,o=V(e),c,n=r=>r){let r=0,s=[],a=u(i=>n(i.split(`
|
|
6
|
-
`).map(l=>l.length>200?l.slice(0,200)+"\u2026":l).join(`
|
|
7
|
-
`)),"codePreview");for(let i of o)s.push(a(e.slice(r,i.from))),s.push(c?.(i)??`${i.name}(${i.path?i.path.literal?i.path.text:`\u2039${i.path.text}\u203A`:"\u2026"})`),r=i.to;return s.push(a(e.slice(r))),s.join("")}u(ie,"compactApplySource");function J(e,o){let c="",n="",r=[];return s=>{if(s===c)return n;let a=0;for(;a<c.length&&a<s.length&&c[a]===s[a];)a++;r=U.applyChanges(r,[{fromA:a,toA:c.length,fromB:a,toB:s.length}]);let i=q.parse(s,r);return r=U.addTree(i),n=ie(s,V(s,i),e,o),c=s,n}}u(J,"createApplySourceProjection");import{lstat as G,unlink as se}from"node:fs/promises";import Y from"node:path";import z from"fs-extra";import{Type as x}from"typebox";import{Value as ae}from"typebox/value";var T=x.String({minLength:1,description:"Local regular file path, relative to cwd or absolute."}),le=x.Object({path:T},{additionalProperties:!1}),ce=x.Object({path:T,target:T,overwrite:x.Optional(x.Boolean({description:"Allow replacing an existing regular target file. Defaults to false."}))},{additionalProperties:!1});function E(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="file-operation"}u(E,"isFileOperationResult");function D(e){return[`${e.operation}: ${e.effect}`,e.path,e.target===void 0?void 0:`Target: ${e.target}`,e.error===void 0?void 0:`${e.error.code}: ${e.error.message}`].filter(o=>o!==void 0).join(`
|
|
8
|
-
`)}u(D,"formatFileOperation");async function Ue(e,o,c,n){let r=!1,s,a;try{let i=e==="delete"?le:ce;if(!ae.Check(i,o))throw Object.assign(new Error("Invalid file operation arguments"),{code:"INVALID_ARGUMENTS"});let l=o;s=Y.resolve(c,l.path),a=l.target===void 0?void 0:Y.resolve(c,l.target),n?.throwIfAborted();let t=await pe(s);if(a!==void 0){let p=await fe(a);if(p!==void 0){if(!p.isFile()||p.isSymbolicLink())throw Object.assign(new Error("Target must be a regular file"),{code:"INVALID_FILE_TYPE"});if(s===a||t.ino===p.ino&&t.dev===p.dev)throw Object.assign(new Error("Source and target are the same file"),{code:"SAME_FILE"});if(l.overwrite!==!0)throw Object.assign(new Error("Target exists; use overwrite: true to replace it"),{code:"EEXIST"})}}return n?.throwIfAborted(),r=!0,e==="delete"?await se(s):a!==void 0&&(e==="copy"?await z.copy(s,a,{overwrite:l.overwrite===!0,errorOnExist:!0}):await z.move(s,a,{overwrite:l.overwrite===!0})),{kind:"file-operation",operation:e,ok:!0,effect:"applied",path:s,...a===void 0?{}:{target:a}}}catch(i){return{kind:"file-operation",operation:e,ok:!1,effect:r?"unknown":"not-applied",...s===void 0?{}:{path:s},...a===void 0?{}:{target:a},error:{code:i!==null&&typeof i=="object"&&"code"in i?String(i.code):"FILE_OPERATION_FAILED",message:i instanceof Error?i.message:String(i)}}}}u(Ue,"executeFileOperation");async function pe(e){let o=await G(e);if(!o.isFile()||o.isSymbolicLink())throw Object.assign(new Error("Source must be a regular file"),{code:"INVALID_FILE_TYPE"});return o}u(pe,"regularFile");async function fe(e){try{return await G(e)}catch(o){if(o!==null&&typeof o=="object"&&"code"in o&&o.code==="ENOENT")return;throw o}}u(fe,"optionalStat");import{Text as de}from"@earendil-works/pi-tui";function K(e){let o=e.select(),c=e.mutationValues().filter(ue);return o.files.map(n=>{let r=c.flatMap(i=>i.files.filter(l=>l.source===n.source).map(l=>({outcome:i,changed:l}))),s=e.mutationPresentation(n.source)?.data,a=s?.afterContent===n.after?s:void 0;return new A({ok:!0,path:n.source,files:[{path:n.source,action:n.before===null?"created":"edited"}],snapshot:{content:n.before??""},beforeContentMap:{[n.source]:n.before},afterContent:n.after??"",afterDocument:a?.afterDocument,resultPresentation:a?.resultPresentation,scopeMarkers:a?.scopeMarkers,hints:a?.hints,warnings:a?.warnings,diffStatuses:a?.diffStatuses,diffs:[b(n.source,n.before??"",n.after??"").diff],operations:r.map(({outcome:i,changed:l})=>({operation:i.operation==="remove"?"delete":i.operation,changes:l.changes.length})),formatting:a?.formatting??r.at(-1)?.changed.formatting})})}u(K,"finalApplyMutations");function ue(e){return e!==null&&typeof e=="object"&&"operation"in e&&"files"in e&&Array.isArray(e.files)&&"effect"in e}u(ue,"isMutation");import{highlightCode as Z}from"@earendil-works/pi-coding-agent";import{wrapTextWithAnsi as W,visibleWidth as X,truncateToWidth as me}from"@earendil-works/pi-tui";function nt(e,o,c,n=process.cwd()){let r=e.select(),s=[...r.automatic,...r.explicit.filter(t=>t.kind==="operation")].filter(t=>R(t.value)&&!t.value.equal),a=s.flatMap(t=>R(t.value)?[j(t.value,n)]:[]),i=new Set(s.flatMap(t=>t.presentation?.content??[]));if(r.files.length===0){let t=[...r.automatic.map(p=>p.presentation),...r.explicit.map(p=>p.kind==="operation"?p.presentation:void 0)].filter(p=>p!==void 0);return{comparisons:a,cwd:n,blocks:[...o.content.filter(p=>!i.has(p)).flatMap(p=>p.type==="text"?[{text:H(p.text),read:t.find(m=>m.content.includes(p))}]:[])]}}let l=K(e);return{...l.length>0?{mutations:{results:l}}:{},comparisons:a,cwd:n,blocks:[...r.explicit.flatMap(t=>t.kind==="operation"&&R(t.value)&&!t.value.equal?[]:E(t.value)?[{text:D(t.value)}]:t.kind==="operation"?t.presentation?.content.flatMap(p=>p.type==="text"?[{text:p.text,read:t.presentation}]:[])??[]:[{text:H(typeof t.value=="string"?t.value:t.value===void 0?"undefined":JSON.stringify(t.value,null,2))}]),...r.automatic.flatMap(({value:t,presentation:p})=>{if(E(t))return[{text:D(t)}];if(t!==null&&typeof t=="object"&&"kind"in t&&t.kind==="index-operation")return p?.content.flatMap(m=>m.type==="text"?[{text:m.text}]:[])??[];if(t===null||typeof t!="object"||!("errors"in t)||!Array.isArray(t.errors))return[];if("operations"in t&&Array.isArray(t.operations)){let m=t.operations.filter(f=>f!==null&&typeof f=="object"&&"status"in f&&f.status==="applied").length;if(m===t.operations.length)return[];let y=t.operations.filter(f=>f!==null&&typeof f=="object"&&"status"in f&&f.status!=="applied").map(f=>({text:we(f)}));return[{text:`Apply partially applied: ${m} of ${t.operations.length} operations completed.`},...y]}return t.errors.flatMap(m=>m!==null&&typeof m=="object"&&"message"in m&&typeof m.message=="string"?[{text:m.message}]:[])}),...c===void 0?[]:[{text:c instanceof Error?c.message:JSON.stringify(c)}]]}}u(nt,"createApplyDisplay");function P(e,o,c,n,r,s,a=!1){let i=Math.max(1,c);if(i<5)return e.split(`
|
|
9
|
-
`).flatMap(d=>W(d,i));let l=i-4,t=u(d=>o.fg("borderMuted",d),"border"),m=me(` ${n==="call"?"Apply \xB7 JavaScript":"Result"} `,i-4,""),y=[t(`${n==="call"?"\u256D":"\u251C"}\u2500`)+o.fg(a?"error":"accent",m)+t(`${"\u2500".repeat(Math.max(0,i-X(m)-3))}${n==="call"?"\u256E":"\u2524"}`)],f=`${t("\u2502")}${" ".repeat(i-2)}${t("\u2502")}`;for(let d of e.split(`
|
|
10
|
-
`)){let h=s==="diff"?o.fg(d.startsWith("+")?"toolDiffAdded":d.startsWith("-")?"toolDiffRemoved":"toolDiffContext",d):s?Z(d,s).join(`
|
|
11
|
-
`):o.fg("toolOutput",d);for(let w of W(h,l))y.push(`${t("\u2502")} ${w}${" ".repeat(Math.max(0,l-X(w)))} ${t("\u2502")}`)}n==="call"&&y.push(f),r&&y.push(t(`\u2570${"\u2500".repeat(i-2)}\u256F`));let g=o.getBgAnsi("toolPendingBg");return y.map(d=>g+M(d,g)+"\x1B[0m")}u(P,"applyFrameRows");function ge(e){return(o,c,n)=>{let r=n.state,s=r.projectSource??=J(e?i=>e(i,c):void 0,e?i=>Z(i,"javascript").join(`
|
|
12
|
-
`):void 0),a=o!==null&&typeof o=="object"&&"source"in o&&typeof o.source=="string"?o.source:"";return{invalidate(){},render(i){return P(r.codeView||n.expanded?r.displaySource??a:ye(s(r.displaySource??a)),c,i,"call",!r.applyResultReady,r.codeView||n.expanded||!e?"javascript":void 0)}}}}u(ge,"createApplyCallRenderer");function ye(e,o=F){let c=e.split(`
|
|
13
|
-
`);if(c.length<=o)return e;let n=Math.max(2,o-1),r=Math.ceil(n/2),s=Math.floor(n/2),a=c.length-r-s;return[...c.slice(0,r),`\u2026 ${a} lines omitted \u2026`,...c.slice(-s)].join(`
|
|
14
|
-
`)}u(ye,"compactApplyPreview");var ot=ge();function he(e){return(o,c,n,r)=>{r.state.applyResultReady=!0;let s=o.details;r.state.displaySource=s?.displaySource;let a=s?.display,i=a?.blocks??[{text:r.isError?"Apply failed":"Apply finished"}],l=$({kind:"source"}),t=i.map(f=>l(f.read??{content:[{type:"text",text:f.text}],details:xe(f.text)},c,n,{...r,isError:!1,lastComponent:void 0})),p=a?.mutations,m=(a?.comparisons??[]).flatMap(f=>[e?.(f,n,c.expanded,a?.cwd??process.cwd())??new de((f.results??[]).flatMap(d=>d.data.diffs??[]).join(`
|
|
15
|
-
`),0,0)]),y=p===void 0?void 0:e?.(p,n,c.expanded,a?.cwd??process.cwd());return{invalidate(){y?.invalidate();for(let f of m)f.invalidate()},render(f){let g=[];for(let d of t){let h=d.render(Math.max(1,f-4));h.length!==0&&(g.length>0&&g.push(""),g.push(...h))}for(let d of m)g.length>0&&g.push(""),g.push(...d.render(Math.max(1,f-4)));if(y!==void 0){let d=y.render(Math.max(1,f-4));g.length>0&&d.length>0&&g.push(""),g.push(...d)}else p!==void 0&&g.push(...(p.results??[]).map(d=>d.path??"Changed file"));return g.length===0&&i.length>0&&i.every(d=>d.read?.details.diagnosticCheck?.complete&&d.read.details.diagnosticCheck.count===0)?P("",n,f,"result",!0).slice(-1):P(g.length===0?"No output":g.join(`
|
|
16
|
-
`),n,f,"result",!0,void 0,r.isError)}}}}u(he,"createApplyResultRenderer");function we(e){if(e===null||typeof e!="object")return String(e);let o="index"in e?Number(e.index)+1:"?",c="kind"in e?String(e.kind):"operation",n="status"in e?String(e.status):"unknown",r="error"in e&&e.error!==null&&typeof e.error=="object"?`: ${"code"in e.error?String(e.error.code):"ERROR"}: ${"message"in e.error?String(e.error.message):"Operation failed"}`:"";return`Operation ${o} (${c}): ${n}${r}`}u(we,"formatDisplayOutcome");function H(e){if(/^(?:Undo transaction:|Undo available)/u.test(e.trim()))return"";try{let o=JSON.parse(e);return JSON.stringify(C(o),null,2)}catch{return e.replace(/APPLY#[0-9A-F]{12}/gu,"Apply transaction")}}u(H,"redactApplyReceipts");function C(e){return Array.isArray(e)?e.map(C):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).filter(([o])=>o!=="transaction").map(([o,c])=>[o,C(c)]))}u(C,"redactTransactionKeys");function xe(e){try{let o=JSON.parse(e);return o!==null&&typeof o=="object"?{source:"result.json"}:{}}catch{return{}}}u(xe,"jsonDetails");var it=he();export{ne as a,Ee as b,De as c,Ue as d,K as e,nt as f,ge as g,ot as h,he as i,it as j};
|
package/dist/chunk-526E364R.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{c as O}from"./chunk-YHUTTZC6.js";import{i as y,o as p,t as S,u as L}from"./chunk-5VSE5X5R.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function Re(e,n){let{lines:t,truncation:r,...i}=e,o=t?.map(s=>{let l=[s.lineNumber,S(s.content,n),s.lineEnding];return(s.presentation!==void 0||s.metadata!==void 0)&&l.push(s.presentation),s.metadata!==void 0&&l.push(s.metadata),l}),{content:a,...u}=r??{};return{...i,...o===void 0?{}:{storedLines:o},...r===void 0?{}:{truncation:u,truncatedText:S(a??"",n)}}}d(Re,"compactReadDetails");function W(e,n){let t=e;if(t.storedLines===void 0&&t.truncatedText===void 0)return e;let{storedLines:r,truncatedText:i,truncation:o,...a}=t;return{...a,...r===void 0?{}:{lines:r.map(([u,s,l,c,h])=>({lineNumber:u,content:L(s,n),lineEnding:l,...c==null?{}:{presentation:c},...h==null?{}:{metadata:h}}))},...o===void 0?{}:{truncation:{...o,content:L(i??"",n)}}}}d(W,"restoreReadDetails");import f from"node:path";import{homedir as I}from"node:os";import{createReadToolDefinition as J,getReadmePath as Z}from"@earendil-works/pi-coding-agent";import{Text as K}from"@earendil-works/pi-tui";var v=J(process.cwd()),X=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]);function $(e,n=process.cwd()){if(typeof e!="object"||e===null)return;let t=e,r=t.path;if(typeof r!="string"||r.length===0||r.includes("#")||!f.isAbsolute(r)&&/^[a-z][a-z\d+.-]*:/iu.test(r)||t.views!==void 0&&(!Array.isArray(t.views)||t.views.length>0)||t.offset!==void 0&&(typeof t.offset!="number"||!Number.isInteger(t.offset)||t.offset<1)||t.limit!==void 0&&(typeof t.limit!="number"||!Number.isInteger(t.limit)||t.limit<1))return;let i=r.startsWith("~/")?f.join(I(),r.slice(2)):r,o=f.resolve(n,i),a=f.basename(o),u=f.relative(f.dirname(Z()),o),s=!f.isAbsolute(u)&&(u==="README.md"||u.startsWith(`docs${f.sep}`)||u.startsWith(`examples${f.sep}`));if(!(a!=="SKILL.md"&&!X.has(a)&&!s))return{path:r,...t.offset===void 0?{}:{offset:t.offset},...t.limit===void 0?{}:{limit:t.limit}}}d($,"nativeReadArguments");function C(e,n){return{...e,args:n,lastComponent:e.lastComponent instanceof K?e.lastComponent:void 0}}d(C,"nativeReadContext");import{getLanguageFromPath as M,getMarkdownTheme as Y,highlightCode as P,keyHint as Q}from"@earendil-works/pi-coding-agent";import{Container as b,Markdown as _,Text as ee,truncateToWidth as T,visibleWidth as m,wrapTextWithAnsi as j}from"@earendil-works/pi-tui";var q=12;function ne(e,n,t){let r=typeof n=="number"?n:void 0,i=typeof t=="number"?t:void 0;if(r===void 0&&i===void 0)return{pathSuffix:"",qualifiers:[],details:[]};if(e==="inherited source"||e.includes("#")){let s=r??1,l=i===void 0?String(s):`${s}-${s+i-1}`;return{pathSuffix:"",qualifiers:[{text:`relative lines ${l}`}],details:[{label:"relative lines",value:l}]}}if(r!==void 0&&r<0)return{pathSuffix:"",qualifiers:[{text:`tail ${Math.abs(r)}`},...i===void 0?[]:[{text:`limit ${i}`}]],details:[{label:"tail",value:String(Math.abs(r))},...i===void 0?[]:[{label:"limit",value:String(i)}]]};let a=Math.max(1,r??1),u=i===void 0?String(a):`${a}-${a+i-1}`;return{pathSuffix:`:${u}`,qualifiers:[],details:[{label:"lines",value:u}]}}d(ne,"readWindowPresentation");function Pe(e,n,t){let r=$(e,t.cwd);if(r!==void 0)return x(v.renderCall)(r,n,C(t,r));if(typeof e.path=="string"&&e.path.startsWith("shell:"))return new b;let i=typeof e.path=="string"?e.path:"inherited source",o=ne(i,e.offset,e.limit),a=Array.isArray(e.views)?e.views.filter(l=>typeof l=="string"):[],u=[...o.qualifiers,...a.length===0?[]:[{text:`views ${a.join(",")}`}]],s=[...typeof e.path=="string"?[{label:"path",value:e.path}]:[],...o.details,...a.length===0?[]:[{label:"views",value:a.join(",")}]];return O(t.lastComponent,{tool:"read",primary:{text:`${i}${o.pathSuffix}`,color:typeof e.path=="string"?"accent":"muted",underline:typeof e.path=="string",truncate:"start"},qualifiers:u,details:s,expanded:t.expanded},n)}d(Pe,"renderReadCall");function Ne(e){let n=new WeakMap;return(t,r,i,o)=>{let a=e.nativeResources?$(o.args,o.cwd):void 0;if(a!==void 0&&!r.isPartial)return x(v.renderResult)({...t,details:{truncation:D(t.details).truncation}},r,i,C(o,a));if(r.isPartial||o.isError){let h=k(t),G=o.isError?"error":"dim";return new ee(i.fg(G,h),0,0)}let u=D(t.details).diagnosticCheck;if(u?.complete&&u.count===0)return new b;if(!le(t))return o.lastComponent instanceof b?o.lastComponent:new b;let s=n.get(t);s===void 0&&(s=W(D(t.details),k(t)),n.set(t,s));let c=(o.lastComponent instanceof w?o.lastComponent:void 0)??new w({result:t,details:s,options:e,expanded:r.expanded,theme:i});return c.update({result:t,details:s,options:e,expanded:r.expanded,theme:i}),c}}d(Ne,"createReadResultRenderer");var w=class{constructor(n){this.state=n}static{d(this,"ReadResultPanel")}cached;update(n){this.state.result===n.result&&this.state.details===n.details&&this.state.options===n.options&&this.state.expanded===n.expanded&&this.state.theme===n.theme||(this.state=n,this.invalidate())}render(n){if(this.cached?.width===n)return this.cached.lines;if(n<8){let l=[T(V(this.state,n),Math.max(1,n))];return this.cached={width:n,lines:l},l}let t=n-2,r=Math.max(1,t-2),i=te(this.state,r).flatMap(l=>j(l,r)),o=oe(i,this.state.expanded,this.state.theme),a=[ae(this.state,t,this.state.theme)];for(let l of o)for(let c of j(l,r))a.push(z(c,t,this.state.theme));let u=de(this.state.details,this.state.theme);u!==void 0&&a.push(z(u,t,this.state.theme)),a.push(this.state.theme.fg("borderMuted",`\u2570${"\u2500".repeat(t)}\u256F`));let s=a.map(l=>T(l,n));return this.cached={width:n,lines:s},s}invalidate(){this.cached=void 0}};function te(e,n){let t=B(e.details),r=ue(e.result,t,e.details,!e.expanded);if(e.options.kind==="markdown"||ce(e.details,t,e.options.kind)){let s=new _(r,0,0,Y());return A(s.render(n),e.theme)}if(e.options.kind==="code-view"){let s=t===void 0?g(r).map(l=>N(l,e.theme,!1)):F(t)?re(t,!e.expanded,e.theme):ie(t,e.theme);return A(s,e.theme)}let i=t!==void 0&&F(t),o=t===void 0||i?g(r).map(R):t.map(({content:s})=>R(s)),a=E(e.details,t),u=a===void 0?o.map(s=>e.theme.fg("toolOutput",s)):i?H(t,a,!e.expanded,e.theme):P(o.join(`
|
|
2
|
-
`),a);return A(u,e.theme)}d(te,"renderContentRows");function H(e,n,t,r){return e.flatMap(i=>{let o=R(i.content),a=P(o,n)[0]??r.fg("toolOutput",o),u=!1,s=p({source:"",content:i.content,lines:[i]},{compact:t});return g(s).map(l=>{if(!u&&o.length>0){let c=l.indexOf(o);if(c>=0)return u=!0,`${r.fg("toolOutput",l.slice(0,c))}${a}${r.fg("toolOutput",l.slice(c+o.length))}`}return r.fg("toolOutput",l)})})}d(H,"renderHighlightedPresentedLines");function re(e,n,t){return e.flatMap(r=>{let i=y(r);if(i===void 0){let a=p({source:"",content:r.content,lines:[r]},{compact:n});return g(a).map(u=>N(u,t,!1))}let o=M(i.source);if(o===void 0){let a=p({source:"",content:r.content,lines:[r]},{compact:n});return g(a).map(u=>t.fg("toolOutput",u))}return H([r],o,n,t)})}d(re,"renderPresentedCodeViewLines");function ie(e,n){return e.map(t=>{let r=y(t);if(r===void 0)return N(t.content,n);let i=M(r.source),o=R(U(t.content));return i===void 0?n.fg("toolOutput",o):P(o,i)[0]??n.fg("toolOutput",o)})}d(ie,"renderCodeViewLines");function U(e){return e.replace(/(?:[ \t]{2,}<!--[ \t]+scope-(?:begin|end)-[^\s>]+[ \t]+-->)+[ \t]*$/u,"")}d(U,"stripScopeMarkers");function N(e,n,t=!0){let r=R(t?U(e):e);return/^#{2,3}\s/u.test(r)?n.fg("mdHeading",n.bold(r.replace(/^#{2,3}\s+/u,""))):/^(?:Lines|Reason|Recovery):/u.test(r)?n.fg("dim",r):/^[\p{L}][^:]*:$/u.test(r)?n.fg("accent",n.bold(r)):/^\s*[-*]\s/u.test(r)?n.fg("mdListBullet",r):n.fg("toolOutput",r)}d(N,"renderCodeViewLabel");function oe(e,n,t){if(n||e.length<=q)return e;let r=e.slice(0,q-1),i=e.length-r.length;return[...r,`${t.fg("dim",`\u2026 ${String(i)} more ${i===1?"row":"rows"} \xB7 `)}${Q("app.tools.expand","to expand")}`]}d(oe,"compactRows");function ae(e,n,t){let r=d(a=>t.fg("borderMuted",a),"frame"),i=T(` ${V(e,Math.max(1,n-1))} `,Math.max(0,n-1),""),o="\u2500".repeat(Math.max(0,n-m(i)-1));return`${r("\u256D\u2500")}${i}${r(`${o}\u256E`)}`}d(ae,"renderTopBorder");function V(e,n){let t=e.options.label??pe(E(e.details,B(e.details))),r=e.details.source??"read result",i=se(e.details),o=e.theme.fg("accent",e.theme.bold(t)),a=i===void 0?"":e.theme.fg("dim",` \xB7 ${i}`),u=Math.max(1,n-m(o)-m(a)-2),s=me(r,u);return`${o} ${e.theme.fg("muted",s)}${a}`}d(V,"readTitle");function se(e){if(!(e.startLine===void 0||e.endLine===void 0||e.totalLines===void 0||e.totalLines<=0))return`${String(e.startLine)}\u2013${String(e.endLine)} / ${String(e.totalLines)}`}d(se,"sourceRange");function de(e,n){let t=e.truncation;if(t?.firstLineExceedsLimit===!0)return n.fg("warning","First source line is larger than the saved read limit");if(t?.truncated===!0)return n.fg("warning",`Saved result contains ${String(t.outputLines)} of ${String(t.totalLines)} rendered rows`)}d(de,"readStatus");function z(e,n,t){let r=Math.max(0,n-2),i=T(e,r),o=` ${i}${" ".repeat(Math.max(0,r-m(i)))} `,a=t.fg("borderMuted","\u2502");return`${a}${o}${a}`}d(z,"framed");function ue(e,n,t,r){if(n!==void 0)return p({source:t.source??"",content:"",lines:n},{compact:r});let i=k(e);return t.truncation===void 0&&!(t.totalLines!==void 0&&t.endLine!==void 0&&t.endLine<t.totalLines)?i:i.replace(/\n\n\[(?:Showing lines|Output truncated|\d+ more lines in source)[\s\S]*\]$/u,"")}d(ue,"cleanText");function F(e){return e.some(n=>n.presentation!==void 0)}d(F,"hasPresentation");function g(e){let n=e.split(/\r\n|\r|\n/u);return n.at(-1)===""&&/(?:\r\n|\r|\n)$/u.test(e)&&n.pop(),n}d(g,"splitTextRows");function k(e){return e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
3
|
-
`)}d(k,"textBlocks");function B(e){return e.lines}d(B,"readLines");function D(e){return typeof e=="object"&&e!==null?e:{}}d(D,"readDetails");function le(e){return e.content.some(n=>n.type==="text")}d(le,"hasTextContent");function E(e,n){let r=n?.map(y).find(i=>i!==void 0)?.source??e.source;return r===void 0?void 0:M(fe(r))}d(E,"languageFor");function ce(e,n,t){return t==="source"&&E(e,n)==="markdown"}d(ce,"isMarkdownSource");function fe(e){try{let n=new URL(e);return n.protocol==="file:"?n.pathname:`${n.pathname}${n.search}`}catch{return e.replace(/#[^/\\]*$/u,"").replace(/^[A-Za-z][A-Za-z\d+.-]*:(?=[/\\])/u,"")}}d(fe,"normalizeSourcePath");function R(e){let n="";for(let t of e.replaceAll(" "," ".repeat(4))){let r=x(t.codePointAt(0));n+=r<32||r===127?"\uFFFD":t}return n}d(R,"normalizeText");function pe(e){return e===void 0?"TEXT":{javascript:"JS",json:"JSON",markdown:"MD",python:"PY",rust:"RS",typescript:"TS"}[e]??e.slice(0,4).toUpperCase()}d(pe,"languageLabel");function A(e,n){return e.length===0?[n.fg("dim","Empty content")]:[...e]}d(A,"nonEmptyRows");function me(e,n){return m(e)<=n?e:n<=1?"\u2026":`\u2026${e.slice(-(n-1))}`}d(me,"truncateFromStart");export{Re as a,q as b,Pe as c,Ne as d};
|
package/dist/chunk-DDKHZZDO.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as L}from"./chunk-M5IVSCR2.js";import{a as U}from"./chunk-6CZO43OH.js";import{a as M,b as $}from"./chunk-OBNING2A.js";import{a as k}from"./chunk-ZTYWHL2F.js";import{a as O,b as T}from"./chunk-7UGNGK7Y.js";import{a as c}from"./chunk-EI7MMDWY.js";import{execFile as Z}from"node:child_process";import ee from"node:os";import{promisify as ne}from"node:util";import{createCanvas as _,loadImage as te}from"@napi-rs/canvas";var p=ne(Z),I=20*1024*1024,B={durationSeconds:2,intervalSeconds:.5,scale:.5},W=new Set;function F(e){let n=D({mode:"sequence",durationSeconds:Number(e.durationSeconds??2),intervalSeconds:Number(e.intervalSeconds??.5),scale:Number(e.scale??.5)});B={durationSeconds:n.durationSeconds,intervalSeconds:n.intervalSeconds,scale:n.scale},W=new Set((e.allowedExecutables??"").split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}c(F,"configureVision");function y(){return B}c(y,"getVisionDefaults");function H(e){let n=e.includes("\\")?e.slice(e.lastIndexOf("\\")+1):e,r=n.trim().split(/\s+/u)[0]??"",t=r.slice(r.lastIndexOf("/")+1);return W.has((e.includes("\\")?n:t).toLowerCase())}c(H,"isExecutableAllowed");function j(e,n){let r=e?.filter(a=>/^(?:image|sequence)(?::|$)/u.test(a))??[];if(r.length===0)return;if(r.length>1)throw new Error("Use only one image or sequence view");let t=r[0],i=t.indexOf(":"),s=t.slice(0,i<0?void 0:i),o={};if(i>=0&&re(t.slice(i+1),o),s==="image"&&(o.duration!==void 0||o.interval!==void 0))throw new Error("duration and interval are supported only by the sequence view");return D({mode:s,durationSeconds:o.duration??n.durationSeconds,intervalSeconds:o.interval??n.intervalSeconds,scale:o.scale??n.scale,...o.region===void 0?{}:{region:o.region}})}c(j,"parseVisionView");function re(e,n){if(e.length===0)throw new Error("View parameters cannot be empty");let r=e.split(",");for(let t=0;t<r.length;t+=1){let i=r[t],s=i.indexOf("=");if(s<=0)throw new Error(`Invalid view parameter ${i}`);let o=i.slice(0,s),a=i.slice(s+1);if(o==="region"){let l=[a,r[t+1],r[t+2],r[t+3]].map(Number);if(l.some(m=>!Number.isFinite(m)))throw new Error("region requires x,y,width,height values");n.region={x:l[0],y:l[1],width:l[2],height:l[3]},t+=3;continue}if(o!=="duration"&&o!=="interval"&&o!=="scale")throw new Error(`Unknown view parameter ${o}`);let d=Number(a);if(!Number.isFinite(d))throw new Error(`View parameter ${o} must be a number`);if(n[o]!==void 0)throw new Error(`Duplicate view parameter ${o}`);n[o]=d}}c(re,"parseViewParameters");function G(e){if(!e.startsWith("display:"))return;if(e==="display:")return 0;let n=/^display:#(\d+)$/u.exec(e);if(n===null)throw new Error("Display sources use display: or display:#N with a zero-based index");let r=Number(n[1]);if(!Number.isSafeInteger(r))throw new Error("Display sources use display: or display:#N with a zero-based index");return r}c(G,"parseDisplaySource");async function E(e){let n=new Map(e.list().flatMap(i=>i.pid===void 0?[]:[[i.pid,i]]));if(process.platform!=="linux"&&process.platform!=="darwin")return[...n].map(([i,s])=>({pid:i,command:s.description,owned:!0,source:s.source}));let{stdout:r}=await p("ps",["-eo","pid=,ppid=,lstart=,args="],{maxBuffer:4*1024*1024}),t=r.split(`
|
|
2
|
-
`).flatMap(i=>{let s=/^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.*)$/u.exec(i);if(s===null)return[];let o=Number(s[1]),a=n.get(o);return[{pid:o,parentPid:Number(s[2]),started:s[3],command:s[4]??"",owned:a!==void 0,...a===void 0?{}:{source:a.source}}]});return x()?[...t,...await oe()]:t}c(E,"listProcesses");async function oe(){try{let{stdout:e}=await p("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command","Get-Process | Select-Object Id,ProcessName,Path,StartTime | ConvertTo-Json -Compress"],{maxBuffer:4194304}),n=JSON.parse(e);return(Array.isArray(n)?n:[n]).flatMap(t=>{if(typeof t!="object"||t===null||!("Id"in t)||typeof t.Id!="number")return[];let i="ProcessName"in t&&typeof t.ProcessName=="string"?t.ProcessName:"Windows process",s="Path"in t&&typeof t.Path=="string"?t.Path:void 0,o="StartTime"in t&&typeof t.StartTime=="string"?t.StartTime:void 0;return[{pid:t.Id,command:s??i,owned:!1,...o===void 0?{}:{started:o}}]})}catch{return[]}}c(oe,"listWindowsProcesses");async function A(e,n){if(!Number.isSafeInteger(e)||e<=0)throw new Error("Process PID must be a positive integer");let r=(await E(n)).find(t=>t.pid===e);if(r===void 0)throw new Error(`Process ${e} is not running`);return r}c(A,"readProcess");function D(e){let n=e.scale??1;if(!(n>0&&n<=1))throw new Error("Image scale must be greater than 0 and at most 1");let r=e.durationSeconds??0,t=e.intervalSeconds??1;if(e.mode==="sequence"){if(!(r>0&&r<=10))throw new Error("Sequence duration must be greater than 0 and at most 10 seconds");if(!(t>0))throw new Error("Sequence interval must be greater than 0 seconds");if(Math.floor(r/t)+1>20)throw new Error("Sequence capture is limited to 20 frames")}if(e.region!==void 0){let{x:i,y:s,width:o,height:a}=e.region;if(i<0||s<0||o<=0||a<=0||i+o>1||s+a>1)throw new Error("Image region x,y,width,height must fit within normalized bounds 0..1")}if(e.cellIndex!==void 0&&e.cellSize===void 0)throw new Error("Image offset requires limit to set the square grid cell size");if(e.cellSize!==void 0&&(!Number.isSafeInteger(e.cellSize)||e.cellSize<=0))throw new Error("Image limit must be a positive integer pixel size");if(e.cellIndex!==void 0&&(!Number.isSafeInteger(e.cellIndex)||e.cellIndex<0))throw new Error("Image offset must be a zero-based cell index");return e}c(D,"validateVisionOptions");async function b(e,n,r){let t=D(n),i=t.mode==="image"?1:Math.floor(t.durationSeconds/t.intervalSeconds)+1,s=[],o=0;for(let a=0;a<i;a+=1){r?.throwIfAborted(),a>0&&await de(t.intervalSeconds*1e3,r);let d=await e();if(o+=d.byteLength,o>I)throw new Error("Captured images exceed the 20MB aggregate limit");for(let l of await ie(d,t))s.push({type:"image",data:Buffer.from(l).toString("base64"),mimeType:"image/png"})}return s}c(b,"captureImages");async function ie(e,n){let r=await te(e),t=n.region??{x:0,y:0,width:1,height:1},i=Math.round(t.x*r.width),s=Math.round(t.y*r.height),o=Math.max(1,Math.round(t.width*r.width)),a=Math.max(1,Math.round(t.height*r.height)),d=n.scale??1,l=Math.max(1,Math.round(o*d)),m=Math.max(1,Math.round(a*d)),w=_(l,m);if(w.getContext("2d").drawImage(r,i,s,o,a,0,0,l,m),n.cellSize===void 0)return[await w.encode("png")];let u=Math.ceil(l/n.cellSize),f=Math.ceil(m/n.cellSize),h=n.cellIndex??0;if(h>=u*f)throw new Error(`Image cell offset ${h} exceeds the ${u}x${f} grid`);let K=h%u,Q=Math.floor(h/u),C=K*n.cellSize,V=Q*n.cellSize,P=Math.min(n.cellSize,l-C),S=Math.min(n.cellSize,m-V),q=_(P,S);return q.getContext("2d").drawImage(w,C,V,P,S,0,0,P,S),[await q.encode("png")]}c(ie,"selectImage");function J(){return{async captureWindow(e,n){if(n?.throwIfAborted(),x())return se(e,n);if(process.platform!=="linux"&&process.platform!=="darwin")throw new Error(`Window capture is unsupported on ${process.platform}`);let{Window:r}=await import("node-screenshots"),t;try{t=r.all()}catch(o){throw new Error(`Desktop window enumeration is unavailable: ${z(o)}`,{cause:o})}let i=t.find(o=>{try{return o.pid()===e}catch{return!1}});if(i===void 0)throw new Error(`No capturable desktop window belongs to PID ${e}`);let s=await i.captureImage();return n?.throwIfAborted(),new Uint8Array(await s.toPng())},async captureDisplay(e,n){if(n?.throwIfAborted(),x())return ae(e,n);if(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32")throw new Error(`Display capture is unsupported on ${process.platform}`);let{Monitor:r}=await import("node-screenshots"),t;try{t=r.all()}catch(o){throw new Error(`Desktop display enumeration is unavailable: ${z(o)}`,{cause:o})}let i=t[e];if(i===void 0)throw new Error(`Display index ${e} is unavailable; found ${t.length} display(s)`);let s=await i.captureImage();return n?.throwIfAborted(),new Uint8Array(await s.toPng())},async captureUrl(e,n){if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Web screenshots require an HTTP(S) URL");let{chromium:r}=await import("playwright-core"),t=await ce(),i=await r.launch({executablePath:t,headless:!0,chromiumSandbox:!1,timeout:3e4}),s=c(()=>{i.close()},"abort");n?.addEventListener("abort",s,{once:!0});try{let o=await i.newPage({viewport:{width:1280,height:720}});return await o.goto(e.href,{waitUntil:"domcontentloaded",timeout:3e4}),await o.waitForLoadState("networkidle",{timeout:1500}).catch(()=>{}),n?.throwIfAborted(),new Uint8Array(await o.screenshot({type:"png",fullPage:!0}))}finally{n?.removeEventListener("abort",s),await i.close().catch(()=>{})}}}}c(J,"createCaptureBackend");async function se(e,n){let r=new URL("windows-window-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await p("wslpath",["-w",r.pathname],{signal:n}),{stdout:i}=await p("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-ProcessId",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(i)}c(se,"captureWslWindow");async function ae(e,n){let r=new URL("windows-display-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await p("wslpath",["-w",r.pathname],{signal:n}),{stdout:i}=await p("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-DisplayIndex",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(i)}c(ae,"captureWslDisplay");function x(){return process.platform==="linux"&&(process.env.WSL_DISTRO_NAME!==void 0||ee.release().toLowerCase().includes("microsoft"))}c(x,"isWsl");async function ce(){let e=process.env.PI_AGENT_IDE_BROWSER_PATH;if(e!==void 0)return e;let{stdout:n}=await p("bash",["-lc","command -v google-chrome-stable || command -v google-chrome || command -v chromium || command -v chromium-browser"]),r=n.trim();if(r.length===0)throw new Error("No Chrome or Chromium executable was found; set PI_AGENT_IDE_BROWSER_PATH");return r}c(ce,"resolveBrowser");function de(e,n){return new Promise((r,t)=>{let i=setTimeout(r,e),s=c(()=>{clearTimeout(i),t(n?.reason??new Error("Capture aborted"))},"abort");n?.addEventListener("abort",s,{once:!0}),i.unref()})}c(de,"delay");function z(e){return e instanceof Error?e.message:String(e)}c(z,"errorMessage");async function ue(e,n){let r=n?.preferences??{};F({durationSeconds:r["vision.sequenceDurationSeconds"],intervalSeconds:r["vision.sequenceIntervalSeconds"],scale:r["vision.imageScale"],allowedExecutables:r["vision.allowedExecutables"]});let t=L(e),i=J();await Promise.all([U(e,{protocol:M,apiVersion:$,id:"vision",setup(s){for(let a of["image","sequence"])s.addView({view:a,presenter:{id:`vision-${a}`,present:c(d=>d,"present")}});s.addHandler({stage:"pre-read",async handler(a){let d=a.request.path;if(d===void 0)return{kind:"continue",context:a};let l=G(d);if(l!==void 0){if(e.getFlag("pi-agent-ide-vision-displays")!==!0)return g(d,"Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.");try{let u=await b(()=>i.captureDisplay(l,a.resolverContext.signal),R(a.request),a.resolverContext.signal);return v(d,u)}catch(u){return g(d,N(u))}}let m=X(d,"process:");if(m!==void 0){let u=await A(m,t);return v(d,[{type:"text",text:Y(u)}])}let w=X(d,"window:");if(w!==void 0){let u=await A(w,t);if(!u.owned&&!H(u.command)&&e.getFlag("pi-agent-ide-vision-arbitrary-windows")!==!0)return g(d,`Window capture for PID ${w} is denied because the process is neither Agent IDE-owned nor allowlisted by executable name. Enable --pi-agent-ide-vision-arbitrary-windows to allow it.`);try{let f=await b(()=>i.captureWindow(w,a.resolverContext.signal),R(a.request),a.resolverContext.signal);return v(d,f)}catch(f){return g(d,N(f))}}if(/^https?:\/\//iu.test(d)&&le(a.request)){let u=new URL(d);try{let f=await b(()=>i.captureUrl(u,a.resolverContext.signal),R(a.request),a.resolverContext.signal);return v(u.href,f)}catch(f){return g(u.href,N(f))}}return{kind:"continue",context:a}}});let o=y();s.describe(`Process metadata: process:PID. Visual capture: window:PID and display: or display:#N. HTTP(S) sources accept image and sequence screenshots. Use named view parameters such as sequence:duration=2,interval=0.5,scale=0.5 and image:scale=0.5,region=0.25,0.25,0.5,0.5. Duration is limited to 10 seconds and sequences to 20 frames. Defaults: duration=${o.durationSeconds}, interval=${o.intervalSeconds}, scale=${o.scale}. Region uses normalized x,y,width,height and runs before scaling. For captures, limit is a square grid cell size in output pixels and offset is one zero-based row-major cell index; limit without offset selects cell 0, while offset without limit is invalid. Omit both for the bounded transformed image.`),s.addPromptGuideline("Use search with process:<query> before reading process:PID or window:PID. Capture arbitrary desktop windows and full displays only when their dedicated flags are enabled; Agent IDE-owned terminal processes are allowed by default. Use a bounded sequence view only when one image is insufficient; set named duration, interval, scale and region parameters when the defaults do not fit. Use limit and offset to select one image grid cell.")}}),k(e,{protocol:O,apiVersion:T,id:"vision-processes",setup(s){s.addResolver({priority:-100,resolver:{id:"processes",async tryResolve(o){let a=/^process:(.*)$/isu.exec(o.query);if(a===null)return{kind:"not-handled"};let d=(a[1]??"").trim().toLowerCase();return{kind:"resolved",payload:(await E(t)).filter(m=>d.length===0||String(m.pid)===d||m.command.toLowerCase().includes(d)).slice(0,Math.min(o.limit??50,100))}},format(o){let a=o;return{content:[{type:"text",text:a.length===0?"No matching processes.":a.map(Y).join(`
|
|
3
|
-
|
|
4
|
-
`)}],details:{count:a.length,processes:a}}}}}),s.describe("process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture."),s.addPromptGuideline("Use process:<query> to discover a PID before selecting a process or window source.")}})])}c(ue,"registerVision");function X(e,n){if(!e.startsWith(n))return;let r=e.slice(n.length);if(!/^\d+$/u.test(r))throw new Error(`${n} sources require a numeric PID`);return Number(r)}c(X,"prefixedPid");function R(e){return{...j(e.views,y())??{mode:"image",...y()},...e.limit===void 0?{}:{cellSize:e.limit},...e.offset===void 0?{}:{cellIndex:e.offset}}}c(R,"options");function le(e){return e.views?.some(n=>/^(?:image|sequence)(?::|$)/u.test(n))===!0}c(le,"requestsScreenshot");function v(e,n){return{kind:"return",result:{content:n,details:{source:e,resolvedBy:"vision"}}}}c(v,"returned");function g(e,n){return{kind:"return",result:{content:[{type:"text",text:n}],details:{source:e,resolvedBy:"vision",failure:{code:"READ_FAILED",source:e,resolverId:"vision",message:n}},isError:!0}}}c(g,"failed");function N(e){return e instanceof Error?e.message:String(e)}c(N,"errorMessage");function Y(e){return[`PID: ${e.pid}`,`Command: ${e.command}`,`Owned by Agent IDE: ${e.owned?"yes":"no"}`,...e.parentPid===void 0?[]:[`Parent PID: ${e.parentPid}`],...e.started===void 0?[]:[`Started: ${e.started}`],...e.source===void 0?[]:[`Agent IDE source: ${e.source}`]].join(`
|
|
5
|
-
`)}c(Y,"formatProcess");export{ue as default};
|
package/dist/chunk-EJ5OACQM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-EI7MMDWY.js";import{readFile as b}from"node:fs/promises";import p from"node:os";import i from"node:path";function I(n=process.env,o=p.homedir(),e=process.cwd()){let r=n.PI_CODING_AGENT_DIR?.trim(),t=r===void 0||r.length===0?i.join(o,".pi","agent"):i.resolve(r);return{globalPath:i.join(t,"pi-agent-ide","extensions.json"),projectPath:i.resolve(e,".pi","pi-agent-ide","extensions.json")}}s(I,"resolvePiAgentIdeExtensionsConfigPaths");async function $(n){let o=await g(n.globalPath),e=await g(n.projectPath);return{disabled:[...new Set([...o.disabled,...e.disabled])],enabled:[...new Set([...o.enabled,...e.enabled])],...o.flags===void 0&&e.flags===void 0?{}:{flags:{...c(o),...c(e)}},...o.preferences===void 0&&e.preferences===void 0?{}:{preferences:{...o.preferences,...e.preferences}},noAnimations:e.noAnimations??o.noAnimations??!1,noPostProcessing:e.noPostProcessing??o.noPostProcessing??!1}}s($,"readPiAgentIdeExtensionsConfig");function c(n){return{...n.noAnimations===void 0?{}:{"pi-agent-ide-no-animations":n.noAnimations},...n.noPostProcessing===void 0?{}:{"pi-agent-ide-no-post-processing":n.noPostProcessing},...n.flags}}s(c,"configuredFeatureFlags");async function h(n){return g(n)}s(h,"readExtensionSettingsScope");async function g(n){let o;try{o=await b(n,"utf8")}catch(r){if(y(r))return{disabled:[],enabled:[]};throw new Error(`Cannot read Pi Agent IDE extension config at ${n}: ${u(r)}`,{cause:r})}let e;try{e=JSON.parse(o)}catch(r){throw new Error(`Invalid JSON in Pi Agent IDE extension config at ${n}: ${u(r)}`,{cause:r})}if(!a(e))throw new Error(`Pi Agent IDE extension config at ${n} must be a JSON object`);return{disabled:f(e,"disabled",n),enabled:f(e,"enabled",n),...e.flags===void 0?{}:{flags:m(e.flags,n)},...e.preferences===void 0?{}:{preferences:w(e.preferences,n)},...e.noAnimations===void 0?{}:{noAnimations:l(e,"noAnimations",n)},...e.noPostProcessing===void 0?{}:{noPostProcessing:l(e,"noPostProcessing",n)}}}s(g,"readConfigExtensionIds");function w(n,o){if(!a(n))throw new Error(`preferences in ${o} must be an object`);let e={};for(let[r,t]of Object.entries(n)){if(typeof t!="string"||t.length===0)throw new Error(`Preference ${r} in ${o} must be a non-empty string`);e[r]=t}return e}s(w,"readPreferences");function m(n,o){if(!a(n))throw new Error(`flags in ${o} must be an object`);let e={};for(let[r,t]of Object.entries(n)){if(typeof t!="boolean")throw new Error(`Flag ${r} in ${o} must be a boolean`);e[r]=t}return e}s(m,"readFlags");function l(n,o,e){let r=n[o];if(typeof r!="boolean")throw new Error(`${o} in ${e} must be a boolean`);return r}s(l,"readBoolean");function f(n,o,e){let r=n[o];if(r===void 0)return[];if(!Array.isArray(r))throw new Error(`${o} in ${e} must be an array of non-empty strings`);let t=r.filter(d=>typeof d=="string");if(t.length!==r.length||t.some(d=>d.length===0))throw new Error(`${o} in ${e} must be an array of non-empty strings`);if(new Set(t).size!==t.length)throw new Error(`${o} in ${e} must not contain duplicate IDs`);return t}s(f,"readIdField");function y(n){return a(n)&&n.code==="ENOENT"}s(y,"isMissingFile");function a(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}s(a,"isRecord");function u(n){return n instanceof Error?n.message:String(n)}s(u,"errorMessage");export{I as a,$ as b,c,h as d};
|
package/dist/chunk-PCZH7GOX.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import{a as re,b as ie,c as oe}from"./chunk-ESPNEJHK.js";import{a as ne}from"./chunk-M5IVSCR2.js";import{a as Z}from"./chunk-L7JMDDSD.js";import{a as z,b as J}from"./chunk-O6LE42GK.js";import{b as R}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as K}from"./chunk-6CZO43OH.js";import{a as Y,b as V}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as te}from"./chunk-ZTYWHL2F.js";import{a as Q,b as ee}from"./chunk-7UGNGK7Y.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Fe from"node:path";import{stripVTControlCharacters as je}from"node:util";import{truncateLine as Ge}from"@earendil-works/pi-coding-agent";import{Text as x}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as se,DEFAULT_MAX_LINES as ae,formatSize as Ue,truncateTail as We}from"@earendil-works/pi-coding-agent";function I(t){return We(t,{maxBytes:se-4096,maxLines:ae-32})}a(I,"terminalOutputTail");function P(t){let e=I(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"?`${ae} line output budget`:`${Ue(se)} 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(P,"formatAgentTerminalSnapshot");var He=500;function le(t,e,n,r,i){let s=e?"background":"wait",o=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${$(n)} \xB7 ${s}`)}`;return new x(`${o}
|
|
9
|
-
${i.fg("accent",O(r.family))} ${t}`,0,0)}a(le,"renderRunCall");function ue(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 x(r.join(`
|
|
10
|
-
`),0,0)}a(ue,"renderTerminalActionResult");function E(t,e,n,r,i){let s=[Ye(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&s.push(...r.map(o=>` ${i.fg("dim",o)}`)),new x(s.join(`
|
|
11
|
-
`),0,0)}a(E,"renderTerminalAction");function S(t,e,n,r){let i=Be(t,R,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),new x(i.join(`
|
|
12
|
-
`),0,0)}a(S,"renderTerminalResult");function ce(t,e,n){if(e)return S(t,!0,n);let r=_(t.output??"",R),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(s=>` ${n.fg("dim",s)}`)];return i.push(D(t,(s,o)=>n.fg(s,o))),new x(i.join(`
|
|
13
|
-
`),0,0)}a(ce,"renderRunResult");function de(t,e){let n=a((o,l)=>e?.fg(o,l)??l,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${$(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",O(t.shellFamily))} ${M(t.command,84)}`],s=qe(t.output,2);return s.length>0&&i.push(...s.map(o=>` ${n("dim",M(o,90))}`)),i.push(D(t,n)),i.join(`
|
|
14
|
-
`)}a(de,"renderActiveTerminal");function Be(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",s=t.cwd===void 0?"workspace":$(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=_(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(D(t,(c,d)=>n.fg(c,d))),l}a(Be,"terminalCardLines");function qe(t,e){return _(t,e).lines}a(qe,"outputTail");function _(t,e){let n=I(je(t).replaceAll("\r","")),r=n.content.split(`
|
|
15
|
-
`).map(u=>Ge(u.trimEnd(),He).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(_,"outputWindow");function D(t,e){let n=t.status??"running",r=Xe(n),i=n==="completed"?"success":n==="running"?"accent":"error",s=[`${r} ${n}`,Ve(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(D,"statusLine");function Xe(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}a(Xe,"statusIcon");function O(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}a(O,"promptMarker");function Ye(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":$(t.cwd),i=t.background===!0?"background":"wait",s=M(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${s}`)}`}a(Ye,"terminalIdentity");function $(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${Fe.sep}`))?`~${t.slice(e.length)}`:t}a($,"shortCwd");function M(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}a(M,"oneLine");function Ve(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(Ve,"formatElapsed");function me(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=>de(e,n).split(`
|
|
16
|
-
`),"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(me,"terminalProcessProvider");var Ke="#d8dee9",N="#111418",ze=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function U(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||Je(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(U,"renderTerminalScreen");function Je(t,e,n,r){let i=pe(e,"foreground"),s=pe(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(Je,"drawCell");function pe(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?Ke:N;let i=n?t.isFgRGB():t.isBgRGB(),s=n?t.getFgColor():t.getBgColor();return i?`#${s.toString(16).padStart(6,"0")}`:Ze(s)}a(pe,"cellColor");function Ze(t){let e=ze[t];if(e!==void 0)return e;if(t>=232){let l=8+(t-232)*10;return fe(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 fe(o(r),o(i),o(s))}a(Ze,"ansiColor");function fe(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}a(fe,"rgb");var W="\0pi-terminal-write\0",F="\0pi-terminal-keys\0";async function Se(t,e){let n=new Map,r=new Map,i={protocol:Y,apiVersion:V,id:"terminal",setup(o){o.addResolver({resolver:Qe(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(`
|
|
17
|
-
`)},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:ge(u,`Unknown terminal session ${u}`)};try{return e.markInspected(u),{kind:"return",result:{content:[{type:"image",data:await U(e,u),mimeType:"image/png"}],details:{source:c.source,resolvedBy:"terminal"}}}}catch(d){return{kind:"return",result:ge(u,d instanceof Error?d.message:String(d))}}}}),o.describe('shell:<session> \u2014 terminal session status and a bounded output tail with a full-log path when truncated. Use views: ["image"] to read the current virtual terminal screen as a PNG.'),o.addPromptGuideline("Use read with a returned shell:<session> source to inspect terminal status and output. Add the image view when cursor movement, ANSI layout, or a full-screen terminal interface matters.")}},s={protocol:z,apiVersion:J,id:"terminal",setup(o){o.addResolver({resolver:et(e)}),o.tool("write").addHandler({stage:"text-pre-edit",handler:a(async l=>(ye(l.input,e,n),await he(l.input,e,r),tt(l,W)),"handler")}),o.tool("insert").addHandler({stage:"text-pre-edit",handler:a(async l=>(await he(l.input,e,r),ye(l.input,e,n),nt(l)),"handler")});for(let l of["write","insert","delete"])o.addToolRenderer({tool:l,matches:a((u,c)=>st(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)),E(f.snapshot??{},l,we(l,m),[],c)},renderResult(u,c,d){let m=ot(u.details);return ue(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([K(t,i),Z(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 Ne=e.snapshot(X);return e.delete(u).then(()=>({content:[{type:"text",text:`Deleted terminal session ${u}.`}],details:{source:u,deleted:!0,snapshot:Ne,action:"delete",input:"session",changedLines:[]},isError:!1}),L=>({content:[{type:"text",text:L instanceof Error?L.message:String(L)}],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,v=we(h,o.input),b=e.screenChangeRegion(d,m,6),q=[{type:"text",text:`Sent ${v} to ${d.source}.`}];return l.model?.input.includes("image")===!0&&q.push({type:"image",data:await U(e,c,{start:b.startRow,count:b.lines.length}),mimeType:"image/png"}),{content:q,details:{source:d.source,action:h,status:d.status,snapshot:f,input:v,changedLines:b.lines},isError:o.isError}})}a(Se,"registerTerminalResources");function Qe(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:rt(r)}]}}}}}}a(Qe,"createReadResolver");function et(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=it(r),s=i.indexOf(W),o=i.indexOf(F);if(s>=0){t.write(n.source,i.slice(s+W.length));return}if(o>=0){t.sendKeys(n.source,i.slice(o+F.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}a(et,"createInputResolver");function tt(t,e){return!w(t.input)||!Te(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}a(tt,"transformWriteInput");function nt(t){if(!w(t.input)||!Te(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:`${F}${typeof t.input.text=="string"?t.input.text:""}`}}}a(nt,"transformInsertInput");function rt(t){return P(t)}a(rt,"formatSnapshot");function it(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}a(it,"singleText");function ge(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}a(ge,"failure");function y(t){return/^shell:[a-f\d]{12}$/u.test(t)}a(y,"isShellSource");function Te(t){return typeof t=="string"&&y(t)}a(Te,"isShellSourceValue");function ot(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(ot,"terminalActionDetails");async function he(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(he,"rememberScreen");function ye(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(ye,"rememberOutputEnd");function we(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(we,"terminalInputLabel");function st(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(st,"isTerminalRenderValue");function w(t){return typeof t=="object"&&t!==null}a(w,"isRecord");async function Re(t,e){await te(t,{protocol:Q,apiVersion:ee,id:"terminal",setup(r){r.addResolver({resolver:at(e),priority:100}),r.describe("path shell:<session> searches the retained text output of that terminal, including rows outside its current screen."),r.addPromptGuideline("Use search with path shell:<session> to find text in retained terminal output. Read the same shell source with the returned line number when more context is needed.")}})}a(Re,"registerTerminalSearch");function at(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=lt(r,e);return{kind:"resolved",payload:{snapshot:r,query:e.query,matches:i}}},format(e){let n=j(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(`
|
|
18
|
-
`)}
|
|
19
|
-
|
|
20
|
-
${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=H(i)?j(i.payload):j(void 0),o=E(s.snapshot,"search",JSON.stringify(s.query),s.matches.slice(-6).map(l=>`${l.lineNumber}: ${l.lineText}`),r);return new G(o,n.expanded===!0,r)}}}a(at,"terminalSearchResolver");var be=12,G=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<=be)return n;let r=be-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 lt(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(`
|
|
21
|
-
`).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||ut(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(lt,"findTerminalMatches");function ut(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}a(ut,"isWordBoundary");function j(t){if(!ct(t))throw new TypeError("Invalid terminal search result");return t}a(j,"parsePayload");function ct(t){return H(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&H(t.snapshot)&&typeof t.snapshot.source=="string"}a(ct,"isTerminalSearchPayload");function H(t){return typeof t=="object"&&t!==null}a(H,"isRecord");import{spawn as dt}from"node:child_process";import{closeSync as mt,mkdirSync as pt,openSync as ft,rmSync as gt,writeSync as ht}from"node:fs";import yt from"node:os";import xe from"node:path";import{createRequire as wt}from"node:module";import{randomUUID as St}from"node:crypto";import{stripVTControlCharacters as Tt}from"node:util";var Ee=wt(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),ve=1e6,bt=100,Rt=30,xt=2e3,A=class{static{a(this,"TerminalSessionManager")}#a;#e=new Map;#t=new Set;#r=new Set;#i=new Map;#o=!1;constructor(e=Et){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($t(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=Mt(n);this.#i.set(n,ft(r,"a",384));let i=e.cols??bt,s=e.rows??Rt,o=Pt(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=Ee("node-pty"),f={name:"xterm-256color",cols:i,rows:s,cwd:e.cwd,env:kt(At())};d=p.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],f)}catch(p){let f={...c,status:"failed",endedAt:Date.now(),error:It(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})=>{T(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 T(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(T(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&&T(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]??"",v=h.length>0&&!n.includes(h),b=f.length>0&&h.length===0;f!==h&&(v||b)&&(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(Ct(n))}async stop(e,n="stopped"){let r=this.required(e);return T(r.status)||(r.status="stopping",this.#n(r),await Pe(r,!1),await Promise.race([r.completion.then(()=>!0),B(xt).then(()=>!1)])||(await Pe(r,!0),await Promise.race([r.completion,B(1e3)])),T(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),gt(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=>!T(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=Tt(n),i=this.#i.get(e.id);if(i!==void 0&&ht(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&&(mt(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 Pt(t,e){let{Terminal:n}=Ee("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}a(Pt,"createScreen");function Et(){return St().replaceAll("-","").slice(0,12)}a(Et,"defaultSessionId");function $t(t){return t.startsWith("shell:")?t.slice(6):t}a($t,"normalizeSessionId");function T(t){return t!=="running"&&t!=="stopping"}a(T,"isTerminalStatus");function At(){return process.env}a(At,"processEnvironment");function kt(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(kt,"cleanEnvironment");function Ct(t){return t.split(/[\s,]+/u).filter(Boolean).map(Lt).join("")}a(Ct,"encodeTerminalKeys");function Lt(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(Lt,"encodeTerminalKey");async function Pe(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=dt("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}a(Pe,"terminateProcessTree");function B(t){return new Promise(e=>setTimeout(e,t))}a(B,"delay");function It(t){return t instanceof Error?t.message:String(t)}a(It,"errorMessage");function Mt(t){let e=xe.join(yt.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return pt(e,{recursive:!0,mode:448}),xe.join(e,`${t}.log`)}a(Mt,"createOutputLog");import _t from"node:os";import $e from"node:path";function Ae(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",s=$e.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()||_t.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=$e.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:a(i=>["-c",i],"commandArgs")}}a(Ae,"resolveShellProfile");function ke(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(ke,"shellSyntaxGuidance");import Ce from"node:path";import{stripVTControlCharacters as Dt}from"node:util";import{defineTool as Ot}from"@earendil-works/pi-coding-agent";import{Type as g}from"typebox";var Nt=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 Le(t,e,n,r){let i=process.platform==="win32"?"powershell":"bash";t.registerTool(Ot({name:i,label:n.displayName,promptSnippet:`Execute ${n.displayName} commands in synchronous or background terminal sessions`,promptGuidelines:[`Write commands for ${n.displayName}; commands are not translated between shell languages.`,`Use ${i} with background for servers, watchers, and long builds. After a session enters background, do not poll it continuously; continue other work or wait for completion. Keep short tasks in the foreground. Enable periodic or verbose output for long-running commands. Use the returned shell: source with read, write, insert, and delete.`],description:`Use ${i} 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. ${ke(n)}`,parameters:Nt,async execute(s,o,l,u,c){r.bind(c);let d=o.cwd===void 0?c.cwd:Ce.resolve(c.cwd,o.cwd),m=e.start({command:o.command,background:o.background??!1,cwd:d,shell:n,...o.cols===void 0?{}:{cols:o.cols},...o.rows===void 0?{}:{rows:o.rows}});if(o.background===!0&&m.status!=="failed")return await Ut(e,m,u),m.status!=="running"&&(m.completionDelivered=!0),k(e.snapshot(m));if(m.status==="failed")return k(e.snapshot(m));let p=await e.waitForForeground(m.source,{signal:l,timeoutMs:(o.timeoutSeconds??60)*1e3});return p.reason==="aborted"&&r.notifyWaitTransition(p.session),k(e.snapshot(p.session))},renderCall(s,o){let l=typeof s.command=="string"?s.command:"",u=typeof s.cwd=="string"?Ce.resolve(process.cwd(),s.cwd):process.cwd();return le(l,s.background===!0,u,n,o)},renderResult(s,o,l){return ce(s.details,o.expanded,l)}}))}a(Le,"registerTerminalTools");function k(t){return{content:[{type:"text",text:P(t)}],details:t,isError:t.status==="failed"||t.status==="lost"}}a(k,"terminalResult");async function Ut(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?.(k(c)),(Dt(c.output).replaceAll("\r","").split(`
|
|
22
|
-
`).filter(m=>m.length>0).length>=R||c.status!=="running")&&l()},"publish");o=t.onDidChange(c=>{c.id===e.id&&u()}),s=setTimeout(l,2e3),u()})}a(Ut,"captureInitialBackgroundPreview");import{Box as Ie,Container as Me}from"@earendil-works/pi-tui";var Wt=120,Ft=12e4,C=class{constructor(e,n,r=Ft){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:s},o)=>{let l=_e(i.details)?i.details:void 0,u=new Me;l!==void 0&&u.addChild(S(l,s,o,"stale \xB7 inspect session"));let c=new Ie(1,1,d=>o.bg("toolPendingBg",d));return c.addChild(u),c}),e.registerMessageRenderer("terminal-completion",(i,{expanded:s},o)=>{let l=new Me;for(let c of jt(i.details))l.addChild(S(c,s,o));let u=new Ie(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:Ht(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:Gt(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"})},Wt)))}};function jt(t){return!Oe(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(_e)}a(jt,"completionSnapshots");function _e(t){return Oe(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(_e,"isTerminalSessionSnapshot");function Gt(t){return`${t.length===1?"Background terminal completed:":"Background terminals completed:"}
|
|
23
|
-
${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}, ${De(n.elapsedMs)}
|
|
24
|
-
${s||"(no output)"}`}).join(`
|
|
25
|
-
`)}`}a(Gt,"formatCompletionMessage");function Ht(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${De(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
26
|
-
${e||"(no output)"}`}a(Ht,"formatStaleMessage");function De(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(De,"formatElapsed");function Oe(t){return typeof t=="object"&&t!==null}a(Oe,"isRecord");async function Bt(t){let e=ie("terminal")??new A,n=Ae(),r=new C(t,e),i=ne(t).add(me(e));await Promise.all([Se(t,e),Re(t,e)]),Le(t,e,n,r),t.on("session_start",(s,o)=>r.bind(o)),t.on("agent_settled",(s,o)=>r.onAgentSettled(o)),t.on("session_shutdown",async s=>{if(r.dispose(),i(),s.reason!=="quit"){re("terminal",e);return}oe("terminal",e),await e.dispose()})}a(Bt,"registerTerminal");export{Bt as default};
|
package/dist/chunk-SQ7ZTGOP.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as O}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as N}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as E}from"./chunk-6CZO43OH.js";import{a as A,b}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{e as m,f as D,g as w,h as k,i as P,l as v}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as C}from"./chunk-HKMBQLEK.js";import{a as y,b as I}from"./chunk-Z3VC3S2T.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import S from"node:path";var T="diagnostics",V=N({kind:"code-view",label:"Diagnostics"});async function q(c){let n,t=l((o,f,e)=>{if(n===void 0)throw new Error("IDE diagnostics are not connected");return n(o,{cwd:f,...e})},"collect"),i={protocol:y,apiVersion:4,id:"diagnostics",setup(o){n=o.readDiagnostics}},r=new WeakMap,s=new WeakMap,a=new WeakMap,d=new WeakMap,M={protocol:A,apiVersion:b,id:"diagnostics",setup(o){o.addResolver({resolver:W(t,s),renderResult:V});let f=v();o.addView({view:"diagnostics",priority:100,presenter:j(t,d)}),o.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let g=e.state.content[0],u=s.get(g);return u&&r.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}}}),o.addHandler({stage:"post-read",handler(e){let g=r.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),h=u&&d.get(u),p=e.result,R=p?.content[0];return!h||!p||R?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:{...e,result:{...p,content:[{...R,text:`${h}
|
|
2
|
-
${R.text}`},...p.content.slice(1)]}}}}}),o.describe('diagnostics:<path> \u2014 lint and language-server diagnostics. views: ["diagnostics"] \u2014 diagnostics alongside source text. Diagnostic sources name the actual reporting tools. Automatic notices include findings only and wake an idle agent after the notification buffer (five seconds by default); silence does not prove the file is clean. Use an explicit diagnostic read to check readiness. Pending results and snapshots are not completed checks; an empty snapshot does not prove the file is clean.'),o.addPromptGuideline("Use read with `diagnostics:<path>` or the `diagnostics` view for per-file diagnostics instead of running equivalent checks through Bash. Project builds and tests remain separate verification.")}};await Promise.all([C(c,i),E(c,M)])}l(q,"registerDiagnostics");function W(c,n){return{id:"diagnostics",tryResolve(t,i){return Promise.resolve(_(t,i.cwd,c,n,{signal:i.signal,...i.audience==="script"&&{mode:"complete"}}))}}}l(W,"createDiagnosticResolver");function _(c,n,t,i,r){let s;try{s=m(c,T,n)}catch(a){return{kind:"failed",error:a}}return s===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:D(T,s),async read(){let a=await t(s,n,r),d=w(s,a.content,a.results);return i.set(d,d.diagnosticCheck),[d]}}}}l(_,"resolveDiagnosticSource");function j(c,n){return{id:"diagnostics",async present(t,i){if(i.purpose!=="read"||!S.isAbsolute(t.source))return t;let r=i.audience==="script"&&!i.requestedViews?.includes("diagnostics");if(r&&O(t.source))return t;let s=await c(t.source,i.cwd,{signal:i.signal,...i.audience==="script"&&{mode:r?"snapshot":"complete"}}).catch(a=>{if(i.signal?.throwIfAborted(),!r)throw a});if(s===void 0||r&&s.content!==t.content)return t;if(s.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,P(s.results)),k(t,s.results)}}}l(j,"createDiagnosticPresenter");export{q as default};
|
package/dist/entry-18.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-K4ZMRDEI.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-18.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-27.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-29.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-35.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-36.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-37.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/entry-45.js";
|