@optave/codegraph 3.4.0 → 3.5.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 +23 -22
- 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/rules/javascript.d.ts.map +1 -1
- package/dist/ast-analysis/rules/javascript.js +1 -0
- package/dist/ast-analysis/rules/javascript.js.map +1 -1
- package/dist/ast-analysis/shared.d.ts.map +1 -1
- package/dist/ast-analysis/shared.js +0 -1
- package/dist/ast-analysis/shared.js.map +1 -1
- package/dist/ast-analysis/visitors/ast-store-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/ast-store-visitor.js +103 -35
- package/dist/ast-analysis/visitors/ast-store-visitor.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/better-sqlite3.d.ts +3 -0
- package/dist/db/better-sqlite3.d.ts.map +1 -0
- package/dist/db/better-sqlite3.js +19 -0
- package/dist/db/better-sqlite3.js.map +1 -0
- package/dist/db/connection.d.ts +30 -2
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +167 -4
- package/dist/db/connection.js.map +1 -1
- package/dist/db/index.d.ts +2 -2
- 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 +9 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/query-builder.d.ts +5 -5
- package/dist/db/query-builder.d.ts.map +1 -1
- package/dist/db/query-builder.js +20 -4
- package/dist/db/query-builder.js.map +1 -1
- package/dist/db/repository/index.d.ts +1 -0
- package/dist/db/repository/index.d.ts.map +1 -1
- package/dist/db/repository/index.js +1 -0
- package/dist/db/repository/index.js.map +1 -1
- package/dist/db/repository/native-repository.d.ts +58 -0
- package/dist/db/repository/native-repository.d.ts.map +1 -0
- package/dist/db/repository/native-repository.js +261 -0
- package/dist/db/repository/native-repository.js.map +1 -0
- package/dist/db/repository/nodes.d.ts +4 -4
- package/dist/db/repository/nodes.d.ts.map +1 -1
- package/dist/db/repository/nodes.js +6 -6
- package/dist/db/repository/nodes.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 +3 -3
- package/dist/domain/graph/builder/context.d.ts.map +1 -1
- package/dist/domain/graph/builder/context.js +1 -0
- 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 +34 -6
- 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 +113 -15
- 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 +186 -62
- package/dist/domain/graph/builder/stages/build-structure.js.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.js +71 -7
- package/dist/domain/graph/builder/stages/collect-files.js.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js +42 -20
- 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 +111 -64
- 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 +104 -9
- 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 +12 -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 +111 -98
- 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 +4 -3
- package/dist/extractors/rust.js.map +1 -1
- package/dist/features/ast.d.ts +14 -1
- package/dist/features/ast.d.ts.map +1 -1
- package/dist/features/ast.js +38 -1
- package/dist/features/ast.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 +5 -4
- 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.js +2 -2
- 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 +4 -17
- 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 +230 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +62 -11
- package/src/ast-analysis/engine.ts +3 -9
- package/src/ast-analysis/rules/javascript.ts +1 -0
- package/src/ast-analysis/shared.ts +0 -1
- package/src/ast-analysis/visitors/ast-store-visitor.ts +102 -33
- 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/better-sqlite3.ts +20 -0
- package/src/db/connection.ts +191 -16
- package/src/db/index.ts +5 -1
- package/src/db/migrations.ts +9 -0
- package/src/db/query-builder.ts +30 -5
- package/src/db/repository/index.ts +1 -0
- package/src/db/repository/native-repository.ts +361 -0
- package/src/db/repository/nodes.ts +7 -3
- 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 +4 -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 +37 -5
- package/src/domain/graph/builder/stages/build-edges.ts +131 -20
- package/src/domain/graph/builder/stages/build-structure.ts +245 -80
- package/src/domain/graph/builder/stages/collect-files.ts +84 -7
- package/src/domain/graph/builder/stages/detect-changes.ts +49 -32
- package/src/domain/graph/builder/stages/finalize.ts +132 -84
- package/src/domain/graph/builder/stages/insert-nodes.ts +141 -18
- 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 +12 -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 +112 -97
- package/src/extractors/php.ts +2 -2
- package/src/extractors/python.ts +2 -2
- package/src/extractors/rust.ts +4 -3
- package/src/features/ast.ts +66 -1
- package/src/features/audit.ts +1 -2
- package/src/features/branch-compare.ts +6 -10
- 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 +3 -3
- 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 +4 -20
- 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 +277 -10
- package/src/vendor.d.ts +0 -39
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { debug } from '../../infrastructure/logger.js';
|
|
3
4
|
import { loadNative } from '../../infrastructure/native.js';
|
|
4
5
|
import { normalizePath } from '../../shared/constants.js';
|
|
6
|
+
import { toErrorMessage } from '../../shared/errors.js';
|
|
5
7
|
import type { BareSpecifier, BatchResolvedMap, ImportBatchItem, PathAliases } from '../../types.js';
|
|
6
8
|
|
|
7
9
|
// ── package.json exports resolution ─────────────────────────────────
|
|
8
10
|
|
|
9
11
|
/** Cache: packageDir → parsed exports field (or null) */
|
|
10
|
-
// biome-ignore lint/suspicious/noExplicitAny: package.json exports field has no fixed schema
|
|
11
12
|
const _exportsCache: Map<string, any> = new Map();
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -55,7 +56,6 @@ function findPackageDir(packageName: string, rootDir: string): string | null {
|
|
|
55
56
|
* Read and cache the exports field from a package's package.json.
|
|
56
57
|
* Returns the exports value or null.
|
|
57
58
|
*/
|
|
58
|
-
// biome-ignore lint/suspicious/noExplicitAny: package.json exports field has no fixed schema
|
|
59
59
|
function getPackageExports(packageDir: string): any {
|
|
60
60
|
if (_exportsCache.has(packageDir)) return _exportsCache.get(packageDir);
|
|
61
61
|
try {
|
|
@@ -64,7 +64,8 @@ function getPackageExports(packageDir: string): any {
|
|
|
64
64
|
const exports = pkg.exports ?? null;
|
|
65
65
|
_exportsCache.set(packageDir, exports);
|
|
66
66
|
return exports;
|
|
67
|
-
} catch {
|
|
67
|
+
} catch (e) {
|
|
68
|
+
debug(`readPackageExports: failed to read package.json in ${packageDir}: ${toErrorMessage(e)}`);
|
|
68
69
|
_exportsCache.set(packageDir, null);
|
|
69
70
|
return null;
|
|
70
71
|
}
|
|
@@ -515,8 +516,10 @@ export function resolveImportPath(
|
|
|
515
516
|
// unresolved ".." components (PathBuf::components().collect() doesn't
|
|
516
517
|
// collapse parent refs). Apply the remap on the JS side as a fallback.
|
|
517
518
|
return remapJsToTs(normalized, rootDir);
|
|
518
|
-
} catch {
|
|
519
|
-
|
|
519
|
+
} catch (e) {
|
|
520
|
+
debug(
|
|
521
|
+
`resolveImportPath: native resolution failed, falling back to JS: ${toErrorMessage(e)}`,
|
|
522
|
+
);
|
|
520
523
|
}
|
|
521
524
|
}
|
|
522
525
|
return resolveImportPathJS(fromFile, importSource, rootDir, aliases);
|
|
@@ -535,8 +538,10 @@ export function computeConfidence(
|
|
|
535
538
|
if (native) {
|
|
536
539
|
try {
|
|
537
540
|
return native.computeConfidence(callerFile, targetFile, importedFrom || null);
|
|
538
|
-
} catch {
|
|
539
|
-
|
|
541
|
+
} catch (e) {
|
|
542
|
+
debug(
|
|
543
|
+
`computeConfidence: native computation failed, falling back to JS: ${toErrorMessage(e)}`,
|
|
544
|
+
);
|
|
540
545
|
}
|
|
541
546
|
}
|
|
542
547
|
return computeConfidenceJS(callerFile, targetFile, importedFrom);
|
|
@@ -575,7 +580,8 @@ export function resolveImportsBatch(
|
|
|
575
580
|
map.set(`${r.fromFile}|${r.importSource}`, resolved);
|
|
576
581
|
}
|
|
577
582
|
return map;
|
|
578
|
-
} catch {
|
|
583
|
+
} catch (e) {
|
|
584
|
+
debug(`batchResolve: native batch resolution failed: ${toErrorMessage(e)}`);
|
|
579
585
|
return null;
|
|
580
586
|
}
|
|
581
587
|
}
|
|
@@ -24,9 +24,7 @@ export async function watchProject(rootDir: string, opts: { engine?: string } =
|
|
|
24
24
|
throw new DbError('No graph.db found. Run `codegraph build` first.', { file: dbPath });
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const db = openDb(dbPath)
|
|
28
|
-
// Alias for functions expecting the project's BetterSqlite3Database interface
|
|
29
|
-
const typedDb = db as unknown as import('../../types.js').BetterSqlite3Database;
|
|
27
|
+
const db = openDb(dbPath);
|
|
30
28
|
initSchema(db);
|
|
31
29
|
const engineOpts: import('../../types.js').EngineOpts = {
|
|
32
30
|
engine: (opts.engine || 'auto') as import('../../types.js').EngineMode,
|
|
@@ -51,7 +49,7 @@ export async function watchProject(rootDir: string, opts: { engine?: string } =
|
|
|
51
49
|
),
|
|
52
50
|
getNodeId: {
|
|
53
51
|
get: (name: string, kind: string, file: string, line: number) => {
|
|
54
|
-
const id = getNodeIdQuery(
|
|
52
|
+
const id = getNodeIdQuery(db, name, kind, file, line);
|
|
55
53
|
return id != null ? { id } : undefined;
|
|
56
54
|
},
|
|
57
55
|
},
|
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
|
|
|
@@ -85,6 +85,7 @@ const COMMON_QUERY_PATTERNS: string[] = [
|
|
|
85
85
|
'(variable_declarator name: (identifier) @varfn_name value: (arrow_function) @varfn_value)',
|
|
86
86
|
'(variable_declarator name: (identifier) @varfn_name value: (function_expression) @varfn_value)',
|
|
87
87
|
'(method_definition name: (property_identifier) @meth_name) @meth_node',
|
|
88
|
+
'(method_definition name: (private_property_identifier) @meth_name) @meth_node',
|
|
88
89
|
'(import_statement source: (string) @imp_source) @imp_node',
|
|
89
90
|
'(export_statement) @exp_node',
|
|
90
91
|
'(call_expression function: (identifier) @callfn_name) @callfn_node',
|
|
@@ -171,7 +172,6 @@ export function disposeParsers(): void {
|
|
|
171
172
|
_queryCache.clear();
|
|
172
173
|
if (_cachedLanguages) {
|
|
173
174
|
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
175
|
if (lang && typeof (lang as any).delete === 'function') {
|
|
176
176
|
try {
|
|
177
177
|
(lang as any).delete();
|
|
@@ -197,7 +197,6 @@ export function getParser(parsers: Map<string, Parser | null>, filePath: string)
|
|
|
197
197
|
* don't each need to create parsers and re-parse independently.
|
|
198
198
|
* Only parses files whose extension is in SUPPORTED_EXTENSIONS.
|
|
199
199
|
*/
|
|
200
|
-
// biome-ignore lint/suspicious/noExplicitAny: fileSymbols values have dynamic shape from extractors
|
|
201
200
|
export async function ensureWasmTrees(
|
|
202
201
|
fileSymbols: Map<string, any>,
|
|
203
202
|
rootDir: string,
|
|
@@ -274,7 +273,6 @@ function resolveEngine(opts: ParseEngineOpts = {}): ResolvedEngine {
|
|
|
274
273
|
* - Backward compat for older native binaries missing js_name annotations
|
|
275
274
|
* - dataflow argFlows/mutations bindingType -> binding wrapper
|
|
276
275
|
*/
|
|
277
|
-
// biome-ignore lint/suspicious/noExplicitAny: native addon result has no type declarations
|
|
278
276
|
function patchNativeResult(r: any): ExtractorOutput {
|
|
279
277
|
// lineCount: napi(js_name) emits "lineCount"; older binaries may emit "line_count"
|
|
280
278
|
r.lineCount = r.lineCount ?? r.line_count ?? null;
|
|
@@ -433,7 +431,6 @@ export const SUPPORTED_EXTENSIONS: Set<string> = new Set(_extToLang.keys());
|
|
|
433
431
|
* matches inside comments and string literals.
|
|
434
432
|
* TODO: Remove once all published native binaries include typeMap extraction (>= 3.2.0)
|
|
435
433
|
*/
|
|
436
|
-
// biome-ignore lint/suspicious/noExplicitAny: return shape matches native result typeMap
|
|
437
434
|
async function backfillTypeMap(
|
|
438
435
|
filePath: string,
|
|
439
436
|
source?: string,
|
|
@@ -442,7 +439,8 @@ async function backfillTypeMap(
|
|
|
442
439
|
if (!code) {
|
|
443
440
|
try {
|
|
444
441
|
code = fs.readFileSync(filePath, 'utf-8');
|
|
445
|
-
} catch {
|
|
442
|
+
} catch (e) {
|
|
443
|
+
debug(`backfillTypeMap: failed to read ${filePath}: ${toErrorMessage(e)}`);
|
|
446
444
|
return { typeMap: new Map(), backfilled: false };
|
|
447
445
|
}
|
|
448
446
|
}
|
|
@@ -458,7 +456,9 @@ async function backfillTypeMap(
|
|
|
458
456
|
if (extracted?.tree && typeof extracted.tree.delete === 'function') {
|
|
459
457
|
try {
|
|
460
458
|
extracted.tree.delete();
|
|
461
|
-
} catch {
|
|
459
|
+
} catch (e) {
|
|
460
|
+
debug(`backfillTypeMap: WASM tree cleanup failed: ${toErrorMessage(e)}`);
|
|
461
|
+
}
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
}
|
|
@@ -488,7 +488,6 @@ function wasmExtractSymbols(
|
|
|
488
488
|
if (!entry) return null;
|
|
489
489
|
const query = _queryCache.get(entry.id) ?? undefined;
|
|
490
490
|
// Query (web-tree-sitter) is structurally compatible with TreeSitterQuery at runtime
|
|
491
|
-
// biome-ignore lint/suspicious/noExplicitAny: thin WASM wrapper type mismatch
|
|
492
491
|
const symbols = entry.extractor(tree as any, filePath, query as any);
|
|
493
492
|
return symbols ? { symbols, tree, langId: entry.id } : null;
|
|
494
493
|
}
|
|
@@ -571,14 +570,16 @@ export async function parseFilesAuto(
|
|
|
571
570
|
symbols.typeMap = extracted.symbols.typeMap;
|
|
572
571
|
symbols._typeMapBackfilled = true;
|
|
573
572
|
}
|
|
574
|
-
} catch {
|
|
575
|
-
|
|
573
|
+
} catch (e) {
|
|
574
|
+
debug(`batchExtract: typeMap backfill failed: ${toErrorMessage(e)}`);
|
|
576
575
|
} finally {
|
|
577
576
|
// Free the WASM tree to prevent memory accumulation across repeated builds
|
|
578
577
|
if (extracted?.tree && typeof extracted.tree.delete === 'function') {
|
|
579
578
|
try {
|
|
580
579
|
extracted.tree.delete();
|
|
581
|
-
} catch {
|
|
580
|
+
} catch (e) {
|
|
581
|
+
debug(`batchExtract: WASM tree cleanup failed: ${toErrorMessage(e)}`);
|
|
582
|
+
}
|
|
582
583
|
}
|
|
583
584
|
}
|
|
584
585
|
}
|
|
@@ -638,7 +639,6 @@ export function getActiveEngine(opts: ParseEngineOpts = {}): {
|
|
|
638
639
|
* Create a native ParseTreeCache for incremental parsing.
|
|
639
640
|
* Returns null if the native engine is unavailable (WASM fallback).
|
|
640
641
|
*/
|
|
641
|
-
// biome-ignore lint/suspicious/noExplicitAny: native ParseTreeCache has no type declarations
|
|
642
642
|
export function createParseTreeCache(): any {
|
|
643
643
|
const native = loadNative();
|
|
644
644
|
if (!native || !native.ParseTreeCache) return null;
|
|
@@ -648,7 +648,6 @@ export function createParseTreeCache(): any {
|
|
|
648
648
|
/**
|
|
649
649
|
* Parse a file incrementally using the cache, or fall back to full parse.
|
|
650
650
|
*/
|
|
651
|
-
// biome-ignore lint/suspicious/noExplicitAny: cache is native ParseTreeCache with no type declarations
|
|
652
651
|
export async function parseFileIncremental(
|
|
653
652
|
cache: any,
|
|
654
653
|
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
|
|
|
@@ -263,51 +260,69 @@ function extractSymbolsQuery(tree: TreeSitterTree, query: TreeSitterQuery): Extr
|
|
|
263
260
|
return { definitions, calls, imports, classes, exports: exps, typeMap };
|
|
264
261
|
}
|
|
265
262
|
|
|
263
|
+
/** Node types that define a function scope — constants inside these are skipped. */
|
|
264
|
+
const FUNCTION_SCOPE_TYPES = new Set([
|
|
265
|
+
'function_declaration',
|
|
266
|
+
'arrow_function',
|
|
267
|
+
'function_expression',
|
|
268
|
+
'method_definition',
|
|
269
|
+
'generator_function_declaration',
|
|
270
|
+
'generator_function',
|
|
271
|
+
]);
|
|
272
|
+
|
|
266
273
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
274
|
+
* Recursively walk the AST to extract `const x = <literal>` as constants.
|
|
275
|
+
* Skips nodes inside function scopes so only file-level / block-level constants
|
|
276
|
+
* are captured — matching the native engine's behaviour.
|
|
270
277
|
*/
|
|
271
|
-
function extractConstantsWalk(
|
|
272
|
-
for (let i = 0; i <
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
278
|
+
function extractConstantsWalk(node: TreeSitterNode, definitions: Definition[]): void {
|
|
279
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
280
|
+
const child = node.child(i);
|
|
281
|
+
if (!child) continue;
|
|
282
|
+
|
|
283
|
+
// Don't descend into function scopes
|
|
284
|
+
if (FUNCTION_SCOPE_TYPES.has(child.type)) continue;
|
|
275
285
|
|
|
276
|
-
let declNode =
|
|
286
|
+
let declNode = child;
|
|
277
287
|
// Handle `export const …` — unwrap the export_statement to its declaration child
|
|
278
|
-
if (
|
|
279
|
-
const inner =
|
|
280
|
-
if (
|
|
281
|
-
declNode = inner;
|
|
288
|
+
if (child.type === 'export_statement') {
|
|
289
|
+
const inner = child.childForFieldName('declaration');
|
|
290
|
+
if (inner) declNode = inner;
|
|
282
291
|
}
|
|
283
292
|
|
|
284
293
|
const t = declNode.type;
|
|
285
|
-
if (t
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
294
|
+
if (t === 'lexical_declaration' || t === 'variable_declaration') {
|
|
295
|
+
if (declNode.text.startsWith('const ')) {
|
|
296
|
+
for (let j = 0; j < declNode.childCount; j++) {
|
|
297
|
+
const declarator = declNode.child(j);
|
|
298
|
+
if (!declarator || declarator.type !== 'variable_declarator') continue;
|
|
299
|
+
const nameN = declarator.childForFieldName('name');
|
|
300
|
+
const valueN = declarator.childForFieldName('value');
|
|
301
|
+
if (!nameN || nameN.type !== 'identifier' || !valueN) continue;
|
|
302
|
+
// Skip functions — already captured by query patterns
|
|
303
|
+
const valType = valueN.type;
|
|
304
|
+
if (
|
|
305
|
+
valType === 'arrow_function' ||
|
|
306
|
+
valType === 'function_expression' ||
|
|
307
|
+
valType === 'function'
|
|
308
|
+
)
|
|
309
|
+
continue;
|
|
310
|
+
if (isConstantValue(valueN)) {
|
|
311
|
+
definitions.push({
|
|
312
|
+
name: nameN.text,
|
|
313
|
+
kind: 'constant',
|
|
314
|
+
line: declNode.startPosition.row + 1,
|
|
315
|
+
endLine: nodeEndLine(declNode),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
309
319
|
}
|
|
310
320
|
}
|
|
321
|
+
|
|
322
|
+
// Recurse into non-function, non-export-statement children (blocks, if-statements, etc.)
|
|
323
|
+
if (child.type !== 'export_statement') {
|
|
324
|
+
extractConstantsWalk(child, definitions);
|
|
325
|
+
}
|
|
311
326
|
}
|
|
312
327
|
}
|
|
313
328
|
|
|
@@ -929,7 +944,7 @@ function extractTypeMapWalk(rootNode: TreeSitterNode, typeMap: Map<string, TypeM
|
|
|
929
944
|
}
|
|
930
945
|
|
|
931
946
|
function walk(node: TreeSitterNode, depth: number): void {
|
|
932
|
-
if (depth >=
|
|
947
|
+
if (depth >= MAX_WALK_DEPTH) return;
|
|
933
948
|
const t = node.type;
|
|
934
949
|
if (t === 'variable_declarator') {
|
|
935
950
|
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 (
|