pi-agent-ide 0.1.0 → 0.2.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 +27 -0
- package/README.md +38 -10
- package/dist/chunk-266RH77Z.js +1 -0
- package/dist/chunk-2SKAED2I.js +2 -0
- package/dist/chunk-2ZMYT6ZC.js +1 -0
- package/dist/chunk-34ZQTTU2.js +2 -0
- package/dist/chunk-3H2EU7VQ.js +0 -0
- package/dist/chunk-3YK4XMWB.js +0 -0
- package/dist/chunk-476MR2QB.js +1 -0
- package/dist/chunk-4KQOODGE.js +13 -0
- package/dist/chunk-4SQQKEVD.js +16 -0
- package/dist/chunk-52BM6J6I.js +6 -0
- package/dist/chunk-5A25RATC.js +3 -0
- package/dist/chunk-5BWUVAR4.js +1 -0
- package/dist/chunk-6DN7NO7L.js +1 -0
- package/dist/chunk-6SMFVLTY.js +1 -0
- package/dist/chunk-7NDBZ4WX.js +1 -0
- package/dist/chunk-AP7Z3VWC.js +1 -0
- package/dist/chunk-BYWAG6X3.js +6 -0
- package/dist/chunk-DEP55R35.js +1 -0
- package/dist/chunk-E2RESHYR.js +1 -0
- package/dist/chunk-E4SECPF4.js +1 -0
- package/dist/chunk-EEH4WYI7.js +1 -0
- package/dist/chunk-EI7MMDWY.js +1 -0
- package/dist/chunk-ERVMDQGX.js +1 -0
- package/dist/chunk-EW2KVKCN.js +2 -0
- package/dist/chunk-F6SESI3P.js +4 -0
- package/dist/chunk-GTK5AREE.js +2 -0
- package/dist/chunk-HOBTFFQR.js +1 -0
- package/dist/chunk-IMVCVPMP.js +3 -0
- package/dist/chunk-IOCABSRL.js +1 -0
- package/dist/chunk-JASLOB2X.js +1 -0
- package/dist/chunk-JMVDFOTQ.js +1 -0
- package/dist/chunk-K4ZMRDEI.js +0 -0
- package/dist/chunk-KINKBPPX.js +1 -0
- package/dist/chunk-KNMWCDDK.js +7 -0
- package/dist/chunk-KP37XTDI.js +1 -0
- package/dist/chunk-KYVOMBO5.js +1 -0
- package/dist/chunk-KZBAJFCV.js +1 -0
- package/dist/chunk-LFV6G5Z3.js +1 -0
- package/dist/chunk-MB6VVVAF.js +2 -0
- package/dist/chunk-MBUXFKIW.js +3 -0
- package/dist/chunk-MTTKFJV6.js +1 -0
- package/dist/chunk-NI2NK4JU.js +1 -0
- package/dist/chunk-NNCZYO4Q.js +0 -0
- package/dist/chunk-OBWZ5RYN.js +1 -0
- package/dist/chunk-OIL6BB2S.js +33 -0
- package/dist/chunk-ORAPGW7W.js +1 -0
- package/dist/chunk-OVUYPHDE.js +1 -0
- package/dist/chunk-PETQCA7G.js +1 -0
- package/dist/chunk-PODWLGNO.js +6 -0
- package/dist/chunk-QNZVPFSP.js +3 -0
- package/dist/chunk-QW5O42QJ.js +2 -0
- package/dist/chunk-SJYDLHEF.js +108 -0
- package/dist/chunk-SSZB66C3.js +3 -0
- package/dist/chunk-STUZZM5B.js +1 -0
- package/dist/chunk-T2RPMEM2.js +1 -0
- package/dist/chunk-TG6H6EOI.js +1 -0
- package/dist/chunk-TNWYEXFG.js +1 -0
- package/dist/chunk-U4D6FT66.js +1 -0
- package/dist/chunk-VCCMVQXU.js +1 -0
- package/dist/chunk-VFBLX4TG.js +1 -0
- package/dist/chunk-VSP2QQPQ.js +2 -0
- package/dist/chunk-VUNCBASK.js +10 -0
- package/dist/chunk-VWVLBOMU.js +8 -0
- package/dist/chunk-W3XYKJ5H.js +1 -0
- package/dist/chunk-XGUAL3CA.js +1 -0
- package/dist/chunk-XNXQYPVT.js +10 -0
- package/dist/chunk-YHUTTZC6.js +2 -0
- package/dist/chunk-YPHXLAQF.js +1 -0
- package/dist/chunk-YQTLJ5ZV.js +58 -0
- package/dist/chunk-ZC65Z3CK.js +1 -0
- package/dist/entry-0.js +1 -0
- package/dist/entry-1.js +1 -0
- package/dist/entry-10.js +1 -0
- package/dist/entry-11.js +1 -0
- package/dist/entry-12.js +1 -0
- package/dist/entry-13.js +1 -0
- package/dist/entry-14.js +1 -0
- package/dist/entry-16.js +1 -0
- package/dist/entry-17.js +1 -0
- package/dist/entry-18.js +1 -0
- package/dist/entry-19.js +1 -0
- package/dist/entry-2.js +1 -0
- package/dist/entry-20.js +1 -0
- package/dist/entry-21.js +1 -0
- package/dist/entry-22.js +1 -0
- package/dist/entry-23.js +1 -0
- package/dist/entry-24.js +1 -0
- package/dist/entry-25.js +1 -0
- package/dist/entry-26.js +1 -0
- package/dist/entry-27.js +1 -0
- package/dist/entry-28.js +1 -0
- package/dist/entry-29.js +1 -0
- package/dist/entry-3.js +1 -0
- package/dist/entry-30.js +1 -0
- package/dist/entry-31.js +1 -0
- package/dist/entry-32.js +1 -0
- package/dist/entry-33.js +1 -0
- package/dist/entry-34.js +1 -0
- package/dist/entry-35.js +1 -0
- package/dist/entry-36.js +1 -0
- package/dist/entry-37.js +1 -0
- package/dist/entry-38.js +1 -0
- package/dist/entry-39.js +1 -0
- package/dist/entry-4.js +1 -0
- package/dist/entry-40.js +1 -0
- package/dist/entry-41.js +1 -0
- package/dist/entry-42.js +1 -0
- package/dist/entry-43.js +1 -0
- package/dist/entry-44.js +1 -0
- package/dist/entry-45.js +1 -0
- package/dist/entry-46.js +1 -0
- package/dist/entry-47.js +1 -0
- package/dist/entry-48.js +1 -0
- package/dist/entry-49.js +1 -0
- package/dist/entry-5.js +1 -0
- package/dist/entry-50.js +1 -0
- package/dist/entry-51.js +1 -0
- package/dist/entry-52.js +1 -0
- package/dist/entry-53.js +0 -0
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -0
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +1 -0
- package/dist/entry-58.js +1 -0
- package/dist/entry-59.js +1 -0
- package/dist/entry-6.js +1 -0
- package/dist/entry-60.js +1 -0
- package/dist/entry-61.js +1 -0
- package/dist/entry-62.js +0 -0
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -0
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +1 -0
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +1 -0
- package/dist/entry-69.js +1 -0
- package/dist/entry-7.js +1 -0
- package/dist/entry-70.js +1 -0
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -0
- package/dist/entry-76.js +1 -0
- package/dist/entry-77.js +1 -0
- package/dist/entry-78.js +1 -0
- package/dist/entry-79.js +1 -0
- package/dist/entry-8.js +1 -0
- package/dist/entry-9.js +1 -0
- package/dist/pi-agent-ide.js +13 -0
- package/docs/architecture.md +30 -14
- package/docs/configuration.md +180 -53
- package/docs/development.md +116 -4
- package/docs/extensions.md +196 -154
- package/docs/generated/tool-catalog/c.md +9 -0
- package/docs/generated/tool-catalog/cmake.md +9 -0
- package/docs/generated/tool-catalog/cpp.md +9 -0
- package/docs/generated/tool-catalog/csharp.md +9 -0
- package/docs/generated/tool-catalog/css.md +11 -0
- package/docs/generated/tool-catalog/dockerfile.md +9 -0
- package/docs/generated/tool-catalog/go.md +10 -0
- package/docs/generated/tool-catalog/html.md +10 -0
- package/docs/generated/tool-catalog/index.md +30 -0
- package/docs/generated/tool-catalog/java.md +9 -0
- package/docs/generated/tool-catalog/javascript.md +12 -0
- package/docs/generated/tool-catalog/json.md +11 -0
- package/docs/generated/tool-catalog/kotlin.md +9 -0
- package/docs/generated/tool-catalog/lua.md +9 -0
- package/docs/generated/tool-catalog/markdown.md +10 -0
- package/docs/generated/tool-catalog/php.md +9 -0
- package/docs/generated/tool-catalog/python.md +10 -0
- package/docs/generated/tool-catalog/ruby.md +9 -0
- package/docs/generated/tool-catalog/rust.md +9 -0
- package/docs/generated/tool-catalog/shell.md +9 -0
- package/docs/generated/tool-catalog/sql.md +9 -0
- package/docs/generated/tool-catalog/swift.md +9 -0
- package/docs/generated/tool-catalog/terraform.md +9 -0
- package/docs/generated/tool-catalog/toml.md +10 -0
- package/docs/generated/tool-catalog/typescript.md +12 -0
- package/docs/generated/tool-catalog/xml.md +9 -0
- package/docs/generated/tool-catalog/yaml.md +10 -0
- package/docs/tools.md +88 -6
- package/node_modules/pi-agent-doctor/package.json +29 -0
- package/node_modules/pi-agent-doctor/runtime/entry-16.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-17.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-19.js +1 -0
- package/node_modules/pi-agent-doctor/src/catalog.ts +55 -0
- package/node_modules/pi-agent-doctor/src/connect-plugin.ts +53 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +80 -0
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +147 -0
- package/node_modules/pi-agent-filesystem/index.ts +43 -44
- package/node_modules/pi-agent-filesystem/package.json +11 -11
- package/node_modules/pi-agent-filesystem/runtime/entry-20.js +2 -0
- package/node_modules/pi-agent-filesystem/src/resolver.ts +112 -135
- package/node_modules/pi-agent-filesystem-image/index.ts +5 -6
- package/node_modules/pi-agent-filesystem-image/package.json +8 -8
- package/node_modules/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
- package/node_modules/pi-agent-filesystem-pdf/index.ts +5 -6
- package/node_modules/pi-agent-filesystem-pdf/package.json +6 -6
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
- package/node_modules/pi-agent-filesystem-text/index.ts +11 -12
- package/node_modules/pi-agent-filesystem-text/package.json +8 -8
- package/node_modules/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
- package/node_modules/pi-agent-ide-ast/index.ts +1 -1
- package/node_modules/pi-agent-ide-ast/package.json +15 -13
- package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +1 -0
- package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +11 -16
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +292 -322
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +591 -656
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +15 -19
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +130 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +75 -64
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +51 -54
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +168 -185
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +36 -36
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +118 -129
- package/node_modules/pi-agent-ide-changes/index.ts +57 -51
- package/node_modules/pi-agent-ide-changes/package.json +14 -12
- package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +1 -0
- package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +2 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +74 -78
- package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +230 -245
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +189 -192
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +75 -79
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +259 -276
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +164 -190
- package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +59 -0
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +10 -9
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +49 -62
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +98 -93
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +131 -126
- package/node_modules/pi-agent-ide-formatter/index.ts +22 -23
- package/node_modules/pi-agent-ide-formatter/package.json +6 -3
- package/node_modules/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
- package/node_modules/pi-agent-ide-formatter/src/catalog.ts +281 -0
- package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +156 -0
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +38 -40
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +94 -27
- package/node_modules/pi-agent-ide-languages/index.ts +24 -0
- package/{src/extensions/pi-agent-search/plugins/pi-agent-search-semantic → node_modules/pi-agent-ide-languages}/package.json +6 -7
- package/node_modules/pi-agent-ide-languages/runtime/entry-29.js +2 -0
- package/node_modules/pi-agent-ide-languages/src/languages.ts +84 -0
- package/node_modules/pi-agent-ide-lint/index.ts +66 -225
- package/node_modules/pi-agent-ide-lint/package.json +10 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-30.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/catalog.ts +295 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +98 -144
- package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +182 -0
- package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +155 -0
- package/node_modules/pi-agent-ide-lint/src/registry.ts +94 -27
- package/node_modules/pi-agent-ide-lsp/index.ts +111 -231
- package/node_modules/pi-agent-ide-lsp/package.json +13 -11
- package/node_modules/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/catalog.ts +248 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +109 -116
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +163 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +439 -396
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +421 -458
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +143 -159
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +25 -20
- package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +31 -33
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +49 -57
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +350 -415
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +58 -63
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +196 -77
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +36 -36
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +118 -127
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +108 -107
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +76 -57
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +36 -32
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-image/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-image/src/image-converter.ts +210 -249
- package/node_modules/pi-agent-image/src/index.ts +4 -4
- package/node_modules/pi-agent-invariant/package.json +12 -0
- package/node_modules/pi-agent-invariant/runtime/entry-33.js +1 -0
- package/node_modules/pi-agent-invariant/src/index.ts +8 -0
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-pdf/runtime/entry-34.js +1 -0
- package/node_modules/pi-agent-pdf/src/index.ts +1 -5
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +133 -155
- package/node_modules/pi-agent-read/index.ts +1 -1
- package/node_modules/pi-agent-read/package.json +15 -13
- package/node_modules/pi-agent-read/runtime/entry-35.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-36.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-37.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-38.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-39.js +2 -0
- package/node_modules/pi-agent-read/src/api/connect-plugin.ts +38 -51
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +27 -33
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -4
- package/node_modules/pi-agent-read/src/api/tools/read.ts +237 -134
- package/node_modules/pi-agent-read/src/core/extension.ts +51 -33
- package/node_modules/pi-agent-read/src/core/read-core.ts +353 -330
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +169 -156
- package/node_modules/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +381 -313
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +169 -154
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +165 -187
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +29 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +1117 -680
- package/node_modules/pi-agent-resource/package.json +5 -2
- package/node_modules/pi-agent-resource/runtime/entry-40.js +1 -0
- package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +50 -62
- package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +28 -34
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +16 -20
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +53 -58
- package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +116 -135
- package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +38 -39
- package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +118 -108
- package/node_modules/pi-agent-resource/src/content.ts +5 -9
- package/node_modules/pi-agent-resource/src/index.ts +51 -40
- package/node_modules/pi-agent-resource/src/resolver.ts +11 -13
- package/node_modules/pi-agent-resource/src/resource.ts +17 -24
- package/node_modules/pi-agent-resource/src/validation.ts +106 -92
- package/node_modules/pi-agent-search/package.json +11 -10
- package/node_modules/pi-agent-search/runtime/entry-41.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-42.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-43.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-44.js +2 -0
- package/node_modules/pi-agent-search/src/api/connect-plugin.ts +37 -47
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +26 -30
- package/node_modules/pi-agent-search/src/api/search.ts +65 -67
- package/node_modules/pi-agent-search/src/core/extension.ts +184 -92
- package/node_modules/pi-agent-search/src/core/search-config.ts +98 -0
- package/node_modules/pi-agent-search/src/core/search-core.ts +332 -357
- package/node_modules/pi-agent-search/src/core/search-timeout.ts +54 -0
- package/node_modules/pi-agent-search-text/index.ts +90 -38
- package/node_modules/pi-agent-search-text/package.json +13 -12
- package/node_modules/pi-agent-search-text/runtime/entry-45.js +2 -0
- package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
- package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +48 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +90 -86
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +56 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +158 -161
- package/node_modules/pi-agent-search-text/src/ripgrep.ts +16 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +215 -249
- package/node_modules/pi-agent-search-text/src/search-query.ts +262 -102
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +68 -0
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +275 -345
- package/node_modules/pi-agent-search-text/src/search-result.ts +152 -157
- package/node_modules/pi-agent-search-text/src/search-session.ts +438 -278
- package/node_modules/pi-agent-text/package.json +6 -3
- package/node_modules/pi-agent-text/runtime/entry-47.js +1 -0
- package/node_modules/pi-agent-text/src/index.ts +53 -22
- package/node_modules/pi-agent-text/src/presented-text.ts +15 -17
- package/node_modules/pi-agent-text/src/source-line.ts +33 -36
- package/node_modules/pi-agent-text/src/stored-text.ts +14 -0
- package/node_modules/pi-agent-text/src/text-anchor.ts +264 -117
- package/node_modules/pi-agent-text/src/text-converter.ts +71 -84
- package/node_modules/pi-agent-text/src/text-document.ts +120 -110
- package/node_modules/pi-agent-text/src/text-target.ts +105 -0
- package/node_modules/pi-agent-text-anchor-constant/index.ts +18 -20
- package/node_modules/pi-agent-text-anchor-constant/package.json +9 -6
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
- package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +35 -36
- package/node_modules/pi-agent-text-anchor-exact/index.ts +34 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +27 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
- package/node_modules/pi-agent-text-anchor-exact/src/config.ts +159 -0
- package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
- package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +40 -36
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +16 -12
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +105 -84
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +43 -42
- package/node_modules/pi-agent-text-editor/index.ts +7 -9
- package/node_modules/pi-agent-text-editor/package.json +26 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-54.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-56.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-57.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-58.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-59.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-60.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-61.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-62.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-63.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-64.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-65.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-66.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-67.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-68.js +2 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +18 -18
- package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +40 -50
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +10 -13
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +31 -36
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +25 -27
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +26 -31
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +18 -21
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +20 -19
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +154 -131
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +173 -144
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +93 -103
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -14
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +85 -99
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +10 -10
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +18 -22
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +49 -48
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +136 -127
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +279 -313
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +85 -95
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +233 -289
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +553 -582
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +86 -98
- package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +12 -11
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +369 -335
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +184 -214
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +476 -511
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +93 -105
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +31 -33
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +526 -372
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +111 -87
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +1899 -2027
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +26 -22
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +1043 -634
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +979 -1032
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +19 -23
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +270 -273
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +353 -403
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +9 -11
- package/node_modules/pi-agent-text-editor/src/tools/extension.ts +7 -8
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +289 -75
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +100 -106
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +73 -66
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +64 -42
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +116 -124
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +78 -58
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +26 -17
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +16 -19
- package/node_modules/pi-agent-text-editor-argument-order/package.json +5 -5
- package/node_modules/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +79 -91
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +297 -323
- package/node_modules/pi-agent-text-editor-overwrite/package.json +6 -5
- package/node_modules/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/index.ts +31 -12
- package/node_modules/pi-agent-text-editor-renderer/package.json +10 -7
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
- package/node_modules/pi-agent-text-editor-renderer/src/config.ts +73 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +347 -359
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +255 -216
- package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +297 -329
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +19 -25
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +160 -168
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +284 -180
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +550 -329
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +142 -118
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -4
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +744 -631
- package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +215 -157
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +335 -335
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +7 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +5 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +473 -350
- package/node_modules/pi-agent-tool-ui/package.json +15 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-74.js +1 -0
- package/node_modules/pi-agent-tool-ui/src/index.ts +318 -0
- package/node_modules/pi-agent-web/index.ts +35 -26
- package/node_modules/pi-agent-web/package.json +12 -10
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +180 -0
- package/node_modules/pi-agent-web/src/doctor-plugin.ts +41 -0
- package/node_modules/pi-agent-web/src/resolver.ts +228 -146
- package/node_modules/pi-agent-web-html/index.ts +5 -6
- package/node_modules/pi-agent-web-html/package.json +9 -6
- package/node_modules/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +72 -77
- package/node_modules/pi-agent-web-html/src/html-converter.ts +62 -75
- package/node_modules/pi-agent-web-image/index.ts +5 -6
- package/node_modules/pi-agent-web-image/package.json +6 -6
- package/node_modules/pi-agent-web-image/runtime/entry-77.js +2 -0
- package/node_modules/pi-agent-web-pdf/index.ts +5 -6
- package/node_modules/pi-agent-web-pdf/package.json +6 -6
- package/node_modules/pi-agent-web-pdf/runtime/entry-78.js +2 -0
- package/node_modules/pi-agent-web-text/index.ts +5 -6
- package/node_modules/pi-agent-web-text/package.json +6 -6
- package/node_modules/pi-agent-web-text/runtime/entry-79.js +2 -0
- package/package.json +101 -67
- package/src/api/code-view.ts +21 -17
- package/src/api/connect-doctor-plugin.ts +1 -0
- package/src/api/connect-plugin.ts +38 -48
- package/src/api/connect-tip-provider.ts +49 -0
- package/src/api/doctor.ts +1 -0
- package/src/api/plugin-protocol.ts +71 -40
- package/src/api/read.ts +6 -1
- package/src/api/resource.ts +3 -1
- package/src/api/search.ts +5 -1
- package/src/api/text-editor.ts +4 -1
- package/src/api/text.ts +3 -1
- package/src/api/tips.ts +77 -0
- package/src/api/tool-catalog.ts +1 -0
- package/src/api/tool-config/formatters.json +215 -0
- package/src/api/tool-config/linters.json +257 -0
- package/src/api/tool-config/lsp-servers.json +275 -0
- package/src/api/tool-config.ts +569 -0
- package/src/api/toolchain.ts +13 -18
- package/src/code-view/diagnostic-view.ts +150 -58
- package/src/code-view/reference.ts +64 -82
- package/src/code-view/source-view.ts +159 -180
- package/src/composite/builtin-extensions.ts +47 -37
- package/src/composite/extensions-config.ts +137 -0
- package/src/composite/selection.ts +109 -52
- package/src/core/diagnostic-store.ts +244 -0
- package/src/core/extension.ts +71 -35
- package/src/core/ide-core.ts +126 -98
- package/src/doctor/config-writer.ts +115 -0
- package/src/doctor/core.ts +221 -0
- package/src/doctor/discovery.ts +223 -0
- package/src/doctor/extension.ts +119 -0
- package/src/doctor/index.ts +1 -0
- package/src/doctor/inventory.ts +109 -0
- package/src/doctor/run.ts +177 -0
- package/src/doctor/tip-provider.ts +92 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +43 -44
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +11 -11
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +11 -12
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +112 -135
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +35 -26
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +12 -10
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +9 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +72 -77
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +62 -75
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-77.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-79.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +180 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +41 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +228 -146
- package/src/extensions/pi-agent-read/index.ts +1 -1
- package/src/extensions/pi-agent-read/package.json +15 -13
- package/src/extensions/pi-agent-read/runtime/entry-35.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-36.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-37.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-38.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-39.js +2 -0
- package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +38 -51
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +27 -33
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -4
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +237 -134
- package/src/extensions/pi-agent-read/src/core/extension.ts +51 -33
- package/src/extensions/pi-agent-read/src/core/read-core.ts +353 -330
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +169 -156
- package/src/extensions/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +381 -313
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +169 -154
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +165 -187
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +29 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +1117 -680
- package/src/extensions/pi-agent-search/package.json +11 -10
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +90 -38
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +13 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +48 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +90 -86
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +56 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +158 -161
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +16 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +215 -249
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +262 -102
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +68 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +275 -345
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +152 -157
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +438 -278
- package/src/extensions/pi-agent-search/runtime/entry-41.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-42.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-43.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-44.js +2 -0
- package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +37 -47
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +26 -30
- package/src/extensions/pi-agent-search/src/api/search.ts +65 -67
- package/src/extensions/pi-agent-search/src/core/extension.ts +184 -92
- package/src/extensions/pi-agent-search/src/core/search-config.ts +98 -0
- package/src/extensions/pi-agent-search/src/core/search-core.ts +332 -357
- package/src/extensions/pi-agent-search/src/core/search-timeout.ts +54 -0
- package/src/extensions/pi-agent-text-editor/index.ts +7 -9
- package/src/extensions/pi-agent-text-editor/package.json +26 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +18 -20
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +9 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +35 -36
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +34 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +27 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +159 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +40 -36
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +16 -12
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +105 -84
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +43 -42
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +16 -19
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +79 -91
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +297 -323
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +31 -12
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +10 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +73 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +347 -359
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +255 -216
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +297 -329
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +19 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +160 -168
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +284 -180
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +550 -329
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +142 -118
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +744 -631
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +215 -157
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +335 -335
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +7 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +18 -18
- package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +40 -50
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +10 -13
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +31 -36
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +25 -27
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +26 -31
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +18 -21
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +20 -19
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +154 -131
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +173 -144
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +93 -103
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -14
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +85 -99
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +10 -10
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +18 -22
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +49 -48
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +136 -127
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +279 -313
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +85 -95
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +233 -289
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +553 -582
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +86 -98
- package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +12 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +369 -335
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +184 -214
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +476 -511
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +93 -105
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +31 -33
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +526 -372
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +111 -87
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +1899 -2027
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +26 -22
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +1043 -634
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +979 -1032
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +19 -23
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +270 -273
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +353 -403
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +9 -11
- package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +7 -8
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +289 -75
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +100 -106
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +73 -66
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +64 -42
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +116 -124
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +78 -58
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +26 -17
- package/src/pi-agent-ide.ts +22 -10
- package/src/plugins/pi-agent-ide-ast/index.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/package.json +15 -13
- package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +1 -0
- package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +11 -16
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +292 -322
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +591 -656
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +15 -19
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +130 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +75 -64
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +51 -54
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +168 -185
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +36 -36
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +118 -129
- package/src/plugins/pi-agent-ide-changes/index.ts +57 -51
- package/src/plugins/pi-agent-ide-changes/package.json +14 -12
- package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +1 -0
- package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +2 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +74 -78
- package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +230 -245
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +189 -192
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +75 -79
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +259 -276
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +164 -190
- package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +59 -0
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +10 -9
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +49 -62
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +98 -93
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +131 -126
- package/src/plugins/pi-agent-ide-diagnostics/index.ts +1 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +191 -0
- package/src/plugins/pi-agent-ide-formatter/index.ts +22 -23
- package/src/plugins/pi-agent-ide-formatter/package.json +6 -3
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
- package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +281 -0
- package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +156 -0
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +38 -40
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +94 -27
- package/src/plugins/pi-agent-ide-languages/index.ts +24 -0
- package/{node_modules/pi-agent-search-semantic → src/plugins/pi-agent-ide-languages}/package.json +6 -7
- package/src/plugins/pi-agent-ide-languages/runtime/entry-29.js +2 -0
- package/src/plugins/pi-agent-ide-languages/src/languages.ts +84 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +66 -225
- package/src/plugins/pi-agent-ide-lint/package.json +10 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-30.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/catalog.ts +295 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +98 -144
- package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +182 -0
- package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +155 -0
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +94 -27
- package/src/plugins/pi-agent-ide-lsp/index.ts +111 -231
- package/src/plugins/pi-agent-ide-lsp/package.json +13 -11
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +248 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +109 -116
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +163 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +439 -396
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +421 -458
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +143 -159
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +25 -20
- package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +31 -33
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +49 -57
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +350 -415
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +58 -63
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +196 -77
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +36 -36
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +118 -127
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +108 -107
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +76 -57
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +36 -32
- package/src/post-edit/gate.ts +18 -150
- package/src/tips/core.ts +86 -0
- package/src/tips/extension.ts +115 -0
- package/src/tips/persistence.ts +225 -0
- package/src/tips/tip-callout.ts +77 -0
- package/src/toolchain/diagnostic.ts +3 -4
- package/src/toolchain/registry.ts +133 -170
- package/src/toolchain/types.ts +83 -128
- package/node_modules/pi-agent-ide-formatter/src/types.ts +0 -10
- package/node_modules/pi-agent-ide-lint/src/command-runner.ts +0 -51
- package/node_modules/pi-agent-ide-lint/src/types.ts +0 -10
- package/node_modules/pi-agent-search-semantic/index.ts +0 -105
- package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -22
- package/node_modules/pi-agent-search-web/index.ts +0 -74
- package/node_modules/pi-agent-search-web/package.json +0 -19
- package/node_modules/pi-agent-search-web/src/config.ts +0 -499
- package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -78
- package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +0 -89
- package/node_modules/pi-agent-search-web/src/providers/request.ts +0 -430
- package/node_modules/pi-agent-search-web/src/providers/response.ts +0 -402
- package/node_modules/pi-agent-search-web/src/search-format.ts +0 -29
- package/node_modules/pi-agent-search-web/src/search.ts +0 -434
- package/node_modules/pi-agent-search-web/src/types.ts +0 -153
- package/src/composite/config.ts +0 -94
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +0 -105
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -22
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +0 -74
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +0 -19
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +0 -499
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -78
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +0 -89
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +0 -430
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +0 -402
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +0 -29
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +0 -434
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +0 -153
- package/src/plugins/pi-agent-ide-formatter/src/types.ts +0 -10
- package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +0 -51
- package/src/plugins/pi-agent-ide-lint/src/types.ts +0 -10
- package/src/toolchain/gate.ts +0 -322
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { requiredValue } from "pi-agent-invariant";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
formatSourceViewResults,
|
|
6
|
+
renderSourceViewLine,
|
|
7
|
+
type SourceMappedTextContent,
|
|
8
|
+
type SourceViewBlock,
|
|
9
|
+
type SourceViewLine,
|
|
9
10
|
} from "pi-agent-ide/api/code-view";
|
|
10
11
|
|
|
11
12
|
import { collectFiles } from "./collect-files.js";
|
|
@@ -15,615 +16,554 @@ import { readTextFile } from "./read-text.js";
|
|
|
15
16
|
import type * as WTS from "web-tree-sitter";
|
|
16
17
|
|
|
17
18
|
const SUPPORTED_EXTENSIONS = new Set([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
".ts",
|
|
20
|
+
".tsx",
|
|
21
|
+
".js",
|
|
22
|
+
".jsx",
|
|
23
|
+
".mjs",
|
|
24
|
+
".cjs",
|
|
25
|
+
".py",
|
|
26
|
+
".rs",
|
|
27
|
+
".c",
|
|
28
|
+
".cpp",
|
|
29
|
+
".cxx",
|
|
30
|
+
".h",
|
|
31
|
+
".hpp",
|
|
32
|
+
".json",
|
|
33
|
+
".jsonc",
|
|
34
|
+
".yaml",
|
|
35
|
+
".yml",
|
|
36
|
+
".toml",
|
|
36
37
|
]);
|
|
37
38
|
|
|
38
39
|
const DATA_EXTENSIONS = new Set([".json", ".jsonc", ".yaml", ".yml", ".toml"]);
|
|
39
40
|
|
|
40
41
|
const DECLARATION_TYPES = new Set([
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
"class_declaration",
|
|
43
|
+
"class_definition",
|
|
44
|
+
"class_specifier",
|
|
45
|
+
"enum_declaration",
|
|
46
|
+
"enum_definition",
|
|
47
|
+
"enum_item",
|
|
48
|
+
"enum_specifier",
|
|
49
|
+
"export_statement",
|
|
50
|
+
"function_declaration",
|
|
51
|
+
"function_definition",
|
|
52
|
+
"function_item",
|
|
53
|
+
"impl_item",
|
|
54
|
+
"interface_declaration",
|
|
55
|
+
"lexical_declaration",
|
|
56
|
+
"namespace_definition",
|
|
57
|
+
"mod_item",
|
|
58
|
+
"public_field_definition",
|
|
59
|
+
"method_definition",
|
|
60
|
+
"method_signature",
|
|
61
|
+
"property_signature",
|
|
62
|
+
"field_declaration",
|
|
63
|
+
"struct_item",
|
|
64
|
+
"struct_specifier",
|
|
65
|
+
"trait_item",
|
|
66
|
+
"type_alias_declaration",
|
|
67
|
+
"type_item",
|
|
68
|
+
"variable_declaration",
|
|
69
|
+
"assignment",
|
|
69
70
|
]);
|
|
70
71
|
|
|
71
72
|
const ROOT_TYPES = new Set(["module", "program", "source_file"]);
|
|
72
73
|
|
|
73
74
|
const IMPORT_TYPES = new Set([
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
"import_declaration",
|
|
76
|
+
"import_from_statement",
|
|
77
|
+
"import_statement",
|
|
78
|
+
"use_declaration",
|
|
78
79
|
]);
|
|
79
80
|
|
|
80
81
|
const FUNCTION_TYPES = new Set([
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
"arrow_function",
|
|
83
|
+
"function_declaration",
|
|
84
|
+
"function_definition",
|
|
85
|
+
"function_item",
|
|
86
|
+
"function_expression",
|
|
87
|
+
"method_definition",
|
|
87
88
|
]);
|
|
88
89
|
|
|
89
|
-
const INITIALIZER_TYPES = new Set([
|
|
90
|
-
"public_field_definition",
|
|
91
|
-
"variable_declarator",
|
|
92
|
-
"assignment",
|
|
93
|
-
]);
|
|
90
|
+
const INITIALIZER_TYPES = new Set(["public_field_definition", "variable_declarator", "assignment"]);
|
|
94
91
|
|
|
95
92
|
const NAME_TYPES = new Set([
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
"field_identifier",
|
|
94
|
+
"identifier",
|
|
95
|
+
"property_identifier",
|
|
96
|
+
"shorthand_property_identifier_pattern",
|
|
97
|
+
"type_identifier",
|
|
101
98
|
]);
|
|
102
99
|
|
|
103
|
-
interface Replacement
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
readonly lineSourceLines?: readonly (number | undefined)[];
|
|
100
|
+
interface Replacement {
|
|
101
|
+
readonly start: number;
|
|
102
|
+
readonly end: number;
|
|
103
|
+
readonly text: string;
|
|
104
|
+
readonly lineSourceLines?: readonly (number | undefined)[];
|
|
109
105
|
}
|
|
110
106
|
|
|
111
|
-
interface ProjectedLine
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
readonly sourceLine?: number;
|
|
107
|
+
interface ProjectedLine {
|
|
108
|
+
readonly content: string;
|
|
109
|
+
readonly sourceLine?: number;
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
export function isSupportedOutlinePath(filePath: string): boolean
|
|
118
|
-
|
|
119
|
-
return SUPPORTED_EXTENSIONS.has(path.extname(filePath).toLowerCase());
|
|
112
|
+
export function isSupportedOutlinePath(filePath: string): boolean {
|
|
113
|
+
return SUPPORTED_EXTENSIONS.has(path.extname(filePath).toLowerCase());
|
|
120
114
|
}
|
|
121
115
|
|
|
122
116
|
const PEEK_FORMAT_OPTIONS = {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
failureLabel: "PEEK_FAILED",
|
|
118
|
+
emptyReason: "no entries to peek.",
|
|
119
|
+
recovery: ['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.'],
|
|
126
120
|
} as const;
|
|
127
121
|
|
|
128
122
|
const AST_OUTLINE_FORMAT_OPTIONS = {
|
|
129
|
-
|
|
130
|
-
|
|
123
|
+
failureLabel: "AST_OUTLINE_FAILED",
|
|
124
|
+
emptyReason: "no AST outline was produced.",
|
|
131
125
|
} as const;
|
|
132
126
|
|
|
133
|
-
export function formatAstOutline(block: SourceViewBlock): SourceMappedTextContent
|
|
134
|
-
|
|
135
|
-
return formatSourceViewResults([block], AST_OUTLINE_FORMAT_OPTIONS);
|
|
127
|
+
export function formatAstOutline(block: SourceViewBlock): SourceMappedTextContent {
|
|
128
|
+
return formatSourceViewResults([block], AST_OUTLINE_FORMAT_OPTIONS);
|
|
136
129
|
}
|
|
137
130
|
|
|
138
|
-
export class AstOutlineManager
|
|
139
|
-
|
|
140
|
-
private readonly fallbackScopeManager = new AstScopeManager();
|
|
141
|
-
|
|
142
|
-
public async readFileOutline(filePath: string, cwd: string): Promise<SourceViewBlock>
|
|
143
|
-
{
|
|
144
|
-
const absolutePath = resolvePath(filePath, cwd);
|
|
145
|
-
const displayPath = path.relative(cwd, absolutePath) || absolutePath;
|
|
146
|
-
|
|
147
|
-
if (!isSupportedOutlinePath(absolutePath))
|
|
148
|
-
{
|
|
149
|
-
throw new Error(`AST outline is not supported for ${displayPath}.`);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const snapshot = await readTextFile(absolutePath);
|
|
153
|
-
const tree = await parseDocument(absolutePath, cwd, snapshot.lines);
|
|
154
|
-
|
|
155
|
-
if (!tree)
|
|
156
|
-
{
|
|
157
|
-
throw new Error(`No AST parser is available for ${displayPath}.`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return await this.createSourceViewBlock(
|
|
161
|
-
tree.rootNode,
|
|
162
|
-
absolutePath,
|
|
163
|
-
displayPath,
|
|
164
|
-
cwd,
|
|
165
|
-
snapshot.lines,
|
|
166
|
-
snapshot.content,
|
|
167
|
-
path.extname(absolutePath).toLowerCase(),
|
|
168
|
-
);
|
|
169
|
-
}
|
|
131
|
+
export class AstOutlineManager {
|
|
132
|
+
private readonly fallbackScopeManager = new AstScopeManager();
|
|
170
133
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const displayPath = path.relative(cwd, absolutePath) || absolutePath;
|
|
175
|
-
|
|
176
|
-
if (!isSupportedOutlinePath(absolutePath))
|
|
177
|
-
{
|
|
178
|
-
const snapshot = await readTextFile(absolutePath);
|
|
179
|
-
return formatSourceViewResults(
|
|
180
|
-
[formatUnsupportedSourceBlock(absolutePath, displayPath, snapshot.lines)],
|
|
181
|
-
PEEK_FORMAT_OPTIONS,
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
try
|
|
186
|
-
{
|
|
187
|
-
return formatSourceViewResults([await this.readFileOutline(absolutePath, cwd)], PEEK_FORMAT_OPTIONS);
|
|
188
|
-
}
|
|
189
|
-
catch (error)
|
|
190
|
-
{
|
|
191
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
192
|
-
return formatSourceViewResults([failedSourceViewBlock(displayPath, message)], PEEK_FORMAT_OPTIONS);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
134
|
+
public async readFileOutline(filePath: string, cwd: string): Promise<SourceViewBlock> {
|
|
135
|
+
const absolutePath = resolvePath(filePath, cwd);
|
|
136
|
+
const displayPath = path.relative(cwd, absolutePath) || absolutePath;
|
|
195
137
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const files = await collectFiles(cwd);
|
|
199
|
-
const supportedFiles = files
|
|
200
|
-
.filter((filePath) => isSupportedOutlinePath(filePath))
|
|
201
|
-
.sort();
|
|
202
|
-
|
|
203
|
-
for (const filePath of supportedFiles)
|
|
204
|
-
{
|
|
205
|
-
let snapshot;
|
|
206
|
-
|
|
207
|
-
try
|
|
208
|
-
{
|
|
209
|
-
snapshot = await readTextFile(filePath);
|
|
210
|
-
}
|
|
211
|
-
catch
|
|
212
|
-
{
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
let tree;
|
|
217
|
-
|
|
218
|
-
try
|
|
219
|
-
{
|
|
220
|
-
tree = await parseDocument(filePath, cwd, snapshot.lines);
|
|
221
|
-
}
|
|
222
|
-
catch
|
|
223
|
-
{
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (!tree)
|
|
228
|
-
{
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const match = findSymbol(tree.rootNode, symbol);
|
|
233
|
-
|
|
234
|
-
if (!match)
|
|
235
|
-
{
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const displayPath = path.relative(cwd, filePath) || filePath;
|
|
240
|
-
const block = await this.createSourceViewBlock(
|
|
241
|
-
match,
|
|
242
|
-
filePath,
|
|
243
|
-
displayPath,
|
|
244
|
-
cwd,
|
|
245
|
-
snapshot.lines,
|
|
246
|
-
snapshot.content,
|
|
247
|
-
path.extname(filePath).toLowerCase(),
|
|
248
|
-
symbol,
|
|
249
|
-
[`defined in: ${displayPath}:${match.startPosition.row + 1}`],
|
|
250
|
-
);
|
|
251
|
-
return formatSourceViewResults([block], PEEK_FORMAT_OPTIONS);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return formatSourceViewResults(
|
|
255
|
-
[failedSourceViewBlock("", `symbol not found: ${symbol}`, "PEEK_NOT_FOUND")],
|
|
256
|
-
PEEK_FORMAT_OPTIONS,
|
|
257
|
-
);
|
|
138
|
+
if (!isSupportedOutlinePath(absolutePath)) {
|
|
139
|
+
throw new Error(`AST outline is not supported for ${displayPath}.`);
|
|
258
140
|
}
|
|
259
141
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
filePath: string,
|
|
263
|
-
displayPath: string,
|
|
264
|
-
cwd: string,
|
|
265
|
-
sourceLines: readonly string[],
|
|
266
|
-
source: string,
|
|
267
|
-
extension: string,
|
|
268
|
-
heading?: string,
|
|
269
|
-
details?: readonly string[],
|
|
270
|
-
): Promise<SourceViewBlock>
|
|
271
|
-
{
|
|
272
|
-
const projectedLines = renderNodeLines(node, source, extension);
|
|
273
|
-
const scopes = await getOutlineScopes(this.fallbackScopeManager, filePath, cwd, sourceLines);
|
|
274
|
-
const markersByLine = buildScopeMarkers(scopes);
|
|
275
|
-
const renderedLines = projectedLines.map((line) =>
|
|
276
|
-
{
|
|
277
|
-
const sourceLineNumber = line.sourceLine;
|
|
278
|
-
const sourceContent = sourceLineNumber === undefined ? undefined : sourceLines[sourceLineNumber - 1] ?? "";
|
|
279
|
-
const markers = sourceLineNumber === undefined ? undefined : markersByLine.get(sourceLineNumber);
|
|
280
|
-
const suffix = markers?.map((marker) => ` <!-- ${marker} -->`).join("") ?? "";
|
|
281
|
-
|
|
282
|
-
return renderSourceViewLine({
|
|
283
|
-
content: line.content,
|
|
284
|
-
...(sourceLineNumber === undefined || sourceContent === undefined
|
|
285
|
-
? {}
|
|
286
|
-
: {
|
|
287
|
-
sourceLine: {
|
|
288
|
-
source: filePath,
|
|
289
|
-
lineNumber: sourceLineNumber,
|
|
290
|
-
content: sourceContent,
|
|
291
|
-
},
|
|
292
|
-
}),
|
|
293
|
-
...(suffix.length === 0 ? {} : { suffix }),
|
|
294
|
-
} satisfies SourceViewLine);
|
|
295
|
-
});
|
|
142
|
+
const snapshot = await readTextFile(absolutePath);
|
|
143
|
+
const tree = await parseDocument(absolutePath, cwd, snapshot.lines);
|
|
296
144
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
...(heading === undefined ? {} : { heading }),
|
|
300
|
-
...(details === undefined ? {} : { details }),
|
|
301
|
-
startLine: node.startPosition.row + 1,
|
|
302
|
-
endLine: node.endPosition.row + 1,
|
|
303
|
-
totalLines: sourceLines.length,
|
|
304
|
-
renderedLines,
|
|
305
|
-
};
|
|
145
|
+
if (!tree) {
|
|
146
|
+
throw new Error(`No AST parser is available for ${displayPath}.`);
|
|
306
147
|
}
|
|
307
|
-
}
|
|
308
148
|
|
|
309
|
-
|
|
310
|
-
|
|
149
|
+
return await this.createSourceViewBlock(
|
|
150
|
+
tree.rootNode,
|
|
151
|
+
absolutePath,
|
|
152
|
+
displayPath,
|
|
153
|
+
cwd,
|
|
154
|
+
snapshot.lines,
|
|
155
|
+
snapshot.content,
|
|
156
|
+
path.extname(absolutePath).toLowerCase(),
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public async formatFile(filePath: string, cwd: string): Promise<SourceMappedTextContent> {
|
|
161
|
+
const absolutePath = resolvePath(filePath, cwd);
|
|
162
|
+
const displayPath = path.relative(cwd, absolutePath) || absolutePath;
|
|
163
|
+
|
|
164
|
+
if (!isSupportedOutlinePath(absolutePath)) {
|
|
165
|
+
const snapshot = await readTextFile(absolutePath);
|
|
166
|
+
return formatSourceViewResults(
|
|
167
|
+
[formatUnsupportedSourceBlock(absolutePath, displayPath, snapshot.lines)],
|
|
168
|
+
PEEK_FORMAT_OPTIONS,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
return formatSourceViewResults(
|
|
174
|
+
[await this.readFileOutline(absolutePath, cwd)],
|
|
175
|
+
PEEK_FORMAT_OPTIONS,
|
|
176
|
+
);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
179
|
+
return formatSourceViewResults(
|
|
180
|
+
[failedSourceViewBlock(displayPath, message)],
|
|
181
|
+
PEEK_FORMAT_OPTIONS,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public async formatSymbol(symbol: string, cwd: string): Promise<SourceMappedTextContent> {
|
|
187
|
+
const files = await collectFiles(cwd);
|
|
188
|
+
const supportedFiles = files.filter((filePath) => isSupportedOutlinePath(filePath)).sort();
|
|
189
|
+
|
|
190
|
+
for (const filePath of supportedFiles) {
|
|
191
|
+
let snapshot;
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
snapshot = await readTextFile(filePath);
|
|
195
|
+
} catch {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let tree;
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
tree = await parseDocument(filePath, cwd, snapshot.lines);
|
|
203
|
+
} catch {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!tree) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const match = findSymbol(tree.rootNode, symbol);
|
|
212
|
+
|
|
213
|
+
if (!match) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const displayPath = path.relative(cwd, filePath) || filePath;
|
|
218
|
+
const block = await this.createSourceViewBlock(
|
|
219
|
+
match,
|
|
220
|
+
filePath,
|
|
221
|
+
displayPath,
|
|
222
|
+
cwd,
|
|
223
|
+
snapshot.lines,
|
|
224
|
+
snapshot.content,
|
|
225
|
+
path.extname(filePath).toLowerCase(),
|
|
226
|
+
symbol,
|
|
227
|
+
[`defined in: ${displayPath}:${match.startPosition.row + 1}`],
|
|
228
|
+
);
|
|
229
|
+
return formatSourceViewResults([block], PEEK_FORMAT_OPTIONS);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return formatSourceViewResults(
|
|
233
|
+
[failedSourceViewBlock("", `symbol not found: ${symbol}`, "PEEK_NOT_FOUND")],
|
|
234
|
+
PEEK_FORMAT_OPTIONS,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private async createSourceViewBlock(
|
|
239
|
+
node: WTS.Node,
|
|
240
|
+
filePath: string,
|
|
311
241
|
displayPath: string,
|
|
242
|
+
cwd: string,
|
|
312
243
|
sourceLines: readonly string[],
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
244
|
+
source: string,
|
|
245
|
+
extension: string,
|
|
246
|
+
heading?: string,
|
|
247
|
+
details?: readonly string[],
|
|
248
|
+
): Promise<SourceViewBlock> {
|
|
249
|
+
const projectedLines = renderNodeLines(node, source, extension);
|
|
250
|
+
const scopes = await getOutlineScopes(this.fallbackScopeManager, filePath, cwd, sourceLines);
|
|
251
|
+
const markersByLine = buildScopeMarkers(scopes);
|
|
252
|
+
const renderedLines = projectedLines.map((line) => {
|
|
253
|
+
const sourceLineNumber = line.sourceLine;
|
|
254
|
+
const sourceContent =
|
|
255
|
+
sourceLineNumber === undefined ? undefined : (sourceLines[sourceLineNumber - 1] ?? "");
|
|
256
|
+
const markers =
|
|
257
|
+
sourceLineNumber === undefined ? undefined : markersByLine.get(sourceLineNumber);
|
|
258
|
+
const suffix = markers?.map((marker) => ` <!-- ${marker} -->`).join("") ?? "";
|
|
259
|
+
|
|
260
|
+
return renderSourceViewLine({
|
|
261
|
+
content: line.content,
|
|
262
|
+
...(!(sourceLineNumber === undefined || sourceContent === undefined) && {
|
|
263
|
+
sourceLine: {
|
|
264
|
+
source: filePath,
|
|
265
|
+
lineNumber: sourceLineNumber,
|
|
266
|
+
content: sourceContent,
|
|
267
|
+
},
|
|
268
|
+
}),
|
|
269
|
+
...(suffix.length > 0 && { suffix }),
|
|
270
|
+
} satisfies SourceViewLine);
|
|
271
|
+
});
|
|
332
272
|
|
|
333
|
-
function failedSourceViewBlock(path: string, error: string, code = "PEEK_FAILED"): SourceViewBlock
|
|
334
|
-
{
|
|
335
273
|
return {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
code,
|
|
274
|
+
path: displayPath,
|
|
275
|
+
...(heading !== undefined && { heading }),
|
|
276
|
+
...(details !== undefined && { details }),
|
|
277
|
+
startLine: node.startPosition.row + 1,
|
|
278
|
+
endLine: node.endPosition.row + 1,
|
|
279
|
+
totalLines: sourceLines.length,
|
|
280
|
+
renderedLines,
|
|
344
281
|
};
|
|
282
|
+
}
|
|
345
283
|
}
|
|
346
284
|
|
|
347
|
-
function
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
285
|
+
function formatUnsupportedSourceBlock(
|
|
286
|
+
sourcePath: string,
|
|
287
|
+
displayPath: string,
|
|
288
|
+
sourceLines: readonly string[],
|
|
289
|
+
): SourceViewBlock {
|
|
290
|
+
return {
|
|
291
|
+
path: displayPath,
|
|
292
|
+
startLine: sourceLines.length > 0 ? 1 : 0,
|
|
293
|
+
endLine: sourceLines.length,
|
|
294
|
+
totalLines: sourceLines.length,
|
|
295
|
+
renderedLines: sourceLines.map((content, index) =>
|
|
296
|
+
renderSourceViewLine({
|
|
297
|
+
content,
|
|
298
|
+
sourceLine: {
|
|
299
|
+
source: sourcePath,
|
|
300
|
+
lineNumber: index + 1,
|
|
301
|
+
content,
|
|
302
|
+
},
|
|
303
|
+
}),
|
|
304
|
+
),
|
|
305
|
+
};
|
|
355
306
|
}
|
|
356
307
|
|
|
357
|
-
function
|
|
358
|
-
{
|
|
359
|
-
|
|
308
|
+
function failedSourceViewBlock(path: string, error: string, code = "PEEK_FAILED"): SourceViewBlock {
|
|
309
|
+
return {
|
|
310
|
+
path,
|
|
311
|
+
startLine: 0,
|
|
312
|
+
endLine: 0,
|
|
313
|
+
totalLines: 0,
|
|
314
|
+
renderedLines: [],
|
|
315
|
+
status: "failed",
|
|
316
|
+
error,
|
|
317
|
+
code,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
360
320
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
321
|
+
function getOutlineScopes(
|
|
322
|
+
fallback: AstScopeManager,
|
|
323
|
+
filePath: string,
|
|
324
|
+
cwd: string,
|
|
325
|
+
lines: readonly string[],
|
|
326
|
+
): Promise<ScopeEntry[]> {
|
|
327
|
+
return fallback.getDocumentScopes(filePath, cwd, lines);
|
|
328
|
+
}
|
|
366
329
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
markers.set(scope.endLine, end);
|
|
370
|
-
}
|
|
330
|
+
function buildScopeMarkers(scopes: readonly ScopeEntry[]): Map<number, string[]> {
|
|
331
|
+
const markers = new Map<number, string[]>();
|
|
371
332
|
|
|
372
|
-
|
|
373
|
-
|
|
333
|
+
for (const scope of scopes) {
|
|
334
|
+
const begin = markers.get(scope.startLine) ?? [];
|
|
335
|
+
begin.push(scope.beginAnchor.value);
|
|
336
|
+
markers.set(scope.startLine, begin);
|
|
374
337
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return decodeURIComponent(filePath.slice("file://".length));
|
|
380
|
-
}
|
|
338
|
+
const end = markers.get(scope.endLine) ?? [];
|
|
339
|
+
end.push(scope.endScopeAnchor.value);
|
|
340
|
+
markers.set(scope.endLine, end);
|
|
341
|
+
}
|
|
381
342
|
|
|
382
|
-
|
|
343
|
+
return markers;
|
|
383
344
|
}
|
|
384
345
|
|
|
385
|
-
function
|
|
386
|
-
{
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const visit = (node: WTS.Node): void =>
|
|
390
|
-
{
|
|
391
|
-
if (result)
|
|
392
|
-
{
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (DECLARATION_TYPES.has(node.type) && getNodeName(node) === symbol)
|
|
397
|
-
{
|
|
398
|
-
result = unwrapDeclaration(node);
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
for (const child of node.namedChildren)
|
|
403
|
-
{
|
|
404
|
-
visit(child);
|
|
405
|
-
}
|
|
406
|
-
};
|
|
346
|
+
function resolvePath(filePath: string, cwd: string): string {
|
|
347
|
+
if (filePath.startsWith("file://")) {
|
|
348
|
+
return decodeURIComponent(filePath.slice("file://".length));
|
|
349
|
+
}
|
|
407
350
|
|
|
408
|
-
|
|
409
|
-
return result;
|
|
351
|
+
return path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
410
352
|
}
|
|
411
353
|
|
|
412
|
-
function
|
|
413
|
-
|
|
414
|
-
const nameField = node.childForFieldName("name");
|
|
354
|
+
function findSymbol(root: WTS.Node, symbol: string): WTS.Node | undefined {
|
|
355
|
+
let result: WTS.Node | undefined;
|
|
415
356
|
|
|
416
|
-
|
|
417
|
-
{
|
|
418
|
-
|
|
357
|
+
const visit = (node: WTS.Node): void => {
|
|
358
|
+
if (result) {
|
|
359
|
+
return;
|
|
419
360
|
}
|
|
420
361
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
{
|
|
425
|
-
return child.text;
|
|
426
|
-
}
|
|
362
|
+
if (DECLARATION_TYPES.has(node.type) && getNodeName(node) === symbol) {
|
|
363
|
+
result = unwrapDeclaration(node);
|
|
364
|
+
return;
|
|
427
365
|
}
|
|
428
366
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const declarator = node.namedChildren.find((child) => child.type === "variable_declarator");
|
|
432
|
-
const name = declarator?.childForFieldName("name");
|
|
433
|
-
return name?.text;
|
|
367
|
+
for (const child of node.namedChildren) {
|
|
368
|
+
visit(child);
|
|
434
369
|
}
|
|
370
|
+
};
|
|
435
371
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const declarator = node.childForFieldName("declarator");
|
|
439
|
-
return declarator ? findNestedName(declarator) : undefined;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
return undefined;
|
|
372
|
+
visit(root);
|
|
373
|
+
return result;
|
|
443
374
|
}
|
|
444
375
|
|
|
445
|
-
function
|
|
446
|
-
|
|
447
|
-
if (NAME_TYPES.has(node.type))
|
|
448
|
-
{
|
|
449
|
-
return node.text;
|
|
450
|
-
}
|
|
376
|
+
function getNodeName(node: WTS.Node): string | undefined {
|
|
377
|
+
const nameField = node.childForFieldName("name");
|
|
451
378
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
379
|
+
if (nameField && NAME_TYPES.has(nameField.type)) {
|
|
380
|
+
return nameField.text;
|
|
381
|
+
}
|
|
455
382
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
383
|
+
for (const child of node.namedChildren) {
|
|
384
|
+
if (NAME_TYPES.has(child.type)) {
|
|
385
|
+
return child.text;
|
|
460
386
|
}
|
|
387
|
+
}
|
|
461
388
|
|
|
462
|
-
|
|
463
|
-
|
|
389
|
+
if (node.type === "lexical_declaration" || node.type === "variable_declaration") {
|
|
390
|
+
const declarator = node.namedChildren.find((child) => child.type === "variable_declarator");
|
|
391
|
+
const name = declarator?.childForFieldName("name");
|
|
392
|
+
return name?.text;
|
|
393
|
+
}
|
|
464
394
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (
|
|
470
|
-
parent
|
|
471
|
-
&& (parent.type === "export_statement" || parent.type === "decorated_definition"
|
|
472
|
-
|| parent.type === "template_declaration")
|
|
473
|
-
)
|
|
474
|
-
{
|
|
475
|
-
return parent;
|
|
476
|
-
}
|
|
395
|
+
if (node.type === "function_definition") {
|
|
396
|
+
const declarator = node.childForFieldName("declarator");
|
|
397
|
+
return declarator ? findNestedName(declarator) : undefined;
|
|
398
|
+
}
|
|
477
399
|
|
|
478
|
-
|
|
400
|
+
return undefined;
|
|
479
401
|
}
|
|
480
402
|
|
|
481
|
-
|
|
482
|
-
{
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
403
|
+
function findNestedName(node: WTS.Node): string | undefined {
|
|
404
|
+
if (NAME_TYPES.has(node.type)) {
|
|
405
|
+
return node.text;
|
|
406
|
+
}
|
|
486
407
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
const replacements: Replacement[] = [];
|
|
408
|
+
for (const child of node.namedChildren) {
|
|
409
|
+
const name = findNestedName(child);
|
|
490
410
|
|
|
491
|
-
if (
|
|
492
|
-
|
|
493
|
-
collectDataReplacements(node, extension, replacements);
|
|
494
|
-
}
|
|
495
|
-
else
|
|
496
|
-
{
|
|
497
|
-
collectReplacements(node, extension, replacements);
|
|
411
|
+
if (name) {
|
|
412
|
+
return name;
|
|
498
413
|
}
|
|
414
|
+
}
|
|
499
415
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const relevant = replacements
|
|
503
|
-
.filter((replacement) => replacement.start >= start && replacement.end <= end)
|
|
504
|
-
.sort((a, b) => b.start - a.start);
|
|
505
|
-
const mapped = mapSourceRange(source, start, end);
|
|
506
|
-
|
|
507
|
-
for (const replacement of relevant)
|
|
508
|
-
{
|
|
509
|
-
const relativeStart = replacement.start - start;
|
|
510
|
-
const relativeEnd = replacement.end - start;
|
|
511
|
-
const inserted = mapReplacement(replacement);
|
|
512
|
-
mapped.splice(relativeStart, relativeEnd - relativeStart, ...inserted);
|
|
513
|
-
}
|
|
416
|
+
return undefined;
|
|
417
|
+
}
|
|
514
418
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
mapped.pop();
|
|
518
|
-
}
|
|
419
|
+
function unwrapDeclaration(node: WTS.Node): WTS.Node {
|
|
420
|
+
const parent = node.parent;
|
|
519
421
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
else
|
|
529
|
-
{
|
|
530
|
-
lines.at(-1)!.push(item);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
422
|
+
if (
|
|
423
|
+
parent &&
|
|
424
|
+
(parent.type === "export_statement" ||
|
|
425
|
+
parent.type === "decorated_definition" ||
|
|
426
|
+
parent.type === "template_declaration")
|
|
427
|
+
) {
|
|
428
|
+
return parent;
|
|
429
|
+
}
|
|
533
430
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
431
|
+
return node;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
interface MappedCharacter {
|
|
435
|
+
readonly char: string;
|
|
436
|
+
readonly sourceLine?: number;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function renderNodeLines(node: WTS.Node, source: string, extension: string): ProjectedLine[] {
|
|
440
|
+
const replacements: Replacement[] = [];
|
|
441
|
+
|
|
442
|
+
if (DATA_EXTENSIONS.has(extension)) {
|
|
443
|
+
collectDataReplacements(node, extension, replacements);
|
|
444
|
+
} else {
|
|
445
|
+
collectReplacements(node, extension, replacements);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const start = lineStartAt(source, node.startIndex);
|
|
449
|
+
const end = lineEndAt(source, node.endIndex);
|
|
450
|
+
const relevant = replacements
|
|
451
|
+
.filter((replacement) => replacement.start >= start && replacement.end <= end)
|
|
452
|
+
.sort((a, b) => b.start - a.start);
|
|
453
|
+
const mapped = mapSourceRange(source, start, end);
|
|
454
|
+
|
|
455
|
+
for (const replacement of relevant) {
|
|
456
|
+
const relativeStart = replacement.start - start;
|
|
457
|
+
const relativeEnd = replacement.end - start;
|
|
458
|
+
const inserted = mapReplacement(replacement);
|
|
459
|
+
mapped.splice(relativeStart, relativeEnd - relativeStart, ...inserted);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
while (mapped.length > 0 && /\s/u.test(requiredValue(mapped.at(-1)).char)) {
|
|
463
|
+
mapped.pop();
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const lines: MappedCharacter[][] = [[]];
|
|
467
|
+
|
|
468
|
+
for (const item of mapped) {
|
|
469
|
+
if (item.char === "\n") {
|
|
470
|
+
lines.push([]);
|
|
471
|
+
} else {
|
|
472
|
+
requiredValue(lines.at(-1)).push(item);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return lines.map((line) => {
|
|
477
|
+
const sourceLines = [
|
|
478
|
+
...new Set(line.flatMap((item) => (item.sourceLine === undefined ? [] : [item.sourceLine]))),
|
|
479
|
+
];
|
|
480
|
+
return {
|
|
481
|
+
content: line.map((item) => item.char).join(""),
|
|
482
|
+
...(sourceLines.length === 1 && { sourceLine: sourceLines[0] }),
|
|
483
|
+
};
|
|
484
|
+
});
|
|
544
485
|
}
|
|
545
486
|
|
|
546
|
-
function lineStartAt(source: string, index: number): number
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return newline + 1;
|
|
487
|
+
function lineStartAt(source: string, index: number): number {
|
|
488
|
+
const newline = source.lastIndexOf("\n", Math.max(0, index - 1));
|
|
489
|
+
return newline + 1;
|
|
550
490
|
}
|
|
551
491
|
|
|
552
|
-
function lineEndAt(source: string, index: number): number
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
return newline === -1 ? source.length : newline;
|
|
492
|
+
function lineEndAt(source: string, index: number): number {
|
|
493
|
+
const newline = source.indexOf("\n", index);
|
|
494
|
+
return newline === -1 ? source.length : newline;
|
|
556
495
|
}
|
|
557
496
|
|
|
558
|
-
function mapSourceRange(source: string, start: number, end: number): MappedCharacter[]
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const mapped: MappedCharacter[] = [];
|
|
497
|
+
function mapSourceRange(source: string, start: number, end: number): MappedCharacter[] {
|
|
498
|
+
let sourceLine = source.slice(0, start).split("\n").length;
|
|
499
|
+
const mapped: MappedCharacter[] = [];
|
|
562
500
|
|
|
563
|
-
|
|
564
|
-
{
|
|
565
|
-
mapped.push({ char, sourceLine });
|
|
501
|
+
for (const char of source.slice(start, end)) {
|
|
502
|
+
mapped.push({ char, sourceLine });
|
|
566
503
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
sourceLine += 1;
|
|
570
|
-
}
|
|
504
|
+
if (char === "\n") {
|
|
505
|
+
sourceLine += 1;
|
|
571
506
|
}
|
|
507
|
+
}
|
|
572
508
|
|
|
573
|
-
|
|
509
|
+
return mapped;
|
|
574
510
|
}
|
|
575
511
|
|
|
576
|
-
function mapReplacement(replacement: Replacement): MappedCharacter[]
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
let lineIndex = 0;
|
|
512
|
+
function mapReplacement(replacement: Replacement): MappedCharacter[] {
|
|
513
|
+
const lineSources = replacement.lineSourceLines ?? [];
|
|
514
|
+
let lineIndex = 0;
|
|
580
515
|
|
|
581
|
-
|
|
516
|
+
const mapped: MappedCharacter[] = [];
|
|
582
517
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
mapped.push(sourceLine === undefined ? { char } : { char, sourceLine });
|
|
518
|
+
for (let index = 0; index < replacement.text.length; index += 1) {
|
|
519
|
+
const char = requiredValue(replacement.text[index]);
|
|
520
|
+
const sourceLine = lineSources[lineIndex];
|
|
521
|
+
mapped.push(sourceLine === undefined ? { char } : { char, sourceLine });
|
|
588
522
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
lineIndex += 1;
|
|
592
|
-
}
|
|
523
|
+
if (char === "\n") {
|
|
524
|
+
lineIndex += 1;
|
|
593
525
|
}
|
|
526
|
+
}
|
|
594
527
|
|
|
595
|
-
|
|
528
|
+
return mapped;
|
|
596
529
|
}
|
|
597
530
|
|
|
598
|
-
function collectDataReplacements(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
collectDataReplacements(child, extension, replacements);
|
|
531
|
+
function collectDataReplacements(
|
|
532
|
+
node: WTS.Node,
|
|
533
|
+
extension: string,
|
|
534
|
+
replacements: Replacement[],
|
|
535
|
+
): void {
|
|
536
|
+
for (const child of node.namedChildren) {
|
|
537
|
+
if (isDataScalar(child, extension)) {
|
|
538
|
+
if (!isDataKey(child)) {
|
|
539
|
+
replacements.push({
|
|
540
|
+
start: child.startIndex,
|
|
541
|
+
end: child.endIndex,
|
|
542
|
+
text: "…",
|
|
543
|
+
lineSourceLines: [child.startPosition.row + 1],
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
continue;
|
|
618
548
|
}
|
|
549
|
+
|
|
550
|
+
collectDataReplacements(child, extension, replacements);
|
|
551
|
+
}
|
|
619
552
|
}
|
|
620
553
|
|
|
621
|
-
function isDataScalar(node: WTS.Node, extension: string): boolean
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
? [
|
|
554
|
+
function isDataScalar(node: WTS.Node, extension: string): boolean {
|
|
555
|
+
const scalarTypes =
|
|
556
|
+
extension === ".json" || extension === ".jsonc"
|
|
557
|
+
? ["string", "number", "true", "false", "null"]
|
|
558
|
+
: extension === ".yaml" || extension === ".yml"
|
|
559
|
+
? [
|
|
560
|
+
"string_scalar",
|
|
561
|
+
"integer_scalar",
|
|
562
|
+
"float_scalar",
|
|
563
|
+
"boolean_scalar",
|
|
564
|
+
"null_scalar",
|
|
565
|
+
"block_scalar",
|
|
566
|
+
]
|
|
627
567
|
: [
|
|
628
568
|
"string",
|
|
629
569
|
"integer",
|
|
@@ -634,180 +574,175 @@ function isDataScalar(node: WTS.Node, extension: string): boolean
|
|
|
634
574
|
"local_date_time",
|
|
635
575
|
"local_date",
|
|
636
576
|
"local_time",
|
|
637
|
-
|
|
577
|
+
];
|
|
638
578
|
|
|
639
|
-
|
|
579
|
+
return scalarTypes.includes(node.type);
|
|
640
580
|
}
|
|
641
581
|
|
|
642
|
-
function isDataKey(node: WTS.Node): boolean
|
|
643
|
-
|
|
644
|
-
let ancestor = node.parent;
|
|
582
|
+
function isDataKey(node: WTS.Node): boolean {
|
|
583
|
+
let ancestor = node.parent;
|
|
645
584
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
585
|
+
while (
|
|
586
|
+
ancestor &&
|
|
587
|
+
!ancestor.type.endsWith("pair") &&
|
|
588
|
+
ancestor.type !== "pair" &&
|
|
589
|
+
ancestor.type !== "table"
|
|
590
|
+
) {
|
|
591
|
+
ancestor = ancestor.parent;
|
|
592
|
+
}
|
|
650
593
|
|
|
651
|
-
|
|
652
|
-
|
|
594
|
+
const key = ancestor?.namedChildren[0];
|
|
595
|
+
return key !== undefined && key.startIndex <= node.startIndex && key.endIndex >= node.endIndex;
|
|
653
596
|
}
|
|
654
597
|
|
|
655
598
|
function collectReplacements(
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
): void
|
|
661
|
-
{
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
{
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
for (const child of node.namedChildren)
|
|
707
|
-
{
|
|
708
|
-
collectReplacements(child, extension, replacements, ROOT_TYPES.has(node.type));
|
|
709
|
-
}
|
|
599
|
+
node: WTS.Node,
|
|
600
|
+
extension: string,
|
|
601
|
+
replacements: Replacement[],
|
|
602
|
+
topLevel = false,
|
|
603
|
+
): void {
|
|
604
|
+
if (topLevel && !isTopLevelInterfaceNode(node)) {
|
|
605
|
+
replacements.push({
|
|
606
|
+
start: node.startIndex,
|
|
607
|
+
end: node.endIndex,
|
|
608
|
+
text: "…",
|
|
609
|
+
lineSourceLines: [node.startPosition.row + 1],
|
|
610
|
+
});
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (FUNCTION_TYPES.has(node.type)) {
|
|
615
|
+
const body = findBody(node);
|
|
616
|
+
|
|
617
|
+
if (body) {
|
|
618
|
+
const placeholder = renderBodyPlaceholder(body, extension);
|
|
619
|
+
replacements.push({
|
|
620
|
+
start: body.startIndex,
|
|
621
|
+
end: body.endIndex,
|
|
622
|
+
text: placeholder.text,
|
|
623
|
+
lineSourceLines: placeholder.lineSourceLines,
|
|
624
|
+
});
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if (INITIALIZER_TYPES.has(node.type)) {
|
|
630
|
+
const value = node.childForFieldName("value");
|
|
631
|
+
|
|
632
|
+
if (value && !FUNCTION_TYPES.has(value.type)) {
|
|
633
|
+
replacements.push({
|
|
634
|
+
start: value.startIndex,
|
|
635
|
+
end: value.endIndex,
|
|
636
|
+
text: "…",
|
|
637
|
+
lineSourceLines: [value.startPosition.row + 1],
|
|
638
|
+
});
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
for (const child of node.namedChildren) {
|
|
644
|
+
collectReplacements(child, extension, replacements, ROOT_TYPES.has(node.type));
|
|
645
|
+
}
|
|
710
646
|
}
|
|
711
647
|
|
|
712
|
-
function isTopLevelInterfaceNode(node: WTS.Node): boolean
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
648
|
+
function isTopLevelInterfaceNode(node: WTS.Node): boolean {
|
|
649
|
+
return (
|
|
650
|
+
DECLARATION_TYPES.has(node.type) ||
|
|
651
|
+
IMPORT_TYPES.has(node.type) ||
|
|
652
|
+
node.type === "comment" ||
|
|
653
|
+
node.type.startsWith("preproc")
|
|
654
|
+
);
|
|
718
655
|
}
|
|
719
656
|
|
|
720
|
-
function findBody(node: WTS.Node): WTS.Node | undefined
|
|
721
|
-
|
|
722
|
-
const fieldBody = node.childForFieldName("body");
|
|
657
|
+
function findBody(node: WTS.Node): WTS.Node | undefined {
|
|
658
|
+
const fieldBody = node.childForFieldName("body");
|
|
723
659
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
660
|
+
if (fieldBody) {
|
|
661
|
+
return fieldBody;
|
|
662
|
+
}
|
|
728
663
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
664
|
+
return node.namedChildren.find(
|
|
665
|
+
(child) =>
|
|
666
|
+
child.type === "block" ||
|
|
667
|
+
child.type === "compound_statement" ||
|
|
668
|
+
child.type === "statement_block",
|
|
669
|
+
);
|
|
732
670
|
}
|
|
733
671
|
|
|
734
|
-
interface BodyPlaceholder
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
readonly lineSourceLines: readonly (number | undefined)[];
|
|
672
|
+
interface BodyPlaceholder {
|
|
673
|
+
readonly text: string;
|
|
674
|
+
readonly lineSourceLines: readonly (number | undefined)[];
|
|
738
675
|
}
|
|
739
676
|
|
|
740
|
-
function renderBodyPlaceholder(body: WTS.Node, extension: string): BodyPlaceholder
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
const endLine = body.endPosition.row + 1;
|
|
677
|
+
function renderBodyPlaceholder(body: WTS.Node, extension: string): BodyPlaceholder {
|
|
678
|
+
const startLine = body.startPosition.row + 1;
|
|
679
|
+
const endLine = body.endPosition.row + 1;
|
|
744
680
|
|
|
745
|
-
|
|
746
|
-
{
|
|
747
|
-
|
|
748
|
-
}
|
|
681
|
+
if (extension === ".py") {
|
|
682
|
+
return { text: "...", lineSourceLines: [startLine] };
|
|
683
|
+
}
|
|
749
684
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
685
|
+
const bodyLines = body.text.split("\n");
|
|
686
|
+
const firstLine = bodyLines[0] ?? "";
|
|
687
|
+
const lastLine = bodyLines.at(-1) ?? "";
|
|
688
|
+
const openIndex = firstLine.indexOf("{");
|
|
689
|
+
const closeIndex = lastLine.lastIndexOf("}");
|
|
755
690
|
|
|
756
|
-
|
|
757
|
-
{
|
|
758
|
-
|
|
759
|
-
}
|
|
691
|
+
if (openIndex === -1 || closeIndex === -1) {
|
|
692
|
+
return { text: "…", lineSourceLines: [startLine] };
|
|
693
|
+
}
|
|
760
694
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const inner = firstLine.slice(openIndex + 1, closeIndex);
|
|
695
|
+
if (bodyLines.length === 1) {
|
|
696
|
+
const inner = firstLine.slice(openIndex + 1, closeIndex);
|
|
764
697
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
return { text: body.text, lineSourceLines: [startLine] };
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
return {
|
|
771
|
-
text: firstLine.slice(0, openIndex + 1) + maskSegment(inner) + firstLine.slice(closeIndex),
|
|
772
|
-
lineSourceLines: [startLine],
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
const afterOpen = firstLine.slice(openIndex + 1);
|
|
777
|
-
const beforeClose = lastLine.slice(0, closeIndex);
|
|
778
|
-
const interiorHasContent = bodyLines.slice(1, -1).some((line) => line.trim() !== "");
|
|
779
|
-
const firstHasContent = afterOpen.trim() !== "";
|
|
780
|
-
const lastHasContent = beforeClose.trim() !== "";
|
|
781
|
-
|
|
782
|
-
if (!interiorHasContent && !firstHasContent && !lastHasContent)
|
|
783
|
-
{
|
|
784
|
-
return {
|
|
785
|
-
text: body.text,
|
|
786
|
-
lineSourceLines: bodyLines.map((_, index) => startLine + index),
|
|
787
|
-
};
|
|
698
|
+
if (inner.trim() === "") {
|
|
699
|
+
return { text: body.text, lineSourceLines: [startLine] };
|
|
788
700
|
}
|
|
789
701
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
if (!firstHasContent && interiorHasContent)
|
|
796
|
-
{
|
|
797
|
-
const indentation = bodyLines.slice(1, -1).find((line) => line.trim() !== "")?.match(/^\s*/u)?.[0] ?? "";
|
|
798
|
-
output.push(`${indentation}…`);
|
|
799
|
-
lineSourceLines.push(undefined);
|
|
800
|
-
}
|
|
702
|
+
return {
|
|
703
|
+
text: firstLine.slice(0, openIndex + 1) + maskSegment(inner) + firstLine.slice(closeIndex),
|
|
704
|
+
lineSourceLines: [startLine],
|
|
705
|
+
};
|
|
706
|
+
}
|
|
801
707
|
|
|
802
|
-
|
|
803
|
-
|
|
708
|
+
const afterOpen = firstLine.slice(openIndex + 1);
|
|
709
|
+
const beforeClose = lastLine.slice(0, closeIndex);
|
|
710
|
+
const isInteriorHasContent = bodyLines.slice(1, -1).some((line) => line.trim() !== "");
|
|
711
|
+
const isFirstHasContent = afterOpen.trim() !== "";
|
|
712
|
+
const isLastHasContent = beforeClose.trim() !== "";
|
|
804
713
|
|
|
805
|
-
|
|
714
|
+
if (!isInteriorHasContent && !isFirstHasContent && !isLastHasContent) {
|
|
715
|
+
return {
|
|
716
|
+
text: body.text,
|
|
717
|
+
lineSourceLines: bodyLines.map((_, index) => startLine + index),
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
const output: string[] = [];
|
|
722
|
+
const lineSourceLines: (number | undefined)[] = [];
|
|
723
|
+
output.push(
|
|
724
|
+
isFirstHasContent ? firstLine.slice(0, openIndex + 1) + maskSegment(afterOpen) : firstLine,
|
|
725
|
+
);
|
|
726
|
+
lineSourceLines.push(startLine);
|
|
727
|
+
|
|
728
|
+
if (!isFirstHasContent && isInteriorHasContent) {
|
|
729
|
+
const indentation =
|
|
730
|
+
bodyLines
|
|
731
|
+
.slice(1, -1)
|
|
732
|
+
.find((line) => line.trim() !== "")
|
|
733
|
+
?.match(/^\s*/u)?.[0] ?? "";
|
|
734
|
+
output.push(`${indentation}…`);
|
|
735
|
+
lineSourceLines.push(undefined);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
output.push(isLastHasContent ? maskSegment(beforeClose) + lastLine.slice(closeIndex) : lastLine);
|
|
739
|
+
lineSourceLines.push(endLine);
|
|
740
|
+
|
|
741
|
+
return { text: output.join("\n"), lineSourceLines };
|
|
806
742
|
}
|
|
807
743
|
|
|
808
|
-
function maskSegment(segment: string): string
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
return `${leading}…${trailing}`;
|
|
744
|
+
function maskSegment(segment: string): string {
|
|
745
|
+
const leading = /^\s*/u.exec(segment)?.[0] ?? "";
|
|
746
|
+
const trailing = /\s*$/u.exec(segment)?.[0] ?? "";
|
|
747
|
+
return `${leading}…${trailing}`;
|
|
813
748
|
}
|