@jafreck/lore 0.3.5 → 0.3.6
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/README.md +33 -27
- package/dist/cli.js +59 -19
- package/dist/cli.js.map +1 -1
- package/dist/{lore-server/db.d.ts → db/read-only.d.ts} +1 -1
- package/dist/db/read-only.d.ts.map +1 -0
- package/dist/{lore-server/db.js → db/read-only.js} +1 -1
- package/dist/db/read-only.js.map +1 -0
- package/dist/{indexer/db.d.ts → db/schema.d.ts} +1 -1
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/{indexer/db.js → db/schema.js} +3 -3
- package/dist/db/schema.js.map +1 -0
- package/dist/{indexer → discovery}/poller.d.ts +27 -2
- package/dist/discovery/poller.d.ts.map +1 -0
- package/dist/{indexer → discovery}/poller.js +60 -1
- package/dist/discovery/poller.js.map +1 -0
- package/dist/{indexer → discovery}/walker.d.ts +1 -1
- package/dist/discovery/walker.d.ts.map +1 -0
- package/dist/{indexer → discovery}/walker.js +1 -1
- package/dist/discovery/walker.js.map +1 -0
- package/dist/{indexer → discovery}/watcher.d.ts +27 -2
- package/dist/discovery/watcher.d.ts.map +1 -0
- package/dist/{indexer → discovery}/watcher.js +62 -1
- package/dist/discovery/watcher.js.map +1 -0
- package/dist/docs/docs.d.ts.map +1 -0
- package/dist/docs/docs.js.map +1 -0
- package/dist/embeddings/embedder.d.ts.map +1 -0
- package/dist/embeddings/embedder.js.map +1 -0
- package/dist/{indexer/git-history.d.ts → git/history.d.ts} +2 -2
- package/dist/git/history.d.ts.map +1 -0
- package/dist/{indexer/git-history.js → git/history.js} +2 -2
- package/dist/git/history.js.map +1 -0
- package/dist/{indexer/git-hooks.d.ts → git/hooks.d.ts} +2 -1
- package/dist/git/hooks.d.ts.map +1 -0
- package/dist/{indexer/git-hooks.js → git/hooks.js} +5 -4
- package/dist/git/hooks.js.map +1 -0
- package/dist/index.d.ts +29 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/indexer/index.d.ts +9 -6
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js +18 -9
- package/dist/indexer/index.js.map +1 -1
- package/dist/indexer/pipeline.d.ts +36 -10
- package/dist/indexer/pipeline.d.ts.map +1 -1
- package/dist/indexer/pipeline.js +12 -6
- package/dist/indexer/pipeline.js.map +1 -1
- package/dist/indexer/stages/dependency-api.js +4 -4
- package/dist/indexer/stages/dependency-api.js.map +1 -1
- package/dist/indexer/stages/docs-index.d.ts +2 -2
- package/dist/indexer/stages/docs-index.d.ts.map +1 -1
- package/dist/indexer/stages/docs-index.js +2 -2
- package/dist/indexer/stages/docs-index.js.map +1 -1
- package/dist/indexer/stages/embedding.js +2 -2
- package/dist/indexer/stages/embedding.js.map +1 -1
- package/dist/indexer/stages/import-resolution.js +1 -1
- package/dist/indexer/stages/import-resolution.js.map +1 -1
- package/dist/indexer/stages/index.d.ts +2 -0
- package/dist/indexer/stages/index.d.ts.map +1 -1
- package/dist/indexer/stages/index.js +2 -0
- package/dist/indexer/stages/index.js.map +1 -1
- package/dist/indexer/stages/lsp-enrichment.d.ts +2 -2
- package/dist/indexer/stages/lsp-enrichment.d.ts.map +1 -1
- package/dist/indexer/stages/lsp-enrichment.js +131 -6
- package/dist/indexer/stages/lsp-enrichment.js.map +1 -1
- package/dist/indexer/stages/scip-enrichment.d.ts +43 -0
- package/dist/indexer/stages/scip-enrichment.d.ts.map +1 -0
- package/dist/indexer/stages/scip-enrichment.js +174 -0
- package/dist/indexer/stages/scip-enrichment.js.map +1 -0
- package/dist/indexer/stages/scip-source.d.ts +117 -0
- package/dist/indexer/stages/scip-source.d.ts.map +1 -0
- package/dist/indexer/stages/scip-source.js +922 -0
- package/dist/indexer/stages/scip-source.js.map +1 -0
- package/dist/indexer/stages/source-index.d.ts +2 -2
- package/dist/indexer/stages/source-index.d.ts.map +1 -1
- package/dist/indexer/stages/source-index.js +39 -30
- package/dist/indexer/stages/source-index.js.map +1 -1
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/{indexer/lsp → lsp}/client.js +1 -1
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/config.d.ts.map +1 -0
- package/dist/{indexer/lsp → lsp}/config.js +1 -1
- package/dist/lsp/config.js.map +1 -0
- package/dist/lsp/enrichment.d.ts.map +1 -0
- package/dist/lsp/enrichment.js.map +1 -0
- package/dist/lsp/registry.d.ts.map +1 -0
- package/dist/{indexer/lsp → lsp}/registry.js +1 -1
- package/dist/lsp/registry.js.map +1 -0
- package/dist/{indexer → parsing}/complexity.d.ts.map +1 -1
- package/dist/{indexer → parsing}/complexity.js.map +1 -1
- package/dist/{indexer → parsing}/config-parser.d.ts.map +1 -1
- package/dist/{indexer → parsing}/config-parser.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/bash.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/bash.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/c.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/c.js +4 -4
- package/dist/parsing/extractors/c.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/cpp.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/cpp.js +6 -12
- package/dist/parsing/extractors/cpp.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/csharp.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/csharp.js +1 -6
- package/dist/{indexer → parsing}/extractors/csharp.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/elixir.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/elixir.js +10 -15
- package/dist/parsing/extractors/elixir.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/elm.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/elm.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/go.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/go.js +0 -1
- package/dist/parsing/extractors/go.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/haskell.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/haskell.js +2 -4
- package/dist/parsing/extractors/haskell.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/java.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/java.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/javascript.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/javascript.js +23 -3
- package/dist/parsing/extractors/javascript.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/julia.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/julia.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/kotlin.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/kotlin.js +4 -3
- package/dist/{indexer → parsing}/extractors/kotlin.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/lua.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/lua.js +1 -13
- package/dist/parsing/extractors/lua.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/objc.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/objc.js +4 -6
- package/dist/parsing/extractors/objc.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/ocaml.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/ocaml.js +2 -10
- package/dist/parsing/extractors/ocaml.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/php.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/php.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/python.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/python.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/ruby.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/ruby.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/rust.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/rust.js +1 -1
- package/dist/{indexer → parsing}/extractors/rust.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/scala.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/scala.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/swift.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/swift.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/types.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/types.js.map +1 -1
- package/dist/{indexer → parsing}/extractors/typescript.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/typescript.js +45 -19
- package/dist/parsing/extractors/typescript.js.map +1 -0
- package/dist/{indexer → parsing}/extractors/zig.d.ts.map +1 -1
- package/dist/{indexer → parsing}/extractors/zig.js +0 -4
- package/dist/parsing/extractors/zig.js.map +1 -0
- package/dist/{indexer → parsing}/parser.d.ts.map +1 -1
- package/dist/{indexer → parsing}/parser.js.map +1 -1
- package/dist/{indexer → resolution}/call-graph.d.ts +15 -1
- package/dist/resolution/call-graph.d.ts.map +1 -0
- package/dist/{indexer → resolution}/call-graph.js +34 -0
- package/dist/resolution/call-graph.js.map +1 -0
- package/dist/{indexer → resolution}/graph-analysis.d.ts +1 -1
- package/dist/resolution/graph-analysis.d.ts.map +1 -0
- package/dist/resolution/graph-analysis.js.map +1 -0
- package/dist/{indexer → resolution}/resolution-method.d.ts +3 -1
- package/dist/resolution/resolution-method.d.ts.map +1 -0
- package/dist/{indexer → resolution}/resolution-method.js +4 -0
- package/dist/resolution/resolution-method.js.map +1 -0
- package/dist/{indexer → resolution}/resolver.d.ts +1 -1
- package/dist/resolution/resolver.d.ts.map +1 -0
- package/dist/resolution/resolver.js.map +1 -0
- package/dist/runtime.d.ts +6 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -3
- package/dist/runtime.js.map +1 -1
- package/dist/scip/config.d.ts +32 -0
- package/dist/scip/config.d.ts.map +1 -0
- package/dist/scip/config.js +96 -0
- package/dist/scip/config.js.map +1 -0
- package/dist/scip/enrichment.d.ts +56 -0
- package/dist/scip/enrichment.d.ts.map +1 -0
- package/dist/scip/enrichment.js +258 -0
- package/dist/scip/enrichment.js.map +1 -0
- package/dist/scip/index-reader.d.ts +100 -0
- package/dist/scip/index-reader.d.ts.map +1 -0
- package/dist/scip/index-reader.js +225 -0
- package/dist/scip/index-reader.js.map +1 -0
- package/dist/scip/registry.d.ts +51 -0
- package/dist/scip/registry.d.ts.map +1 -0
- package/dist/scip/registry.js +131 -0
- package/dist/scip/registry.js.map +1 -0
- package/dist/scip/scip_pb.d.ts +2118 -0
- package/dist/scip/scip_pb.d.ts.map +1 -0
- package/dist/scip/scip_pb.js +1534 -0
- package/dist/scip/scip_pb.js.map +1 -0
- package/dist/{lore-server → server}/server.d.ts +2 -2
- package/dist/server/server.d.ts.map +1 -0
- package/dist/{lore-server → server}/server.js +3 -3
- package/dist/server/server.js.map +1 -0
- package/dist/{lore-server → server}/tool-registry.d.ts +2 -2
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/{lore-server → server}/tools/annotations.d.ts +2 -2
- package/dist/server/tools/annotations.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/annotations.js +1 -1
- package/dist/server/tools/annotations.js.map +1 -0
- package/dist/{lore-server → server}/tools/architecture.d.ts +1 -1
- package/dist/server/tools/architecture.d.ts.map +1 -0
- package/dist/server/tools/architecture.js.map +1 -0
- package/dist/{lore-server → server}/tools/blame.d.ts +1 -1
- package/dist/server/tools/blame.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/blame.js +1 -1
- package/dist/server/tools/blame.js.map +1 -0
- package/dist/{lore-server → server}/tools/coverage.d.ts +1 -1
- package/dist/server/tools/coverage.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/coverage.js +1 -1
- package/dist/server/tools/coverage.js.map +1 -0
- package/dist/{lore-server → server}/tools/docs.d.ts +3 -3
- package/dist/server/tools/docs.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/docs.js +1 -1
- package/dist/server/tools/docs.js.map +1 -0
- package/dist/{lore-server → server}/tools/graph-analysis.d.ts +2 -2
- package/dist/server/tools/graph-analysis.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/graph-analysis.js +1 -1
- package/dist/server/tools/graph-analysis.js.map +1 -0
- package/dist/{lore-server → server}/tools/graph.d.ts +25 -3
- package/dist/server/tools/graph.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/graph.js +101 -6
- package/dist/server/tools/graph.js.map +1 -0
- package/dist/{lore-server → server}/tools/history.d.ts +3 -3
- package/dist/server/tools/history.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/history.js +1 -1
- package/dist/server/tools/history.js.map +1 -0
- package/dist/{lore-server → server}/tools/lookup.d.ts +2 -2
- package/dist/server/tools/lookup.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/lookup.js +1 -1
- package/dist/server/tools/lookup.js.map +1 -0
- package/dist/{lore-server → server}/tools/metrics.d.ts +2 -2
- package/dist/server/tools/metrics.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/metrics.js +3 -2
- package/dist/server/tools/metrics.js.map +1 -0
- package/dist/{lore-server → server}/tools/notes.d.ts +1 -1
- package/dist/server/tools/notes.d.ts.map +1 -0
- package/dist/server/tools/notes.js.map +1 -0
- package/dist/{lore-server → server}/tools/routes.d.ts +2 -2
- package/dist/server/tools/routes.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/routes.js +1 -1
- package/dist/server/tools/routes.js.map +1 -0
- package/dist/{lore-server → server}/tools/search.d.ts +2 -2
- package/dist/server/tools/search.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/search.js +1 -1
- package/dist/server/tools/search.js.map +1 -0
- package/dist/{lore-server → server}/tools/snippet.d.ts +1 -1
- package/dist/server/tools/snippet.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/snippet.js +1 -1
- package/dist/server/tools/snippet.js.map +1 -0
- package/dist/{lore-server → server}/tools/test-map.d.ts +1 -1
- package/dist/server/tools/test-map.d.ts.map +1 -0
- package/dist/{lore-server → server}/tools/test-map.js +1 -1
- package/dist/server/tools/test-map.js.map +1 -0
- package/dist/server/tools/writeback.d.ts.map +1 -0
- package/dist/server/tools/writeback.js.map +1 -0
- package/dist/{indexer → testing}/coverage.d.ts +1 -1
- package/dist/testing/coverage.d.ts.map +1 -0
- package/dist/{indexer → testing}/coverage.js.map +1 -1
- package/dist/{indexer → testing}/test-mapper.d.ts +1 -1
- package/dist/testing/test-mapper.d.ts.map +1 -0
- package/dist/{indexer → testing}/test-mapper.js.map +1 -1
- package/package.json +12 -9
- package/dist/indexer/call-graph.d.ts.map +0 -1
- package/dist/indexer/call-graph.js.map +0 -1
- package/dist/indexer/coverage.d.ts.map +0 -1
- package/dist/indexer/db.d.ts.map +0 -1
- package/dist/indexer/db.js.map +0 -1
- package/dist/indexer/docs.d.ts.map +0 -1
- package/dist/indexer/docs.js.map +0 -1
- package/dist/indexer/embedder.d.ts.map +0 -1
- package/dist/indexer/embedder.js.map +0 -1
- package/dist/indexer/extractors/c.js.map +0 -1
- package/dist/indexer/extractors/cpp.js.map +0 -1
- package/dist/indexer/extractors/elixir.js.map +0 -1
- package/dist/indexer/extractors/go.js.map +0 -1
- package/dist/indexer/extractors/haskell.js.map +0 -1
- package/dist/indexer/extractors/javascript.js.map +0 -1
- package/dist/indexer/extractors/lua.js.map +0 -1
- package/dist/indexer/extractors/objc.js.map +0 -1
- package/dist/indexer/extractors/ocaml.js.map +0 -1
- package/dist/indexer/extractors/typescript.js.map +0 -1
- package/dist/indexer/extractors/zig.js.map +0 -1
- package/dist/indexer/git-history.d.ts.map +0 -1
- package/dist/indexer/git-history.js.map +0 -1
- package/dist/indexer/git-hooks.d.ts.map +0 -1
- package/dist/indexer/git-hooks.js.map +0 -1
- package/dist/indexer/graph-analysis.d.ts.map +0 -1
- package/dist/indexer/graph-analysis.js.map +0 -1
- package/dist/indexer/lsp/client.d.ts.map +0 -1
- package/dist/indexer/lsp/client.js.map +0 -1
- package/dist/indexer/lsp/config.d.ts.map +0 -1
- package/dist/indexer/lsp/config.js.map +0 -1
- package/dist/indexer/lsp/enrichment.d.ts.map +0 -1
- package/dist/indexer/lsp/enrichment.js.map +0 -1
- package/dist/indexer/lsp/registry.d.ts.map +0 -1
- package/dist/indexer/lsp/registry.js.map +0 -1
- package/dist/indexer/poller.d.ts.map +0 -1
- package/dist/indexer/poller.js.map +0 -1
- package/dist/indexer/resolution-method.d.ts.map +0 -1
- package/dist/indexer/resolution-method.js.map +0 -1
- package/dist/indexer/resolver.d.ts.map +0 -1
- package/dist/indexer/resolver.js.map +0 -1
- package/dist/indexer/test-mapper.d.ts.map +0 -1
- package/dist/indexer/walker.d.ts.map +0 -1
- package/dist/indexer/walker.js.map +0 -1
- package/dist/indexer/watcher.d.ts.map +0 -1
- package/dist/indexer/watcher.js.map +0 -1
- package/dist/lore-server/db.d.ts.map +0 -1
- package/dist/lore-server/db.js.map +0 -1
- package/dist/lore-server/server.d.ts.map +0 -1
- package/dist/lore-server/server.js.map +0 -1
- package/dist/lore-server/tool-registry.d.ts.map +0 -1
- package/dist/lore-server/tool-registry.js.map +0 -1
- package/dist/lore-server/tools/annotations.d.ts.map +0 -1
- package/dist/lore-server/tools/annotations.js.map +0 -1
- package/dist/lore-server/tools/architecture.d.ts.map +0 -1
- package/dist/lore-server/tools/architecture.js.map +0 -1
- package/dist/lore-server/tools/blame.d.ts.map +0 -1
- package/dist/lore-server/tools/blame.js.map +0 -1
- package/dist/lore-server/tools/coverage.d.ts.map +0 -1
- package/dist/lore-server/tools/coverage.js.map +0 -1
- package/dist/lore-server/tools/docs.d.ts.map +0 -1
- package/dist/lore-server/tools/docs.js.map +0 -1
- package/dist/lore-server/tools/graph-analysis.d.ts.map +0 -1
- package/dist/lore-server/tools/graph-analysis.js.map +0 -1
- package/dist/lore-server/tools/graph.d.ts.map +0 -1
- package/dist/lore-server/tools/graph.js.map +0 -1
- package/dist/lore-server/tools/history.d.ts.map +0 -1
- package/dist/lore-server/tools/history.js.map +0 -1
- package/dist/lore-server/tools/lookup.d.ts.map +0 -1
- package/dist/lore-server/tools/lookup.js.map +0 -1
- package/dist/lore-server/tools/metrics.d.ts.map +0 -1
- package/dist/lore-server/tools/metrics.js.map +0 -1
- package/dist/lore-server/tools/notes.d.ts.map +0 -1
- package/dist/lore-server/tools/notes.js.map +0 -1
- package/dist/lore-server/tools/routes.d.ts.map +0 -1
- package/dist/lore-server/tools/routes.js.map +0 -1
- package/dist/lore-server/tools/search.d.ts.map +0 -1
- package/dist/lore-server/tools/search.js.map +0 -1
- package/dist/lore-server/tools/snippet.d.ts.map +0 -1
- package/dist/lore-server/tools/snippet.js.map +0 -1
- package/dist/lore-server/tools/test-map.d.ts.map +0 -1
- package/dist/lore-server/tools/test-map.js.map +0 -1
- package/dist/lore-server/tools/writeback.d.ts.map +0 -1
- package/dist/lore-server/tools/writeback.js.map +0 -1
- /package/dist/{indexer → docs}/docs.d.ts +0 -0
- /package/dist/{indexer → docs}/docs.js +0 -0
- /package/dist/{indexer → embeddings}/embedder.d.ts +0 -0
- /package/dist/{indexer → embeddings}/embedder.js +0 -0
- /package/dist/{indexer/lsp → lsp}/client.d.ts +0 -0
- /package/dist/{indexer/lsp → lsp}/config.d.ts +0 -0
- /package/dist/{indexer/lsp → lsp}/enrichment.d.ts +0 -0
- /package/dist/{indexer/lsp → lsp}/enrichment.js +0 -0
- /package/dist/{indexer/lsp → lsp}/registry.d.ts +0 -0
- /package/dist/{indexer → parsing}/complexity.d.ts +0 -0
- /package/dist/{indexer → parsing}/complexity.js +0 -0
- /package/dist/{indexer → parsing}/config-parser.d.ts +0 -0
- /package/dist/{indexer → parsing}/config-parser.js +0 -0
- /package/dist/{indexer → parsing}/extractors/bash.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/bash.js +0 -0
- /package/dist/{indexer → parsing}/extractors/c.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/cpp.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/csharp.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/elixir.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/elm.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/elm.js +0 -0
- /package/dist/{indexer → parsing}/extractors/go.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/haskell.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/java.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/java.js +0 -0
- /package/dist/{indexer → parsing}/extractors/javascript.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/julia.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/julia.js +0 -0
- /package/dist/{indexer → parsing}/extractors/kotlin.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/lua.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/objc.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/ocaml.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/php.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/php.js +0 -0
- /package/dist/{indexer → parsing}/extractors/python.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/python.js +0 -0
- /package/dist/{indexer → parsing}/extractors/ruby.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/ruby.js +0 -0
- /package/dist/{indexer → parsing}/extractors/rust.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/scala.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/scala.js +0 -0
- /package/dist/{indexer → parsing}/extractors/swift.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/swift.js +0 -0
- /package/dist/{indexer → parsing}/extractors/types.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/types.js +0 -0
- /package/dist/{indexer → parsing}/extractors/typescript.d.ts +0 -0
- /package/dist/{indexer → parsing}/extractors/zig.d.ts +0 -0
- /package/dist/{indexer → parsing}/parser.d.ts +0 -0
- /package/dist/{indexer → parsing}/parser.js +0 -0
- /package/dist/{indexer → resolution}/graph-analysis.js +0 -0
- /package/dist/{indexer → resolution}/resolver.js +0 -0
- /package/dist/{lore-server → server}/tool-registry.js +0 -0
- /package/dist/{lore-server → server}/tools/architecture.js +0 -0
- /package/dist/{lore-server → server}/tools/notes.js +0 -0
- /package/dist/{lore-server → server}/tools/writeback.d.ts +0 -0
- /package/dist/{lore-server → server}/tools/writeback.js +0 -0
- /package/dist/{indexer → testing}/coverage.js +0 -0
- /package/dist/{indexer → testing}/test-mapper.js +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module indexer/scip/enrichment
|
|
3
|
+
*
|
|
4
|
+
* `ScipEnrichmentCoordinator` drives the SCIP enrichment workflow:
|
|
5
|
+
*
|
|
6
|
+
* 1. Run SCIP indexers (or read pre-computed index files) for each language.
|
|
7
|
+
* 2. Parse the resulting protobuf indexes into in-memory lookup structures.
|
|
8
|
+
* 3. For a batch of targets (file + position), resolve each to its
|
|
9
|
+
* definition location and type signature using the SCIP data.
|
|
10
|
+
*
|
|
11
|
+
* Returns the same `ResolvedTypeMetadata` shape as the LSP enrichment
|
|
12
|
+
* coordinator, so the enrichment stage and resolution stage are agnostic
|
|
13
|
+
* to the enrichment source.
|
|
14
|
+
*/
|
|
15
|
+
import type { ResolvedTypeMetadata } from '../lsp/enrichment.js';
|
|
16
|
+
import type { EffectiveScipSettings } from './config.js';
|
|
17
|
+
export interface ScipEnrichmentTarget {
|
|
18
|
+
line: number;
|
|
19
|
+
character: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ScipEnrichmentRequest {
|
|
22
|
+
filePath: string;
|
|
23
|
+
language: string;
|
|
24
|
+
source: string;
|
|
25
|
+
targets: readonly ScipEnrichmentTarget[];
|
|
26
|
+
}
|
|
27
|
+
export declare class ScipEnrichmentCoordinator {
|
|
28
|
+
private readonly settings;
|
|
29
|
+
private readonly rootDir;
|
|
30
|
+
private readonly resolvedIndexers;
|
|
31
|
+
/** Merged SCIP index data from all indexer runs. */
|
|
32
|
+
private indexData;
|
|
33
|
+
/** Languages for which SCIP indexing succeeded. */
|
|
34
|
+
private readonly enrichedLanguages;
|
|
35
|
+
constructor(settings: EffectiveScipSettings, rootDir: string);
|
|
36
|
+
/**
|
|
37
|
+
* Run SCIP indexers (or load pre-computed indexes) for the given languages.
|
|
38
|
+
* Must be called before `enrich()`.
|
|
39
|
+
*
|
|
40
|
+
* @returns Set of languages for which SCIP data is available.
|
|
41
|
+
*/
|
|
42
|
+
start(languages: Iterable<string>): Promise<ReadonlySet<string>>;
|
|
43
|
+
/**
|
|
44
|
+
* Enrich a batch of targets with SCIP-derived metadata.
|
|
45
|
+
*
|
|
46
|
+
* Returns an array parallel to `request.targets` — each entry is either
|
|
47
|
+
* a `ResolvedTypeMetadata` or `null` (no SCIP data for that position).
|
|
48
|
+
*/
|
|
49
|
+
enrich(request: ScipEnrichmentRequest): Array<ResolvedTypeMetadata | null>;
|
|
50
|
+
/** Set of languages for which SCIP enrichment data is available. */
|
|
51
|
+
get coveredLanguages(): ReadonlySet<string>;
|
|
52
|
+
dispose(): Promise<void>;
|
|
53
|
+
private readPrecomputedIndex;
|
|
54
|
+
private runIndexer;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=enrichment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.d.ts","sourceRoot":"","sources":["../../src/scip/enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAazD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC1C;AAID,qBAAa,yBAAyB;IASlC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAR3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6C;IAC9E,oDAAoD;IACpD,OAAO,CAAC,SAAS,CAA8B;IAC/C,mDAAmD;IACnD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;gBAGpC,QAAQ,EAAE,qBAAqB,EAChD,OAAO,EAAE,MAAM;IAMjB;;;;;OAKG;IACG,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAgFtE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA0C1E,oEAAoE;IACpE,IAAI,gBAAgB,IAAI,WAAW,CAAC,MAAM,CAAC,CAE1C;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B,OAAO,CAAC,oBAAoB;YAiBd,UAAU;CA+DzB"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module indexer/scip/enrichment
|
|
3
|
+
*
|
|
4
|
+
* `ScipEnrichmentCoordinator` drives the SCIP enrichment workflow:
|
|
5
|
+
*
|
|
6
|
+
* 1. Run SCIP indexers (or read pre-computed index files) for each language.
|
|
7
|
+
* 2. Parse the resulting protobuf indexes into in-memory lookup structures.
|
|
8
|
+
* 3. For a batch of targets (file + position), resolve each to its
|
|
9
|
+
* definition location and type signature using the SCIP data.
|
|
10
|
+
*
|
|
11
|
+
* Returns the same `ResolvedTypeMetadata` shape as the LSP enrichment
|
|
12
|
+
* coordinator, so the enrichment stage and resolution stage are agnostic
|
|
13
|
+
* to the enrichment source.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync, unlinkSync } from 'node:fs';
|
|
16
|
+
import { join } from 'node:path';
|
|
17
|
+
import { execFileSync } from 'node:child_process';
|
|
18
|
+
import { pathToFileURL } from 'node:url';
|
|
19
|
+
import { resolveScipIndexerRegistry, SCIP_SUPPORTED_LANGUAGES } from './registry.js';
|
|
20
|
+
import { parseScipIndex, extractSignatureFromDocs, extractReturnType, } from './index-reader.js';
|
|
21
|
+
import { getLogger } from '../logger.js';
|
|
22
|
+
// ─── Coordinator ──────────────────────────────────────────────────────────────
|
|
23
|
+
export class ScipEnrichmentCoordinator {
|
|
24
|
+
settings;
|
|
25
|
+
rootDir;
|
|
26
|
+
resolvedIndexers;
|
|
27
|
+
/** Merged SCIP index data from all indexer runs. */
|
|
28
|
+
indexData = null;
|
|
29
|
+
/** Languages for which SCIP indexing succeeded. */
|
|
30
|
+
enrichedLanguages = new Set();
|
|
31
|
+
constructor(settings, rootDir) {
|
|
32
|
+
this.settings = settings;
|
|
33
|
+
this.rootDir = rootDir;
|
|
34
|
+
this.resolvedIndexers = resolveScipIndexerRegistry(settings.indexers);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run SCIP indexers (or load pre-computed indexes) for the given languages.
|
|
38
|
+
* Must be called before `enrich()`.
|
|
39
|
+
*
|
|
40
|
+
* @returns Set of languages for which SCIP data is available.
|
|
41
|
+
*/
|
|
42
|
+
async start(languages) {
|
|
43
|
+
if (!this.settings.enabled)
|
|
44
|
+
return this.enrichedLanguages;
|
|
45
|
+
const log = getLogger();
|
|
46
|
+
const uniqueLanguages = new Set(languages);
|
|
47
|
+
// Determine which languages have SCIP coverage.
|
|
48
|
+
const toProcess = new Set();
|
|
49
|
+
for (const lang of uniqueLanguages) {
|
|
50
|
+
if (SCIP_SUPPORTED_LANGUAGES.has(lang)) {
|
|
51
|
+
const resolved = this.resolvedIndexers[lang];
|
|
52
|
+
if (resolved?.available || this.settings.indexDir) {
|
|
53
|
+
toProcess.add(lang);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (toProcess.size === 0) {
|
|
58
|
+
log.indexing('scip: no indexers available for requested languages');
|
|
59
|
+
return this.enrichedLanguages;
|
|
60
|
+
}
|
|
61
|
+
// Group languages by shared indexer command to avoid running the same
|
|
62
|
+
// indexer multiple times (e.g., scip-java for java + scala + kotlin).
|
|
63
|
+
const commandGroups = new Map();
|
|
64
|
+
for (const lang of toProcess) {
|
|
65
|
+
const resolved = this.resolvedIndexers[lang];
|
|
66
|
+
const key = resolved ? resolved.command : `indexDir:${lang}`;
|
|
67
|
+
if (!commandGroups.has(key))
|
|
68
|
+
commandGroups.set(key, new Set());
|
|
69
|
+
commandGroups.get(key).add(lang);
|
|
70
|
+
}
|
|
71
|
+
for (const [commandKey, langs] of commandGroups) {
|
|
72
|
+
const representativeLang = langs.values().next().value;
|
|
73
|
+
try {
|
|
74
|
+
let indexBuffer = null;
|
|
75
|
+
if (this.settings.indexDir) {
|
|
76
|
+
// Read pre-computed index from the configured directory.
|
|
77
|
+
indexBuffer = this.readPrecomputedIndex(representativeLang);
|
|
78
|
+
}
|
|
79
|
+
if (!indexBuffer) {
|
|
80
|
+
// Run the SCIP indexer.
|
|
81
|
+
indexBuffer = await this.runIndexer(representativeLang);
|
|
82
|
+
}
|
|
83
|
+
if (indexBuffer) {
|
|
84
|
+
const parsed = parseScipIndex(indexBuffer, this.rootDir);
|
|
85
|
+
// Merge documents and symbols into the combined index.
|
|
86
|
+
for (const lang of langs) {
|
|
87
|
+
this.enrichedLanguages.add(lang);
|
|
88
|
+
}
|
|
89
|
+
// Re-parse and merge (the parsed data is self-contained per ScipIndexData).
|
|
90
|
+
// For a proper merge we need to transfer data. Since our parsing is
|
|
91
|
+
// cheap, just re-assign if single or accumulate:
|
|
92
|
+
if (this.indexData === null) {
|
|
93
|
+
this.indexData = parsed;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// Merge by re-parsing into the existing index.
|
|
97
|
+
// This is a design limitation — for now, multiple indexes are
|
|
98
|
+
// handled by re-reading. A future optimisation could merge the
|
|
99
|
+
// ScipIndexData structures directly.
|
|
100
|
+
this.indexData = mergeScipIndexDataPartial(this.indexData, parsed);
|
|
101
|
+
}
|
|
102
|
+
log.indexing(`scip: loaded index for ${[...langs].join(', ')}`, {
|
|
103
|
+
files: parsed.fileCount,
|
|
104
|
+
definitions: parsed.definitionCount,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
110
|
+
log.indexing(`scip: indexer failed for ${[...langs].join(', ')}: ${msg}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return this.enrichedLanguages;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Enrich a batch of targets with SCIP-derived metadata.
|
|
117
|
+
*
|
|
118
|
+
* Returns an array parallel to `request.targets` — each entry is either
|
|
119
|
+
* a `ResolvedTypeMetadata` or `null` (no SCIP data for that position).
|
|
120
|
+
*/
|
|
121
|
+
enrich(request) {
|
|
122
|
+
const empty = request.targets.map(() => null);
|
|
123
|
+
if (!this.indexData || !this.enrichedLanguages.has(request.language)) {
|
|
124
|
+
return empty;
|
|
125
|
+
}
|
|
126
|
+
const results = [];
|
|
127
|
+
for (const target of request.targets) {
|
|
128
|
+
const occ = this.indexData.findOccurrence(request.filePath, target.line, target.character);
|
|
129
|
+
if (!occ || !occ.symbol) {
|
|
130
|
+
results.push(null);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
// Resolve definition location.
|
|
134
|
+
const def = this.indexData.getDefinition(occ.symbol);
|
|
135
|
+
const info = this.indexData.getSymbolInfo(occ.symbol);
|
|
136
|
+
// Extract type signature.
|
|
137
|
+
const resolvedTypeSignature = info ? extractSignatureFromDocs(info) : null;
|
|
138
|
+
const resolvedReturnType = extractReturnType(resolvedTypeSignature);
|
|
139
|
+
if (!def && !resolvedTypeSignature) {
|
|
140
|
+
results.push(null);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const definitionUri = def ? pathToFileURL(def.filePath).toString() : null;
|
|
144
|
+
results.push({
|
|
145
|
+
resolvedTypeSignature,
|
|
146
|
+
resolvedReturnType,
|
|
147
|
+
definitionUri,
|
|
148
|
+
definitionPath: def?.filePath ?? null,
|
|
149
|
+
definitionLine: def?.line ?? null,
|
|
150
|
+
definitionCharacter: def?.character ?? null,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return results;
|
|
154
|
+
}
|
|
155
|
+
/** Set of languages for which SCIP enrichment data is available. */
|
|
156
|
+
get coveredLanguages() {
|
|
157
|
+
return this.enrichedLanguages;
|
|
158
|
+
}
|
|
159
|
+
async dispose() {
|
|
160
|
+
this.indexData = null;
|
|
161
|
+
this.enrichedLanguages.clear();
|
|
162
|
+
}
|
|
163
|
+
// ─── Private helpers ──────────────────────────────────────────────────────
|
|
164
|
+
readPrecomputedIndex(language) {
|
|
165
|
+
if (!this.settings.indexDir)
|
|
166
|
+
return null;
|
|
167
|
+
// Check for language-specific index or generic index.scip.
|
|
168
|
+
const candidates = [
|
|
169
|
+
join(this.rootDir, this.settings.indexDir, `${language}.scip`),
|
|
170
|
+
join(this.rootDir, this.settings.indexDir, 'index.scip'),
|
|
171
|
+
];
|
|
172
|
+
for (const candidate of candidates) {
|
|
173
|
+
if (existsSync(candidate)) {
|
|
174
|
+
return readFileSync(candidate);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
async runIndexer(language) {
|
|
180
|
+
const resolved = this.resolvedIndexers[language];
|
|
181
|
+
if (!resolved?.available)
|
|
182
|
+
return null;
|
|
183
|
+
const log = getLogger();
|
|
184
|
+
const outputPath = join(this.rootDir, `.lore-scip-${language}.scip`);
|
|
185
|
+
// Replace {output} placeholder in args.
|
|
186
|
+
const args = resolved.args.map((arg) => arg.replace(/\{output\}/gu, outputPath));
|
|
187
|
+
const cwd = resolved.cwd ? join(this.rootDir, resolved.cwd) : this.rootDir;
|
|
188
|
+
log.indexing(`scip: running ${resolved.command} for ${language}`);
|
|
189
|
+
try {
|
|
190
|
+
execFileSync(resolved.command, args, {
|
|
191
|
+
cwd,
|
|
192
|
+
timeout: this.settings.timeoutMs,
|
|
193
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
194
|
+
encoding: 'utf8',
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
199
|
+
log.indexing(`scip: ${resolved.command} failed: ${msg}`);
|
|
200
|
+
// rust-analyzer scip writes to index.scip in cwd, not to {output}.
|
|
201
|
+
// Check if it wrote to the default location.
|
|
202
|
+
const defaultOutput = join(cwd, 'index.scip');
|
|
203
|
+
if (existsSync(defaultOutput) && defaultOutput !== outputPath) {
|
|
204
|
+
try {
|
|
205
|
+
const data = readFileSync(defaultOutput);
|
|
206
|
+
unlinkSync(defaultOutput);
|
|
207
|
+
return data;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
// Fall through to return null.
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
// Read the output.
|
|
216
|
+
// Some indexers write to the specified path; others write to index.scip.
|
|
217
|
+
const candidatePaths = [outputPath, join(cwd, 'index.scip')];
|
|
218
|
+
for (const candidate of candidatePaths) {
|
|
219
|
+
if (existsSync(candidate)) {
|
|
220
|
+
try {
|
|
221
|
+
const data = readFileSync(candidate);
|
|
222
|
+
// Clean up temporary files.
|
|
223
|
+
if (candidate.includes('.lore-scip-')) {
|
|
224
|
+
try {
|
|
225
|
+
unlinkSync(candidate);
|
|
226
|
+
}
|
|
227
|
+
catch { /* best effort */ }
|
|
228
|
+
}
|
|
229
|
+
return data;
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
log.indexing(`scip: ${resolved.command} completed but no index file found`);
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// ─── Merge helper ─────────────────────────────────────────────────────────────
|
|
241
|
+
/**
|
|
242
|
+
* Partial merge of two ScipIndexData instances.
|
|
243
|
+
* In practice we re-parse the protobuf bytes, so this is a simple
|
|
244
|
+
* "use the second index" fallback. A full merge would iterate the
|
|
245
|
+
* internal maps, but for the common case (one indexer per run) this
|
|
246
|
+
* is sufficient.
|
|
247
|
+
*/
|
|
248
|
+
function mergeScipIndexDataPartial(a, b) {
|
|
249
|
+
// For now, since ScipIndexData doesn't expose its internal maps for
|
|
250
|
+
// iteration, we rely on the coordinator loading indexes sequentially
|
|
251
|
+
// and always use the latest one. A proper merge would require adding
|
|
252
|
+
// a `merge()` method to ScipIndexData.
|
|
253
|
+
//
|
|
254
|
+
// TODO: Implement proper merge across multiple SCIP indexes.
|
|
255
|
+
// For single-language projects (the common case), `b` is sufficient.
|
|
256
|
+
return b;
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=enrichment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.js","sourceRoot":"","sources":["../../src/scip/enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAA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BACjC,CAAC;YACH,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,mBAAmB;QACnB,yEAAyE;QACzE,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;QAC7D,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;YACvC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;oBACrC,4BAA4B;oBAC5B,IAAI,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;wBACtC,IAAI,CAAC;4BAAC,UAAU,CAAC,SAAS,CAAC,CAAC;wBAAC,CAAC;wBAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;oBAC5D,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;gBAAC,MAAM,CAAC;oBACP,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,GAAG,CAAC,QAAQ,CAAC,SAAS,QAAQ,CAAC,OAAO,oCAAoC,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,iFAAiF;AAEjF;;;;;;GAMG;AACH,SAAS,yBAAyB,CAAC,CAAgB,EAAE,CAAgB;IACnE,oEAAoE;IACpE,qEAAqE;IACrE,sEAAsE;IACtE,uCAAuC;IACvC,EAAE;IACF,6DAA6D;IAC7D,qEAAqE;IACrE,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module indexer/scip/index-reader
|
|
3
|
+
*
|
|
4
|
+
* Parses a SCIP index (protobuf binary) into in-memory lookup structures
|
|
5
|
+
* that the enrichment coordinator can query by file + position.
|
|
6
|
+
*
|
|
7
|
+
* Uses the official SCIP protobuf schema (vendored `scip_pb.ts`) with
|
|
8
|
+
* `@bufbuild/protobuf` for decoding — no manual wire-format parsing.
|
|
9
|
+
*
|
|
10
|
+
* ## SCIP data model (relevant subset)
|
|
11
|
+
*
|
|
12
|
+
* - `Index.documents[]` — per-file occurrences and symbol definitions
|
|
13
|
+
* - `Index.external_symbols[]` — hover docs for symbols from other packages
|
|
14
|
+
* - `Occurrence.range` — `[startLine, startChar, endChar]` (3-elem) or
|
|
15
|
+
* `[startLine, startChar, endLine, endChar]` (4-elem), 0-based
|
|
16
|
+
* - `Occurrence.symbol_roles` — bitset; bit 0 = Definition
|
|
17
|
+
* - `SymbolInformation.documentation` — markdown hover text
|
|
18
|
+
* - `SymbolInformation.signature_documentation` — structured signature
|
|
19
|
+
*/
|
|
20
|
+
import { type Document as ScipDocument, type SymbolInformation as ScipSymbolInformation } from './scip_pb.js';
|
|
21
|
+
export interface ScipDefinitionLocation {
|
|
22
|
+
/** Absolute path to the file containing the definition. */
|
|
23
|
+
filePath: string;
|
|
24
|
+
/** 0-based line number. */
|
|
25
|
+
line: number;
|
|
26
|
+
/** 0-based character offset. */
|
|
27
|
+
character: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ScipSymbolInfo {
|
|
30
|
+
symbol: string;
|
|
31
|
+
documentation: string[];
|
|
32
|
+
displayName: string;
|
|
33
|
+
signatureText: string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface ScipOccurrenceRecord {
|
|
36
|
+
startLine: number;
|
|
37
|
+
startCharacter: number;
|
|
38
|
+
endLine: number;
|
|
39
|
+
endCharacter: number;
|
|
40
|
+
symbol: string;
|
|
41
|
+
isDefinition: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* In-memory SCIP index optimised for enrichment lookups.
|
|
45
|
+
*
|
|
46
|
+
* Given a file path + position, returns the definition location and
|
|
47
|
+
* type signature for the symbol at that position.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ScipIndexData {
|
|
50
|
+
private readonly projectRoot;
|
|
51
|
+
/** symbol → definition location */
|
|
52
|
+
private readonly definitions;
|
|
53
|
+
/** symbol → metadata (docs, display name, signature) */
|
|
54
|
+
private readonly symbolInfo;
|
|
55
|
+
/** absolute file path → sorted occurrences */
|
|
56
|
+
private readonly fileOccurrences;
|
|
57
|
+
/** Set of languages present in this index */
|
|
58
|
+
readonly languages: Set<string>;
|
|
59
|
+
constructor(projectRoot: string);
|
|
60
|
+
addDocument(doc: ScipDocument): void;
|
|
61
|
+
addExternalSymbol(sym: ScipSymbolInformation): void;
|
|
62
|
+
/**
|
|
63
|
+
* Look up the occurrence at (or nearest to) the given position in a file.
|
|
64
|
+
*/
|
|
65
|
+
findOccurrence(filePath: string, line: number, character: number): ScipOccurrenceRecord | null;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a SCIP symbol string to its definition location.
|
|
68
|
+
*/
|
|
69
|
+
getDefinition(symbol: string): ScipDefinitionLocation | null;
|
|
70
|
+
/**
|
|
71
|
+
* Get symbol metadata (documentation, signature).
|
|
72
|
+
*/
|
|
73
|
+
getSymbolInfo(symbol: string): ScipSymbolInfo | null;
|
|
74
|
+
/** Number of indexed files. */
|
|
75
|
+
get fileCount(): number;
|
|
76
|
+
/** Number of unique symbols with known definition locations. */
|
|
77
|
+
get definitionCount(): number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parse a SCIP protobuf index from raw bytes.
|
|
81
|
+
*
|
|
82
|
+
* @param buffer The raw protobuf bytes (e.g. `fs.readFileSync(path)`).
|
|
83
|
+
* @param projectRoot Absolute path to the project root. Document
|
|
84
|
+
* `relative_path` values are resolved against this.
|
|
85
|
+
* @returns Populated `ScipIndexData` ready for enrichment queries.
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseScipIndex(buffer: Uint8Array, projectRoot: string): ScipIndexData;
|
|
88
|
+
/**
|
|
89
|
+
* Extract a human-readable type signature from SCIP symbol documentation.
|
|
90
|
+
*
|
|
91
|
+
* Strips markdown code fences and extracts the first meaningful line,
|
|
92
|
+
* similar to how the LSP enrichment extracts hover text.
|
|
93
|
+
*/
|
|
94
|
+
export declare function extractSignatureFromDocs(info: ScipSymbolInfo): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Extract a return type from a type signature string.
|
|
97
|
+
* Reuses the same heuristics as LSP enrichment.
|
|
98
|
+
*/
|
|
99
|
+
export declare function extractReturnType(signature: string | null): string | null;
|
|
100
|
+
//# sourceMappingURL=index-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-reader.d.ts","sourceRoot":"","sources":["../../src/scip/index-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAIL,KAAK,QAAQ,IAAI,YAAY,EAE7B,KAAK,iBAAiB,IAAI,qBAAqB,EAChD,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IAUZ,OAAO,CAAC,QAAQ,CAAC,WAAW;IATxC,mCAAmC;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6C;IACzE,wDAAwD;IACxD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqC;IAChE,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6C;IAC7E,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,cAAqB;gBAEV,WAAW,EAAE,MAAM;IAEhD,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI;IA0CpC,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI;IAMnD;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI;IAmC9F;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAI5D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAIpD,+BAA+B;IAC/B,IAAI,SAAS,IAAI,MAAM,CAAsC;IAE7D,gEAAgE;IAChE,IAAI,eAAe,IAAI,MAAM,CAAkC;CAChE;AAeD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAYrF;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAqB5E;AAWD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAgBzE"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module indexer/scip/index-reader
|
|
3
|
+
*
|
|
4
|
+
* Parses a SCIP index (protobuf binary) into in-memory lookup structures
|
|
5
|
+
* that the enrichment coordinator can query by file + position.
|
|
6
|
+
*
|
|
7
|
+
* Uses the official SCIP protobuf schema (vendored `scip_pb.ts`) with
|
|
8
|
+
* `@bufbuild/protobuf` for decoding — no manual wire-format parsing.
|
|
9
|
+
*
|
|
10
|
+
* ## SCIP data model (relevant subset)
|
|
11
|
+
*
|
|
12
|
+
* - `Index.documents[]` — per-file occurrences and symbol definitions
|
|
13
|
+
* - `Index.external_symbols[]` — hover docs for symbols from other packages
|
|
14
|
+
* - `Occurrence.range` — `[startLine, startChar, endChar]` (3-elem) or
|
|
15
|
+
* `[startLine, startChar, endLine, endChar]` (4-elem), 0-based
|
|
16
|
+
* - `Occurrence.symbol_roles` — bitset; bit 0 = Definition
|
|
17
|
+
* - `SymbolInformation.documentation` — markdown hover text
|
|
18
|
+
* - `SymbolInformation.signature_documentation` — structured signature
|
|
19
|
+
*/
|
|
20
|
+
import { resolve } from 'node:path';
|
|
21
|
+
import { fromBinary } from '@bufbuild/protobuf';
|
|
22
|
+
import { IndexSchema, SymbolRole, } from './scip_pb.js';
|
|
23
|
+
/**
|
|
24
|
+
* In-memory SCIP index optimised for enrichment lookups.
|
|
25
|
+
*
|
|
26
|
+
* Given a file path + position, returns the definition location and
|
|
27
|
+
* type signature for the symbol at that position.
|
|
28
|
+
*/
|
|
29
|
+
export class ScipIndexData {
|
|
30
|
+
projectRoot;
|
|
31
|
+
/** symbol → definition location */
|
|
32
|
+
definitions = new Map();
|
|
33
|
+
/** symbol → metadata (docs, display name, signature) */
|
|
34
|
+
symbolInfo = new Map();
|
|
35
|
+
/** absolute file path → sorted occurrences */
|
|
36
|
+
fileOccurrences = new Map();
|
|
37
|
+
/** Set of languages present in this index */
|
|
38
|
+
languages = new Set();
|
|
39
|
+
constructor(projectRoot) {
|
|
40
|
+
this.projectRoot = projectRoot;
|
|
41
|
+
}
|
|
42
|
+
addDocument(doc) {
|
|
43
|
+
const absPath = resolve(this.projectRoot, doc.relativePath);
|
|
44
|
+
if (doc.language)
|
|
45
|
+
this.languages.add(doc.language.toLowerCase());
|
|
46
|
+
const records = [];
|
|
47
|
+
for (const occ of doc.occurrences) {
|
|
48
|
+
const range = occ.range;
|
|
49
|
+
if (range.length < 3)
|
|
50
|
+
continue;
|
|
51
|
+
const startLine = range[0];
|
|
52
|
+
const startChar = range[1];
|
|
53
|
+
const endLine = range.length >= 4 ? range[2] : startLine;
|
|
54
|
+
const endChar = range.length >= 4 ? range[3] : range[2];
|
|
55
|
+
const isDefinition = (occ.symbolRoles & SymbolRole.Definition) !== 0;
|
|
56
|
+
records.push({
|
|
57
|
+
startLine,
|
|
58
|
+
startCharacter: startChar,
|
|
59
|
+
endLine,
|
|
60
|
+
endCharacter: endChar,
|
|
61
|
+
symbol: occ.symbol,
|
|
62
|
+
isDefinition,
|
|
63
|
+
});
|
|
64
|
+
// Register definition locations.
|
|
65
|
+
if (isDefinition && occ.symbol && !occ.symbol.startsWith('local ')) {
|
|
66
|
+
if (!this.definitions.has(occ.symbol)) {
|
|
67
|
+
this.definitions.set(occ.symbol, { filePath: absPath, line: startLine, character: startChar });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Sort by (startLine, startCharacter) for binary search.
|
|
72
|
+
records.sort((a, b) => a.startLine - b.startLine || a.startCharacter - b.startCharacter);
|
|
73
|
+
this.fileOccurrences.set(absPath, records);
|
|
74
|
+
// Index symbol info from document-level symbols.
|
|
75
|
+
for (const sym of doc.symbols) {
|
|
76
|
+
if (sym.symbol) {
|
|
77
|
+
this.symbolInfo.set(sym.symbol, toScipSymbolInfo(sym));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
addExternalSymbol(sym) {
|
|
82
|
+
if (sym.symbol) {
|
|
83
|
+
this.symbolInfo.set(sym.symbol, toScipSymbolInfo(sym));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Look up the occurrence at (or nearest to) the given position in a file.
|
|
88
|
+
*/
|
|
89
|
+
findOccurrence(filePath, line, character) {
|
|
90
|
+
const occs = this.fileOccurrences.get(filePath);
|
|
91
|
+
if (!occs || occs.length === 0)
|
|
92
|
+
return null;
|
|
93
|
+
// Binary search for the first occurrence on this line.
|
|
94
|
+
let lo = 0;
|
|
95
|
+
let hi = occs.length;
|
|
96
|
+
while (lo < hi) {
|
|
97
|
+
const mid = (lo + hi) >>> 1;
|
|
98
|
+
if (occs[mid].startLine < line)
|
|
99
|
+
lo = mid + 1;
|
|
100
|
+
else
|
|
101
|
+
hi = mid;
|
|
102
|
+
}
|
|
103
|
+
// Scan forward through occurrences on this line to find the best match.
|
|
104
|
+
let best = null;
|
|
105
|
+
let bestDistance = Infinity;
|
|
106
|
+
for (let i = lo; i < occs.length && occs[i].startLine === line; i++) {
|
|
107
|
+
const occ = occs[i];
|
|
108
|
+
// Exact containment: character is within the occurrence range.
|
|
109
|
+
if (character >= occ.startCharacter && (occ.endLine > line || character <= occ.endCharacter)) {
|
|
110
|
+
return occ;
|
|
111
|
+
}
|
|
112
|
+
// Nearest on the same line.
|
|
113
|
+
const dist = Math.abs(occ.startCharacter - character);
|
|
114
|
+
if (dist < bestDistance) {
|
|
115
|
+
bestDistance = dist;
|
|
116
|
+
best = occ;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Allow a nearby match (within 5 characters) on the same line.
|
|
120
|
+
return bestDistance <= 5 ? best : null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resolve a SCIP symbol string to its definition location.
|
|
124
|
+
*/
|
|
125
|
+
getDefinition(symbol) {
|
|
126
|
+
return this.definitions.get(symbol) ?? null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get symbol metadata (documentation, signature).
|
|
130
|
+
*/
|
|
131
|
+
getSymbolInfo(symbol) {
|
|
132
|
+
return this.symbolInfo.get(symbol) ?? null;
|
|
133
|
+
}
|
|
134
|
+
/** Number of indexed files. */
|
|
135
|
+
get fileCount() { return this.fileOccurrences.size; }
|
|
136
|
+
/** Number of unique symbols with known definition locations. */
|
|
137
|
+
get definitionCount() { return this.definitions.size; }
|
|
138
|
+
}
|
|
139
|
+
// ─── Protobuf → internal type conversion ──────────────────────────────────────
|
|
140
|
+
function toScipSymbolInfo(sym) {
|
|
141
|
+
return {
|
|
142
|
+
symbol: sym.symbol,
|
|
143
|
+
documentation: [...sym.documentation],
|
|
144
|
+
displayName: sym.displayName,
|
|
145
|
+
signatureText: sym.signatureDocumentation?.text || null,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
149
|
+
/**
|
|
150
|
+
* Parse a SCIP protobuf index from raw bytes.
|
|
151
|
+
*
|
|
152
|
+
* @param buffer The raw protobuf bytes (e.g. `fs.readFileSync(path)`).
|
|
153
|
+
* @param projectRoot Absolute path to the project root. Document
|
|
154
|
+
* `relative_path` values are resolved against this.
|
|
155
|
+
* @returns Populated `ScipIndexData` ready for enrichment queries.
|
|
156
|
+
*/
|
|
157
|
+
export function parseScipIndex(buffer, projectRoot) {
|
|
158
|
+
const decoded = fromBinary(IndexSchema, buffer);
|
|
159
|
+
const index = new ScipIndexData(projectRoot);
|
|
160
|
+
for (const doc of decoded.documents) {
|
|
161
|
+
index.addDocument(doc);
|
|
162
|
+
}
|
|
163
|
+
for (const sym of decoded.externalSymbols) {
|
|
164
|
+
index.addExternalSymbol(sym);
|
|
165
|
+
}
|
|
166
|
+
return index;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Extract a human-readable type signature from SCIP symbol documentation.
|
|
170
|
+
*
|
|
171
|
+
* Strips markdown code fences and extracts the first meaningful line,
|
|
172
|
+
* similar to how the LSP enrichment extracts hover text.
|
|
173
|
+
*/
|
|
174
|
+
export function extractSignatureFromDocs(info) {
|
|
175
|
+
// Prefer signature_documentation text.
|
|
176
|
+
if (info.signatureText) {
|
|
177
|
+
const cleaned = info.signatureText
|
|
178
|
+
.replace(/```[a-z0-9_+-]*\n/giu, '')
|
|
179
|
+
.replace(/```/gu, '')
|
|
180
|
+
.trim();
|
|
181
|
+
return cleaned || null;
|
|
182
|
+
}
|
|
183
|
+
// Fall back to first documentation entry that looks like a signature.
|
|
184
|
+
for (const doc of info.documentation) {
|
|
185
|
+
const cleaned = doc
|
|
186
|
+
.replace(/```[a-z0-9_+-]*\n/giu, '')
|
|
187
|
+
.replace(/```/gu, '')
|
|
188
|
+
.trim();
|
|
189
|
+
if (cleaned && looksLikeSignature(cleaned)) {
|
|
190
|
+
return cleaned;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
/** Heuristic: does this text look like a code signature? */
|
|
196
|
+
function looksLikeSignature(text) {
|
|
197
|
+
const firstLine = text.split('\n')[0] ?? '';
|
|
198
|
+
return /(?:function|def|fn|func|class|interface|type|const|let|var|pub|export|public|private|protected)\s/u.test(firstLine)
|
|
199
|
+
|| /\(.*\)/u.test(firstLine)
|
|
200
|
+
|| /:\s*\w/u.test(firstLine)
|
|
201
|
+
|| /->\s*\w/u.test(firstLine);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Extract a return type from a type signature string.
|
|
205
|
+
* Reuses the same heuristics as LSP enrichment.
|
|
206
|
+
*/
|
|
207
|
+
export function extractReturnType(signature) {
|
|
208
|
+
if (!signature)
|
|
209
|
+
return null;
|
|
210
|
+
const lines = signature.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
211
|
+
if (lines.length === 0)
|
|
212
|
+
return null;
|
|
213
|
+
const firstLine = lines[0];
|
|
214
|
+
const functionStyle = firstLine.match(/\)\s*:\s*([^={]+)$/u);
|
|
215
|
+
if (functionStyle?.[1])
|
|
216
|
+
return functionStyle[1].trim();
|
|
217
|
+
const arrowStyle = firstLine.match(/->\s*([^={]+)$/u);
|
|
218
|
+
if (arrowStyle?.[1])
|
|
219
|
+
return arrowStyle[1].trim();
|
|
220
|
+
const colonStyle = firstLine.match(/:\s*([^={]+)$/u);
|
|
221
|
+
if (colonStyle?.[1])
|
|
222
|
+
return colonStyle[1].trim();
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=index-reader.js.map
|