pi-agent-ide 0.4.0 → 0.5.0
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 +7 -7
- package/dist/chunk-25CZ5ZIU.js +3 -0
- package/dist/chunk-526E364R.js +3 -0
- package/dist/chunk-5PLV4HLG.js +1 -0
- package/dist/chunk-5QQABP47.js +14 -0
- package/dist/{chunk-72EEL2DW.js → chunk-6CZO43OH.js} +1 -1
- package/dist/chunk-AWXVJ5AC.js +1 -0
- package/dist/chunk-BGUSBUUD.js +26 -0
- package/dist/{chunk-GFW5QPQV.js → chunk-DQXPQOF7.js} +1 -1
- package/dist/chunk-ESPNEJHK.js +1 -0
- package/dist/chunk-G725MARR.js +16 -0
- package/dist/{chunk-M5L42DWE.js → chunk-HKXDP2FD.js} +2 -2
- package/dist/chunk-IQD6PON5.js +0 -0
- package/dist/chunk-J4RTW44E.js +1 -0
- package/dist/{chunk-HGPUI7F3.js → chunk-KII2JQC5.js} +1 -1
- package/dist/{chunk-TI5GMJ7Q.js → chunk-L7JMDDSD.js} +1 -1
- package/dist/{chunk-6DZA4CLO.js → chunk-LY6U5EAD.js} +1 -1
- package/dist/{chunk-ERVMDQGX.js → chunk-MGCHOGQD.js} +1 -1
- package/dist/{chunk-Y7ZMR4LT.js → chunk-O6LE42GK.js} +1 -1
- package/dist/{chunk-KAB3AYA2.js → chunk-OBNING2A.js} +1 -1
- package/dist/chunk-QH4ZUDOD.js +1 -0
- package/dist/{chunk-VFBLX4TG.js → chunk-T6LX2RX5.js} +1 -1
- package/dist/{chunk-AADJ2KIB.js → chunk-U22JNO6N.js} +1 -1
- package/dist/chunk-U2JKHKLK.js +0 -0
- package/dist/{chunk-DQF5QMJ2.js → chunk-WGGIQ7IJ.js} +1 -1
- package/dist/chunk-ZG2MWXCR.js +2 -0
- package/dist/chunk-ZUMN6U77.js +27 -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 -0
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -2
- package/dist/entry-22.js +2 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +1 -12
- package/dist/entry-27.js +12 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +1 -4
- package/dist/entry-32.js +3 -8
- package/dist/entry-33.js +9 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-40.js +1 -18
- package/dist/entry-41.js +18 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +1 -7
- package/dist/entry-46.js +7 -11
- package/dist/entry-47.js +11 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -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 -0
- package/dist/entry-56.js +0 -1
- package/dist/entry-57.js +1 -0
- package/dist/entry-58.js +0 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +0 -1
- package/dist/entry-66.js +1 -0
- package/dist/entry-67.js +0 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -123
- package/dist/entry-71.js +198 -25
- package/dist/entry-72.js +30 -2
- package/dist/entry-73.js +2 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -3
- package/dist/entry-77.js +3 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/pi-agent-ide.js +3 -3
- package/docs/configuration.md +1 -1
- package/docs/user-hooks.md +68 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-21.js +1 -0
- package/node_modules/pi-agent-doctor/src/catalog.ts +9 -1
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +5 -0
- 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-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-25.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +32 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +16 -8
- package/node_modules/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +22 -17
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +4 -1
- package/node_modules/pi-agent-ide-changes/index.ts +3 -1
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
- package/node_modules/pi-agent-ide-formatter/package.json +9 -4
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/package.json +13 -8
- package/node_modules/pi-agent-ide-lsp/index.ts +4 -1
- package/node_modules/pi-agent-ide-lsp/package.json +15 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-33.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 +11 -11
- package/node_modules/pi-agent-read/runtime/entry-40.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-41.js +2 -0
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/rendering.ts +1 -1
- package/node_modules/pi-agent-read/src/api/tools/read.ts +32 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +8 -0
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +105 -5
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +7 -7
- package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +5 -1
- package/node_modules/pi-agent-search-text/index.ts +1 -1
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-47.js +1 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +47 -19
- package/node_modules/pi-agent-search-text/src/search-backend.ts +6 -15
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +80 -0
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +17 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +32 -12
- package/node_modules/pi-agent-search-text/src/search-session.ts +6 -3
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-49.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-50.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-51.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.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-53.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +25 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-70.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +37 -8
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -4
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
- package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -0
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.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-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
- package/package.json +58 -38
- package/src/api/hooks.ts +168 -0
- package/src/api/text-editor.ts +2 -0
- package/src/composite/builtin-extensions.ts +7 -0
- package/src/composite/module-labels.ts +8 -0
- package/src/composite/preferences.ts +3 -3
- package/src/core/reload-resource-store.ts +34 -0
- package/src/doctor/tip-provider.ts +1 -0
- 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-pdf/package.json +4 -4
- 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-25.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.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-pdf/package.json +4 -4
- 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-80.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/package.json +11 -11
- package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-41.js +2 -0
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/rendering.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +32 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +8 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +105 -5
- package/src/extensions/pi-agent-search/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +47 -19
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +6 -15
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +80 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +17 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +32 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +6 -3
- package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +2 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +5 -1
- package/src/extensions/pi-agent-text-editor/package.json +25 -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-50.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-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.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-53.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
- 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-73.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +37 -8
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -4
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
- package/src/plugins/pi-agent-ide-ast/package.json +32 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +16 -8
- package/src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +22 -17
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +4 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +3 -1
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
- package/src/plugins/pi-agent-ide-debugger/index.ts +573 -0
- package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +73 -0
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +306 -0
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +338 -0
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +349 -0
- package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +39 -0
- package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +152 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +1344 -0
- package/src/plugins/pi-agent-ide-debugger/src/ui.ts +14 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +9 -4
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/package.json +13 -8
- package/src/plugins/pi-agent-ide-lsp/index.ts +4 -1
- package/src/plugins/pi-agent-ide-lsp/package.json +15 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
- package/src/plugins/pi-agent-ide-processes/index.ts +28 -0
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +81 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +252 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +19 -13
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +52 -0
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +30 -0
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +24 -58
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -14
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +114 -1
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +23 -29
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +13 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +116 -240
- package/dist/chunk-3SE372WC.js +0 -3
- package/dist/chunk-5MSNYFDE.js +0 -1
- package/dist/chunk-7JYQMAEL.js +0 -14
- package/dist/chunk-B5KB2I7J.js +0 -3
- package/dist/chunk-NMFQGKPE.js +0 -2
- package/dist/chunk-OVUYPHDE.js +0 -1
- package/dist/chunk-TPIHQYK2.js +0 -14
- package/dist/chunk-XSTHESNR.js +0 -25
- package/dist/entry-16.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-16.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-21.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-33.js +0 -1
- package/node_modules/pi-agent-resource/runtime/entry-41.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-22.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-36.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-42.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-22.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 — 2026-09-13
|
|
4
|
+
|
|
5
|
+
### Debugging
|
|
6
|
+
|
|
7
|
+
- Add agent-native debugger sessions backed by the Debug Adapter Protocol. Agents can launch programs, set and remove breakpoints, continue execution, step through code, inspect stopped source, and terminate sessions through addressable `debug:` resources.
|
|
8
|
+
- Add verified Linux adapters and project checks for JavaScript, TypeScript source maps, shell scripts, C, C++, Rust, Swift, Zig, Java, Kotlin, C#, Python, Go, Dart, PHP, Ruby, Lua, PowerShell, R, Julia, and Elixir.
|
|
9
|
+
- Bring terminal and debugger activity into one `/agent-ide-processes` panel with live state, elapsed time, source context, and session controls.
|
|
10
|
+
- Keep active debugger sessions attached across extension reloads, preserving their `debug:` resources and stopped state.
|
|
11
|
+
|
|
12
|
+
### Transactional Apply
|
|
13
|
+
|
|
14
|
+
- Replace full-file rewrites inside `apply` with a snapshot-guarded editor API. Scripts open immutable file snapshots, stage exact text and whole-file changes, and commit them together with an explicit `apply()` call.
|
|
15
|
+
- Validate every staged operation before writing. If a multi-file commit fails after writing starts, Apply attempts to restore the original files and reports whether rollback completed.
|
|
16
|
+
- Return a session-scoped `APPLY#` receipt to the agent after a successful commit. `undo` can use it once to restore every touched path together, refuses stale receipts before changing files, and reports any restore or compensating-rollback failure.
|
|
17
|
+
- Keep the undo receipt out of the user-facing Apply result. Undo itself uses a compact success or failure status with the number of restored files.
|
|
18
|
+
- Compact long Apply source previews to a useful head and tail, and render explicit `result()` values as first-class result blocks.
|
|
19
|
+
|
|
20
|
+
### Terminal reliability
|
|
21
|
+
|
|
22
|
+
- Replace the generic `run` tool with `bash` on Unix-like systems and `powershell` on Windows. Commands still run in the user’s configured system shell, whose syntax is included in the agent guidance.
|
|
23
|
+
- Preserve foreground commands when the agent turn times out or is interrupted. They continue as background sessions instead of being terminated, and interactive prompts return control without losing the process.
|
|
24
|
+
- Add configurable foreground wait timeouts and report process timeouts, signals, failures, and successful exits as soon as they happen.
|
|
25
|
+
- Wake an idle agent when a running background session produces no output for two minutes. Repeat the notice every two silent minutes until the session changes or finishes.
|
|
26
|
+
- Bound terminal output in both command results and `shell:` reads. Keep the useful tail in context and save the complete output to a readable log file.
|
|
27
|
+
- Keep process panels live while terminal and debugger sessions change state.
|
|
28
|
+
- Keep live terminal sessions attached across extension reloads with the same `shell:` resource and process.
|
|
29
|
+
|
|
30
|
+
### Reading, search, and language support
|
|
31
|
+
|
|
32
|
+
- Expand AST parsing and structural search across the supported language catalog, including native parsers for Go and other non-TypeScript languages.
|
|
33
|
+
- Apply syntax highlighting before AST scope and anchor annotations, so structural reads keep both code colours and stable line markers.
|
|
34
|
+
- Promote semantic code views in agent guidance: workspace symbols for discovery, file graphs for relationships, and declaration reads for focused implementation work.
|
|
35
|
+
- Compact large text-search results before they consume the agent context while preserving reusable search selections.
|
|
36
|
+
|
|
37
|
+
### File operations and hooks
|
|
38
|
+
|
|
39
|
+
- Unify whole-file and selected-text operations under `copy`, `move`, and `delete`. Supplying only source and target paths performs a whole-file operation; selectors continue to operate on text.
|
|
40
|
+
- Show whole-file copy, move, and delete results as compact success or failure cards without repeating paths already present in the header.
|
|
41
|
+
- Add project and global file hooks for reads and text edits. Extensions can deny reads, reject resolved text edits and file creation before their first write, or attach feedback after a saved text edit.
|
|
42
|
+
- Run before-edit hooks once against the complete set of staged text edits in an Apply commit. Whole-file copy, move, and delete operations remain outside the edit-hook contract.
|
|
43
|
+
|
|
3
44
|
## 0.4.0 — 2026-09-11
|
|
4
45
|
|
|
5
46
|
### Terminal sessions
|
package/README.md
CHANGED
|
@@ -25,16 +25,16 @@ The current focus is measurement. The project is being compared with vanilla Pi
|
|
|
25
25
|
|
|
26
26
|
Pi Agent IDE gives the agent a focused set of tools that work together:
|
|
27
27
|
|
|
28
|
-
- `read` handles text files, original bytes, web pages, images, PDFs, code views, and
|
|
29
|
-
- `
|
|
28
|
+
- `read` handles text files, original bytes, web pages, images, PDFs, code views, diagnostics, terminal output, and debugger state;
|
|
29
|
+
- `bash` on Unix-like systems and `powershell` on Windows run commands in the user's configured shell. Long-running and interactive commands remain available through `shell:` resources, including across extension reloads;
|
|
30
30
|
- `search` finds files, text, symbols, and syntax-tree patterns;
|
|
31
|
-
- `write`, `replace`, `insert`, `delete`, `copy`, and `move` edit text with exact matches, line anchors, search results, AST matches, and language-server symbols;
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
31
|
+
- `write`, `replace`, `insert`, `delete`, `copy`, and `move` edit text with exact matches, line anchors, search results, AST matches, and language-server symbols. `copy`, `move`, and `delete` also handle whole files;
|
|
32
|
+
- `apply` opens immutable file snapshots, stages several text and whole-file changes in JavaScript, validates them together, and commits them as one guarded transaction. A successful transaction returns a short-lived receipt that the agent can pass to `undo`;
|
|
33
|
+
- `debug` creates addressable Debug Adapter Protocol sessions. Agents can set breakpoints, inspect stopped source, step through code, and keep active `debug:` sessions across extension reloads;
|
|
34
34
|
- formatting and diagnostics run after edits and stay local to the project that owns each file;
|
|
35
|
-
- `/pi-agent-ide-doctor` checks the languages and tools available in the current project.
|
|
35
|
+
- `/agent-ide-processes` shows terminal and debugger activity, while `/pi-agent-ide-doctor` checks the languages and tools available in the current project.
|
|
36
36
|
|
|
37
|
-
The tools share
|
|
37
|
+
The tools share resources and safeguards. Reads and searches produce references that editing tools can reuse. Apply validates staged changes before its first write, attempts rollback if a later write fails, and reports whether recovery completed. Formatting, diagnostics, previews, and undo use the same underlying editing pipeline.
|
|
38
38
|
|
|
39
39
|
The npm package loads as one Pi extension. Its built-in modules can be enabled, disabled, replaced, or extended through versioned plugin protocols.
|
|
40
40
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as S}from"./chunk-5VSE5X5R.js";import{a as d}from"./chunk-EI7MMDWY.js";import{createRequire as j}from"node:module";import{Lang as y,parse as T,registerDynamicLanguage as F}from"@ast-grep/napi";var R=j(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),B={bash:"@ast-grep/lang-bash",csharp:"@ast-grep/lang-csharp",dart:"@ast-grep/lang-dart",elixir:"@ast-grep/lang-elixir",go:"@ast-grep/lang-go",html:"@ast-grep/lang-html",java:"@ast-grep/lang-java",kotlin:"@ast-grep/lang-kotlin",lua:"@ast-grep/lang-lua",markdown:"@ast-grep/lang-markdown",php:"@ast-grep/lang-php",ruby:"@ast-grep/lang-ruby",scala:"@ast-grep/lang-scala",sql:"@ast-grep/lang-sql",swift:"@ast-grep/lang-swift"},D={".bash":"bash",".cs":"csharp",".css":y.Css,".less":y.Css,".scss":y.Css,".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".htm":"html",".html":"html",".java":"java",".kt":"kotlin",".kts":"kotlin",".lua":"lua",".md":"markdown",".mdx":"markdown",".php":"php",".rb":"ruby",".rake":"ruby",".scala":"scala",".sc":"scala",".sql":"sql",".sh":"bash",".swift":"swift"},N=!1;function O(){if(N)return;let r={};for(let[e,t]of Object.entries(B))r[e]=R(t);F(r),N=!0}d(O,"ensureLanguagesRegistered");function C(r,e){let t=D[r];if(t)return O(),{rootNode:new b(T(t,e).root(),e)}}d(C,"parseNativeDocument");var b=class r{constructor(e,t){this.node=e;this.source=t}static{d(this,"NativeSyntaxNode")}get type(){return String(this.node.kind())}get text(){return this.node.text()}get isNamed(){return this.node.isNamed()}get hasError(){return this.type==="ERROR"||this.node.children().some(e=>new r(e,this.source).hasError)}get startIndex(){return k(this.source,this.node.range().start.index)}get endIndex(){return k(this.source,this.node.range().end.index)}get startPosition(){let{line:e,column:t}=this.node.range().start;return{row:e,column:t}}get endPosition(){let{line:e,column:t}=this.node.range().end;return{row:e,column:t}}get parent(){let e=this.node.parent();return e?new r(e,this.source):null}get namedChildCount(){return this.namedChildren.length}get namedChildren(){return this.node.children().filter(e=>e.isNamed()).map(e=>new r(e,this.source))}childForFieldName(e){let t=this.node.field(e);return t?new r(t,this.source):null}};function k(r,e){return Buffer.from(r).subarray(0,e).toString("utf8").length}d(k,"byteOffsetToStringIndex");import{createHash as q}from"node:crypto";import{createRequire as W}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var I=W(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),M=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]),A,P=new Map;function $(r){switch(r){case".ts":case".tsx":case".mts":case".cts":return"tree-sitter-typescript/tree-sitter-typescript.wasm";case".js":case".jsx":case".mjs":case".cjs":return"tree-sitter-javascript/tree-sitter-javascript.wasm";case".py":case".pyi":return"tree-sitter-python/tree-sitter-python.wasm";case".rs":return"tree-sitter-rust/tree-sitter-rust.wasm";case".c":case".cc":case".hh":case".hxx":case".cpp":case".cxx":case".h":case".hpp":return"tree-sitter-cpp/tree-sitter-cpp.wasm";case".json":case".jsonc":return"tree-sitter-json/tree-sitter-json.wasm";case".yaml":case".yml":return"@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm";case".toml":return"@tree-sitter-grammars/tree-sitter-toml/tree-sitter-toml.wasm";default:return}}d($,"grammarWasmPath");async function G(r){let e=$(r);if(!e)return;A??=p.Parser.init(),await A;let t=P.get(e);if(t===void 0){let i=I.resolve(e);t=p.Language.load(i),P.set(e,t)}let a=await t,o=new p.Parser;return o.setLanguage(a),o}d(G,"ensureParser");async function U(r,e,t){if(t.length===0)return;let a=L.isAbsolute(r)?r:L.resolve(e,r),o=L.extname(a).toLowerCase(),i=t.join(`
|
|
2
|
+
`),u=await G(o);return u?u.parse(i)??void 0:C(o,i)}d(U,"parseDocument");function E(r,e,t){let a=r.slice(Math.max(0,e-1),Math.max(0,t)).join(`
|
|
3
|
+
`);return q("sha1").update(a).digest("hex").slice(0,4).toUpperCase()}d(E,"hashScope");var w=class extends S{static{d(this,"AstScopeTextAnchor")}constructor(e,t,a,o){super(`scope-${e}-${t}${o===void 0?"":`-${o}`}`,a)}};function f(r,e,t,a){return new w(r,e,t,a)}d(f,"createScopeAnchor");var v=class{static{d(this,"AstScopeManager")}async getDocumentScopes(e,t,a){if(a.length===0)return[];let o=await U(e,t,a);if(!o)return[];let i=[];return this.collectCandidates(o.rootNode,i),this.buildEntries(i,a)}collectCandidates(e,t,a=0,o=!1){if(a>100||!e.isNamed)return;let i=e.type;if(!i||M.has(i)){for(let c of e.namedChildren)this.collectCandidates(c,t,a+1);return}for(let c of x){let n=e.childForFieldName(c);if(!n?.isNamed)continue;let s=n.startPosition.row+1,g=n.endPosition.row+1,h=g-s>=3,l=[...x].some(m=>n.childForFieldName(m)!==null);h&&!l&&t.push({startLine:s,endLine:g,kind:`${i}.${c}`,fromBodyField:!0}),this.collectCandidates(n,t,a+1,!0)}if(![...x].some(c=>e.childForFieldName(c)!==null)&&!o){let c=e.startPosition.row+1,n=e.endPosition.row+1;n-c>=3&&e.namedChildren.length>0&&t.push({startLine:c,endLine:n,kind:i,fromBodyField:!1})}for(let c of e.namedChildren)this.collectCandidates(c,t,a+1)}buildEntries(e,t){let a=new Map;for(let n of e){let s=a.get(n.startLine);(!s||n.endLine>s.endLine||n.endLine===s.endLine&&n.fromBodyField&&!s.fromBodyField)&&a.set(n.startLine,n)}let o=[...a.values()].sort((n,s)=>n.startLine-s.startLine||s.endLine-n.endLine),i=[];for(let n of o)i.some(g=>g.startLine<n.startLine&&g.endLine===n.endLine)||i.push(n);let u=new Map;for(let n of i){let s=E(t,n.startLine,n.endLine);u.set(s,(u.get(s)??0)+1)}let c=new Map;return i.map(n=>{let s=E(t,n.startLine,n.endLine),g=u.get(s)??1,h=(c.get(s)??0)+1;c.set(s,h);let l=g>1?h:void 0;return{name:n.kind,kind:n.kind,startLine:n.startLine,endLine:n.endLine,depth:i.filter(m=>m!==n&&m.startLine<=n.startLine&&m.endLine>=n.endLine&&(m.startLine<n.startLine||m.endLine>n.endLine)).length,hash:s,blockHash:s,...l!==void 0&&{occurrence:l},beginAnchor:f("begin",s,n.startLine,l),endScopeAnchor:f("end",s,n.endLine,l),scopeBeginAnchor:f("begin",s,n.startLine,l),scopeEndAnchor:f("end",s,n.endLine,l)}})}};export{D as a,U as b,v as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./chunk-EI7MMDWY.js";var i=class{static{s(this,"AgentIdeProcessRegistry")}#t=new Map;#s=new Set;#e=new Map;add(e){return this.#e.get(e.id)?.(),this.#t.set(e.id,e),this.#e.set(e.id,e.onDidChange(()=>this.#i())),this.#i(),()=>{this.#t.get(e.id)===e&&(this.#e.get(e.id)?.(),this.#e.delete(e.id),this.#t.delete(e.id),this.#i())}}list(){return[...this.#t.values()].flatMap(e=>e.list())}onDidChange(e){return this.#s.add(e),()=>this.#s.delete(e)}dispose(){for(let e of this.#e.values())e();this.#e.clear(),this.#t.clear(),this.#s.clear()}#i(){for(let e of this.#s)e()}},n=new WeakMap;function r(t){let e=n.get(t);return e===void 0&&(e=new i,n.set(t,e)),e}s(r,"agentIdeProcessRegistry");export{r as a};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as k,b as I,c as A}from"./chunk-25CZ5ZIU.js";import{j as E,k as S}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import"./chunk-KINKBPPX.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as K}from"node:fs/promises";import W from"node:path";async function T(e){let n=[],t=await K(e,{withFileTypes:!0});for(let i of t){let o=W.join(e,i.name);i.isDirectory()?n.push(...await T(o)):(i.isFile()||i.isSymbolicLink())&&n.push(o)}return n}s(T,"collectFiles");import{readFile as X}from"node:fs/promises";var v=256*1024;async function w(e){let n=await X(e);if(n.byteLength>v)throw new Error(`File exceeds the ${v}-byte AST outline limit: ${e}`);if(n.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${e}`);let t=n.toString("utf8").replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`),i=t.endsWith(`
|
|
4
|
+
`)?t.slice(0,-1):t,o=i.length===0?[]:i.split(`
|
|
5
|
+
`);return{content:t,lines:o}}s(w,"readTextFile");var H=new Set([...Object.keys(k),".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".py",".pyi",".rs",".c",".cc",".hh",".hxx",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),G=new Set([".json",".jsonc",".yaml",".yml",".toml"]),B=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),q=new Set(["module","program","source_file"]),Z=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),M=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),z=new Set(["public_field_definition","variable_declarator","assignment"]),C=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function N(e){return H.has(h.extname(e).toLowerCase())}s(N,"isSupportedOutlinePath");var L={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},J={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ce(e){return S([e],J)}s(Ce,"formatAstOutline");var R=class{constructor(n=Number.POSITIVE_INFINITY){this.maxDepth=n}static{s(this,"AstOutlineManager")}fallbackScopeManager=new A;async readFileOutline(n,t){let i=P(n,t),o=h.relative(t,i)||i;if(!N(i))throw new Error(`AST outline is not supported for ${o}.`);let r=await w(i);return this.readDocumentOutline(i,t,r.lines)}async readDocumentOutline(n,t,i,o){let r=P(n,t),c=h.relative(t,r)||r;if(!N(r))throw new Error(`AST outline is not supported for ${c}.`);let a=await I(r,t,i);if(!a)throw new Error(`No AST parser is available for ${c}.`);if(Number.isFinite(this.maxDepth)&&a.rootNode.hasError)throw new Error(`Cannot build an automatic outline from invalid syntax in ${c}.`);let u=i.join(`
|
|
6
|
+
`);for(let d=this.maxDepth;;d-=1){let l=await this.createSourceViewBlock(a.rootNode,r,c,t,i,u,h.extname(r).toLowerCase(),void 0,void 0,d);if(o===void 0||o(l)||d<=0||!Number.isFinite(d))return l}}async formatFile(n,t){let i=P(n,t),o=h.relative(t,i)||i;if(!N(i)){let r=await w(i);return S([Q(i,o,r.lines)],L)}try{return S([await this.readFileOutline(i,t)],L)}catch(r){let c=r instanceof Error?r.message:String(r);return S([j(o,c)],L)}}async formatSymbol(n,t){let o=(await T(t)).filter(r=>N(r)).sort();for(let r of o){let c;try{c=await w(r)}catch{continue}let a;try{a=await I(r,t,c.lines)}catch{continue}if(!a)continue;let u=ne(a.rootNode,n);if(!u)continue;let d=h.relative(t,r)||r,l=await this.createSourceViewBlock(u,r,d,t,c.lines,c.content,h.extname(r).toLowerCase(),n,[`defined in: ${d}:${u.startPosition.row+1}`]);return S([l],L)}return S([j("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],L)}async createSourceViewBlock(n,t,i,o,r,c,a,u,d,l=this.maxDepth){let f=oe(n,c,a,l),m=await ee(this.fallbackScopeManager,t,o,r),x=te(m),g=f.map(y=>{let p=y.sourceLine,_=p===void 0?void 0:r[p-1]??"",O=(p===void 0?void 0:x.get(p))?.map(Y=>` <!-- ${Y} -->`).join("")??"";return E({content:y.content,...!(p===void 0||_===void 0)&&{sourceLine:{source:t,lineNumber:p,content:_}},...O.length>0&&{suffix:O}})});return{path:i,...u!==void 0&&{heading:u},...d!==void 0&&{details:d},startLine:n.startPosition.row+1,endLine:n.endPosition.row+1,totalLines:r.length,renderedLines:g}}};function Q(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,o)=>E({content:i,sourceLine:{source:e,lineNumber:o+1,content:i}}))}}s(Q,"formatUnsupportedSourceBlock");function j(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}s(j,"failedSourceViewBlock");function ee(e,n,t,i){return e.getDocumentScopes(n,t,i)}s(ee,"getOutlineScopes");function te(e){let n=new Map;for(let t of e){let i=n.get(t.startLine)??[];i.push(t.beginAnchor.value),n.set(t.startLine,i);let o=n.get(t.endLine)??[];o.push(t.endScopeAnchor.value),n.set(t.endLine,o)}return n}s(te,"buildScopeMarkers");function P(e,n){return e.startsWith("file://")?decodeURIComponent(e.slice(7)):h.isAbsolute(e)?e:h.resolve(n,e)}s(P,"resolvePath");function ne(e,n){let t,i=s(o=>{if(!t){if(B.has(o.type)&&re(o)===n){t=ie(o);return}for(let r of o.namedChildren)i(r)}},"visit");return i(e),t}s(ne,"findSymbol");function re(e){let n=e.childForFieldName("name");if(n&&C.has(n.type))return n.text;for(let t of e.namedChildren)if(C.has(t.type))return t.text;if(e.type==="lexical_declaration"||e.type==="variable_declaration")return e.namedChildren.find(o=>o.type==="variable_declarator")?.childForFieldName("name")?.text;if(e.type==="function_definition"){let t=e.childForFieldName("declarator");return t?V(t):void 0}}s(re,"getNodeName");function V(e){if(C.has(e.type))return e.text;for(let n of e.namedChildren){let t=V(n);if(t)return t}}s(V,"findNestedName");function ie(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}s(ie,"unwrapDeclaration");function oe(e,n,t,i){let o=[];G.has(t)?$(e,t,o,i):U(e,t,o,!1,i);let r=se(n,e.startIndex),c=ae(n,e.endIndex),a=o.filter(l=>l.start>=r&&l.end<=c).sort((l,f)=>f.start-l.start),u=ce(n,r,c);for(let l of a){let f=l.start-r,m=l.end-r,x=le(l);u.splice(f,m-f,...x)}for(;u.length>0&&/\s/u.test(b(u.at(-1)).char);)u.pop();let d=[[]];for(let l of u)l.char===`
|
|
7
|
+
`?d.push([]):b(d.at(-1)).push(l);return d.map(l=>{let f=[...new Set(l.flatMap(m=>m.sourceLine===void 0?[]:[m.sourceLine]))];return{content:l.map(m=>m.char).join(""),...f.length===1&&{sourceLine:f[0]}}})}s(oe,"renderNodeLines");function se(e,n){return e.lastIndexOf(`
|
|
8
|
+
`,Math.max(0,n-1))+1}s(se,"lineStartAt");function ae(e,n){let t=e.indexOf(`
|
|
9
|
+
`,n);return t===-1?e.length:t}s(ae,"lineEndAt");function ce(e,n,t){let i=e.slice(0,n).split(`
|
|
10
|
+
`).length,o=[];for(let r=n;r<t;r+=1){let c=b(e[r]);o.push({char:c,sourceLine:i}),c===`
|
|
11
|
+
`&&(i+=1)}return o}s(ce,"mapSourceRange");function le(e){let n=e.lineSourceLines??[],t=0,i=[];for(let o=0;o<e.text.length;o+=1){let r=b(e.text[o]),c=n[t];i.push(c===void 0?{char:r}:{char:r,sourceLine:c}),r===`
|
|
12
|
+
`&&(t+=1)}return i}s(le,"mapReplacement");function D(e,n,t,i){return t<i||e.namedChildCount===0?!1:(n.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]}),!0)}s(D,"collapseDeepNode");function $(e,n,t,i,o=0){if(!D(e,t,o,i))for(let r of e.namedChildren){if(ue(r,n)){de(r)||t.push({start:r.startIndex,end:r.endIndex,text:"\u2026",lineSourceLines:[r.startPosition.row+1]});continue}$(r,n,t,i,o+1)}}s($,"collectDataReplacements");function ue(e,n){return(n===".json"||n===".jsonc"?["string","number","true","false","null"]:n===".yaml"||n===".yml"?["string_scalar","integer_scalar","float_scalar","boolean_scalar","null_scalar","block_scalar"]:["string","integer","float","boolean","date_time","offset_date_time","local_date_time","local_date","local_time"]).includes(e.type)}s(ue,"isDataScalar");function de(e){let n=e.parent;for(;n&&!n.type.endsWith("pair")&&n.type!=="pair"&&n.type!=="table";)n=n.parent;let t=n?.namedChildren[0];return t!==void 0&&t.startIndex<=e.startIndex&&t.endIndex>=e.endIndex}s(de,"isDataKey");function U(e,n,t,i,o,r=0){if(D(e,t,r,o))return;let c=Number.isFinite(o)&&e.type==="expression_statement";if(i&&!pe(e)&&!c){t.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]});return}if(M.has(e.type)){let a=fe(e);if(a){let u=me(a,n);t.push({start:a.startIndex,end:a.endIndex,text:u.text,lineSourceLines:u.lineSourceLines});return}}if(z.has(e.type)){let a=e.childForFieldName("value");if(a&&!M.has(a.type)){t.push({start:a.startIndex,end:a.endIndex,text:"\u2026",lineSourceLines:[a.startPosition.row+1]});return}}for(let a of e.namedChildren)U(a,n,t,q.has(e.type),o,r+1)}s(U,"collectReplacements");function pe(e){return B.has(e.type)||Z.has(e.type)||e.type==="comment"||e.type.startsWith("preproc")}s(pe,"isTopLevelInterfaceNode");function fe(e){let n=e.childForFieldName("body");return n||e.namedChildren.find(t=>t.type==="block"||t.type==="compound_statement"||t.type==="statement_block")}s(fe,"findBody");function me(e,n){let t=e.startPosition.row+1,i=e.endPosition.row+1;if(n===".py")return{text:"...",lineSourceLines:[t]};let o=e.text.split(`
|
|
13
|
+
`),r=o[0]??"",c=o.at(-1)??"",a=r.indexOf("{"),u=c.lastIndexOf("}");if(a===-1||u===-1)return{text:"\u2026",lineSourceLines:[t]};if(o.length===1){let p=r.slice(a+1,u);return p.trim()===""?{text:e.text,lineSourceLines:[t]}:{text:r.slice(0,a+1)+F(p)+r.slice(u),lineSourceLines:[t]}}let d=r.slice(a+1),l=c.slice(0,u),f=o.slice(1,-1).some(p=>p.trim()!==""),m=d.trim()!=="",x=l.trim()!=="";if(!f&&!m&&!x)return{text:e.text,lineSourceLines:o.map((p,_)=>t+_)};let g=[],y=[];if(g.push(m?r.slice(0,a+1)+F(d):r),y.push(t),!m&&f){let p=o.slice(1,-1).find(_=>_.trim()!=="")?.match(/^\s*/u)?.[0]??"";g.push(`${p}\u2026`),y.push(void 0)}return g.push(x?F(l)+c.slice(u):c),y.push(i),{text:g.join(`
|
|
14
|
+
`),lineSourceLines:y}}s(me,"renderBodyPlaceholder");function F(e){let n=/^\s*/u.exec(e)?.[0]??"",t=/\s*$/u.exec(e)?.[0]??"";return`${n}\u2026${t}`}s(F,"maskSegment");export{R as AstOutlineManager,Ce as formatAstOutline,N as isSupportedOutlinePath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a,d as u,e as c}from"./chunk-
|
|
1
|
+
import{c as a,d as u,e as c}from"./chunk-OBNING2A.js";import{a as t}from"./chunk-EI7MMDWY.js";function E(o,r){let s=t(()=>{let e,i={plugin:r,accept(R){if(e!==void 0)throw new Error(`Plugin ${r.id} registration was accepted more than once`);e=R}};return o.events.emit(u,i),e},"announce"),n=t(()=>{},"unsubscribe");n=o.events.on(a,e=>{if(!c(e))throw new Error("Invalid pi-agent-read core readiness event");let i=s();if(i===void 0)throw new Error("pi-agent-read core announced readiness without accepting the plugin");n(),i.catch(()=>{})}),o.on("session_shutdown",n);let d=s();if(d!==void 0)return n(),d}t(E,"connectReadPlugin");export{E as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-EI7MMDWY.js";function l(t,n){return typeof n=="string"&&n.length>0&&t.nonAnchorValues?.includes(n)!==!0}r(l,"isMutationAnchorValue");function u(t){if(typeof t.name!="string"||t.name.trim().length===0)throw new TypeError("Mutation tool name must be a non-empty string");if(typeof t.description!="string"||typeof t.mutate!="function")throw new TypeError(`Mutation tool ${t.name} has an invalid description or operation`);if(t.direct!==void 0&&(typeof t.direct.matches!="function"||typeof t.direct.execute!="function"))throw new TypeError(`Mutation tool ${t.name} has an invalid direct operation`);let n=t.intent;if(n!==void 0&&n!=="edit"&&n!=="restore")throw new TypeError(`Mutation tool ${t.name} has an invalid intent`);let o=d(t.parameters,t.name);c(o,t.source.field,`${t.name} primary source`);let a=new Set([t.source.field]);for(let e of t.source.targets??[]){if(c(o,e.field,`${t.name} target source`),!a.has(e.fallbackTo))throw new TypeError(`Mutation tool ${t.name} target ${e.field} has an unknown fallback ${e.fallbackTo}`);a.add(e.field)}let s=new Set;for(let e of t.anchors??[]){if(c(o,e.field,`${t.name} anchor`),!a.has(e.sourceField))throw new TypeError(`Mutation tool ${t.name} anchor ${e.field} has an unknown source ${e.sourceField}`);if(!Array.isArray(e.kinds)||e.kinds.length===0||e.kinds.some(i=>typeof i!="string"||i.trim().length===0))throw new TypeError(`Mutation tool ${t.name} anchor ${e.field} must accept non-empty kinds`);if(new Set(e.kinds).size!==e.kinds.length)throw new TypeError(`Mutation tool ${t.name} anchor ${e.field} declares duplicate kinds`);if(e.nonAnchorValues!==void 0&&(e.nonAnchorValues.length===0||e.nonAnchorValues.some(i=>typeof i!="string"||i.length===0)))throw new TypeError(`Mutation tool ${t.name} anchor ${e.field} must declare non-empty non-anchor values`);if(e.nonAnchorValues!==void 0&&new Set(e.nonAnchorValues).size!==e.nonAnchorValues.length)throw new TypeError(`Mutation tool ${t.name} anchor ${e.field} declares duplicate non-anchor values`);if(s.has(e.field))throw new TypeError(`Mutation tool ${t.name} declares anchor ${e.field} more than once`);s.add(e.field)}for(let e of t.pair??[])if(!s.has(e))throw new TypeError(`Mutation tool ${t.name} pair field ${e} is not an anchor`)}r(u,"assertTextMutationToolRegistration");function p(t,n){let o=n[t.source.field];return typeof o=="string"?o:""}r(p,"mutationSource");function d(t,n){let o=t.properties;if(typeof o!="object"||o===null)throw new TypeError(`Mutation tool ${n} parameters must be an object schema`);return o}r(d,"schemaProperties");function c(t,n,o){if(typeof n!="string"||n.length===0||!(n in t))throw new TypeError(`${o} field ${n} is not declared by its schema`)}r(c,"assertProperty");export{l as a,u as b,p as c};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{a as ne,b as re,c as ie}from"./chunk-ESPNEJHK.js";import{a as te}from"./chunk-5PLV4HLG.js";import{b as R}from"./chunk-526E364R.js";import"./chunk-YHUTTZC6.js";import{a as V}from"./chunk-6CZO43OH.js";import{a as X,b as Y}from"./chunk-OBNING2A.js";import{a as ee}from"./chunk-ZTYWHL2F.js";import{a as Z,b as Q}from"./chunk-7UGNGK7Y.js";import{a as J}from"./chunk-L7JMDDSD.js";import{a as K,b as z}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import Ue from"node:path";import{stripVTControlCharacters as We}from"node:util";import{truncateLine as Fe}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 oe,formatSize as Oe,truncateTail as Ne}from"@earendil-works/pi-coding-agent";function I(t){return Ne(t,{maxBytes:se-4096,maxLines:oe-32})}a(I,"terminalOutputTail");function v(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(s=>s!==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"?`${oe} line output budget`:`${Oe(se)} output budget`,o=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
output:
|
|
7
|
+
${o}${r.length===0?"":`
|
|
8
|
+
${r}`}`}a(v,"formatAgentTerminalSnapshot");var je=500;function ae(t,e,n,r,i){let o=e?"background":"wait",s=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${E(n)} \xB7 ${o}`)}`;return new x(`${s}
|
|
9
|
+
${i.fg("accent",O(r.family))} ${t}`,0,0)}a(ae,"renderRunCall");function le(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(le,"renderTerminalActionResult");function $(t,e,n,r,i){let o=[qe(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&o.push(...r.map(s=>` ${i.fg("dim",s)}`)),new x(o.join(`
|
|
11
|
+
`),0,0)}a($,"renderTerminalAction");function S(t,e,n,r){let i=Ge(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 ue(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(o=>` ${n.fg("dim",o)}`)];return i.push(D(t,(o,s)=>n.fg(o,s))),new x(i.join(`
|
|
13
|
+
`),0,0)}a(ue,"renderRunResult");function ce(t,e){let n=a((s,l)=>e?.fg(s,l)??l,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${E(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",O(t.shellFamily))} ${M(t.command,84)}`],o=He(t.output,2);return o.length>0&&i.push(...o.map(s=>` ${n("dim",M(s,90))}`)),i.push(D(t,n)),i.join(`
|
|
14
|
+
`)}a(ce,"renderActiveTerminal");function Ge(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",o=t.cwd===void 0?"workspace":E(t.cwd),s=t.shellFamily??"posix",l=[`${n.fg("accent",r)} ${n.fg("muted",`\xB7 ${o} \xB7 ${i}`)}`,`${n.fg("accent",O(s))} ${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(Ge,"terminalCardLines");function He(t,e){return _(t,e).lines}a(He,"outputTail");function _(t,e){let n=I(We(t).replaceAll("\r","")),r=n.content.split(`
|
|
15
|
+
`).map(u=>Fe(u.trimEnd(),je).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,o=Math.max(0,r.length-i),s=Math.max(0,n.totalLines-n.outputLines),l=o+s;return{lines:r.slice(o),...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=Be(n),i=n==="completed"?"success":n==="running"?"accent":"error",o=[`${r} ${n}`,Xe(t.elapsedMs??0)];return t.waitReason!==void 0&&o.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&o.push(`reason ${t.completionReason}`),t.exitCode!==void 0?o.push(`exit ${t.exitCode}`):t.signal!==void 0&&o.push(`signal ${t.signal}`),e(i,o.join(" \xB7 "))}a(D,"statusLine");function Be(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}a(Be,"statusIcon");function O(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}a(O,"promptMarker");function qe(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":E(t.cwd),i=t.background===!0?"background":"wait",o=M(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${o}`)}`}a(qe,"terminalIdentity");function E(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${Ue.sep}`))?`~${t.slice(e.length)}`:t}a(E,"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 Xe(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(Xe,"formatElapsed");function de(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",renderSummary:a(n=>ce(e,n).split(`
|
|
16
|
+
`),"renderSummary"),renderDetail:a(n=>S(e,!0,n),"renderDetail"),stop:a(()=>t.delete(e.source),"stop")})),"list")}}a(de,"terminalProcessProvider");var Ye="#d8dee9",N="#111418",Ve=["#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"),o=Math.max(0,Math.min(r.rows-1,n?.start??0)),s=Math.max(1,Math.min(r.rows-o,n?.count??r.rows)),l=i(r.cols*9+24,s*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<s;m+=1){let p=c.getLine(d+o+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||Ke(u,h,f,m)}}return r.status==="running"&&c.cursorY>=o&&c.cursorY<o+s&&(u.fillStyle="rgba(216, 222, 233, 0.75)",u.fillRect(12+c.cursorX*9,12+(c.cursorY-o)*18+18-2,9,2)),l.toBuffer("image/png").toString("base64")}a(U,"renderTerminalScreen");function Ke(t,e,n,r){let i=me(e,"foreground"),o=me(e,"background");e.isInverse()&&([i,o]=[o,i]);let s=12+n*9,l=12+r*18;o!==N&&(t.fillStyle=o,t.fillRect(s,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,s,l),e.isUnderline()&&t.fillRect(s,l+18-2,9*Math.max(1,e.getWidth()),1))}a(Ke,"drawCell");function me(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?Ye:N;let i=n?t.isFgRGB():t.isBgRGB(),o=n?t.getFgColor():t.getBgColor();return i?`#${o.toString(16).padStart(6,"0")}`:ze(o)}a(me,"cellColor");function ze(t){let e=Ve[t];if(e!==void 0)return e;if(t>=232){let l=8+(t-232)*10;return pe(l,l,l)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),o=n%6,s=a(l=>l===0?0:55+l*40,"channel");return pe(s(r),s(i),s(o))}a(ze,"ansiColor");function pe(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}a(pe,"rgb");var W="\0pi-terminal-write\0",F="\0pi-terminal-keys\0";async function we(t,e){let n=new Map,r=new Map,i={protocol:X,apiVersion:Y,id:"terminal",setup(s){s.addResolver({resolver:Je(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")}}),s.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:fe(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:fe(u,d instanceof Error?d.message:String(d))}}}}),s.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.'),s.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.")}},o={protocol:K,apiVersion:z,id:"terminal",setup(s){s.addResolver({resolver:Ze(e)}),s.tool("write").addHandler({stage:"text-pre-edit",handler:a(async l=>(he(l.input,e,n),await ge(l.input,e,r),Qe(l,W)),"handler")}),s.tool("insert").addHandler({stage:"text-pre-edit",handler:a(async l=>(await ge(l.input,e,r),he(l.input,e,n),et(l)),"handler")});for(let l of["write","insert","delete"])s.addToolRenderer({tool:l,matches:a((u,c)=>it(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)),$(f.snapshot??{},l,ye(l,m),[],c)},renderResult(u,c,d){let m=rt(u.details);return le(m.action,m.changedLines,d)}});s.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."),s.tool("write").describe("When path is shell:<session>, send content exactly as terminal input without adding Enter."),s.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([V(t,i),J(t,o)]),t.on("tool_result",async(s,l)=>{if(!w(s.input))return;let u=s.input.path;if(s.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:s.details,isError:!0};if(s.toolName==="delete"&&typeof u=="string"&&y(u)){let q=e.get(u);if(q===void 0)return;let De=e.snapshot(q);return e.delete(u).then(()=>({content:[{type:"text",text:`Deleted terminal session ${u}.`}],details:{source:u,deleted:!0,snapshot:De,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(s.toolName!=="write"&&s.toolName!=="insert"||s.isError)return;let c=s.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=s.toolName,P=ye(h,s.input),b=e.screenChangeRegion(d,m,6),B=[{type:"text",text:`Sent ${P} to ${d.source}.`}];return l.model?.input.includes("image")===!0&&B.push({type:"image",data:await U(e,c,{start:b.startRow,count:b.lines.length}),mimeType:"image/png"}),{content:B,details:{source:d.source,action:h,status:d.status,snapshot:f,input:P,changedLines:b.lines},isError:s.isError}})}a(we,"registerTerminalResources");function Je(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:tt(r)}]}}}}}}a(Je,"createReadResolver");function Ze(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=nt(r),o=i.indexOf(W),s=i.indexOf(F);if(o>=0){t.write(n.source,i.slice(o+W.length));return}if(s>=0){t.sendKeys(n.source,i.slice(s+F.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}a(Ze,"createInputResolver");function Qe(t,e){return!w(t.input)||!Se(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}a(Qe,"transformWriteInput");function et(t){if(!w(t.input)||!Se(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(et,"transformInsertInput");function tt(t){return v(t)}a(tt,"formatSnapshot");function nt(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}a(nt,"singleText");function fe(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}a(fe,"failure");function y(t){return/^shell:[a-f\d]{12}$/u.test(t)}a(y,"isShellSource");function Se(t){return typeof t=="string"&&y(t)}a(Se,"isShellSourceValue");function rt(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(rt,"terminalActionDetails");async function ge(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(ge,"rememberScreen");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&&n.set(t.path,r.outputStart+r.output.length)}a(he,"rememberOutputEnd");function ye(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(ye,"terminalInputLabel");function it(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(it,"isTerminalRenderValue");function w(t){return typeof t=="object"&&t!==null}a(w,"isRecord");async function Te(t,e){await ee(t,{protocol:Z,apiVersion:Q,id:"terminal",setup(r){r.addResolver({resolver:st(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(Te,"registerTerminalSearch");function st(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=ot(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,o=G(i)?j(i.payload):j(void 0);return $(o.snapshot,"search",JSON.stringify(o.query),o.matches.slice(-6).map(s=>`${s.lineNumber}: ${s.lineText}`),r)}}}a(st,"terminalSearchResolver");function ot(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[o,s]of t.output.replaceAll("\r","").split(`
|
|
21
|
+
`).entries()){let l=e.caseSensitive===!0?s:s.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||at(l,c,d))&&r.push({source:t.source,lineNumber:o+1,startColumn:c,endColumn:d,matchedText:s.slice(c,d),lineText:s}),u=Math.max(d,c+1)}if(r.length>=i)break}return r}a(ot,"findTerminalMatches");function at(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}a(at,"isWordBoundary");function j(t){if(!lt(t))throw new TypeError("Invalid terminal search result");return t}a(j,"parsePayload");function lt(t){return G(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&G(t.snapshot)&&typeof t.snapshot.source=="string"}a(lt,"isTerminalSearchPayload");function G(t){return typeof t=="object"&&t!==null}a(G,"isRecord");import{spawn as ut}from"node:child_process";import{closeSync as ct,mkdirSync as dt,openSync as mt,rmSync as pt,writeSync as ft}from"node:fs";import gt from"node:os";import be from"node:path";import{createRequire as ht}from"node:module";import{randomUUID as yt}from"node:crypto";import{stripVTControlCharacters as wt}from"node:util";var Pe=ht(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),Re=1e6,St=100,Tt=30,bt=2e3,A=class{static{a(this,"TerminalSessionManager")}#a;#e=new Map;#t=new Set;#r=new Set;#i=new Map;#s=!1;constructor(e=Pt){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(vt(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,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.#s)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=Lt(n);this.#i.set(n,mt(r,"a",384));let i=e.cols??St,o=e.rows??Tt,s=xt(i,o),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:o,fullOutputPath:r,screen:s,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:u,resolveCompletion:l,completionDelivered:!1},d;try{let p=Pe("node-pty"),f={name:"xterm-256color",cols:i,rows:o,cwd:e.cwd,env:Et($t())};d=p.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],f)}catch(p){let f={...c,status:"failed",endedAt:Date.now(),error:Ct(p)};return this.#e.set(n,f),this.#o(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.#o(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,o)=>{let s=a(()=>{this.stop(r.source,"cancelled").then(i,o)},"onAbort");n?.addEventListener("abort",s,{once:!0}),r.completion.then(l=>{n?.removeEventListener("abort",s),i(l)},o)})}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(o=>{let s=!1,l,u=a(p=>{s||(p!==void 0&&T(r.status)&&(p=void 0),s=!0,clearTimeout(d),clearInterval(m),n.signal?.removeEventListener("abort",c),p!==void 0&&(r.background=!0,r.waitReason=p,this.#n(r)),o({session:r,...p===void 0?{}:{reason:p}}))},"finish"),c=a(()=>u("aborted"),"onAbort"),d=setTimeout(()=>u("timeout"),n.timeoutMs),m=setInterval(()=>{if(!Rt(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,o;for(;Date.now()<r;){let s=e.outputStart+e.output.length;if(s!==i)i=s,o=Date.now(),await e.screenReady;else if(o!==void 0&&Date.now()-o>=40)return;await H(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),o=Math.max(1,Math.min(e.rows,r)),s=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(o/2)),l=-1;for(let d=0;d<=e.rows-o;d+=1){let m=0;for(let p=d;p<d+o;p+=1){let f=n[p]??"",h=i[p]??"",P=h.length>0&&!n.includes(h),b=f.length>0&&h.length===0;f!==h&&(P||b)&&(m+=1)}m>l&&(l=m,s=d)}let u=e.screen.buffer.active;return{lines:i.slice(s,s+o).map((d,m)=>{if(s+m!==u.cursorY)return d;let f=d.padEnd(u.cursorX," ");return`${f.slice(0,u.cursorX)}\u258C${f.slice(u.cursorX)}`}),startRow:s}}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),o=[];for(let s=0;s<e.rows;s+=1){let l=r.getLine(i+s)?.translateToString(!0).trimEnd();l!==void 0&&l.length>0&&o.push(l)}return o.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(At(n))}async stop(e,n="stopped"){let r=this.required(e);return T(r.status)||(r.status="stopping",this.#n(r),await xe(r,!1),await Promise.race([r.completion.then(()=>!0),H(bt).then(()=>!1)])||(await xe(r,!0),await Promise.race([r.completion,H(1e3)])),T(r.status)||(r.status=n,r.endedAt=Date.now(),this.#o(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.#o(n.id),pt(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=[],o=Math.max(0,r.baseY);for(let s=o;s<o+n.rows;s+=1)i.push(r.getLine(s)?.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.#s){this.#s=!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.#o(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=wt(n),i=this.#i.get(e.id);if(i!==void 0&&ft(i,r),e.output+=r,e.output.length>Re){let o=e.output.length-Re;e.output=e.output.slice(o),e.outputStart+=o}e.screenReady=e.screenReady.then(()=>new Promise(o=>{e.screen.write(n,o)})),this.#n(e)}#o(e){let n=this.#i.get(e);n!==void 0&&(ct(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 Rt(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(Rt,"looksInteractive");function xt(t,e){let{Terminal:n}=Pe("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}a(xt,"createScreen");function Pt(){return yt().replaceAll("-","").slice(0,12)}a(Pt,"defaultSessionId");function vt(t){return t.startsWith("shell:")?t.slice(6):t}a(vt,"normalizeSessionId");function T(t){return t!=="running"&&t!=="stopping"}a(T,"isTerminalStatus");function $t(){return process.env}a($t,"processEnvironment");function Et(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(Et,"cleanEnvironment");function At(t){return t.split(/[\s,]+/u).filter(Boolean).map(kt).join("")}a(At,"encodeTerminalKeys");function kt(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"),o=r.has("alt")||r.has("meta"),s=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 o?`\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&&!o&&!s&&l[n]!==void 0)return l[n];if(o&&!i&&!s&&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&&!o&&!s?`\x1B[${c}`:`\x1B[1;${1+(s?1:0)+(o?2:0)+(i?4:0)}${c}`;if(o&&!i&&n.length===1)return`\x1B${s?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}a(kt,"encodeTerminalKey");async function xe(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=ut("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}a(xe,"terminateProcessTree");function H(t){return new Promise(e=>setTimeout(e,t))}a(H,"delay");function Ct(t){return t instanceof Error?t.message:String(t)}a(Ct,"errorMessage");function Lt(t){let e=be.join(gt.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return dt(e,{recursive:!0,mode:448}),be.join(e,`${t}.log`)}a(Lt,"createOutputLog");import It from"node:os";import ve from"node:path";function $e(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",o=ve.win32.basename(i).toLowerCase();return o==="cmd"||o==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:a(s=>["/d","/s","/c",s],"commandArgs")}:{executable:i,displayName:o.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:a(s=>["-NoLogo","-NoProfile","-Command",s],"commandArgs")}}let n=e.SHELL?.trim()||It.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=ve.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:a(i=>["-c",i],"commandArgs")}}a($e,"resolveShellProfile");function Ee(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(Ee,"shellSyntaxGuidance");import Ae from"node:path";import{stripVTControlCharacters as Mt}from"node:util";import{defineTool as _t}from"@earendil-works/pi-coding-agent";import{Type as g}from"typebox";var Dt=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 ke(t,e,n,r){let i=process.platform==="win32"?"powershell":"bash";t.registerTool(_t({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. Foreground waits become background after timeoutSeconds (60 by default), on a stable interactive prompt, or when the turn is aborted. A background session with no output for two minutes wakes an idle agent so it can be inspected. Sessions survive extension reloads and keep the same shell: source. Large output returns a bounded tail and a fullOutput file path. 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; completion is delivered automatically and wakes the agent. 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. ${Ee(n)}`,parameters:Dt,async execute(o,s,l,u,c){r.bind(c);let d=s.cwd===void 0?c.cwd:Ae.resolve(c.cwd,s.cwd),m=e.start({command:s.command,background:s.background??!1,cwd:d,shell:n,...s.cols===void 0?{}:{cols:s.cols},...s.rows===void 0?{}:{rows:s.rows}});if(s.background===!0&&m.status!=="failed")return await Ot(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:(s.timeoutSeconds??60)*1e3});return p.reason==="aborted"&&r.notifyWaitTransition(p.session),k(e.snapshot(p.session))},renderCall(o,s){let l=typeof o.command=="string"?o.command:"",u=typeof o.cwd=="string"?Ae.resolve(process.cwd(),o.cwd):process.cwd();return ae(l,o.background===!0,u,n,s)},renderResult(o,s,l){return ue(o.details,s.expanded,l)}}))}a(ke,"registerTerminalTools");function k(t){return{content:[{type:"text",text:v(t)}],details:t,isError:t.status==="failed"||t.status==="lost"}}a(k,"terminalResult");async function Ot(t,e,n){await new Promise(r=>{let i=!1,o,s=a(()=>{},"unsubscribe"),l=a(()=>{i||(i=!0,clearTimeout(o),s(),r())},"finish"),u=a(()=>{let c=t.snapshot(e);n?.(k(c)),(Mt(c.output).replaceAll("\r","").split(`
|
|
22
|
+
`).filter(m=>m.length>0).length>=R||c.status!=="running")&&l()},"publish");s=t.onDidChange(c=>{c.id===e.id&&u()}),o=setTimeout(l,2e3),u()})}a(Ot,"captureInitialBackgroundPreview");import{Box as Ce,Container as Le}from"@earendil-works/pi-tui";var Nt=120,Ut=12e4,C=class{constructor(e,n,r=Ut){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:o},s)=>{let l=Ie(i.details)?i.details:void 0,u=new Le;l!==void 0&&u.addChild(S(l,o,s,"stale \xB7 inspect session"));let c=new Ce(1,1,d=>s.bg("toolPendingBg",d));return c.addChild(u),c}),e.registerMessageRenderer("terminal-completion",(i,{expanded:o},s)=>{let l=new Le;for(let c of Wt(i.details))l.addChild(S(c,o,s));let u=new Ce(1,1,c=>s.bg("toolSuccessBg",c));return u.addChild(l),u}),this.#u=[n.onDidChange(i=>this.#o(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;#s=!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.#o(r,!0)}}notifyWaitTransition(e){let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-wait-transition",display:!1,content:`Terminal wait aborted; ${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.#s=!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()}#o(e,n=!1){if(this.#l(e.id),this.#s||!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.#s||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:jt(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.#s||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.#s||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:Ft(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"})},Nt)))}};function Wt(t){return!_e(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(Ie)}a(Wt,"completionSnapshots");function Ie(t){return _e(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(Ie,"isTerminalSessionSnapshot");function Ft(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}`,o=n.output.trimEnd().slice(-2e3);return`- ${n.source}: ${n.status}${r}${i}, ${Me(n.elapsedMs)}
|
|
24
|
+
${o||"(no output)"}`}).join(`
|
|
25
|
+
`)}`}a(Ft,"formatCompletionMessage");function jt(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${Me(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
26
|
+
${e||"(no output)"}`}a(jt,"formatStaleMessage");function Me(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(Me,"formatElapsed");function _e(t){return typeof t=="object"&&t!==null}a(_e,"isRecord");async function Gt(t){let e=re("terminal")??new A,n=$e(),r=new C(t,e),i=te(t).add(de(e));await Promise.all([we(t,e),Te(t,e)]),ke(t,e,n,r),t.on("session_start",(o,s)=>r.bind(s)),t.on("agent_settled",(o,s)=>r.onAgentSettled(s)),t.on("session_shutdown",async o=>{if(r.dispose(),i(),o.reason==="reload"){ne("terminal",e);return}ie("terminal",e),await e.dispose()})}a(Gt,"registerTerminal");export{Gt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-NNCZYO4Q.js";import{d as N}from"./chunk-
|
|
1
|
+
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{d as O}from"./chunk-WGGIQ7IJ.js";import"./chunk-O6LE42GK.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
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-EI7MMDWY.js";var s=Symbol.for("pi-agent-ide.reload-resource-store");function n(){let e=globalThis,o=e[s];if(o!==void 0)return o;let r=new Map;return e[s]=r,r}t(n,"store");function u(e,o){n().set(e,o)}t(u,"retainReloadResource");function a(e){let o=n(),r=o.get(e);return o.delete(e),r}t(a,"takeReloadResource");function c(e,o){let r=n();r.get(e)===o&&r.delete(e)}t(c,"forgetReloadResource");export{u as a,a as b,c};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{a as b,d as A}from"./chunk-ITSNK5YG.js";import{a as $}from"./chunk-J4RTW44E.js";import{b as F,d as v}from"./chunk-526E364R.js";import{f as M}from"./chunk-YHUTTZC6.js";import{a as f}from"./chunk-EI7MMDWY.js";import N from"node:path";import{truncateHead as L,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 _=O.Union([O.String({minLength:1}),$]),I=O.Object({before:_,after:_},{additionalProperties:!1});async function ne(e,i,c){if(!re.Check(I,i))throw Object.assign(new Error("Use before and after source strings or read request objects"),{code:"INVALID_ARGUMENTS"});let n=i,r=f(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"),a=await r(n.before),s=await r(n.after),o=b(a.source,a.content,s.content,s.source);return{kind:"diff",ok:!0,equal:a.content===s.content,before:a,after:s,...o}}f(ne,"executeDiff");function B(e,i){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,i));return{source:e.source??i,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
|
+
`)}}f(B,"comparisonText");function R(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="diff"&&"ok"in e&&e.ok===!0}f(R,"isDiffOutcome");function E(e,i=process.cwd()){let c=f(r=>N.isAbsolute(r)?N.relative(i,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]})]}}f(E,"diffPresentation");function T(e){return e.equal?`No differences: ${e.before.source} \u2192 ${e.after.source}`:e.diff}f(T,"diffText");function Pe(e){return{content:[{type:"text",text:T(e)}],details:{}}}f(Pe,"diffReadResult");function ke(e,i,c){e.registerTool({name:"diff",label:"Diff",parameters:I,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,a,s){let o=n.details;if(o?.comparison?.equal)return new S(T(o.comparison),0,0);let l=i.getToolRenderer("diff")?.renderResult;return l?l(n,r,a,s):new S(n.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
4
|
+
`),0,0)},async execute(n,r,a,s,o){let l=c();if(l===void 0)throw new Error("Diff requires the read extension");let t=await ne(l,r,{cwd:o.cwd,signal:a}),p=T(t),y=L(p).truncated?await l.saveTemporary(p):void 0,d=y===void 0?"":`
|
|
5
|
+
Full diff: ${y}`;return{content:[{type:"text",text:y===void 0?p:L(p,{maxLines:te-2,maxBytes:ee-Buffer.byteLength(d)}).content+d}],details:{...E(t,o.cwd),comparison:t,temporarySource:y}}}})}f(ke,"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","apply","result"]);function V(e,i=q.parse(e)){let c=[];i.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 a=r.node.parent;for(;a?.parent&&!["VariableDeclaration","ParamList","Block","Script"].includes(a.name);)a=a.parent;let s=a?.name==="VariableDeclaration"&&a.firstChild?.name==="var",o=new Set(["Script","FunctionDeclaration","FunctionExpression","ArrowFunction",...s?[]:["Block"]]),l=r.node.parent;for(l?.name==="FunctionDeclaration"&&(l=l.parent);l?.parent&&!o.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 i.iterate({enter(r){if(r.name!=="CallExpression")return;let a=r.node.firstChild;if(a?.name!=="VariableName")return;let s=e.slice(a.from,a.to);if(!oe.has(s)||c.some(t=>t.name===s&&t.from<=r.from&&t.to>=r.to))return;let o=r.node.getChild("ArgList")?.getChild("ObjectExpression"),l=Object.create(null);if(!o){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 o?.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 d=t.lastChild;if(!d||d.type.isError||d.name===":")continue;let m=e.slice(d.from,d.to),u=m.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(m);l[y]={text:u.length>160&&!h?`${u.slice(0,100)}\u2026${u.slice(-40)} (${m.length} source chars)`:u,literal:["String","Number","BooleanLiteral","Null"].includes(d.name)&&d.lastChild?.type.isError!==!0}}return n.push({name:s,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}f(V,"parseApplyCalls");function ie(e,i=V(e),c,n=r=>r){let r=0,a=[],s=f(o=>n(o.split(`
|
|
6
|
+
`).map(l=>l.length>200?l.slice(0,200)+"\u2026":l).join(`
|
|
7
|
+
`)),"codePreview");for(let o of i)a.push(s(e.slice(r,o.from))),a.push(c?.(o)??`${o.name}(${o.path?o.path.literal?o.path.text:`\u2039${o.path.text}\u203A`:"\u2026"})`),r=o.to;return a.push(s(e.slice(r))),a.join("")}f(ie,"compactApplySource");function J(e,i){let c="",n="",r=[];return a=>{if(a===c)return n;let s=0;for(;s<c.length&&s<a.length&&c[s]===a[s];)s++;r=U.applyChanges(r,[{fromA:s,toA:c.length,fromB:s,toB:a.length}]);let o=q.parse(a,r);return r=U.addTree(o),n=ie(a,V(a,o),e,i),c=a,n}}f(J,"createApplySourceProjection");import{lstat as G,unlink as ae}from"node:fs/promises";import Y from"node:path";import z from"fs-extra";import{Type as x}from"typebox";import{Value as se}from"typebox/value";var P=x.String({minLength:1,description:"Local regular file path, relative to cwd or absolute."}),le=x.Object({path:P},{additionalProperties:!1}),ce=x.Object({path:P,target:P,overwrite:x.Optional(x.Boolean({description:"Allow replacing an existing regular target file. Defaults to false."}))},{additionalProperties:!1});function k(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="file-operation"}f(k,"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(i=>i!==void 0).join(`
|
|
8
|
+
`)}f(D,"formatFileOperation");async function Be(e,i,c,n){let r=!1,a,s;try{let o=e==="delete"?le:ce;if(!se.Check(o,i))throw Object.assign(new Error("Invalid file operation arguments"),{code:"INVALID_ARGUMENTS"});let l=i;a=Y.resolve(c,l.path),s=l.target===void 0?void 0:Y.resolve(c,l.target),n?.throwIfAborted();let t=await pe(a);if(s!==void 0){let p=await fe(s);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(a===s||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 ae(a):s!==void 0&&(e==="copy"?await z.copy(a,s,{overwrite:l.overwrite===!0,errorOnExist:!0}):await z.move(a,s,{overwrite:l.overwrite===!0})),{kind:"file-operation",operation:e,ok:!0,effect:"applied",path:a,...s===void 0?{}:{target:s}}}catch(o){return{kind:"file-operation",operation:e,ok:!1,effect:r?"unknown":"not-applied",...a===void 0?{}:{path:a},...s===void 0?{}:{target:s},error:{code:o!==null&&typeof o=="object"&&"code"in o?String(o.code):"FILE_OPERATION_FAILED",message:o instanceof Error?o.message:String(o)}}}}f(Be,"executeFileOperation");async function pe(e){let i=await G(e);if(!i.isFile()||i.isSymbolicLink())throw Object.assign(new Error("Source must be a regular file"),{code:"INVALID_FILE_TYPE"});return i}f(pe,"regularFile");async function fe(e){try{return await G(e)}catch(i){if(i!==null&&typeof i=="object"&&"code"in i&&i.code==="ENOENT")return;throw i}}f(fe,"optionalStat");import{Text as de}from"@earendil-works/pi-tui";function K(e){let i=e.select(),c=e.mutationValues().filter(ue);return i.files.map(n=>{let r=c.flatMap(o=>o.files.filter(l=>l.source===n.source).map(l=>({outcome:o,changed:l}))),a=e.mutationPresentation(n.source)?.data,s=a?.afterContent===n.after?a: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:s?.afterDocument,resultPresentation:s?.resultPresentation,scopeMarkers:s?.scopeMarkers,hints:s?.hints,warnings:s?.warnings,diffStatuses:s?.diffStatuses,diffs:[b(n.source,n.before??"",n.after??"").diff],operations:r.map(({outcome:o,changed:l})=>({operation:o.operation==="remove"?"delete":o.operation,changes:l.changes.length})),formatting:s?.formatting??r.at(-1)?.changed.formatting})})}f(K,"finalApplyMutations");function ue(e){return e!==null&&typeof e=="object"&&"operation"in e&&"files"in e&&Array.isArray(e.files)&&"effect"in e}f(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 rt(e,i,c,n=process.cwd()){let r=e.select(),a=[...r.automatic,...r.explicit.filter(t=>t.kind==="operation")].filter(t=>R(t.value)&&!t.value.equal),s=a.flatMap(t=>R(t.value)?[E(t.value,n)]:[]),o=new Set(a.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:s,cwd:n,blocks:[...i.content.filter(p=>!o.has(p)).flatMap(p=>p.type==="text"?[{text:H(p.text),read:t.find(g=>g.content.includes(p))}]:[])]}}let l=K(e);return{...l.length>0?{mutations:{results:l}}:{},comparisons:s,cwd:n,blocks:[...r.explicit.flatMap(t=>t.kind==="operation"&&R(t.value)&&!t.value.equal?[]:k(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})=>k(t)?[{text:D(t)}]:t!==null&&typeof t=="object"&&"kind"in t&&t.kind==="index-operation"?p?.content.flatMap(g=>g.type==="text"?[{text:g.text}]:[])??[]:t===null||typeof t!="object"||!("errors"in t)||!Array.isArray(t.errors)?[]:t.errors.flatMap(g=>g!==null&&typeof g=="object"&&"message"in g&&typeof g.message=="string"?[{text:g.message}]:[])),...c===void 0?[]:[{text:c instanceof Error?c.message:JSON.stringify(c)}]]}}f(rt,"createApplyDisplay");function j(e,i,c,n,r,a,s=!1){let o=Math.max(1,c);if(o<5)return e.split(`
|
|
9
|
+
`).flatMap(u=>W(u,o));let l=o-4,t=f(u=>i.fg("borderMuted",u),"border"),g=me(` ${n==="call"?"Apply \xB7 JavaScript":"Result"} `,o-4,""),y=[t(`${n==="call"?"\u256D":"\u251C"}\u2500`)+i.fg(s?"error":"accent",g)+t(`${"\u2500".repeat(Math.max(0,o-X(g)-3))}${n==="call"?"\u256E":"\u2524"}`)],d=`${t("\u2502")}${" ".repeat(o-2)}${t("\u2502")}`;for(let u of e.split(`
|
|
10
|
+
`)){let h=a==="diff"?i.fg(u.startsWith("+")?"toolDiffAdded":u.startsWith("-")?"toolDiffRemoved":"toolDiffContext",u):a?Z(u,a).join(`
|
|
11
|
+
`):i.fg("toolOutput",u);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(d),r&&y.push(t(`\u2570${"\u2500".repeat(o-2)}\u256F`));let m=i.getBgAnsi("toolPendingBg");return y.map(u=>m+M(u,m)+"\x1B[0m")}f(j,"applyFrameRows");function ge(e){return(i,c,n)=>{let r=n.state,a=r.projectSource??=J(e?o=>e(o,c):void 0,e?o=>Z(o,"javascript").join(`
|
|
12
|
+
`):void 0),s=i!==null&&typeof i=="object"&&"source"in i&&typeof i.source=="string"?i.source:"";return{invalidate(){},render(o){return j(r.codeView||n.expanded?r.displaySource??s:ye(a(r.displaySource??s)),c,o,"call",!r.applyResultReady,r.codeView||n.expanded||!e?"javascript":void 0)}}}}f(ge,"createApplyCallRenderer");function ye(e,i=F){let c=e.split(`
|
|
13
|
+
`);if(c.length<=i)return e;let n=Math.max(2,i-1),r=Math.ceil(n/2),a=Math.floor(n/2),s=c.length-r-a;return[...c.slice(0,r),`\u2026 ${s} lines omitted \u2026`,...c.slice(-a)].join(`
|
|
14
|
+
`)}f(ye,"compactApplyPreview");var nt=ge();function he(e){return(i,c,n,r)=>{r.state.applyResultReady=!0;let a=i.details;r.state.displaySource=a?.displaySource;let s=a?.display,o=s?.blocks??[{text:r.isError?"Apply failed":"Apply finished"}],l=v({kind:"source"}),t=o.map(d=>l(d.read??{content:[{type:"text",text:d.text}],details:we(d.text)},c,n,{...r,isError:!1,lastComponent:void 0})),p=s?.mutations,g=(s?.comparisons??[]).flatMap(d=>[e?.(d,n,c.expanded,s?.cwd??process.cwd())??new de((d.results??[]).flatMap(u=>u.data.diffs??[]).join(`
|
|
15
|
+
`),0,0)]),y=p===void 0?void 0:e?.(p,n,c.expanded,s?.cwd??process.cwd());return{invalidate(){y?.invalidate();for(let d of g)d.invalidate()},render(d){let m=[];for(let u of t){let h=u.render(Math.max(1,d-4));h.length!==0&&(m.length>0&&m.push(""),m.push(...h))}for(let u of g)m.length>0&&m.push(""),m.push(...u.render(Math.max(1,d-4)));if(y!==void 0){let u=y.render(Math.max(1,d-4));m.length>0&&u.length>0&&m.push(""),m.push(...u)}else p!==void 0&&m.push(...(p.results??[]).map(u=>u.path??"Changed file"));return m.length===0&&o.length>0&&o.every(u=>u.read?.details.diagnosticCheck?.complete&&u.read.details.diagnosticCheck.count===0)?j("",n,d,"result",!0).slice(-1):j(m.length===0?"No output":m.join(`
|
|
16
|
+
`),n,d,"result",!0,void 0,r.isError)}}}}f(he,"createApplyResultRenderer");function H(e){if(/^(?:Undo transaction:|Undo available)/u.test(e.trim()))return"";try{let i=JSON.parse(e);return JSON.stringify(C(i),null,2)}catch{return e.replace(/APPLY#[0-9A-F]{12}/gu,"Apply transaction")}}f(H,"redactApplyReceipts");function C(e){return Array.isArray(e)?e.map(C):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).filter(([i])=>i!=="transaction").map(([i,c])=>[i,C(c)]))}f(C,"redactTransactionKeys");function we(e){try{let i=JSON.parse(e);return i!==null&&typeof i=="object"?{source:"result.json"}:{}}catch{return{}}}f(we,"jsonDetails");var ot=he();export{ne as a,Pe as b,ke as c,Be as d,K as e,rt as f,ge as g,nt as h,he as i,ot as j};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import"./chunk-3YK4XMWB.js";import{a as J,b as V,c as U,d as q,f as z}from"./chunk-
|
|
1
|
+
import"./chunk-3YK4XMWB.js";import{a as J,b as V,c as U,d as q,f as z}from"./chunk-T6LX2RX5.js";import{d as L,e as h}from"./chunk-M5MJP7Z2.js";import{a as E}from"./chunk-WZI4YC2O.js";import{d as N}from"./chunk-N34ATN52.js";import{a as O}from"./chunk-ZC65Z3CK.js";import{a as _,b as F,c as M}from"./chunk-JMVDFOTQ.js";import{a as c}from"./chunk-EI7MMDWY.js";import{mkdir as ie,readFile as B,writeFile as re}from"node:fs/promises";async function G(n,t){await ie(L(n),{recursive:!0});let e=[],o=t.filter(r=>r.recipe.formatter!==void 0),i=t.filter(r=>r.recipe.linter!==void 0),s=t.filter(r=>r.recipe.lsp!==void 0);if(o.length>0){let r=h(n,"formatters"),a=await S(r,{version:1,formatters:{}}),u=P(a,"formatters");for(let l of o)u[l.recipe.id]??=l.recipe.formatter;await R(r,a)&&e.push(r)}if(i.length>0){let r=h(n,"linters"),a=await S(r,{version:1,linters:{}}),u=P(a,"linters");for(let l of i)u[l.recipe.id]??=l.recipe.linter;await R(r,a)&&e.push(r)}if(s.length>0){let r=h(n,"lsp-servers"),a=await S(r,{version:1,servers:{}}),u=P(a,"servers");for(let l of s){let d=O(l.recipe.lsp);u[l.recipe.id]??={command:d.command,transport:"stdio",rootMarkers:d.rootMarkers,...d.initializationOptions!==void 0&&{initializationOptions:d.initializationOptions},...d.settings!==void 0&&{settings:d.settings},...d.requireRootMarker!==void 0&&{requireRootMarker:d.requireRootMarker},languages:Object.fromEntries(Object.entries(d.languageIds).map(([p,f])=>[p,{extensions:f,...d.fileNames?.[p]&&{fileNames:d.fileNames[p]}}])),capabilities:["diagnostics"]}}await R(r,a)&&e.push(r)}return e}c(G,"writeSuggestedConfigs");async function S(n,t){try{let e=JSON.parse(await B(n,"utf8"));if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must contain an object`);return e}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return t;throw e}}c(S,"readObject");function P(n,t){let e=n[t];if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} must be an object`);return e}c(P,"objectMember");async function R(n,t){let e=`${JSON.stringify(t,null,2)}
|
|
2
2
|
`;return await B(n,"utf8").catch(()=>{})===e?!1:(await re(n,e,"utf8"),!0)}c(R,"writeJson");var C=class{static{c(this,"DoctorCore")}plugins=new Map;languages=[];recipes=[];setupChecks=[];checks=[];queue=Promise.resolve();registerPlugin(t){let e=this.plugins.get(t.id);if(e!==void 0)return e;let o=this.queue.then(async()=>{let i=!0,s=[],r=[],a=[],u=[],l={addLanguage:c(d=>{b(d,s,t.id,"language",()=>i)},"addLanguage"),addToolRecipe:c(d=>{b(d,r,t.id,"tool recipe",()=>i)},"addToolRecipe"),addSetupCheck:c(d=>{b(d,a,t.id,"setup check",()=>i)},"addSetupCheck"),addCheck:c(d=>{b(d,u,t.id,"check",()=>i)},"addCheck")};try{await t.setup(l)}finally{i=!1}W(this.languages,s,"language"),W(this.recipes,r,"tool recipe"),this.languages.push(...s),this.recipes.push(...r),this.setupChecks.push(...a),this.checks.push(...u)});return this.plugins.set(t.id,o),this.queue=o.catch(()=>{}),o.catch(()=>{this.plugins.delete(t.id)}),o}async waitForPlugins(){await Promise.all(this.plugins.values())}snapshot(){return{languages:[...this.languages],recipes:[...this.recipes],setupChecks:[...this.setupChecks],checks:[...this.checks]}}};async function H(n,t){let e=[],o=[];for(let i of n.setupChecks)try{let s=await i.value.inspect(t);e.push(...(s.selections??[]).map(r=>({...r,pluginId:i.pluginId}))),o.push(...(s.actions??[]).map(r=>({...r,pluginId:i.pluginId})))}catch{}return{selections:e,actions:o}}c(H,"runContributedSetupChecks");async function X(n,t){let e=[];for(let o of n.checks)try{e.push({pluginId:o.pluginId,title:o.value.title,findings:await o.value.run(t)})}catch(i){e.push({pluginId:o.pluginId,title:o.value.title,findings:[{status:"fail",message:i instanceof Error?i.message:String(i)}]})}return e}c(X,"runContributedChecks");function W(n,t,e){for(let o of t){let i=n.find(s=>s.value.id===o.value.id)?.pluginId;if(i!==void 0)throw new Error(`${e} ${o.value.id} is already owned by doctor plugin ${i}`)}}c(W,"assertAvailable");function b(n,t,e,o,i){if(!i())throw new Error(`Doctor plugin ${e} setup is complete`);if(!/^[a-z0-9][a-z0-9.-]*$/u.test(n.id))throw new Error(`Invalid ${o} ID: ${n.id}`);if(t.some(s=>s.value.id===n.id))throw new Error(`Doctor plugin ${e} registered ${o} ${n.id} twice`);t.push({pluginId:e,value:n})}c(b,"add");import fe from"node:path";import{readFile as se}from"node:fs/promises";async function Y(n,t,e,o=process.env){let i=await E(n,e.map(a=>a.value)),s=await ce(n),r=[];for(let a of e){let u=a.value;if(u.languages.every(v=>!t.has(v)))continue;let l=[],d=1,p=i.get(u.id),f=p?.config;f!==void 0&&(d+=6,l.push(`project config: ${f}`)),s.has(`${u.kind}:${u.id}`)&&(d+=6,l.push("Pi Agent IDE config"));let w=p?.dependency;w!==void 0&&(d+=4,l.push(`project dependency: ${w}`));let m=await ae(n,u.executables,o);m!==void 0&&(d+=3,l.push(`executable: ${m}`)),r.push({pluginId:a.pluginId,recipe:u,score:d,evidence:l,...m&&{executable:m}})}return r.sort((a,u)=>u.score-a.score||a.recipe.id.localeCompare(u.recipe.id))}c(Y,"discoverRecipeCandidates");function K(n,t,e=[]){let o=new Map,i=new Map(e.map(s=>[`${s.kind}:${s.languageId}`,s.toolId]));for(let s of t)for(let r of["formatter","linter","lsp"]){let a=i.get(`${r}:${s}`),u=a===void 0?4:7,l=n.filter(p=>p.recipe.kind===r&&p.recipe.languages.includes(s)&&p.executable!==void 0&&p.recipe.id!==a&&p.score>=u),d=l[0];d!==void 0&&(l.filter(p=>p.score===d.score).length>1||o.set(`${d.recipe.kind}:${d.recipe.id}`,d))}return[...o.values()]}c(K,"selectSuggestedRecipes");async function ae(n,t,e){for(let o of t)if(await N(o,n,e))return o}c(ae,"firstExecutable");async function ce(n){let t=new Set;for(let[e,o,i]of[["formatters","formatters","formatter"],["linters","linters","linter"],["lsp-servers","servers","lsp"]])try{let s=JSON.parse(await se(h(n,e),"utf8"));if(typeof s!="object"||s===null||Array.isArray(s))continue;let a=s[o];if(typeof a=="object"&&a!==null&&!Array.isArray(a))for(let u of Object.keys(a))t.add(`${i}:${u}`)}catch{}return t}c(ce,"managedRecipeIds");import{execFile as de}from"node:child_process";import{readdir as ue}from"node:fs/promises";import y from"node:path";import{promisify as le}from"node:util";var pe=le(de),ge=new Set([".git",".hg",".svn","node_modules","vendor","build","dist","coverage",".cache",".next","target"]);async function Q(n,t){t?.throwIfAborted();try{let o=(await pe("git",["ls-files","--cached","--others","--exclude-standard","-z"],{cwd:n,encoding:"utf8",maxBuffer:16777216,signal:t})).stdout.split("\0").filter(Boolean).map(i=>y.resolve(n,i)).filter(i=>!ee(i));return t?.throwIfAborted(),o.length>0?o:await k(n,t)}catch{return t?.throwIfAborted(),k(n,t)}}c(Q,"collectProjectFiles");function Z(n,t){let e=new Map;for(let o of t){let i=new Set(o.extensions.map(a=>a.toLowerCase())),s=new Set(o.fileNames),r=n.filter(a=>!a.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")&&(i.has(y.extname(a).toLowerCase())||s.has(y.basename(a))));r.length>0&&e.set(o.id,r)}return e}c(Z,"detectProjectLanguages");async function k(n,t){t?.throwIfAborted();let e=[];for(let o of await ue(n,{withFileTypes:!0})){if(o.isDirectory()&&ge.has(o.name))continue;let i=y.join(n,o.name);ee(i)||(o.isDirectory()?e.push(...await k(i,t)):o.isFile()&&e.push(i))}return e}c(k,"walk");function ee(n){return n.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")}c(ee,"isManagedIdeConfig");async function $(n,t,e=process.env,o){o?.throwIfAborted();let i=await Q(t,o);o?.throwIfAborted();let s=Z(i,n.languages.map(p=>p.value)),r=new Set(s.keys()),a={cwd:t,files:i,detectedLanguageIds:r,detectedLanguages:s,env:e},[u,l]=await Promise.all([Y(t,r,n.recipes,e),H(n,a)]),d=new Map;for(let p of r)for(let f of["formatter","linter","lsp"]){if(l.selections.some(g=>g.languageId===p&&g.kind===f))continue;let w=u.filter(g=>g.recipe.kind===f&&g.recipe.languages.includes(p)),m=c(g=>g.score-(g.executable===void 0?0:3),"nativeScore"),v=Math.max(1,...w.map(m));for(let g of w){if(g.executable!==void 0||m(g)!==v||v<=1)continue;let T=`${f}-${g.recipe.id}-unavailable`;d.set(T,{id:T,pluginId:g.pluginId,message:`Native project setup selects ${g.recipe.id}, but its executable is unavailable. Install ${g.recipe.executables.join(" or ")} and run Doctor again.`})}}return{cwd:t,files:i,detectedLanguages:s,candidates:u,selections:l.selections,actions:[...l.actions,...d.values()],suggestions:K(u,r,l.selections)}}c($,"inspectDoctorSetup");async function I(n,t,e=process.env){let o=await $(n,t,e),i=new Set(o.detectedLanguages.keys()),s={cwd:t,files:o.files,detectedLanguageIds:i,detectedLanguages:o.detectedLanguages,env:e},r=await X(n,s),a=[{status:"pass",message:`Project: ${t}`},o.files.length>0?{status:"pass",message:`${o.files.length} project files inspected`}:{status:"warn",message:"No project files found"},i.size>0?{status:"pass",message:`Detected: ${[...i].join(", ")}`}:{status:"warn",message:"No registered project languages detected"}];return{...o,sections:[{title:"Project",pluginId:"doctor",findings:a},...r]}}c(I,"runDoctor");function D(n){let t=["Pi Agent IDE doctor",""];for(let e of n.sections){t.push(`${e.title} (${e.pluginId})`);for(let o of e.findings)t.push(` ${o.status.toUpperCase().padEnd(4)} ${o.message}`),o.detail!==void 0&&t.push(` \`${o.detail}\``);t.push("")}if(n.actions.length>0){t.push("Setup needs attention");for(let e of n.actions)t.push(` ${e.message} [${e.pluginId}]`);t.push("")}if(n.suggestions.length>0){t.push("Suggested configuration");for(let e of n.suggestions){let o=e.evidence.length>0?` \u2014 ${e.evidence.join(", ")}`:"";t.push(` ${e.recipe.kind.padEnd(9)} ${e.recipe.id} [${e.pluginId}]${o}`)}t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()}c(D,"formatDoctorReport");function j(n){return n.actions.length>0||n.suggestions.length>0||n.sections.some(t=>t.findings.some(e=>e.status==="fail"))}c(j,"doctorNeedsWork");function te(n){let t=n.candidates.map(e=>({owner:e.pluginId,id:e.recipe.id,kind:e.recipe.kind,languages:e.recipe.languages,evidence:e.evidence,documentation:e.recipe.documentation}));return["Finish configuring Pi Agent IDE for this project.","Preserve existing formatter, linter, compiler, and style rules. Do not invent or replace native project settings.","Do not install packages, write credentials, or change source files without the user's normal confirmation.","Pi Agent IDE project configs live in .pi/pi-agent-ide/.","Use only the relevant plugin contributions listed below; each owner remains responsible for its own scope.","",D(n),"","Relevant registered recipes:",JSON.stringify(t,null,2),"",`Project root: ${fe.resolve(n.cwd)}`].join(`
|
|
4
4
|
`)}c(te,"buildDoctorAgentPrompt");import{createHash as me}from"node:crypto";var he="doctor",x=3;function ne(n,t){let e=_(n,ye(t));e!==void 0&&e.catch(()=>{})}c(ne,"registerDoctorTipProvider");function ye(n){return{protocol:F,apiVersion:M,id:he,async getTip(t){let e=await n(t),o=we(e);if(o.length===0)return;let i=o.slice(0,x).map(s=>`\u2022 ${s.message}`);return o.length>x&&i.push(`\u2022 ${o.length-x} more`),{id:`doctor-setup-${De(o)}`,title:o.length===1?"Project setup needs attention":`${o.length} project setup items`,body:[...i,"Run /pi-agent-ide-doctor"].join(`
|
|
5
|
-
`)}}}}c(ye,"createDoctorTipProvider");function we(n){let t=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),e=n.suggestions.map(o=>{let i=o.recipe.languages.filter(r=>n.detectedLanguages.has(r)).join(", "),s={formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${i} ${s}`}});return[...t,...e].sort((o,i)=>o.id.localeCompare(i.id))}c(we,"setupItems");function De(n){return me("sha256").update(n.map(t=>`${t.id}\0${t.message}`).join("\0")).digest("hex").slice(0,12)}c(De,"fingerprint");async function oe(n){let t=new C;ne(n,async i=>(await t.waitForPlugins(),$(t.snapshot(),i.cwd,process.env,i.signal)));let e,o=n.events.on(q,i=>{if(!z(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",o),n.registerCommand("pi-agent-ide-doctor",{description:"Check and configure Pi Agent IDE for this project",handler:c(async(i,s)=>{await t.waitForPlugins();let r=await I(t.snapshot(),s.cwd);A(n,D(r));let a=new Set(i.trim().split(/\s+/u).filter(Boolean));if(r.suggestions.length>0&&!a.has("--no-apply")&&(a.has("--apply")||s.hasUI&&await s.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let d=await G(s.cwd,r.suggestions),p=d.length===0?"Pi Agent IDE configs are already up to date":`Updated ${d.length} Pi Agent IDE config ${d.length===1?"file":"files"}`;s.ui.notify(p,"info"),r=await I(t.snapshot(),s.cwd),A(n,D(r))}if(!j(r)&&!a.has("--agent"))return;(a.has("--agent")||s.hasUI&&await s.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(e=s.cwd,n.sendUserMessage(te(r)))},"handler")}),n.on("agent_end",async(i,s)=>{let r=e;if(r===void 0)return;e=void 0;let a=await I(t.snapshot(),r,process.env);A(n,`Doctor recheck after agent setup
|
|
5
|
+
`)}}}}c(ye,"createDoctorTipProvider");function we(n){let t=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),e=n.suggestions.map(o=>{let i=o.recipe.languages.filter(r=>n.detectedLanguages.has(r)).join(", "),s={debugger:"debugging",formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${i} ${s}`}});return[...t,...e].sort((o,i)=>o.id.localeCompare(i.id))}c(we,"setupItems");function De(n){return me("sha256").update(n.map(t=>`${t.id}\0${t.message}`).join("\0")).digest("hex").slice(0,12)}c(De,"fingerprint");async function oe(n){let t=new C;ne(n,async i=>(await t.waitForPlugins(),$(t.snapshot(),i.cwd,process.env,i.signal)));let e,o=n.events.on(q,i=>{if(!z(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",o),n.registerCommand("pi-agent-ide-doctor",{description:"Check and configure Pi Agent IDE for this project",handler:c(async(i,s)=>{await t.waitForPlugins();let r=await I(t.snapshot(),s.cwd);A(n,D(r));let a=new Set(i.trim().split(/\s+/u).filter(Boolean));if(r.suggestions.length>0&&!a.has("--no-apply")&&(a.has("--apply")||s.hasUI&&await s.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let d=await G(s.cwd,r.suggestions),p=d.length===0?"Pi Agent IDE configs are already up to date":`Updated ${d.length} Pi Agent IDE config ${d.length===1?"file":"files"}`;s.ui.notify(p,"info"),r=await I(t.snapshot(),s.cwd),A(n,D(r))}if(!j(r)&&!a.has("--agent"))return;(a.has("--agent")||s.hasUI&&await s.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(e=s.cwd,n.sendUserMessage(te(r)))},"handler")}),n.on("agent_end",async(i,s)=>{let r=e;if(r===void 0)return;e=void 0;let a=await I(t.snapshot(),r,process.env);A(n,`Doctor recheck after agent setup
|
|
6
6
|
|
|
7
7
|
${D(a)}`),j(a)?s.ui.notify("Pi Agent IDE setup still needs attention","warning"):s.ui.notify("Pi Agent IDE setup is ready","info")}),n.events.emit(U,{protocol:J,apiVersion:1}),await t.waitForPlugins()}c(oe,"registerDoctor");function A(n,t){n.sendMessage({customType:"pi-agent-ide-doctor",content:t,display:!0},{triggerTurn:!1})}c(A,"sendReport");export{oe as default};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as s}from"./chunk-S3ZPXWX7.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";import{Type as n}from"typebox";var l=n.Object({path:n.Optional(n.String({description:"What to read: a 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."})),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."})),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())}),y=e.Object({id:e.String({pattern:"\\S"}),priority:e.Optional(e.Number()),resolve:a}),c=e.Object({view:e.String({pattern:"\\S"}),includes:e.Optional(e.Array(e.String({pattern:"\\S"}))),presenter:e.Object({id:e.String(),present:a}),priority:e.Optional(e.Number())}),p=e.Object({resolvedBy:e.String({pattern:"\\S"}),contentKind:e.Union([e.Literal("text"),e.Literal("any")])}),g=e.Union([e.Object({stage:e.Literal("pre-read"),handler:a}),e.Object({stage:e.Literal("read"),when:p,handler:a}),e.Object({stage:e.Literal("post-read"),handler:a})]);function h(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(h,"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(c,t)}o(C,"isReadViewRegistration");function k(t){return i.Check(y,t)}o(k,"isFragmentResolverRegistration");function P(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(P,"isReadFragmentResolution");function m(t){return typeof t=="object"&&t!==null}o(m,"isRecord");export{l as a,h as b,O as c,S as d,C as e,k as f,P as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Type as e}from"typebox";var
|
|
1
|
+
import{Type as e}from"typebox";var t=e.Object({query:e.String({minLength:1,description:"Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching."}),path:e.Optional(e.String({description:"Optional file or directory scope for local search"})),include:e.Optional(e.String({description:"Optional include glob for local search"})),exclude:e.Optional(e.String({description:"Optional exclude glob for local search"})),caseSensitive:e.Optional(e.Boolean({description:"Match letter case in local search"})),wholeWord:e.Optional(e.Boolean({description:"Match complete words in local search"})),limit:e.Optional(e.Integer({minimum:1,maximum:1e3,description:"Maximum detailed results returned to the agent (default 50)"}))},{additionalProperties:!1});export{t as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as u,f as E,k as a}from"./chunk-
|
|
1
|
+
import{e as u,f as E,k as a}from"./chunk-O6LE42GK.js";import{a as n}from"./chunk-EI7MMDWY.js";function T(o,r){let s=n(()=>{let e,i={plugin:r,accept(c){if(e!==void 0)throw new Error(`Plugin ${r.id} registration was accepted more than once`);e=c}};return o.events.emit(E,i),e},"announce"),t=n(()=>{},"unsubscribe");t=o.events.on(u,e=>{if(!a(e))throw new Error("Invalid pi-agent-text-editor core readiness event");let i=s();if(i===void 0)throw new Error("pi-agent-text-editor core announced readiness without accepting the plugin");t(),i.catch(()=>{})}),o.on("session_shutdown",t);let d=s();if(d!==void 0)return t(),d}n(T,"connectTextEditorPlugin");export{T as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,l as M}from"./chunk-
|
|
1
|
+
import{a as j,l as M}from"./chunk-WGGIQ7IJ.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-Z3VC3S2T.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var h=[],y=[],P=[];function b(n,t,e){if(t.some(i=>i.name===e))throw new Error(`[pi-agent-ide] ${n} "${e}" is already registered. Use a unique name.`)}c(b,"assertUniqueName");function q(n){let t=new Set;for(let e of n){let i=`${e.kind}:${e.name}`;if(t.has(i))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(i),e.kind){case"compiler":{b(e.kind,y,e.name);break}case"formatter":{b(e.kind,h,e.name);break}case"linter":{b(e.kind,P,e.name);break}}}for(let e of n)switch(e.kind){case"compiler":{y.push(e);break}case"formatter":{h.push(e);break}case"linter":{P.push(e);break}}}c(q,"registerTools");async function L(n,t){let e=[];for(let i of n)try{await i.detect(t)&&e.push(i)}catch(o){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,o)}return e.sort((i,o)=>o.priority-i.priority),H(e),e}c(L,"filterActive");function H(n){let t=new Map;for(let e of n)for(let i of e.extensions){let o=`${i}@${e.priority}`,a=t.get(o);if(a!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${a}" and "${e.name}" both claim "${i}" at priority ${e.priority}.`);t.set(o,e.name)}}c(H,"assertNoPriorityConflicts");async function G(n){let[t,e]=await Promise.all([L(h,n),L(y.filter(i=>i.syntaxOnly===!0),n)]);return{ctx:n,formatters:t,compilers:e,linters:[]}}c(G,"warmupFormatting");function T(){h.length=0,y.length=0,P.length=0}c(T,"resetRegistry");import{readFile as D}from"node:fs/promises";import g from"node:path";var v=class{constructor(t,e={}){this.sources=t;this.options=e}static{c(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:i}){this.disposed||this.ensure(t,e,i)}async read(t,{cwd:e,mode:i,signal:o}){o?.throwIfAborted(),this.assertActive();let a=g.resolve(e,t),s=await D(a,"utf8");this.assertActive();let r=this.ensure(a,s,e);i==="complete"?await this.waitComplete(r,o):i!=="snapshot"&&await K(Promise.all(r.jobs),this.options.readWaitMs??5e3),o?.throwIfAborted(),this.assertActive();let d=await D(a,"utf8");this.assertActive();let l=this.ensure(a,d,e);if(i==="complete"&&l!==r)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:a,content:l.content,results:[...l.results.values()]}}async waitComplete(t,e){let i=e?AbortSignal.any([e,t.controller.signal]):t.controller.signal;i.throwIfAborted();let o=[];await new Promise((a,s)=>{let r=c(m=>s(Object.assign(new Error(m),{code:m,details:[...t.results.values()]})),"fail"),d=c(()=>{let m=[...t.results.values()];m.some(w=>w.status==="unavailable")?r("DIAGNOSTICS_UNAVAILABLE"):m.every(w=>w.status==="ready")&&a()},"check"),l=c(()=>s(i.reason),"abort"),f=this.onDidChange(d),u=setTimeout(()=>r("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",l,{once:!0});let p=c(()=>{clearTimeout(u),f(),i.removeEventListener("abort",l)},"cleanup");Promise.resolve().then(d),o.push(p)}).finally(()=>{for(let a of o)a()})}async takeNotifications(t){let e=[];for(let i of[...this.dirty]){if(i.cwd!==g.resolve(t)||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let o=[...i.results.values()].filter(d=>d.status!=="pending"&&d.status!=="unavailable"&&d.diagnostics.length>0),a=this.key(i.filePath,i.cwd),s=JSON.stringify(o);if(this.sent.get(a)===s||(this.sent.set(a,s),o.length===0))continue;let r=o.map(d=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=d.diagnostics.filter(p=>p.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${d.source} ${l.join(", ")}${d.status==="snapshot"?" (snapshot; completion unknown)":d.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,i.filePath),results:o,text:`${JSON.stringify(g.relative(t,i.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,i){let o=this.key(t,i),a=this.files.get(o);if(a?.content===e)return a;a?.controller.abort(),a&&this.dirty.delete(a);let s={cwd:g.resolve(i),filePath:g.resolve(i,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let d=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(d)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await D(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,i){let o=(t.publications.get(e)??0)+1;if(t.publications.set(e,o),!await this.isCurrent(t)||t.publications.get(e)!==o)return;let a={...i,source:i.source??e};if(JSON.stringify(t.results.get(e))===JSON.stringify(a))return;t.results.set(e,a),this.dirty.add(t);let s=[...t.results.values()].some(r=>r.status!=="pending"&&r.status!=="unavailable"&&r.diagnostics.length>0);s||this.sent.delete(this.key(t.filePath,t.cwd));for(let r of this.changeListeners)r(t.cwd,s)}async check(t,e){if(!await this.isCurrent(t))return;let i=new AbortController,o=AbortSignal.any([i.signal,t.controller.signal]);if(o.aborted)return;let a,s;try{let r=new Promise((l,f)=>{s=c(()=>f(o.reason),"onAbort"),o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:o,publish:c(l=>{o.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,d)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(a),s&&o.removeEventListener("abort",s)}}};async function K(n,t){let e;try{await Promise.race([n,new Promise(i=>{e=setTimeout(i,t)})])}finally{clearTimeout(e)}}c(K,"waitAtMost");function V(){let n=new Map,t=[],e=new v(t),i=Promise.resolve();return{diagnostics:e,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=n.get(o.id);if(a!==void 0)return a;let s=i.then(async()=>{let r=[],d=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);Z(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);tt(u),d.push(u)},readDiagnostics(u,p){return e.read(u,p)}};try{await o.setup(f)}catch(u){throw l=!1,u}l=!1,Q(t,d),q(r),t.push(...d)});return n.set(o.id,s),i=s.catch(()=>{}),s.catch(()=>{n.delete(o.id)}),s},async waitForPendingPlugins(){await Promise.all(n.values())}}}c(V,"createIdeCore");function Q(n,t){let e=new Set(n.map(i=>i.id));for(let i of t){if(e.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);e.add(i.id)}}c(Q,"assertUniqueDiagnosticSources");function Z(n){if(!U(n))throw new TypeError("IDE tool must be an object");let t=n.kind,e=t==="compiler"?n.compile:t==="formatter"?n.format:t==="linter"?n.lint:void 0;if(e===void 0||typeof e!="function"||typeof n.detect!="function"||typeof n.name!="string"||n.name.trim().length===0||typeof n.priority!="number"||!Number.isFinite(n.priority)||!Array.isArray(n.extensions)||n.extensions.length===0||n.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}c(Z,"assertIdeTool");function tt(n){if(!U(n)||typeof n.id!="string"||n.id.trim().length===0||typeof n.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}c(tt,"assertDiagnosticSource");function U(n){return typeof n=="object"&&n!==null}c(U,"isRecord");function J(n,t,e=console.error){let i=new Map,o=!1,a=Promise.resolve();return{schedule(s){if(o||i.has(s))return;let r=setTimeout(()=>{i.delete(s),a=a.then(async()=>{o||await n(s)}).catch(e)},t);i.set(s,r)},dispose(){o=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}c(J,"createDiagnosticDelivery");import{Text as Y}from"@earendil-works/pi-tui";var S="ide-diagnostic-summary";function W(n){return{filePath:n.filePath,sources:n.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let i of t.diagnostics)e[i.severity]++;return{source:t.source,status:t.status,counts:e}})}}c(W,"diagnosticEntryData");function E(n,t,e=!1){return{render(i){let o=n.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(d=>d>0));if(o.length===0)return[];let a=o.map(r=>`${x(r.counts,t)} ${t.fg("dim",`(${I(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",I(n.filePath))} \xB7 ${a}`];if(e)for(let r of o)s.push(` ${t.fg("dim",I(r.source))} \xB7 ${x(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new Y(s.join(`
|
|
2
2
|
`),0,0).render(i)},invalidate(){}}}c(E,"renderDiagnosticEntry");function B(n){n.registerEntryRenderer(S,(t,e,i)=>{let o=k(t.data);return"files"in o?et(o.files,i,e.expanded):E(o,i,e.expanded)})}c(B,"registerDiagnosticEntryRenderer");function et(n,t,e=!1){return{render(i){let o=n.filter(d=>d.sources.some(l=>l.status!=="pending"&&l.status!=="unavailable"&&Object.values(l.counts).some(f=>f>0)));if(o.length===1&&o[0])return E(o[0],t,e).render(i);if(o.length===0)return[];let a={error:0,warning:0,info:0,hint:0},s=new Set;for(let d of o)for(let l of d.sources)if(!(l.status==="pending"||l.status==="unavailable")){s.add(l.source);for(let f of["error","warning","info","hint"])a[f]+=l.counts[f]}let r=new Y(`${t.fg("accent","Diagnostics")} \xB7 ${o.length} files \xB7 ${x(a,t)} \xB7 ${s.size} tools`,0,0).render(i);return e?[...r,...o.flatMap(d=>E(d,t,!0).render(i))]:r},invalidate(){}}}c(et,"renderDiagnosticBatch");function x(n,t){return["error","warning","info","hint"].filter(e=>n[e]>0).map(e=>{let i=n[e],o=e==="info"||i===1?e:`${e}s`,a=i>0&&(e==="error"||e==="warning")?e:"muted";return t.fg(a,`${i} ${o}`)}).join(", ")}c(x,"renderCounts");function I(n){return n.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}c(I,"plain");import X from"node:path";async function z(n){if(!X.isAbsolute(n.resourceSource))return{formatting:{status:"unavailable"}};let t;try{let e=await G({cwd:n.cwd}),i=X.extname(n.resourceSource).toLowerCase(),o=c(d=>d.extensions.includes(i)||d.extensions.includes("*"),"matches"),a=e.compilers.find(o);if(a&&(await a.compile({filePath:n.resourceSource},e.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=e.formatters.find(o);if(!s)return{formatting:{status:"unavailable"}};t=s.name;let r=await s.format({filePath:n.resourceSource},e.ctx);return r.formatter===null?{formatting:{status:"unavailable"}}:(t=r.formatter??s.name,{formatting:{status:r.ok?r.edits>0?"changed":"unchanged":"failed",formatter:t},...r.ok?{diffStatuses:[{text:`Formatted (${t})`,tone:"success",formatter:t}]}:{diffStatuses:[{text:`Formatting failed (${t})`,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error"}],formatting:{status:"failed",...t===void 0?{}:{formatter:t}}}}}c(z,"runIdePostEditGate");import it from"node:path";async function nt(n){T();let t=V();B(n);let e=n.events.on($,s=>{if(!F(s))throw new Error("Invalid pi-agent-ide plugin registration request");s.accept(t.registerPlugin(s.plugin))});n.on("session_shutdown",()=>{e(),t.diagnostics.dispose(),T()}),M(n,{id:"pi-agent-ide",handler:c(s=>n.getFlag("pi-agent-ide-no-post-processing")===!0?Promise.resolve({formatting:{status:"disabled"}}):z(s),"handler")}),n.events.emit(A,{protocol:C,apiVersion:4}),await _(n,{protocol:N,apiVersion:O,id:"ide-diagnostics",setup(s){s.onDidEdit(r=>{n.getFlag("pi-agent-ide-no-post-processing")===!0||r.postProcessing==="deferred"||it.isAbsolute(r.resourceSource)&&j(()=>t.diagnostics.schedule(r.resourceSource,r.after.content,{cwd:r.cwd}))})}});let i=!1,o=J(async s=>{let r=await t.diagnostics.takeNotifications(s);i||r.length===0||(n.sendMessage({customType:"ide-diagnostics",display:!1,content:`File diagnostics:
|
|
3
3
|
${r.map(d=>d.text).join(`
|
|
4
4
|
`)}`},{triggerTurn:!0,deliverAs:"steer"}),n.appendEntry(S,{files:r.map(W)}))},n.getFlag("pi-agent-ide-no-diagnostic-buffer")===!0?0:5e3),a=t.diagnostics.onDidChange((s,r)=>{r&&o.schedule(s)});n.on("session_shutdown",()=>{i=!0,o.dispose(),a()}),await t.waitForPendingPlugins()}c(nt,"registerPiAgentIde");export{nt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as d,d as u,e as a}from"./chunk-
|
|
1
|
+
import{c as d,d as u,e as a}from"./chunk-T6LX2RX5.js";import{a as t}from"./chunk-EI7MMDWY.js";function E(r,i){let s=t(()=>{let o,n={plugin:i,accept(f){if(o!==void 0)throw new Error(`Doctor plugin ${i.id} was accepted more than once`);o=f}};return r.events.emit(u,n),o},"announce"),e=t(()=>{},"unsubscribe");e=r.events.on(d,o=>{if(!a(o))throw new Error("Invalid doctor core readiness event");let n=s();if(n===void 0)throw new Error("Doctor core did not accept the plugin");e(),n.catch(()=>{})}),r.on("session_shutdown",e);let c=s();if(c!==void 0)return e(),c}t(E,"connectDoctorPlugin");export{E as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as c}from"./chunk-S3ZPXWX7.js";import{e as a}from"./chunk-5VSE5X5R.js";import{a as r}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";var n="pi-agent-text-editor",p=
|
|
1
|
+
import{d as c}from"./chunk-S3ZPXWX7.js";import{e as a}from"./chunk-5VSE5X5R.js";import{a as r}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";var n="pi-agent-text-editor",p=22,P="pi-agent-text-editor/position",S="pi-agent-text-editor/search",I=`${n}/core/ready`,b=`${n}/plugin/register`,s=e.Function([],e.Unknown()),u=e.Object({tryResolve:s},{additionalProperties:!0}),l=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),T=e.Object({start:l,end:l,linewise:e.Optional(e.Boolean())}),x=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(T))}),R=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(x,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),g=e.String({pattern:"\\S"}),m=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),y=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),v=e.Object({protocol:e.Literal(n),apiVersion:e.Literal(p)}),d=e.Object({protocol:e.Literal(n),apiVersion:e.Literal(p),id:e.String(),setup:s}),E=e.Object({plugin:d,accept:s});function k(t){return i.Check(g,t)}r(k,"isTextEditorToolId");function _(t){if(!i.Check(m,t))return!1;let o=t;return c(o.resolver)&&(!("priority"in o)||typeof o.priority=="number")}r(_,"isResourceResolverRegistration");function C(t){if(!i.Check(y,t))return!1;let o=t;return a(o.resolver)&&(!("resources"in o)||i.Check(u,o.resources))&&(!("priority"in o)||typeof o.priority=="number")}r(C,"isTextAnchorResolverRegistration");function j(t){return i.Check(R,t)}r(j,"isTextAnchorResourceResolutionAttempt");function w(t){return i.Check(v,t)}r(w,"isTextEditorCoreReady");function L(t){return i.Check(d,t)}r(L,"isTextEditorPlugin");function N(t){return i.Check(E,t)}r(N,"isTextEditorPluginRegistrationRequest");export{n as a,p as b,P as c,S as d,I as e,b as f,k as g,_ as h,C as i,j,w as k,L as l,N as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-read",r=
|
|
1
|
+
import{a as i}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var t="pi-agent-read",r=13,c=`${t}/core/ready`,s=`${t}/plugin/register`,a=e.Function([],e.Unknown()),p=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(r)}),R=e.Object({protocol:e.Literal(t),apiVersion:e.Literal(r),id:e.String(),setup:a}),l=e.Object({plugin:R,accept:a});function g(o){return n.Check(p,o)}i(g,"isReadCoreReady");function P(o){return n.Check(R,o)}i(P,"isReadPlugin");function y(o){return n.Check(l,o)}i(y,"isReadPluginRegistrationRequest");export{t as a,r as b,c,s as d,g as e,P as f,y as g};
|