@optave/codegraph 3.1.5 → 3.3.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/README.md +50 -56
- package/dist/ast-analysis/engine.d.ts +17 -0
- package/dist/ast-analysis/engine.d.ts.map +1 -0
- package/dist/ast-analysis/engine.js +328 -0
- package/dist/ast-analysis/engine.js.map +1 -0
- package/dist/ast-analysis/metrics.d.ts +51 -0
- package/dist/ast-analysis/metrics.d.ts.map +1 -0
- package/dist/ast-analysis/metrics.js +106 -0
- package/dist/ast-analysis/metrics.js.map +1 -0
- package/dist/ast-analysis/rules/csharp.d.ts +24 -0
- package/dist/ast-analysis/rules/csharp.d.ts.map +1 -0
- package/dist/ast-analysis/rules/csharp.js +192 -0
- package/dist/ast-analysis/rules/csharp.js.map +1 -0
- package/dist/ast-analysis/rules/go.d.ts +24 -0
- package/dist/ast-analysis/rules/go.d.ts.map +1 -0
- package/dist/ast-analysis/rules/go.js +173 -0
- package/dist/ast-analysis/rules/go.js.map +1 -0
- package/dist/ast-analysis/rules/index.d.ts +31 -0
- package/dist/ast-analysis/rules/index.d.ts.map +1 -0
- package/dist/ast-analysis/rules/index.js +72 -0
- package/dist/ast-analysis/rules/index.js.map +1 -0
- package/dist/ast-analysis/rules/java.d.ts +24 -0
- package/dist/ast-analysis/rules/java.d.ts.map +1 -0
- package/dist/ast-analysis/rules/java.js +166 -0
- package/dist/ast-analysis/rules/java.js.map +1 -0
- package/dist/ast-analysis/rules/javascript.d.ts +31 -0
- package/dist/ast-analysis/rules/javascript.d.ts.map +1 -0
- package/dist/ast-analysis/rules/javascript.js +235 -0
- package/dist/ast-analysis/rules/javascript.js.map +1 -0
- package/dist/ast-analysis/rules/php.d.ts +24 -0
- package/dist/ast-analysis/rules/php.d.ts.map +1 -0
- package/dist/ast-analysis/rules/php.js +210 -0
- package/dist/ast-analysis/rules/php.js.map +1 -0
- package/dist/ast-analysis/rules/python.d.ts +24 -0
- package/dist/ast-analysis/rules/python.d.ts.map +1 -0
- package/dist/ast-analysis/rules/python.js +188 -0
- package/dist/ast-analysis/rules/python.js.map +1 -0
- package/dist/ast-analysis/rules/ruby.d.ts +24 -0
- package/dist/ast-analysis/rules/ruby.d.ts.map +1 -0
- package/dist/ast-analysis/rules/ruby.js +193 -0
- package/dist/ast-analysis/rules/ruby.js.map +1 -0
- package/dist/ast-analysis/rules/rust.d.ts +24 -0
- package/dist/ast-analysis/rules/rust.d.ts.map +1 -0
- package/dist/ast-analysis/rules/rust.js +165 -0
- package/dist/ast-analysis/rules/rust.js.map +1 -0
- package/dist/ast-analysis/shared.d.ts +106 -0
- package/dist/ast-analysis/shared.d.ts.map +1 -0
- package/dist/ast-analysis/shared.js +186 -0
- package/dist/ast-analysis/shared.js.map +1 -0
- package/dist/ast-analysis/visitor-utils.d.ts +41 -0
- package/dist/ast-analysis/visitor-utils.d.ts.map +1 -0
- package/dist/ast-analysis/visitor-utils.js +180 -0
- package/dist/ast-analysis/visitor-utils.js.map +1 -0
- package/dist/ast-analysis/visitor.d.ts +119 -0
- package/dist/ast-analysis/visitor.d.ts.map +1 -0
- package/dist/ast-analysis/visitor.js +146 -0
- package/dist/ast-analysis/visitor.js.map +1 -0
- package/dist/ast-analysis/visitors/ast-store-visitor.d.ts +11 -0
- package/dist/ast-analysis/visitors/ast-store-visitor.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/ast-store-visitor.js +147 -0
- package/dist/ast-analysis/visitors/ast-store-visitor.js.map +1 -0
- package/dist/ast-analysis/visitors/cfg-visitor.d.ts +8 -0
- package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/cfg-visitor.js +660 -0
- package/dist/ast-analysis/visitors/cfg-visitor.js.map +1 -0
- package/dist/ast-analysis/visitors/complexity-visitor.d.ts +17 -0
- package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/complexity-visitor.js +216 -0
- package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -0
- package/dist/ast-analysis/visitors/dataflow-visitor.d.ts +8 -0
- package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/dataflow-visitor.js +321 -0
- package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -0
- package/dist/cli/commands/ast.d.ts +9 -0
- package/dist/cli/commands/ast.d.ts.map +1 -0
- package/dist/cli/commands/ast.js +23 -0
- package/dist/cli/commands/ast.js.map +1 -0
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/audit.d.ts.map +1 -0
- package/dist/cli/commands/audit.js +46 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/batch.d.ts +9 -0
- package/dist/cli/commands/batch.d.ts.map +1 -0
- package/dist/cli/commands/batch.js +70 -0
- package/dist/cli/commands/batch.js.map +1 -0
- package/dist/cli/commands/branch-compare.d.ts +7 -0
- package/dist/cli/commands/branch-compare.d.ts.map +1 -0
- package/dist/cli/commands/branch-compare.js +22 -0
- package/dist/cli/commands/branch-compare.js.map +1 -0
- package/dist/cli/commands/brief.d.ts +7 -0
- package/dist/cli/commands/brief.d.ts.map +1 -0
- package/dist/cli/commands/brief.js +12 -0
- package/dist/cli/commands/brief.js.map +1 -0
- package/dist/cli/commands/build.d.ts +7 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +26 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/cfg.d.ts +10 -0
- package/dist/cli/commands/cfg.d.ts.map +1 -0
- package/dist/cli/commands/cfg.js +27 -0
- package/dist/cli/commands/cfg.js.map +1 -0
- package/dist/cli/commands/check.d.ts +8 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +65 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/children.d.ts +9 -0
- package/dist/cli/commands/children.d.ts.map +1 -0
- package/dist/cli/commands/children.js +33 -0
- package/dist/cli/commands/children.js.map +1 -0
- package/dist/cli/commands/co-change.d.ts +7 -0
- package/dist/cli/commands/co-change.d.ts.map +1 -0
- package/dist/cli/commands/co-change.js +62 -0
- package/dist/cli/commands/co-change.js.map +1 -0
- package/dist/cli/commands/communities.d.ts +8 -0
- package/dist/cli/commands/communities.d.ts.map +1 -0
- package/dist/cli/commands/communities.js +20 -0
- package/dist/cli/commands/communities.js.map +1 -0
- package/dist/cli/commands/complexity.d.ts +9 -0
- package/dist/cli/commands/complexity.d.ts.map +1 -0
- package/dist/cli/commands/complexity.js +47 -0
- package/dist/cli/commands/complexity.js.map +1 -0
- package/dist/cli/commands/context.d.ts +10 -0
- package/dist/cli/commands/context.d.ts.map +1 -0
- package/dist/cli/commands/context.js +35 -0
- package/dist/cli/commands/context.js.map +1 -0
- package/dist/cli/commands/cycles.d.ts +7 -0
- package/dist/cli/commands/cycles.d.ts.map +1 -0
- package/dist/cli/commands/cycles.js +33 -0
- package/dist/cli/commands/cycles.js.map +1 -0
- package/dist/cli/commands/dataflow.d.ts +10 -0
- package/dist/cli/commands/dataflow.d.ts.map +1 -0
- package/dist/cli/commands/dataflow.js +29 -0
- package/dist/cli/commands/dataflow.js.map +1 -0
- package/dist/cli/commands/deps.d.ts +8 -0
- package/dist/cli/commands/deps.d.ts.map +1 -0
- package/dist/cli/commands/deps.js +18 -0
- package/dist/cli/commands/deps.js.map +1 -0
- package/dist/cli/commands/diff-impact.d.ts +7 -0
- package/dist/cli/commands/diff-impact.d.ts.map +1 -0
- package/dist/cli/commands/diff-impact.js +28 -0
- package/dist/cli/commands/diff-impact.js.map +1 -0
- package/dist/cli/commands/embed.d.ts +8 -0
- package/dist/cli/commands/embed.d.ts.map +1 -0
- package/dist/cli/commands/embed.js +29 -0
- package/dist/cli/commands/embed.js.map +1 -0
- package/dist/cli/commands/export.d.ts +7 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +72 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/exports.d.ts +8 -0
- package/dist/cli/commands/exports.d.ts.map +1 -0
- package/dist/cli/commands/exports.js +14 -0
- package/dist/cli/commands/exports.js.map +1 -0
- package/dist/cli/commands/flow.d.ts +10 -0
- package/dist/cli/commands/flow.d.ts.map +1 -0
- package/dist/cli/commands/flow.js +32 -0
- package/dist/cli/commands/flow.js.map +1 -0
- package/dist/cli/commands/fn-impact.d.ts +10 -0
- package/dist/cli/commands/fn-impact.d.ts.map +1 -0
- package/dist/cli/commands/fn-impact.js +33 -0
- package/dist/cli/commands/fn-impact.js.map +1 -0
- package/dist/cli/commands/impact.d.ts +7 -0
- package/dist/cli/commands/impact.d.ts.map +1 -0
- package/dist/cli/commands/impact.js +12 -0
- package/dist/cli/commands/impact.js.map +1 -0
- package/dist/cli/commands/implementations.d.ts +10 -0
- package/dist/cli/commands/implementations.d.ts.map +1 -0
- package/dist/cli/commands/implementations.js +29 -0
- package/dist/cli/commands/implementations.js.map +1 -0
- package/dist/cli/commands/info.d.ts +6 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/info.js +66 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/interfaces.d.ts +10 -0
- package/dist/cli/commands/interfaces.d.ts.map +1 -0
- package/dist/cli/commands/interfaces.js +29 -0
- package/dist/cli/commands/interfaces.js.map +1 -0
- package/dist/cli/commands/map.d.ts +7 -0
- package/dist/cli/commands/map.d.ts.map +1 -0
- package/dist/cli/commands/map.js +19 -0
- package/dist/cli/commands/map.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +7 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +19 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/models.d.ts +6 -0
- package/dist/cli/commands/models.d.ts.map +1 -0
- package/dist/cli/commands/models.js +17 -0
- package/dist/cli/commands/models.js.map +1 -0
- package/dist/cli/commands/owners.d.ts +8 -0
- package/dist/cli/commands/owners.d.ts.map +1 -0
- package/dist/cli/commands/owners.js +27 -0
- package/dist/cli/commands/owners.js.map +1 -0
- package/dist/cli/commands/path.d.ts +8 -0
- package/dist/cli/commands/path.d.ts.map +1 -0
- package/dist/cli/commands/path.js +36 -0
- package/dist/cli/commands/path.js.map +1 -0
- package/dist/cli/commands/plot.d.ts +7 -0
- package/dist/cli/commands/plot.d.ts.map +1 -0
- package/dist/cli/commands/plot.js +94 -0
- package/dist/cli/commands/plot.js.map +1 -0
- package/dist/cli/commands/query.d.ts +10 -0
- package/dist/cli/commands/query.d.ts.map +1 -0
- package/dist/cli/commands/query.js +51 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/registry.d.ts +16 -0
- package/dist/cli/commands/registry.d.ts.map +1 -0
- package/dist/cli/commands/registry.js +95 -0
- package/dist/cli/commands/registry.js.map +1 -0
- package/dist/cli/commands/roles.d.ts +9 -0
- package/dist/cli/commands/roles.d.ts.map +1 -0
- package/dist/cli/commands/roles.js +31 -0
- package/dist/cli/commands/roles.js.map +1 -0
- package/dist/cli/commands/search.d.ts +9 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +47 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/commands/sequence.d.ts +10 -0
- package/dist/cli/commands/sequence.d.ts.map +1 -0
- package/dist/cli/commands/sequence.js +29 -0
- package/dist/cli/commands/sequence.js.map +1 -0
- package/dist/cli/commands/snapshot.d.ts +11 -0
- package/dist/cli/commands/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/snapshot.js +61 -0
- package/dist/cli/commands/snapshot.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +7 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +15 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/commands/structure.d.ts +7 -0
- package/dist/cli/commands/structure.d.ts.map +1 -0
- package/dist/cli/commands/structure.js +33 -0
- package/dist/cli/commands/structure.js.map +1 -0
- package/dist/cli/commands/triage.d.ts +8 -0
- package/dist/cli/commands/triage.d.ts.map +1 -0
- package/dist/cli/commands/triage.js +89 -0
- package/dist/cli/commands/triage.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +6 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +12 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/commands/where.d.ts +9 -0
- package/dist/cli/commands/where.d.ts.map +1 -0
- package/dist/cli/commands/where.js +20 -0
- package/dist/cli/commands/where.js.map +1 -0
- package/dist/cli/index.d.ts +31 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +109 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/shared/open-graph.d.ts +14 -0
- package/dist/cli/shared/open-graph.d.ts.map +1 -0
- package/dist/cli/shared/open-graph.js +13 -0
- package/dist/cli/shared/open-graph.js.map +1 -0
- package/dist/cli/shared/options.d.ts +31 -0
- package/dist/cli/shared/options.d.ts.map +1 -0
- package/dist/cli/shared/options.js +58 -0
- package/dist/cli/shared/options.js.map +1 -0
- package/dist/cli/shared/output.d.ts +2 -0
- package/dist/cli/shared/output.d.ts.map +1 -0
- package/dist/cli/shared/output.js +2 -0
- package/dist/cli/shared/output.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/db/connection.d.ts +39 -0
- package/dist/db/connection.d.ts.map +1 -0
- package/dist/db/connection.js +217 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/db/index.d.ts +5 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +6 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +8 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +323 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/query-builder.d.ts +106 -0
- package/dist/db/query-builder.d.ts.map +1 -0
- package/dist/db/query-builder.js +313 -0
- package/dist/db/query-builder.js.map +1 -0
- package/dist/db/repository/base.d.ts +115 -0
- package/dist/db/repository/base.d.ts.map +1 -0
- package/dist/db/repository/base.js +165 -0
- package/dist/db/repository/base.js.map +1 -0
- package/dist/db/repository/build-stmts.d.ts +25 -0
- package/dist/db/repository/build-stmts.d.ts.map +1 -0
- package/dist/db/repository/build-stmts.js +86 -0
- package/dist/db/repository/build-stmts.js.map +1 -0
- package/dist/db/repository/cached-stmt.d.ts +13 -0
- package/dist/db/repository/cached-stmt.d.ts.map +1 -0
- package/dist/db/repository/cached-stmt.js +20 -0
- package/dist/db/repository/cached-stmt.js.map +1 -0
- package/dist/db/repository/cfg.d.ts +27 -0
- package/dist/db/repository/cfg.d.ts.map +1 -0
- package/dist/db/repository/cfg.js +57 -0
- package/dist/db/repository/cfg.js.map +1 -0
- package/dist/db/repository/cochange.d.ts +20 -0
- package/dist/db/repository/cochange.d.ts.map +1 -0
- package/dist/db/repository/cochange.js +45 -0
- package/dist/db/repository/cochange.js.map +1 -0
- package/dist/db/repository/complexity.d.ts +15 -0
- package/dist/db/repository/complexity.d.ts.map +1 -0
- package/dist/db/repository/complexity.js +15 -0
- package/dist/db/repository/complexity.js.map +1 -0
- package/dist/db/repository/dataflow.d.ts +7 -0
- package/dist/db/repository/dataflow.d.ts.map +1 -0
- package/dist/db/repository/dataflow.js +17 -0
- package/dist/db/repository/dataflow.js.map +1 -0
- package/dist/db/repository/edges.d.ts +173 -0
- package/dist/db/repository/edges.d.ts.map +1 -0
- package/dist/db/repository/edges.js +231 -0
- package/dist/db/repository/edges.js.map +1 -0
- package/dist/db/repository/embeddings.d.ts +20 -0
- package/dist/db/repository/embeddings.d.ts.map +1 -0
- package/dist/db/repository/embeddings.js +47 -0
- package/dist/db/repository/embeddings.js.map +1 -0
- package/dist/db/repository/graph-read.d.ts +41 -0
- package/dist/db/repository/graph-read.d.ts.map +1 -0
- package/dist/db/repository/graph-read.js +41 -0
- package/dist/db/repository/graph-read.js.map +1 -0
- package/dist/db/repository/in-memory-repository.d.ts +156 -0
- package/dist/db/repository/in-memory-repository.d.ts.map +1 -0
- package/dist/db/repository/in-memory-repository.js +533 -0
- package/dist/db/repository/in-memory-repository.js.map +1 -0
- package/dist/db/repository/index.d.ts +14 -0
- package/dist/db/repository/index.d.ts.map +1 -0
- package/dist/db/repository/index.js +15 -0
- package/dist/db/repository/index.js.map +1 -0
- package/dist/db/repository/nodes.d.ts +151 -0
- package/dist/db/repository/nodes.d.ts.map +1 -0
- package/dist/db/repository/nodes.js +244 -0
- package/dist/db/repository/nodes.js.map +1 -0
- package/dist/db/repository/sqlite-repository.d.ts +100 -0
- package/dist/db/repository/sqlite-repository.d.ts.map +1 -0
- package/dist/db/repository/sqlite-repository.js +143 -0
- package/dist/db/repository/sqlite-repository.js.map +1 -0
- package/dist/domain/analysis/brief.d.ts +16 -0
- package/dist/domain/analysis/brief.d.ts.map +1 -0
- package/dist/domain/analysis/brief.js +147 -0
- package/dist/domain/analysis/brief.js.map +1 -0
- package/dist/domain/analysis/context.d.ts +3 -0
- package/dist/domain/analysis/context.d.ts.map +1 -0
- package/dist/domain/analysis/context.js +378 -0
- package/dist/domain/analysis/context.js.map +1 -0
- package/dist/domain/analysis/dependencies.d.ts +60 -0
- package/dist/domain/analysis/dependencies.d.ts.map +1 -0
- package/dist/domain/analysis/dependencies.js +359 -0
- package/dist/domain/analysis/dependencies.js.map +1 -0
- package/dist/domain/analysis/exports.d.ts +2 -0
- package/dist/domain/analysis/exports.d.ts.map +1 -0
- package/dist/domain/analysis/exports.js +168 -0
- package/dist/domain/analysis/exports.js.map +1 -0
- package/dist/domain/analysis/impact.d.ts +39 -0
- package/dist/domain/analysis/impact.d.ts.map +1 -0
- package/dist/domain/analysis/impact.js +596 -0
- package/dist/domain/analysis/impact.js.map +1 -0
- package/dist/domain/analysis/implementations.d.ts +59 -0
- package/dist/domain/analysis/implementations.d.ts.map +1 -0
- package/dist/domain/analysis/implementations.js +93 -0
- package/dist/domain/analysis/implementations.js.map +1 -0
- package/dist/domain/analysis/module-map.d.ts +64 -0
- package/dist/domain/analysis/module-map.d.ts.map +1 -0
- package/dist/domain/analysis/module-map.js +334 -0
- package/dist/domain/analysis/module-map.js.map +1 -0
- package/dist/domain/analysis/roles.d.ts +2 -0
- package/dist/domain/analysis/roles.d.ts.map +1 -0
- package/dist/domain/analysis/roles.js +50 -0
- package/dist/domain/analysis/roles.js.map +1 -0
- package/dist/domain/analysis/symbol-lookup.d.ts +12 -0
- package/dist/domain/analysis/symbol-lookup.d.ts.map +1 -0
- package/dist/domain/analysis/symbol-lookup.js +202 -0
- package/dist/domain/analysis/symbol-lookup.js.map +1 -0
- package/dist/domain/graph/builder/context.d.ts +91 -0
- package/dist/domain/graph/builder/context.d.ts.map +1 -0
- package/dist/domain/graph/builder/context.js +78 -0
- package/dist/domain/graph/builder/context.js.map +1 -0
- package/dist/domain/graph/builder/helpers.d.ts +43 -0
- package/dist/domain/graph/builder/helpers.d.ts.map +1 -0
- package/dist/domain/graph/builder/helpers.js +209 -0
- package/dist/domain/graph/builder/helpers.js.map +1 -0
- package/dist/domain/graph/builder/incremental.d.ts +17 -0
- package/dist/domain/graph/builder/incremental.d.ts.map +1 -0
- package/dist/domain/graph/builder/incremental.js +191 -0
- package/dist/domain/graph/builder/incremental.js.map +1 -0
- package/dist/domain/graph/builder/pipeline.d.ts +13 -0
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -0
- package/dist/domain/graph/builder/pipeline.js +146 -0
- package/dist/domain/graph/builder/pipeline.js.map +1 -0
- package/dist/domain/graph/builder/stages/build-edges.d.ts +5 -0
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/build-edges.js +387 -0
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -0
- package/dist/domain/graph/builder/stages/build-structure.d.ts +5 -0
- package/dist/domain/graph/builder/stages/build-structure.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/build-structure.js +107 -0
- package/dist/domain/graph/builder/stages/build-structure.js.map +1 -0
- package/dist/domain/graph/builder/stages/collect-files.d.ts +5 -0
- package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/collect-files.js +45 -0
- package/dist/domain/graph/builder/stages/collect-files.js.map +1 -0
- package/dist/domain/graph/builder/stages/detect-changes.d.ts +5 -0
- package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/detect-changes.js +358 -0
- package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -0
- package/dist/domain/graph/builder/stages/finalize.d.ts +5 -0
- package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/finalize.js +123 -0
- package/dist/domain/graph/builder/stages/finalize.js.map +1 -0
- package/dist/domain/graph/builder/stages/insert-nodes.d.ts +5 -0
- package/dist/domain/graph/builder/stages/insert-nodes.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/insert-nodes.js +183 -0
- package/dist/domain/graph/builder/stages/insert-nodes.js.map +1 -0
- package/dist/domain/graph/builder/stages/parse-files.d.ts +5 -0
- package/dist/domain/graph/builder/stages/parse-files.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/parse-files.js +25 -0
- package/dist/domain/graph/builder/stages/parse-files.js.map +1 -0
- package/dist/domain/graph/builder/stages/resolve-imports.d.ts +18 -0
- package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/resolve-imports.js +139 -0
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -0
- package/dist/domain/graph/builder/stages/run-analyses.d.ts +5 -0
- package/dist/domain/graph/builder/stages/run-analyses.d.ts.map +1 -0
- package/dist/domain/graph/builder/stages/run-analyses.js +39 -0
- package/dist/domain/graph/builder/stages/run-analyses.js.map +1 -0
- package/dist/domain/graph/builder.d.ts +4 -0
- package/dist/domain/graph/builder.d.ts.map +1 -0
- package/dist/domain/graph/builder.js +6 -0
- package/dist/domain/graph/builder.js.map +1 -0
- package/dist/domain/graph/change-journal.d.ts +57 -0
- package/dist/domain/graph/change-journal.d.ts.map +1 -0
- package/dist/domain/graph/change-journal.js +120 -0
- package/dist/domain/graph/change-journal.js.map +1 -0
- package/dist/domain/graph/cycles.d.ts +18 -0
- package/dist/domain/graph/cycles.d.ts.map +1 -0
- package/dist/domain/graph/cycles.js +75 -0
- package/dist/domain/graph/cycles.js.map +1 -0
- package/dist/domain/graph/journal.d.ts +27 -0
- package/dist/domain/graph/journal.d.ts.map +1 -0
- package/dist/domain/graph/journal.js +100 -0
- package/dist/domain/graph/journal.js.map +1 -0
- package/dist/domain/graph/resolve.d.ts +76 -0
- package/dist/domain/graph/resolve.d.ts.map +1 -0
- package/dist/domain/graph/resolve.js +482 -0
- package/dist/domain/graph/resolve.js.map +1 -0
- package/dist/domain/graph/watcher.d.ts +2 -0
- package/dist/domain/graph/watcher.d.ts.map +1 -0
- package/dist/domain/graph/watcher.js +140 -0
- package/dist/domain/graph/watcher.js.map +1 -0
- package/dist/domain/parser.d.ts +104 -0
- package/dist/domain/parser.d.ts.map +1 -0
- package/dist/domain/parser.js +557 -0
- package/dist/domain/parser.js.map +1 -0
- package/dist/domain/queries.d.ts +14 -0
- package/dist/domain/queries.d.ts.map +1 -0
- package/dist/domain/queries.js +25 -0
- package/dist/domain/queries.js.map +1 -0
- package/dist/domain/search/generator.d.ts +17 -0
- package/dist/domain/search/generator.d.ts.map +1 -0
- package/dist/domain/search/generator.js +135 -0
- package/dist/domain/search/generator.js.map +1 -0
- package/dist/domain/search/index.d.ts +8 -0
- package/dist/domain/search/index.d.ts.map +1 -0
- package/dist/domain/search/index.js +13 -0
- package/dist/domain/search/index.js.map +1 -0
- package/dist/domain/search/models.d.ts +82 -0
- package/dist/domain/search/models.d.ts.map +1 -0
- package/dist/domain/search/models.js +198 -0
- package/dist/domain/search/models.js.map +1 -0
- package/dist/domain/search/search/cli-formatter.d.ts +6 -0
- package/dist/domain/search/search/cli-formatter.d.ts.map +1 -0
- package/dist/domain/search/search/cli-formatter.js +135 -0
- package/dist/domain/search/search/cli-formatter.js.map +1 -0
- package/dist/domain/search/search/filters.d.ts +19 -0
- package/dist/domain/search/search/filters.d.ts.map +1 -0
- package/dist/domain/search/search/filters.js +48 -0
- package/dist/domain/search/search/filters.js.map +1 -0
- package/dist/domain/search/search/hybrid.d.ts +22 -0
- package/dist/domain/search/search/hybrid.d.ts.map +1 -0
- package/dist/domain/search/search/hybrid.js +113 -0
- package/dist/domain/search/search/hybrid.js.map +1 -0
- package/dist/domain/search/search/keyword.d.ts +17 -0
- package/dist/domain/search/search/keyword.d.ts.map +1 -0
- package/dist/domain/search/search/keyword.js +66 -0
- package/dist/domain/search/search/keyword.js.map +1 -0
- package/dist/domain/search/search/prepare.d.ts +13 -0
- package/dist/domain/search/search/prepare.d.ts.map +1 -0
- package/dist/domain/search/search/prepare.js +70 -0
- package/dist/domain/search/search/prepare.js.map +1 -0
- package/dist/domain/search/search/semantic.d.ts +34 -0
- package/dist/domain/search/search/semantic.d.ts.map +1 -0
- package/dist/domain/search/search/semantic.js +129 -0
- package/dist/domain/search/search/semantic.js.map +1 -0
- package/dist/domain/search/stores/fts5.d.ts +11 -0
- package/dist/domain/search/stores/fts5.d.ts.map +1 -0
- package/dist/domain/search/stores/fts5.js +31 -0
- package/dist/domain/search/stores/fts5.js.map +1 -0
- package/dist/domain/search/stores/sqlite-blob.d.ts +27 -0
- package/dist/domain/search/stores/sqlite-blob.d.ts.map +1 -0
- package/dist/domain/search/stores/sqlite-blob.js +22 -0
- package/dist/domain/search/stores/sqlite-blob.js.map +1 -0
- package/dist/domain/search/strategies/source.d.ts +5 -0
- package/dist/domain/search/strategies/source.d.ts.map +1 -0
- package/dist/domain/search/strategies/source.js +14 -0
- package/dist/domain/search/strategies/source.js.map +1 -0
- package/dist/domain/search/strategies/structured.d.ts +6 -0
- package/dist/domain/search/strategies/structured.d.ts.map +1 -0
- package/dist/domain/search/strategies/structured.js +40 -0
- package/dist/domain/search/strategies/structured.js.map +1 -0
- package/dist/domain/search/strategies/text-utils.d.ts +11 -0
- package/dist/domain/search/strategies/text-utils.d.ts.map +1 -0
- package/dist/domain/search/strategies/text-utils.js +47 -0
- package/dist/domain/search/strategies/text-utils.js.map +1 -0
- package/dist/extractors/csharp.d.ts +12 -0
- package/dist/extractors/csharp.d.ts.map +1 -0
- package/dist/extractors/csharp.js +402 -0
- package/dist/extractors/csharp.js.map +1 -0
- package/dist/extractors/go.d.ts +12 -0
- package/dist/extractors/go.d.ts.map +1 -0
- package/dist/extractors/go.js +381 -0
- package/dist/extractors/go.js.map +1 -0
- package/dist/extractors/hcl.d.ts +11 -0
- package/dist/extractors/hcl.d.ts.map +1 -0
- package/dist/extractors/hcl.js +105 -0
- package/dist/extractors/hcl.js.map +1 -0
- package/dist/extractors/helpers.d.ts +16 -0
- package/dist/extractors/helpers.d.ts.map +1 -0
- package/dist/extractors/helpers.js +88 -0
- package/dist/extractors/helpers.js.map +1 -0
- package/dist/extractors/index.d.ts +10 -0
- package/dist/extractors/index.d.ts.map +1 -0
- package/dist/extractors/index.js +10 -0
- package/dist/extractors/index.js.map +1 -0
- package/dist/extractors/java.d.ts +12 -0
- package/dist/extractors/java.d.ts.map +1 -0
- package/dist/extractors/java.js +325 -0
- package/dist/extractors/java.js.map +1 -0
- package/dist/extractors/javascript.d.ts +81 -0
- package/dist/extractors/javascript.d.ts.map +1 -0
- package/dist/extractors/javascript.js +1232 -0
- package/dist/extractors/javascript.js.map +1 -0
- package/dist/extractors/php.d.ts +12 -0
- package/dist/extractors/php.d.ts.map +1 -0
- package/dist/extractors/php.js +380 -0
- package/dist/extractors/php.js.map +1 -0
- package/dist/extractors/python.d.ts +12 -0
- package/dist/extractors/python.d.ts.map +1 -0
- package/dist/extractors/python.js +426 -0
- package/dist/extractors/python.js.map +1 -0
- package/dist/extractors/ruby.d.ts +11 -0
- package/dist/extractors/ruby.d.ts.map +1 -0
- package/dist/extractors/ruby.js +284 -0
- package/dist/extractors/ruby.js.map +1 -0
- package/dist/extractors/rust.d.ts +12 -0
- package/dist/extractors/rust.d.ts.map +1 -0
- package/dist/extractors/rust.js +366 -0
- package/dist/extractors/rust.js.map +1 -0
- package/dist/features/ast.d.ts +30 -0
- package/dist/features/ast.d.ts.map +1 -0
- package/dist/features/ast.js +242 -0
- package/dist/features/ast.js.map +1 -0
- package/dist/features/audit.d.ts +6 -0
- package/dist/features/audit.d.ts.map +1 -0
- package/dist/features/audit.js +283 -0
- package/dist/features/audit.js.map +1 -0
- package/dist/features/batch.d.ts +110 -0
- package/dist/features/batch.d.ts.map +1 -0
- package/dist/features/batch.js +138 -0
- package/dist/features/batch.js.map +1 -0
- package/dist/features/boundaries.d.ts +69 -0
- package/dist/features/boundaries.d.ts.map +1 -0
- package/dist/features/boundaries.js +344 -0
- package/dist/features/boundaries.js.map +1 -0
- package/dist/features/branch-compare.d.ts +52 -0
- package/dist/features/branch-compare.d.ts.map +1 -0
- package/dist/features/branch-compare.js +425 -0
- package/dist/features/branch-compare.js.map +1 -0
- package/dist/features/cfg.d.ts +51 -0
- package/dist/features/cfg.d.ts.map +1 -0
- package/dist/features/cfg.js +372 -0
- package/dist/features/cfg.js.map +1 -0
- package/dist/features/check.d.ts +99 -0
- package/dist/features/check.d.ts.map +1 -0
- package/dist/features/check.js +296 -0
- package/dist/features/check.js.map +1 -0
- package/dist/features/cochange.d.ts +119 -0
- package/dist/features/cochange.d.ts.map +1 -0
- package/dist/features/cochange.js +425 -0
- package/dist/features/cochange.js.map +1 -0
- package/dist/features/communities.d.ts +40 -0
- package/dist/features/communities.d.ts.map +1 -0
- package/dist/features/communities.js +163 -0
- package/dist/features/communities.js.map +1 -0
- package/dist/features/complexity.d.ts +127 -0
- package/dist/features/complexity.d.ts.map +1 -0
- package/dist/features/complexity.js +683 -0
- package/dist/features/complexity.js.map +1 -0
- package/dist/features/dataflow.d.ts +72 -0
- package/dist/features/dataflow.d.ts.map +1 -0
- package/dist/features/dataflow.js +483 -0
- package/dist/features/dataflow.js.map +1 -0
- package/dist/features/export.d.ts +29 -0
- package/dist/features/export.d.ts.map +1 -0
- package/dist/features/export.js +336 -0
- package/dist/features/export.js.map +1 -0
- package/dist/features/flow.d.ts +49 -0
- package/dist/features/flow.d.ts.map +1 -0
- package/dist/features/flow.js +203 -0
- package/dist/features/flow.js.map +1 -0
- package/dist/features/graph-enrichment.d.ts +54 -0
- package/dist/features/graph-enrichment.d.ts.map +1 -0
- package/dist/features/graph-enrichment.js +297 -0
- package/dist/features/graph-enrichment.js.map +1 -0
- package/dist/features/manifesto.d.ts +46 -0
- package/dist/features/manifesto.d.ts.map +1 -0
- package/dist/features/manifesto.js +398 -0
- package/dist/features/manifesto.js.map +1 -0
- package/dist/features/owners.d.ts +123 -0
- package/dist/features/owners.d.ts.map +1 -0
- package/dist/features/owners.js +289 -0
- package/dist/features/owners.js.map +1 -0
- package/dist/features/sequence.d.ts +33 -0
- package/dist/features/sequence.d.ts.map +1 -0
- package/dist/features/sequence.js +269 -0
- package/dist/features/sequence.js.map +1 -0
- package/dist/features/shared/find-nodes.d.ts +11 -0
- package/dist/features/shared/find-nodes.d.ts.map +1 -0
- package/dist/features/shared/find-nodes.js +27 -0
- package/dist/features/shared/find-nodes.js.map +1 -0
- package/dist/features/snapshot.d.ts +64 -0
- package/dist/features/snapshot.d.ts.map +1 -0
- package/dist/features/snapshot.js +132 -0
- package/dist/features/snapshot.js.map +1 -0
- package/dist/features/structure.d.ts +42 -0
- package/dist/features/structure.d.ts.map +1 -0
- package/dist/features/structure.js +596 -0
- package/dist/features/structure.js.map +1 -0
- package/dist/features/triage.d.ts +13 -0
- package/dist/features/triage.d.ts.map +1 -0
- package/dist/features/triage.js +133 -0
- package/dist/features/triage.js.map +1 -0
- package/dist/graph/algorithms/bfs.d.ts +13 -0
- package/dist/graph/algorithms/bfs.d.ts.map +1 -0
- package/dist/graph/algorithms/bfs.js +47 -0
- package/dist/graph/algorithms/bfs.js.map +1 -0
- package/dist/graph/algorithms/centrality.d.ts +11 -0
- package/dist/graph/algorithms/centrality.d.ts.map +1 -0
- package/dist/graph/algorithms/centrality.js +17 -0
- package/dist/graph/algorithms/centrality.js.map +1 -0
- package/dist/graph/algorithms/index.d.ts +6 -0
- package/dist/graph/algorithms/index.d.ts.map +1 -0
- package/dist/graph/algorithms/index.js +6 -0
- package/dist/graph/algorithms/index.js.map +1 -0
- package/dist/graph/algorithms/louvain.d.ts +5 -0
- package/dist/graph/algorithms/louvain.d.ts.map +1 -0
- package/dist/graph/algorithms/louvain.js +22 -0
- package/dist/graph/algorithms/louvain.js.map +1 -0
- package/dist/graph/algorithms/shortest-path.d.ts +10 -0
- package/dist/graph/algorithms/shortest-path.d.ts.map +1 -0
- package/dist/graph/algorithms/shortest-path.js +41 -0
- package/dist/graph/algorithms/shortest-path.js.map +1 -0
- package/dist/graph/algorithms/tarjan.d.ts +9 -0
- package/dist/graph/algorithms/tarjan.d.ts.map +1 -0
- package/dist/graph/algorithms/tarjan.js +48 -0
- package/dist/graph/algorithms/tarjan.js.map +1 -0
- package/dist/graph/builders/dependency.d.ts +15 -0
- package/dist/graph/builders/dependency.d.ts.map +1 -0
- package/dist/graph/builders/dependency.js +99 -0
- package/dist/graph/builders/dependency.js.map +1 -0
- package/dist/graph/builders/index.d.ts +4 -0
- package/dist/graph/builders/index.d.ts.map +1 -0
- package/dist/graph/builders/index.js +4 -0
- package/dist/graph/builders/index.js.map +1 -0
- package/dist/graph/builders/structure.d.ts +7 -0
- package/dist/graph/builders/structure.d.ts.map +1 -0
- package/dist/graph/builders/structure.js +32 -0
- package/dist/graph/builders/structure.js.map +1 -0
- package/dist/graph/builders/temporal.d.ts +10 -0
- package/dist/graph/builders/temporal.d.ts.map +1 -0
- package/dist/graph/builders/temporal.js +31 -0
- package/dist/graph/builders/temporal.js.map +1 -0
- package/dist/graph/classifiers/index.d.ts +3 -0
- package/dist/graph/classifiers/index.d.ts.map +1 -0
- package/dist/graph/classifiers/index.js +3 -0
- package/dist/graph/classifiers/index.js.map +1 -0
- package/dist/graph/classifiers/risk.d.ts +49 -0
- package/dist/graph/classifiers/risk.d.ts.map +1 -0
- package/dist/graph/classifiers/risk.js +84 -0
- package/dist/graph/classifiers/risk.js.map +1 -0
- package/dist/graph/classifiers/roles.d.ts +29 -0
- package/dist/graph/classifiers/roles.d.ts.map +1 -0
- package/dist/graph/classifiers/roles.js +109 -0
- package/dist/graph/classifiers/roles.js.map +1 -0
- package/dist/graph/index.d.ts +5 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +6 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/model.d.ts +53 -0
- package/dist/graph/model.d.ts.map +1 -0
- package/dist/graph/model.js +210 -0
- package/dist/graph/model.js.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/config.d.ts +222 -0
- package/dist/infrastructure/config.d.ts.map +1 -0
- package/dist/infrastructure/config.js +386 -0
- package/dist/infrastructure/config.js.map +1 -0
- package/dist/infrastructure/logger.d.ts +7 -0
- package/dist/infrastructure/logger.d.ts.map +1 -0
- package/dist/infrastructure/logger.js +21 -0
- package/dist/infrastructure/logger.js.map +1 -0
- package/dist/infrastructure/native.d.ts +19 -0
- package/dist/infrastructure/native.d.ts.map +1 -0
- package/dist/infrastructure/native.js +105 -0
- package/dist/infrastructure/native.js.map +1 -0
- package/dist/infrastructure/registry.d.ts +57 -0
- package/dist/infrastructure/registry.d.ts.map +1 -0
- package/dist/infrastructure/registry.js +157 -0
- package/dist/infrastructure/registry.js.map +1 -0
- package/dist/infrastructure/result-formatter.d.ts +2 -0
- package/dist/infrastructure/result-formatter.d.ts.map +1 -0
- package/dist/infrastructure/result-formatter.js +3 -0
- package/dist/infrastructure/result-formatter.js.map +1 -0
- package/dist/infrastructure/test-filter.d.ts +5 -0
- package/dist/infrastructure/test-filter.d.ts.map +1 -0
- package/dist/infrastructure/test-filter.js +7 -0
- package/dist/infrastructure/test-filter.js.map +1 -0
- package/dist/infrastructure/update-check.d.ts +24 -0
- package/dist/infrastructure/update-check.d.ts.map +1 -0
- package/dist/infrastructure/update-check.js +150 -0
- package/dist/infrastructure/update-check.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/middleware.d.ts +26 -0
- package/dist/mcp/middleware.d.ts.map +1 -0
- package/dist/mcp/middleware.js +38 -0
- package/dist/mcp/middleware.js.map +1 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +120 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +8 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tool-registry.js +819 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/mcp/tools/ast-query.d.ts +9 -0
- package/dist/mcp/tools/ast-query.d.ts.map +1 -0
- package/dist/mcp/tools/ast-query.js +13 -0
- package/dist/mcp/tools/ast-query.js.map +1 -0
- package/dist/mcp/tools/audit.d.ts +3 -0
- package/dist/mcp/tools/audit.d.ts.map +1 -0
- package/dist/mcp/tools/audit.js +20 -0
- package/dist/mcp/tools/audit.js.map +1 -0
- package/dist/mcp/tools/batch-query.d.ts +9 -0
- package/dist/mcp/tools/batch-query.d.ts.map +1 -0
- package/dist/mcp/tools/batch-query.js +11 -0
- package/dist/mcp/tools/batch-query.js.map +1 -0
- package/dist/mcp/tools/branch-compare.d.ts +3 -0
- package/dist/mcp/tools/branch-compare.d.ts.map +1 -0
- package/dist/mcp/tools/branch-compare.js +10 -0
- package/dist/mcp/tools/branch-compare.js.map +1 -0
- package/dist/mcp/tools/brief.d.ts +3 -0
- package/dist/mcp/tools/brief.d.ts.map +1 -0
- package/dist/mcp/tools/brief.js +8 -0
- package/dist/mcp/tools/brief.js.map +1 -0
- package/dist/mcp/tools/cfg.d.ts +10 -0
- package/dist/mcp/tools/cfg.d.ts.map +1 -0
- package/dist/mcp/tools/cfg.js +20 -0
- package/dist/mcp/tools/cfg.js.map +1 -0
- package/dist/mcp/tools/check.d.ts +24 -0
- package/dist/mcp/tools/check.d.ts.map +1 -0
- package/dist/mcp/tools/check.js +39 -0
- package/dist/mcp/tools/check.js.map +1 -0
- package/dist/mcp/tools/co-changes.d.ts +10 -0
- package/dist/mcp/tools/co-changes.d.ts.map +1 -0
- package/dist/mcp/tools/co-changes.js +19 -0
- package/dist/mcp/tools/co-changes.js.map +1 -0
- package/dist/mcp/tools/code-owners.d.ts +48 -0
- package/dist/mcp/tools/code-owners.d.ts.map +1 -0
- package/dist/mcp/tools/code-owners.js +12 -0
- package/dist/mcp/tools/code-owners.js.map +1 -0
- package/dist/mcp/tools/communities.d.ts +8 -0
- package/dist/mcp/tools/communities.d.ts.map +1 -0
- package/dist/mcp/tools/communities.js +14 -0
- package/dist/mcp/tools/communities.js.map +1 -0
- package/dist/mcp/tools/complexity.d.ts +7 -0
- package/dist/mcp/tools/complexity.d.ts.map +1 -0
- package/dist/mcp/tools/complexity.js +17 -0
- package/dist/mcp/tools/complexity.js.map +1 -0
- package/dist/mcp/tools/context.d.ts +3 -0
- package/dist/mcp/tools/context.d.ts.map +1 -0
- package/dist/mcp/tools/context.js +16 -0
- package/dist/mcp/tools/context.js.map +1 -0
- package/dist/mcp/tools/dataflow.d.ts +6 -0
- package/dist/mcp/tools/dataflow.d.ts.map +1 -0
- package/dist/mcp/tools/dataflow.js +25 -0
- package/dist/mcp/tools/dataflow.js.map +1 -0
- package/dist/mcp/tools/diff-impact.d.ts +3 -0
- package/dist/mcp/tools/diff-impact.d.ts.map +1 -0
- package/dist/mcp/tools/diff-impact.js +23 -0
- package/dist/mcp/tools/diff-impact.js.map +1 -0
- package/dist/mcp/tools/execution-flow.d.ts +17 -0
- package/dist/mcp/tools/execution-flow.d.ts.map +1 -0
- package/dist/mcp/tools/execution-flow.js +25 -0
- package/dist/mcp/tools/execution-flow.js.map +1 -0
- package/dist/mcp/tools/export-graph.d.ts +3 -0
- package/dist/mcp/tools/export-graph.d.ts.map +1 -0
- package/dist/mcp/tools/export-graph.js +55 -0
- package/dist/mcp/tools/export-graph.js.map +1 -0
- package/dist/mcp/tools/file-deps.d.ts +3 -0
- package/dist/mcp/tools/file-deps.d.ts.map +1 -0
- package/dist/mcp/tools/file-deps.js +11 -0
- package/dist/mcp/tools/file-deps.js.map +1 -0
- package/dist/mcp/tools/file-exports.d.ts +3 -0
- package/dist/mcp/tools/file-exports.d.ts.map +1 -0
- package/dist/mcp/tools/file-exports.js +12 -0
- package/dist/mcp/tools/file-exports.js.map +1 -0
- package/dist/mcp/tools/find-cycles.d.ts +6 -0
- package/dist/mcp/tools/find-cycles.d.ts.map +1 -0
- package/dist/mcp/tools/find-cycles.js +15 -0
- package/dist/mcp/tools/find-cycles.js.map +1 -0
- package/dist/mcp/tools/fn-impact.d.ts +3 -0
- package/dist/mcp/tools/fn-impact.d.ts.map +1 -0
- package/dist/mcp/tools/fn-impact.js +14 -0
- package/dist/mcp/tools/fn-impact.js.map +1 -0
- package/dist/mcp/tools/impact-analysis.d.ts +3 -0
- package/dist/mcp/tools/impact-analysis.d.ts.map +1 -0
- package/dist/mcp/tools/impact-analysis.js +11 -0
- package/dist/mcp/tools/impact-analysis.js.map +1 -0
- package/dist/mcp/tools/implementations.d.ts +3 -0
- package/dist/mcp/tools/implementations.d.ts.map +1 -0
- package/dist/mcp/tools/implementations.js +13 -0
- package/dist/mcp/tools/implementations.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +76 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/interfaces.d.ts +3 -0
- package/dist/mcp/tools/interfaces.d.ts.map +1 -0
- package/dist/mcp/tools/interfaces.js +13 -0
- package/dist/mcp/tools/interfaces.js.map +1 -0
- package/dist/mcp/tools/list-functions.d.ts +3 -0
- package/dist/mcp/tools/list-functions.d.ts.map +1 -0
- package/dist/mcp/tools/list-functions.js +13 -0
- package/dist/mcp/tools/list-functions.js.map +1 -0
- package/dist/mcp/tools/list-repos.d.ts +11 -0
- package/dist/mcp/tools/list-repos.d.ts.map +1 -0
- package/dist/mcp/tools/list-repos.js +11 -0
- package/dist/mcp/tools/list-repos.js.map +1 -0
- package/dist/mcp/tools/module-map.d.ts +3 -0
- package/dist/mcp/tools/module-map.d.ts.map +1 -0
- package/dist/mcp/tools/module-map.js +6 -0
- package/dist/mcp/tools/module-map.js.map +1 -0
- package/dist/mcp/tools/node-roles.d.ts +3 -0
- package/dist/mcp/tools/node-roles.d.ts.map +1 -0
- package/dist/mcp/tools/node-roles.js +13 -0
- package/dist/mcp/tools/node-roles.js.map +1 -0
- package/dist/mcp/tools/path.d.ts +3 -0
- package/dist/mcp/tools/path.d.ts.map +1 -0
- package/dist/mcp/tools/path.js +12 -0
- package/dist/mcp/tools/path.js.map +1 -0
- package/dist/mcp/tools/query.d.ts +3 -0
- package/dist/mcp/tools/query.d.ts.map +1 -0
- package/dist/mcp/tools/query.js +29 -0
- package/dist/mcp/tools/query.js.map +1 -0
- package/dist/mcp/tools/semantic-search.d.ts +3 -0
- package/dist/mcp/tools/semantic-search.d.ts.map +1 -0
- package/dist/mcp/tools/semantic-search.js +61 -0
- package/dist/mcp/tools/semantic-search.js.map +1 -0
- package/dist/mcp/tools/sequence.d.ts +18 -0
- package/dist/mcp/tools/sequence.d.ts.map +1 -0
- package/dist/mcp/tools/sequence.js +16 -0
- package/dist/mcp/tools/sequence.js.map +1 -0
- package/dist/mcp/tools/structure.d.ts +3 -0
- package/dist/mcp/tools/structure.d.ts.map +1 -0
- package/dist/mcp/tools/structure.js +14 -0
- package/dist/mcp/tools/structure.js.map +1 -0
- package/dist/mcp/tools/symbol-children.d.ts +3 -0
- package/dist/mcp/tools/symbol-children.d.ts.map +1 -0
- package/dist/mcp/tools/symbol-children.js +13 -0
- package/dist/mcp/tools/symbol-children.js.map +1 -0
- package/dist/mcp/tools/triage.d.ts +3 -0
- package/dist/mcp/tools/triage.d.ts.map +1 -0
- package/dist/mcp/tools/triage.js +34 -0
- package/dist/mcp/tools/triage.js.map +1 -0
- package/dist/mcp/tools/where.d.ts +3 -0
- package/dist/mcp/tools/where.d.ts.map +1 -0
- package/dist/mcp/tools/where.js +12 -0
- package/dist/mcp/tools/where.js.map +1 -0
- package/dist/presentation/audit.d.ts +5 -0
- package/dist/presentation/audit.d.ts.map +1 -0
- package/dist/presentation/audit.js +77 -0
- package/dist/presentation/audit.js.map +1 -0
- package/dist/presentation/batch.d.ts +10 -0
- package/dist/presentation/batch.d.ts.map +1 -0
- package/dist/presentation/batch.js +25 -0
- package/dist/presentation/batch.js.map +1 -0
- package/dist/presentation/branch-compare.d.ts +2 -0
- package/dist/presentation/branch-compare.d.ts.map +1 -0
- package/dist/presentation/branch-compare.js +75 -0
- package/dist/presentation/branch-compare.js.map +1 -0
- package/dist/presentation/brief.d.ts +12 -0
- package/dist/presentation/brief.d.ts.map +1 -0
- package/dist/presentation/brief.js +49 -0
- package/dist/presentation/brief.js.map +1 -0
- package/dist/presentation/cfg.d.ts +5 -0
- package/dist/presentation/cfg.d.ts.map +1 -0
- package/dist/presentation/cfg.js +50 -0
- package/dist/presentation/cfg.js.map +1 -0
- package/dist/presentation/check.d.ts +5 -0
- package/dist/presentation/check.d.ts.map +1 -0
- package/dist/presentation/check.js +70 -0
- package/dist/presentation/check.js.map +1 -0
- package/dist/presentation/cochange.d.ts +9 -0
- package/dist/presentation/cochange.d.ts.map +1 -0
- package/dist/presentation/cochange.js +39 -0
- package/dist/presentation/cochange.js.map +1 -0
- package/dist/presentation/colors.d.ts +26 -0
- package/dist/presentation/colors.d.ts.map +1 -0
- package/dist/presentation/colors.js +42 -0
- package/dist/presentation/colors.js.map +1 -0
- package/dist/presentation/communities.d.ts +5 -0
- package/dist/presentation/communities.d.ts.map +1 -0
- package/dist/presentation/communities.js +56 -0
- package/dist/presentation/communities.js.map +1 -0
- package/dist/presentation/complexity.d.ts +5 -0
- package/dist/presentation/complexity.d.ts.map +1 -0
- package/dist/presentation/complexity.js +56 -0
- package/dist/presentation/complexity.js.map +1 -0
- package/dist/presentation/dataflow.d.ts +5 -0
- package/dist/presentation/dataflow.d.ts.map +1 -0
- package/dist/presentation/dataflow.js +96 -0
- package/dist/presentation/dataflow.js.map +1 -0
- package/dist/presentation/export.d.ts +137 -0
- package/dist/presentation/export.d.ts.map +1 -0
- package/dist/presentation/export.js +374 -0
- package/dist/presentation/export.js.map +1 -0
- package/dist/presentation/flow.d.ts +5 -0
- package/dist/presentation/flow.d.ts.map +1 -0
- package/dist/presentation/flow.js +64 -0
- package/dist/presentation/flow.js.map +1 -0
- package/dist/presentation/manifesto.d.ts +5 -0
- package/dist/presentation/manifesto.d.ts.map +1 -0
- package/dist/presentation/manifesto.js +56 -0
- package/dist/presentation/manifesto.js.map +1 -0
- package/dist/presentation/owners.d.ts +5 -0
- package/dist/presentation/owners.d.ts.map +1 -0
- package/dist/presentation/owners.js +45 -0
- package/dist/presentation/owners.js.map +1 -0
- package/dist/presentation/queries-cli/exports.d.ts +2 -0
- package/dist/presentation/queries-cli/exports.d.ts.map +1 -0
- package/dist/presentation/queries-cli/exports.js +94 -0
- package/dist/presentation/queries-cli/exports.js.map +1 -0
- package/dist/presentation/queries-cli/impact.d.ts +6 -0
- package/dist/presentation/queries-cli/impact.d.ts.map +1 -0
- package/dist/presentation/queries-cli/impact.js +196 -0
- package/dist/presentation/queries-cli/impact.js.map +1 -0
- package/dist/presentation/queries-cli/index.d.ts +6 -0
- package/dist/presentation/queries-cli/index.d.ts.map +1 -0
- package/dist/presentation/queries-cli/index.js +6 -0
- package/dist/presentation/queries-cli/index.js.map +1 -0
- package/dist/presentation/queries-cli/inspect.d.ts +8 -0
- package/dist/presentation/queries-cli/inspect.d.ts.map +1 -0
- package/dist/presentation/queries-cli/inspect.js +353 -0
- package/dist/presentation/queries-cli/inspect.js.map +1 -0
- package/dist/presentation/queries-cli/overview.d.ts +4 -0
- package/dist/presentation/queries-cli/overview.d.ts.map +1 -0
- package/dist/presentation/queries-cli/overview.js +163 -0
- package/dist/presentation/queries-cli/overview.js.map +1 -0
- package/dist/presentation/queries-cli/path.d.ts +2 -0
- package/dist/presentation/queries-cli/path.d.ts.map +1 -0
- package/dist/presentation/queries-cli/path.js +51 -0
- package/dist/presentation/queries-cli/path.js.map +1 -0
- package/dist/presentation/queries-cli.d.ts +2 -0
- package/dist/presentation/queries-cli.d.ts.map +1 -0
- package/dist/presentation/queries-cli.js +12 -0
- package/dist/presentation/queries-cli.js.map +1 -0
- package/dist/presentation/query.d.ts +2 -0
- package/dist/presentation/query.d.ts.map +1 -0
- package/dist/presentation/query.js +6 -0
- package/dist/presentation/query.js.map +1 -0
- package/dist/presentation/result-formatter.d.ts +10 -0
- package/dist/presentation/result-formatter.d.ts.map +1 -0
- package/dist/presentation/result-formatter.js +134 -0
- package/dist/presentation/result-formatter.js.map +1 -0
- package/dist/presentation/sequence-renderer.d.ts +12 -0
- package/dist/presentation/sequence-renderer.d.ts.map +1 -0
- package/dist/presentation/sequence-renderer.js +36 -0
- package/dist/presentation/sequence-renderer.js.map +1 -0
- package/dist/presentation/sequence.d.ts +5 -0
- package/dist/presentation/sequence.d.ts.map +1 -0
- package/dist/presentation/sequence.js +29 -0
- package/dist/presentation/sequence.js.map +1 -0
- package/dist/presentation/structure.d.ts +8 -0
- package/dist/presentation/structure.d.ts.map +1 -0
- package/dist/presentation/structure.js +50 -0
- package/dist/presentation/structure.js.map +1 -0
- package/dist/presentation/table.d.ts +28 -0
- package/dist/presentation/table.d.ts.map +1 -0
- package/dist/presentation/table.js +39 -0
- package/dist/presentation/table.js.map +1 -0
- package/dist/presentation/triage.d.ts +5 -0
- package/dist/presentation/triage.d.ts.map +1 -0
- package/dist/presentation/triage.js +37 -0
- package/dist/presentation/triage.js.map +1 -0
- package/dist/presentation/viewer.d.ts +85 -0
- package/dist/presentation/viewer.d.ts.map +1 -0
- package/dist/presentation/viewer.js +621 -0
- package/dist/presentation/viewer.js.map +1 -0
- package/dist/shared/constants.d.ts +11 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +35 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/errors.d.ts +47 -0
- package/dist/shared/errors.d.ts.map +1 -0
- package/dist/shared/errors.js +69 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/file-utils.d.ts +14 -0
- package/dist/shared/file-utils.d.ts.map +1 -0
- package/dist/shared/file-utils.js +165 -0
- package/dist/shared/file-utils.js.map +1 -0
- package/dist/shared/generators.d.ts +62 -0
- package/dist/shared/generators.d.ts.map +1 -0
- package/dist/shared/generators.js +120 -0
- package/dist/shared/generators.js.map +1 -0
- package/dist/shared/hierarchy.d.ts +2 -0
- package/dist/shared/hierarchy.d.ts.map +1 -0
- package/dist/shared/hierarchy.js +27 -0
- package/dist/shared/hierarchy.js.map +1 -0
- package/dist/shared/kinds.d.ts +11 -0
- package/dist/shared/kinds.d.ts.map +1 -0
- package/dist/shared/kinds.js +56 -0
- package/dist/shared/kinds.js.map +1 -0
- package/dist/shared/normalize.d.ts +19 -0
- package/dist/shared/normalize.d.ts.map +1 -0
- package/dist/shared/normalize.js +59 -0
- package/dist/shared/normalize.js.map +1 -0
- package/dist/shared/paginate.d.ts +80 -0
- package/dist/shared/paginate.d.ts.map +1 -0
- package/dist/shared/paginate.js +111 -0
- package/dist/shared/paginate.js.map +1 -0
- package/dist/types.d.ts +1322 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +21 -15
- package/src/ast-analysis/engine.js +252 -258
- package/src/ast-analysis/shared.js +0 -12
- package/src/ast-analysis/visitors/cfg-visitor.js +635 -649
- package/src/ast-analysis/visitors/complexity-visitor.js +135 -139
- package/src/ast-analysis/visitors/dataflow-visitor.js +230 -224
- package/src/cli/commands/ast.js +2 -1
- package/src/cli/commands/audit.js +2 -1
- package/src/cli/commands/batch.js +2 -1
- package/src/cli/commands/brief.js +12 -0
- package/src/cli/commands/cfg.js +2 -1
- package/src/cli/commands/check.js +20 -23
- package/src/cli/commands/children.js +6 -1
- package/src/cli/commands/complexity.js +2 -1
- package/src/cli/commands/context.js +6 -1
- package/src/cli/commands/dataflow.js +2 -1
- package/src/cli/commands/deps.js +8 -3
- package/src/cli/commands/diff-impact.js +2 -0
- package/src/cli/commands/flow.js +2 -1
- package/src/cli/commands/fn-impact.js +8 -1
- package/src/cli/commands/implementations.js +29 -0
- package/src/cli/commands/info.js +1 -1
- package/src/cli/commands/interfaces.js +29 -0
- package/src/cli/commands/owners.js +4 -2
- package/src/cli/commands/query.js +6 -1
- package/src/cli/commands/roles.js +4 -2
- package/src/cli/commands/search.js +8 -2
- package/src/cli/commands/sequence.js +2 -1
- package/src/cli/commands/triage.js +42 -28
- package/src/db/connection.js +18 -12
- package/src/db/index.js +2 -0
- package/src/db/migrations.js +41 -64
- package/src/db/query-builder.js +69 -8
- package/src/db/repository/edges.js +38 -0
- package/src/db/repository/in-memory-repository.js +38 -18
- package/src/db/repository/index.js +2 -0
- package/src/db/repository/nodes.js +8 -10
- package/src/domain/analysis/brief.js +161 -0
- package/src/domain/analysis/context.js +237 -199
- package/src/domain/analysis/dependencies.js +200 -146
- package/src/domain/analysis/exports.js +84 -12
- package/src/domain/analysis/impact.js +350 -157
- package/src/domain/analysis/implementations.js +98 -0
- package/src/domain/analysis/module-map.js +256 -221
- package/src/domain/analysis/roles.js +16 -7
- package/src/domain/analysis/symbol-lookup.js +7 -5
- package/src/domain/graph/builder/helpers.js +1 -1
- package/src/domain/graph/builder/incremental.js +136 -90
- package/src/domain/graph/builder/pipeline.js +114 -80
- package/src/domain/graph/builder/stages/build-edges.js +413 -237
- package/src/domain/graph/builder/stages/detect-changes.js +198 -177
- package/src/domain/graph/builder/stages/insert-nodes.js +147 -139
- package/src/domain/graph/resolve.js +315 -1
- package/src/domain/graph/watcher.js +2 -2
- package/src/domain/parser.js +90 -17
- package/src/domain/queries.js +2 -0
- package/src/domain/search/search/filters.js +9 -5
- package/src/domain/search/search/hybrid.js +7 -4
- package/src/domain/search/search/keyword.js +12 -5
- package/src/domain/search/search/prepare.js +13 -5
- package/src/domain/search/search/semantic.js +11 -6
- package/src/extractors/csharp.js +286 -207
- package/src/extractors/go.js +304 -159
- package/src/extractors/hcl.js +94 -78
- package/src/extractors/java.js +239 -207
- package/src/extractors/javascript.js +437 -305
- package/src/extractors/php.js +276 -220
- package/src/extractors/python.js +379 -247
- package/src/extractors/ruby.js +192 -185
- package/src/extractors/rust.js +243 -168
- package/src/features/ast.js +5 -3
- package/src/features/audit.js +6 -3
- package/src/features/boundaries.js +98 -83
- package/src/features/cfg.js +134 -143
- package/src/features/communities.js +70 -53
- package/src/features/complexity.js +143 -132
- package/src/features/dataflow.js +146 -149
- package/src/features/export.js +3 -3
- package/src/features/graph-enrichment.js +3 -3
- package/src/features/manifesto.js +9 -6
- package/src/features/owners.js +4 -3
- package/src/features/sequence.js +155 -142
- package/src/features/shared/find-nodes.js +31 -0
- package/src/features/structure.js +161 -101
- package/src/features/triage.js +93 -71
- package/src/graph/classifiers/risk.js +12 -4
- package/src/graph/classifiers/roles.js +54 -3
- package/src/index.js +1 -0
- package/src/infrastructure/config.js +255 -4
- package/src/mcp/middleware.js +20 -2
- package/src/mcp/server.js +71 -56
- package/src/mcp/tool-registry.js +53 -1
- package/src/mcp/tools/brief.js +8 -0
- package/src/mcp/tools/implementations.js +14 -0
- package/src/mcp/tools/index.js +6 -0
- package/src/mcp/tools/interfaces.js +14 -0
- package/src/presentation/brief.js +51 -0
- package/src/presentation/queries-cli/exports.js +72 -15
- package/src/presentation/queries-cli/impact.js +55 -39
- package/src/presentation/queries-cli/index.js +9 -1
- package/src/presentation/queries-cli/inspect.js +241 -182
- package/src/presentation/queries-cli/overview.js +57 -58
- package/src/presentation/queries-cli/path.js +36 -29
- package/src/presentation/queries-cli.js +3 -1
- package/src/presentation/result-formatter.js +9 -5
- package/src/presentation/table.js +0 -8
- package/src/shared/file-utils.js +20 -11
- package/src/shared/generators.js +7 -3
- package/src/shared/kinds.js +14 -1
- package/src/shared/paginate.js +10 -2
- package/src/types.ts +1609 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { computeLOCMetrics as _computeLOCMetrics, computeMaintainabilityIndex as _computeMaintainabilityIndex, } from '../ast-analysis/metrics.js';
|
|
4
|
+
import { COMPLEXITY_RULES, HALSTEAD_RULES } from '../ast-analysis/rules/index.js';
|
|
5
|
+
import { findFunctionNode as _findFunctionNode, buildExtensionSet, buildExtToLangMap, } from '../ast-analysis/shared.js';
|
|
6
|
+
import { walkWithVisitors } from '../ast-analysis/visitor.js';
|
|
7
|
+
import { createComplexityVisitor } from '../ast-analysis/visitors/complexity-visitor.js';
|
|
8
|
+
import { getFunctionNodeId, openReadonlyOrFail } from '../db/index.js';
|
|
9
|
+
import { buildFileConditionSQL } from '../db/query-builder.js';
|
|
10
|
+
import { loadConfig } from '../infrastructure/config.js';
|
|
11
|
+
import { debug, info } from '../infrastructure/logger.js';
|
|
12
|
+
import { isTestFile } from '../infrastructure/test-filter.js';
|
|
13
|
+
import { paginateResult } from '../shared/paginate.js';
|
|
14
|
+
// Re-export rules for backward compatibility
|
|
15
|
+
export { COMPLEXITY_RULES, HALSTEAD_RULES };
|
|
16
|
+
// Extensions whose language has complexity rules — used to skip needless WASM init
|
|
17
|
+
const COMPLEXITY_EXTENSIONS = buildExtensionSet(COMPLEXITY_RULES);
|
|
18
|
+
// ─── Halstead Metrics Computation ─────────────────────────────────────────
|
|
19
|
+
/**
|
|
20
|
+
* Compute Halstead metrics for a function's AST subtree.
|
|
21
|
+
*
|
|
22
|
+
* @param {object} functionNode - tree-sitter node for the function
|
|
23
|
+
* @param {string} language - Language ID
|
|
24
|
+
* @returns {{ n1: number, n2: number, bigN1: number, bigN2: number, vocabulary: number, length: number, volume: number, difficulty: number, effort: number, bugs: number } | null}
|
|
25
|
+
*/
|
|
26
|
+
export function computeHalsteadMetrics(functionNode, language) {
|
|
27
|
+
const rules = HALSTEAD_RULES.get(language);
|
|
28
|
+
if (!rules)
|
|
29
|
+
return null;
|
|
30
|
+
const operators = new Map(); // type -> count
|
|
31
|
+
const operands = new Map(); // text -> count
|
|
32
|
+
function walk(node) {
|
|
33
|
+
if (!node)
|
|
34
|
+
return;
|
|
35
|
+
// Skip type annotation subtrees
|
|
36
|
+
if (rules.skipTypes.has(node.type))
|
|
37
|
+
return;
|
|
38
|
+
// Compound operators (non-leaf): count the node type as an operator
|
|
39
|
+
if (rules.compoundOperators.has(node.type)) {
|
|
40
|
+
operators.set(node.type, (operators.get(node.type) || 0) + 1);
|
|
41
|
+
}
|
|
42
|
+
// Leaf nodes: classify as operator or operand
|
|
43
|
+
if (node.childCount === 0) {
|
|
44
|
+
if (rules.operatorLeafTypes.has(node.type)) {
|
|
45
|
+
operators.set(node.type, (operators.get(node.type) || 0) + 1);
|
|
46
|
+
}
|
|
47
|
+
else if (rules.operandLeafTypes.has(node.type)) {
|
|
48
|
+
const text = node.text;
|
|
49
|
+
operands.set(text, (operands.get(text) || 0) + 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
53
|
+
walk(node.child(i));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
walk(functionNode);
|
|
57
|
+
const n1 = operators.size; // distinct operators
|
|
58
|
+
const n2 = operands.size; // distinct operands
|
|
59
|
+
let bigN1 = 0; // total operators
|
|
60
|
+
for (const c of operators.values())
|
|
61
|
+
bigN1 += c;
|
|
62
|
+
let bigN2 = 0; // total operands
|
|
63
|
+
for (const c of operands.values())
|
|
64
|
+
bigN2 += c;
|
|
65
|
+
const vocabulary = n1 + n2;
|
|
66
|
+
const length = bigN1 + bigN2;
|
|
67
|
+
// Guard against zero
|
|
68
|
+
const volume = vocabulary > 0 ? length * Math.log2(vocabulary) : 0;
|
|
69
|
+
const difficulty = n2 > 0 ? (n1 / 2) * (bigN2 / n2) : 0;
|
|
70
|
+
const effort = difficulty * volume;
|
|
71
|
+
const bugs = volume / 3000;
|
|
72
|
+
return {
|
|
73
|
+
n1,
|
|
74
|
+
n2,
|
|
75
|
+
bigN1,
|
|
76
|
+
bigN2,
|
|
77
|
+
vocabulary,
|
|
78
|
+
length,
|
|
79
|
+
volume: +volume.toFixed(2),
|
|
80
|
+
difficulty: +difficulty.toFixed(2),
|
|
81
|
+
effort: +effort.toFixed(2),
|
|
82
|
+
bugs: +bugs.toFixed(4),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// ─── LOC Metrics Computation ──────────────────────────────────────────────
|
|
86
|
+
// Delegated to ast-analysis/metrics.js; re-exported for backward compatibility.
|
|
87
|
+
export const computeLOCMetrics = _computeLOCMetrics;
|
|
88
|
+
// ─── Maintainability Index ────────────────────────────────────────────────
|
|
89
|
+
// Delegated to ast-analysis/metrics.js; re-exported for backward compatibility.
|
|
90
|
+
export const computeMaintainabilityIndex = _computeMaintainabilityIndex;
|
|
91
|
+
// ─── Algorithm: Single-Traversal DFS ──────────────────────────────────────
|
|
92
|
+
/**
|
|
93
|
+
* Compute cognitive complexity, cyclomatic complexity, and max nesting depth
|
|
94
|
+
* for a function's AST subtree in a single DFS walk.
|
|
95
|
+
*
|
|
96
|
+
* @param {object} functionNode - tree-sitter node for the function body
|
|
97
|
+
* @param {string} language - Language ID (e.g. 'javascript', 'typescript')
|
|
98
|
+
* @returns {{ cognitive: number, cyclomatic: number, maxNesting: number } | null}
|
|
99
|
+
*/
|
|
100
|
+
export function computeFunctionComplexity(functionNode, language) {
|
|
101
|
+
const rules = COMPLEXITY_RULES.get(language);
|
|
102
|
+
if (!rules)
|
|
103
|
+
return null;
|
|
104
|
+
let cognitive = 0;
|
|
105
|
+
let cyclomatic = 1; // McCabe starts at 1
|
|
106
|
+
let maxNesting = 0;
|
|
107
|
+
function walk(node, nestingLevel, isTopFunction) {
|
|
108
|
+
if (!node)
|
|
109
|
+
return;
|
|
110
|
+
const type = node.type;
|
|
111
|
+
// Track nesting depth
|
|
112
|
+
if (nestingLevel > maxNesting)
|
|
113
|
+
maxNesting = nestingLevel;
|
|
114
|
+
// Handle logical operators in binary expressions
|
|
115
|
+
if (type === rules.logicalNodeType) {
|
|
116
|
+
const op = node.child(1)?.type;
|
|
117
|
+
if (op && rules.logicalOperators.has(op)) {
|
|
118
|
+
// Cyclomatic: +1 for every logical operator
|
|
119
|
+
cyclomatic++;
|
|
120
|
+
// Cognitive: +1 only when operator changes from the previous sibling sequence
|
|
121
|
+
// Walk up to check if parent is same type with same operator
|
|
122
|
+
const parent = node.parent;
|
|
123
|
+
let sameSequence = false;
|
|
124
|
+
if (parent && parent.type === rules.logicalNodeType) {
|
|
125
|
+
const parentOp = parent.child(1)?.type;
|
|
126
|
+
if (parentOp === op) {
|
|
127
|
+
sameSequence = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (!sameSequence) {
|
|
131
|
+
cognitive++;
|
|
132
|
+
}
|
|
133
|
+
// Walk children manually to avoid double-counting
|
|
134
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
135
|
+
walk(node.child(i), nestingLevel, false);
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Handle optional chaining (cyclomatic only)
|
|
141
|
+
if (type === rules.optionalChainType) {
|
|
142
|
+
cyclomatic++;
|
|
143
|
+
}
|
|
144
|
+
// Handle branch/control flow nodes (skip keyword leaf tokens like Ruby's `if`)
|
|
145
|
+
if (rules.branchNodes.has(type) && node.childCount > 0) {
|
|
146
|
+
// Pattern A: else clause wraps if (JS/C#/Rust)
|
|
147
|
+
if (rules.elseNodeType && type === rules.elseNodeType) {
|
|
148
|
+
const firstChild = node.namedChild(0);
|
|
149
|
+
if (firstChild && firstChild.type === rules.ifNodeType) {
|
|
150
|
+
// else-if: the if_statement child handles its own increment
|
|
151
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
152
|
+
walk(node.child(i), nestingLevel, false);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Plain else
|
|
157
|
+
cognitive++;
|
|
158
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
159
|
+
walk(node.child(i), nestingLevel, false);
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// Pattern B: explicit elif node (Python/Ruby/PHP)
|
|
164
|
+
if (rules.elifNodeType && type === rules.elifNodeType) {
|
|
165
|
+
cognitive++;
|
|
166
|
+
cyclomatic++;
|
|
167
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
168
|
+
walk(node.child(i), nestingLevel, false);
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// Detect else-if via Pattern A or C
|
|
173
|
+
let isElseIf = false;
|
|
174
|
+
if (type === rules.ifNodeType) {
|
|
175
|
+
if (rules.elseViaAlternative) {
|
|
176
|
+
// Pattern C (Go/Java): if_statement is the alternative of parent if_statement
|
|
177
|
+
isElseIf =
|
|
178
|
+
node.parent?.type === rules.ifNodeType &&
|
|
179
|
+
node.parent.childForFieldName('alternative')?.id === node.id;
|
|
180
|
+
}
|
|
181
|
+
else if (rules.elseNodeType) {
|
|
182
|
+
// Pattern A (JS/C#/Rust): if_statement inside else_clause
|
|
183
|
+
isElseIf = node.parent?.type === rules.elseNodeType;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (isElseIf) {
|
|
187
|
+
cognitive++;
|
|
188
|
+
cyclomatic++;
|
|
189
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
190
|
+
walk(node.child(i), nestingLevel, false);
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// Regular branch node
|
|
195
|
+
cognitive += 1 + nestingLevel; // structural + nesting
|
|
196
|
+
cyclomatic++;
|
|
197
|
+
// Switch-like nodes don't add cyclomatic themselves (cases do)
|
|
198
|
+
if (rules.switchLikeNodes?.has(type)) {
|
|
199
|
+
cyclomatic--; // Undo the ++ above; cases handle cyclomatic
|
|
200
|
+
}
|
|
201
|
+
if (rules.nestingNodes.has(type)) {
|
|
202
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
203
|
+
walk(node.child(i), nestingLevel + 1, false);
|
|
204
|
+
}
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Pattern C plain else: block that is the alternative of an if_statement (Go/Java)
|
|
209
|
+
if (rules.elseViaAlternative &&
|
|
210
|
+
type !== rules.ifNodeType &&
|
|
211
|
+
node.parent?.type === rules.ifNodeType &&
|
|
212
|
+
node.parent.childForFieldName('alternative')?.id === node.id) {
|
|
213
|
+
cognitive++;
|
|
214
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
215
|
+
walk(node.child(i), nestingLevel, false);
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
// Handle case nodes (cyclomatic only, skip keyword leaves)
|
|
220
|
+
if (rules.caseNodes.has(type) && node.childCount > 0) {
|
|
221
|
+
cyclomatic++;
|
|
222
|
+
}
|
|
223
|
+
// Handle nested function definitions (increase nesting)
|
|
224
|
+
if (!isTopFunction && rules.functionNodes.has(type)) {
|
|
225
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
226
|
+
walk(node.child(i), nestingLevel + 1, false);
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
// Walk children
|
|
231
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
232
|
+
walk(node.child(i), nestingLevel, false);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
walk(functionNode, 0, true);
|
|
236
|
+
return { cognitive, cyclomatic, maxNesting };
|
|
237
|
+
}
|
|
238
|
+
// ─── Merged Single-Pass Computation ───────────────────────────────────────
|
|
239
|
+
/**
|
|
240
|
+
* Compute all metrics (complexity + Halstead + LOC + MI) in a single DFS walk.
|
|
241
|
+
* Merges computeFunctionComplexity and computeHalsteadMetrics into one tree
|
|
242
|
+
* traversal, avoiding two separate DFS walks per function node at build time.
|
|
243
|
+
* LOC is text-based (not tree-based) and computed separately (very cheap).
|
|
244
|
+
*
|
|
245
|
+
* Now delegates to the complexity visitor via the unified walker.
|
|
246
|
+
*
|
|
247
|
+
* @param {object} functionNode - tree-sitter node for the function
|
|
248
|
+
* @param {string} langId - Language ID (e.g. 'javascript', 'python')
|
|
249
|
+
* @returns {{ cognitive: number, cyclomatic: number, maxNesting: number, halstead: object|null, loc: object, mi: number } | null}
|
|
250
|
+
*/
|
|
251
|
+
export function computeAllMetrics(functionNode, langId) {
|
|
252
|
+
const cRules = COMPLEXITY_RULES.get(langId);
|
|
253
|
+
if (!cRules)
|
|
254
|
+
return null;
|
|
255
|
+
const hRules = HALSTEAD_RULES.get(langId);
|
|
256
|
+
const visitor = createComplexityVisitor(cRules, hRules, { langId });
|
|
257
|
+
const nestingNodes = new Set(cRules.nestingNodes);
|
|
258
|
+
// NOTE: do NOT add functionNodes here — in function-level mode the walker
|
|
259
|
+
// walks a single function node, and adding it to nestingNodeTypes would
|
|
260
|
+
// inflate context.nestingLevel by +1 for the entire body.
|
|
261
|
+
const results = walkWithVisitors(functionNode, [visitor], langId, {
|
|
262
|
+
nestingNodeTypes: nestingNodes,
|
|
263
|
+
});
|
|
264
|
+
const rawResult = results.complexity;
|
|
265
|
+
// The visitor's finish() in function-level mode returns the raw metrics
|
|
266
|
+
// but without LOC (needs the functionNode text). Compute LOC + MI here.
|
|
267
|
+
const loc = _computeLOCMetrics(functionNode, langId);
|
|
268
|
+
const volume = rawResult.halstead ? rawResult.halstead.volume : 0;
|
|
269
|
+
const commentRatio = loc.loc > 0 ? loc.commentLines / loc.loc : 0;
|
|
270
|
+
const mi = _computeMaintainabilityIndex(volume, rawResult.cyclomatic, loc.sloc, commentRatio);
|
|
271
|
+
return {
|
|
272
|
+
cognitive: rawResult.cognitive,
|
|
273
|
+
cyclomatic: rawResult.cyclomatic,
|
|
274
|
+
maxNesting: rawResult.maxNesting,
|
|
275
|
+
halstead: rawResult.halstead,
|
|
276
|
+
loc,
|
|
277
|
+
mi,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
// ─── Build-Time: Compute Metrics for Changed Files ────────────────────────
|
|
281
|
+
/**
|
|
282
|
+
* Find the function body node in a parse tree that matches a given line range.
|
|
283
|
+
*/
|
|
284
|
+
export { _findFunctionNode as findFunctionNode };
|
|
285
|
+
async function initWasmParsersIfNeeded(fileSymbols) {
|
|
286
|
+
for (const [relPath, symbols] of fileSymbols) {
|
|
287
|
+
if (!symbols._tree) {
|
|
288
|
+
const ext = path.extname(relPath).toLowerCase();
|
|
289
|
+
if (!COMPLEXITY_EXTENSIONS.has(ext))
|
|
290
|
+
continue;
|
|
291
|
+
const hasPrecomputed = symbols.definitions.every((d) => (d.kind !== 'function' && d.kind !== 'method') || d.complexity);
|
|
292
|
+
if (!hasPrecomputed) {
|
|
293
|
+
const { createParsers } = await import('../domain/parser.js');
|
|
294
|
+
const parsers = await createParsers();
|
|
295
|
+
const extToLang = buildExtToLangMap();
|
|
296
|
+
return { parsers, extToLang };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return { parsers: null, extToLang: null };
|
|
301
|
+
}
|
|
302
|
+
function getTreeForFile(symbols, relPath, rootDir, parsers, extToLang, getParser) {
|
|
303
|
+
let tree = symbols._tree;
|
|
304
|
+
let langId = symbols._langId;
|
|
305
|
+
const allPrecomputed = symbols.definitions.every((d) => (d.kind !== 'function' && d.kind !== 'method') || d.complexity);
|
|
306
|
+
if (!allPrecomputed && !tree) {
|
|
307
|
+
const ext = path.extname(relPath).toLowerCase();
|
|
308
|
+
if (!COMPLEXITY_EXTENSIONS.has(ext))
|
|
309
|
+
return null;
|
|
310
|
+
if (!extToLang)
|
|
311
|
+
return null;
|
|
312
|
+
langId = extToLang.get(ext);
|
|
313
|
+
if (!langId)
|
|
314
|
+
return null;
|
|
315
|
+
const absPath = path.join(rootDir, relPath);
|
|
316
|
+
let code;
|
|
317
|
+
try {
|
|
318
|
+
code = fs.readFileSync(absPath, 'utf-8');
|
|
319
|
+
}
|
|
320
|
+
catch (e) {
|
|
321
|
+
debug(`complexity: cannot read ${relPath}: ${e.message}`);
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
const parser = getParser(parsers, absPath);
|
|
325
|
+
if (!parser)
|
|
326
|
+
return null;
|
|
327
|
+
try {
|
|
328
|
+
tree = parser.parse(code);
|
|
329
|
+
}
|
|
330
|
+
catch (e) {
|
|
331
|
+
debug(`complexity: parse failed for ${relPath}: ${e.message}`);
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return { tree, langId };
|
|
336
|
+
}
|
|
337
|
+
function upsertPrecomputedComplexity(db, upsert, def, relPath) {
|
|
338
|
+
const nodeId = getFunctionNodeId(db, def.name, relPath, def.line);
|
|
339
|
+
if (!nodeId)
|
|
340
|
+
return 0;
|
|
341
|
+
const ch = def.complexity.halstead;
|
|
342
|
+
const cl = def.complexity.loc;
|
|
343
|
+
upsert.run(nodeId, def.complexity.cognitive, def.complexity.cyclomatic, def.complexity.maxNesting ?? 0, cl ? cl.loc : 0, cl ? cl.sloc : 0, cl ? cl.commentLines : 0, ch ? ch.n1 : 0, ch ? ch.n2 : 0, ch ? ch.bigN1 : 0, ch ? ch.bigN2 : 0, ch ? ch.vocabulary : 0, ch ? ch.length : 0, ch ? ch.volume : 0, ch ? ch.difficulty : 0, ch ? ch.effort : 0, ch ? ch.bugs : 0, def.complexity.maintainabilityIndex ?? 0);
|
|
344
|
+
return 1;
|
|
345
|
+
}
|
|
346
|
+
function upsertAstComplexity(db, upsert, def, relPath, tree, langId, rules) {
|
|
347
|
+
if (!tree || !rules)
|
|
348
|
+
return 0;
|
|
349
|
+
const funcNode = _findFunctionNode(tree.rootNode, def.line, def.endLine, rules);
|
|
350
|
+
if (!funcNode)
|
|
351
|
+
return 0;
|
|
352
|
+
const metrics = computeAllMetrics(funcNode, langId);
|
|
353
|
+
if (!metrics)
|
|
354
|
+
return 0;
|
|
355
|
+
const nodeId = getFunctionNodeId(db, def.name, relPath, def.line);
|
|
356
|
+
if (!nodeId)
|
|
357
|
+
return 0;
|
|
358
|
+
const h = metrics.halstead;
|
|
359
|
+
upsert.run(nodeId, metrics.cognitive, metrics.cyclomatic, metrics.maxNesting, metrics.loc.loc, metrics.loc.sloc, metrics.loc.commentLines, h ? h.n1 : 0, h ? h.n2 : 0, h ? h.bigN1 : 0, h ? h.bigN2 : 0, h ? h.vocabulary : 0, h ? h.length : 0, h ? h.volume : 0, h ? h.difficulty : 0, h ? h.effort : 0, h ? h.bugs : 0, metrics.mi);
|
|
360
|
+
return 1;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Re-parse changed files with WASM tree-sitter, find function AST subtrees,
|
|
364
|
+
* compute complexity, and upsert into function_complexity table.
|
|
365
|
+
*
|
|
366
|
+
* @param {object} db - open better-sqlite3 database (read-write)
|
|
367
|
+
* @param {Map<string, object>} fileSymbols - Map<relPath, { definitions, ... }>
|
|
368
|
+
* @param {string} rootDir - absolute project root path
|
|
369
|
+
* @param {object} [engineOpts] - engine options (unused; always uses WASM for AST)
|
|
370
|
+
*/
|
|
371
|
+
export async function buildComplexityMetrics(db, fileSymbols, rootDir, _engineOpts) {
|
|
372
|
+
const { parsers, extToLang } = await initWasmParsersIfNeeded(fileSymbols);
|
|
373
|
+
const { getParser } = await import('../domain/parser.js');
|
|
374
|
+
const upsert = db.prepare(`INSERT OR REPLACE INTO function_complexity
|
|
375
|
+
(node_id, cognitive, cyclomatic, max_nesting,
|
|
376
|
+
loc, sloc, comment_lines,
|
|
377
|
+
halstead_n1, halstead_n2, halstead_big_n1, halstead_big_n2,
|
|
378
|
+
halstead_vocabulary, halstead_length, halstead_volume,
|
|
379
|
+
halstead_difficulty, halstead_effort, halstead_bugs,
|
|
380
|
+
maintainability_index)
|
|
381
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
382
|
+
let analyzed = 0;
|
|
383
|
+
const tx = db.transaction(() => {
|
|
384
|
+
for (const [relPath, symbols] of fileSymbols) {
|
|
385
|
+
const result = getTreeForFile(symbols, relPath, rootDir, parsers, extToLang, getParser);
|
|
386
|
+
const tree = result ? result.tree : null;
|
|
387
|
+
const langId = result ? result.langId : null;
|
|
388
|
+
const rules = langId ? COMPLEXITY_RULES.get(langId) : null;
|
|
389
|
+
for (const def of symbols.definitions) {
|
|
390
|
+
if (def.kind !== 'function' && def.kind !== 'method')
|
|
391
|
+
continue;
|
|
392
|
+
if (!def.line)
|
|
393
|
+
continue;
|
|
394
|
+
if (def.complexity) {
|
|
395
|
+
analyzed += upsertPrecomputedComplexity(db, upsert, def, relPath);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
analyzed += upsertAstComplexity(db, upsert, def, relPath, tree, langId, rules);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
tx();
|
|
404
|
+
if (analyzed > 0) {
|
|
405
|
+
info(`Complexity: ${analyzed} functions analyzed`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
// ─── Query-Time Functions ─────────────────────────────────────────────────
|
|
409
|
+
/**
|
|
410
|
+
* Return structured complexity data for querying.
|
|
411
|
+
*
|
|
412
|
+
* @param {string} [customDbPath] - Path to graph.db
|
|
413
|
+
* @param {object} [opts] - Options
|
|
414
|
+
* @param {string} [opts.target] - Function name filter (partial match)
|
|
415
|
+
* @param {number} [opts.limit] - Max results (default: 20)
|
|
416
|
+
* @param {string} [opts.sort] - Sort by: cognitive | cyclomatic | nesting (default: cognitive)
|
|
417
|
+
* @param {boolean} [opts.aboveThreshold] - Only functions above warn thresholds
|
|
418
|
+
* @param {string} [opts.file] - Filter by file (partial match)
|
|
419
|
+
* @param {string} [opts.kind] - Filter by symbol kind
|
|
420
|
+
* @param {boolean} [opts.noTests] - Exclude test files
|
|
421
|
+
* @returns {{ functions: object[], summary: object, thresholds: object }}
|
|
422
|
+
*/
|
|
423
|
+
export function complexityData(customDbPath, opts = {}) {
|
|
424
|
+
const db = openReadonlyOrFail(customDbPath);
|
|
425
|
+
try {
|
|
426
|
+
const sort = opts.sort || 'cognitive';
|
|
427
|
+
const noTests = opts.noTests || false;
|
|
428
|
+
const aboveThreshold = opts.aboveThreshold || false;
|
|
429
|
+
const target = opts.target || null;
|
|
430
|
+
const fileFilter = opts.file || null;
|
|
431
|
+
const kindFilter = opts.kind || null;
|
|
432
|
+
// Load thresholds from config
|
|
433
|
+
const config = opts.config || loadConfig(process.cwd());
|
|
434
|
+
const thresholds = config.manifesto?.rules || {
|
|
435
|
+
cognitive: { warn: 15, fail: null },
|
|
436
|
+
cyclomatic: { warn: 10, fail: null },
|
|
437
|
+
maxNesting: { warn: 4, fail: null },
|
|
438
|
+
maintainabilityIndex: { warn: 20, fail: null },
|
|
439
|
+
};
|
|
440
|
+
// Build query
|
|
441
|
+
let where = "WHERE n.kind IN ('function','method')";
|
|
442
|
+
const params = [];
|
|
443
|
+
if (noTests) {
|
|
444
|
+
where += ` AND n.file NOT LIKE '%.test.%'
|
|
445
|
+
AND n.file NOT LIKE '%.spec.%'
|
|
446
|
+
AND n.file NOT LIKE '%__test__%'
|
|
447
|
+
AND n.file NOT LIKE '%__tests__%'
|
|
448
|
+
AND n.file NOT LIKE '%.stories.%'`;
|
|
449
|
+
}
|
|
450
|
+
if (target) {
|
|
451
|
+
where += ' AND n.name LIKE ?';
|
|
452
|
+
params.push(`%${target}%`);
|
|
453
|
+
}
|
|
454
|
+
{
|
|
455
|
+
const fc = buildFileConditionSQL(fileFilter, 'n.file');
|
|
456
|
+
where += fc.sql;
|
|
457
|
+
params.push(...fc.params);
|
|
458
|
+
}
|
|
459
|
+
if (kindFilter) {
|
|
460
|
+
where += ' AND n.kind = ?';
|
|
461
|
+
params.push(kindFilter);
|
|
462
|
+
}
|
|
463
|
+
const isValidThreshold = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
464
|
+
let having = '';
|
|
465
|
+
if (aboveThreshold) {
|
|
466
|
+
const conditions = [];
|
|
467
|
+
if (isValidThreshold(thresholds.cognitive?.warn)) {
|
|
468
|
+
conditions.push(`fc.cognitive >= ${thresholds.cognitive.warn}`);
|
|
469
|
+
}
|
|
470
|
+
if (isValidThreshold(thresholds.cyclomatic?.warn)) {
|
|
471
|
+
conditions.push(`fc.cyclomatic >= ${thresholds.cyclomatic.warn}`);
|
|
472
|
+
}
|
|
473
|
+
if (isValidThreshold(thresholds.maxNesting?.warn)) {
|
|
474
|
+
conditions.push(`fc.max_nesting >= ${thresholds.maxNesting.warn}`);
|
|
475
|
+
}
|
|
476
|
+
if (isValidThreshold(thresholds.maintainabilityIndex?.warn)) {
|
|
477
|
+
conditions.push(`fc.maintainability_index > 0 AND fc.maintainability_index <= ${thresholds.maintainabilityIndex.warn}`);
|
|
478
|
+
}
|
|
479
|
+
if (conditions.length > 0) {
|
|
480
|
+
having = `AND (${conditions.join(' OR ')})`;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
const orderMap = {
|
|
484
|
+
cognitive: 'fc.cognitive DESC',
|
|
485
|
+
cyclomatic: 'fc.cyclomatic DESC',
|
|
486
|
+
nesting: 'fc.max_nesting DESC',
|
|
487
|
+
mi: 'fc.maintainability_index ASC',
|
|
488
|
+
volume: 'fc.halstead_volume DESC',
|
|
489
|
+
effort: 'fc.halstead_effort DESC',
|
|
490
|
+
bugs: 'fc.halstead_bugs DESC',
|
|
491
|
+
loc: 'fc.loc DESC',
|
|
492
|
+
};
|
|
493
|
+
const orderBy = orderMap[sort] || 'fc.cognitive DESC';
|
|
494
|
+
let rows;
|
|
495
|
+
try {
|
|
496
|
+
rows = db
|
|
497
|
+
.prepare(`SELECT n.name, n.kind, n.file, n.line, n.end_line,
|
|
498
|
+
fc.cognitive, fc.cyclomatic, fc.max_nesting,
|
|
499
|
+
fc.loc, fc.sloc, fc.maintainability_index,
|
|
500
|
+
fc.halstead_volume, fc.halstead_difficulty, fc.halstead_effort, fc.halstead_bugs
|
|
501
|
+
FROM function_complexity fc
|
|
502
|
+
JOIN nodes n ON fc.node_id = n.id
|
|
503
|
+
${where} ${having}
|
|
504
|
+
ORDER BY ${orderBy}`)
|
|
505
|
+
.all(...params);
|
|
506
|
+
}
|
|
507
|
+
catch (e) {
|
|
508
|
+
debug(`complexity query failed (table may not exist): ${e.message}`);
|
|
509
|
+
// Check if graph has nodes even though complexity table is missing/empty
|
|
510
|
+
let hasGraph = false;
|
|
511
|
+
try {
|
|
512
|
+
hasGraph = db.prepare('SELECT COUNT(*) as c FROM nodes').get().c > 0;
|
|
513
|
+
}
|
|
514
|
+
catch (e2) {
|
|
515
|
+
debug(`nodes table check failed: ${e2.message}`);
|
|
516
|
+
}
|
|
517
|
+
return { functions: [], summary: null, thresholds, hasGraph };
|
|
518
|
+
}
|
|
519
|
+
// Post-filter test files if needed (belt-and-suspenders for isTestFile)
|
|
520
|
+
const filtered = noTests ? rows.filter((r) => !isTestFile(r.file)) : rows;
|
|
521
|
+
const functions = filtered.map((r) => {
|
|
522
|
+
const exceeds = [];
|
|
523
|
+
if (isValidThreshold(thresholds.cognitive?.warn) && r.cognitive >= thresholds.cognitive.warn)
|
|
524
|
+
exceeds.push('cognitive');
|
|
525
|
+
if (isValidThreshold(thresholds.cyclomatic?.warn) &&
|
|
526
|
+
r.cyclomatic >= thresholds.cyclomatic.warn)
|
|
527
|
+
exceeds.push('cyclomatic');
|
|
528
|
+
if (isValidThreshold(thresholds.maxNesting?.warn) &&
|
|
529
|
+
r.max_nesting >= thresholds.maxNesting.warn)
|
|
530
|
+
exceeds.push('maxNesting');
|
|
531
|
+
if (isValidThreshold(thresholds.maintainabilityIndex?.warn) &&
|
|
532
|
+
r.maintainability_index > 0 &&
|
|
533
|
+
r.maintainability_index <= thresholds.maintainabilityIndex.warn)
|
|
534
|
+
exceeds.push('maintainabilityIndex');
|
|
535
|
+
return {
|
|
536
|
+
name: r.name,
|
|
537
|
+
kind: r.kind,
|
|
538
|
+
file: r.file,
|
|
539
|
+
line: r.line,
|
|
540
|
+
endLine: r.end_line || null,
|
|
541
|
+
cognitive: r.cognitive,
|
|
542
|
+
cyclomatic: r.cyclomatic,
|
|
543
|
+
maxNesting: r.max_nesting,
|
|
544
|
+
loc: r.loc || 0,
|
|
545
|
+
sloc: r.sloc || 0,
|
|
546
|
+
maintainabilityIndex: r.maintainability_index || 0,
|
|
547
|
+
halstead: {
|
|
548
|
+
volume: r.halstead_volume || 0,
|
|
549
|
+
difficulty: r.halstead_difficulty || 0,
|
|
550
|
+
effort: r.halstead_effort || 0,
|
|
551
|
+
bugs: r.halstead_bugs || 0,
|
|
552
|
+
},
|
|
553
|
+
exceeds: exceeds.length > 0 ? exceeds : undefined,
|
|
554
|
+
};
|
|
555
|
+
});
|
|
556
|
+
// Summary stats
|
|
557
|
+
let summary = null;
|
|
558
|
+
try {
|
|
559
|
+
const allRows = db
|
|
560
|
+
.prepare(`SELECT fc.cognitive, fc.cyclomatic, fc.max_nesting, fc.maintainability_index
|
|
561
|
+
FROM function_complexity fc JOIN nodes n ON fc.node_id = n.id
|
|
562
|
+
WHERE n.kind IN ('function','method')
|
|
563
|
+
${noTests ? `AND n.file NOT LIKE '%.test.%' AND n.file NOT LIKE '%.spec.%' AND n.file NOT LIKE '%__test__%' AND n.file NOT LIKE '%__tests__%' AND n.file NOT LIKE '%.stories.%'` : ''}`)
|
|
564
|
+
.all();
|
|
565
|
+
if (allRows.length > 0) {
|
|
566
|
+
const miValues = allRows.map((r) => r.maintainability_index || 0);
|
|
567
|
+
summary = {
|
|
568
|
+
analyzed: allRows.length,
|
|
569
|
+
avgCognitive: +(allRows.reduce((s, r) => s + r.cognitive, 0) / allRows.length).toFixed(1),
|
|
570
|
+
avgCyclomatic: +(allRows.reduce((s, r) => s + r.cyclomatic, 0) / allRows.length).toFixed(1),
|
|
571
|
+
maxCognitive: Math.max(...allRows.map((r) => r.cognitive)),
|
|
572
|
+
maxCyclomatic: Math.max(...allRows.map((r) => r.cyclomatic)),
|
|
573
|
+
avgMI: +(miValues.reduce((s, v) => s + v, 0) / miValues.length).toFixed(1),
|
|
574
|
+
minMI: +Math.min(...miValues).toFixed(1),
|
|
575
|
+
aboveWarn: allRows.filter((r) => (isValidThreshold(thresholds.cognitive?.warn) &&
|
|
576
|
+
r.cognitive >= thresholds.cognitive.warn) ||
|
|
577
|
+
(isValidThreshold(thresholds.cyclomatic?.warn) &&
|
|
578
|
+
r.cyclomatic >= thresholds.cyclomatic.warn) ||
|
|
579
|
+
(isValidThreshold(thresholds.maxNesting?.warn) &&
|
|
580
|
+
r.max_nesting >= thresholds.maxNesting.warn) ||
|
|
581
|
+
(isValidThreshold(thresholds.maintainabilityIndex?.warn) &&
|
|
582
|
+
r.maintainability_index > 0 &&
|
|
583
|
+
r.maintainability_index <= thresholds.maintainabilityIndex.warn)).length,
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
catch (e) {
|
|
588
|
+
debug(`complexity summary query failed: ${e.message}`);
|
|
589
|
+
}
|
|
590
|
+
// When summary is null (no complexity rows), check if graph has nodes
|
|
591
|
+
let hasGraph = false;
|
|
592
|
+
if (summary === null) {
|
|
593
|
+
try {
|
|
594
|
+
hasGraph = db.prepare('SELECT COUNT(*) as c FROM nodes').get().c > 0;
|
|
595
|
+
}
|
|
596
|
+
catch (e) {
|
|
597
|
+
debug(`nodes table check failed: ${e.message}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const base = { functions, summary, thresholds, hasGraph };
|
|
601
|
+
return paginateResult(base, 'functions', { limit: opts.limit, offset: opts.offset });
|
|
602
|
+
}
|
|
603
|
+
finally {
|
|
604
|
+
db.close();
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Generator: stream complexity rows one-by-one using .iterate() for memory efficiency.
|
|
609
|
+
* @param {string} [customDbPath]
|
|
610
|
+
* @param {object} [opts]
|
|
611
|
+
* @param {boolean} [opts.noTests]
|
|
612
|
+
* @param {string} [opts.file]
|
|
613
|
+
* @param {string} [opts.target]
|
|
614
|
+
* @param {string} [opts.kind]
|
|
615
|
+
* @param {string} [opts.sort]
|
|
616
|
+
* @yields {{ name: string, kind: string, file: string, line: number, cognitive: number, cyclomatic: number, maxNesting: number, loc: number, sloc: number }}
|
|
617
|
+
*/
|
|
618
|
+
export function* iterComplexity(customDbPath, opts = {}) {
|
|
619
|
+
const db = openReadonlyOrFail(customDbPath);
|
|
620
|
+
try {
|
|
621
|
+
const noTests = opts.noTests || false;
|
|
622
|
+
const sort = opts.sort || 'cognitive';
|
|
623
|
+
let where = "WHERE n.kind IN ('function','method')";
|
|
624
|
+
const params = [];
|
|
625
|
+
if (noTests) {
|
|
626
|
+
where += ` AND n.file NOT LIKE '%.test.%'
|
|
627
|
+
AND n.file NOT LIKE '%.spec.%'
|
|
628
|
+
AND n.file NOT LIKE '%__test__%'
|
|
629
|
+
AND n.file NOT LIKE '%__tests__%'
|
|
630
|
+
AND n.file NOT LIKE '%.stories.%'`;
|
|
631
|
+
}
|
|
632
|
+
if (opts.target) {
|
|
633
|
+
where += ' AND n.name LIKE ?';
|
|
634
|
+
params.push(`%${opts.target}%`);
|
|
635
|
+
}
|
|
636
|
+
{
|
|
637
|
+
const fc = buildFileConditionSQL(opts.file, 'n.file');
|
|
638
|
+
where += fc.sql;
|
|
639
|
+
params.push(...fc.params);
|
|
640
|
+
}
|
|
641
|
+
if (opts.kind) {
|
|
642
|
+
where += ' AND n.kind = ?';
|
|
643
|
+
params.push(opts.kind);
|
|
644
|
+
}
|
|
645
|
+
const orderMap = {
|
|
646
|
+
cognitive: 'fc.cognitive DESC',
|
|
647
|
+
cyclomatic: 'fc.cyclomatic DESC',
|
|
648
|
+
nesting: 'fc.max_nesting DESC',
|
|
649
|
+
mi: 'fc.maintainability_index ASC',
|
|
650
|
+
volume: 'fc.halstead_volume DESC',
|
|
651
|
+
effort: 'fc.halstead_effort DESC',
|
|
652
|
+
bugs: 'fc.halstead_bugs DESC',
|
|
653
|
+
loc: 'fc.loc DESC',
|
|
654
|
+
};
|
|
655
|
+
const orderBy = orderMap[sort] || 'fc.cognitive DESC';
|
|
656
|
+
const stmt = db.prepare(`SELECT n.name, n.kind, n.file, n.line, n.end_line,
|
|
657
|
+
fc.cognitive, fc.cyclomatic, fc.max_nesting, fc.loc, fc.sloc
|
|
658
|
+
FROM function_complexity fc
|
|
659
|
+
JOIN nodes n ON fc.node_id = n.id
|
|
660
|
+
${where}
|
|
661
|
+
ORDER BY ${orderBy}`);
|
|
662
|
+
for (const r of stmt.iterate(...params)) {
|
|
663
|
+
if (noTests && isTestFile(r.file))
|
|
664
|
+
continue;
|
|
665
|
+
yield {
|
|
666
|
+
name: r.name,
|
|
667
|
+
kind: r.kind,
|
|
668
|
+
file: r.file,
|
|
669
|
+
line: r.line,
|
|
670
|
+
endLine: r.end_line || null,
|
|
671
|
+
cognitive: r.cognitive,
|
|
672
|
+
cyclomatic: r.cyclomatic,
|
|
673
|
+
maxNesting: r.max_nesting,
|
|
674
|
+
loc: r.loc || 0,
|
|
675
|
+
sloc: r.sloc || 0,
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
finally {
|
|
680
|
+
db.close();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
//# sourceMappingURL=complexity.js.map
|