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,127 @@
|
|
|
1
|
+
import type { SKRSContext2D } from "@napi-rs/canvas";
|
|
2
|
+
import type { IBufferCell } from "@xterm/headless";
|
|
3
|
+
|
|
4
|
+
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
5
|
+
|
|
6
|
+
const CELL_WIDTH = 9;
|
|
7
|
+
const CELL_HEIGHT = 18;
|
|
8
|
+
const FONT_SIZE = 14;
|
|
9
|
+
const PADDING = 12;
|
|
10
|
+
const DEFAULT_FOREGROUND = "#d8dee9";
|
|
11
|
+
const DEFAULT_BACKGROUND = "#111418";
|
|
12
|
+
const ANSI_16 = [
|
|
13
|
+
"#000000",
|
|
14
|
+
"#cd0000",
|
|
15
|
+
"#00cd00",
|
|
16
|
+
"#cdcd00",
|
|
17
|
+
"#0000ee",
|
|
18
|
+
"#cd00cd",
|
|
19
|
+
"#00cdcd",
|
|
20
|
+
"#e5e5e5",
|
|
21
|
+
"#7f7f7f",
|
|
22
|
+
"#ff0000",
|
|
23
|
+
"#00ff00",
|
|
24
|
+
"#ffff00",
|
|
25
|
+
"#5c5cff",
|
|
26
|
+
"#ff00ff",
|
|
27
|
+
"#00ffff",
|
|
28
|
+
"#ffffff",
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
/** Render the current ANSI-aware virtual terminal screen to a PNG for multimodal agent reads. */
|
|
32
|
+
export async function renderTerminalScreen(
|
|
33
|
+
manager: TerminalSessionManager,
|
|
34
|
+
source: string,
|
|
35
|
+
rows?: { readonly start: number; readonly count: number },
|
|
36
|
+
): Promise<string> {
|
|
37
|
+
const session = manager.get(source);
|
|
38
|
+
if (session === undefined) throw new Error(`Unknown terminal session ${source}`);
|
|
39
|
+
await session.screenReady;
|
|
40
|
+
const { createCanvas } = await import("@napi-rs/canvas");
|
|
41
|
+
const startRow = Math.max(0, Math.min(session.rows - 1, rows?.start ?? 0));
|
|
42
|
+
const rowCount = Math.max(1, Math.min(session.rows - startRow, rows?.count ?? session.rows));
|
|
43
|
+
const canvas = createCanvas(
|
|
44
|
+
session.cols * CELL_WIDTH + PADDING * 2,
|
|
45
|
+
rowCount * CELL_HEIGHT + PADDING * 2,
|
|
46
|
+
);
|
|
47
|
+
const context = canvas.getContext("2d");
|
|
48
|
+
context.fillStyle = DEFAULT_BACKGROUND;
|
|
49
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
50
|
+
context.textBaseline = "top";
|
|
51
|
+
|
|
52
|
+
const buffer = session.screen.buffer.active;
|
|
53
|
+
const firstRow = Math.max(0, buffer.baseY);
|
|
54
|
+
for (let row = 0; row < rowCount; row += 1) {
|
|
55
|
+
const line = buffer.getLine(firstRow + startRow + row);
|
|
56
|
+
if (line === undefined) continue;
|
|
57
|
+
for (let column = 0; column < session.cols; column += 1) {
|
|
58
|
+
const cell = line.getCell(column);
|
|
59
|
+
if (cell === undefined || cell.getWidth() === 0) continue;
|
|
60
|
+
drawCell(context, cell, column, row);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
session.status === "running" &&
|
|
66
|
+
buffer.cursorY >= startRow &&
|
|
67
|
+
buffer.cursorY < startRow + rowCount
|
|
68
|
+
) {
|
|
69
|
+
context.fillStyle = "rgba(216, 222, 233, 0.75)";
|
|
70
|
+
context.fillRect(
|
|
71
|
+
PADDING + buffer.cursorX * CELL_WIDTH,
|
|
72
|
+
PADDING + (buffer.cursorY - startRow) * CELL_HEIGHT + CELL_HEIGHT - 2,
|
|
73
|
+
CELL_WIDTH,
|
|
74
|
+
2,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return canvas.toBuffer("image/png").toString("base64");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function drawCell(context: SKRSContext2D, cell: IBufferCell, column: number, row: number): void {
|
|
81
|
+
let foreground = cellColor(cell, "foreground");
|
|
82
|
+
let background = cellColor(cell, "background");
|
|
83
|
+
if (cell.isInverse()) [foreground, background] = [background, foreground];
|
|
84
|
+
const x = PADDING + column * CELL_WIDTH;
|
|
85
|
+
const y = PADDING + row * CELL_HEIGHT;
|
|
86
|
+
if (background !== DEFAULT_BACKGROUND) {
|
|
87
|
+
context.fillStyle = background;
|
|
88
|
+
context.fillRect(x, y, CELL_WIDTH * Math.max(1, cell.getWidth()), CELL_HEIGHT);
|
|
89
|
+
}
|
|
90
|
+
const chars = cell.getChars();
|
|
91
|
+
if (chars.length === 0) return;
|
|
92
|
+
context.font = `${cell.isBold() ? "bold " : ""}${FONT_SIZE}px monospace`;
|
|
93
|
+
context.fillStyle = foreground;
|
|
94
|
+
context.fillText(chars, x, y);
|
|
95
|
+
if (cell.isUnderline()) {
|
|
96
|
+
context.fillRect(x, y + CELL_HEIGHT - 2, CELL_WIDTH * Math.max(1, cell.getWidth()), 1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function cellColor(cell: IBufferCell, kind: "foreground" | "background"): string {
|
|
101
|
+
const foreground = kind === "foreground";
|
|
102
|
+
const isDefault = foreground ? cell.isFgDefault() : cell.isBgDefault();
|
|
103
|
+
if (isDefault) return foreground ? DEFAULT_FOREGROUND : DEFAULT_BACKGROUND;
|
|
104
|
+
const isRgb = foreground ? cell.isFgRGB() : cell.isBgRGB();
|
|
105
|
+
const value = foreground ? cell.getFgColor() : cell.getBgColor();
|
|
106
|
+
if (isRgb) return `#${value.toString(16).padStart(6, "0")}`;
|
|
107
|
+
return ansiColor(value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function ansiColor(index: number): string {
|
|
111
|
+
const basic = ANSI_16[index];
|
|
112
|
+
if (basic !== undefined) return basic;
|
|
113
|
+
if (index >= 232) {
|
|
114
|
+
const level = 8 + (index - 232) * 10;
|
|
115
|
+
return rgb(level, level, level);
|
|
116
|
+
}
|
|
117
|
+
const cube = Math.max(0, index - 16);
|
|
118
|
+
const red = Math.floor(cube / 36);
|
|
119
|
+
const green = Math.floor((cube % 36) / 6);
|
|
120
|
+
const blue = cube % 6;
|
|
121
|
+
const channel = (value: number): number => (value === 0 ? 0 : 55 + value * 40);
|
|
122
|
+
return rgb(channel(red), channel(green), channel(blue));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function rgb(red: number, green: number, blue: number): string {
|
|
126
|
+
return `#${[red, green, blue].map((value) => value.toString(16).padStart(2, "0")).join("")}`;
|
|
127
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { connectSearchPlugin } from "pi-agent-search/api/connect-plugin";
|
|
2
|
+
import {
|
|
3
|
+
SEARCH_API_VERSION,
|
|
4
|
+
SEARCH_PROTOCOL,
|
|
5
|
+
type SearchPlugin,
|
|
6
|
+
} from "pi-agent-search/api/plugin-protocol";
|
|
7
|
+
import type { SearchRequest, SearchSelectionMatch } from "pi-agent-search/api/search";
|
|
8
|
+
|
|
9
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
10
|
+
|
|
11
|
+
import { renderTerminalAction } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
12
|
+
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
13
|
+
import type { TerminalSessionSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
14
|
+
|
|
15
|
+
interface TerminalSearchPayload {
|
|
16
|
+
readonly snapshot: TerminalSessionSnapshot;
|
|
17
|
+
readonly query: string;
|
|
18
|
+
readonly matches: readonly SearchSelectionMatch[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Register retained terminal output as a searchable resource. */
|
|
22
|
+
export async function registerTerminalSearch(
|
|
23
|
+
pi: ExtensionAPI,
|
|
24
|
+
manager: TerminalSessionManager,
|
|
25
|
+
): Promise<void> {
|
|
26
|
+
const plugin = {
|
|
27
|
+
protocol: SEARCH_PROTOCOL,
|
|
28
|
+
apiVersion: SEARCH_API_VERSION,
|
|
29
|
+
id: "terminal",
|
|
30
|
+
setup(api) {
|
|
31
|
+
api.addResolver({ resolver: terminalSearchResolver(manager), priority: 100 });
|
|
32
|
+
api.describe(
|
|
33
|
+
"path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.",
|
|
34
|
+
);
|
|
35
|
+
api.addPromptGuideline(
|
|
36
|
+
"Use search with path shell:<session> to find text in retained terminal output. Read the same shell source with the returned line number when more context is needed.",
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
} satisfies SearchPlugin;
|
|
40
|
+
await connectSearchPlugin(pi, plugin);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function terminalSearchResolver(manager: TerminalSessionManager) {
|
|
44
|
+
return {
|
|
45
|
+
id: "terminal",
|
|
46
|
+
async tryResolve(request: SearchRequest) {
|
|
47
|
+
if (request.path === undefined || !request.path.startsWith("shell:")) {
|
|
48
|
+
return { kind: "not-handled" as const };
|
|
49
|
+
}
|
|
50
|
+
const session = manager.get(request.path);
|
|
51
|
+
if (session === undefined) {
|
|
52
|
+
return {
|
|
53
|
+
kind: "failed" as const,
|
|
54
|
+
error: new Error(`Unknown terminal session ${request.path}`),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const snapshot = manager.snapshot(session);
|
|
58
|
+
const matches = findTerminalMatches(snapshot, request);
|
|
59
|
+
return {
|
|
60
|
+
kind: "resolved" as const,
|
|
61
|
+
payload: {
|
|
62
|
+
snapshot,
|
|
63
|
+
query: request.query,
|
|
64
|
+
matches,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
format(payload: unknown) {
|
|
69
|
+
const result = parsePayload(payload);
|
|
70
|
+
const lines = result.matches.map(
|
|
71
|
+
(match) => `${result.snapshot.source}:${match.lineNumber}: ${match.lineText}`,
|
|
72
|
+
);
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: "text" as const,
|
|
77
|
+
text:
|
|
78
|
+
lines.length === 0
|
|
79
|
+
? `No matches in ${result.snapshot.source}`
|
|
80
|
+
: `${lines.join("\n")}\n\n${lines.length} match${lines.length === 1 ? "" : "es"} in ${result.snapshot.source}`,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
details: { source: result.snapshot.source, payload: result },
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
renderResult(
|
|
87
|
+
result: { details: unknown },
|
|
88
|
+
_options: unknown,
|
|
89
|
+
theme: Parameters<typeof renderTerminalAction>[4],
|
|
90
|
+
) {
|
|
91
|
+
const details = result.details;
|
|
92
|
+
const payload = isRecord(details) ? parsePayload(details.payload) : parsePayload(undefined);
|
|
93
|
+
return renderTerminalAction(
|
|
94
|
+
payload.snapshot,
|
|
95
|
+
"search",
|
|
96
|
+
JSON.stringify(payload.query),
|
|
97
|
+
payload.matches.slice(-6).map((match) => `${match.lineNumber}: ${match.lineText}`),
|
|
98
|
+
theme,
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function findTerminalMatches(
|
|
105
|
+
snapshot: TerminalSessionSnapshot,
|
|
106
|
+
request: SearchRequest,
|
|
107
|
+
): SearchSelectionMatch[] {
|
|
108
|
+
const query = request.caseSensitive === true ? request.query : request.query.toLocaleLowerCase();
|
|
109
|
+
if (query.length === 0) return [];
|
|
110
|
+
const matches: SearchSelectionMatch[] = [];
|
|
111
|
+
const maximum = request.limit ?? 100;
|
|
112
|
+
for (const [index, lineText] of snapshot.output.replaceAll("\r", "").split("\n").entries()) {
|
|
113
|
+
const haystack = request.caseSensitive === true ? lineText : lineText.toLocaleLowerCase();
|
|
114
|
+
let column = 0;
|
|
115
|
+
while (matches.length < maximum) {
|
|
116
|
+
const startColumn = haystack.indexOf(query, column);
|
|
117
|
+
if (startColumn < 0) break;
|
|
118
|
+
const endColumn = startColumn + query.length;
|
|
119
|
+
const wholeWord =
|
|
120
|
+
request.wholeWord !== true || isWordBoundary(haystack, startColumn, endColumn);
|
|
121
|
+
if (wholeWord) {
|
|
122
|
+
matches.push({
|
|
123
|
+
source: snapshot.source,
|
|
124
|
+
lineNumber: index + 1,
|
|
125
|
+
startColumn,
|
|
126
|
+
endColumn,
|
|
127
|
+
matchedText: lineText.slice(startColumn, endColumn),
|
|
128
|
+
lineText,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
column = Math.max(endColumn, startColumn + 1);
|
|
132
|
+
}
|
|
133
|
+
if (matches.length >= maximum) break;
|
|
134
|
+
}
|
|
135
|
+
return matches;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function isWordBoundary(text: string, start: number, end: number): boolean {
|
|
139
|
+
return !/[\p{L}\p{N}_]/u.test(text[start - 1] ?? "") && !/[\p{L}\p{N}_]/u.test(text[end] ?? "");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function parsePayload(value: unknown): TerminalSearchPayload {
|
|
143
|
+
if (!isTerminalSearchPayload(value)) throw new TypeError("Invalid terminal search result");
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function isTerminalSearchPayload(value: unknown): value is TerminalSearchPayload {
|
|
148
|
+
return (
|
|
149
|
+
isRecord(value) &&
|
|
150
|
+
typeof value.query === "string" &&
|
|
151
|
+
Array.isArray(value.matches) &&
|
|
152
|
+
isRecord(value.snapshot) &&
|
|
153
|
+
typeof value.snapshot.source === "string"
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
158
|
+
return typeof value === "object" && value !== null;
|
|
159
|
+
}
|