pi-agent-ide 0.3.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 +62 -0
- package/README.md +7 -6
- 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-CW53ZTU3.js → chunk-DQXPQOF7.js} +1 -1
- package/dist/chunk-EJ5OACQM.js +1 -0
- 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-J34VKQGJ.js +1 -0
- package/dist/chunk-J4RTW44E.js +1 -0
- package/dist/{chunk-HGPUI7F3.js → chunk-KII2JQC5.js} +1 -1
- package/dist/{chunk-CEKXBS55.js → chunk-L7JMDDSD.js} +1 -1
- package/dist/{chunk-EWNWKDMP.js → chunk-LY6U5EAD.js} +1 -1
- package/dist/{chunk-ERVMDQGX.js → chunk-MGCHOGQD.js} +1 -1
- package/dist/{chunk-LRYE2WCN.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-SSHZEWWV.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/tools.md +11 -0
- 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 +66 -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-resource/src/resource.ts +2 -0
- 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/api/tool-renderer.ts +3 -0
- 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 +182 -10
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +135 -6
- 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 +60 -2
- 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 +61 -38
- package/src/api/hooks.ts +168 -0
- package/src/api/text-editor.ts +2 -0
- package/src/composite/builtin-extensions.ts +13 -0
- package/src/composite/extensions-config.ts +18 -0
- package/src/composite/module-labels.ts +12 -0
- package/src/composite/module-settings-store.ts +17 -1
- package/src/composite/module-settings.ts +34 -4
- package/src/composite/preferences.ts +26 -0
- package/src/composite/settings-panel.ts +62 -30
- 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 +66 -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 +60 -2
- 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/api/tool-renderer.ts +3 -0
- 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 +182 -10
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +135 -6
- 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/pi-agent-ide.ts +2 -1
- 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 +40 -0
- 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 +204 -0
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +452 -0
- package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +127 -0
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +159 -0
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +642 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +56 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +151 -0
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +78 -0
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +212 -0
- package/dist/chunk-5MSNYFDE.js +0 -1
- package/dist/chunk-B5KB2I7J.js +0 -3
- package/dist/chunk-NMFQGKPE.js +0 -2
- package/dist/chunk-OVUYPHDE.js +0 -1
- package/dist/chunk-RHV5STR3.js +0 -3
- package/dist/chunk-TPIHQYK2.js +0 -14
- package/dist/chunk-VCCMVQXU.js +0 -1
- package/dist/chunk-VZJIZXSH.js +0 -14
- 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
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { stripVTControlCharacters } from "node:util";
|
|
3
|
+
|
|
4
|
+
import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Type } from "typebox";
|
|
6
|
+
|
|
7
|
+
import { COMPACT_READ_ROWS } from "#src/extensions/pi-agent-read/src/core/tools/read/read-renderer.js";
|
|
8
|
+
import { formatAgentTerminalSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/output-limits.js";
|
|
9
|
+
import { renderRunCall, renderRunResult } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
10
|
+
|
|
11
|
+
import { shellSyntaxGuidance } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
|
|
12
|
+
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
13
|
+
import type { TerminalUi } from "#src/plugins/pi-agent-ide-terminal/src/ui.js";
|
|
14
|
+
import type {
|
|
15
|
+
ShellProfile,
|
|
16
|
+
TerminalSessionSnapshot,
|
|
17
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
18
|
+
|
|
19
|
+
const runParameters = Type.Object(
|
|
20
|
+
{
|
|
21
|
+
command: Type.String({
|
|
22
|
+
minLength: 1,
|
|
23
|
+
description: "Command written in the syntax of the configured system shell",
|
|
24
|
+
}),
|
|
25
|
+
background: Type.Optional(
|
|
26
|
+
Type.Boolean({
|
|
27
|
+
description: "Return immediately while the terminal session continues. Defaults to false.",
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
timeoutSeconds: Type.Optional(
|
|
31
|
+
Type.Number({
|
|
32
|
+
minimum: 0.1,
|
|
33
|
+
maximum: 86_400,
|
|
34
|
+
description:
|
|
35
|
+
"Maximum foreground wait in seconds before returning the live session as background. Defaults to 60.",
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
38
|
+
cwd: Type.Optional(
|
|
39
|
+
Type.String({
|
|
40
|
+
description: "Working directory. Relative paths resolve from the current workspace.",
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
cols: Type.Optional(
|
|
44
|
+
Type.Integer({ minimum: 20, maximum: 300, description: "Virtual terminal width in cells" }),
|
|
45
|
+
),
|
|
46
|
+
rows: Type.Optional(
|
|
47
|
+
Type.Integer({ minimum: 5, maximum: 120, description: "Virtual terminal height in cells" }),
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
{ additionalProperties: false },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
/** Register terminal process lifecycle tools with platform-specific shell guidance. */
|
|
54
|
+
export function registerTerminalTools(
|
|
55
|
+
pi: ExtensionAPI,
|
|
56
|
+
manager: TerminalSessionManager,
|
|
57
|
+
profile: ShellProfile,
|
|
58
|
+
ui: Pick<TerminalUi, "bind" | "notifyWaitTransition">,
|
|
59
|
+
): void {
|
|
60
|
+
const toolName = process.platform === "win32" ? "powershell" : "bash";
|
|
61
|
+
pi.registerTool(
|
|
62
|
+
defineTool<typeof runParameters, TerminalSessionSnapshot>({
|
|
63
|
+
name: toolName,
|
|
64
|
+
label: profile.displayName,
|
|
65
|
+
promptSnippet: `Execute ${profile.displayName} commands in synchronous or background terminal sessions`,
|
|
66
|
+
promptGuidelines: [
|
|
67
|
+
`Write commands for ${profile.displayName}; commands are not translated between shell languages.`,
|
|
68
|
+
`Use ${toolName} 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.`,
|
|
69
|
+
],
|
|
70
|
+
description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort; 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. ${shellSyntaxGuidance(profile)}`,
|
|
71
|
+
parameters: runParameters,
|
|
72
|
+
async execute(_toolCallId, input, signal, onUpdate, context) {
|
|
73
|
+
ui.bind(context);
|
|
74
|
+
const cwd = input.cwd === undefined ? context.cwd : path.resolve(context.cwd, input.cwd);
|
|
75
|
+
const session = manager.start({
|
|
76
|
+
command: input.command,
|
|
77
|
+
background: input.background ?? false,
|
|
78
|
+
cwd,
|
|
79
|
+
shell: profile,
|
|
80
|
+
...(input.cols === undefined ? {} : { cols: input.cols }),
|
|
81
|
+
...(input.rows === undefined ? {} : { rows: input.rows }),
|
|
82
|
+
});
|
|
83
|
+
if (input.background === true && session.status !== "failed") {
|
|
84
|
+
await captureInitialBackgroundPreview(manager, session, onUpdate);
|
|
85
|
+
if (session.status !== "running") session.completionDelivered = true;
|
|
86
|
+
return terminalResult(manager.snapshot(session));
|
|
87
|
+
}
|
|
88
|
+
if (session.status === "failed") return terminalResult(manager.snapshot(session));
|
|
89
|
+
const outcome = await manager.waitForForeground(session.source, {
|
|
90
|
+
signal,
|
|
91
|
+
timeoutMs: (input.timeoutSeconds ?? 60) * 1_000,
|
|
92
|
+
});
|
|
93
|
+
if (outcome.reason === "aborted") ui.notifyWaitTransition(outcome.session);
|
|
94
|
+
return terminalResult(manager.snapshot(outcome.session));
|
|
95
|
+
},
|
|
96
|
+
renderCall(args, theme) {
|
|
97
|
+
const command = typeof args.command === "string" ? args.command : "";
|
|
98
|
+
const cwd =
|
|
99
|
+
typeof args.cwd === "string" ? path.resolve(process.cwd(), args.cwd) : process.cwd();
|
|
100
|
+
return renderRunCall(command, args.background === true, cwd, profile, theme);
|
|
101
|
+
},
|
|
102
|
+
renderResult(result, options, theme) {
|
|
103
|
+
return renderRunResult(
|
|
104
|
+
result.details as Partial<TerminalSessionSnapshot>,
|
|
105
|
+
options.expanded,
|
|
106
|
+
theme,
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function terminalResult(snapshot: TerminalSessionSnapshot) {
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text" as const, text: formatAgentTerminalSnapshot(snapshot) }],
|
|
116
|
+
details: snapshot,
|
|
117
|
+
isError: snapshot.status === "failed" || snapshot.status === "lost",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async function captureInitialBackgroundPreview(
|
|
121
|
+
manager: TerminalSessionManager,
|
|
122
|
+
session: ReturnType<TerminalSessionManager["start"]>,
|
|
123
|
+
onUpdate: ((result: ReturnType<typeof terminalResult>) => void) | undefined,
|
|
124
|
+
): Promise<void> {
|
|
125
|
+
await new Promise<void>((resolve) => {
|
|
126
|
+
let settled = false;
|
|
127
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
128
|
+
let unsubscribe = (): void => {};
|
|
129
|
+
const finish = (): void => {
|
|
130
|
+
if (settled) return;
|
|
131
|
+
settled = true;
|
|
132
|
+
clearTimeout(timeout);
|
|
133
|
+
unsubscribe();
|
|
134
|
+
resolve();
|
|
135
|
+
};
|
|
136
|
+
const publish = (): void => {
|
|
137
|
+
const snapshot = manager.snapshot(session);
|
|
138
|
+
onUpdate?.(terminalResult(snapshot));
|
|
139
|
+
const rows = stripVTControlCharacters(snapshot.output)
|
|
140
|
+
.replaceAll("\r", "")
|
|
141
|
+
.split("\n")
|
|
142
|
+
.filter((line) => line.length > 0).length;
|
|
143
|
+
if (rows >= COMPACT_READ_ROWS || snapshot.status !== "running") finish();
|
|
144
|
+
};
|
|
145
|
+
unsubscribe = manager.onDidChange((changed) => {
|
|
146
|
+
if (changed.id === session.id) publish();
|
|
147
|
+
});
|
|
148
|
+
timeout = setTimeout(finish, 2_000);
|
|
149
|
+
publish();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { IPty } from "node-pty";
|
|
2
|
+
import type { Terminal } from "@xterm/headless";
|
|
3
|
+
|
|
4
|
+
export type TerminalWaitReason = "timeout" | "interactive" | "aborted";
|
|
5
|
+
export type TerminalCompletionReason = "timeout";
|
|
6
|
+
|
|
7
|
+
export type TerminalSessionStatus =
|
|
8
|
+
| "running"
|
|
9
|
+
| "completed"
|
|
10
|
+
| "failed"
|
|
11
|
+
| "stopping"
|
|
12
|
+
| "stopped"
|
|
13
|
+
| "cancelled"
|
|
14
|
+
| "lost";
|
|
15
|
+
|
|
16
|
+
export interface ShellProfile {
|
|
17
|
+
readonly executable: string;
|
|
18
|
+
readonly displayName: string;
|
|
19
|
+
readonly family: "posix" | "powershell" | "cmd";
|
|
20
|
+
readonly commandArgs: (command: string) => readonly string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface TerminalSession {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly source: string;
|
|
26
|
+
readonly command: string;
|
|
27
|
+
background: boolean;
|
|
28
|
+
readonly cwd: string;
|
|
29
|
+
readonly shell: ShellProfile;
|
|
30
|
+
readonly startedAt: number;
|
|
31
|
+
readonly cols: number;
|
|
32
|
+
readonly rows: number;
|
|
33
|
+
readonly fullOutputPath: string;
|
|
34
|
+
readonly process?: IPty;
|
|
35
|
+
readonly screen: Terminal;
|
|
36
|
+
status: TerminalSessionStatus;
|
|
37
|
+
endedAt?: number;
|
|
38
|
+
exitCode?: number;
|
|
39
|
+
signal?: number;
|
|
40
|
+
error?: string;
|
|
41
|
+
output: string;
|
|
42
|
+
outputStart: number;
|
|
43
|
+
screenReady: Promise<void>;
|
|
44
|
+
completion: Promise<TerminalSession>;
|
|
45
|
+
resolveCompletion: (session: TerminalSession) => void;
|
|
46
|
+
completionDelivered: boolean;
|
|
47
|
+
waitReason?: TerminalWaitReason;
|
|
48
|
+
completionReason?: TerminalCompletionReason;
|
|
49
|
+
lastActivityAt: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface TerminalSessionSnapshot {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly source: string;
|
|
55
|
+
readonly command: string;
|
|
56
|
+
readonly cwd: string;
|
|
57
|
+
readonly shell: string;
|
|
58
|
+
readonly shellFamily: ShellProfile["family"];
|
|
59
|
+
readonly background: boolean;
|
|
60
|
+
readonly status: TerminalSessionStatus;
|
|
61
|
+
readonly waitReason?: TerminalWaitReason;
|
|
62
|
+
readonly completionReason?: TerminalCompletionReason;
|
|
63
|
+
readonly lastActivityAt: number;
|
|
64
|
+
readonly idleMs: number;
|
|
65
|
+
readonly startedAt: number;
|
|
66
|
+
readonly endedAt?: number;
|
|
67
|
+
readonly elapsedMs: number;
|
|
68
|
+
readonly exitCode?: number;
|
|
69
|
+
readonly signal?: number;
|
|
70
|
+
readonly error?: string;
|
|
71
|
+
readonly output: string;
|
|
72
|
+
readonly outputStart: number;
|
|
73
|
+
readonly outputEnd: number;
|
|
74
|
+
readonly truncated: boolean;
|
|
75
|
+
readonly fullOutputPath: string;
|
|
76
|
+
readonly cols: number;
|
|
77
|
+
readonly rows: number;
|
|
78
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Box, Container } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
import { renderTerminalResult } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
5
|
+
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
6
|
+
import type {
|
|
7
|
+
TerminalSession,
|
|
8
|
+
TerminalSessionSnapshot,
|
|
9
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
10
|
+
|
|
11
|
+
const COMPLETION_DELAY_MS = 120;
|
|
12
|
+
const DEFAULT_STALE_INTERVAL_MS = 120_000;
|
|
13
|
+
|
|
14
|
+
/** Delivers background terminal completion messages separately from the shared process UI. */
|
|
15
|
+
export class TerminalUi {
|
|
16
|
+
readonly #pending = new Map<string, TerminalSession>();
|
|
17
|
+
#deliveryTimer: ReturnType<typeof setTimeout> | undefined;
|
|
18
|
+
readonly #staleTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
19
|
+
readonly #overdue = new Set<string>();
|
|
20
|
+
#context: ExtensionContext | undefined;
|
|
21
|
+
#closed = false;
|
|
22
|
+
readonly #removeManagerListeners: readonly (() => void)[];
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly pi: ExtensionAPI,
|
|
26
|
+
private readonly manager: TerminalSessionManager,
|
|
27
|
+
private readonly staleIntervalMs = DEFAULT_STALE_INTERVAL_MS,
|
|
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
|
+
});
|
|
40
|
+
pi.registerMessageRenderer("terminal-completion", (message, { expanded }, theme) => {
|
|
41
|
+
const content = new Container();
|
|
42
|
+
for (const session of completionSnapshots(message.details))
|
|
43
|
+
content.addChild(renderTerminalResult(session, expanded, theme));
|
|
44
|
+
const card = new Box(1, 1, (line) => theme.bg("toolSuccessBg", line));
|
|
45
|
+
card.addChild(content);
|
|
46
|
+
return card;
|
|
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
|
+
}
|
|
56
|
+
|
|
57
|
+
bind(context: ExtensionContext): void {
|
|
58
|
+
this.#context = context;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Deliver deferred stale notices after Pi has fully settled. */
|
|
62
|
+
onAgentSettled(context: ExtensionContext): void {
|
|
63
|
+
this.#context = context;
|
|
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
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
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 aborted; ${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 {
|
|
86
|
+
this.#closed = true;
|
|
87
|
+
if (this.#deliveryTimer !== undefined) clearTimeout(this.#deliveryTimer);
|
|
88
|
+
this.#deliveryTimer = undefined;
|
|
89
|
+
this.#pending.clear();
|
|
90
|
+
for (const timer of this.#staleTimers.values()) clearTimeout(timer);
|
|
91
|
+
this.#staleTimers.clear();
|
|
92
|
+
this.#overdue.clear();
|
|
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);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#queueCompletion(session: TerminalSession): void {
|
|
143
|
+
if (this.#closed || session.completionDelivered) return;
|
|
144
|
+
this.#pending.set(session.id, session);
|
|
145
|
+
if (this.#deliveryTimer !== undefined) return;
|
|
146
|
+
this.#deliveryTimer = setTimeout(() => {
|
|
147
|
+
this.#deliveryTimer = undefined;
|
|
148
|
+
const sessions = [...this.#pending.values()].filter(
|
|
149
|
+
(candidate) => !candidate.completionDelivered,
|
|
150
|
+
);
|
|
151
|
+
this.#pending.clear();
|
|
152
|
+
if (this.#closed || sessions.length === 0) return;
|
|
153
|
+
for (const completed of sessions) completed.completionDelivered = true;
|
|
154
|
+
const snapshots = sessions.map((completed) => this.manager.snapshot(completed));
|
|
155
|
+
this.pi.sendMessage(
|
|
156
|
+
{
|
|
157
|
+
customType: "terminal-completion",
|
|
158
|
+
display: true,
|
|
159
|
+
content: formatCompletionMessage(snapshots),
|
|
160
|
+
details: { sessions: snapshots },
|
|
161
|
+
},
|
|
162
|
+
{ triggerTurn: true, deliverAs: "steer" },
|
|
163
|
+
);
|
|
164
|
+
}, COMPLETION_DELAY_MS);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function completionSnapshots(details: unknown): readonly TerminalSessionSnapshot[] {
|
|
169
|
+
if (!isRecord(details) || !Array.isArray(details.sessions)) return [];
|
|
170
|
+
return details.sessions.filter(isTerminalSessionSnapshot);
|
|
171
|
+
}
|
|
172
|
+
function isTerminalSessionSnapshot(value: unknown): value is TerminalSessionSnapshot {
|
|
173
|
+
return (
|
|
174
|
+
isRecord(value) &&
|
|
175
|
+
typeof value.id === "string" &&
|
|
176
|
+
typeof value.source === "string" &&
|
|
177
|
+
typeof value.command === "string" &&
|
|
178
|
+
typeof value.cwd === "string" &&
|
|
179
|
+
typeof value.shell === "string" &&
|
|
180
|
+
typeof value.background === "boolean" &&
|
|
181
|
+
typeof value.status === "string" &&
|
|
182
|
+
typeof value.startedAt === "number" &&
|
|
183
|
+
typeof value.elapsedMs === "number" &&
|
|
184
|
+
typeof value.output === "string"
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
function formatCompletionMessage(sessions: readonly TerminalSessionSnapshot[]): string {
|
|
188
|
+
const heading =
|
|
189
|
+
sessions.length === 1 ? "Background terminal completed:" : "Background terminals completed:";
|
|
190
|
+
return `${heading}\n${sessions
|
|
191
|
+
.map((session) => {
|
|
192
|
+
const exit = session.exitCode === undefined ? "" : `, exit ${session.exitCode}`;
|
|
193
|
+
const reason =
|
|
194
|
+
session.completionReason === undefined ? "" : `, reason ${session.completionReason}`;
|
|
195
|
+
const excerpt = session.output.trimEnd().slice(-2_000);
|
|
196
|
+
return `- ${session.source}: ${session.status}${exit}${reason}, ${formatElapsed(session.elapsedMs)}\n${excerpt || "(no output)"}`;
|
|
197
|
+
})
|
|
198
|
+
.join("\n")}`;
|
|
199
|
+
}
|
|
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)"}`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function formatElapsed(milliseconds: number): string {
|
|
206
|
+
return milliseconds < 1_000
|
|
207
|
+
? `${milliseconds}ms`
|
|
208
|
+
: `${(milliseconds / 1_000).toFixed(milliseconds < 10_000 ? 1 : 0)}s`;
|
|
209
|
+
}
|
|
210
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
211
|
+
return typeof value === "object" && value !== null;
|
|
212
|
+
}
|
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-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};
|
package/dist/chunk-NMFQGKPE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-GUTQ3PWL.js";import{m as b}from"./chunk-5VSE5X5R.js";import{a as S}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{createHash as ue}from"node:crypto";import{readFile as q}from"node:fs/promises";import h from"node:path";import{spawn as ee}from"node:child_process";import D from"node:path";import{createInterface as te}from"node:readline";import{existsSync as Y}from"node:fs";import Z from"node:os";import H from"node:path";function F(e=process.env.PI_CODING_AGENT_DIR??H.join(Z.homedir(),".pi","agent"),t=process.platform){let n=H.join(e,"bin",t==="win32"?"rg.exe":"rg");return Y(n)?n:"rg"}a(F,"resolveRipgrepExecutable");async function A(e,t,n){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let r=e.limit??100,o=D.resolve(t,oe(e.path??".")),s=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...O(e.include).flatMap(i=>["--glob",i]),...O(e.exclude).flatMap(i=>["--glob",`!${i}`]),"--",e.query,o];if(e.regex!==!0)return R(["--fixed-strings",...s],r,n);try{return await R(["--engine","auto",...s],r,n)}catch(i){if(!ne(i))throw i;return R(["--engine","default",...s],r,n)}}a(A,"searchText");function R(e,t,n){return new Promise((r,o)=>{let s=ee(F(),e,{stdio:["ignore","pipe","pipe"]}),i=te({input:s.stdout}),c=[],l="",u=!1,d,g=a(()=>{s.kill()},"abort"),m=a(()=>{n?.removeEventListener("abort",g),i.close()},"cleanup");s.stderr.setEncoding("utf8"),s.stderr.on("data",f=>{l+=f}),i.on("line",f=>{if(!(u||d!==void 0||f.length===0))try{let p=JSON.parse(f);if(p.type!=="match")return;for(let X of re(p)){if(c.length===t){u=!0,s.kill();return}c.push(X)}}catch(p){d=p,s.kill()}}),s.once("error",f=>{m(),o(f)}),s.once("close",f=>{if(m(),n?.aborted===!0){let p=new Error("Search was aborted.");p.name="AbortError",o(p);return}if(d!==void 0){o(new Error("Unable to parse ripgrep search output.",{cause:d}));return}if(!u&&f!==0&&f!==1){o(new Error(l.trim()||`ripgrep exited with code ${String(f)}.`));return}c.sort(ie),r({matches:c,complete:!u})}),n?.addEventListener("abort",g,{once:!0}),n?.aborted===!0&&g()})}a(R,"runRipgrep");function ne(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}a(ne,"isPcre2MatchLimitError");function re(e){let t=e.data.path.text,n=e.data.lines.text;if(t===void 0||n===void 0||!Number.isSafeInteger(e.data.line_number))return[];let r=n.replace(/(?:\r\n|\n)$/u,""),o=Buffer.from(n),s=[];for(let i of e.data.submatches){if(i.start<0||i.end<=i.start||i.end>o.length)continue;let c=o.subarray(0,i.start).toString("utf8").length,l=o.subarray(0,i.end).toString("utf8").length;s.push({source:D.resolve(t),lineNumber:e.data.line_number,startColumn:c,endColumn:l,matchedText:r.slice(c,l),lineText:r})}return s}a(re,"matchesFromEvent");function O(e){if(e===void 0)return[];let t=[],n=0,r="";for(let o of e){if(o==="{"?n+=1:o==="}"&&(n=Math.max(0,n-1)),n===0&&(o===","||/\s/u.test(o))){r.length>0&&(t.push(r),r="");continue}r+=o}return r.length>0&&t.push(r),t}a(O,"splitGlobList");function oe(e){return e.startsWith("@")?e.slice(1):e}a(oe,"stripFilePrefix");function ie(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}a(ie,"compareMatches");function N(e,t=!1){let n=M(e);if(!C(n))return t?e:B(e);let r=E(new v(e,n).parse(),t);return`^${r.condition}.*?\\K(${r.match})`}a(N,"compileSearchQuery");function _(e){if(C(M(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(B).join("|")})`:void 0}a(_,"compileSearchFallbackQuery");function C(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}a(C,"containsBooleanSyntax");var v=class{static{a(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(t,n){this.#t=t,this.#r=n}parse(){let t=this.#s(),n=this.#e();if(n.type!=="end"){let r=n.type==="right"?"unexpected ')'.":`unexpected ${ae(n)}.`;throw y(n.offset,r)}return t}#s(){let t=this.#n();for(;this.#e().type==="or";){let n=this.#o(),r=this.#c(`after ${n.value}`);t={kind:"or",left:t,right:this.#a(r)}}return t}#n(){return this.#a(this.#c())}#a(t){let n=t;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#c(`after ${r.value}`);n={kind:r.type,left:n,right:o};continue}if(r.type==="term"||r.type==="left"){n={kind:"and",left:n,right:this.#c()};continue}return n}}#c(t){let n=this.#e();if(n.type==="term")return this.#o(),{kind:"term",value:n.value,quoted:n.quoted};if(n.type==="left"){if(this.#o(),this.#e().type==="right"||this.#e().type==="end")throw y(this.#e().offset,"expected a term after '('.");let o=this.#s();if(this.#e().type!=="right")throw y(this.#e().offset,"expected ')'.");return this.#o(),o}if(t===void 0&&(n.type==="and"||n.type==="or"||n.type==="not"))throw y(n.offset,`expected a term before ${n.value}.`);let r=t===void 0?"":` ${t}`;throw y(n.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let t=this.#e();return this.#i+=1,t}};function M(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(/\s/u.test(r)){n+=1;continue}if(r==="("&&se(e,n)){t.push({type:"left",value:r,offset:n}),n+=1;continue}if(r===")"){t.push({type:"right",value:r,offset:n}),n+=1;continue}if(W(e,n)){let i=e.charAt(n+1)==="|"?2:1;t.push({type:"or",value:e.slice(n,n+i),offset:n}),n+=i;continue}if(r==="'"||r==='"'){let i=n,c=r,l="";for(n+=1;n<e.length&&e.charAt(n)!==c;)e.charAt(n)==="\\"&&(e.charAt(n+1)===c||e.charAt(n+1)==="\\")&&(n+=1),l+=e.charAt(n++);if(n>=e.length)throw y(i,`unterminated ${c==="'"?"single":"double"}-quoted term.`);if(n+=1,l.length===0)throw y(i,"quoted terms must not be empty.");t.push({type:"term",value:l,offset:i,quoted:!0});continue}let o=n;for(;n<e.length;){let i=e.charAt(n);if(/\s/u.test(i)||i===")"||W(e,n))break;i==="\\"&&n+1<e.length?n+=2:i==="["||i==="("?n=$(e,n)??n+1:n+=1}let s=e.slice(o,n);t.push({type:ce(s),value:s,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}a(M,"tokenize");function W(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}a(W,"isBooleanPipe");function $(e,t){let n=e.charAt(t)==="["?"]":")",r=t+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===n)return r+1;if(n===")"&&(o==="("||o==="[")){let s=$(e,r);if(s===void 0)return;r=s}else r+=1}}}a($,"regexBlockEnd");function se(e,t){let n=$(e,t);if(n===void 0)return!0;let r=e.slice(t+1,n-1);return r.trim().length===0?!0:C(M(r))}a(se,"isBooleanGroup");function ce(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}a(ce,"operatorType");function ae(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}a(ae,"quoteToken");function y(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}a(y,"syntaxError");function E(e,t){if(e.kind==="term"){let o=t&&!e.quoted?e.value:B(e.value);return{condition:`(?=.*(?:${o}))`,match:o}}let n=E(e.left,t),r=E(e.right,t);return e.kind==="or"?{condition:`(?:${n.condition}|${r.condition})`,match:`(?:${n.match}|${r.match})`}:e.kind==="not"?{condition:`${n.condition}(?!${r.condition})`,match:n.match}:{condition:`${n.condition}${r.condition}`,match:`(?:${n.match}|${r.match})`}}a(E,"compileExpression");function B(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}a(B,"escapeRegex");function Be(e){let t=N(e.query),n=N(e.query,!0),r=_(e.query),o=[];return n!==t&&o.push({query:n,mode:"regex"}),r!==void 0&&r!==t&&r!==n&&o.push({query:r,mode:"words"}),{...e,query:t,regex:!0,fallbacks:o}}a(Be,"createSearchRecipe");async function P(e,t,n){let r=e.query,o=await A(e,t,n),s=[];for(let i of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;n?.throwIfAborted();try{o=await A({...e,query:i.query,regex:!0},t,n),r=i.query,s.push(i.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(c){if(i.mode!=="regex"||!le(c)||n?.aborted)throw c;s.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:s}}a(P,"runSearchRecipe");function le(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}a(le,"isRegexSyntaxError");var de=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,z=4;function _e(e,t,n,r){return U(e,t,n,r).slice(0,z)}a(_e,"createSearchSessionId");function U(e,t,n,r){let o=n===void 0?pe(t.map(c=>c.source)):h.resolve(n),s=t.map(c=>({match:c,source:h.relative(o,h.resolve(c.source))})).sort((c,l)=>c.source.localeCompare(l.source)||L(c.match,l.match)).map(({match:c,source:l})=>[l,c.lineNumber,c.startColumn,c.endLineNumber??c.lineNumber,c.endColumn,c.matchedText,c.lineText]),i=K(r??{query:e,regex:!0},o);return ue("sha256").update(JSON.stringify([e,o,i,s])).digest("hex").toUpperCase()}a(U,"createSearchSessionIdentity");function he(e,t){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let n=z;n<=e.length;n+=1){let r=e.slice(0,n);if(!t.has(r))return r}throw new Error("Could not allocate a unique search session id.")}a(he,"allocateSearchSessionId");function K(e,t){return{query:e.query,path:h.resolve(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??100,regex:e.regex===!0,fallbacks:e.fallbacks??[]}}a(K,"normalizeRecipe");var Q=class{constructor(t=U){this.createIdentity=t}static{a(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(t,n,r,o,s,i={query:t,regex:!0},c){let l=n.map(p=>({...p,source:h.resolve(p.source)})).sort(L),u=await J(l,s),d=this.createIdentity(t,l,o,i),m=this.#r.get(d)??he(d,new Set(this.#t.keys())),f={id:m,query:t,matches:l,complete:r,contentBySource:u,recipe:i,...c!==void 0&&{refresh:c},cwd:h.resolve(o)};return this.#r.set(d,m),this.#t.set(m,f),f}async observeAfterEdit(t,n){let r=new Set(t.flatMap(s=>{let i=typeof s=="string"?T(s):void 0;return i===void 0?[]:[i.id]})),o=[];for(let s of r){let i=this.#t.get(s);if(i===void 0)continue;let c={sessionId:s,query:i.recipe.originalQuery??i.query,scope:K(i.recipe,i.cwd)};try{let l=i.refresh===void 0?await P(i.recipe,i.cwd,n):await i.refresh(n);o.push({...c,matches:l.matches.length,complete:l.complete,notices:l.notices})}catch(l){o.push({...c,error:l instanceof Error?l.message:String(l)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
|
|
2
|
-
`),renderFull(t){return t},renderCompact(t){let n=T(t);return n===void 0?"selected result":n.selector==="all"?n.mode==="match"?"all matches":"all lines":n.mode==="match"?`match ${String(n.selector)}`:`line ${String(n.selector)}`},tryResolve:a((t,n)=>this.#i(t,n.source,n.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:a((t,n)=>this.#s(t,n.cwd),"tryResolve")}}async#i(t,n,r){let o=T(t);if(o===void 0)return{kind:"not-handled"};let s=this.#t.get(o.id);if(s===void 0)return w();if(o.selector==="all"&&!s.complete)return x();let i=h.resolve(n),c=s;if(o.selector==="all"){if(s.refreshedComplete?.complete===!0)c=s.refreshedComplete;else if(s.refreshedComplete!==void 0&&(c=await this.#n(s,r),!c.complete))return x()}let l=k(c,o.selector,o.mode),u=l.filter(m=>m.source===i);if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await I(i,r);if(d===void 0)return w(S(u[0]).lineNumber);if(o.selector==="all"&&d!==c.contentBySource.get(i)){if(c=await this.#n(s,r),!c.complete)return x();l=k(c,o.selector,o.mode),u=l.filter(m=>m.source===i)}if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==s.contentBySource.get(i))return w(S(u[0]).lineNumber);let g=b(i,d);return{kind:"resolved",anchor:new j(t,i,u.map(m=>G(g,m,o.mode)))}}async#s(t,n){let r=T(t);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return w();if(r.selector==="all"&&!o.complete)return x();let s=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)s=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(s=await this.#n(o),!s.complete))return x();let u=new Set(k(s,r.selector,r.mode).map(d=>d.source));for(let d of u)if(await I(d)!==s.contentBySource.get(d)){if(s=await this.#n(o),!s.complete)return x();break}}let i=k(s,r.selector,r.mode);if(r.selector!=="all"){let u=i[0]?.source;if(u!==void 0&&await I(u)!==s.contentBySource.get(u))return w(i[0]?.lineNumber)}let c=new Map;for(let u of i){let d=c.get(u.source)??[];d.push(G(b(u.source,s.contentBySource.get(u.source)??u.lineText),u,r.mode)),c.set(u.source,d)}let l=[...c].map(([u,d])=>({source:u,ranges:d,expectedContent:s.contentBySource.get(u)}));return l.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:l}}async#n(t,n){let r=t.refresh===void 0?await P(t.recipe,t.cwd,n):await t.refresh(n),o=r.matches.map(i=>({...i,source:h.resolve(i.source)})).sort(L),s={matches:o,complete:r.complete,contentBySource:await J(o,n)};return this.#t.set(t.id,{...t,refreshedComplete:s}),s}};function T(e){let t=de.exec(e);if(t!==null)return{id:S(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}a(T,"parseSearchAnchor");function k(e,t,n){let r=t==="all"?e.matches:[e.matches[t-1]].filter(fe);if(n==="match"||t!=="all")return r;let o=new Set;return r.flatMap(s=>{let i=b(s.source,e.contentBySource.get(s.source)??s.lineText),c=V(s);return i.lines.slice(s.lineNumber-1,c).flatMap(l=>{let u=`${s.source}\0${String(l.lineNumber)}`;return o.has(u)?[]:(o.add(u),[{...s,lineNumber:l.lineNumber,endLineNumber:l.lineNumber,startColumn:0,endColumn:l.content.length,lineText:l.content,matchedText:l.content}])})})}a(k,"selectMatches");function fe(e){return e!==void 0}a(fe,"isMatch");function V(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}a(V,"lastContainingLine");function G(e,t,n){if(n==="match")return{start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:t.endLineNumber??t.lineNumber,column:t.endColumn}};let r=V(t),o=S(e.lines[r-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:r+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}a(G,"selectionRange");function me(e,t){let n=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,n).map(r=>{let o=r.lineNumber===t.lineNumber?t.startColumn:0,s=r.lineNumber===n?t.endColumn:r.content.length;return r.content.slice(o,s)+(r.lineNumber===n?"":r.lineEnding)}).join("")}a(me,"matchedSourceText");async function J(e,t){let n=new Map;for(let r of new Set(e.map(o=>o.source))){let o=await q(r,{encoding:"utf8",...t!==void 0&&{signal:t}}),s=b(r,o);for(let i of e.filter(c=>c.source===r))if(s.lines[i.lineNumber-1]?.content!==i.lineText||me(s,i)!==i.matchedText)throw new Error(`Search result in ${r} changed before its anchors were registered.`);n.set(r,o)}return n}a(J,"snapshotContents");async function I(e,t){try{return await q(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}catch{return}}a(I,"readCurrent");function w(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}a(w,"staleAnchor");function x(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}a(x,"missingCompleteAnchor");function pe(e){if(e.length===0)return".";let t=h.dirname(h.resolve(S(e[0])));for(let n of e.slice(1)){let r=h.resolve(n);for(;!ge(t,r);){let o=h.dirname(t);if(o===t)return t;t=o}}return t}a(pe,"commonSourceDirectory");function ge(e,t){let n=h.relative(e,t);return n!==".."&&!n.startsWith(`..${h.sep}`)&&!h.isAbsolute(n)}a(ge,"isWithin");function L(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||(e.endLineNumber??e.lineNumber)-(t.endLineNumber??t.lineNumber)||e.endColumn-t.endColumn}a(L,"compareMatches");export{F as a,Be as b,P as c,_e as d,U as e,he as f,Q as g};
|
package/dist/chunk-OVUYPHDE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 p(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`);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=c(t.parameters,t.name);d(o,t.source.field,`${t.name} primary source`);let a=new Set([t.source.field]);for(let e of t.source.targets??[]){if(d(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(d(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(p,"assertTextMutationToolRegistration");function u(t,n){let o=n[t.source.field];return typeof o=="string"?o:""}r(u,"mutationSource");function c(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(c,"schemaProperties");function d(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(d,"assertProperty");export{l as a,p as b,u as c};
|
package/dist/chunk-RHV5STR3.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{c as M}from"./chunk-YHUTTZC6.js";import{i as y,o as k,t as b,u as w}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,b(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:b(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,f,m])=>({lineNumber:u,content:w(d,n),lineEnding:l,...f==null?{}:{presentation:f},...m==null?{}:{metadata:m}}))},...o===void 0?{}:{truncation:{...o,content:w(i??"",n)}}}}a(P,"restoreReadDetails");import c 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 T=V(process.cwd()),K=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]);function S(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("#")||!c.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("~/")?c.join(I(),r.slice(2)):r,o=c.resolve(n,i),s=c.basename(o),u=c.relative(c.dirname(J()),o),d=!c.isAbsolute(u)&&(u==="README.md"||u.startsWith(`docs${c.sep}`)||u.startsWith(`examples${c.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(S,"nativeReadArguments");function v(e,n){return{...e,args:n,lastComponent:e.lastComponent instanceof Z?e.lastComponent:void 0}}a(v,"nativeReadContext");import{getLanguageFromPath as q,getMarkdownTheme as X,highlightCode as z,keyHint as Y}from"@earendil-works/pi-coding-agent";import{Container as L,Markdown as Q,Text as _,truncateToWidth as g,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=S(e,t.cwd);if(r!==void 0)return R(T.renderCall)(r,n,v(t,r));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?S(o.args,o.cwd):void 0;if(s!==void 0&&!r.isPartial)return R(T.renderResult)({...t,details:{truncation:$(t.details).truncation}},r,i,v(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 L;if(!de(t))return o.lastComponent instanceof L?o.lastComponent:new L;let d=n.get(t);d===void 0&&(d=P($(t.details),D(t)),n.set(t,d));let f=(o.lastComponent instanceof h?o.lastComponent:void 0)??new h({result:t,details:d,options:e,expanded:r.expanded,theme:i});return f.update({result:t,details:d,options:e,expanded:r.expanded,theme:i}),f}}a(Me,"createReadResultRenderer");var h=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=[g(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 f of N(l,r))s.push(W(f,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=>g(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(x):t.map(({content:u})=>x(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=y(t);if(r===void 0)return U(t.content,n);let i=q(r.source),o=x(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=x(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=g(` ${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??ce(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=fe(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=g(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(y).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 x(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(x,"normalizeText");function ce(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(ce,"languageLabel");function C(e,n){return e.length===0?[n.fg("dim","Empty content")]:[...e]}a(C,"nonEmptyRows");function fe(e,n){return p(e)<=n?e:n<=1?"\u2026":`\u2026${e.slice(-(n-1))}`}a(fe,"truncateFromStart");export{me as a,ke as b,Me as c};
|
package/dist/chunk-TPIHQYK2.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{a as I,b as k}from"./chunk-B5KB2I7J.js";import{j as N,k as y}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 U}from"node:fs/promises";import Y from"node:path";async function E(e){let n=[],t=await U(e,{withFileTypes:!0});for(let i of t){let o=Y.join(e,i.name);i.isDirectory()?n.push(...await E(o)):(i.isFile()||i.isSymbolicLink())&&n.push(o)}return n}s(E,"collectFiles");import{readFile as K}from"node:fs/promises";var v=256*1024;async function L(e){let n=await K(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(L,"readTextFile");var H=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rs",".c",".cc",".hh",".hxx",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),X=new Set([".json",".jsonc",".yaml",".yml",".toml"]),R=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"]),A=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 T(e){return H.has(h.extname(e).toLowerCase())}s(T,"isSupportedOutlinePath");var w={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},G={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Pe(e){return y([e],G)}s(Pe,"formatAstOutline");var W=class{constructor(n=Number.POSITIVE_INFINITY){this.maxDepth=n}static{s(this,"AstOutlineManager")}fallbackScopeManager=new k;async readFileOutline(n,t){let i=P(n,t),o=h.relative(t,i)||i;if(!T(i))throw new Error(`AST outline is not supported for ${o}.`);let r=await L(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(!T(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(!T(i)){let r=await L(i);return y([J(i,o,r.lines)],w)}try{return y([await this.readFileOutline(i,t)],w)}catch(r){let c=r instanceof Error?r.message:String(r);return y([M(o,c)],w)}}async formatSymbol(n,t){let o=(await E(t)).filter(r=>T(r)).sort();for(let r of o){let c;try{c=await L(r)}catch{continue}let a;try{a=await I(r,t,c.lines)}catch{continue}if(!a)continue;let u=te(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 y([l],w)}return y([M("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],w)}async createSourceViewBlock(n,t,i,o,r,c,a,u,d,l=this.maxDepth){let f=ie(n,c,a,l),m=await Q(this.fallbackScopeManager,t,o,r),g=ee(m),_=f.map(S=>{let p=S.sourceLine,x=p===void 0?void 0:r[p-1]??"",O=(p===void 0?void 0:g.get(p))?.map($=>` <!-- ${$} -->`).join("")??"";return N({content:S.content,...!(p===void 0||x===void 0)&&{sourceLine:{source:t,lineNumber:p,content:x}},...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:_}}};function J(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,o)=>N({content:i,sourceLine:{source:e,lineNumber:o+1,content:i}}))}}s(J,"formatUnsupportedSourceBlock");function M(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}s(M,"failedSourceViewBlock");function Q(e,n,t,i){return e.getDocumentScopes(n,t,i)}s(Q,"getOutlineScopes");function ee(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(ee,"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 te(e,n){let t,i=s(o=>{if(!t){if(R.has(o.type)&&ne(o)===n){t=re(o);return}for(let r of o.namedChildren)i(r)}},"visit");return i(e),t}s(te,"findSymbol");function ne(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?B(t):void 0}}s(ne,"getNodeName");function B(e){if(C.has(e.type))return e.text;for(let n of e.namedChildren){let t=B(n);if(t)return t}}s(B,"findNestedName");function re(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}s(re,"unwrapDeclaration");function ie(e,n,t,i){let o=[];X.has(t)?V(e,t,o,i):D(e,t,o,!1,i);let r=oe(n,e.startIndex),c=se(n,e.endIndex),a=o.filter(l=>l.start>=r&&l.end<=c).sort((l,f)=>f.start-l.start),u=ae(n,r,c);for(let l of a){let f=l.start-r,m=l.end-r,g=ce(l);u.splice(f,m-f,...g)}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(ie,"renderNodeLines");function oe(e,n){return e.lastIndexOf(`
|
|
8
|
-
`,Math.max(0,n-1))+1}s(oe,"lineStartAt");function se(e,n){let t=e.indexOf(`
|
|
9
|
-
`,n);return t===-1?e.length:t}s(se,"lineEndAt");function ae(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(ae,"mapSourceRange");function ce(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(ce,"mapReplacement");function j(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(j,"collapseDeepNode");function V(e,n,t,i,o=0){if(!j(e,t,o,i))for(let r of e.namedChildren){if(le(r,n)){ue(r)||t.push({start:r.startIndex,end:r.endIndex,text:"\u2026",lineSourceLines:[r.startPosition.row+1]});continue}V(r,n,t,i,o+1)}}s(V,"collectDataReplacements");function le(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(le,"isDataScalar");function ue(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(ue,"isDataKey");function D(e,n,t,i,o,r=0){if(j(e,t,r,o))return;let c=Number.isFinite(o)&&e.type==="expression_statement";if(i&&!de(e)&&!c){t.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]});return}if(A.has(e.type)){let a=pe(e);if(a){let u=fe(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&&!A.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)D(a,n,t,q.has(e.type),o,r+1)}s(D,"collectReplacements");function de(e){return R.has(e.type)||Z.has(e.type)||e.type==="comment"||e.type.startsWith("preproc")}s(de,"isTopLevelInterfaceNode");function pe(e){let n=e.childForFieldName("body");return n||e.namedChildren.find(t=>t.type==="block"||t.type==="compound_statement"||t.type==="statement_block")}s(pe,"findBody");function fe(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()!=="",g=l.trim()!=="";if(!f&&!m&&!g)return{text:e.text,lineSourceLines:o.map((p,x)=>t+x)};let _=[],S=[];if(_.push(m?r.slice(0,a+1)+F(d):r),S.push(t),!m&&f){let p=o.slice(1,-1).find(x=>x.trim()!=="")?.match(/^\s*/u)?.[0]??"";_.push(`${p}\u2026`),S.push(void 0)}return _.push(g?F(l)+c.slice(u):c),S.push(i),{text:_.join(`
|
|
14
|
-
`),lineSourceLines:S}}s(fe,"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{W as AstOutlineManager,Pe as formatAstOutline,T as isSupportedOutlinePath};
|
package/dist/chunk-VCCMVQXU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as n}from"typebox/value";var r=e.Function([],e.Unknown()),i=e.Object({tool:e.String({pattern:"\\S"}),fallback:e.Optional(e.Boolean()),renderCall:e.Optional(r),renderResult:e.Optional(r),renderShell:e.Optional(e.Union([e.Literal("default"),e.Literal("self")]))});function d(o){return n.Check(i,o)?o.renderCall!==void 0||o.renderResult!==void 0:!1}t(d,"isTextEditorToolRendererRegistration");export{d as a};
|