pi-agent-ide 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +74 -22
- package/assets/gallery/apply-editing.png +0 -0
- package/assets/gallery/debugging.png +0 -0
- package/assets/gallery/read-web.png +0 -0
- package/assets/gallery/search-replace.png +0 -0
- package/assets/gallery/terminal.png +0 -0
- package/assets/gallery/tool-editing.png +0 -0
- package/dist/chunk-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-7ALCBKCW.js +26 -0
- package/dist/chunk-AWXVJ5AC.js +1 -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-IRECDTJG.js +27 -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-NZYDMBM6.js +1 -0
- package/dist/{chunk-Y7ZMR4LT.js → chunk-O6LE42GK.js} +1 -1
- package/dist/{chunk-KAB3AYA2.js → chunk-OBNING2A.js} +1 -1
- package/dist/chunk-P7XO5CIP.js +2 -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/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 +3 -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/development.md +0 -6
- 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 +72 -39
- 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 +33 -4
- 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/src/resolver.ts +128 -1
- 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 +59 -39
- 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/extensions/pi-agent-web/src/resolver.ts +128 -1
- 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 +72 -39
- 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 +33 -4
- 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 +83 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +260 -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 +31 -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/search.ts +32 -2
- 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 +14 -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/docs/evaluation.md +0 -14
- 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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { IPty } from "node-pty";
|
|
2
2
|
import type { Terminal } from "@xterm/headless";
|
|
3
3
|
|
|
4
|
+
export type TerminalWaitReason = "timeout" | "interactive";
|
|
5
|
+
export type TerminalWaitOutcomeReason = TerminalWaitReason | "aborted";
|
|
6
|
+
export type TerminalCompletionReason = "timeout";
|
|
7
|
+
|
|
4
8
|
export type TerminalSessionStatus =
|
|
5
9
|
| "running"
|
|
6
10
|
| "completed"
|
|
@@ -21,12 +25,13 @@ export interface TerminalSession {
|
|
|
21
25
|
readonly id: string;
|
|
22
26
|
readonly source: string;
|
|
23
27
|
readonly command: string;
|
|
24
|
-
|
|
28
|
+
background: boolean;
|
|
25
29
|
readonly cwd: string;
|
|
26
30
|
readonly shell: ShellProfile;
|
|
27
31
|
readonly startedAt: number;
|
|
28
32
|
readonly cols: number;
|
|
29
33
|
readonly rows: number;
|
|
34
|
+
readonly fullOutputPath: string;
|
|
30
35
|
readonly process?: IPty;
|
|
31
36
|
readonly screen: Terminal;
|
|
32
37
|
status: TerminalSessionStatus;
|
|
@@ -40,6 +45,9 @@ export interface TerminalSession {
|
|
|
40
45
|
completion: Promise<TerminalSession>;
|
|
41
46
|
resolveCompletion: (session: TerminalSession) => void;
|
|
42
47
|
completionDelivered: boolean;
|
|
48
|
+
waitReason?: TerminalWaitReason;
|
|
49
|
+
completionReason?: TerminalCompletionReason;
|
|
50
|
+
lastActivityAt: number;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
export interface TerminalSessionSnapshot {
|
|
@@ -51,6 +59,10 @@ export interface TerminalSessionSnapshot {
|
|
|
51
59
|
readonly shellFamily: ShellProfile["family"];
|
|
52
60
|
readonly background: boolean;
|
|
53
61
|
readonly status: TerminalSessionStatus;
|
|
62
|
+
readonly waitReason?: TerminalWaitReason;
|
|
63
|
+
readonly completionReason?: TerminalCompletionReason;
|
|
64
|
+
readonly lastActivityAt: number;
|
|
65
|
+
readonly idleMs: number;
|
|
54
66
|
readonly startedAt: number;
|
|
55
67
|
readonly endedAt?: number;
|
|
56
68
|
readonly elapsedMs: number;
|
|
@@ -61,6 +73,7 @@ export interface TerminalSessionSnapshot {
|
|
|
61
73
|
readonly outputStart: number;
|
|
62
74
|
readonly outputEnd: number;
|
|
63
75
|
readonly truncated: boolean;
|
|
76
|
+
readonly fullOutputPath: string;
|
|
64
77
|
readonly cols: number;
|
|
65
78
|
readonly rows: number;
|
|
66
79
|
}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ExtensionAPI,
|
|
4
|
-
type ExtensionContext,
|
|
5
|
-
} from "@earendil-works/pi-coding-agent";
|
|
6
|
-
import {
|
|
7
|
-
Box,
|
|
8
|
-
Container,
|
|
9
|
-
Key,
|
|
10
|
-
matchesKey,
|
|
11
|
-
SelectList,
|
|
12
|
-
Text,
|
|
13
|
-
truncateToWidth,
|
|
14
|
-
type SelectItem,
|
|
15
|
-
} from "@earendil-works/pi-tui";
|
|
1
|
+
import { Box, Container } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
16
3
|
|
|
17
|
-
import {
|
|
18
|
-
renderTerminalResult,
|
|
19
|
-
renderTerminalWidgetLines,
|
|
20
|
-
} from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
4
|
+
import { renderTerminalResult } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
21
5
|
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
22
6
|
import type {
|
|
23
7
|
TerminalSession,
|
|
@@ -25,65 +9,134 @@ import type {
|
|
|
25
9
|
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
26
10
|
|
|
27
11
|
const COMPLETION_DELAY_MS = 120;
|
|
12
|
+
const DEFAULT_STALE_INTERVAL_MS = 120_000;
|
|
28
13
|
|
|
29
|
-
/**
|
|
14
|
+
/** Delivers background terminal completion messages separately from the shared process UI. */
|
|
30
15
|
export class TerminalUi {
|
|
31
16
|
readonly #pending = new Map<string, TerminalSession>();
|
|
32
|
-
#context: ExtensionContext | undefined;
|
|
33
17
|
#deliveryTimer: ReturnType<typeof setTimeout> | undefined;
|
|
34
|
-
#
|
|
18
|
+
readonly #staleTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
19
|
+
readonly #overdue = new Set<string>();
|
|
20
|
+
#context: ExtensionContext | undefined;
|
|
35
21
|
#closed = false;
|
|
22
|
+
readonly #removeManagerListeners: readonly (() => void)[];
|
|
36
23
|
|
|
37
|
-
|
|
24
|
+
constructor(
|
|
38
25
|
private readonly pi: ExtensionAPI,
|
|
39
26
|
private readonly manager: TerminalSessionManager,
|
|
40
|
-
private readonly
|
|
27
|
+
private readonly staleIntervalMs = DEFAULT_STALE_INTERVAL_MS,
|
|
41
28
|
) {
|
|
29
|
+
pi.registerMessageRenderer("terminal-stale", (message, { expanded }, theme) => {
|
|
30
|
+
const snapshot = isTerminalSessionSnapshot(message.details) ? message.details : undefined;
|
|
31
|
+
const content = new Container();
|
|
32
|
+
if (snapshot !== undefined)
|
|
33
|
+
content.addChild(
|
|
34
|
+
renderTerminalResult(snapshot, expanded, theme, "stale · inspect session"),
|
|
35
|
+
);
|
|
36
|
+
const card = new Box(1, 1, (line) => theme.bg("toolPendingBg", line));
|
|
37
|
+
card.addChild(content);
|
|
38
|
+
return card;
|
|
39
|
+
});
|
|
42
40
|
pi.registerMessageRenderer("terminal-completion", (message, { expanded }, theme) => {
|
|
43
41
|
const content = new Container();
|
|
44
|
-
for (const session of completionSnapshots(message.details))
|
|
42
|
+
for (const session of completionSnapshots(message.details))
|
|
45
43
|
content.addChild(renderTerminalResult(session, expanded, theme));
|
|
46
|
-
}
|
|
47
44
|
const card = new Box(1, 1, (line) => theme.bg("toolSuccessBg", line));
|
|
48
45
|
card.addChild(content);
|
|
49
46
|
return card;
|
|
50
47
|
});
|
|
48
|
+
this.#removeManagerListeners = [
|
|
49
|
+
manager.onDidChange((session) => this.#refreshStaleTimer(session)),
|
|
50
|
+
manager.onDidComplete((session) => {
|
|
51
|
+
this.#clearStaleTimer(session.id);
|
|
52
|
+
if (session.background) this.#queueCompletion(session);
|
|
53
|
+
}),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (session.background) this.#queueCompletion(session);
|
|
55
|
-
this.#renderActive();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
pi.registerCommand("terminals", {
|
|
59
|
-
description: "Show active and recent terminal sessions",
|
|
60
|
-
handler: async (_args, context) => {
|
|
61
|
-
this.bind(context);
|
|
62
|
-
if (context.mode !== "tui") {
|
|
63
|
-
context.ui.notify("The terminal session overlay requires the TUI.", "info");
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
await this.#showOverlay(context);
|
|
67
|
-
},
|
|
68
|
-
});
|
|
57
|
+
bind(context: ExtensionContext): void {
|
|
58
|
+
this.#context = context;
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
/** Deliver deferred stale notices after Pi has fully settled. */
|
|
62
|
+
onAgentSettled(context: ExtensionContext): void {
|
|
73
63
|
this.#context = context;
|
|
74
|
-
this.#
|
|
64
|
+
for (const id of [...this.#overdue]) {
|
|
65
|
+
this.#overdue.delete(id);
|
|
66
|
+
const session = this.manager.get(id);
|
|
67
|
+
if (session !== undefined) this.#refreshStaleTimer(session, true);
|
|
68
|
+
}
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
|
|
71
|
+
/** Notify the agent when an aborted tool result may no longer be deliverable. */
|
|
72
|
+
notifyWaitTransition(session: TerminalSession): void {
|
|
73
|
+
const snapshot = this.manager.snapshot(session);
|
|
74
|
+
this.pi.sendMessage(
|
|
75
|
+
{
|
|
76
|
+
customType: "terminal-wait-transition",
|
|
77
|
+
display: false,
|
|
78
|
+
content: `Terminal wait ended; ${snapshot.source} is still running in background. Read it to inspect output, then use write or insert to send input.`,
|
|
79
|
+
details: snapshot,
|
|
80
|
+
},
|
|
81
|
+
{ triggerTurn: true, deliverAs: "steer" },
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
dispose(): void {
|
|
78
86
|
this.#closed = true;
|
|
79
87
|
if (this.#deliveryTimer !== undefined) clearTimeout(this.#deliveryTimer);
|
|
80
|
-
if (this.#elapsedTimer !== undefined) clearInterval(this.#elapsedTimer);
|
|
81
88
|
this.#deliveryTimer = undefined;
|
|
82
|
-
this.#elapsedTimer = undefined;
|
|
83
|
-
this.#context?.ui.setWidget("agent-terminal", undefined);
|
|
84
|
-
this.#context?.ui.setStatus("agent-terminal", undefined);
|
|
85
89
|
this.#pending.clear();
|
|
90
|
+
for (const timer of this.#staleTimers.values()) clearTimeout(timer);
|
|
91
|
+
this.#staleTimers.clear();
|
|
92
|
+
this.#overdue.clear();
|
|
86
93
|
this.#context = undefined;
|
|
94
|
+
for (const removeListener of this.#removeManagerListeners) removeListener();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#refreshStaleTimer(session: TerminalSession, checkNow = false): void {
|
|
98
|
+
this.#clearStaleTimer(session.id);
|
|
99
|
+
if (this.#closed || !session.background || session.status !== "running") return;
|
|
100
|
+
const snapshot = this.manager.snapshot(session);
|
|
101
|
+
const remaining = Math.max(0, this.staleIntervalMs - snapshot.idleMs);
|
|
102
|
+
if (checkNow && remaining === 0) {
|
|
103
|
+
this.#handleStale(session);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.#staleTimers.set(
|
|
107
|
+
session.id,
|
|
108
|
+
setTimeout(() => this.#handleStale(session), remaining),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#handleStale(session: TerminalSession): void {
|
|
113
|
+
this.#staleTimers.delete(session.id);
|
|
114
|
+
if (this.#closed || session.status !== "running" || !session.background) return;
|
|
115
|
+
if (this.#context?.isIdle() !== true) {
|
|
116
|
+
this.#overdue.add(session.id);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const snapshot = this.manager.snapshot(session);
|
|
120
|
+
this.pi.sendMessage(
|
|
121
|
+
{
|
|
122
|
+
customType: "terminal-stale",
|
|
123
|
+
display: true,
|
|
124
|
+
content: formatStaleMessage(snapshot),
|
|
125
|
+
details: snapshot,
|
|
126
|
+
},
|
|
127
|
+
{ triggerTurn: true, deliverAs: "followUp" },
|
|
128
|
+
);
|
|
129
|
+
this.#staleTimers.set(
|
|
130
|
+
session.id,
|
|
131
|
+
setTimeout(() => this.#handleStale(session), this.staleIntervalMs),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#clearStaleTimer(id: string): void {
|
|
136
|
+
const timer = this.#staleTimers.get(id);
|
|
137
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
138
|
+
this.#staleTimers.delete(id);
|
|
139
|
+
this.#overdue.delete(id);
|
|
87
140
|
}
|
|
88
141
|
|
|
89
142
|
#queueCompletion(session: TerminalSession): void {
|
|
@@ -93,198 +146,29 @@ export class TerminalUi {
|
|
|
93
146
|
this.#deliveryTimer = setTimeout(() => {
|
|
94
147
|
this.#deliveryTimer = undefined;
|
|
95
148
|
const sessions = [...this.#pending.values()].filter(
|
|
96
|
-
(
|
|
149
|
+
(candidate) => !candidate.completionDelivered,
|
|
97
150
|
);
|
|
98
151
|
this.#pending.clear();
|
|
99
152
|
if (this.#closed || sessions.length === 0) return;
|
|
100
153
|
for (const completed of sessions) completed.completionDelivered = true;
|
|
101
154
|
const snapshots = sessions.map((completed) => this.manager.snapshot(completed));
|
|
102
|
-
const content = formatCompletionMessage(snapshots);
|
|
103
155
|
this.pi.sendMessage(
|
|
104
156
|
{
|
|
105
157
|
customType: "terminal-completion",
|
|
106
158
|
display: true,
|
|
107
|
-
content,
|
|
159
|
+
content: formatCompletionMessage(snapshots),
|
|
108
160
|
details: { sessions: snapshots },
|
|
109
161
|
},
|
|
110
162
|
{ triggerTurn: true, deliverAs: "steer" },
|
|
111
163
|
);
|
|
112
164
|
}, COMPLETION_DELAY_MS);
|
|
113
165
|
}
|
|
114
|
-
|
|
115
|
-
#renderActive(): void {
|
|
116
|
-
const context = this.#context;
|
|
117
|
-
if (this.#closed || context === undefined || !context.hasUI) return;
|
|
118
|
-
const active = this.manager
|
|
119
|
-
.list()
|
|
120
|
-
.filter((session) => session.status === "running" || session.status === "stopping");
|
|
121
|
-
if (this.activityMode === "off") {
|
|
122
|
-
context.ui.setWidget("agent-terminal", undefined);
|
|
123
|
-
context.ui.setStatus("agent-terminal", undefined);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (active.length === 0) {
|
|
127
|
-
context.ui.setWidget("agent-terminal", undefined);
|
|
128
|
-
context.ui.setStatus("agent-terminal", undefined);
|
|
129
|
-
if (this.#elapsedTimer !== undefined) clearInterval(this.#elapsedTimer);
|
|
130
|
-
this.#elapsedTimer = undefined;
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (this.activityMode === "compact") {
|
|
134
|
-
context.ui.setWidget("agent-terminal", undefined);
|
|
135
|
-
context.ui.setStatus("agent-terminal", `terminals: ${active.length}`);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
context.ui.setStatus("agent-terminal", undefined);
|
|
139
|
-
context.ui.setWidget(
|
|
140
|
-
"agent-terminal",
|
|
141
|
-
(_tui, theme) => ({
|
|
142
|
-
invalidate() {},
|
|
143
|
-
render: (width: number) => renderTerminalWidgetLines(active, width, theme),
|
|
144
|
-
}),
|
|
145
|
-
{ placement: "belowEditor" },
|
|
146
|
-
);
|
|
147
|
-
if (this.#elapsedTimer === undefined) {
|
|
148
|
-
this.#elapsedTimer = setInterval(() => this.#renderActive(), 1_000);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async #showOverlay(context: ExtensionContext): Promise<void> {
|
|
153
|
-
for (;;) {
|
|
154
|
-
const sessions = this.manager
|
|
155
|
-
.list()
|
|
156
|
-
.filter((session) => session.status === "running" || session.status === "stopping");
|
|
157
|
-
if (sessions.length === 0) {
|
|
158
|
-
context.ui.notify("No active terminal sessions.", "info");
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const action = await context.ui.custom<TerminalOverlayAction | null>(
|
|
162
|
-
(tui, theme, _keybindings, done) => {
|
|
163
|
-
const items: SelectItem[] = sessions.map((session) => ({
|
|
164
|
-
value: session.source,
|
|
165
|
-
label: `${session.status} ${formatElapsed(session.elapsedMs)} ${session.shell}`,
|
|
166
|
-
description: shortCommand(session.command, 90),
|
|
167
|
-
}));
|
|
168
|
-
const list = new SelectList(items, Math.min(items.length, 12), {
|
|
169
|
-
selectedPrefix: (text) => theme.fg("accent", text),
|
|
170
|
-
selectedText: (text) => theme.fg("accent", text),
|
|
171
|
-
description: (text) => theme.fg("muted", text),
|
|
172
|
-
scrollInfo: (text) => theme.fg("dim", text),
|
|
173
|
-
noMatch: (text) => theme.fg("warning", text),
|
|
174
|
-
});
|
|
175
|
-
let page: "list" | "detail" | "confirm" = "list";
|
|
176
|
-
let selectedSource: string | undefined;
|
|
177
|
-
list.onSelect = (item) => {
|
|
178
|
-
selectedSource = item.value;
|
|
179
|
-
page = "detail";
|
|
180
|
-
};
|
|
181
|
-
list.onCancel = () => done(null);
|
|
182
|
-
return {
|
|
183
|
-
render: (width: number) => {
|
|
184
|
-
const container = new Container();
|
|
185
|
-
container.addChild(new DynamicBorder((text: string) => theme.fg("accent", text)));
|
|
186
|
-
if (page === "list") {
|
|
187
|
-
container.addChild(
|
|
188
|
-
new Text(theme.fg("accent", theme.bold("Terminal sessions")), 1, 0),
|
|
189
|
-
);
|
|
190
|
-
container.addChild(list);
|
|
191
|
-
container.addChild(
|
|
192
|
-
new Text(theme.fg("dim", "enter view · d delete · esc close"), 1, 0),
|
|
193
|
-
);
|
|
194
|
-
} else {
|
|
195
|
-
const session =
|
|
196
|
-
selectedSource === undefined ? undefined : this.manager.get(selectedSource);
|
|
197
|
-
if (session === undefined) {
|
|
198
|
-
container.addChild(
|
|
199
|
-
new Text(theme.fg("warning", "Terminal is no longer available."), 1, 0),
|
|
200
|
-
);
|
|
201
|
-
} else {
|
|
202
|
-
const snapshot = this.manager.snapshot(session);
|
|
203
|
-
container.addChild(
|
|
204
|
-
new Text(theme.fg("accent", theme.bold(`${snapshot.shell} terminal`)), 1, 0),
|
|
205
|
-
);
|
|
206
|
-
container.addChild(
|
|
207
|
-
new Text(
|
|
208
|
-
theme.fg(
|
|
209
|
-
"muted",
|
|
210
|
-
truncateToWidth(
|
|
211
|
-
`${snapshot.status} · ${formatElapsed(snapshot.elapsedMs)} · ${snapshot.cwd}`,
|
|
212
|
-
Math.max(1, width - 2),
|
|
213
|
-
),
|
|
214
|
-
),
|
|
215
|
-
1,
|
|
216
|
-
0,
|
|
217
|
-
),
|
|
218
|
-
);
|
|
219
|
-
container.addChild(new Text(theme.fg("text", `$ ${snapshot.command}`), 1, 0));
|
|
220
|
-
const rows = visibleScreenTail(this.manager.screenRows(session), 24);
|
|
221
|
-
container.addChild(
|
|
222
|
-
new Text(
|
|
223
|
-
rows.map((row) => theme.fg("toolOutput", row || " ")).join("\n"),
|
|
224
|
-
1,
|
|
225
|
-
0,
|
|
226
|
-
),
|
|
227
|
-
);
|
|
228
|
-
container.addChild(
|
|
229
|
-
new Text(
|
|
230
|
-
theme.fg(
|
|
231
|
-
page === "confirm" ? "warning" : "dim",
|
|
232
|
-
page === "confirm"
|
|
233
|
-
? "Delete this terminal session? y confirm · n/esc cancel"
|
|
234
|
-
: "esc back · d delete",
|
|
235
|
-
),
|
|
236
|
-
1,
|
|
237
|
-
0,
|
|
238
|
-
),
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
container.addChild(new DynamicBorder((text: string) => theme.fg("accent", text)));
|
|
243
|
-
return container.render(width);
|
|
244
|
-
},
|
|
245
|
-
handleInput: (data: string) => {
|
|
246
|
-
if (page === "list") {
|
|
247
|
-
if (data === "d") {
|
|
248
|
-
selectedSource = list.getSelectedItem()?.value;
|
|
249
|
-
if (selectedSource !== undefined) page = "confirm";
|
|
250
|
-
} else {
|
|
251
|
-
list.handleInput(data);
|
|
252
|
-
}
|
|
253
|
-
} else if (page === "detail") {
|
|
254
|
-
if (matchesKey(data, Key.escape)) page = "list";
|
|
255
|
-
else if (data === "d") page = "confirm";
|
|
256
|
-
} else if (data === "y" && selectedSource !== undefined) {
|
|
257
|
-
done({ kind: "delete", source: selectedSource });
|
|
258
|
-
} else if (data === "n" || matchesKey(data, Key.escape)) {
|
|
259
|
-
page = "detail";
|
|
260
|
-
}
|
|
261
|
-
tui.requestRender();
|
|
262
|
-
},
|
|
263
|
-
invalidate: () => list.invalidate(),
|
|
264
|
-
};
|
|
265
|
-
},
|
|
266
|
-
{ overlay: true, overlayOptions: { width: "75%", maxHeight: "80%", minWidth: 52 } },
|
|
267
|
-
);
|
|
268
|
-
if (action === null) return;
|
|
269
|
-
await this.manager.delete(action.source);
|
|
270
|
-
context.ui.notify("Terminal session deleted.", "info");
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
166
|
}
|
|
274
167
|
|
|
275
|
-
function visibleScreenTail(rows: readonly string[], limit: number): readonly string[] {
|
|
276
|
-
const first = rows.findIndex((row) => row.length > 0);
|
|
277
|
-
if (first === -1) return ["(no visible output)"];
|
|
278
|
-
let last = rows.length - 1;
|
|
279
|
-
while (last > first && rows[last]?.length === 0) last -= 1;
|
|
280
|
-
return rows.slice(Math.max(first, last - limit + 1), last + 1);
|
|
281
|
-
}
|
|
282
|
-
type TerminalOverlayAction = { readonly kind: "delete"; readonly source: string };
|
|
283
168
|
function completionSnapshots(details: unknown): readonly TerminalSessionSnapshot[] {
|
|
284
169
|
if (!isRecord(details) || !Array.isArray(details.sessions)) return [];
|
|
285
170
|
return details.sessions.filter(isTerminalSessionSnapshot);
|
|
286
171
|
}
|
|
287
|
-
|
|
288
172
|
function isTerminalSessionSnapshot(value: unknown): value is TerminalSessionSnapshot {
|
|
289
173
|
return (
|
|
290
174
|
isRecord(value) &&
|
|
@@ -293,44 +177,36 @@ function isTerminalSessionSnapshot(value: unknown): value is TerminalSessionSnap
|
|
|
293
177
|
typeof value.command === "string" &&
|
|
294
178
|
typeof value.cwd === "string" &&
|
|
295
179
|
typeof value.shell === "string" &&
|
|
296
|
-
(value.shellFamily === "posix" ||
|
|
297
|
-
value.shellFamily === "powershell" ||
|
|
298
|
-
value.shellFamily === "cmd") &&
|
|
299
180
|
typeof value.background === "boolean" &&
|
|
300
181
|
typeof value.status === "string" &&
|
|
301
182
|
typeof value.startedAt === "number" &&
|
|
302
183
|
typeof value.elapsedMs === "number" &&
|
|
303
|
-
typeof value.output === "string"
|
|
304
|
-
typeof value.outputStart === "number" &&
|
|
305
|
-
typeof value.outputEnd === "number" &&
|
|
306
|
-
typeof value.truncated === "boolean" &&
|
|
307
|
-
typeof value.cols === "number" &&
|
|
308
|
-
typeof value.rows === "number"
|
|
184
|
+
typeof value.output === "string"
|
|
309
185
|
);
|
|
310
186
|
}
|
|
311
|
-
|
|
312
187
|
function formatCompletionMessage(sessions: readonly TerminalSessionSnapshot[]): string {
|
|
313
188
|
const heading =
|
|
314
189
|
sessions.length === 1 ? "Background terminal completed:" : "Background terminals completed:";
|
|
315
190
|
return `${heading}\n${sessions
|
|
316
191
|
.map((session) => {
|
|
317
192
|
const exit = session.exitCode === undefined ? "" : `, exit ${session.exitCode}`;
|
|
193
|
+
const reason =
|
|
194
|
+
session.completionReason === undefined ? "" : `, reason ${session.completionReason}`;
|
|
318
195
|
const excerpt = session.output.trimEnd().slice(-2_000);
|
|
319
|
-
return `- ${session.source}: ${session.status}${exit}, ${formatElapsed(session.elapsedMs)}\n${excerpt || "(no output)"}`;
|
|
196
|
+
return `- ${session.source}: ${session.status}${exit}${reason}, ${formatElapsed(session.elapsedMs)}\n${excerpt || "(no output)"}`;
|
|
320
197
|
})
|
|
321
198
|
.join("\n")}`;
|
|
322
199
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return singleLine.length <= max ? singleLine : `${singleLine.slice(0, max - 1)}…`;
|
|
200
|
+
function formatStaleMessage(session: TerminalSessionSnapshot): string {
|
|
201
|
+
const excerpt = session.output.trimEnd().slice(-2_000);
|
|
202
|
+
return `Background terminal ${session.source} has produced no output for ${formatElapsed(session.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.\n${excerpt || "(no output)"}`;
|
|
327
203
|
}
|
|
328
204
|
|
|
329
205
|
function formatElapsed(milliseconds: number): string {
|
|
330
|
-
|
|
331
|
-
|
|
206
|
+
return milliseconds < 1_000
|
|
207
|
+
? `${milliseconds}ms`
|
|
208
|
+
: `${(milliseconds / 1_000).toFixed(milliseconds < 10_000 ? 1 : 0)}s`;
|
|
332
209
|
}
|
|
333
|
-
|
|
334
210
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
335
211
|
return typeof value === "object" && value !== null;
|
|
336
212
|
}
|
package/dist/chunk-3SE372WC.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{c as M}from"./chunk-YHUTTZC6.js";import{i as b,o as k,t as w,u as T}from"./chunk-5VSE5X5R.js";import{a as R}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";function me(e,n){let{lines:t,truncation:r,...i}=e,o=t?.map(d=>{let l=[d.lineNumber,w(d.content,n),d.lineEnding];return(d.presentation!==void 0||d.metadata!==void 0)&&l.push(d.presentation),d.metadata!==void 0&&l.push(d.metadata),l}),{content:s,...u}=r??{};return{...i,...o===void 0?{}:{storedLines:o},...r===void 0?{}:{truncation:u,truncatedText:w(s??"",n)}}}a(me,"compactReadDetails");function P(e,n){let t=e;if(t.storedLines===void 0&&t.truncatedText===void 0)return e;let{storedLines:r,truncatedText:i,truncation:o,...s}=t;return{...s,...r===void 0?{}:{lines:r.map(([u,d,l,c,m])=>({lineNumber:u,content:T(d,n),lineEnding:l,...c==null?{}:{presentation:c},...m==null?{}:{metadata:m}}))},...o===void 0?{}:{truncation:{...o,content:T(i??"",n)}}}}a(P,"restoreReadDetails");import f from"node:path";import{homedir as I}from"node:os";import{createReadToolDefinition as V,getReadmePath as J}from"@earendil-works/pi-coding-agent";import{Text as Z}from"@earendil-works/pi-tui";var S=V(process.cwd()),K=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]);function v(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),s=f.basename(o),u=f.relative(f.dirname(J()),o),d=!f.isAbsolute(u)&&(u==="README.md"||u.startsWith(`docs${f.sep}`)||u.startsWith(`examples${f.sep}`));if(!(s!=="SKILL.md"&&!K.has(s)&&!d))return{path:r,...t.offset===void 0?{}:{offset:t.offset},...t.limit===void 0?{}:{limit:t.limit}}}a(v,"nativeReadArguments");function L(e,n){return{...e,args:n,lastComponent:e.lastComponent instanceof Z?e.lastComponent:void 0}}a(L,"nativeReadContext");import{getLanguageFromPath as q,getMarkdownTheme as X,highlightCode as z,keyHint as Y}from"@earendil-works/pi-coding-agent";import{Container as g,Markdown as Q,Text as _,truncateToWidth as h,visibleWidth as p,wrapTextWithAnsi as N}from"@earendil-works/pi-tui";var E=12;function ee(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 d=r??1,l=i===void 0?String(d):`${d}-${d+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 s=Math.max(1,r??1),u=i===void 0?String(s):`${s}-${s+i-1}`;return{pathSuffix:`:${u}`,qualifiers:[],details:[{label:"lines",value:u}]}}a(ee,"readWindowPresentation");function ke(e,n,t){let r=v(e,t.cwd);if(r!==void 0)return R(S.renderCall)(r,n,L(t,r));if(typeof e.path=="string"&&e.path.startsWith("shell:"))return new g;let i=typeof e.path=="string"?e.path:"inherited source",o=ee(i,e.offset,e.limit),s=Array.isArray(e.views)?e.views.filter(l=>typeof l=="string"):[],u=[...o.qualifiers,...s.length===0?[]:[{text:`views ${s.join(",")}`}]],d=[...typeof e.path=="string"?[{label:"path",value:e.path}]:[],...o.details,...s.length===0?[]:[{label:"views",value:s.join(",")}]];return M(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:d,expanded:t.expanded},n)}a(ke,"renderReadCall");function Me(e){let n=new WeakMap;return(t,r,i,o)=>{let s=e.nativeResources?v(o.args,o.cwd):void 0;if(s!==void 0&&!r.isPartial)return R(S.renderResult)({...t,details:{truncation:$(t.details).truncation}},r,i,L(o,s));if(r.isPartial||o.isError){let m=D(t),H=o.isError?"error":"dim";return new _(i.fg(H,m),0,0)}let u=$(t.details).diagnosticCheck;if(u?.complete&&u.count===0)return new g;if(!de(t))return o.lastComponent instanceof g?o.lastComponent:new g;let d=n.get(t);d===void 0&&(d=P($(t.details),D(t)),n.set(t,d));let c=(o.lastComponent instanceof x?o.lastComponent:void 0)??new x({result:t,details:d,options:e,expanded:r.expanded,theme:i});return c.update({result:t,details:d,options:e,expanded:r.expanded,theme:i}),c}}a(Me,"createReadResultRenderer");var x=class{constructor(n){this.state=n}static{a(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=[h(B(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=ne(this.state,r).flatMap(l=>N(l,r)),o=re(i,this.state.expanded,this.state.theme),s=[ie(this.state,t,this.state.theme)];for(let l of o)for(let c of N(l,r))s.push(W(c,t,this.state.theme));let u=ae(this.state.details,this.state.theme);u!==void 0&&s.push(W(u,t,this.state.theme)),s.push(this.state.theme.fg("borderMuted",`\u2570${"\u2500".repeat(t)}\u256F`));let d=s.map(l=>h(l,n));return this.cached={width:n,lines:d},d}invalidate(){this.cached=void 0}};function ne(e,n){let t=G(e.details),r=se(e.result,t,e.details,!e.expanded);if(e.options.kind==="markdown"||ue(e.details,t,e.options.kind)){let u=new Q(r,0,0,X());return C(u.render(n),e.theme)}if(e.options.kind==="code-view"){let u=t===void 0||j(t)?O(r).map(d=>U(d,e.theme,!1)):te(t,e.theme);return C(u,e.theme)}let i=t===void 0||j(t)?O(r).map(y):t.map(({content:u})=>y(u)),o=A(e.details,t),s=o===void 0?i.map(u=>e.theme.fg("toolOutput",u)):z(i.join(`
|
|
2
|
-
`),o);return C(s,e.theme)}a(ne,"renderContentRows");function te(e,n){return e.map(t=>{let r=b(t);if(r===void 0)return U(t.content,n);let i=q(r.source),o=y(F(t.content));return i===void 0?n.fg("toolOutput",o):z(o,i)[0]??n.fg("toolOutput",o)})}a(te,"renderCodeViewLines");function F(e){return e.replace(/(?:[ \t]{2,}<!--[ \t]+scope-(?:begin|end)-[^\s>]+[ \t]+-->)+[ \t]*$/u,"")}a(F,"stripScopeMarkers");function U(e,n,t=!0){let r=y(t?F(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)}a(U,"renderCodeViewLabel");function re(e,n,t){if(n||e.length<=E)return e;let r=e.slice(0,E-1),i=e.length-r.length;return[...r,`${t.fg("dim",`\u2026 ${String(i)} more ${i===1?"row":"rows"} \xB7 `)}${Y("app.tools.expand","to expand")}`]}a(re,"compactRows");function ie(e,n,t){let r=a(s=>t.fg("borderMuted",s),"frame"),i=h(` ${B(e,Math.max(1,n-1))} `,Math.max(0,n-1),""),o="\u2500".repeat(Math.max(0,n-p(i)-1));return`${r("\u256D\u2500")}${i}${r(`${o}\u256E`)}`}a(ie,"renderTopBorder");function B(e,n){let t=e.options.label??fe(A(e.details,G(e.details))),r=e.details.source??"read result",i=oe(e.details),o=e.theme.fg("accent",e.theme.bold(t)),s=i===void 0?"":e.theme.fg("dim",` \xB7 ${i}`),u=Math.max(1,n-p(o)-p(s)-2),d=ce(r,u);return`${o} ${e.theme.fg("muted",d)}${s}`}a(B,"readTitle");function oe(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)}`}a(oe,"sourceRange");function ae(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`)}a(ae,"readStatus");function W(e,n,t){let r=Math.max(0,n-2),i=h(e,r),o=` ${i}${" ".repeat(Math.max(0,r-p(i)))} `,s=t.fg("borderMuted","\u2502");return`${s}${o}${s}`}a(W,"framed");function se(e,n,t,r){if(n!==void 0)return k({source:t.source??"",content:"",lines:n},{compact:r});let i=D(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,"")}a(se,"cleanText");function j(e){return e.some(n=>n.presentation!==void 0)}a(j,"hasPresentation");function O(e){let n=e.split(/\r\n|\r|\n/u);return n.at(-1)===""&&/(?:\r\n|\r|\n)$/u.test(e)&&n.pop(),n}a(O,"splitTextRows");function D(e){return e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
3
|
-
`)}a(D,"textBlocks");function G(e){return e.lines}a(G,"readLines");function $(e){return typeof e=="object"&&e!==null?e:{}}a($,"readDetails");function de(e){return e.content.some(n=>n.type==="text")}a(de,"hasTextContent");function A(e,n){let r=n?.map(b).find(i=>i!==void 0)?.source??e.source;return r===void 0?void 0:q(le(r))}a(A,"languageFor");function ue(e,n,t){return t==="source"&&A(e,n)==="markdown"}a(ue,"isMarkdownSource");function le(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,"")}}a(le,"normalizeSourcePath");function y(e){let n="";for(let t of e.replaceAll(" "," ".repeat(4))){let r=R(t.codePointAt(0));n+=r<32||r===127?"\uFFFD":t}return n}a(y,"normalizeText");function fe(e){return e===void 0?"TEXT":{javascript:"JS",json:"JSON",markdown:"MD",python:"PY",rust:"RS",typescript:"TS"}[e]??e.slice(0,4).toUpperCase()}a(fe,"languageLabel");function C(e,n){return e.length===0?[n.fg("dim","Empty content")]:[...e]}a(C,"nonEmptyRows");function ce(e,n){return p(e)<=n?e:n<=1?"\u2026":`\u2026${e.slice(-(n-1))}`}a(ce,"truncateFromStart");export{me as a,E as b,ke as c,Me as d};
|
package/dist/chunk-5MSNYFDE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as s}from"./chunk-S3ZPXWX7.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";import{Type as n}from"typebox";var l=n.Object({path:n.Optional(n.String({description:"What to read: a file or directory path, URL, returned temp: or SEARCH# reference, or one of the source forms listed in the description. Supply a path; an empty call cannot select a source."})),offset:n.Optional(n.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or a SEARCH selection, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier."})),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(),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())}),p=e.Object({id:e.String({pattern:"\\S"}),priority:e.Optional(e.Number()),resolve:a}),y=e.Object({view:e.String({pattern:"\\S"}),includes:e.Optional(e.Array(e.String({pattern:"\\S"}))),presenter:e.Object({id:e.String(),present:a}),priority:e.Optional(e.Number())}),c=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:c,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 S(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")&&(!("renderResult"in r)||typeof r.renderResult=="function"):!1}o(S,"isResourceResolverRegistration");function O(t){return i.Check(g,t)}o(O,"isReadHandlerRegistration");function k(t){return i.Check(y,t)}o(k,"isReadViewRegistration");function L(t){return i.Check(p,t)}o(L,"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,S as c,O as d,k as e,L as f,P as g};
|
package/dist/chunk-7JYQMAEL.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{a as b,d as A}from"./chunk-ITSNK5YG.js";import{a as v}from"./chunk-5MSNYFDE.js";import{d as M}from"./chunk-3SE372WC.js";import{f as C}from"./chunk-YHUTTZC6.js";import{a as p}from"./chunk-EI7MMDWY.js";import F from"node:path";import{truncateHead as $,DEFAULT_MAX_BYTES as W,DEFAULT_MAX_LINES as Z}from"@earendil-works/pi-coding-agent";import{Text as S}from"@earendil-works/pi-tui";import{Type as T}from"typebox";import{Value as Q}from"typebox/value";var N=T.Union([T.String({minLength:1}),v]),_=T.Object({before:N,after:N},{additionalProperties:!1});async function ee(e,l,f){if(!Q.Check(_,l))throw Object.assign(new Error("Use before and after source strings or read request objects"),{code:"INVALID_ARGUMENTS"});let n=l,r=p(async s=>{let t=typeof s=="string"?{path:s}:s,c=await e.read(t,f,"script");if(c.isError||c.details.failure)throw Object.assign(new Error(c.details.failure?.message??"Comparison read failed"),{code:c.details.failure?.code??"READ_FAILED",details:c.details.failure});if(c.script===void 0)throw Object.assign(new Error("Source has no comparable text data"),{code:"UNSUPPORTED_CONTENT"});return L(c.script,t.path??"source")},"resolve"),i=await r(n.before),a=await r(n.after),o=b(i.source,i.content,a.content,a.source);return{kind:"diff",ok:!0,equal:i.content===a.content,before:i,after:a,...o}}p(ee,"executeDiff");function L(e,l){if(e.kind==="text")return{source:e.source,sources:[e.source],content:e.content};if(e.kind==="resources"){let f=e.resources.map(n=>L(n,l));return{source:e.source??l,sources:f.flatMap(n=>n.sources),content:f.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(f=>f.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(f=>f.type==="text"?[f.text]:[]).join(`
|
|
3
|
-
`)}}p(L,"comparisonText");function R(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="diff"&&"ok"in e&&e.ok===!0}p(R,"isDiffOutcome");function D(e,l=process.cwd()){let f=p(r=>F.isAbsolute(r)?F.relative(l,r)||".":r,"displaySource"),n=`Diff: ${f(e.before.source)} \u2192 ${f(e.after.source)}`;return{results:[new A({ok:!0,path:n,beforeContentMap:{[n]:e.before.content},afterContent:e.after.content,diffs:[e.diff]})]}}p(D,"diffPresentation");function O(e){return e.equal?`No differences: ${e.before.source} \u2192 ${e.after.source}`:e.diff}p(O,"diffText");function Se(e){return{content:[{type:"text",text:O(e)}],details:{}}}p(Se,"diffReadResult");function Te(e,l,f){e.registerTool({name:"diff",label:"Diff",parameters:_,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,i,a){let o=n.details;if(o?.comparison?.equal)return new S(O(o.comparison),0,0);let s=l.getToolRenderer("diff")?.renderResult;return s?s(n,r,i,a):new S(n.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
4
|
-
`),0,0)},async execute(n,r,i,a,o){let s=f();if(s===void 0)throw new Error("Diff requires the read extension");let t=await ee(s,r,{cwd:o.cwd,signal:i}),c=O(t),y=$(c).truncated?await s.saveTemporary(c):void 0,d=y===void 0?"":`
|
|
5
|
-
Full diff: ${y}`;return{content:[{type:"text",text:y===void 0?c:$(c,{maxLines:Z-2,maxBytes:W-Buffer.byteLength(d)}).content+d}],details:{...D(t,o.cwd),comparison:t,temporarySource:y}}}})}p(Te,"registerDiff");import{parser as B}from"@lezer/javascript";import{TreeFragment as I}from"@lezer/common";var te=new Set(["read","search","diff","write","replace","insert","remove","copy","move","undo","stage","unstage","delete_file","copy_file","move_file"]);function q(e,l=B.parse(e)){let f=[];l.iterate({enter(r){if(r.name==="AssignmentExpression"){let t=r.node.firstChild;t?.name==="VariableName"&&f.push({name:e.slice(t.from,t.to),from:0,to:e.length})}if(r.name!=="VariableDefinition")return;let i=r.node.parent;for(;i?.parent&&!["VariableDeclaration","ParamList","Block","Script"].includes(i.name);)i=i.parent;let a=i?.name==="VariableDeclaration"&&i.firstChild?.name==="var",o=new Set(["Script","FunctionDeclaration","FunctionExpression","ArrowFunction",...a?[]:["Block"]]),s=r.node.parent;for(s?.name==="FunctionDeclaration"&&(s=s.parent);s?.parent&&!o.has(s.name);)s=s.parent;f.push({name:e.slice(r.from,r.to),from:s?.from??0,to:s?.to??e.length})}});let n=[];return l.iterate({enter(r){if(r.name!=="CallExpression")return;let i=r.node.firstChild;if(i?.name!=="VariableName")return;let a=e.slice(i.from,i.to);if(!te.has(a)||f.some(t=>t.name===a&&t.from<=r.from&&t.to>=r.to))return;let o=r.node.getChild("ArgList")?.getChild("ObjectExpression"),s=Object.create(null);if(!o){let t=r.node.getChild("ArgList"),c=t?e.slice(t.from+1,t.to).replace(/\)$/,""):"";c&&(s.arguments={text:c.length>160?c.slice(0,120)+"\u2026":c,literal:!1})}for(let t of o?.getChildren("Property")??[]){let c=t.firstChild,y=(c?e.slice(c.from,c.to):"").replace(/^["']|["']$/g,"");if(!/^[a-zA-Z_$][\w$]*$/.test(y)){for(let K of["path","query","target","before","after"])delete s[K];let w=e.slice(t.from,t.to);s[`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);s[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:a,from:r.from,to:r.to,path:s.path,query:s.query,target:s.target,before:s.before,after:s.after,arguments:s}),!1}}),n}p(q,"parseApplyCalls");function re(e,l=q(e),f,n=r=>r){let r=0,i=[],a=p(o=>n(o.split(`
|
|
6
|
-
`).map(s=>s.length>200?s.slice(0,200)+"\u2026":s).join(`
|
|
7
|
-
`)),"codePreview");for(let o of l)i.push(a(e.slice(r,o.from))),i.push(f?.(o)??`${o.name}(${o.path?o.path.literal?o.path.text:`\u2039${o.path.text}\u203A`:"\u2026"})`),r=o.to;return i.push(a(e.slice(r))),i.join("")}p(re,"compactApplySource");function U(e,l){let f="",n="",r=[];return i=>{if(i===f)return n;let a=0;for(;a<f.length&&a<i.length&&f[a]===i[a];)a++;r=I.applyChanges(r,[{fromA:a,toA:f.length,fromB:a,toB:i.length}]);let o=B.parse(i,r);return r=I.addTree(o),n=re(i,q(i,o),e,l),f=i,n}}p(U,"createApplySourceProjection");import{lstat as z,unlink as ne}from"node:fs/promises";import V from"node:path";import J from"fs-extra";import{Type as x}from"typebox";import{Value as oe}from"typebox/value";var Ne=["delete_file","move_file","copy_file"],E=x.String({minLength:1,description:"Local regular file path, relative to cwd or absolute."}),ie=x.Object({path:E},{additionalProperties:!1}),ae=x.Object({path:E,target:E,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"}p(k,"isFileOperationResult");function P(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(l=>l!==void 0).join(`
|
|
8
|
-
`)}p(P,"formatFileOperation");async function _e(e,l,f,n){let r=!1,i,a;try{let o=e==="delete_file"?ie:ae;if(!oe.Check(o,l))throw Object.assign(new Error("Invalid file operation arguments"),{code:"INVALID_ARGUMENTS"});let s=l;i=V.resolve(f,s.path),a=s.target===void 0?void 0:V.resolve(f,s.target),n?.throwIfAborted();let t=await se(i);if(a!==void 0){let c=await le(a);if(c!==void 0){if(!c.isFile()||c.isSymbolicLink())throw Object.assign(new Error("Target must be a regular file"),{code:"INVALID_FILE_TYPE"});if(i===a||t.ino===c.ino&&t.dev===c.dev)throw Object.assign(new Error("Source and target are the same file"),{code:"SAME_FILE"});if(s.overwrite!==!0)throw Object.assign(new Error("Target exists; use overwrite: true to replace it"),{code:"EEXIST"})}}return n?.throwIfAborted(),r=!0,e==="delete_file"?await ne(i):a!==void 0&&(e==="copy_file"?await J.copy(i,a,{overwrite:s.overwrite===!0,errorOnExist:!0}):await J.move(i,a,{overwrite:s.overwrite===!0})),{kind:"file-operation",operation:e,ok:!0,effect:"applied",path:i,...a===void 0?{}:{target:a}}}catch(o){return{kind:"file-operation",operation:e,ok:!1,effect:r?"unknown":"not-applied",...i===void 0?{}:{path:i},...a===void 0?{}:{target:a},error:{code:o!==null&&typeof o=="object"&&"code"in o?String(o.code):"FILE_OPERATION_FAILED",message:o instanceof Error?o.message:String(o)}}}}p(_e,"executeFileOperation");async function se(e){let l=await z(e);if(!l.isFile()||l.isSymbolicLink())throw Object.assign(new Error("Source must be a regular file"),{code:"INVALID_FILE_TYPE"});return l}p(se,"regularFile");async function le(e){try{return await z(e)}catch(l){if(l!==null&&typeof l=="object"&&"code"in l&&l.code==="ENOENT")return;throw l}}p(le,"optionalStat");import{Text as fe}from"@earendil-works/pi-tui";function G(e){let l=e.select(),f=e.mutationValues().filter(ce);return l.files.map(n=>{let r=f.flatMap(o=>o.files.filter(s=>s.source===n.source).map(s=>({outcome:o,changed:s}))),i=e.mutationPresentation(n.source)?.data,a=i?.afterContent===n.after?i:void 0;return new A({ok:!0,path:n.source,files:[{path:n.source,action:n.before===null?"created":"edited"}],snapshot:{content:n.before??""},beforeContentMap:{[n.source]:n.before},afterContent:n.after??"",afterDocument:a?.afterDocument,resultPresentation:a?.resultPresentation,scopeMarkers:a?.scopeMarkers,hints:a?.hints,warnings:a?.warnings,diffStatuses:a?.diffStatuses,diffs:[b(n.source,n.before??"",n.after??"").diff],operations:r.map(({outcome:o,changed:s})=>({operation:o.operation==="remove"?"delete":o.operation,changes:s.changes.length})),formatting:a?.formatting??r.at(-1)?.changed.formatting})})}p(G,"finalApplyMutations");function ce(e){return e!==null&&typeof e=="object"&&"operation"in e&&"files"in e&&Array.isArray(e.files)&&"effect"in e}p(ce,"isMutation");import{highlightCode as H}from"@earendil-works/pi-coding-agent";import{wrapTextWithAnsi as X,visibleWidth as Y,truncateToWidth as pe}from"@earendil-works/pi-tui";function Qe(e,l,f,n=process.cwd()){let r=e.select(),i=[...r.automatic,...r.explicit.filter(t=>t.kind==="operation")].filter(t=>R(t.value)&&!t.value.equal),a=i.flatMap(t=>R(t.value)?[D(t.value,n)]:[]),o=new Set(i.flatMap(t=>t.presentation?.content??[]));if(r.files.length===0){let t=[...r.automatic.map(c=>c.presentation),...r.explicit.map(c=>c.kind==="operation"?c.presentation:void 0)].filter(c=>c!==void 0);return{comparisons:a,cwd:n,blocks:l.content.filter(c=>!o.has(c)).flatMap(c=>c.type==="text"?[{text:c.text,read:t.find(g=>g.content.includes(c))}]:[])}}let s=G(e);return{...s.length>0?{mutations:{results:s}}:{},comparisons:a,cwd:n,blocks:[...r.explicit.flatMap(t=>t.kind==="operation"&&R(t.value)&&!t.value.equal?[]:k(t.value)?[{text:P(t.value)}]:t.kind==="operation"?t.presentation?.content.flatMap(c=>c.type==="text"?[{text:c.text,read:t.presentation}]:[])??[]:[{text:typeof t.value=="string"?t.value:t.value===void 0?"undefined":JSON.stringify(t.value,null,2)}]),...r.automatic.flatMap(({value:t,presentation:c})=>k(t)?[{text:P(t)}]:t!==null&&typeof t=="object"&&"kind"in t&&t.kind==="index-operation"?c?.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}]:[])),...f===void 0?[]:[{text:f instanceof Error?f.message:JSON.stringify(f)}]]}}p(Qe,"createApplyDisplay");function j(e,l,f,n,r,i,a=!1){let o=Math.max(1,f);if(o<5)return e.split(`
|
|
9
|
-
`).flatMap(u=>X(u,o));let s=o-4,t=p(u=>l.fg("borderMuted",u),"border"),g=pe(` ${n==="call"?"Apply \xB7 JavaScript":"Result"} `,o-4,""),y=[t(`${n==="call"?"\u256D":"\u251C"}\u2500`)+l.fg(a?"error":"accent",g)+t(`${"\u2500".repeat(Math.max(0,o-Y(g)-3))}${n==="call"?"\u256E":"\u2524"}`)],d=`${t("\u2502")}${" ".repeat(o-2)}${t("\u2502")}`;for(let u of e.split(`
|
|
10
|
-
`)){let h=i==="diff"?l.fg(u.startsWith("+")?"toolDiffAdded":u.startsWith("-")?"toolDiffRemoved":"toolDiffContext",u):i?H(u,i).join(`
|
|
11
|
-
`):l.fg("toolOutput",u);for(let w of X(h,s))y.push(`${t("\u2502")} ${w}${" ".repeat(Math.max(0,s-Y(w)))} ${t("\u2502")}`)}n==="call"&&y.push(d),r&&y.push(t(`\u2570${"\u2500".repeat(o-2)}\u256F`));let m=l.getBgAnsi("toolPendingBg");return y.map(u=>m+C(u,m)+"\x1B[0m")}p(j,"applyFrameRows");function ue(e){return(l,f,n)=>{let r=n.state,i=r.projectSource??=U(e?o=>e(o,f):void 0,e?o=>H(o,"javascript").join(`
|
|
12
|
-
`):void 0),a=l!==null&&typeof l=="object"&&"source"in l&&typeof l.source=="string"?l.source:"";return{invalidate(){},render(o){return j(r.codeView||n.expanded?r.displaySource??a:i(r.displaySource??a),f,o,"call",!r.applyResultReady,r.codeView||n.expanded||!e?"javascript":void 0)}}}}p(ue,"createApplyCallRenderer");var et=ue();function de(e){return(l,f,n,r)=>{r.state.applyResultReady=!0;let i=l.details;r.state.displaySource=i?.displaySource;let a=i?.display,o=a?.blocks??[{text:r.isError?"Apply failed":"Apply finished"}],s=M({kind:"source"}),t=o.map(d=>s(d.read??{content:[{type:"text",text:d.text}],details:me(d.text)},f,n,{...r,isError:!1,lastComponent:void 0})),c=a?.mutations,g=(a?.comparisons??[]).flatMap(d=>[e?.(d,n,f.expanded,a?.cwd??process.cwd())??new fe((d.results??[]).flatMap(u=>u.data.diffs??[]).join(`
|
|
13
|
-
`),0,0)]),y=c===void 0?void 0:e?.(c,n,f.expanded,a?.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 c!==void 0&&m.push(...(c.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(`
|
|
14
|
-
`),n,d,"result",!0,void 0,r.isError)}}}}p(de,"createApplyResultRenderer");function me(e){try{let l=JSON.parse(e);return l!==null&&typeof l=="object"?{source:"result.json"}:{}}catch{return{}}}p(me,"jsonDetails");var tt=de();export{ee as a,Se as b,Te as c,Ne as d,ie as e,ae as f,_e as g,G as h,Qe as i,ue as j,et as k,de as l,tt as m};
|
package/dist/chunk-B5KB2I7J.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as w}from"./chunk-5VSE5X5R.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as T}from"node:crypto";import{createRequire as P}from"node:module";import L from"node:path";import*as h from"web-tree-sitter";var F=P(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),j=new Set(["program","module"]),y=new Set(["body","consequence","alternative","handler","finalizer"]),S,x=new Map;function E(c){switch(c){case".ts":case".tsx":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":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}}u(E,"grammarWasmPath");async function B(c){let n=E(c);if(!n)return;S??=h.Parser.init(),await S;let t=x.get(n);if(t===void 0){let o=F.resolve(n);t=h.Language.load(o),x.set(n,t)}let s=await t,i=new h.Parser;return i.setLanguage(s),i}u(B,"ensureParser");async function W(c,n,t){if(t.length===0)return;let s=L.isAbsolute(c)?c:L.resolve(n,c),i=await B(L.extname(s).toLowerCase());if(i)return i.parse(t.join(`
|
|
2
|
-
`))??void 0}u(W,"parseDocument");function A(c,n,t){let s=c.slice(Math.max(0,n-1),Math.max(0,t)).join(`
|
|
3
|
-
`);return T("sha1").update(s).digest("hex").slice(0,4).toUpperCase()}u(A,"hashScope");var b=class extends w{static{u(this,"AstScopeTextAnchor")}constructor(n,t,s,i){super(`scope-${n}-${t}${i===void 0?"":`-${i}`}`,s)}};function g(c,n,t,s){return new b(c,n,t,s)}u(g,"createScopeAnchor");var C=class{static{u(this,"AstScopeManager")}async getDocumentScopes(n,t,s){if(s.length===0)return[];let i=await W(n,t,s);if(!i)return[];let o=[];return this.collectCandidates(i.rootNode,o),this.buildEntries(o,s)}collectCandidates(n,t,s=0,i=!1){if(s>100||!n.isNamed)return;let o=n.type;if(!o||j.has(o)){for(let a of n.namedChildren)this.collectCandidates(a,t,s+1);return}for(let a of y){let e=n.childForFieldName(a);if(!e?.isNamed)continue;let r=e.startPosition.row+1,l=e.endPosition.row+1,f=l-r>=3,d=[...y].some(m=>e.childForFieldName(m)!==null);f&&!d&&t.push({startLine:r,endLine:l,kind:`${o}.${a}`,fromBodyField:!0}),this.collectCandidates(e,t,s+1,!0)}if(![...y].some(a=>n.childForFieldName(a)!==null)&&!i){let a=n.startPosition.row+1,e=n.endPosition.row+1;e-a>=3&&n.namedChildren.length>0&&t.push({startLine:a,endLine:e,kind:o,fromBodyField:!1})}for(let a of n.namedChildren)this.collectCandidates(a,t,s+1)}buildEntries(n,t){let s=new Map;for(let e of n){let r=s.get(e.startLine);(!r||e.endLine>r.endLine||e.endLine===r.endLine&&e.fromBodyField&&!r.fromBodyField)&&s.set(e.startLine,e)}let i=[...s.values()].sort((e,r)=>e.startLine-r.startLine||r.endLine-e.endLine),o=[];for(let e of i)o.some(l=>l.startLine<e.startLine&&l.endLine===e.endLine)||o.push(e);let p=new Map;for(let e of o){let r=A(t,e.startLine,e.endLine);p.set(r,(p.get(r)??0)+1)}let a=new Map;return o.map(e=>{let r=A(t,e.startLine,e.endLine),l=p.get(r)??1,f=(a.get(r)??0)+1;a.set(r,f);let d=l>1?f:void 0;return{name:e.kind,kind:e.kind,startLine:e.startLine,endLine:e.endLine,depth:o.filter(m=>m!==e&&m.startLine<=e.startLine&&m.endLine>=e.endLine&&(m.startLine<e.startLine||m.endLine>e.endLine)).length,hash:r,blockHash:r,...d!==void 0&&{occurrence:d},beginAnchor:g("begin",r,e.startLine,d),endScopeAnchor:g("end",r,e.endLine,d),scopeBeginAnchor:g("begin",r,e.startLine,d),scopeEndAnchor:g("end",r,e.endLine,d)}})}};export{W as a,C as b};
|