pi-agent-ide 0.6.0 → 0.6.2
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 +41 -0
- package/README.md +146 -68
- package/assets/social-preview.png +0 -0
- package/assets/summary/debugging.png +0 -0
- package/assets/summary/editing.png +0 -0
- package/assets/summary/read.png +0 -0
- package/assets/summary/search-and-replace.png +0 -0
- package/assets/summary/search.png +0 -0
- package/assets/summary/settings.png +0 -0
- package/assets/summary/terminal.png +0 -0
- package/assets/summary/thumbs/debugging.png +0 -0
- package/assets/summary/thumbs/editing.png +0 -0
- package/assets/summary/thumbs/read.png +0 -0
- package/assets/summary/thumbs/search-and-replace.png +0 -0
- package/assets/summary/thumbs/search.png +0 -0
- package/assets/summary/thumbs/settings.png +0 -0
- package/assets/summary/thumbs/terminal.png +0 -0
- package/assets/summary/thumbs/user_terminal.png +0 -0
- package/assets/summary/user_terminal.png +0 -0
- package/dist/chunk-3E2NTWCN.js +2 -0
- package/dist/chunk-7WCZOO5I.js +1 -0
- package/dist/chunk-CEX3VOJ7.js +2 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
- package/dist/chunk-LVWMWWWF.js +28 -0
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
- package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
- package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
- package/dist/chunk-T7CZIACQ.js +27 -0
- package/dist/chunk-T7I2VX3J.js +1 -0
- package/dist/chunk-VCTK4JSN.js +3 -0
- package/dist/chunk-VXD6FZP5.js +5 -0
- package/dist/chunk-W7CASEO3.js +1 -0
- package/dist/chunk-YT42LKFV.js +16 -0
- package/dist/entry-1.js +1 -1
- 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-2.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 +13 -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 +10 -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 +1 -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 +0 -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 +1 -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 +0 -30
- package/dist/entry-74.js +1 -2
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +315 -3
- package/dist/entry-78.js +30 -3
- package/dist/entry-79.js +2 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +3 -0
- package/dist/entry-83.js +3 -0
- package/dist/entry-84.js +1 -0
- package/dist/entry-85.js +1 -0
- package/dist/entry-86.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 +12 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
- 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 +17 -9
- package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
- package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-55.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-56.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-58.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-60.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/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/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-80.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-84.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
- package/package.json +108 -44
- package/src/api/documentation.ts +2 -0
- package/src/api/plugin-protocol.ts +10 -4
- 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-html/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-84.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-85.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-86.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.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 +17 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
- 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-56.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-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.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-59.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.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-78.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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
- 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 +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.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 +12 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
- 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 +44 -14
- package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
- package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
- 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 +88 -12
- package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
- 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 +10 -7
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
- package/assets/gallery/apply-editing.png +0 -0
- package/assets/gallery/debugging.png +0 -0
- package/assets/gallery/read-web.png +0 -0
- package/assets/gallery/search-replace.png +0 -0
- package/assets/gallery/terminal.png +0 -0
- package/assets/gallery/tool-editing.png +0 -0
- 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-HSM6R7IB.js +0 -27
- 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-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/runtime/entry-60.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-web-pdf/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-web-text/runtime/entry-81.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/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.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-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/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-60.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-anchor-line-hash → pi-agent-search-text}/runtime/entry-54.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-75.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-text-editor}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-text-editor-stale-anchor}/runtime/entry-79.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-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-text-editor/plugins/pi-agent-text-anchor-line-hash → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-54.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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
4
|
|
|
4
5
|
import { sameFilePath } from "pi-agent-ide/api/path-identity";
|
|
@@ -31,7 +32,22 @@ export async function runConfiguredLinter(
|
|
|
31
32
|
let result: ProcessResult;
|
|
32
33
|
|
|
33
34
|
try {
|
|
34
|
-
|
|
35
|
+
const executable = path.basename(config.check.command[0] ?? "").toLocaleLowerCase();
|
|
36
|
+
const isRuff = executable === "ruff" || executable === "ruff.exe";
|
|
37
|
+
const inheritedEnvironment = context.env ?? process.env;
|
|
38
|
+
result = await runConfiguredProcess(config.check, {
|
|
39
|
+
...context,
|
|
40
|
+
...(isRuff
|
|
41
|
+
? {
|
|
42
|
+
env: {
|
|
43
|
+
...inheritedEnvironment,
|
|
44
|
+
RUFF_CACHE_DIR:
|
|
45
|
+
inheritedEnvironment.RUFF_CACHE_DIR ??
|
|
46
|
+
path.join(os.tmpdir(), "pi-agent-ide", "ruff-cache"),
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
50
|
+
});
|
|
35
51
|
} catch (error) {
|
|
36
52
|
return {
|
|
37
53
|
ok: false,
|
|
@@ -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.2",
|
|
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.2",
|
|
8
|
+
"pi-agent-invariant": "0.6.2",
|
|
9
|
+
"pi-agent-read": "0.6.2",
|
|
10
|
+
"pi-agent-resource": "0.6.2",
|
|
11
|
+
"pi-agent-search": "0.6.2",
|
|
12
|
+
"pi-agent-text": "0.6.2",
|
|
13
|
+
"pi-agent-text-editor": "0.6.2",
|
|
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.2"
|
|
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)}`]),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
READ_API_VERSION,
|
|
3
5
|
READ_PROTOCOL,
|
|
@@ -27,6 +29,56 @@ import type { TerminalSessionSnapshot } from "#src/plugins/pi-agent-ide-terminal
|
|
|
27
29
|
const WRITE_PREFIX = "\u0000pi-terminal-write\u0000";
|
|
28
30
|
const KEYS_PREFIX = "\u0000pi-terminal-keys\u0000";
|
|
29
31
|
|
|
32
|
+
interface TerminalVisualView {
|
|
33
|
+
readonly mode: "image" | "sequence";
|
|
34
|
+
readonly duration: number;
|
|
35
|
+
readonly interval: number;
|
|
36
|
+
readonly scale: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Parse the bounded image or sequence view requested for a terminal screen. */
|
|
40
|
+
export function parseTerminalVisualView(
|
|
41
|
+
views: readonly string[] | undefined,
|
|
42
|
+
): TerminalVisualView | undefined {
|
|
43
|
+
const selected = views?.find(
|
|
44
|
+
(view) =>
|
|
45
|
+
view === "image" ||
|
|
46
|
+
view === "sequence" ||
|
|
47
|
+
view.startsWith("image:") ||
|
|
48
|
+
view.startsWith("sequence:"),
|
|
49
|
+
);
|
|
50
|
+
if (selected === undefined) return undefined;
|
|
51
|
+
const separator = selected.indexOf(":");
|
|
52
|
+
const mode = (separator < 0 ? selected : selected.slice(0, separator)) as "image" | "sequence";
|
|
53
|
+
const values = new Map<string, number>();
|
|
54
|
+
if (separator >= 0) {
|
|
55
|
+
for (const parameter of selected.slice(separator + 1).split(",")) {
|
|
56
|
+
const [name, raw, extra] = parameter.split("=");
|
|
57
|
+
if (name === undefined || raw === undefined || extra !== undefined || raw.length === 0)
|
|
58
|
+
throw new Error(`Invalid terminal ${mode} view parameter: ${parameter}`);
|
|
59
|
+
if (name !== "duration" && name !== "interval" && name !== "scale")
|
|
60
|
+
throw new Error(`Unsupported terminal ${mode} view parameter: ${name}`);
|
|
61
|
+
const value = Number(raw);
|
|
62
|
+
if (!Number.isFinite(value)) throw new Error(`Terminal ${name} must be a number`);
|
|
63
|
+
values.set(name, value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const duration = values.get("duration") ?? 2;
|
|
67
|
+
const interval = values.get("interval") ?? 0.5;
|
|
68
|
+
const scale = values.get("scale") ?? 1;
|
|
69
|
+
if (!(scale > 0 && scale <= 1))
|
|
70
|
+
throw new Error("Terminal image scale must be greater than 0 and at most 1");
|
|
71
|
+
if (mode === "sequence") {
|
|
72
|
+
if (!(duration > 0 && duration <= 10))
|
|
73
|
+
throw new Error("Terminal sequence duration must be greater than 0 and at most 10 seconds");
|
|
74
|
+
if (!(interval > 0))
|
|
75
|
+
throw new Error("Terminal sequence interval must be greater than 0 seconds");
|
|
76
|
+
if (Math.floor(duration / interval) + 1 > 20)
|
|
77
|
+
throw new Error("Terminal sequence capture is limited to 20 frames");
|
|
78
|
+
}
|
|
79
|
+
return { mode, duration, interval, scale };
|
|
80
|
+
}
|
|
81
|
+
|
|
30
82
|
type TerminalAction = "write" | "insert" | "delete";
|
|
31
83
|
interface TerminalActionDetails {
|
|
32
84
|
readonly source: string;
|
|
@@ -71,13 +123,19 @@ export async function registerTerminalResources(
|
|
|
71
123
|
stage: "pre-read",
|
|
72
124
|
async handler(context) {
|
|
73
125
|
const source = context.request.path;
|
|
74
|
-
if (
|
|
75
|
-
source === undefined ||
|
|
76
|
-
!isShellSource(source) ||
|
|
77
|
-
context.request.views?.includes("image") !== true
|
|
78
|
-
) {
|
|
126
|
+
if (source === undefined || !isShellSource(source)) {
|
|
79
127
|
return { kind: "continue", context };
|
|
80
128
|
}
|
|
129
|
+
let visual: TerminalVisualView | undefined;
|
|
130
|
+
try {
|
|
131
|
+
visual = parseTerminalVisualView(context.request.views);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return {
|
|
134
|
+
kind: "return",
|
|
135
|
+
result: failure(source, error instanceof Error ? error.message : String(error)),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (visual === undefined) return { kind: "continue", context };
|
|
81
139
|
const session = manager.get(source);
|
|
82
140
|
if (session === undefined) {
|
|
83
141
|
return {
|
|
@@ -87,12 +145,33 @@ export async function registerTerminalResources(
|
|
|
87
145
|
}
|
|
88
146
|
try {
|
|
89
147
|
manager.markInspected(source);
|
|
90
|
-
const
|
|
148
|
+
const count =
|
|
149
|
+
visual.mode === "image" ? 1 : Math.floor(visual.duration / visual.interval) + 1;
|
|
150
|
+
const content: Array<{
|
|
151
|
+
readonly type: "image";
|
|
152
|
+
readonly data: string;
|
|
153
|
+
readonly mimeType: "image/png";
|
|
154
|
+
}> = [];
|
|
155
|
+
for (let frame = 0; frame < count; frame += 1) {
|
|
156
|
+
context.resolverContext.signal?.throwIfAborted();
|
|
157
|
+
if (frame > 0) {
|
|
158
|
+
await delay(visual.interval * 1_000, undefined, {
|
|
159
|
+
signal: context.resolverContext.signal,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const data = await renderTerminalScreen(manager, source, undefined, visual.scale);
|
|
163
|
+
content.push({ type: "image", data, mimeType: "image/png" });
|
|
164
|
+
}
|
|
91
165
|
return {
|
|
92
166
|
kind: "return",
|
|
93
167
|
result: {
|
|
94
|
-
content
|
|
95
|
-
details: {
|
|
168
|
+
content,
|
|
169
|
+
details: {
|
|
170
|
+
source: session.source,
|
|
171
|
+
resolvedBy: "terminal",
|
|
172
|
+
frames: count,
|
|
173
|
+
mode: visual.mode,
|
|
174
|
+
},
|
|
96
175
|
},
|
|
97
176
|
};
|
|
98
177
|
} catch (error) {
|
|
@@ -104,10 +183,7 @@ export async function registerTerminalResources(
|
|
|
104
183
|
},
|
|
105
184
|
});
|
|
106
185
|
api.describe(
|
|
107
|
-
|
|
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.",
|
|
186
|
+
"shell:<session> — terminal status and a bounded output tail with a full-log path when truncated. image and parameterized sequence views return the virtual terminal screen as ordered PNG frames.",
|
|
111
187
|
);
|
|
112
188
|
},
|
|
113
189
|
} satisfies ReadPlugin;
|
|
@@ -33,6 +33,7 @@ export async function renderTerminalScreen(
|
|
|
33
33
|
manager: TerminalSessionManager,
|
|
34
34
|
source: string,
|
|
35
35
|
rows?: { readonly start: number; readonly count: number },
|
|
36
|
+
scale = 1,
|
|
36
37
|
): Promise<string> {
|
|
37
38
|
const session = manager.get(source);
|
|
38
39
|
if (session === undefined) throw new Error(`Unknown terminal session ${source}`);
|
|
@@ -40,11 +41,14 @@ export async function renderTerminalScreen(
|
|
|
40
41
|
const { createCanvas } = await import("@napi-rs/canvas");
|
|
41
42
|
const startRow = Math.max(0, Math.min(session.rows - 1, rows?.start ?? 0));
|
|
42
43
|
const rowCount = Math.max(1, Math.min(session.rows - startRow, rows?.count ?? session.rows));
|
|
44
|
+
const width = session.cols * CELL_WIDTH + PADDING * 2;
|
|
45
|
+
const height = rowCount * CELL_HEIGHT + PADDING * 2;
|
|
43
46
|
const canvas = createCanvas(
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
Math.max(1, Math.round(width * scale)),
|
|
48
|
+
Math.max(1, Math.round(height * scale)),
|
|
46
49
|
);
|
|
47
50
|
const context = canvas.getContext("2d");
|
|
51
|
+
context.scale(scale, scale);
|
|
48
52
|
context.fillStyle = DEFAULT_BACKGROUND;
|
|
49
53
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
50
54
|
context.textBaseline = "top";
|
|
@@ -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"],
|
|
@@ -92,7 +100,8 @@ export default async function registerVision(
|
|
|
92
100
|
|
|
93
101
|
try {
|
|
94
102
|
const content = await captureImages(
|
|
95
|
-
() =>
|
|
103
|
+
() =>
|
|
104
|
+
backend.captureWindow(windowPid, metadata.host, context.resolverContext.signal),
|
|
96
105
|
options(context.request),
|
|
97
106
|
context.resolverContext.signal,
|
|
98
107
|
);
|
|
@@ -121,9 +130,6 @@ export default async function registerVision(
|
|
|
121
130
|
api.describe(
|
|
122
131
|
`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
132
|
);
|
|
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
133
|
},
|
|
128
134
|
}),
|
|
129
135
|
connectSearchPlugin(pi, {
|
|
@@ -169,9 +175,6 @@ export default async function registerVision(
|
|
|
169
175
|
api.describe(
|
|
170
176
|
"process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture.",
|
|
171
177
|
);
|
|
172
|
-
api.addPromptGuideline(
|
|
173
|
-
"Use process:<query> to discover a PID before selecting a process or window source.",
|
|
174
|
-
);
|
|
175
178
|
},
|
|
176
179
|
}),
|
|
177
180
|
]);
|
|
@@ -45,10 +45,16 @@ export interface ProcessMetadata {
|
|
|
45
45
|
readonly started?: string;
|
|
46
46
|
readonly owned: boolean;
|
|
47
47
|
readonly source?: string;
|
|
48
|
+
/** Host process namespace used to select the matching window backend under WSL. */
|
|
49
|
+
readonly host: "local" | "windows";
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export interface CaptureBackend {
|
|
51
|
-
captureWindow(
|
|
53
|
+
captureWindow(
|
|
54
|
+
pid: number,
|
|
55
|
+
host: ProcessMetadata["host"],
|
|
56
|
+
signal?: AbortSignal,
|
|
57
|
+
): Promise<Uint8Array>;
|
|
52
58
|
captureDisplay(index: number, signal?: AbortSignal): Promise<Uint8Array>;
|
|
53
59
|
captureUrl(url: URL, signal?: AbortSignal): Promise<Uint8Array>;
|
|
54
60
|
}
|
|
@@ -179,6 +185,7 @@ export async function listProcesses(registry: AgentIdeProcessRegistry): Promise<
|
|
|
179
185
|
command: item.description,
|
|
180
186
|
owned: true,
|
|
181
187
|
source: item.source,
|
|
188
|
+
host: "local",
|
|
182
189
|
}));
|
|
183
190
|
}
|
|
184
191
|
const { stdout } = await execFileAsync("ps", ["-eo", "pid=,ppid=,lstart=,args="], {
|
|
@@ -196,6 +203,7 @@ export async function listProcesses(registry: AgentIdeProcessRegistry): Promise<
|
|
|
196
203
|
started: match[3],
|
|
197
204
|
command: match[4] ?? "",
|
|
198
205
|
owned: item !== undefined,
|
|
206
|
+
host: "local" as const,
|
|
199
207
|
...(item === undefined ? {} : { source: item.source }),
|
|
200
208
|
},
|
|
201
209
|
];
|
|
@@ -240,6 +248,7 @@ async function listWindowsProcesses(): Promise<ProcessMetadata[]> {
|
|
|
240
248
|
pid: record.Id,
|
|
241
249
|
command: path ?? name,
|
|
242
250
|
owned: false,
|
|
251
|
+
host: "windows",
|
|
243
252
|
...(started === undefined ? {} : { started }),
|
|
244
253
|
},
|
|
245
254
|
];
|
|
@@ -362,12 +371,17 @@ export async function selectImage(
|
|
|
362
371
|
return [await canvas.encode("png")];
|
|
363
372
|
}
|
|
364
373
|
|
|
374
|
+
/** Selects the Windows-host helper only for Windows process identities discovered under WSL. */
|
|
375
|
+
export function usesWindowsHostWindowCapture(wsl: boolean, host: ProcessMetadata["host"]): boolean {
|
|
376
|
+
return wsl && host === "windows";
|
|
377
|
+
}
|
|
378
|
+
|
|
365
379
|
/** Creates the supported local desktop and isolated browser capture backend. */
|
|
366
380
|
export function createCaptureBackend(): CaptureBackend {
|
|
367
381
|
return {
|
|
368
|
-
async captureWindow(pid, signal) {
|
|
382
|
+
async captureWindow(pid, host, signal) {
|
|
369
383
|
signal?.throwIfAborted();
|
|
370
|
-
if (isWsl()) return captureWslWindow(pid, signal);
|
|
384
|
+
if (usesWindowsHostWindowCapture(isWsl(), host)) return captureWslWindow(pid, signal);
|
|
371
385
|
if (process.platform !== "linux" && process.platform !== "darwin")
|
|
372
386
|
throw new Error(`Window capture is unsupported on ${process.platform}`);
|
|
373
387
|
const { Window } = await import("node-screenshots");
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
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};
|