@optave/codegraph 3.7.0 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -16
- package/dist/ast-analysis/engine.d.ts.map +1 -1
- package/dist/ast-analysis/engine.js +195 -30
- package/dist/ast-analysis/engine.js.map +1 -1
- package/dist/ast-analysis/metrics.d.ts +0 -3
- package/dist/ast-analysis/metrics.d.ts.map +1 -1
- package/dist/ast-analysis/metrics.js +30 -13
- package/dist/ast-analysis/metrics.js.map +1 -1
- package/dist/ast-analysis/rules/javascript.d.ts.map +1 -1
- package/dist/ast-analysis/rules/javascript.js +0 -1
- package/dist/ast-analysis/rules/javascript.js.map +1 -1
- package/dist/ast-analysis/shared.d.ts.map +1 -1
- package/dist/ast-analysis/shared.js +24 -19
- package/dist/ast-analysis/shared.js.map +1 -1
- package/dist/ast-analysis/visitor-utils.d.ts.map +1 -1
- package/dist/ast-analysis/visitor-utils.js +55 -39
- package/dist/ast-analysis/visitor-utils.js.map +1 -1
- package/dist/ast-analysis/visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitor.js +91 -70
- package/dist/ast-analysis/visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/ast-store-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/ast-store-visitor.js +52 -129
- package/dist/ast-analysis/visitors/ast-store-visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/complexity-visitor.js +32 -39
- package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.js +57 -38
- package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -1
- package/dist/cli/commands/ast.js +2 -2
- package/dist/cli/commands/ast.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +16 -2
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +29 -26
- package/dist/db/connection.js.map +1 -1
- package/dist/db/query-builder.d.ts.map +1 -1
- package/dist/db/query-builder.js +16 -5
- package/dist/db/query-builder.js.map +1 -1
- package/dist/db/repository/base.d.ts +10 -0
- package/dist/db/repository/base.d.ts.map +1 -1
- package/dist/db/repository/base.js +17 -0
- package/dist/db/repository/base.js.map +1 -1
- package/dist/db/repository/native-repository.d.ts +6 -1
- package/dist/db/repository/native-repository.d.ts.map +1 -1
- package/dist/db/repository/native-repository.js +77 -1
- package/dist/db/repository/native-repository.js.map +1 -1
- package/dist/db/repository/nodes.d.ts.map +1 -1
- package/dist/db/repository/nodes.js +8 -4
- package/dist/db/repository/nodes.js.map +1 -1
- package/dist/db/repository/sqlite-repository.d.ts +3 -0
- package/dist/db/repository/sqlite-repository.d.ts.map +1 -1
- package/dist/db/repository/sqlite-repository.js +26 -0
- package/dist/db/repository/sqlite-repository.js.map +1 -1
- package/dist/domain/analysis/brief.d.ts.map +1 -1
- package/dist/domain/analysis/brief.js +13 -17
- package/dist/domain/analysis/brief.js.map +1 -1
- package/dist/domain/analysis/context.d.ts.map +1 -1
- package/dist/domain/analysis/context.js +14 -11
- package/dist/domain/analysis/context.js.map +1 -1
- package/dist/domain/analysis/dependencies.d.ts.map +1 -1
- package/dist/domain/analysis/dependencies.js +53 -52
- package/dist/domain/analysis/dependencies.js.map +1 -1
- package/dist/domain/analysis/fn-impact.d.ts +2 -7
- package/dist/domain/analysis/fn-impact.d.ts.map +1 -1
- package/dist/domain/analysis/fn-impact.js +33 -31
- package/dist/domain/analysis/fn-impact.js.map +1 -1
- package/dist/domain/analysis/implementations.d.ts.map +1 -1
- package/dist/domain/analysis/implementations.js +11 -19
- package/dist/domain/analysis/implementations.js.map +1 -1
- package/dist/domain/analysis/module-map.d.ts.map +1 -1
- package/dist/domain/analysis/module-map.js +55 -76
- package/dist/domain/analysis/module-map.js.map +1 -1
- package/dist/domain/analysis/query-helpers.d.ts +7 -0
- package/dist/domain/analysis/query-helpers.d.ts.map +1 -1
- package/dist/domain/analysis/query-helpers.js +15 -1
- package/dist/domain/analysis/query-helpers.js.map +1 -1
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
- package/dist/domain/graph/builder/pipeline.js +315 -43
- package/dist/domain/graph/builder/pipeline.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.js +106 -1
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.js +17 -5
- package/dist/domain/graph/builder/stages/collect-files.js.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js +99 -51
- package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.js +34 -7
- package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
- package/dist/domain/graph/builder/stages/insert-nodes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/insert-nodes.js +50 -26
- package/dist/domain/graph/builder/stages/insert-nodes.js.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js +95 -84
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
- package/dist/domain/graph/cycles.d.ts +6 -0
- package/dist/domain/graph/cycles.d.ts.map +1 -1
- package/dist/domain/graph/cycles.js +114 -22
- package/dist/domain/graph/cycles.js.map +1 -1
- package/dist/domain/graph/resolve.js +1 -1
- package/dist/domain/graph/resolve.js.map +1 -1
- package/dist/domain/graph/watcher.d.ts +2 -0
- package/dist/domain/graph/watcher.d.ts.map +1 -1
- package/dist/domain/graph/watcher.js +170 -75
- package/dist/domain/graph/watcher.js.map +1 -1
- package/dist/domain/parser.d.ts +1 -6
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +101 -32
- package/dist/domain/parser.js.map +1 -1
- package/dist/domain/search/generator.js +1 -1
- package/dist/domain/search/generator.js.map +1 -1
- package/dist/domain/search/models.d.ts +4 -3
- package/dist/domain/search/models.d.ts.map +1 -1
- package/dist/domain/search/models.js +18 -5
- package/dist/domain/search/models.js.map +1 -1
- package/dist/domain/search/search/hybrid.d.ts.map +1 -1
- package/dist/domain/search/search/hybrid.js +29 -18
- package/dist/domain/search/search/hybrid.js.map +1 -1
- package/dist/extractors/clojure.d.ts +12 -0
- package/dist/extractors/clojure.d.ts.map +1 -0
- package/dist/extractors/clojure.js +245 -0
- package/dist/extractors/clojure.js.map +1 -0
- package/dist/extractors/cuda.d.ts +11 -0
- package/dist/extractors/cuda.d.ts.map +1 -0
- package/dist/extractors/cuda.js +302 -0
- package/dist/extractors/cuda.js.map +1 -0
- package/dist/extractors/erlang.d.ts +14 -0
- package/dist/extractors/erlang.d.ts.map +1 -0
- package/dist/extractors/erlang.js +239 -0
- package/dist/extractors/erlang.js.map +1 -0
- package/dist/extractors/fsharp.d.ts +13 -0
- package/dist/extractors/fsharp.d.ts.map +1 -0
- package/dist/extractors/fsharp.js +218 -0
- package/dist/extractors/fsharp.js.map +1 -0
- package/dist/extractors/gleam.d.ts +14 -0
- package/dist/extractors/gleam.d.ts.map +1 -0
- package/dist/extractors/gleam.js +229 -0
- package/dist/extractors/gleam.js.map +1 -0
- package/dist/extractors/go.js +36 -33
- package/dist/extractors/go.js.map +1 -1
- package/dist/extractors/groovy.d.ts +10 -0
- package/dist/extractors/groovy.d.ts.map +1 -0
- package/dist/extractors/groovy.js +304 -0
- package/dist/extractors/groovy.js.map +1 -0
- package/dist/extractors/helpers.d.ts.map +1 -1
- package/dist/extractors/helpers.js +40 -29
- package/dist/extractors/helpers.js.map +1 -1
- package/dist/extractors/index.d.ts +11 -0
- package/dist/extractors/index.d.ts.map +1 -1
- package/dist/extractors/index.js +11 -0
- package/dist/extractors/index.js.map +1 -1
- package/dist/extractors/java.js +58 -46
- package/dist/extractors/java.js.map +1 -1
- package/dist/extractors/javascript.js +46 -45
- package/dist/extractors/javascript.js.map +1 -1
- package/dist/extractors/julia.d.ts +16 -0
- package/dist/extractors/julia.d.ts.map +1 -0
- package/dist/extractors/julia.js +287 -0
- package/dist/extractors/julia.js.map +1 -0
- package/dist/extractors/kotlin.js +84 -78
- package/dist/extractors/kotlin.js.map +1 -1
- package/dist/extractors/objc.d.ts +9 -0
- package/dist/extractors/objc.d.ts.map +1 -0
- package/dist/extractors/objc.js +406 -0
- package/dist/extractors/objc.js.map +1 -0
- package/dist/extractors/ocaml.js +74 -0
- package/dist/extractors/ocaml.js.map +1 -1
- package/dist/extractors/python.js +29 -24
- package/dist/extractors/python.js.map +1 -1
- package/dist/extractors/r.d.ts +13 -0
- package/dist/extractors/r.d.ts.map +1 -0
- package/dist/extractors/r.js +251 -0
- package/dist/extractors/r.js.map +1 -0
- package/dist/extractors/rust.js +41 -32
- package/dist/extractors/rust.js.map +1 -1
- package/dist/extractors/solidity.d.ts +9 -0
- package/dist/extractors/solidity.d.ts.map +1 -0
- package/dist/extractors/solidity.js +365 -0
- package/dist/extractors/solidity.js.map +1 -0
- package/dist/extractors/swift.js +83 -81
- package/dist/extractors/swift.js.map +1 -1
- package/dist/extractors/verilog.d.ts +9 -0
- package/dist/extractors/verilog.d.ts.map +1 -0
- package/dist/extractors/verilog.js +286 -0
- package/dist/extractors/verilog.js.map +1 -0
- package/dist/extractors/zig.js +58 -60
- package/dist/extractors/zig.js.map +1 -1
- package/dist/features/ast.d.ts +16 -14
- package/dist/features/ast.d.ts.map +1 -1
- package/dist/features/ast.js +84 -83
- package/dist/features/ast.js.map +1 -1
- package/dist/features/audit.d.ts.map +1 -1
- package/dist/features/audit.js +8 -6
- package/dist/features/audit.js.map +1 -1
- package/dist/features/branch-compare.d.ts.map +1 -1
- package/dist/features/branch-compare.js +69 -72
- package/dist/features/branch-compare.js.map +1 -1
- package/dist/features/communities.d.ts.map +1 -1
- package/dist/features/communities.js +19 -7
- package/dist/features/communities.js.map +1 -1
- package/dist/features/complexity.d.ts.map +1 -1
- package/dist/features/complexity.js +120 -125
- package/dist/features/complexity.js.map +1 -1
- package/dist/features/dataflow.d.ts.map +1 -1
- package/dist/features/dataflow.js +136 -137
- package/dist/features/dataflow.js.map +1 -1
- package/dist/features/flow.d.ts.map +1 -1
- package/dist/features/flow.js +84 -79
- package/dist/features/flow.js.map +1 -1
- package/dist/features/structure-query.d.ts.map +1 -1
- package/dist/features/structure-query.js +69 -65
- package/dist/features/structure-query.js.map +1 -1
- package/dist/graph/algorithms/bfs.d.ts +2 -0
- package/dist/graph/algorithms/bfs.d.ts.map +1 -1
- package/dist/graph/algorithms/bfs.js +27 -0
- package/dist/graph/algorithms/bfs.js.map +1 -1
- package/dist/graph/algorithms/centrality.d.ts +2 -0
- package/dist/graph/algorithms/centrality.d.ts.map +1 -1
- package/dist/graph/algorithms/centrality.js +28 -0
- package/dist/graph/algorithms/centrality.js.map +1 -1
- package/dist/graph/algorithms/leiden/optimiser.d.ts.map +1 -1
- package/dist/graph/algorithms/leiden/optimiser.js +70 -55
- package/dist/graph/algorithms/leiden/optimiser.js.map +1 -1
- package/dist/graph/algorithms/leiden/partition.d.ts.map +1 -1
- package/dist/graph/algorithms/leiden/partition.js +288 -266
- package/dist/graph/algorithms/leiden/partition.js.map +1 -1
- package/dist/graph/algorithms/louvain.d.ts +3 -4
- package/dist/graph/algorithms/louvain.d.ts.map +1 -1
- package/dist/graph/algorithms/louvain.js +29 -0
- package/dist/graph/algorithms/louvain.js.map +1 -1
- package/dist/graph/algorithms/shortest-path.d.ts +2 -0
- package/dist/graph/algorithms/shortest-path.d.ts.map +1 -1
- package/dist/graph/algorithms/shortest-path.js +18 -1
- package/dist/graph/algorithms/shortest-path.js.map +1 -1
- package/dist/graph/model.d.ts.map +1 -1
- package/dist/graph/model.js +5 -1
- package/dist/graph/model.js.map +1 -1
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +6 -4
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/infrastructure/suppress.d.ts +25 -0
- package/dist/infrastructure/suppress.d.ts.map +1 -0
- package/dist/infrastructure/suppress.js +43 -0
- package/dist/infrastructure/suppress.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +29 -24
- package/dist/mcp/server.js.map +1 -1
- package/dist/presentation/dataflow.d.ts.map +1 -1
- package/dist/presentation/dataflow.js +47 -38
- package/dist/presentation/dataflow.js.map +1 -1
- package/dist/presentation/diff-impact-mermaid.d.ts.map +1 -1
- package/dist/presentation/diff-impact-mermaid.js +60 -51
- package/dist/presentation/diff-impact-mermaid.js.map +1 -1
- package/dist/presentation/queries-cli/exports.d.ts.map +1 -1
- package/dist/presentation/queries-cli/exports.js +20 -14
- package/dist/presentation/queries-cli/exports.js.map +1 -1
- package/dist/presentation/queries-cli/impact.d.ts.map +1 -1
- package/dist/presentation/queries-cli/impact.js +15 -13
- package/dist/presentation/queries-cli/impact.js.map +1 -1
- package/dist/presentation/queries-cli/inspect.d.ts.map +1 -1
- package/dist/presentation/queries-cli/inspect.js +101 -79
- package/dist/presentation/queries-cli/inspect.js.map +1 -1
- package/dist/presentation/queries-cli/overview.d.ts.map +1 -1
- package/dist/presentation/queries-cli/overview.js +25 -16
- package/dist/presentation/queries-cli/overview.js.map +1 -1
- package/dist/presentation/queries-cli/path.js +26 -20
- package/dist/presentation/queries-cli/path.js.map +1 -1
- package/dist/presentation/result-formatter.d.ts +10 -0
- package/dist/presentation/result-formatter.d.ts.map +1 -1
- package/dist/presentation/result-formatter.js +16 -1
- package/dist/presentation/result-formatter.js.map +1 -1
- package/dist/presentation/viewer.d.ts.map +1 -1
- package/dist/presentation/viewer.js +18 -12
- package/dist/presentation/viewer.js.map +1 -1
- package/dist/shared/errors.d.ts +5 -0
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +5 -0
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/hierarchy.d.ts +8 -2
- package/dist/shared/hierarchy.d.ts.map +1 -1
- package/dist/shared/hierarchy.js +42 -1
- package/dist/shared/hierarchy.js.map +1 -1
- package/dist/shared/normalize.d.ts +6 -1
- package/dist/shared/normalize.d.ts.map +1 -1
- package/dist/shared/normalize.js +20 -12
- package/dist/shared/normalize.js.map +1 -1
- package/dist/shared/paginate.d.ts +0 -9
- package/dist/shared/paginate.d.ts.map +1 -1
- package/dist/shared/paginate.js +0 -15
- package/dist/shared/paginate.js.map +1 -1
- package/dist/types.d.ts +129 -3
- package/dist/types.d.ts.map +1 -1
- package/grammars/tree-sitter-clojure.wasm +0 -0
- package/grammars/tree-sitter-cuda.wasm +0 -0
- package/grammars/tree-sitter-erlang.wasm +0 -0
- package/grammars/tree-sitter-fsharp.wasm +0 -0
- package/grammars/tree-sitter-gleam.wasm +0 -0
- package/grammars/tree-sitter-groovy.wasm +0 -0
- package/grammars/tree-sitter-julia.wasm +0 -0
- package/grammars/tree-sitter-objc.wasm +0 -0
- package/grammars/tree-sitter-ocaml_interface.wasm +0 -0
- package/grammars/tree-sitter-r.wasm +0 -0
- package/grammars/tree-sitter-solidity.wasm +0 -0
- package/grammars/tree-sitter-verilog.wasm +0 -0
- package/package.json +18 -7
- package/src/ast-analysis/engine.ts +245 -42
- package/src/ast-analysis/metrics.ts +33 -11
- package/src/ast-analysis/rules/javascript.ts +0 -1
- package/src/ast-analysis/shared.ts +33 -24
- package/src/ast-analysis/visitor-utils.ts +52 -32
- package/src/ast-analysis/visitor.ts +132 -71
- package/src/ast-analysis/visitors/ast-store-visitor.ts +49 -119
- package/src/ast-analysis/visitors/complexity-visitor.ts +35 -40
- package/src/ast-analysis/visitors/dataflow-visitor.ts +87 -43
- package/src/cli/commands/ast.ts +2 -2
- package/src/cli/commands/watch.ts +16 -2
- package/src/db/connection.ts +29 -28
- package/src/db/query-builder.ts +15 -3
- package/src/db/repository/base.ts +20 -0
- package/src/db/repository/native-repository.ts +79 -1
- package/src/db/repository/nodes.ts +13 -8
- package/src/db/repository/sqlite-repository.ts +29 -0
- package/src/domain/analysis/brief.ts +15 -25
- package/src/domain/analysis/context.ts +17 -10
- package/src/domain/analysis/dependencies.ts +67 -76
- package/src/domain/analysis/fn-impact.ts +36 -43
- package/src/domain/analysis/implementations.ts +11 -17
- package/src/domain/analysis/module-map.ts +58 -92
- package/src/domain/analysis/query-helpers.ts +18 -1
- package/src/domain/graph/builder/pipeline.ts +366 -41
- package/src/domain/graph/builder/stages/build-edges.ts +162 -1
- package/src/domain/graph/builder/stages/collect-files.ts +18 -7
- package/src/domain/graph/builder/stages/detect-changes.ts +110 -56
- package/src/domain/graph/builder/stages/finalize.ts +41 -11
- package/src/domain/graph/builder/stages/insert-nodes.ts +75 -39
- package/src/domain/graph/builder/stages/resolve-imports.ts +122 -100
- package/src/domain/graph/cycles.ts +110 -23
- package/src/domain/graph/resolve.ts +1 -1
- package/src/domain/graph/watcher.ts +202 -96
- package/src/domain/parser.ts +122 -28
- package/src/domain/search/generator.ts +1 -1
- package/src/domain/search/models.ts +17 -4
- package/src/domain/search/search/hybrid.ts +69 -51
- package/src/extractors/clojure.ts +273 -0
- package/src/extractors/cuda.ts +316 -0
- package/src/extractors/erlang.ts +252 -0
- package/src/extractors/fsharp.ts +253 -0
- package/src/extractors/gleam.ts +246 -0
- package/src/extractors/go.ts +43 -33
- package/src/extractors/groovy.ts +332 -0
- package/src/extractors/helpers.ts +37 -23
- package/src/extractors/index.ts +11 -0
- package/src/extractors/java.ts +66 -47
- package/src/extractors/javascript.ts +45 -46
- package/src/extractors/julia.ts +318 -0
- package/src/extractors/kotlin.ts +84 -77
- package/src/extractors/objc.ts +431 -0
- package/src/extractors/ocaml.ts +78 -0
- package/src/extractors/python.ts +31 -25
- package/src/extractors/r.ts +253 -0
- package/src/extractors/rust.ts +37 -29
- package/src/extractors/solidity.ts +394 -0
- package/src/extractors/swift.ts +81 -80
- package/src/extractors/verilog.ts +315 -0
- package/src/extractors/zig.ts +58 -61
- package/src/features/ast.ts +131 -112
- package/src/features/audit.ts +8 -6
- package/src/features/branch-compare.ts +105 -79
- package/src/features/communities.ts +25 -10
- package/src/features/complexity.ts +171 -134
- package/src/features/dataflow.ts +165 -175
- package/src/features/flow.ts +129 -92
- package/src/features/structure-query.ts +79 -64
- package/src/graph/algorithms/bfs.ts +34 -0
- package/src/graph/algorithms/centrality.ts +30 -0
- package/src/graph/algorithms/leiden/optimiser.ts +99 -55
- package/src/graph/algorithms/leiden/partition.ts +359 -294
- package/src/graph/algorithms/louvain.ts +31 -4
- package/src/graph/algorithms/shortest-path.ts +20 -1
- package/src/graph/model.ts +6 -1
- package/src/infrastructure/config.ts +6 -4
- package/src/infrastructure/suppress.ts +47 -0
- package/src/mcp/server.ts +53 -37
- package/src/presentation/dataflow.ts +50 -44
- package/src/presentation/diff-impact-mermaid.ts +104 -62
- package/src/presentation/queries-cli/exports.ts +21 -13
- package/src/presentation/queries-cli/impact.ts +15 -13
- package/src/presentation/queries-cli/inspect.ts +100 -81
- package/src/presentation/queries-cli/overview.ts +26 -16
- package/src/presentation/queries-cli/path.ts +33 -25
- package/src/presentation/result-formatter.ts +19 -1
- package/src/presentation/viewer.ts +42 -14
- package/src/shared/errors.ts +6 -0
- package/src/shared/hierarchy.ts +50 -2
- package/src/shared/normalize.ts +31 -12
- package/src/shared/paginate.ts +0 -17
- package/src/types.ts +138 -3
|
@@ -25,45 +25,51 @@ export interface HybridSearchResult {
|
|
|
25
25
|
results: HybridResult[];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.split(';')
|
|
43
|
-
.map((q) => q.trim())
|
|
44
|
-
.filter((q) => q.length > 0)
|
|
45
|
-
: [query];
|
|
28
|
+
interface RankedItem {
|
|
29
|
+
key: string;
|
|
30
|
+
rank: number;
|
|
31
|
+
source: 'bm25' | 'semantic';
|
|
32
|
+
name: string;
|
|
33
|
+
kind: string;
|
|
34
|
+
file: string;
|
|
35
|
+
line: number;
|
|
36
|
+
endLine?: number | null;
|
|
37
|
+
role?: string | null;
|
|
38
|
+
fileHash?: string | null;
|
|
39
|
+
bm25Score?: number;
|
|
40
|
+
similarity?: number;
|
|
41
|
+
}
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
interface FusionEntry {
|
|
44
|
+
name: string;
|
|
45
|
+
kind: string;
|
|
46
|
+
file: string;
|
|
47
|
+
line: number;
|
|
48
|
+
endLine: number | null;
|
|
49
|
+
role: string | null;
|
|
50
|
+
fileHash: string | null;
|
|
51
|
+
rrfScore: number;
|
|
52
|
+
bm25Score: number | null;
|
|
53
|
+
bm25Rank: number | null;
|
|
54
|
+
similarity: number | null;
|
|
55
|
+
semanticRank: number | null;
|
|
56
|
+
}
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
line: number;
|
|
60
|
-
endLine?: number | null;
|
|
61
|
-
role?: string | null;
|
|
62
|
-
fileHash?: string | null;
|
|
63
|
-
bm25Score?: number;
|
|
64
|
-
similarity?: number;
|
|
65
|
-
}
|
|
58
|
+
/** Parse a semicolon-delimited query string into individual queries. */
|
|
59
|
+
function parseQueries(query: string): string[] {
|
|
60
|
+
return query
|
|
61
|
+
.split(';')
|
|
62
|
+
.map((q) => q.trim())
|
|
63
|
+
.filter((q) => q.length > 0);
|
|
64
|
+
}
|
|
66
65
|
|
|
66
|
+
/** Collect BM25 and semantic ranked lists for each query. */
|
|
67
|
+
async function collectRankedLists(
|
|
68
|
+
queries: string[],
|
|
69
|
+
customDbPath: string | undefined,
|
|
70
|
+
opts: SemanticSearchOpts,
|
|
71
|
+
topK: number,
|
|
72
|
+
): Promise<RankedItem[][]> {
|
|
67
73
|
const rankedLists: RankedItem[][] = [];
|
|
68
74
|
|
|
69
75
|
for (const q of queries) {
|
|
@@ -96,22 +102,13 @@ export async function hybridSearchData(
|
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
kind: string;
|
|
102
|
-
file: string;
|
|
103
|
-
line: number;
|
|
104
|
-
endLine: number | null;
|
|
105
|
-
role: string | null;
|
|
106
|
-
fileHash: string | null;
|
|
107
|
-
rrfScore: number;
|
|
108
|
-
bm25Score: number | null;
|
|
109
|
-
bm25Rank: number | null;
|
|
110
|
-
similarity: number | null;
|
|
111
|
-
semanticRank: number | null;
|
|
112
|
-
}
|
|
105
|
+
return rankedLists;
|
|
106
|
+
}
|
|
113
107
|
|
|
108
|
+
/** Reciprocal Rank Fusion: merge ranked lists into a single scored result set. */
|
|
109
|
+
function fuseResults(rankedLists: RankedItem[][], k: number, limit: number): HybridResult[] {
|
|
114
110
|
const fusionMap = new Map<string, FusionEntry>();
|
|
111
|
+
|
|
115
112
|
for (const list of rankedLists) {
|
|
116
113
|
for (const item of list) {
|
|
117
114
|
if (!fusionMap.has(item.key)) {
|
|
@@ -146,7 +143,7 @@ export async function hybridSearchData(
|
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
145
|
|
|
149
|
-
|
|
146
|
+
return [...fusionMap.values()]
|
|
150
147
|
.sort((a, b) => b.rrfScore - a.rrfScore)
|
|
151
148
|
.slice(0, limit)
|
|
152
149
|
.map((e) => ({
|
|
@@ -163,6 +160,27 @@ export async function hybridSearchData(
|
|
|
163
160
|
similarity: e.similarity,
|
|
164
161
|
semanticRank: e.semanticRank,
|
|
165
162
|
}));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function hybridSearchData(
|
|
166
|
+
query: string,
|
|
167
|
+
customDbPath: string | undefined,
|
|
168
|
+
opts: SemanticSearchOpts = {},
|
|
169
|
+
): Promise<HybridSearchResult | null> {
|
|
170
|
+
const config = opts.config || loadConfig();
|
|
171
|
+
const searchCfg = config.search || ({} as CodegraphConfig['search']);
|
|
172
|
+
const limit = opts.limit ?? searchCfg.topK ?? 15;
|
|
173
|
+
const k = opts.rrfK ?? searchCfg.rrfK ?? 60;
|
|
174
|
+
const topK = (opts.limit ?? searchCfg.topK ?? 15) * 5;
|
|
175
|
+
|
|
176
|
+
const checkDb = openReadonlyOrFail(customDbPath) as BetterSqlite3Database;
|
|
177
|
+
const ftsAvailable = hasFtsIndex(checkDb);
|
|
178
|
+
checkDb.close();
|
|
179
|
+
if (!ftsAvailable) return null;
|
|
180
|
+
|
|
181
|
+
const queries = parseQueries(query);
|
|
182
|
+
const rankedLists = await collectRankedLists(queries, customDbPath, opts, topK);
|
|
183
|
+
const results = fuseResults(rankedLists, k, limit);
|
|
166
184
|
|
|
167
185
|
return { results };
|
|
168
186
|
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import type { ExtractorOutput, SubDeclaration, TreeSitterNode, TreeSitterTree } from '../types.js';
|
|
2
|
+
import { nodeEndLine } from './helpers.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extract symbols from Clojure files.
|
|
6
|
+
*
|
|
7
|
+
* Clojure tree-sitter grammar (sogaiu/tree-sitter-clojure) notes:
|
|
8
|
+
* - The grammar is minimal: everything is a list/vector/map/symbol
|
|
9
|
+
* - We detect definitions by the first symbol in a list: defn, def, defprotocol, etc.
|
|
10
|
+
* - Namespace: (ns name ...)
|
|
11
|
+
* - Imports: (:require ...) inside ns, or (require ...)
|
|
12
|
+
*/
|
|
13
|
+
export function extractClojureSymbols(tree: TreeSitterTree, _filePath: string): ExtractorOutput {
|
|
14
|
+
const ctx: ExtractorOutput = {
|
|
15
|
+
definitions: [],
|
|
16
|
+
calls: [],
|
|
17
|
+
imports: [],
|
|
18
|
+
classes: [],
|
|
19
|
+
exports: [],
|
|
20
|
+
typeMap: new Map(),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
walkClojureNode(tree.rootNode, ctx, null);
|
|
24
|
+
return ctx;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function walkClojureNode(
|
|
28
|
+
node: TreeSitterNode,
|
|
29
|
+
ctx: ExtractorOutput,
|
|
30
|
+
currentNs: string | null,
|
|
31
|
+
): void {
|
|
32
|
+
let nextNs = currentNs;
|
|
33
|
+
|
|
34
|
+
if (node.type === 'list_lit') {
|
|
35
|
+
nextNs = handleListForm(node, ctx, currentNs) ?? currentNs;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
39
|
+
const child = node.child(i);
|
|
40
|
+
if (child) walkClojureNode(child, ctx, nextNs);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Returns new namespace name if this is an `ns` form, otherwise null. */
|
|
45
|
+
function handleListForm(
|
|
46
|
+
node: TreeSitterNode,
|
|
47
|
+
ctx: ExtractorOutput,
|
|
48
|
+
currentNs: string | null,
|
|
49
|
+
): string | null {
|
|
50
|
+
const firstSym = findFirstSymbol(node);
|
|
51
|
+
if (!firstSym) return null;
|
|
52
|
+
|
|
53
|
+
const name = firstSym.text;
|
|
54
|
+
|
|
55
|
+
switch (name) {
|
|
56
|
+
case 'ns':
|
|
57
|
+
return handleNsForm(node, ctx);
|
|
58
|
+
case 'def':
|
|
59
|
+
case 'defonce':
|
|
60
|
+
handleDefForm(node, ctx, currentNs, 'variable');
|
|
61
|
+
return null;
|
|
62
|
+
case 'defn':
|
|
63
|
+
case 'defn-':
|
|
64
|
+
handleDefnForm(node, ctx, currentNs, name === 'defn-' ? 'private' : 'public');
|
|
65
|
+
return null;
|
|
66
|
+
case 'defmacro':
|
|
67
|
+
handleDefnForm(node, ctx, currentNs, 'public');
|
|
68
|
+
return null;
|
|
69
|
+
case 'defprotocol':
|
|
70
|
+
handleDefprotocol(node, ctx);
|
|
71
|
+
return null;
|
|
72
|
+
case 'defrecord':
|
|
73
|
+
case 'deftype':
|
|
74
|
+
handleDefrecord(node, ctx, name);
|
|
75
|
+
return null;
|
|
76
|
+
case 'defmulti':
|
|
77
|
+
handleDefForm(node, ctx, currentNs, 'function');
|
|
78
|
+
return null;
|
|
79
|
+
case 'defmethod':
|
|
80
|
+
handleDefnForm(node, ctx, currentNs, 'public');
|
|
81
|
+
return null;
|
|
82
|
+
case 'require':
|
|
83
|
+
case 'use':
|
|
84
|
+
case 'import':
|
|
85
|
+
handleImportForm(node, ctx, name);
|
|
86
|
+
return null;
|
|
87
|
+
default: {
|
|
88
|
+
// Regular function call
|
|
89
|
+
if (!name.startsWith(':') && !name.startsWith('(')) {
|
|
90
|
+
ctx.calls.push({ name, line: node.startPosition.row + 1 });
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function findFirstSymbol(listNode: TreeSitterNode): TreeSitterNode | null {
|
|
98
|
+
for (let i = 0; i < listNode.childCount; i++) {
|
|
99
|
+
const child = listNode.child(i);
|
|
100
|
+
if (!child) continue;
|
|
101
|
+
// Skip delimiters and metadata
|
|
102
|
+
if ('()[]{}#'.includes(child.type) || child.type === 'meta_lit') continue;
|
|
103
|
+
if (child.type === 'sym_lit' || child.type === 'kwd_lit') return child;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function findSecondSymbol(listNode: TreeSitterNode): TreeSitterNode | null {
|
|
110
|
+
let count = 0;
|
|
111
|
+
for (let i = 0; i < listNode.childCount; i++) {
|
|
112
|
+
const child = listNode.child(i);
|
|
113
|
+
if (!child) continue;
|
|
114
|
+
if ('()[]{}#'.includes(child.type) || child.type === 'meta_lit') continue;
|
|
115
|
+
if (child.type === 'sym_lit' || child.type === 'kwd_lit') {
|
|
116
|
+
count++;
|
|
117
|
+
if (count === 2) return child;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function handleNsForm(node: TreeSitterNode, ctx: ExtractorOutput): string | null {
|
|
124
|
+
const nameNode = findSecondSymbol(node);
|
|
125
|
+
if (!nameNode) return null;
|
|
126
|
+
|
|
127
|
+
const nsName = nameNode.text;
|
|
128
|
+
ctx.definitions.push({
|
|
129
|
+
name: nsName,
|
|
130
|
+
kind: 'module',
|
|
131
|
+
line: node.startPosition.row + 1,
|
|
132
|
+
endLine: nodeEndLine(node),
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Extract requires from ns form
|
|
136
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
137
|
+
const child = node.child(i);
|
|
138
|
+
if (!child) continue;
|
|
139
|
+
if (child.type === 'list_lit') {
|
|
140
|
+
const kw = findFirstSymbol(child);
|
|
141
|
+
if (kw && (kw.text === ':require' || kw.text === ':import' || kw.text === ':use')) {
|
|
142
|
+
extractNsRequires(child, ctx);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return nsName;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function extractNsRequires(requireForm: TreeSitterNode, ctx: ExtractorOutput): void {
|
|
151
|
+
for (let i = 0; i < requireForm.childCount; i++) {
|
|
152
|
+
const child = requireForm.child(i);
|
|
153
|
+
if (!child) continue;
|
|
154
|
+
// Vector form: [some.ns :as alias]
|
|
155
|
+
if (child.type === 'vec_lit') {
|
|
156
|
+
const sym = findFirstSymbol(child);
|
|
157
|
+
if (sym) {
|
|
158
|
+
ctx.imports.push({
|
|
159
|
+
source: sym.text,
|
|
160
|
+
names: [sym.text.split('.').pop() || sym.text],
|
|
161
|
+
line: child.startPosition.row + 1,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Symbol form: some.ns
|
|
166
|
+
if (child.type === 'sym_lit' && i > 0) {
|
|
167
|
+
const text = child.text;
|
|
168
|
+
if (!text.startsWith(':')) {
|
|
169
|
+
ctx.imports.push({
|
|
170
|
+
source: text,
|
|
171
|
+
names: [text.split('.').pop() || text],
|
|
172
|
+
line: child.startPosition.row + 1,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function handleDefForm(
|
|
180
|
+
node: TreeSitterNode,
|
|
181
|
+
ctx: ExtractorOutput,
|
|
182
|
+
currentNs: string | null,
|
|
183
|
+
kindOrFallback: 'variable' | 'function',
|
|
184
|
+
): void {
|
|
185
|
+
const nameNode = findSecondSymbol(node);
|
|
186
|
+
if (!nameNode) return;
|
|
187
|
+
|
|
188
|
+
const rawName = nameNode.text;
|
|
189
|
+
const fullName = currentNs ? `${currentNs}/${rawName}` : rawName;
|
|
190
|
+
|
|
191
|
+
ctx.definitions.push({
|
|
192
|
+
name: fullName,
|
|
193
|
+
kind: kindOrFallback,
|
|
194
|
+
line: node.startPosition.row + 1,
|
|
195
|
+
endLine: nodeEndLine(node),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function handleDefnForm(
|
|
200
|
+
node: TreeSitterNode,
|
|
201
|
+
ctx: ExtractorOutput,
|
|
202
|
+
currentNs: string | null,
|
|
203
|
+
visibility: 'public' | 'private',
|
|
204
|
+
): void {
|
|
205
|
+
const nameNode = findSecondSymbol(node);
|
|
206
|
+
if (!nameNode) return;
|
|
207
|
+
|
|
208
|
+
const rawName = nameNode.text;
|
|
209
|
+
const fullName = currentNs ? `${currentNs}/${rawName}` : rawName;
|
|
210
|
+
const params = extractClojureParams(node);
|
|
211
|
+
|
|
212
|
+
ctx.definitions.push({
|
|
213
|
+
name: fullName,
|
|
214
|
+
kind: 'function',
|
|
215
|
+
line: node.startPosition.row + 1,
|
|
216
|
+
endLine: nodeEndLine(node),
|
|
217
|
+
visibility,
|
|
218
|
+
children: params.length > 0 ? params : undefined,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function extractClojureParams(defnNode: TreeSitterNode): SubDeclaration[] {
|
|
223
|
+
const params: SubDeclaration[] = [];
|
|
224
|
+
// Find the parameter vector [x y z]
|
|
225
|
+
for (let i = 0; i < defnNode.childCount; i++) {
|
|
226
|
+
const child = defnNode.child(i);
|
|
227
|
+
if (!child || child.type !== 'vec_lit') continue;
|
|
228
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
229
|
+
const param = child.child(j);
|
|
230
|
+
if (!param) continue;
|
|
231
|
+
if (param.type === 'sym_lit') {
|
|
232
|
+
params.push({ name: param.text, kind: 'parameter', line: param.startPosition.row + 1 });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
break; // Only first vector is params
|
|
236
|
+
}
|
|
237
|
+
return params;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function handleDefprotocol(node: TreeSitterNode, ctx: ExtractorOutput): void {
|
|
241
|
+
const nameNode = findSecondSymbol(node);
|
|
242
|
+
if (!nameNode) return;
|
|
243
|
+
|
|
244
|
+
ctx.definitions.push({
|
|
245
|
+
name: nameNode.text,
|
|
246
|
+
kind: 'interface',
|
|
247
|
+
line: node.startPosition.row + 1,
|
|
248
|
+
endLine: nodeEndLine(node),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function handleDefrecord(node: TreeSitterNode, ctx: ExtractorOutput, keyword: string): void {
|
|
253
|
+
const nameNode = findSecondSymbol(node);
|
|
254
|
+
if (!nameNode) return;
|
|
255
|
+
|
|
256
|
+
ctx.definitions.push({
|
|
257
|
+
name: nameNode.text,
|
|
258
|
+
kind: keyword === 'defrecord' ? 'record' : 'type',
|
|
259
|
+
line: node.startPosition.row + 1,
|
|
260
|
+
endLine: nodeEndLine(node),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function handleImportForm(node: TreeSitterNode, ctx: ExtractorOutput, keyword: string): void {
|
|
265
|
+
const nameNode = findSecondSymbol(node);
|
|
266
|
+
if (!nameNode) return;
|
|
267
|
+
|
|
268
|
+
ctx.imports.push({
|
|
269
|
+
source: nameNode.text,
|
|
270
|
+
names: [keyword],
|
|
271
|
+
line: node.startPosition.row + 1,
|
|
272
|
+
});
|
|
273
|
+
}
|