@optave/codegraph 3.4.0 → 3.4.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 +7 -7
- package/dist/ast-analysis/engine.d.ts.map +1 -1
- package/dist/ast-analysis/engine.js +3 -9
- package/dist/ast-analysis/engine.js.map +1 -1
- package/dist/ast-analysis/shared.d.ts.map +1 -1
- package/dist/ast-analysis/shared.js +0 -1
- package/dist/ast-analysis/shared.js.map +1 -1
- package/dist/ast-analysis/visitors/cfg-conditionals.d.ts +5 -0
- package/dist/ast-analysis/visitors/cfg-conditionals.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/cfg-conditionals.js +166 -0
- package/dist/ast-analysis/visitors/cfg-conditionals.js.map +1 -0
- package/dist/ast-analysis/visitors/cfg-loops.d.ts +7 -0
- package/dist/ast-analysis/visitors/cfg-loops.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/cfg-loops.js +73 -0
- package/dist/ast-analysis/visitors/cfg-loops.js.map +1 -0
- package/dist/ast-analysis/visitors/cfg-shared.d.ts +56 -0
- package/dist/ast-analysis/visitors/cfg-shared.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/cfg-shared.js +107 -0
- package/dist/ast-analysis/visitors/cfg-shared.js.map +1 -0
- package/dist/ast-analysis/visitors/cfg-try-catch.d.ts +4 -0
- package/dist/ast-analysis/visitors/cfg-try-catch.d.ts.map +1 -0
- package/dist/ast-analysis/visitors/cfg-try-catch.js +100 -0
- package/dist/ast-analysis/visitors/cfg-try-catch.js.map +1 -0
- package/dist/ast-analysis/visitors/cfg-visitor.d.ts +2 -2
- package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/cfg-visitor.js +11 -445
- package/dist/ast-analysis/visitors/cfg-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.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -1
- package/dist/cli/commands/batch.d.ts.map +1 -1
- package/dist/cli/commands/batch.js +4 -3
- package/dist/cli/commands/batch.js.map +1 -1
- package/dist/cli/commands/branch-compare.js +1 -1
- package/dist/cli/commands/branch-compare.js.map +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/info.d.ts.map +1 -1
- package/dist/cli/commands/info.js +1 -2
- package/dist/cli/commands/info.js.map +1 -1
- package/dist/cli/commands/path.d.ts.map +1 -1
- package/dist/cli/commands/path.js +7 -2
- package/dist/cli/commands/path.js.map +1 -1
- package/dist/cli/commands/plot.d.ts.map +1 -1
- package/dist/cli/commands/plot.js +2 -2
- package/dist/cli/commands/plot.js.map +1 -1
- package/dist/cli/commands/watch.js +1 -1
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/shared/open-graph.d.ts +2 -2
- package/dist/cli/shared/open-graph.d.ts.map +1 -1
- package/dist/cli/shared/open-graph.js.map +1 -1
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli.js +2 -3
- package/dist/cli.js.map +1 -1
- package/dist/db/connection.d.ts +17 -0
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +91 -2
- package/dist/db/connection.js.map +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +7 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/domain/analysis/brief.d.ts.map +1 -1
- package/dist/domain/analysis/brief.js +1 -3
- 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 +2 -4
- package/dist/domain/analysis/context.js.map +1 -1
- package/dist/domain/analysis/dependencies.d.ts +49 -0
- package/dist/domain/analysis/dependencies.d.ts.map +1 -1
- package/dist/domain/analysis/dependencies.js +145 -0
- package/dist/domain/analysis/dependencies.js.map +1 -1
- package/dist/domain/analysis/diff-impact.d.ts +76 -0
- package/dist/domain/analysis/diff-impact.d.ts.map +1 -0
- package/dist/domain/analysis/diff-impact.js +282 -0
- package/dist/domain/analysis/diff-impact.js.map +1 -0
- package/dist/domain/analysis/exports.d.ts.map +1 -1
- package/dist/domain/analysis/exports.js +0 -1
- package/dist/domain/analysis/exports.js.map +1 -1
- package/dist/domain/analysis/fn-impact.d.ts +66 -0
- package/dist/domain/analysis/fn-impact.d.ts.map +1 -0
- package/dist/domain/analysis/fn-impact.js +189 -0
- package/dist/domain/analysis/fn-impact.js.map +1 -0
- package/dist/domain/analysis/impact.d.ts +8 -148
- package/dist/domain/analysis/impact.d.ts.map +1 -1
- package/dist/domain/analysis/impact.js +8 -568
- package/dist/domain/analysis/impact.js.map +1 -1
- package/dist/domain/analysis/module-map.d.ts.map +1 -1
- package/dist/domain/analysis/module-map.js +1 -3
- package/dist/domain/analysis/module-map.js.map +1 -1
- package/dist/domain/graph/builder/context.d.ts +2 -3
- package/dist/domain/graph/builder/context.d.ts.map +1 -1
- package/dist/domain/graph/builder/context.js.map +1 -1
- package/dist/domain/graph/builder/helpers.d.ts +4 -5
- package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
- package/dist/domain/graph/builder/helpers.js +1 -2
- package/dist/domain/graph/builder/helpers.js.map +1 -1
- package/dist/domain/graph/builder/incremental.d.ts +2 -3
- package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
- package/dist/domain/graph/builder/incremental.js.map +1 -1
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
- package/dist/domain/graph/builder/pipeline.js +6 -0
- 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 +12 -2
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-structure.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-structure.js +155 -59
- package/dist/domain/graph/builder/stages/build-structure.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 +6 -6
- 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 +85 -61
- 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.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 +58 -11
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
- package/dist/domain/graph/cycles.js +2 -2
- package/dist/domain/graph/cycles.js.map +1 -1
- package/dist/domain/graph/resolve.d.ts.map +1 -1
- package/dist/domain/graph/resolve.js +10 -8
- package/dist/domain/graph/resolve.js.map +1 -1
- package/dist/domain/graph/watcher.d.ts.map +1 -1
- package/dist/domain/graph/watcher.js +1 -3
- package/dist/domain/graph/watcher.js.map +1 -1
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +11 -12
- package/dist/domain/parser.js.map +1 -1
- package/dist/domain/queries.d.ts +3 -2
- package/dist/domain/queries.d.ts.map +1 -1
- package/dist/domain/queries.js +3 -2
- package/dist/domain/queries.js.map +1 -1
- package/dist/domain/search/generator.d.ts.map +1 -1
- package/dist/domain/search/generator.js.map +1 -1
- package/dist/extractors/csharp.js +2 -2
- package/dist/extractors/csharp.js.map +1 -1
- package/dist/extractors/go.js +2 -2
- package/dist/extractors/go.js.map +1 -1
- package/dist/extractors/helpers.d.ts +5 -0
- package/dist/extractors/helpers.d.ts.map +1 -1
- package/dist/extractors/helpers.js +5 -0
- package/dist/extractors/helpers.js.map +1 -1
- package/dist/extractors/javascript.js +58 -60
- package/dist/extractors/javascript.js.map +1 -1
- package/dist/extractors/php.js +2 -2
- package/dist/extractors/php.js.map +1 -1
- package/dist/extractors/python.js +2 -2
- package/dist/extractors/python.js.map +1 -1
- package/dist/extractors/rust.js +2 -2
- package/dist/extractors/rust.js.map +1 -1
- package/dist/features/audit.d.ts.map +1 -1
- package/dist/features/audit.js +1 -2
- package/dist/features/audit.js.map +1 -1
- package/dist/features/branch-compare.d.ts.map +1 -1
- package/dist/features/branch-compare.js +2 -3
- package/dist/features/branch-compare.js.map +1 -1
- package/dist/features/cfg.d.ts.map +1 -1
- package/dist/features/cfg.js +2 -4
- package/dist/features/cfg.js.map +1 -1
- package/dist/features/cochange.js +4 -4
- package/dist/features/cochange.js.map +1 -1
- package/dist/features/communities.js +4 -4
- package/dist/features/communities.js.map +1 -1
- package/dist/features/complexity-query.d.ts +37 -0
- package/dist/features/complexity-query.d.ts.map +1 -0
- package/dist/features/complexity-query.js +263 -0
- package/dist/features/complexity-query.js.map +1 -0
- package/dist/features/complexity.d.ts +2 -30
- package/dist/features/complexity.d.ts.map +1 -1
- package/dist/features/complexity.js +7 -261
- package/dist/features/complexity.js.map +1 -1
- package/dist/features/dataflow.d.ts.map +1 -1
- package/dist/features/dataflow.js +8 -24
- package/dist/features/dataflow.js.map +1 -1
- package/dist/features/export.d.ts +7 -8
- package/dist/features/export.d.ts.map +1 -1
- package/dist/features/export.js.map +1 -1
- package/dist/features/flow.d.ts.map +1 -1
- package/dist/features/flow.js.map +1 -1
- package/dist/features/graph-enrichment.d.ts.map +1 -1
- package/dist/features/graph-enrichment.js +1 -3
- package/dist/features/graph-enrichment.js.map +1 -1
- package/dist/features/manifesto.js +8 -8
- package/dist/features/manifesto.js.map +1 -1
- package/dist/features/snapshot.d.ts.map +1 -1
- package/dist/features/snapshot.js +0 -1
- package/dist/features/snapshot.js.map +1 -1
- package/dist/features/structure-query.d.ts +76 -0
- package/dist/features/structure-query.d.ts.map +1 -0
- package/dist/features/structure-query.js +245 -0
- package/dist/features/structure-query.js.map +1 -0
- package/dist/features/structure.d.ts +12 -67
- package/dist/features/structure.d.ts.map +1 -1
- package/dist/features/structure.js +188 -244
- package/dist/features/structure.js.map +1 -1
- package/dist/features/triage.js +2 -2
- package/dist/features/triage.js.map +1 -1
- package/dist/graph/algorithms/leiden/adapter.d.ts.map +1 -1
- package/dist/graph/algorithms/leiden/adapter.js +2 -9
- package/dist/graph/algorithms/leiden/adapter.js.map +1 -1
- package/dist/graph/classifiers/roles.d.ts +5 -1
- package/dist/graph/classifiers/roles.d.ts.map +1 -1
- package/dist/graph/classifiers/roles.js +20 -12
- package/dist/graph/classifiers/roles.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +12 -11
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/infrastructure/native.d.ts.map +1 -1
- package/dist/infrastructure/native.js +7 -3
- package/dist/infrastructure/native.js.map +1 -1
- package/dist/infrastructure/registry.d.ts.map +1 -1
- package/dist/infrastructure/registry.js +1 -1
- package/dist/infrastructure/registry.js.map +1 -1
- package/dist/infrastructure/update-check.js +3 -3
- package/dist/infrastructure/update-check.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +2 -8
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tool-registry.d.ts.map +1 -1
- package/dist/mcp/tool-registry.js +9 -4
- package/dist/mcp/tool-registry.js.map +1 -1
- package/dist/mcp/tools/audit.js +1 -1
- package/dist/mcp/tools/audit.js.map +1 -1
- package/dist/mcp/tools/cfg.js +1 -1
- package/dist/mcp/tools/cfg.js.map +1 -1
- package/dist/mcp/tools/check.js +2 -2
- package/dist/mcp/tools/check.js.map +1 -1
- package/dist/mcp/tools/dataflow.js +2 -2
- package/dist/mcp/tools/dataflow.js.map +1 -1
- package/dist/mcp/tools/export-graph.js +1 -1
- package/dist/mcp/tools/export-graph.js.map +1 -1
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/path.d.ts +1 -0
- package/dist/mcp/tools/path.d.ts.map +1 -1
- package/dist/mcp/tools/path.js +9 -0
- package/dist/mcp/tools/path.js.map +1 -1
- package/dist/mcp/tools/query.js +1 -1
- package/dist/mcp/tools/query.js.map +1 -1
- package/dist/mcp/tools/semantic-search.js +1 -1
- package/dist/mcp/tools/semantic-search.js.map +1 -1
- package/dist/mcp/tools/sequence.js +1 -1
- package/dist/mcp/tools/sequence.js.map +1 -1
- package/dist/mcp/tools/symbol-children.js +1 -1
- package/dist/mcp/tools/symbol-children.js.map +1 -1
- package/dist/mcp/tools/triage.js +1 -1
- package/dist/mcp/tools/triage.js.map +1 -1
- package/dist/presentation/audit.d.ts.map +1 -1
- package/dist/presentation/audit.js +0 -1
- package/dist/presentation/audit.js.map +1 -1
- package/dist/presentation/diff-impact-mermaid.d.ts +11 -0
- package/dist/presentation/diff-impact-mermaid.d.ts.map +1 -0
- package/dist/presentation/diff-impact-mermaid.js +105 -0
- package/dist/presentation/diff-impact-mermaid.js.map +1 -0
- package/dist/presentation/flow.d.ts.map +1 -1
- package/dist/presentation/flow.js +0 -2
- package/dist/presentation/flow.js.map +1 -1
- package/dist/presentation/manifesto.d.ts.map +1 -1
- package/dist/presentation/manifesto.js +0 -1
- package/dist/presentation/manifesto.js.map +1 -1
- package/dist/presentation/queries-cli/inspect.d.ts.map +1 -1
- package/dist/presentation/queries-cli/inspect.js.map +1 -1
- package/dist/presentation/queries-cli/path.d.ts.map +1 -1
- package/dist/presentation/queries-cli/path.js +45 -1
- package/dist/presentation/queries-cli/path.js.map +1 -1
- package/dist/presentation/result-formatter.d.ts.map +1 -1
- package/dist/presentation/result-formatter.js +1 -3
- package/dist/presentation/result-formatter.js.map +1 -1
- package/dist/presentation/sequence.d.ts.map +1 -1
- package/dist/presentation/sequence.js +0 -1
- package/dist/presentation/sequence.js.map +1 -1
- package/dist/presentation/structure.d.ts.map +1 -1
- package/dist/presentation/structure.js.map +1 -1
- package/dist/presentation/triage.d.ts.map +1 -1
- package/dist/presentation/triage.js +0 -1
- package/dist/presentation/triage.js.map +1 -1
- package/dist/shared/constants.d.ts +9 -3
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +6 -3
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/errors.d.ts +2 -0
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +4 -0
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/version.d.ts +2 -0
- package/dist/shared/version.d.ts.map +1 -0
- package/dist/shared/version.js +5 -0
- package/dist/shared/version.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/ast-analysis/engine.ts +3 -9
- package/src/ast-analysis/shared.ts +0 -1
- package/src/ast-analysis/visitors/cfg-conditionals.ts +227 -0
- package/src/ast-analysis/visitors/cfg-loops.ts +136 -0
- package/src/ast-analysis/visitors/cfg-shared.ts +196 -0
- package/src/ast-analysis/visitors/cfg-try-catch.ts +142 -0
- package/src/ast-analysis/visitors/cfg-visitor.ts +34 -655
- package/src/ast-analysis/visitors/complexity-visitor.ts +0 -1
- package/src/ast-analysis/visitors/dataflow-visitor.ts +0 -1
- package/src/cli/commands/batch.ts +4 -3
- package/src/cli/commands/branch-compare.ts +1 -1
- package/src/cli/commands/build.ts +1 -1
- package/src/cli/commands/info.ts +1 -2
- package/src/cli/commands/path.ts +7 -2
- package/src/cli/commands/plot.ts +2 -2
- package/src/cli/commands/watch.ts +1 -1
- package/src/cli/index.ts +2 -2
- package/src/cli/shared/open-graph.ts +2 -2
- package/src/cli/types.ts +1 -1
- package/src/cli.ts +2 -3
- package/src/db/connection.ts +97 -13
- package/src/db/index.ts +2 -0
- package/src/db/migrations.ts +7 -0
- package/src/domain/analysis/brief.ts +0 -1
- package/src/domain/analysis/context.ts +2 -6
- package/src/domain/analysis/dependencies.ts +165 -0
- package/src/domain/analysis/diff-impact.ts +354 -0
- package/src/domain/analysis/exports.ts +0 -2
- package/src/domain/analysis/fn-impact.ts +241 -0
- package/src/domain/analysis/impact.ts +8 -718
- package/src/domain/analysis/module-map.ts +1 -5
- package/src/domain/graph/builder/context.ts +2 -2
- package/src/domain/graph/builder/helpers.ts +14 -11
- package/src/domain/graph/builder/incremental.ts +33 -28
- package/src/domain/graph/builder/pipeline.ts +8 -0
- package/src/domain/graph/builder/stages/build-edges.ts +17 -4
- package/src/domain/graph/builder/stages/build-structure.ts +205 -76
- package/src/domain/graph/builder/stages/detect-changes.ts +11 -12
- package/src/domain/graph/builder/stages/finalize.ts +100 -81
- package/src/domain/graph/builder/stages/insert-nodes.ts +12 -8
- package/src/domain/graph/builder/stages/resolve-imports.ts +75 -10
- package/src/domain/graph/cycles.ts +2 -2
- package/src/domain/graph/resolve.ts +14 -8
- package/src/domain/graph/watcher.ts +2 -4
- package/src/domain/parser.ts +11 -13
- package/src/domain/queries.ts +2 -2
- package/src/domain/search/generator.ts +3 -4
- package/src/extractors/csharp.ts +2 -2
- package/src/extractors/go.ts +2 -2
- package/src/extractors/helpers.ts +6 -0
- package/src/extractors/javascript.ts +58 -61
- package/src/extractors/php.ts +2 -2
- package/src/extractors/python.ts +2 -2
- package/src/extractors/rust.ts +2 -2
- package/src/features/audit.ts +1 -2
- package/src/features/branch-compare.ts +3 -9
- package/src/features/cfg.ts +2 -4
- package/src/features/cochange.ts +4 -4
- package/src/features/communities.ts +4 -4
- package/src/features/complexity-query.ts +370 -0
- package/src/features/complexity.ts +6 -365
- package/src/features/dataflow.ts +48 -70
- package/src/features/export.ts +12 -16
- package/src/features/flow.ts +0 -1
- package/src/features/graph-enrichment.ts +1 -3
- package/src/features/manifesto.ts +8 -8
- package/src/features/snapshot.ts +1 -2
- package/src/features/structure-query.ts +387 -0
- package/src/features/structure.ts +231 -376
- package/src/features/triage.ts +2 -2
- package/src/graph/algorithms/leiden/adapter.ts +2 -9
- package/src/graph/classifiers/roles.ts +22 -13
- package/src/index.ts +1 -0
- package/src/infrastructure/config.ts +12 -13
- package/src/infrastructure/native.ts +7 -3
- package/src/infrastructure/registry.ts +1 -1
- package/src/infrastructure/update-check.ts +3 -3
- package/src/mcp/server.ts +2 -10
- package/src/mcp/tool-registry.ts +11 -4
- package/src/mcp/tools/audit.ts +1 -1
- package/src/mcp/tools/cfg.ts +1 -1
- package/src/mcp/tools/check.ts +2 -2
- package/src/mcp/tools/dataflow.ts +2 -2
- package/src/mcp/tools/export-graph.ts +1 -1
- package/src/mcp/tools/index.ts +0 -1
- package/src/mcp/tools/path.ts +10 -0
- package/src/mcp/tools/query.ts +1 -1
- package/src/mcp/tools/semantic-search.ts +1 -1
- package/src/mcp/tools/sequence.ts +1 -1
- package/src/mcp/tools/symbol-children.ts +1 -1
- package/src/mcp/tools/triage.ts +1 -1
- package/src/presentation/audit.ts +0 -1
- package/src/presentation/diff-impact-mermaid.ts +127 -0
- package/src/presentation/flow.ts +0 -2
- package/src/presentation/manifesto.ts +0 -1
- package/src/presentation/queries-cli/inspect.ts +0 -1
- package/src/presentation/queries-cli/path.ts +71 -1
- package/src/presentation/result-formatter.ts +0 -1
- package/src/presentation/sequence.ts +0 -1
- package/src/presentation/structure.ts +0 -12
- package/src/presentation/triage.ts +0 -1
- package/src/shared/constants.ts +33 -19
- package/src/shared/errors.ts +5 -0
- package/src/shared/version.ts +10 -0
- package/src/types.ts +4 -10
- package/src/vendor.d.ts +0 -39
package/src/domain/parser.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Tree } from 'web-tree-sitter';
|
|
|
5
5
|
import { Language, Parser, Query } from 'web-tree-sitter';
|
|
6
6
|
import { debug, warn } from '../infrastructure/logger.js';
|
|
7
7
|
import { getNative, getNativePackageVersion, loadNative } from '../infrastructure/native.js';
|
|
8
|
+
import { toErrorMessage } from '../shared/errors.js';
|
|
8
9
|
import type {
|
|
9
10
|
EngineMode,
|
|
10
11
|
ExtractorOutput,
|
|
@@ -69,7 +70,6 @@ interface ParseEngineOpts {
|
|
|
69
70
|
|
|
70
71
|
interface ResolvedEngine {
|
|
71
72
|
name: 'native' | 'wasm';
|
|
72
|
-
// biome-ignore lint/suspicious/noExplicitAny: native addon has no type declarations
|
|
73
73
|
native: any;
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -171,7 +171,6 @@ export function disposeParsers(): void {
|
|
|
171
171
|
_queryCache.clear();
|
|
172
172
|
if (_cachedLanguages) {
|
|
173
173
|
for (const [id, lang] of _cachedLanguages) {
|
|
174
|
-
// biome-ignore lint/suspicious/noExplicitAny: .delete() exists at runtime on WASM Language objects but is missing from typings
|
|
175
174
|
if (lang && typeof (lang as any).delete === 'function') {
|
|
176
175
|
try {
|
|
177
176
|
(lang as any).delete();
|
|
@@ -197,7 +196,6 @@ export function getParser(parsers: Map<string, Parser | null>, filePath: string)
|
|
|
197
196
|
* don't each need to create parsers and re-parse independently.
|
|
198
197
|
* Only parses files whose extension is in SUPPORTED_EXTENSIONS.
|
|
199
198
|
*/
|
|
200
|
-
// biome-ignore lint/suspicious/noExplicitAny: fileSymbols values have dynamic shape from extractors
|
|
201
199
|
export async function ensureWasmTrees(
|
|
202
200
|
fileSymbols: Map<string, any>,
|
|
203
201
|
rootDir: string,
|
|
@@ -274,7 +272,6 @@ function resolveEngine(opts: ParseEngineOpts = {}): ResolvedEngine {
|
|
|
274
272
|
* - Backward compat for older native binaries missing js_name annotations
|
|
275
273
|
* - dataflow argFlows/mutations bindingType -> binding wrapper
|
|
276
274
|
*/
|
|
277
|
-
// biome-ignore lint/suspicious/noExplicitAny: native addon result has no type declarations
|
|
278
275
|
function patchNativeResult(r: any): ExtractorOutput {
|
|
279
276
|
// lineCount: napi(js_name) emits "lineCount"; older binaries may emit "line_count"
|
|
280
277
|
r.lineCount = r.lineCount ?? r.line_count ?? null;
|
|
@@ -433,7 +430,6 @@ export const SUPPORTED_EXTENSIONS: Set<string> = new Set(_extToLang.keys());
|
|
|
433
430
|
* matches inside comments and string literals.
|
|
434
431
|
* TODO: Remove once all published native binaries include typeMap extraction (>= 3.2.0)
|
|
435
432
|
*/
|
|
436
|
-
// biome-ignore lint/suspicious/noExplicitAny: return shape matches native result typeMap
|
|
437
433
|
async function backfillTypeMap(
|
|
438
434
|
filePath: string,
|
|
439
435
|
source?: string,
|
|
@@ -442,7 +438,8 @@ async function backfillTypeMap(
|
|
|
442
438
|
if (!code) {
|
|
443
439
|
try {
|
|
444
440
|
code = fs.readFileSync(filePath, 'utf-8');
|
|
445
|
-
} catch {
|
|
441
|
+
} catch (e) {
|
|
442
|
+
debug(`backfillTypeMap: failed to read ${filePath}: ${toErrorMessage(e)}`);
|
|
446
443
|
return { typeMap: new Map(), backfilled: false };
|
|
447
444
|
}
|
|
448
445
|
}
|
|
@@ -458,7 +455,9 @@ async function backfillTypeMap(
|
|
|
458
455
|
if (extracted?.tree && typeof extracted.tree.delete === 'function') {
|
|
459
456
|
try {
|
|
460
457
|
extracted.tree.delete();
|
|
461
|
-
} catch {
|
|
458
|
+
} catch (e) {
|
|
459
|
+
debug(`backfillTypeMap: WASM tree cleanup failed: ${toErrorMessage(e)}`);
|
|
460
|
+
}
|
|
462
461
|
}
|
|
463
462
|
}
|
|
464
463
|
}
|
|
@@ -488,7 +487,6 @@ function wasmExtractSymbols(
|
|
|
488
487
|
if (!entry) return null;
|
|
489
488
|
const query = _queryCache.get(entry.id) ?? undefined;
|
|
490
489
|
// Query (web-tree-sitter) is structurally compatible with TreeSitterQuery at runtime
|
|
491
|
-
// biome-ignore lint/suspicious/noExplicitAny: thin WASM wrapper type mismatch
|
|
492
490
|
const symbols = entry.extractor(tree as any, filePath, query as any);
|
|
493
491
|
return symbols ? { symbols, tree, langId: entry.id } : null;
|
|
494
492
|
}
|
|
@@ -571,14 +569,16 @@ export async function parseFilesAuto(
|
|
|
571
569
|
symbols.typeMap = extracted.symbols.typeMap;
|
|
572
570
|
symbols._typeMapBackfilled = true;
|
|
573
571
|
}
|
|
574
|
-
} catch {
|
|
575
|
-
|
|
572
|
+
} catch (e) {
|
|
573
|
+
debug(`batchExtract: typeMap backfill failed: ${toErrorMessage(e)}`);
|
|
576
574
|
} finally {
|
|
577
575
|
// Free the WASM tree to prevent memory accumulation across repeated builds
|
|
578
576
|
if (extracted?.tree && typeof extracted.tree.delete === 'function') {
|
|
579
577
|
try {
|
|
580
578
|
extracted.tree.delete();
|
|
581
|
-
} catch {
|
|
579
|
+
} catch (e) {
|
|
580
|
+
debug(`batchExtract: WASM tree cleanup failed: ${toErrorMessage(e)}`);
|
|
581
|
+
}
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
584
|
}
|
|
@@ -638,7 +638,6 @@ export function getActiveEngine(opts: ParseEngineOpts = {}): {
|
|
|
638
638
|
* Create a native ParseTreeCache for incremental parsing.
|
|
639
639
|
* Returns null if the native engine is unavailable (WASM fallback).
|
|
640
640
|
*/
|
|
641
|
-
// biome-ignore lint/suspicious/noExplicitAny: native ParseTreeCache has no type declarations
|
|
642
641
|
export function createParseTreeCache(): any {
|
|
643
642
|
const native = loadNative();
|
|
644
643
|
if (!native || !native.ParseTreeCache) return null;
|
|
@@ -648,7 +647,6 @@ export function createParseTreeCache(): any {
|
|
|
648
647
|
/**
|
|
649
648
|
* Parse a file incrementally using the cache, or fall back to full parse.
|
|
650
649
|
*/
|
|
651
|
-
// biome-ignore lint/suspicious/noExplicitAny: cache is native ParseTreeCache with no type declarations
|
|
652
650
|
export async function parseFileIncremental(
|
|
653
651
|
cache: any,
|
|
654
652
|
filePath: string,
|
package/src/domain/queries.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
// ── Re-export from dedicated module for backward compat ───────────────────
|
|
10
10
|
export { isTestFile, TEST_PATTERN } from '../infrastructure/test-filter.js';
|
|
11
|
+
export { diffImpactMermaid } from '../presentation/diff-impact-mermaid.js';
|
|
11
12
|
export { iterListFunctions, iterRoles, iterWhere } from '../shared/generators.js';
|
|
12
13
|
// ── Kind/edge constants (canonical source: kinds.js) ─────────────────────
|
|
13
14
|
export {
|
|
@@ -24,11 +25,10 @@ export {
|
|
|
24
25
|
export { kindIcon, normalizeSymbol } from '../shared/normalize.js';
|
|
25
26
|
export { briefData } from './analysis/brief.js';
|
|
26
27
|
export { contextData, explainData } from './analysis/context.js';
|
|
27
|
-
export { fileDepsData, fnDepsData, pathData } from './analysis/dependencies.js';
|
|
28
|
+
export { fileDepsData, filePathData, fnDepsData, pathData } from './analysis/dependencies.js';
|
|
28
29
|
export { exportsData } from './analysis/exports.js';
|
|
29
30
|
export {
|
|
30
31
|
diffImpactData,
|
|
31
|
-
diffImpactMermaid,
|
|
32
32
|
fnImpactData,
|
|
33
33
|
impactAnalysisData,
|
|
34
34
|
} from './analysis/impact.js';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import type BetterSqlite3 from 'better-sqlite3';
|
|
4
3
|
import { closeDb, findDbPath, openDb } from '../../db/index.js';
|
|
5
4
|
import { warn } from '../../infrastructure/logger.js';
|
|
6
5
|
import { DbError } from '../../shared/errors.js';
|
|
7
|
-
import type { NodeRow } from '../../types.js';
|
|
6
|
+
import type { BetterSqlite3Database, NodeRow } from '../../types.js';
|
|
8
7
|
import { embed, getModelConfig } from './models.js';
|
|
9
8
|
import { buildSourceText } from './strategies/source.js';
|
|
10
9
|
import { buildStructuredText } from './strategies/structured.js';
|
|
@@ -17,7 +16,7 @@ export function estimateTokens(text: string): number {
|
|
|
17
16
|
return Math.ceil(text.length / 4);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
function initEmbeddingsSchema(db:
|
|
19
|
+
function initEmbeddingsSchema(db: BetterSqlite3Database): void {
|
|
21
20
|
db.exec(`
|
|
22
21
|
CREATE TABLE IF NOT EXISTS embeddings (
|
|
23
22
|
node_id INTEGER PRIMARY KEY,
|
|
@@ -71,7 +70,7 @@ export async function buildEmbeddings(
|
|
|
71
70
|
);
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
const db = openDb(dbPath) as
|
|
73
|
+
const db = openDb(dbPath) as BetterSqlite3Database;
|
|
75
74
|
initEmbeddingsSchema(db);
|
|
76
75
|
|
|
77
76
|
db.exec('DELETE FROM embeddings');
|
package/src/extractors/csharp.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
TreeSitterNode,
|
|
7
7
|
TreeSitterTree,
|
|
8
8
|
} from '../types.js';
|
|
9
|
-
import { extractModifierVisibility, findChild, nodeEndLine } from './helpers.js';
|
|
9
|
+
import { extractModifierVisibility, findChild, MAX_WALK_DEPTH, nodeEndLine } from './helpers.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Extract symbols from C# files.
|
|
@@ -333,7 +333,7 @@ function extractCSharpTypeMapDepth(
|
|
|
333
333
|
ctx: ExtractorOutput,
|
|
334
334
|
depth: number,
|
|
335
335
|
): void {
|
|
336
|
-
if (depth >=
|
|
336
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
337
337
|
|
|
338
338
|
// local_declaration_statement → variable_declaration → type + variable_declarator(s)
|
|
339
339
|
if (node.type === 'variable_declaration') {
|
package/src/extractors/go.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
TreeSitterTree,
|
|
7
7
|
TypeMapEntry,
|
|
8
8
|
} from '../types.js';
|
|
9
|
-
import { findChild, goVisibility, nodeEndLine } from './helpers.js';
|
|
9
|
+
import { findChild, goVisibility, MAX_WALK_DEPTH, nodeEndLine } from './helpers.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Extract symbols from Go files.
|
|
@@ -233,7 +233,7 @@ function setIfHigher(
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
function extractGoTypeMapDepth(node: TreeSitterNode, ctx: ExtractorOutput, depth: number): void {
|
|
236
|
-
if (depth >=
|
|
236
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
237
237
|
|
|
238
238
|
// var x MyType = ... or var x, y MyType → var_declaration > var_spec (confidence 0.9)
|
|
239
239
|
if (node.type === 'var_spec') {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { TreeSitterNode } from '../types.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Maximum recursion depth for tree-sitter AST walkers.
|
|
5
|
+
* Shared across all language extractors to prevent stack overflow on deeply nested ASTs.
|
|
6
|
+
*/
|
|
7
|
+
export const MAX_WALK_DEPTH = 200;
|
|
8
|
+
|
|
3
9
|
export function nodeEndLine(node: TreeSitterNode): number {
|
|
4
10
|
return node.endPosition.row + 1;
|
|
5
11
|
}
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
TreeSitterTree,
|
|
13
13
|
TypeMapEntry,
|
|
14
14
|
} from '../types.js';
|
|
15
|
-
import { findChild, nodeEndLine } from './helpers.js';
|
|
15
|
+
import { findChild, MAX_WALK_DEPTH, nodeEndLine } from './helpers.js';
|
|
16
16
|
|
|
17
17
|
/** Built-in globals that start with uppercase but are not user-defined types. */
|
|
18
18
|
const BUILTIN_GLOBALS: Set<string> = new Set([
|
|
@@ -102,44 +102,42 @@ function extractSymbolsQuery(tree: TreeSitterTree, query: TreeSitterQuery): Extr
|
|
|
102
102
|
const c: Record<string, TreeSitterNode> = Object.create(null);
|
|
103
103
|
for (const cap of match.captures) c[cap.name] = cap.node;
|
|
104
104
|
|
|
105
|
-
if (c
|
|
105
|
+
if (c.fn_node) {
|
|
106
106
|
// function_declaration
|
|
107
|
-
const fnChildren = extractParameters(c
|
|
107
|
+
const fnChildren = extractParameters(c.fn_node);
|
|
108
108
|
definitions.push({
|
|
109
|
-
name: c
|
|
109
|
+
name: c.fn_name!.text,
|
|
110
110
|
kind: 'function',
|
|
111
|
-
line: c
|
|
112
|
-
endLine: nodeEndLine(c
|
|
111
|
+
line: c.fn_node.startPosition.row + 1,
|
|
112
|
+
endLine: nodeEndLine(c.fn_node),
|
|
113
113
|
children: fnChildren.length > 0 ? fnChildren : undefined,
|
|
114
114
|
});
|
|
115
|
-
} else if (c
|
|
115
|
+
} else if (c.varfn_name) {
|
|
116
116
|
// variable_declarator with arrow_function / function_expression
|
|
117
|
-
const declNode = c
|
|
118
|
-
const line = declNode
|
|
119
|
-
|
|
120
|
-
: c['varfn_name'].startPosition.row + 1;
|
|
121
|
-
const varFnChildren = extractParameters(c['varfn_value']!);
|
|
117
|
+
const declNode = c.varfn_name.parent?.parent;
|
|
118
|
+
const line = declNode ? declNode.startPosition.row + 1 : c.varfn_name.startPosition.row + 1;
|
|
119
|
+
const varFnChildren = extractParameters(c.varfn_value!);
|
|
122
120
|
definitions.push({
|
|
123
|
-
name: c
|
|
121
|
+
name: c.varfn_name.text,
|
|
124
122
|
kind: 'function',
|
|
125
123
|
line,
|
|
126
|
-
endLine: nodeEndLine(c
|
|
124
|
+
endLine: nodeEndLine(c.varfn_value!),
|
|
127
125
|
children: varFnChildren.length > 0 ? varFnChildren : undefined,
|
|
128
126
|
});
|
|
129
|
-
} else if (c
|
|
127
|
+
} else if (c.cls_node) {
|
|
130
128
|
// class_declaration
|
|
131
|
-
const className = c
|
|
132
|
-
const startLine = c
|
|
133
|
-
const clsChildren = extractClassProperties(c
|
|
129
|
+
const className = c.cls_name!.text;
|
|
130
|
+
const startLine = c.cls_node.startPosition.row + 1;
|
|
131
|
+
const clsChildren = extractClassProperties(c.cls_node);
|
|
134
132
|
definitions.push({
|
|
135
133
|
name: className,
|
|
136
134
|
kind: 'class',
|
|
137
135
|
line: startLine,
|
|
138
|
-
endLine: nodeEndLine(c
|
|
136
|
+
endLine: nodeEndLine(c.cls_node),
|
|
139
137
|
children: clsChildren.length > 0 ? clsChildren : undefined,
|
|
140
138
|
});
|
|
141
139
|
const heritage =
|
|
142
|
-
c
|
|
140
|
+
c.cls_node.childForFieldName('heritage') || findChild(c.cls_node, 'class_heritage');
|
|
143
141
|
if (heritage) {
|
|
144
142
|
const superName = extractSuperclass(heritage);
|
|
145
143
|
if (superName) classes.push({ name: className, extends: superName, line: startLine });
|
|
@@ -148,58 +146,58 @@ function extractSymbolsQuery(tree: TreeSitterTree, query: TreeSitterQuery): Extr
|
|
|
148
146
|
classes.push({ name: className, implements: iface, line: startLine });
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
|
-
} else if (c
|
|
149
|
+
} else if (c.meth_node) {
|
|
152
150
|
// method_definition
|
|
153
|
-
const methName = c
|
|
154
|
-
const parentClass = findParentClass(c
|
|
151
|
+
const methName = c.meth_name!.text;
|
|
152
|
+
const parentClass = findParentClass(c.meth_node);
|
|
155
153
|
const fullName = parentClass ? `${parentClass}.${methName}` : methName;
|
|
156
|
-
const methChildren = extractParameters(c
|
|
157
|
-
const methVis = extractVisibility(c
|
|
154
|
+
const methChildren = extractParameters(c.meth_node);
|
|
155
|
+
const methVis = extractVisibility(c.meth_node);
|
|
158
156
|
definitions.push({
|
|
159
157
|
name: fullName,
|
|
160
158
|
kind: 'method',
|
|
161
|
-
line: c
|
|
162
|
-
endLine: nodeEndLine(c
|
|
159
|
+
line: c.meth_node.startPosition.row + 1,
|
|
160
|
+
endLine: nodeEndLine(c.meth_node),
|
|
163
161
|
children: methChildren.length > 0 ? methChildren : undefined,
|
|
164
162
|
visibility: methVis,
|
|
165
163
|
});
|
|
166
|
-
} else if (c
|
|
164
|
+
} else if (c.iface_node) {
|
|
167
165
|
// interface_declaration (TS/TSX only)
|
|
168
|
-
const ifaceName = c
|
|
166
|
+
const ifaceName = c.iface_name!.text;
|
|
169
167
|
definitions.push({
|
|
170
168
|
name: ifaceName,
|
|
171
169
|
kind: 'interface',
|
|
172
|
-
line: c
|
|
173
|
-
endLine: nodeEndLine(c
|
|
170
|
+
line: c.iface_node.startPosition.row + 1,
|
|
171
|
+
endLine: nodeEndLine(c.iface_node),
|
|
174
172
|
});
|
|
175
173
|
const body =
|
|
176
|
-
c
|
|
177
|
-
findChild(c
|
|
178
|
-
findChild(c
|
|
174
|
+
c.iface_node.childForFieldName('body') ||
|
|
175
|
+
findChild(c.iface_node, 'interface_body') ||
|
|
176
|
+
findChild(c.iface_node, 'object_type');
|
|
179
177
|
if (body) extractInterfaceMethods(body, ifaceName, definitions);
|
|
180
|
-
} else if (c
|
|
178
|
+
} else if (c.type_node) {
|
|
181
179
|
// type_alias_declaration (TS/TSX only)
|
|
182
180
|
definitions.push({
|
|
183
|
-
name: c
|
|
181
|
+
name: c.type_name!.text,
|
|
184
182
|
kind: 'type',
|
|
185
|
-
line: c
|
|
186
|
-
endLine: nodeEndLine(c
|
|
183
|
+
line: c.type_node.startPosition.row + 1,
|
|
184
|
+
endLine: nodeEndLine(c.type_node),
|
|
187
185
|
});
|
|
188
|
-
} else if (c
|
|
186
|
+
} else if (c.imp_node) {
|
|
189
187
|
// import_statement
|
|
190
|
-
const isTypeOnly = c
|
|
191
|
-
const modPath = c
|
|
192
|
-
const names = extractImportNames(c
|
|
188
|
+
const isTypeOnly = c.imp_node.text.startsWith('import type');
|
|
189
|
+
const modPath = c.imp_source!.text.replace(/['"]/g, '');
|
|
190
|
+
const names = extractImportNames(c.imp_node);
|
|
193
191
|
imports.push({
|
|
194
192
|
source: modPath,
|
|
195
193
|
names,
|
|
196
|
-
line: c
|
|
194
|
+
line: c.imp_node.startPosition.row + 1,
|
|
197
195
|
typeOnly: isTypeOnly,
|
|
198
196
|
});
|
|
199
|
-
} else if (c
|
|
197
|
+
} else if (c.exp_node) {
|
|
200
198
|
// export_statement
|
|
201
|
-
const exportLine = c
|
|
202
|
-
const decl = c
|
|
199
|
+
const exportLine = c.exp_node.startPosition.row + 1;
|
|
200
|
+
const decl = c.exp_node.childForFieldName('declaration');
|
|
203
201
|
if (decl) {
|
|
204
202
|
const declType = decl.type;
|
|
205
203
|
const kindMap: Record<string, string> = {
|
|
@@ -214,12 +212,11 @@ function extractSymbolsQuery(tree: TreeSitterTree, query: TreeSitterQuery): Extr
|
|
|
214
212
|
if (n) exps.push({ name: n.text, kind: kind as Export['kind'], line: exportLine });
|
|
215
213
|
}
|
|
216
214
|
}
|
|
217
|
-
const source =
|
|
218
|
-
c['exp_node'].childForFieldName('source') || findChild(c['exp_node'], 'string');
|
|
215
|
+
const source = c.exp_node.childForFieldName('source') || findChild(c.exp_node, 'string');
|
|
219
216
|
if (source && !decl) {
|
|
220
217
|
const modPath = source.text.replace(/['"]/g, '');
|
|
221
|
-
const reexportNames = extractImportNames(c
|
|
222
|
-
const nodeText = c
|
|
218
|
+
const reexportNames = extractImportNames(c.exp_node);
|
|
219
|
+
const nodeText = c.exp_node.text;
|
|
223
220
|
const isWildcard = nodeText.includes('export *') || nodeText.includes('export*');
|
|
224
221
|
imports.push({
|
|
225
222
|
source: modPath,
|
|
@@ -229,25 +226,25 @@ function extractSymbolsQuery(tree: TreeSitterTree, query: TreeSitterQuery): Extr
|
|
|
229
226
|
wildcardReexport: isWildcard && reexportNames.length === 0,
|
|
230
227
|
});
|
|
231
228
|
}
|
|
232
|
-
} else if (c
|
|
229
|
+
} else if (c.callfn_node) {
|
|
233
230
|
// call_expression with identifier function
|
|
234
231
|
calls.push({
|
|
235
|
-
name: c
|
|
236
|
-
line: c
|
|
232
|
+
name: c.callfn_name!.text,
|
|
233
|
+
line: c.callfn_node.startPosition.row + 1,
|
|
237
234
|
});
|
|
238
|
-
} else if (c
|
|
235
|
+
} else if (c.callmem_node) {
|
|
239
236
|
// call_expression with member_expression function
|
|
240
|
-
const callInfo = extractCallInfo(c
|
|
237
|
+
const callInfo = extractCallInfo(c.callmem_fn!, c.callmem_node);
|
|
241
238
|
if (callInfo) calls.push(callInfo);
|
|
242
|
-
const cbDef = extractCallbackDefinition(c
|
|
239
|
+
const cbDef = extractCallbackDefinition(c.callmem_node, c.callmem_fn);
|
|
243
240
|
if (cbDef) definitions.push(cbDef);
|
|
244
|
-
} else if (c
|
|
241
|
+
} else if (c.callsub_node) {
|
|
245
242
|
// call_expression with subscript_expression function
|
|
246
|
-
const callInfo = extractCallInfo(c
|
|
243
|
+
const callInfo = extractCallInfo(c.callsub_fn!, c.callsub_node);
|
|
247
244
|
if (callInfo) calls.push(callInfo);
|
|
248
|
-
} else if (c
|
|
245
|
+
} else if (c.assign_node) {
|
|
249
246
|
// CommonJS: module.exports = require(...) / module.exports = { ...require(...) }
|
|
250
|
-
handleCommonJSAssignment(c
|
|
247
|
+
handleCommonJSAssignment(c.assign_left!, c.assign_right!, c.assign_node, imports);
|
|
251
248
|
}
|
|
252
249
|
}
|
|
253
250
|
|
|
@@ -929,7 +926,7 @@ function extractTypeMapWalk(rootNode: TreeSitterNode, typeMap: Map<string, TypeM
|
|
|
929
926
|
}
|
|
930
927
|
|
|
931
928
|
function walk(node: TreeSitterNode, depth: number): void {
|
|
932
|
-
if (depth >=
|
|
929
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
933
930
|
const t = node.type;
|
|
934
931
|
if (t === 'variable_declarator') {
|
|
935
932
|
const nameN = node.childForFieldName('name');
|
package/src/extractors/php.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
TreeSitterNode,
|
|
6
6
|
TreeSitterTree,
|
|
7
7
|
} from '../types.js';
|
|
8
|
-
import { extractModifierVisibility, findChild, nodeEndLine } from './helpers.js';
|
|
8
|
+
import { extractModifierVisibility, findChild, MAX_WALK_DEPTH, nodeEndLine } from './helpers.js';
|
|
9
9
|
|
|
10
10
|
function extractPhpParameters(fnNode: TreeSitterNode): SubDeclaration[] {
|
|
11
11
|
const params: SubDeclaration[] = [];
|
|
@@ -340,7 +340,7 @@ function extractPhpTypeMap(node: TreeSitterNode, ctx: ExtractorOutput): void {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
function extractPhpTypeMapDepth(node: TreeSitterNode, ctx: ExtractorOutput, depth: number): void {
|
|
343
|
-
if (depth >=
|
|
343
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
344
344
|
|
|
345
345
|
// Function/method parameters with type hints
|
|
346
346
|
if (
|
package/src/extractors/python.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
TreeSitterTree,
|
|
7
7
|
TypeMapEntry,
|
|
8
8
|
} from '../types.js';
|
|
9
|
-
import { findChild, nodeEndLine, pythonVisibility } from './helpers.js';
|
|
9
|
+
import { findChild, MAX_WALK_DEPTH, nodeEndLine, pythonVisibility } from './helpers.js';
|
|
10
10
|
|
|
11
11
|
/** Built-in globals that start with uppercase but are not user-defined types. */
|
|
12
12
|
const BUILTIN_GLOBALS_PY: Set<string> = new Set([
|
|
@@ -365,7 +365,7 @@ function extractPythonTypeMapDepth(
|
|
|
365
365
|
ctx: ExtractorOutput,
|
|
366
366
|
depth: number,
|
|
367
367
|
): void {
|
|
368
|
-
if (depth >=
|
|
368
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
369
369
|
|
|
370
370
|
// typed_parameter: identifier : type (confidence 0.9)
|
|
371
371
|
if (node.type === 'typed_parameter') {
|
package/src/extractors/rust.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
TreeSitterNode,
|
|
6
6
|
TreeSitterTree,
|
|
7
7
|
} from '../types.js';
|
|
8
|
-
import { findChild, nodeEndLine, rustVisibility } from './helpers.js';
|
|
8
|
+
import { findChild, MAX_WALK_DEPTH, nodeEndLine, rustVisibility } from './helpers.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Extract symbols from Rust files.
|
|
@@ -274,7 +274,7 @@ function extractRustTypeMap(node: TreeSitterNode, ctx: ExtractorOutput): void {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
function extractRustTypeMapDepth(node: TreeSitterNode, ctx: ExtractorOutput, depth: number): void {
|
|
277
|
-
if (depth >=
|
|
277
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
278
278
|
|
|
279
279
|
// let x: MyType = ...
|
|
280
280
|
if (node.type === 'let_declaration') {
|
package/src/features/audit.ts
CHANGED
|
@@ -30,7 +30,7 @@ function resolveThresholds(
|
|
|
30
30
|
const repoRoot = path.resolve(dbDir, '..');
|
|
31
31
|
return loadConfig(repoRoot);
|
|
32
32
|
})();
|
|
33
|
-
const userRules = (cfg as Record<string, unknown>)
|
|
33
|
+
const userRules = (cfg as Record<string, unknown>).manifesto || {};
|
|
34
34
|
const resolved: Record<string, ThresholdEntry> = {};
|
|
35
35
|
for (const def of FUNCTION_RULES) {
|
|
36
36
|
const user = (userRules as Record<string, { warn?: number; fail?: number }>)[def.name];
|
|
@@ -163,7 +163,6 @@ export function auditData(
|
|
|
163
163
|
const explained = explainData(target, customDbPath, { noTests, depth: 0 });
|
|
164
164
|
|
|
165
165
|
// Apply --file and --kind filters for function targets
|
|
166
|
-
// biome-ignore lint/suspicious/noExplicitAny: explainData returns a union type that varies by kind
|
|
167
166
|
let results: any[] = explained.results;
|
|
168
167
|
if (explained.kind === 'function') {
|
|
169
168
|
if (fileFilters.length > 0)
|
|
@@ -6,13 +6,7 @@ import Database from 'better-sqlite3';
|
|
|
6
6
|
import { buildGraph } from '../domain/graph/builder.js';
|
|
7
7
|
import { kindIcon } from '../domain/queries.js';
|
|
8
8
|
import { isTestFile } from '../infrastructure/test-filter.js';
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
type DatabaseConstructor = new (
|
|
12
|
-
path: string,
|
|
13
|
-
opts?: Record<string, unknown>,
|
|
14
|
-
) => BetterSqlite3Database;
|
|
15
|
-
const Db = Database as unknown as DatabaseConstructor;
|
|
9
|
+
import type { EngineMode } from '../types.js';
|
|
16
10
|
|
|
17
11
|
// ─── Git Helpers ────────────────────────────────────────────────────────
|
|
18
12
|
|
|
@@ -111,7 +105,7 @@ function loadSymbolsFromDb(
|
|
|
111
105
|
changedFiles: string[],
|
|
112
106
|
noTests: boolean,
|
|
113
107
|
): Map<string, SymbolInfo> {
|
|
114
|
-
const db = new
|
|
108
|
+
const db = new Database(dbPath, { readonly: true });
|
|
115
109
|
try {
|
|
116
110
|
const symbols = new Map<string, SymbolInfo>();
|
|
117
111
|
|
|
@@ -180,7 +174,7 @@ function loadCallersFromDb(
|
|
|
180
174
|
): CallerInfo[] {
|
|
181
175
|
if (nodeIds.length === 0) return [];
|
|
182
176
|
|
|
183
|
-
const db = new
|
|
177
|
+
const db = new Database(dbPath, { readonly: true });
|
|
184
178
|
try {
|
|
185
179
|
const allCallers = new Set<string>();
|
|
186
180
|
|
package/src/features/cfg.ts
CHANGED
|
@@ -62,8 +62,7 @@ export function buildFunctionCFG(functionNode: TreeSitterNode, langId: string):
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
const results = walkWithVisitors(functionNode, [visitor], langId, walkerOpts);
|
|
65
|
-
|
|
66
|
-
const cfgResults = (results['cfg'] || []) as Array<{
|
|
65
|
+
const cfgResults = (results.cfg || []) as Array<{
|
|
67
66
|
funcNode: TreeSitterNode;
|
|
68
67
|
blocks: CfgBuildBlock[];
|
|
69
68
|
edges: CfgBuildEdge[];
|
|
@@ -214,8 +213,7 @@ function buildVisitorCfgMap(
|
|
|
214
213
|
},
|
|
215
214
|
};
|
|
216
215
|
const walkResults = walkWithVisitors(tree?.rootNode, [visitor], langId, walkerOpts);
|
|
217
|
-
|
|
218
|
-
const cfgResults = (walkResults['cfg'] || []) as VisitorCfgResult[];
|
|
216
|
+
const cfgResults = (walkResults.cfg || []) as VisitorCfgResult[];
|
|
219
217
|
const visitorCfgByLine = new Map<number, VisitorCfgResult[]>();
|
|
220
218
|
for (const r of cfgResults) {
|
|
221
219
|
if (r.funcNode) {
|
package/src/features/cochange.ts
CHANGED
|
@@ -472,10 +472,10 @@ function getCoChangeMeta(db: BetterSqlite3Database): CoChangeMeta | null {
|
|
|
472
472
|
meta[row.key] = row.value;
|
|
473
473
|
}
|
|
474
474
|
return {
|
|
475
|
-
analyzedAt: meta
|
|
476
|
-
since: meta
|
|
477
|
-
minSupport: meta
|
|
478
|
-
lastCommit: meta
|
|
475
|
+
analyzedAt: meta.analyzed_at || null,
|
|
476
|
+
since: meta.since || null,
|
|
477
|
+
minSupport: meta.min_support ? parseInt(meta.min_support, 10) : null,
|
|
478
|
+
lastCommit: meta.last_analyzed_commit || null,
|
|
479
479
|
};
|
|
480
480
|
} catch {
|
|
481
481
|
return null;
|
|
@@ -50,12 +50,12 @@ function buildCommunityObjects(
|
|
|
50
50
|
const memberData: CommunityMember[] = [];
|
|
51
51
|
for (const key of members) {
|
|
52
52
|
const attrs = graph.getNodeAttrs(key)!;
|
|
53
|
-
const dir = getDirectory(attrs
|
|
53
|
+
const dir = getDirectory(attrs.file as string);
|
|
54
54
|
dirCounts[dir] = (dirCounts[dir] || 0) + 1;
|
|
55
55
|
memberData.push({
|
|
56
|
-
name: attrs
|
|
57
|
-
file: attrs
|
|
58
|
-
...(attrs
|
|
56
|
+
name: attrs.label as string,
|
|
57
|
+
file: attrs.file as string,
|
|
58
|
+
...(attrs.kind ? { kind: attrs.kind as string } : {}),
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|