@opencodehub/ingestion 0.1.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/LICENSE +202 -0
- package/README.md +69 -0
- package/dist/extract/index.d.ts +8 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +6 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/extract/orm-detector.d.ts +19 -0
- package/dist/extract/orm-detector.d.ts.map +1 -0
- package/dist/extract/orm-detector.js +209 -0
- package/dist/extract/orm-detector.js.map +1 -0
- package/dist/extract/property-access.d.ts +76 -0
- package/dist/extract/property-access.d.ts.map +1 -0
- package/dist/extract/property-access.js +260 -0
- package/dist/extract/property-access.js.map +1 -0
- package/dist/extract/receiver-resolver.d.ts +86 -0
- package/dist/extract/receiver-resolver.d.ts.map +1 -0
- package/dist/extract/receiver-resolver.js +77 -0
- package/dist/extract/receiver-resolver.js.map +1 -0
- package/dist/extract/route-detector-java.d.ts +29 -0
- package/dist/extract/route-detector-java.d.ts.map +1 -0
- package/dist/extract/route-detector-java.js +190 -0
- package/dist/extract/route-detector-java.js.map +1 -0
- package/dist/extract/route-detector-nestjs.d.ts +30 -0
- package/dist/extract/route-detector-nestjs.d.ts.map +1 -0
- package/dist/extract/route-detector-nestjs.js +134 -0
- package/dist/extract/route-detector-nestjs.js.map +1 -0
- package/dist/extract/route-detector-python.d.ts +28 -0
- package/dist/extract/route-detector-python.d.ts.map +1 -0
- package/dist/extract/route-detector-python.js +100 -0
- package/dist/extract/route-detector-python.js.map +1 -0
- package/dist/extract/route-detector-rails.d.ts +28 -0
- package/dist/extract/route-detector-rails.d.ts.map +1 -0
- package/dist/extract/route-detector-rails.js +162 -0
- package/dist/extract/route-detector-rails.js.map +1 -0
- package/dist/extract/route-detector.d.ts +45 -0
- package/dist/extract/route-detector.d.ts.map +1 -0
- package/dist/extract/route-detector.js +467 -0
- package/dist/extract/route-detector.js.map +1 -0
- package/dist/extract/tool-detector.d.ts +26 -0
- package/dist/extract/tool-detector.d.ts.map +1 -0
- package/dist/extract/tool-detector.js +364 -0
- package/dist/extract/tool-detector.js.map +1 -0
- package/dist/extract/types.d.ts +89 -0
- package/dist/extract/types.d.ts.map +1 -0
- package/dist/extract/types.js +11 -0
- package/dist/extract/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/parse/cobol-regex.d.ts +85 -0
- package/dist/parse/cobol-regex.d.ts.map +1 -0
- package/dist/parse/cobol-regex.js +355 -0
- package/dist/parse/cobol-regex.js.map +1 -0
- package/dist/parse/grammar-registry.d.ts +115 -0
- package/dist/parse/grammar-registry.d.ts.map +1 -0
- package/dist/parse/grammar-registry.js +278 -0
- package/dist/parse/grammar-registry.js.map +1 -0
- package/dist/parse/index.d.ts +14 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +10 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/language-detector.d.ts +17 -0
- package/dist/parse/language-detector.d.ts.map +1 -0
- package/dist/parse/language-detector.js +104 -0
- package/dist/parse/language-detector.js.map +1 -0
- package/dist/parse/parse-worker.d.ts +24 -0
- package/dist/parse/parse-worker.d.ts.map +1 -0
- package/dist/parse/parse-worker.js +230 -0
- package/dist/parse/parse-worker.js.map +1 -0
- package/dist/parse/types.d.ts +49 -0
- package/dist/parse/types.d.ts.map +1 -0
- package/dist/parse/types.js +11 -0
- package/dist/parse/types.js.map +1 -0
- package/dist/parse/unified-queries.d.ts +37 -0
- package/dist/parse/unified-queries.d.ts.map +1 -0
- package/dist/parse/unified-queries.js +623 -0
- package/dist/parse/unified-queries.js.map +1 -0
- package/dist/parse/wasm-fallback.d.ts +88 -0
- package/dist/parse/wasm-fallback.d.ts.map +1 -0
- package/dist/parse/wasm-fallback.js +258 -0
- package/dist/parse/wasm-fallback.js.map +1 -0
- package/dist/parse/worker-pool.d.ts +48 -0
- package/dist/parse/worker-pool.d.ts.map +1 -0
- package/dist/parse/worker-pool.js +97 -0
- package/dist/parse/worker-pool.js.map +1 -0
- package/dist/pipeline/dep-parsers/go.d.ts +25 -0
- package/dist/pipeline/dep-parsers/go.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/go.js +146 -0
- package/dist/pipeline/dep-parsers/go.js.map +1 -0
- package/dist/pipeline/dep-parsers/index.d.ts +17 -0
- package/dist/pipeline/dep-parsers/index.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/index.js +16 -0
- package/dist/pipeline/dep-parsers/index.js.map +1 -0
- package/dist/pipeline/dep-parsers/maven.d.ts +24 -0
- package/dist/pipeline/dep-parsers/maven.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/maven.js +131 -0
- package/dist/pipeline/dep-parsers/maven.js.map +1 -0
- package/dist/pipeline/dep-parsers/npm.d.ts +30 -0
- package/dist/pipeline/dep-parsers/npm.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/npm.js +309 -0
- package/dist/pipeline/dep-parsers/npm.js.map +1 -0
- package/dist/pipeline/dep-parsers/nuget.d.ts +24 -0
- package/dist/pipeline/dep-parsers/nuget.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/nuget.js +178 -0
- package/dist/pipeline/dep-parsers/nuget.js.map +1 -0
- package/dist/pipeline/dep-parsers/python.d.ts +21 -0
- package/dist/pipeline/dep-parsers/python.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/python.js +369 -0
- package/dist/pipeline/dep-parsers/python.js.map +1 -0
- package/dist/pipeline/dep-parsers/rust.d.ts +18 -0
- package/dist/pipeline/dep-parsers/rust.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/rust.js +134 -0
- package/dist/pipeline/dep-parsers/rust.js.map +1 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.d.ts +15 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.js +31 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.js.map +1 -0
- package/dist/pipeline/dep-parsers/types.d.ts +63 -0
- package/dist/pipeline/dep-parsers/types.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/types.js +56 -0
- package/dist/pipeline/dep-parsers/types.js.map +1 -0
- package/dist/pipeline/gitignore-stack.d.ts +44 -0
- package/dist/pipeline/gitignore-stack.d.ts.map +1 -0
- package/dist/pipeline/gitignore-stack.js +69 -0
- package/dist/pipeline/gitignore-stack.js.map +1 -0
- package/dist/pipeline/gitignore.d.ts +67 -0
- package/dist/pipeline/gitignore.d.ts.map +1 -0
- package/dist/pipeline/gitignore.js +210 -0
- package/dist/pipeline/gitignore.js.map +1 -0
- package/dist/pipeline/index.d.ts +53 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +29 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/orchestrator.d.ts +105 -0
- package/dist/pipeline/orchestrator.d.ts.map +1 -0
- package/dist/pipeline/orchestrator.js +175 -0
- package/dist/pipeline/orchestrator.js.map +1 -0
- package/dist/pipeline/ownership-helpers/drift.d.ts +41 -0
- package/dist/pipeline/ownership-helpers/drift.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/drift.js +122 -0
- package/dist/pipeline/ownership-helpers/drift.js.map +1 -0
- package/dist/pipeline/ownership-helpers/gini-community.d.ts +24 -0
- package/dist/pipeline/ownership-helpers/gini-community.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/gini-community.js +32 -0
- package/dist/pipeline/ownership-helpers/gini-community.js.map +1 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts +71 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.js +178 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.js.map +1 -0
- package/dist/pipeline/ownership-helpers/line-overlap.d.ts +35 -0
- package/dist/pipeline/ownership-helpers/line-overlap.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/line-overlap.js +62 -0
- package/dist/pipeline/ownership-helpers/line-overlap.js.map +1 -0
- package/dist/pipeline/ownership-helpers/orphan.d.ts +73 -0
- package/dist/pipeline/ownership-helpers/orphan.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/orphan.js +117 -0
- package/dist/pipeline/ownership-helpers/orphan.js.map +1 -0
- package/dist/pipeline/phases/accesses.d.ts +44 -0
- package/dist/pipeline/phases/accesses.d.ts.map +1 -0
- package/dist/pipeline/phases/accesses.js +194 -0
- package/dist/pipeline/phases/accesses.js.map +1 -0
- package/dist/pipeline/phases/annotate.d.ts +28 -0
- package/dist/pipeline/phases/annotate.d.ts.map +1 -0
- package/dist/pipeline/phases/annotate.js +60 -0
- package/dist/pipeline/phases/annotate.js.map +1 -0
- package/dist/pipeline/phases/cochange.d.ts +42 -0
- package/dist/pipeline/phases/cochange.d.ts.map +1 -0
- package/dist/pipeline/phases/cochange.js +0 -0
- package/dist/pipeline/phases/cochange.js.map +1 -0
- package/dist/pipeline/phases/communities.d.ts +34 -0
- package/dist/pipeline/phases/communities.d.ts.map +1 -0
- package/dist/pipeline/phases/communities.js +412 -0
- package/dist/pipeline/phases/communities.js.map +1 -0
- package/dist/pipeline/phases/complexity.d.ts +50 -0
- package/dist/pipeline/phases/complexity.d.ts.map +1 -0
- package/dist/pipeline/phases/complexity.js +794 -0
- package/dist/pipeline/phases/complexity.js.map +1 -0
- package/dist/pipeline/phases/confidence-demote.d.ts +23 -0
- package/dist/pipeline/phases/confidence-demote.d.ts.map +1 -0
- package/dist/pipeline/phases/confidence-demote.js +113 -0
- package/dist/pipeline/phases/confidence-demote.js.map +1 -0
- package/dist/pipeline/phases/content-cache.d.ts +166 -0
- package/dist/pipeline/phases/content-cache.d.ts.map +1 -0
- package/dist/pipeline/phases/content-cache.js +323 -0
- package/dist/pipeline/phases/content-cache.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts +25 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.js +139 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts +25 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.js +51 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts +32 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.js +98 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.d.ts +21 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.js +104 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/types.d.ts +27 -0
- package/dist/pipeline/phases/coverage-parsers/types.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/types.js +39 -0
- package/dist/pipeline/phases/coverage-parsers/types.js.map +1 -0
- package/dist/pipeline/phases/coverage.d.ts +39 -0
- package/dist/pipeline/phases/coverage.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage.js +154 -0
- package/dist/pipeline/phases/coverage.js.map +1 -0
- package/dist/pipeline/phases/cross-file.d.ts +40 -0
- package/dist/pipeline/phases/cross-file.d.ts.map +1 -0
- package/dist/pipeline/phases/cross-file.js +411 -0
- package/dist/pipeline/phases/cross-file.js.map +1 -0
- package/dist/pipeline/phases/dead-code.d.ts +28 -0
- package/dist/pipeline/phases/dead-code.d.ts.map +1 -0
- package/dist/pipeline/phases/dead-code.js +157 -0
- package/dist/pipeline/phases/dead-code.js.map +1 -0
- package/dist/pipeline/phases/default-set.d.ts +24 -0
- package/dist/pipeline/phases/default-set.d.ts.map +1 -0
- package/dist/pipeline/phases/default-set.js +133 -0
- package/dist/pipeline/phases/default-set.js.map +1 -0
- package/dist/pipeline/phases/dependencies.d.ts +59 -0
- package/dist/pipeline/phases/dependencies.d.ts.map +1 -0
- package/dist/pipeline/phases/dependencies.js +281 -0
- package/dist/pipeline/phases/dependencies.js.map +1 -0
- package/dist/pipeline/phases/embedder-pool.d.ts +31 -0
- package/dist/pipeline/phases/embedder-pool.d.ts.map +1 -0
- package/dist/pipeline/phases/embedder-pool.js +79 -0
- package/dist/pipeline/phases/embedder-pool.js.map +1 -0
- package/dist/pipeline/phases/embedder-worker.d.ts +28 -0
- package/dist/pipeline/phases/embedder-worker.d.ts.map +1 -0
- package/dist/pipeline/phases/embedder-worker.js +43 -0
- package/dist/pipeline/phases/embedder-worker.js.map +1 -0
- package/dist/pipeline/phases/embeddings.d.ts +117 -0
- package/dist/pipeline/phases/embeddings.d.ts.map +1 -0
- package/dist/pipeline/phases/embeddings.js +697 -0
- package/dist/pipeline/phases/embeddings.js.map +1 -0
- package/dist/pipeline/phases/fetches.d.ts +47 -0
- package/dist/pipeline/phases/fetches.d.ts.map +1 -0
- package/dist/pipeline/phases/fetches.js +207 -0
- package/dist/pipeline/phases/fetches.js.map +1 -0
- package/dist/pipeline/phases/incremental-helper.d.ts +96 -0
- package/dist/pipeline/phases/incremental-helper.d.ts.map +1 -0
- package/dist/pipeline/phases/incremental-helper.js +125 -0
- package/dist/pipeline/phases/incremental-helper.js.map +1 -0
- package/dist/pipeline/phases/incremental-scope.d.ts +67 -0
- package/dist/pipeline/phases/incremental-scope.d.ts.map +1 -0
- package/dist/pipeline/phases/incremental-scope.js +225 -0
- package/dist/pipeline/phases/incremental-scope.js.map +1 -0
- package/dist/pipeline/phases/markdown.d.ts +29 -0
- package/dist/pipeline/phases/markdown.d.ts.map +1 -0
- package/dist/pipeline/phases/markdown.js +298 -0
- package/dist/pipeline/phases/markdown.js.map +1 -0
- package/dist/pipeline/phases/mro.d.ts +24 -0
- package/dist/pipeline/phases/mro.d.ts.map +1 -0
- package/dist/pipeline/phases/mro.js +303 -0
- package/dist/pipeline/phases/mro.js.map +1 -0
- package/dist/pipeline/phases/openapi.d.ts +52 -0
- package/dist/pipeline/phases/openapi.d.ts.map +1 -0
- package/dist/pipeline/phases/openapi.js +285 -0
- package/dist/pipeline/phases/openapi.js.map +1 -0
- package/dist/pipeline/phases/orm.d.ts +26 -0
- package/dist/pipeline/phases/orm.d.ts.map +1 -0
- package/dist/pipeline/phases/orm.js +183 -0
- package/dist/pipeline/phases/orm.js.map +1 -0
- package/dist/pipeline/phases/ownership.d.ts +88 -0
- package/dist/pipeline/phases/ownership.d.ts.map +1 -0
- package/dist/pipeline/phases/ownership.js +479 -0
- package/dist/pipeline/phases/ownership.js.map +1 -0
- package/dist/pipeline/phases/parse.d.ts +63 -0
- package/dist/pipeline/phases/parse.d.ts.map +1 -0
- package/dist/pipeline/phases/parse.js +994 -0
- package/dist/pipeline/phases/parse.js.map +1 -0
- package/dist/pipeline/phases/processes.d.ts +47 -0
- package/dist/pipeline/phases/processes.d.ts.map +1 -0
- package/dist/pipeline/phases/processes.js +620 -0
- package/dist/pipeline/phases/processes.js.map +1 -0
- package/dist/pipeline/phases/profile.d.ts +33 -0
- package/dist/pipeline/phases/profile.d.ts.map +1 -0
- package/dist/pipeline/phases/profile.js +91 -0
- package/dist/pipeline/phases/profile.js.map +1 -0
- package/dist/pipeline/phases/repo-node.d.ts +112 -0
- package/dist/pipeline/phases/repo-node.d.ts.map +1 -0
- package/dist/pipeline/phases/repo-node.js +272 -0
- package/dist/pipeline/phases/repo-node.js.map +1 -0
- package/dist/pipeline/phases/risk-snapshot.d.ts +34 -0
- package/dist/pipeline/phases/risk-snapshot.d.ts.map +1 -0
- package/dist/pipeline/phases/risk-snapshot.js +63 -0
- package/dist/pipeline/phases/risk-snapshot.js.map +1 -0
- package/dist/pipeline/phases/routes.d.ts +31 -0
- package/dist/pipeline/phases/routes.d.ts.map +1 -0
- package/dist/pipeline/phases/routes.js +262 -0
- package/dist/pipeline/phases/routes.js.map +1 -0
- package/dist/pipeline/phases/sbom.d.ts +45 -0
- package/dist/pipeline/phases/sbom.d.ts.map +1 -0
- package/dist/pipeline/phases/sbom.js +289 -0
- package/dist/pipeline/phases/sbom.js.map +1 -0
- package/dist/pipeline/phases/scan.d.ts +54 -0
- package/dist/pipeline/phases/scan.d.ts.map +1 -0
- package/dist/pipeline/phases/scan.js +340 -0
- package/dist/pipeline/phases/scan.js.map +1 -0
- package/dist/pipeline/phases/scip-index.d.ts +54 -0
- package/dist/pipeline/phases/scip-index.d.ts.map +1 -0
- package/dist/pipeline/phases/scip-index.js +469 -0
- package/dist/pipeline/phases/scip-index.js.map +1 -0
- package/dist/pipeline/phases/structure.d.ts +21 -0
- package/dist/pipeline/phases/structure.d.ts.map +1 -0
- package/dist/pipeline/phases/structure.js +115 -0
- package/dist/pipeline/phases/structure.js.map +1 -0
- package/dist/pipeline/phases/summarize.d.ts +126 -0
- package/dist/pipeline/phases/summarize.d.ts.map +1 -0
- package/dist/pipeline/phases/summarize.js +401 -0
- package/dist/pipeline/phases/summarize.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts +42 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.js +96 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts +22 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.js +32 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts +21 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.js +37 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/gini.d.ts +32 -0
- package/dist/pipeline/phases/temporal-helpers/gini.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/gini.js +78 -0
- package/dist/pipeline/phases/temporal-helpers/gini.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts +14 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.js +25 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts +18 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.js +119 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.js.map +1 -0
- package/dist/pipeline/phases/temporal.d.ts +65 -0
- package/dist/pipeline/phases/temporal.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal.js +621 -0
- package/dist/pipeline/phases/temporal.js.map +1 -0
- package/dist/pipeline/phases/tools.d.ts +21 -0
- package/dist/pipeline/phases/tools.d.ts.map +1 -0
- package/dist/pipeline/phases/tools.js +118 -0
- package/dist/pipeline/phases/tools.js.map +1 -0
- package/dist/pipeline/profile-detectors/api-contracts.d.ts +18 -0
- package/dist/pipeline/profile-detectors/api-contracts.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/api-contracts.js +78 -0
- package/dist/pipeline/profile-detectors/api-contracts.js.map +1 -0
- package/dist/pipeline/profile-detectors/framework-detector.d.ts +11 -0
- package/dist/pipeline/profile-detectors/framework-detector.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/framework-detector.js +11 -0
- package/dist/pipeline/profile-detectors/framework-detector.js.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts +7 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.js +7 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.js.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks.d.ts +7 -0
- package/dist/pipeline/profile-detectors/frameworks.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks.js +7 -0
- package/dist/pipeline/profile-detectors/frameworks.js.map +1 -0
- package/dist/pipeline/profile-detectors/iac.d.ts +22 -0
- package/dist/pipeline/profile-detectors/iac.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/iac.js +97 -0
- package/dist/pipeline/profile-detectors/iac.js.map +1 -0
- package/dist/pipeline/profile-detectors/languages.d.ts +18 -0
- package/dist/pipeline/profile-detectors/languages.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/languages.js +60 -0
- package/dist/pipeline/profile-detectors/languages.js.map +1 -0
- package/dist/pipeline/profile-detectors/manifests.d.ts +7 -0
- package/dist/pipeline/profile-detectors/manifests.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/manifests.js +7 -0
- package/dist/pipeline/profile-detectors/manifests.js.map +1 -0
- package/dist/pipeline/profile-detectors/src-dirs.d.ts +17 -0
- package/dist/pipeline/profile-detectors/src-dirs.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/src-dirs.js +89 -0
- package/dist/pipeline/profile-detectors/src-dirs.js.map +1 -0
- package/dist/pipeline/profile-detectors/variant-detectors.d.ts +7 -0
- package/dist/pipeline/profile-detectors/variant-detectors.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/variant-detectors.js +7 -0
- package/dist/pipeline/profile-detectors/variant-detectors.js.map +1 -0
- package/dist/pipeline/runner.d.ts +54 -0
- package/dist/pipeline/runner.d.ts.map +1 -0
- package/dist/pipeline/runner.js +247 -0
- package/dist/pipeline/runner.js.map +1 -0
- package/dist/pipeline/types.d.ts +235 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +15 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/providers/c.d.ts +3 -0
- package/dist/providers/c.d.ts.map +1 -0
- package/dist/providers/c.js +162 -0
- package/dist/providers/c.js.map +1 -0
- package/dist/providers/cobol.d.ts +19 -0
- package/dist/providers/cobol.d.ts.map +1 -0
- package/dist/providers/cobol.js +44 -0
- package/dist/providers/cobol.js.map +1 -0
- package/dist/providers/cpp.d.ts +3 -0
- package/dist/providers/cpp.d.ts.map +1 -0
- package/dist/providers/cpp.js +200 -0
- package/dist/providers/cpp.js.map +1 -0
- package/dist/providers/csharp.d.ts +3 -0
- package/dist/providers/csharp.d.ts.map +1 -0
- package/dist/providers/csharp.js +292 -0
- package/dist/providers/csharp.js.map +1 -0
- package/dist/providers/dart.d.ts +3 -0
- package/dist/providers/dart.d.ts.map +1 -0
- package/dist/providers/dart.js +214 -0
- package/dist/providers/dart.js.map +1 -0
- package/dist/providers/definition-ids.d.ts +18 -0
- package/dist/providers/definition-ids.d.ts.map +1 -0
- package/dist/providers/definition-ids.js +23 -0
- package/dist/providers/definition-ids.js.map +1 -0
- package/dist/providers/extract-helpers.d.ts +60 -0
- package/dist/providers/extract-helpers.d.ts.map +1 -0
- package/dist/providers/extract-helpers.js +296 -0
- package/dist/providers/extract-helpers.js.map +1 -0
- package/dist/providers/extraction-types.d.ts +85 -0
- package/dist/providers/extraction-types.d.ts.map +1 -0
- package/dist/providers/extraction-types.js +13 -0
- package/dist/providers/extraction-types.js.map +1 -0
- package/dist/providers/go.d.ts +3 -0
- package/dist/providers/go.d.ts.map +1 -0
- package/dist/providers/go.js +359 -0
- package/dist/providers/go.js.map +1 -0
- package/dist/providers/http-detect.d.ts +44 -0
- package/dist/providers/http-detect.d.ts.map +1 -0
- package/dist/providers/http-detect.js +307 -0
- package/dist/providers/http-detect.js.map +1 -0
- package/dist/providers/index.d.ts +38 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +33 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/java.d.ts +3 -0
- package/dist/providers/java.d.ts.map +1 -0
- package/dist/providers/java.js +259 -0
- package/dist/providers/java.js.map +1 -0
- package/dist/providers/javascript.d.ts +3 -0
- package/dist/providers/javascript.d.ts.map +1 -0
- package/dist/providers/javascript.js +139 -0
- package/dist/providers/javascript.js.map +1 -0
- package/dist/providers/kotlin.d.ts +3 -0
- package/dist/providers/kotlin.d.ts.map +1 -0
- package/dist/providers/kotlin.js +175 -0
- package/dist/providers/kotlin.js.map +1 -0
- package/dist/providers/php.d.ts +3 -0
- package/dist/providers/php.d.ts.map +1 -0
- package/dist/providers/php.js +218 -0
- package/dist/providers/php.js.map +1 -0
- package/dist/providers/python-accesses.d.ts +9 -0
- package/dist/providers/python-accesses.d.ts.map +1 -0
- package/dist/providers/python-accesses.js +22 -0
- package/dist/providers/python-accesses.js.map +1 -0
- package/dist/providers/python.d.ts +3 -0
- package/dist/providers/python.d.ts.map +1 -0
- package/dist/providers/python.js +323 -0
- package/dist/providers/python.js.map +1 -0
- package/dist/providers/registry.d.ts +4 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +46 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/resolution/c3.d.ts +6 -0
- package/dist/providers/resolution/c3.d.ts.map +1 -0
- package/dist/providers/resolution/c3.js +76 -0
- package/dist/providers/resolution/c3.js.map +1 -0
- package/dist/providers/resolution/context.d.ts +38 -0
- package/dist/providers/resolution/context.d.ts.map +1 -0
- package/dist/providers/resolution/context.js +45 -0
- package/dist/providers/resolution/context.js.map +1 -0
- package/dist/providers/resolution/first-wins.d.ts +3 -0
- package/dist/providers/resolution/first-wins.d.ts.map +1 -0
- package/dist/providers/resolution/first-wins.js +27 -0
- package/dist/providers/resolution/first-wins.js.map +1 -0
- package/dist/providers/resolution/mro.d.ts +16 -0
- package/dist/providers/resolution/mro.d.ts.map +1 -0
- package/dist/providers/resolution/mro.js +14 -0
- package/dist/providers/resolution/mro.js.map +1 -0
- package/dist/providers/resolution/none.d.ts +3 -0
- package/dist/providers/resolution/none.d.ts.map +1 -0
- package/dist/providers/resolution/none.js +11 -0
- package/dist/providers/resolution/none.js.map +1 -0
- package/dist/providers/resolution/python-all-filter.d.ts +25 -0
- package/dist/providers/resolution/python-all-filter.d.ts.map +1 -0
- package/dist/providers/resolution/python-all-filter.js +64 -0
- package/dist/providers/resolution/python-all-filter.js.map +1 -0
- package/dist/providers/resolution/resolver-strategy.d.ts +42 -0
- package/dist/providers/resolution/resolver-strategy.d.ts.map +1 -0
- package/dist/providers/resolution/resolver-strategy.js +50 -0
- package/dist/providers/resolution/resolver-strategy.js.map +1 -0
- package/dist/providers/resolution/single-inheritance.d.ts +3 -0
- package/dist/providers/resolution/single-inheritance.d.ts.map +1 -0
- package/dist/providers/resolution/single-inheritance.js +21 -0
- package/dist/providers/resolution/single-inheritance.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts +16 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js +50 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/glue.d.ts +15 -0
- package/dist/providers/resolution/stack-graphs/glue.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/glue.js +44 -0
- package/dist/providers/resolution/stack-graphs/glue.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts +30 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.js +366 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts +9 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.js +152 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.d.ts +11 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.js +247 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/types.d.ts +93 -0
- package/dist/providers/resolution/stack-graphs/types.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/types.js +11 -0
- package/dist/providers/resolution/stack-graphs/types.js.map +1 -0
- package/dist/providers/resolution/stack-graphs-python.d.ts +27 -0
- package/dist/providers/resolution/stack-graphs-python.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs-python.js +104 -0
- package/dist/providers/resolution/stack-graphs-python.js.map +1 -0
- package/dist/providers/resolution/stack-graphs-ts.d.ts +134 -0
- package/dist/providers/resolution/stack-graphs-ts.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs-ts.js +372 -0
- package/dist/providers/resolution/stack-graphs-ts.js.map +1 -0
- package/dist/providers/ruby.d.ts +3 -0
- package/dist/providers/ruby.d.ts.map +1 -0
- package/dist/providers/ruby.js +259 -0
- package/dist/providers/ruby.js.map +1 -0
- package/dist/providers/rust.d.ts +3 -0
- package/dist/providers/rust.d.ts.map +1 -0
- package/dist/providers/rust.js +318 -0
- package/dist/providers/rust.js.map +1 -0
- package/dist/providers/swift.d.ts +3 -0
- package/dist/providers/swift.d.ts.map +1 -0
- package/dist/providers/swift.js +177 -0
- package/dist/providers/swift.js.map +1 -0
- package/dist/providers/test-helpers.d.ts +24 -0
- package/dist/providers/test-helpers.d.ts.map +1 -0
- package/dist/providers/test-helpers.js +33 -0
- package/dist/providers/test-helpers.js.map +1 -0
- package/dist/providers/ts-shared.d.ts +30 -0
- package/dist/providers/ts-shared.d.ts.map +1 -0
- package/dist/providers/ts-shared.js +328 -0
- package/dist/providers/ts-shared.js.map +1 -0
- package/dist/providers/tsx.d.ts +7 -0
- package/dist/providers/tsx.d.ts.map +1 -0
- package/dist/providers/tsx.js +79 -0
- package/dist/providers/tsx.js.map +1 -0
- package/dist/providers/types.d.ts +166 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +7 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/typescript-family-accesses.d.ts +14 -0
- package/dist/providers/typescript-family-accesses.d.ts.map +1 -0
- package/dist/providers/typescript-family-accesses.js +27 -0
- package/dist/providers/typescript-family-accesses.js.map +1 -0
- package/dist/providers/typescript.d.ts +9 -0
- package/dist/providers/typescript.d.ts.map +1 -0
- package/dist/providers/typescript.js +84 -0
- package/dist/providers/typescript.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Rule-file parser for the vendored .tsg Python ruleset.
|
|
2
|
+
//
|
|
3
|
+
// The .tsg DSL is a mix of tree-sitter S-expression queries and a
|
|
4
|
+
// small imperative language for declaring nodes, edges, and attributes.
|
|
5
|
+
// We parse only the surface structure we need:
|
|
6
|
+
// * top-level rule blocks: `(pattern) @capture { actions }`
|
|
7
|
+
// * global declarations: `global NAME`, `global NAME = value` (recorded but
|
|
8
|
+
// otherwise ignored — the builder hardcodes Python's needs)
|
|
9
|
+
// * attribute shorthands: `attribute name = ...` (stored raw; the builder
|
|
10
|
+
// references them by name, not by macroexpansion)
|
|
11
|
+
// * actions inside blocks are shallowly tokenised into `node-decl`,
|
|
12
|
+
// `edge-decl`, `attr-decl`, or `unknown` so callers can surface stats.
|
|
13
|
+
//
|
|
14
|
+
// This is deliberately permissive — constructs we don't understand are
|
|
15
|
+
// recorded as `unknown` rather than rejected. The Python evaluator uses
|
|
16
|
+
// the rule file primarily as a licence-scoped manifest: our actual path
|
|
17
|
+
// construction lives in node-edge-builder.ts and is driven by the
|
|
18
|
+
// tree-sitter parse rather than a generic DSL interpreter.
|
|
19
|
+
/** Strip `;;`-prefixed comments from a line. */
|
|
20
|
+
function stripLineComment(line) {
|
|
21
|
+
const idx = line.indexOf(";;");
|
|
22
|
+
if (idx < 0)
|
|
23
|
+
return line;
|
|
24
|
+
return line.slice(0, idx);
|
|
25
|
+
}
|
|
26
|
+
/** Scan the opening pattern — everything inside a balanced `(...)` pair. */
|
|
27
|
+
function readBalanced(source, start, open, close) {
|
|
28
|
+
if (source[start] !== open)
|
|
29
|
+
return null;
|
|
30
|
+
let depth = 0;
|
|
31
|
+
let inString = false;
|
|
32
|
+
for (let i = start; i < source.length; i++) {
|
|
33
|
+
const ch = source[i];
|
|
34
|
+
if (ch === '"' && source[i - 1] !== "\\") {
|
|
35
|
+
inString = !inString;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (inString)
|
|
39
|
+
continue;
|
|
40
|
+
if (ch === open)
|
|
41
|
+
depth++;
|
|
42
|
+
else if (ch === close) {
|
|
43
|
+
depth--;
|
|
44
|
+
if (depth === 0) {
|
|
45
|
+
return { body: source.slice(start + 1, i), end: i };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/** Extract rough tree-sitter pattern info from a parenthesised pattern body. */
|
|
52
|
+
function parsePattern(body) {
|
|
53
|
+
// The S-expression head token names the node type. Any `@capture` after
|
|
54
|
+
// the closing paren is attached outside by the caller; here we only peek
|
|
55
|
+
// at the very first identifier so callers can group rules by target type.
|
|
56
|
+
const m = /^\s*([A-Za-z_][\w]*)/.exec(body);
|
|
57
|
+
const nodeType = m?.[1] ?? "unknown";
|
|
58
|
+
return { kind: "pattern", nodeType };
|
|
59
|
+
}
|
|
60
|
+
/** Classify an action line into one of our coarse buckets. */
|
|
61
|
+
function classifyAction(raw) {
|
|
62
|
+
const trimmed = raw.trim();
|
|
63
|
+
if (trimmed.startsWith("node "))
|
|
64
|
+
return "node-decl";
|
|
65
|
+
if (trimmed.startsWith("edge "))
|
|
66
|
+
return "edge-decl";
|
|
67
|
+
if (trimmed.startsWith("attr ") || trimmed.startsWith("attribute "))
|
|
68
|
+
return "attr-decl";
|
|
69
|
+
return "unknown";
|
|
70
|
+
}
|
|
71
|
+
/** Split an action body into individual statements at top-level newlines. */
|
|
72
|
+
function splitActions(body) {
|
|
73
|
+
// We respect braces — an action like `scan x { ... }` is one statement even
|
|
74
|
+
// though it spans multiple lines. This keeps the `unknown` bucket from
|
|
75
|
+
// exploding.
|
|
76
|
+
const out = [];
|
|
77
|
+
let buf = "";
|
|
78
|
+
let braceDepth = 0;
|
|
79
|
+
let parenDepth = 0;
|
|
80
|
+
let inString = false;
|
|
81
|
+
for (let i = 0; i < body.length; i++) {
|
|
82
|
+
const ch = body[i];
|
|
83
|
+
if (ch === '"' && body[i - 1] !== "\\")
|
|
84
|
+
inString = !inString;
|
|
85
|
+
if (!inString) {
|
|
86
|
+
if (ch === "{")
|
|
87
|
+
braceDepth++;
|
|
88
|
+
else if (ch === "}")
|
|
89
|
+
braceDepth--;
|
|
90
|
+
else if (ch === "(")
|
|
91
|
+
parenDepth++;
|
|
92
|
+
else if (ch === ")")
|
|
93
|
+
parenDepth--;
|
|
94
|
+
}
|
|
95
|
+
buf += ch;
|
|
96
|
+
if (!inString && braceDepth === 0 && parenDepth === 0 && (ch === "\n" || ch === ";")) {
|
|
97
|
+
const cleaned = stripLineComment(buf).trim();
|
|
98
|
+
if (cleaned.length > 0)
|
|
99
|
+
out.push(cleaned);
|
|
100
|
+
buf = "";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const tail = stripLineComment(buf).trim();
|
|
104
|
+
if (tail.length > 0)
|
|
105
|
+
out.push(tail);
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
/** Parse a .tsg source string into a set of rules plus ancillary decls. */
|
|
109
|
+
export function parseTsg(source) {
|
|
110
|
+
const rules = [];
|
|
111
|
+
const globals = [];
|
|
112
|
+
const attributeShorthands = [];
|
|
113
|
+
const warnings = [];
|
|
114
|
+
let i = 0;
|
|
115
|
+
const n = source.length;
|
|
116
|
+
const skipSpaceAndComments = () => {
|
|
117
|
+
while (i < n) {
|
|
118
|
+
const ch = source[i];
|
|
119
|
+
if (ch === undefined)
|
|
120
|
+
break;
|
|
121
|
+
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
|
|
122
|
+
i++;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (ch === ";" && source[i + 1] === ";") {
|
|
126
|
+
while (i < n && source[i] !== "\n")
|
|
127
|
+
i++;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
while (i < n) {
|
|
134
|
+
skipSpaceAndComments();
|
|
135
|
+
if (i >= n)
|
|
136
|
+
break;
|
|
137
|
+
// Top-level keywords we track explicitly.
|
|
138
|
+
if (source.startsWith("global", i)) {
|
|
139
|
+
const end = source.indexOf("\n", i);
|
|
140
|
+
const line = source.slice(i, end < 0 ? n : end).trim();
|
|
141
|
+
globals.push(line);
|
|
142
|
+
i = end < 0 ? n : end;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (source.startsWith("attribute", i)) {
|
|
146
|
+
const end = source.indexOf("\n", i);
|
|
147
|
+
const line = source.slice(i, end < 0 ? n : end).trim();
|
|
148
|
+
attributeShorthands.push(line);
|
|
149
|
+
i = end < 0 ? n : end;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (source.startsWith("inherit", i)) {
|
|
153
|
+
const end = source.indexOf("\n", i);
|
|
154
|
+
i = end < 0 ? n : end;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
// A rule block must start with `(` or `[`.
|
|
158
|
+
const ch = source[i];
|
|
159
|
+
if (ch !== "(" && ch !== "[") {
|
|
160
|
+
// Skip unrecognised tokens to the next newline.
|
|
161
|
+
const end = source.indexOf("\n", i);
|
|
162
|
+
if (end < 0)
|
|
163
|
+
break;
|
|
164
|
+
i = end + 1;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const patterns = [];
|
|
168
|
+
if (ch === "[") {
|
|
169
|
+
// Multi-pattern rule: `[ pat1 pat2 ... ] @capture { ... }`
|
|
170
|
+
const block = readBalanced(source, i, "[", "]");
|
|
171
|
+
if (block === null) {
|
|
172
|
+
warnings.push(`unterminated '[' at offset ${i}`);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
// Walk the bracket body picking out each top-level `(...)` pattern.
|
|
176
|
+
let j = 0;
|
|
177
|
+
while (j < block.body.length) {
|
|
178
|
+
const c = block.body[j];
|
|
179
|
+
if (c === undefined)
|
|
180
|
+
break;
|
|
181
|
+
if (c === " " || c === "\n" || c === "\t" || c === "\r") {
|
|
182
|
+
j++;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (c === ";" && block.body[j + 1] === ";") {
|
|
186
|
+
while (j < block.body.length && block.body[j] !== "\n")
|
|
187
|
+
j++;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (c === "(") {
|
|
191
|
+
const inner = readBalanced(block.body, j, "(", ")");
|
|
192
|
+
if (inner === null)
|
|
193
|
+
break;
|
|
194
|
+
patterns.push(parsePattern(inner.body));
|
|
195
|
+
j = inner.end + 1;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
j++;
|
|
199
|
+
}
|
|
200
|
+
i = block.end + 1;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const pat = readBalanced(source, i, "(", ")");
|
|
204
|
+
if (pat === null) {
|
|
205
|
+
warnings.push(`unterminated '(' at offset ${i}`);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
patterns.push(parsePattern(pat.body));
|
|
209
|
+
i = pat.end + 1;
|
|
210
|
+
}
|
|
211
|
+
// Skip to the action block `{ ... }` — the `@capture` name, if any, lives
|
|
212
|
+
// between the pattern and the brace; we don't need to retain it.
|
|
213
|
+
while (i < n && source[i] !== "{") {
|
|
214
|
+
if (source[i] === "\n" || source[i] === " " || source[i] === "\t" || source[i] === "@") {
|
|
215
|
+
i++;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (source[i] === "(") {
|
|
219
|
+
const pred = readBalanced(source, i, "(", ")");
|
|
220
|
+
if (pred === null)
|
|
221
|
+
break;
|
|
222
|
+
i = pred.end + 1;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
// Unknown chars before the block — drift forward rather than abort.
|
|
226
|
+
i++;
|
|
227
|
+
}
|
|
228
|
+
if (source[i] !== "{") {
|
|
229
|
+
warnings.push(`missing action block after pattern at offset ${i}`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const action = readBalanced(source, i, "{", "}");
|
|
233
|
+
if (action === null) {
|
|
234
|
+
warnings.push(`unterminated action block at offset ${i}`);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
const statements = splitActions(action.body);
|
|
238
|
+
const actions = statements.map((s) => ({
|
|
239
|
+
kind: classifyAction(s),
|
|
240
|
+
raw: s,
|
|
241
|
+
}));
|
|
242
|
+
rules.push({ patterns, actions });
|
|
243
|
+
i = action.end + 1;
|
|
244
|
+
}
|
|
245
|
+
return { rules, globals, attributeShorthands, warnings };
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=rule-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-parser.js","sourceRoot":"","sources":["../../../../src/providers/resolution/stack-graphs/rule-parser.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,kEAAkE;AAClE,wEAAwE;AACxE,+CAA+C;AAC/C,8DAA8D;AAC9D,8EAA8E;AAC9E,gEAAgE;AAChE,4EAA4E;AAC5E,sDAAsD;AACtD,sEAAsE;AACtE,2EAA2E;AAC3E,EAAE;AACF,uEAAuE;AACvE,wEAAwE;AACxE,wEAAwE;AACxE,kEAAkE;A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AC,IAAI,CAAC,uCAAuC,CAAC,EAAE,CAAC,CAAC;YAC1D,MAAM;QACR,CAAC;QACD,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAgB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClD,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;YACvB,GAAG,EAAE,CAAC;SACP,CAAC,CAAC,CAAC;QACJ,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAClC,CAAC,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node roles in our simplified stack-graph. Each maps to one primitive
|
|
3
|
+
* attribute family in the broader stack-graphs model, but we collapse
|
|
4
|
+
* push-scoped / pop-scoped into `push`/`pop` here because Python's
|
|
5
|
+
* reference model doesn't require the scope-stack machinery for the
|
|
6
|
+
* re-export cases we actually resolve.
|
|
7
|
+
*/
|
|
8
|
+
export type StackNodeKind = "push" | "pop" | "scope" | "root";
|
|
9
|
+
/** Opaque node identifier. Format: `${file}#${seq}` where seq is per-file. */
|
|
10
|
+
export type NodeId = string;
|
|
11
|
+
/**
|
|
12
|
+
* One node in our stack graph. `symbol` is populated for push/pop kinds and
|
|
13
|
+
* carries the Python identifier the node pushes or pops. `definitionTarget`
|
|
14
|
+
* is set on pop nodes that correspond to concrete definitions (e.g. the
|
|
15
|
+
* function / class the resolver should land on).
|
|
16
|
+
*/
|
|
17
|
+
export interface StackGraphNode {
|
|
18
|
+
readonly id: NodeId;
|
|
19
|
+
readonly kind: StackNodeKind;
|
|
20
|
+
readonly symbol?: string;
|
|
21
|
+
readonly definitionTarget?: string;
|
|
22
|
+
/** Source file that created this node — useful for cross-file debugging. */
|
|
23
|
+
readonly file: string;
|
|
24
|
+
/** Optional line number in the source file (1-indexed). */
|
|
25
|
+
readonly line?: number;
|
|
26
|
+
}
|
|
27
|
+
/** A directed edge with optional precedence (higher wins at enumeration time). */
|
|
28
|
+
export interface StackGraphEdge {
|
|
29
|
+
readonly source: NodeId;
|
|
30
|
+
readonly target: NodeId;
|
|
31
|
+
readonly precedence: number;
|
|
32
|
+
}
|
|
33
|
+
/** Per-file stack graph plus the well-known root-node id. */
|
|
34
|
+
export interface StackGraph {
|
|
35
|
+
readonly file: string;
|
|
36
|
+
readonly nodes: ReadonlyMap<NodeId, StackGraphNode>;
|
|
37
|
+
readonly edges: readonly StackGraphEdge[];
|
|
38
|
+
/** Id of the module's per-file root — references escape to here. */
|
|
39
|
+
readonly rootNodeId: NodeId;
|
|
40
|
+
/** Ids of reference-push nodes, keyed by (line, column) for lookup. */
|
|
41
|
+
readonly referenceIndex: ReadonlyMap<string, NodeId>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Query input: resolve the reference at this position in this file.
|
|
45
|
+
* The evaluator looks up the starting push-node via `referenceIndex`.
|
|
46
|
+
*/
|
|
47
|
+
export interface ReferenceQuery {
|
|
48
|
+
readonly file: string;
|
|
49
|
+
readonly line: number;
|
|
50
|
+
readonly column: number;
|
|
51
|
+
readonly name: string;
|
|
52
|
+
}
|
|
53
|
+
/** A successful path resolution. */
|
|
54
|
+
export interface ResolvedDefinition {
|
|
55
|
+
readonly targetNodeId: NodeId;
|
|
56
|
+
/** Where the definition actually lives — typically `${file}:${line}:${name}`. */
|
|
57
|
+
readonly targetKey: string;
|
|
58
|
+
/** Length of the path in edges; shorter paths score higher. */
|
|
59
|
+
readonly pathLength: number;
|
|
60
|
+
}
|
|
61
|
+
/** Confidence assigned when stack-graphs produces a hit. */
|
|
62
|
+
export declare const STACK_GRAPHS_HIT_CONFIDENCE = 0.9;
|
|
63
|
+
/** Budget — never enumerate a path longer than this. */
|
|
64
|
+
export declare const MAX_PARTIAL_PATH_DEPTH = 100;
|
|
65
|
+
/**
|
|
66
|
+
* Rule-file AST — consumed by the node/edge builder. We intentionally keep
|
|
67
|
+
* only the shapes our Python evaluator consults; other rule kinds
|
|
68
|
+
* (let/set/var/scan) are parsed into an opaque `raw` form and ignored by
|
|
69
|
+
* the builder.
|
|
70
|
+
*/
|
|
71
|
+
export type TsgMatch = {
|
|
72
|
+
readonly kind: "pattern";
|
|
73
|
+
/** Tree-sitter node type name the rule fires on (e.g. `module`). */
|
|
74
|
+
readonly nodeType: string;
|
|
75
|
+
/** Tree-sitter capture name attached to the match (e.g. `@mod`). */
|
|
76
|
+
readonly capture?: string;
|
|
77
|
+
};
|
|
78
|
+
export type TsgActionKind = "node-decl" | "edge-decl" | "attr-decl" | "unknown";
|
|
79
|
+
export interface TsgAction {
|
|
80
|
+
readonly kind: TsgActionKind;
|
|
81
|
+
/** Raw action source text (debug only). */
|
|
82
|
+
readonly raw: string;
|
|
83
|
+
}
|
|
84
|
+
export interface TsgRule {
|
|
85
|
+
readonly patterns: readonly TsgMatch[];
|
|
86
|
+
readonly actions: readonly TsgAction[];
|
|
87
|
+
}
|
|
88
|
+
/** Result returned from `resolveReference`. */
|
|
89
|
+
export interface PartialPathResult {
|
|
90
|
+
readonly results: readonly ResolvedDefinition[];
|
|
91
|
+
readonly truncated: boolean;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/providers/resolution/stack-graphs/types.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,KAAK,GACL,OAAO,GACP,MAAM,CAAC;AAEX,8EAA8E;AAC9E,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,W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C3B,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,4DAA4D;AAC5D,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,wDAAwD;AACxD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;AAEhF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;CACxC;AAED,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Shared types for the clean-room stack-graphs evaluator.
|
|
2
|
+
//
|
|
3
|
+
// This module is a minimal, Python-scoped subset of the stack-graphs model.
|
|
4
|
+
// Our types are intentionally narrow. All names and semantics were chosen
|
|
5
|
+
// independently from any prior implementation — we model only what our
|
|
6
|
+
// Python rules need.
|
|
7
|
+
/** Confidence assigned when stack-graphs produces a hit. */
|
|
8
|
+
export const STACK_GRAPHS_HIT_CONFIDENCE = 0.9;
|
|
9
|
+
/** Budget — never enumerate a path longer than this. */
|
|
10
|
+
export const MAX_PARTIAL_PATH_DEPTH = 100;
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/providers/resolution/stack-graphs/types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,uEAAuE;AACvE,qBAAqB;AAyErB,4DAA4D;AAC5D,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,wDAAwD;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ResolutionQuery } from "./context.js";
|
|
2
|
+
import type { ResolverStrategy } from "./resolver-strategy.js";
|
|
3
|
+
import type { StackGraph } from "./stack-graphs/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Per-reference lookup info the ingestion pipeline attaches to the query
|
|
6
|
+
* when delegating to stack-graphs. The default three-tier `ResolutionQuery`
|
|
7
|
+
* lacks line/column, so strategies that want them advertise a sibling
|
|
8
|
+
* interface and the pipeline downcasts when invoking stack-graphs.
|
|
9
|
+
*/
|
|
10
|
+
export interface StackGraphsHintedQuery extends ResolutionQuery {
|
|
11
|
+
readonly referenceLine?: number;
|
|
12
|
+
readonly referenceColumn?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Prime the cache with per-file stack graphs. Called by the ingestion parse
|
|
16
|
+
* phase before resolution runs.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerStackGraphs(graphs: ReadonlyMap<string, StackGraph>): void;
|
|
19
|
+
/** For tests: drop all graphs. */
|
|
20
|
+
export declare function clearStackGraphsForTests(): void;
|
|
21
|
+
/** Stats surfaced to the pipeline for telemetry. */
|
|
22
|
+
export declare function getStackGraphsStats(): {
|
|
23
|
+
readonly fallbacks: number;
|
|
24
|
+
readonly hits: number;
|
|
25
|
+
};
|
|
26
|
+
export declare const stackGraphsPythonResolver: ResolverStrategy;
|
|
27
|
+
//# sourceMappingURL=stack-graphs-python.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-graphs-python.d.ts","sourceRoot":"","sources":["../../../src/providers/resolution/stack-graphs-python.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAuB,eAAe,EAAe,MAAM,cAAc,CAAC;AAEtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1E;;;;;GAKG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAcD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI,CAGjF;AAED,kCAAkC;AAClC,wBAAgB,wBAAwB,IAAI,IAAI,CAI/C;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,IAAI;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAE3F;AAyCD,eAAO,MAAM,yBAAyB,EAAE,gBAuBvC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Python-specific ResolverStrategy backed by the clean-room stack-graphs
|
|
2
|
+
// evaluator. Uses the three-tier walker as a fallback whenever stack-graphs
|
|
3
|
+
// can't produce an answer — missing rule file, empty graph cache, parse
|
|
4
|
+
// errors, traversal timeout — so a Python ingest never regresses versus the
|
|
5
|
+
// default resolver.
|
|
6
|
+
//
|
|
7
|
+
// The strategy is registered in resolver-strategy.ts under the key
|
|
8
|
+
// "stack-graphs"; the python provider opts in via `resolverStrategyName`.
|
|
9
|
+
//
|
|
10
|
+
// Cross-module graph wiring is provided by the caller via `registerStackGraphs`
|
|
11
|
+
// — the ingestion pipeline prepares one `StackGraph` per Python file during
|
|
12
|
+
// parse and primes the cache before resolution begins. Tests drive this same
|
|
13
|
+
// API with in-memory fixtures.
|
|
14
|
+
import { CONFIDENCE_BY_TIER, resolve as threeTierResolve } from "./context.js";
|
|
15
|
+
import { resolveViaStackGraphs } from "./stack-graphs/glue.js";
|
|
16
|
+
import { STACK_GRAPHS_HIT_CONFIDENCE } from "./stack-graphs/types.js";
|
|
17
|
+
const STORE = {
|
|
18
|
+
graphs: new Map(),
|
|
19
|
+
fallbacks: 0,
|
|
20
|
+
stackGraphHits: 0,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Prime the cache with per-file stack graphs. Called by the ingestion parse
|
|
24
|
+
* phase before resolution runs.
|
|
25
|
+
*/
|
|
26
|
+
export function registerStackGraphs(graphs) {
|
|
27
|
+
STORE.graphs.clear();
|
|
28
|
+
for (const [k, v] of graphs)
|
|
29
|
+
STORE.graphs.set(k, v);
|
|
30
|
+
}
|
|
31
|
+
/** For tests: drop all graphs. */
|
|
32
|
+
export function clearStackGraphsForTests() {
|
|
33
|
+
STORE.graphs.clear();
|
|
34
|
+
STORE.fallbacks = 0;
|
|
35
|
+
STORE.stackGraphHits = 0;
|
|
36
|
+
}
|
|
37
|
+
/** Stats surfaced to the pipeline for telemetry. */
|
|
38
|
+
export function getStackGraphsStats() {
|
|
39
|
+
return { fallbacks: STORE.fallbacks, hits: STORE.stackGraphHits };
|
|
40
|
+
}
|
|
41
|
+
/** Is this provider Python? Strategy no-ops on non-Python inputs. */
|
|
42
|
+
function isPythonQuery(q) {
|
|
43
|
+
return q.provider.id === "python";
|
|
44
|
+
}
|
|
45
|
+
function mapTargetKeyToResolutionId(targetKey) {
|
|
46
|
+
// targetKey is `${file}:${line}:${qualifiedName}`. We emit this as the
|
|
47
|
+
// resolver's `targetId`. The storage layer treats opaque ids, so any
|
|
48
|
+
// shape that's unique works. Using `:` as the separator mirrors the
|
|
49
|
+
// qualified-name convention elsewhere in the ingestion pipeline.
|
|
50
|
+
return targetKey;
|
|
51
|
+
}
|
|
52
|
+
function runStackGraphs(q) {
|
|
53
|
+
if (STORE.graphs.size === 0)
|
|
54
|
+
return null;
|
|
55
|
+
const line = q.referenceLine;
|
|
56
|
+
const column = q.referenceColumn;
|
|
57
|
+
if (line === undefined || column === undefined)
|
|
58
|
+
return null;
|
|
59
|
+
const ref = {
|
|
60
|
+
file: q.callerFile,
|
|
61
|
+
line,
|
|
62
|
+
column,
|
|
63
|
+
name: q.calleeName,
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
const { results } = resolveViaStackGraphs(ref, STORE.graphs);
|
|
67
|
+
const best = results[0];
|
|
68
|
+
if (best === undefined)
|
|
69
|
+
return null;
|
|
70
|
+
return {
|
|
71
|
+
targetId: mapTargetKeyToResolutionId(best.targetKey),
|
|
72
|
+
tier: "import-scoped",
|
|
73
|
+
confidence: STACK_GRAPHS_HIT_CONFIDENCE,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export const stackGraphsPythonResolver = {
|
|
81
|
+
name: "stack-graphs",
|
|
82
|
+
resolve(q, index) {
|
|
83
|
+
if (!isPythonQuery(q)) {
|
|
84
|
+
return threeTierResolve(q, index);
|
|
85
|
+
}
|
|
86
|
+
const hinted = q;
|
|
87
|
+
const hit = runStackGraphs(hinted);
|
|
88
|
+
if (hit !== null) {
|
|
89
|
+
STORE.stackGraphHits++;
|
|
90
|
+
// Stack-graphs resolutions always outrank the three-tier import-scoped
|
|
91
|
+
// confidence — we emit the fixed STACK_GRAPHS_HIT_CONFIDENCE score and
|
|
92
|
+
// leave re-ranking to the caller.
|
|
93
|
+
const clamped = {
|
|
94
|
+
targetId: hit.targetId,
|
|
95
|
+
tier: hit.tier,
|
|
96
|
+
confidence: Math.max(hit.confidence, CONFIDENCE_BY_TIER["import-scoped"]),
|
|
97
|
+
};
|
|
98
|
+
return [clamped];
|
|
99
|
+
}
|
|
100
|
+
STORE.fallbacks++;
|
|
101
|
+
return threeTierResolve(q, index);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=stack-graphs-python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-graphs-python.js","sourceRoot":"","sources":["../../../src/providers/resolution/stack-graphs-python.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AACxE,4EAA4E;AAC5E,oBAAoB;AACpB,EAAE;AACF,mEAAmE;AACnE,0EAA0E;AAC1E,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,6EAA6E;AAC7E,+BAA+B;AAG/B,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAmBtE,MAAM,KAAK,GAAoB;IAC7B,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,SAAS,EAAE,CAAC;IACZ,cAAc,EAAE,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAuC;IACzE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM;QAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,wBAAwB;IACtC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,KAA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AA2B;SACxC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IACzD,IAAI,EAAE,cAAc;IACpB,OAAO,CAAC,CAAkB,EAAE,KAAkB;QAC5C,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;YACtB,OAAO,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,MAAM,GAAG,CAA2B,CAAC;QAC3C,MAAM,GAAG,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,uEAAuE;YACvE,uEAAuE;YACvE,kCAAkC;YAClC,MAAM,OAAO,GAAwB;gBACnC,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;aAC1E,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,SAAS,EAAE,CAAC;QAClB,OAAO,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ResolutionQuery } from "./context.js";
|
|
2
|
+
import type { ResolverStrategy } from "./resolver-strategy.js";
|
|
3
|
+
import type { StackGraph } from "./stack-graphs/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Per-reference lookup info — the ingestion pipeline attaches (line, column)
|
|
6
|
+
* to the query when delegating to stack-graphs. Mirrors the Python hinted
|
|
7
|
+
* query type.
|
|
8
|
+
*/
|
|
9
|
+
export interface TsStackGraphsHintedQuery extends ResolutionQuery {
|
|
10
|
+
readonly referenceLine?: number;
|
|
11
|
+
readonly referenceColumn?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Prime the TS cache with per-file stack graphs. Called by the ingestion
|
|
15
|
+
* parse phase before resolution runs. Uses a store separate from Python's.
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerTsStackGraphs(graphs: ReadonlyMap<string, StackGraph>): void;
|
|
18
|
+
/** For tests: drop all TS graphs and reset counters. */
|
|
19
|
+
export declare function clearTsStackGraphsForTests(): void;
|
|
20
|
+
/** Stats surfaced to the pipeline for telemetry. */
|
|
21
|
+
export declare function getTsStackGraphsStats(): {
|
|
22
|
+
readonly fallbacks: number;
|
|
23
|
+
readonly hits: number;
|
|
24
|
+
};
|
|
25
|
+
export declare const stackGraphsTsResolver: ResolverStrategy;
|
|
26
|
+
/**
|
|
27
|
+
* Minimal import/export IR. The pipeline's parse phase produces this shape
|
|
28
|
+
* from the TS tree-sitter CST; tests can also hand-author it. Keeping the
|
|
29
|
+
* builder driven by a plain IR (rather than a tree-sitter node adapter)
|
|
30
|
+
* means we don't need to fake the full SyntaxNode surface for every test
|
|
31
|
+
* fixture — unlike the Python builder which consumes `MinimalTsNode`.
|
|
32
|
+
*/
|
|
33
|
+
export type TsImportSpec = {
|
|
34
|
+
readonly kind: "named";
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly local: string;
|
|
37
|
+
readonly module: string;
|
|
38
|
+
readonly typeOnly?: boolean;
|
|
39
|
+
readonly line: number;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "default";
|
|
42
|
+
readonly local: string;
|
|
43
|
+
readonly module: string;
|
|
44
|
+
readonly typeOnly?: boolean;
|
|
45
|
+
readonly line: number;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "namespace";
|
|
48
|
+
readonly local: string;
|
|
49
|
+
readonly module: string;
|
|
50
|
+
readonly typeOnly?: boolean;
|
|
51
|
+
readonly line: number;
|
|
52
|
+
};
|
|
53
|
+
export type TsExportSpec = {
|
|
54
|
+
readonly kind: "named-local";
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly line: number;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "default-local";
|
|
59
|
+
readonly target: string;
|
|
60
|
+
readonly line: number;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: "named-reexport";
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly imported: string;
|
|
65
|
+
readonly module: string;
|
|
66
|
+
readonly line: number;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "default-reexport-as";
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly module: string;
|
|
71
|
+
readonly line: number;
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: "star-reexport";
|
|
74
|
+
readonly module: string;
|
|
75
|
+
readonly line: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* A reference site inside the module — typically an identifier the call
|
|
79
|
+
* extractor already located. The builder emits one push-node per reference
|
|
80
|
+
* so the resolver can look up (line, column).
|
|
81
|
+
*/
|
|
82
|
+
export interface TsReferenceSite {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly line: number;
|
|
85
|
+
readonly column: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* All the per-file facts the builder needs. `moduleKey` is the canonical
|
|
89
|
+
* identifier used both as the `graphs` map key and as the resolution target
|
|
90
|
+
* for cross-file ROOT hops. Typically the absolute file path without the
|
|
91
|
+
* extension; callers decide the shape as long as it's consistent with
|
|
92
|
+
* `resolveModule`.
|
|
93
|
+
*/
|
|
94
|
+
export interface TsModuleFacts {
|
|
95
|
+
readonly file: string;
|
|
96
|
+
readonly moduleKey: string;
|
|
97
|
+
readonly imports: readonly TsImportSpec[];
|
|
98
|
+
readonly exports: readonly TsExportSpec[];
|
|
99
|
+
readonly localDefinitions: readonly {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly line: number;
|
|
102
|
+
}[];
|
|
103
|
+
readonly references: readonly TsReferenceSite[];
|
|
104
|
+
/**
|
|
105
|
+
* Resolve an import specifier (e.g. `"./bar"`) to a `moduleKey` string
|
|
106
|
+
* matching another `TsModuleFacts.moduleKey`. Returning `null` means the
|
|
107
|
+
* import target is unknown — the builder will still emit the push-chain
|
|
108
|
+
* but cross-file traversal won't hop.
|
|
109
|
+
*/
|
|
110
|
+
resolveModule(specifier: string): string | null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Build a stack graph for a single TS-family module from an import/export
|
|
114
|
+
* IR. The graph shape:
|
|
115
|
+
*
|
|
116
|
+
* * module-scope is a `scope` node. ROOT points at it (so external
|
|
117
|
+
* lookups hitting this module begin there).
|
|
118
|
+
* * Local definitions are `pop` nodes hanging off module-scope, precedence 2.
|
|
119
|
+
* * Named imports create a local `pop` for the binding plus a push chain
|
|
120
|
+
* `[binding-name, moduleKey]` terminating at ROOT.
|
|
121
|
+
* * Default imports are identical to named imports with `imported = "default"`.
|
|
122
|
+
* * Namespace imports create a `pop` at the local name whose continuation
|
|
123
|
+
* chains straight to ROOT of the target module (the member push is
|
|
124
|
+
* generated at the reference site — see `references`).
|
|
125
|
+
* * Star re-exports emit a precedence-1 scope edge mirroring Python's
|
|
126
|
+
* wildcard handling.
|
|
127
|
+
* * Named re-exports create a local `pop` whose target is the remote
|
|
128
|
+
* module's export with the same (or renamed-from) name.
|
|
129
|
+
* * Default re-exports (`export { default as foo }`) create a local pop
|
|
130
|
+
* "foo" targeting the remote default slot.
|
|
131
|
+
* * Default exports create a local pop "default" pointing at the target.
|
|
132
|
+
*/
|
|
133
|
+
export declare function buildTsStackGraph(facts: TsModuleFacts): StackGraph;
|
|
134
|
+
//# sourceMappingURL=stack-graphs-ts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-graphs-ts.d.ts","sourceRoot":"","sources":["../../../src/providers/resolution/stack-graphs-ts.ts"],"names":[],"mappings":"AAuBA,OAAO,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