@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,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-addressed parse cache.
|
|
3
|
+
*
|
|
4
|
+
* Per-file JSON sidecar under `<repo>/.codehub/parse-cache/`, keyed on
|
|
5
|
+
* `sha256(content) + grammarSha + pipelineVersion`. Grammar and pipeline
|
|
6
|
+
* version changes invalidate cleanly because they participate in the cache
|
|
7
|
+
* filename — readers that look up the fresh key just miss on old entries.
|
|
8
|
+
*
|
|
9
|
+
* Layout:
|
|
10
|
+
*
|
|
11
|
+
* .codehub/parse-cache/<contentSha[0..2]>/<contentSha>-<grammarSha[0..6]>-<pipelineVersion>.json
|
|
12
|
+
*
|
|
13
|
+
* The 2-char shard prefix keeps each directory under ~2k entries at 100k
|
|
14
|
+
* file scale, which most filesystems handle well. Short grammarSha + full
|
|
15
|
+
* pipelineVersion in the filename keep the disk layout human-inspectable
|
|
16
|
+
* (you can `rm -rf .codehub/parse-cache/` at any time without corruption —
|
|
17
|
+
* the cache is purely a latency optimization, never source of truth).
|
|
18
|
+
*
|
|
19
|
+
* This module is a **utility**, not a pipeline phase:
|
|
20
|
+
* - Scan writes `grammarSha` onto each `ScannedFile`.
|
|
21
|
+
* - `parse.ts` consumes the utility: lookup → replay → fill. Hits bypass
|
|
22
|
+
* the worker pool entirely; misses go through the worker pool and then
|
|
23
|
+
* serialize their {@link CachedExtractions} back to disk for next time.
|
|
24
|
+
*
|
|
25
|
+
* Atomic writes go through `write-file-atomic` (reused helper pattern from
|
|
26
|
+
* `packages/cli/src/fs-atomic.ts`): temp file + fsync + rename. Reads
|
|
27
|
+
* tolerate missing or malformed files by returning `null` — a cache miss
|
|
28
|
+
* is normal behavior, never an error.
|
|
29
|
+
*/
|
|
30
|
+
import { promises as fs } from "node:fs";
|
|
31
|
+
import path from "node:path";
|
|
32
|
+
import { default as wfa } from "write-file-atomic";
|
|
33
|
+
/** Current cache envelope schema. Bump in lockstep with breaking changes. */
|
|
34
|
+
export const CACHE_VERSION = 2;
|
|
35
|
+
/** Shard prefix length; 2 chars → 256 buckets, each <~400 entries at 100k. */
|
|
36
|
+
const SHARD_PREFIX_LEN = 2;
|
|
37
|
+
/** Grammar SHA bytes embedded in the filename (first 6 hex chars). */
|
|
38
|
+
const GRAMMAR_SHA_IN_FILENAME_LEN = 6;
|
|
39
|
+
/**
|
|
40
|
+
* Build a cache key from its three components. Pure; performs no IO.
|
|
41
|
+
* Inputs must already be content-addressed (sha256 hex) or semver strings —
|
|
42
|
+
* no normalization is applied here.
|
|
43
|
+
*/
|
|
44
|
+
export function deriveCacheKey(contentSha, grammarSha, pipelineVersion) {
|
|
45
|
+
return { contentSha, grammarSha, pipelineVersion };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the on-disk path for a cache key under `cacheDir`.
|
|
49
|
+
*
|
|
50
|
+
* Layout:
|
|
51
|
+
* `<cacheDir>/<contentSha[0..2]>/<contentSha>-<grammarSha[0..6]>-<pipelineVersion>.json`
|
|
52
|
+
*
|
|
53
|
+
* The grammarSha/pipelineVersion suffix ensures two simultaneous entries
|
|
54
|
+
* for the same content (e.g. before/after a grammar bump) cannot clobber
|
|
55
|
+
* each other — older entries simply become unreachable and are reclaimed
|
|
56
|
+
* by the LRU sweep in {@link evictIfOverCap}, which runs after every
|
|
57
|
+
* `writeCacheEntry` when `CODEHUB_PARSE_CACHE_MAX_BYTES` (default `1GiB`)
|
|
58
|
+
* is non-zero.
|
|
59
|
+
*/
|
|
60
|
+
export function cacheFilePath(cacheDir, key) {
|
|
61
|
+
const shard = key.contentSha.slice(0, SHARD_PREFIX_LEN);
|
|
62
|
+
const shortGrammar = key.grammarSha.slice(0, GRAMMAR_SHA_IN_FILENAME_LEN);
|
|
63
|
+
const filename = `${key.contentSha}-${shortGrammar}-${key.pipelineVersion}.json`;
|
|
64
|
+
return path.join(cacheDir, shard, filename);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Read a cache entry. Returns `null` on any failure (missing file, read
|
|
68
|
+
* error, JSON parse error, shape mismatch) — a cache miss is never fatal.
|
|
69
|
+
*
|
|
70
|
+
* This deliberately does NOT validate the envelope deeply; downstream
|
|
71
|
+
* consumers treat the shape as advisory and will rebuild on any surprise.
|
|
72
|
+
*/
|
|
73
|
+
export async function readCacheEntry(cacheDir, key) {
|
|
74
|
+
const filePath = cacheFilePath(cacheDir, key);
|
|
75
|
+
let text;
|
|
76
|
+
try {
|
|
77
|
+
text = await fs.readFile(filePath, "utf8");
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
let parsed;
|
|
83
|
+
try {
|
|
84
|
+
parsed = JSON.parse(text);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (!isCacheEntry(parsed)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
// Double-check the envelope matches the composed key — protects against a
|
|
93
|
+
// filesystem races where a stale/misnamed file could shadow a fresh one.
|
|
94
|
+
if (parsed.grammarSha !== key.grammarSha || parsed.pipelineVersion !== key.pipelineVersion) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Default cap when `CODEHUB_PARSE_CACHE_MAX_BYTES` is unset. 1 GiB keeps a
|
|
101
|
+
* generous headroom on a typical dev box while preventing the cache from
|
|
102
|
+
* growing without bound on long-lived analyzer hosts. Set the env var to
|
|
103
|
+
* `0` to disable eviction entirely (useful for ephemeral CI runners).
|
|
104
|
+
*/
|
|
105
|
+
const DEFAULT_CACHE_CAP = "1GiB";
|
|
106
|
+
/**
|
|
107
|
+
* Write a cache entry atomically. Creates the shard directory if missing.
|
|
108
|
+
* Never throws on `mkdir EEXIST`; other IO failures propagate to the caller.
|
|
109
|
+
*
|
|
110
|
+
* After a successful write, runs {@link evictIfOverCap} against the cap
|
|
111
|
+
* sourced from `CODEHUB_PARSE_CACHE_MAX_BYTES` (default `1GiB`; `0`
|
|
112
|
+
* disables). Eviction errors are swallowed — a cache-eviction failure
|
|
113
|
+
* is never fatal to the pipeline.
|
|
114
|
+
*/
|
|
115
|
+
export async function writeCacheEntry(cacheDir, key, entry) {
|
|
116
|
+
const filePath = cacheFilePath(cacheDir, key);
|
|
117
|
+
const parentDir = path.dirname(filePath);
|
|
118
|
+
// recursive:true already tolerates EEXIST; kept explicit for readability.
|
|
119
|
+
await fs.mkdir(parentDir, { recursive: true });
|
|
120
|
+
const payload = `${JSON.stringify(entry, null, 2)}\n`;
|
|
121
|
+
await writeFileAtomicAsync(filePath, payload);
|
|
122
|
+
// Post-write LRU sweep — gated on env, errors swallowed.
|
|
123
|
+
const cap = parseHumanSizeBytes(process.env["CODEHUB_PARSE_CACHE_MAX_BYTES"] ?? DEFAULT_CACHE_CAP);
|
|
124
|
+
if (cap > 0) {
|
|
125
|
+
try {
|
|
126
|
+
await evictIfOverCap(cacheDir, cap);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Cache-eviction failure is never fatal; caller still got their write.
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Parse a human-readable size string (e.g. `"1GiB"`, `"500MB"`, `"0"`) into
|
|
135
|
+
* bytes. Numeric inputs pass through clamped to non-negative. Unknown
|
|
136
|
+
* units, malformed input, or negative numbers all yield `0` (which the
|
|
137
|
+
* eviction code treats as "disabled"). Both decimal (KB/MB/GB/TB) and
|
|
138
|
+
* binary (KiB/MiB/GiB/TiB) prefixes are supported.
|
|
139
|
+
*/
|
|
140
|
+
export function parseHumanSizeBytes(input) {
|
|
141
|
+
if (typeof input === "number")
|
|
142
|
+
return Number.isFinite(input) ? Math.max(0, Math.floor(input)) : 0;
|
|
143
|
+
const m = /^\s*(\d+(?:\.\d+)?)\s*([KMGT]i?B?|B)?\s*$/i.exec(input);
|
|
144
|
+
if (!m)
|
|
145
|
+
return 0;
|
|
146
|
+
const n = Number.parseFloat(m[1] ?? "0");
|
|
147
|
+
if (!Number.isFinite(n) || n < 0)
|
|
148
|
+
return 0;
|
|
149
|
+
const unit = (m[2] ?? "").toUpperCase();
|
|
150
|
+
const mult = {
|
|
151
|
+
"": 1,
|
|
152
|
+
B: 1,
|
|
153
|
+
KB: 1_000,
|
|
154
|
+
KIB: 1024,
|
|
155
|
+
MB: 1_000_000,
|
|
156
|
+
MIB: 1024 ** 2,
|
|
157
|
+
GB: 1_000_000_000,
|
|
158
|
+
GIB: 1024 ** 3,
|
|
159
|
+
TB: 1_000_000_000_000,
|
|
160
|
+
TIB: 1024 ** 4,
|
|
161
|
+
};
|
|
162
|
+
return Math.floor(n * (mult[unit] ?? 1));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* LRU-evict cache entries until total on-disk bytes ≤ `0.9 × capBytes`.
|
|
166
|
+
*
|
|
167
|
+
* Walks the same shard layout as {@link computeCacheSize}: each top-level
|
|
168
|
+
* directory under `cacheDir` is treated as a shard, and every regular
|
|
169
|
+
* file inside it is a candidate. Entries are sorted by mtime ascending,
|
|
170
|
+
* then unlinked in oldest-first order until the running total reaches
|
|
171
|
+
* the 90 % water-mark — the headroom prevents thrash where each new
|
|
172
|
+
* write evicts exactly one older entry.
|
|
173
|
+
*
|
|
174
|
+
* Behavior:
|
|
175
|
+
* - `capBytes <= 0` short-circuits (eviction disabled).
|
|
176
|
+
* - Missing `cacheDir` is a no-op.
|
|
177
|
+
* - Per-file errors during stat or unlink are swallowed (skipped).
|
|
178
|
+
* - Total under cap → no work done.
|
|
179
|
+
*
|
|
180
|
+
* Cache layout reminder: `<cacheDir>/<shard:2>/<contentSha>-<grammar:6>-<pipelineVersion>.json`.
|
|
181
|
+
*/
|
|
182
|
+
export async function evictIfOverCap(cacheDir, capBytes) {
|
|
183
|
+
if (capBytes <= 0)
|
|
184
|
+
return;
|
|
185
|
+
const candidates = [];
|
|
186
|
+
let total = 0;
|
|
187
|
+
let shards;
|
|
188
|
+
try {
|
|
189
|
+
shards = await fs.readdir(cacheDir, { withFileTypes: true });
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return; // Missing cache dir → nothing to evict.
|
|
193
|
+
}
|
|
194
|
+
// Deterministic shard order matches computeCacheSize.
|
|
195
|
+
shards.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
196
|
+
for (const shard of shards) {
|
|
197
|
+
if (!shard.isDirectory())
|
|
198
|
+
continue;
|
|
199
|
+
const shardPath = path.join(cacheDir, shard.name);
|
|
200
|
+
let entries;
|
|
201
|
+
try {
|
|
202
|
+
entries = await fs.readdir(shardPath, { withFileTypes: true });
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
208
|
+
for (const e of entries) {
|
|
209
|
+
if (!e.isFile())
|
|
210
|
+
continue;
|
|
211
|
+
const entryPath = path.join(shardPath, e.name);
|
|
212
|
+
try {
|
|
213
|
+
const s = await fs.stat(entryPath);
|
|
214
|
+
candidates.push({ path: entryPath, size: s.size, mtimeMs: s.mtimeMs });
|
|
215
|
+
total += s.size;
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// File vanished mid-traversal; skip.
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (total <= capBytes)
|
|
223
|
+
return;
|
|
224
|
+
const target = Math.floor(0.9 * capBytes);
|
|
225
|
+
// Oldest first → LRU eviction order.
|
|
226
|
+
candidates.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
227
|
+
for (const c of candidates) {
|
|
228
|
+
if (total <= target)
|
|
229
|
+
break;
|
|
230
|
+
try {
|
|
231
|
+
await fs.unlink(c.path);
|
|
232
|
+
total -= c.size;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
// Concurrent unlink, EACCES, etc. — keep going; over-cap is recoverable.
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Walk `cacheDir` and report total file count + byte size. Used by the
|
|
241
|
+
* meta-sidecar cache-stats path. Returns zeros when the directory does
|
|
242
|
+
* not exist.
|
|
243
|
+
*/
|
|
244
|
+
export async function computeCacheSize(cacheDir) {
|
|
245
|
+
let fileCount = 0;
|
|
246
|
+
let bytes = 0;
|
|
247
|
+
try {
|
|
248
|
+
const shards = await fs.readdir(cacheDir, { withFileTypes: true });
|
|
249
|
+
// Sort for deterministic traversal — size totals are commutative but
|
|
250
|
+
// deterministic iteration makes error messages reproducible.
|
|
251
|
+
shards.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
252
|
+
for (const shard of shards) {
|
|
253
|
+
if (!shard.isDirectory())
|
|
254
|
+
continue;
|
|
255
|
+
const shardPath = path.join(cacheDir, shard.name);
|
|
256
|
+
let entries;
|
|
257
|
+
try {
|
|
258
|
+
entries = await fs.readdir(shardPath, { withFileTypes: true });
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
264
|
+
for (const e of entries) {
|
|
265
|
+
if (!e.isFile())
|
|
266
|
+
continue;
|
|
267
|
+
const entryPath = path.join(shardPath, e.name);
|
|
268
|
+
try {
|
|
269
|
+
const s = await fs.stat(entryPath);
|
|
270
|
+
fileCount += 1;
|
|
271
|
+
bytes += s.size;
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
// Skip files that disappeared during traversal.
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
// Missing cache dir → zeroes.
|
|
281
|
+
}
|
|
282
|
+
return { fileCount, bytes };
|
|
283
|
+
}
|
|
284
|
+
/** Promise wrapper around write-file-atomic's callback/promise dual API. */
|
|
285
|
+
async function writeFileAtomicAsync(filePath, contents) {
|
|
286
|
+
await wfa(filePath, contents, { encoding: "utf8", fsync: true });
|
|
287
|
+
}
|
|
288
|
+
function isCacheEntry(v) {
|
|
289
|
+
if (v === null || typeof v !== "object")
|
|
290
|
+
return false;
|
|
291
|
+
const o = v;
|
|
292
|
+
if (o["cacheVersion"] !== CACHE_VERSION)
|
|
293
|
+
return false;
|
|
294
|
+
if (typeof o["grammarSha"] !== "string")
|
|
295
|
+
return false;
|
|
296
|
+
if (typeof o["pipelineVersion"] !== "string")
|
|
297
|
+
return false;
|
|
298
|
+
const ex = o["extractions"];
|
|
299
|
+
if (ex === null || typeof ex !== "object")
|
|
300
|
+
return false;
|
|
301
|
+
const e = ex;
|
|
302
|
+
if (!Array.isArray(e["definitions"]))
|
|
303
|
+
return false;
|
|
304
|
+
if (!Array.isArray(e["calls"]))
|
|
305
|
+
return false;
|
|
306
|
+
if (!Array.isArray(e["imports"]))
|
|
307
|
+
return false;
|
|
308
|
+
if (!Array.isArray(e["heritage"]))
|
|
309
|
+
return false;
|
|
310
|
+
// `captures` is optional at v2 — validate only if present.
|
|
311
|
+
if (o["captures"] !== undefined && !Array.isArray(o["captures"]))
|
|
312
|
+
return false;
|
|
313
|
+
const md = o["metadata"];
|
|
314
|
+
if (md === null || typeof md !== "object")
|
|
315
|
+
return false;
|
|
316
|
+
const m = md;
|
|
317
|
+
if (typeof m["language"] !== "string")
|
|
318
|
+
return false;
|
|
319
|
+
if (typeof m["byteSize"] !== "number")
|
|
320
|
+
return false;
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=content-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-cache.js","sourceRoot":"","sources":["../../../src/pipeline/phases/content-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAQnD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,sEAAsE;AACtE,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAiEtC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,UAAkB,EAClB,eAAuB;IAEvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,GAAa;IAC3D,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC;IAC1E,MAAM,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E,KAAK,IAAI,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,GAAG,EAA6B,CAAC;IACxC,IAAI,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cobertura coverage.xml parser.
|
|
3
|
+
*
|
|
4
|
+
* Cobertura / Python coverage-xml reports nest per-file coverage under:
|
|
5
|
+
* <coverage>
|
|
6
|
+
* <packages>
|
|
7
|
+
* <package>
|
|
8
|
+
* <classes>
|
|
9
|
+
* <class filename="src/foo.py">
|
|
10
|
+
* <lines>
|
|
11
|
+
* <line number="1" hits="2"/>
|
|
12
|
+
* <line number="2" hits="0"/>
|
|
13
|
+
* </lines>
|
|
14
|
+
* </class>
|
|
15
|
+
*
|
|
16
|
+
* The phase uses `fast-xml-parser` (already a dep). We set
|
|
17
|
+
* `ignoreAttributes=false` so the `number`/`hits`/`filename` attributes are
|
|
18
|
+
* reachable via the attribute-prefix key (`@_`).
|
|
19
|
+
*
|
|
20
|
+
* Determinism: the parser returns a map, which the calling phase sorts
|
|
21
|
+
* before mutating the graph.
|
|
22
|
+
*/
|
|
23
|
+
import { type FileCoverage } from "./types.js";
|
|
24
|
+
export declare function parseCobertura(raw: string, repoRoot: string): ReadonlyMap<string, FileCoverage>;
|
|
25
|
+
//# sourceMappingURL=cobertura.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobertura.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/phases/coverage-parsers/cobertura.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAc,KAAK,YAAY,EAAS,MAAM,YAAY,CAAC;AAOlE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CA6C/F"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cobertura coverage.xml parser.
|
|
3
|
+
*
|
|
4
|
+
* Cobertura / Python coverage-xml reports nest per-file coverage under:
|
|
5
|
+
* <coverage>
|
|
6
|
+
* <packages>
|
|
7
|
+
* <package>
|
|
8
|
+
* <classes>
|
|
9
|
+
* <class filename="src/foo.py">
|
|
10
|
+
* <lines>
|
|
11
|
+
* <line number="1" hits="2"/>
|
|
12
|
+
* <line number="2" hits="0"/>
|
|
13
|
+
* </lines>
|
|
14
|
+
* </class>
|
|
15
|
+
*
|
|
16
|
+
* The phase uses `fast-xml-parser` (already a dep). We set
|
|
17
|
+
* `ignoreAttributes=false` so the `number`/`hits`/`filename` attributes are
|
|
18
|
+
* reachable via the attribute-prefix key (`@_`).
|
|
19
|
+
*
|
|
20
|
+
* Determinism: the parser returns a map, which the calling phase sorts
|
|
21
|
+
* before mutating the graph.
|
|
22
|
+
*/
|
|
23
|
+
import { XMLParser } from "fast-xml-parser";
|
|
24
|
+
import { canonLines, ratio } from "./types.js";
|
|
25
|
+
export function parseCobertura(raw, repoRoot) {
|
|
26
|
+
const parser = new XMLParser({
|
|
27
|
+
ignoreAttributes: false,
|
|
28
|
+
attributeNamePrefix: "@_",
|
|
29
|
+
// Force singletons into arrays where we walk over them.
|
|
30
|
+
isArray: (name) => name === "package" ||
|
|
31
|
+
name === "class" ||
|
|
32
|
+
name === "line" ||
|
|
33
|
+
name === "packages" ||
|
|
34
|
+
name === "classes" ||
|
|
35
|
+
name === "lines",
|
|
36
|
+
});
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = parser.parse(raw);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return new Map();
|
|
43
|
+
}
|
|
44
|
+
const classes = collectClasses(parsed);
|
|
45
|
+
const out = new Map();
|
|
46
|
+
for (const c of classes) {
|
|
47
|
+
const filename = c.filename;
|
|
48
|
+
if (filename === undefined || filename.length === 0)
|
|
49
|
+
continue;
|
|
50
|
+
const linesIn = c.lines ?? [];
|
|
51
|
+
if (linesIn.length === 0)
|
|
52
|
+
continue;
|
|
53
|
+
let covered = 0;
|
|
54
|
+
const coveredLines = [];
|
|
55
|
+
for (const line of linesIn) {
|
|
56
|
+
if (line.hits > 0) {
|
|
57
|
+
covered += 1;
|
|
58
|
+
coveredLines.push(line.line);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const total = linesIn.length;
|
|
62
|
+
const relPath = normalisePath(filename, repoRoot);
|
|
63
|
+
out.set(relPath, {
|
|
64
|
+
filePath: relPath,
|
|
65
|
+
coveredLines: canonLines(coveredLines),
|
|
66
|
+
totalLines: total,
|
|
67
|
+
coveragePercent: ratio(covered, total),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
function collectClasses(parsed) {
|
|
73
|
+
const out = [];
|
|
74
|
+
const root = parsed?.coverage;
|
|
75
|
+
const packagesContainer = root?.packages;
|
|
76
|
+
if (!Array.isArray(packagesContainer))
|
|
77
|
+
return out;
|
|
78
|
+
// Each entry inside `packages[]` is itself an object that *may* nest a
|
|
79
|
+
// further `package` array (repeat container). Walk one more level so both
|
|
80
|
+
// shapes work.
|
|
81
|
+
for (const container of packagesContainer) {
|
|
82
|
+
const packages = container?.package;
|
|
83
|
+
if (!Array.isArray(packages))
|
|
84
|
+
continue;
|
|
85
|
+
for (const pkg of packages) {
|
|
86
|
+
const classesContainer = pkg?.classes;
|
|
87
|
+
if (!Array.isArray(classesContainer))
|
|
88
|
+
continue;
|
|
89
|
+
for (const cContainer of classesContainer) {
|
|
90
|
+
const classes = cContainer?.class;
|
|
91
|
+
if (!Array.isArray(classes))
|
|
92
|
+
continue;
|
|
93
|
+
for (const cls of classes) {
|
|
94
|
+
const filename = cls["@_filename"];
|
|
95
|
+
const linesContainer = cls?.lines;
|
|
96
|
+
const linesRaw = Array.isArray(linesContainer) && linesContainer.length > 0
|
|
97
|
+
? (linesContainer[0]?.line ?? [])
|
|
98
|
+
: [];
|
|
99
|
+
const entries = [];
|
|
100
|
+
if (Array.isArray(linesRaw)) {
|
|
101
|
+
for (const lv of linesRaw) {
|
|
102
|
+
const rec = lv;
|
|
103
|
+
const lineNum = numberAttr(rec["@_number"]);
|
|
104
|
+
const hits = numberAttr(rec["@_hits"]);
|
|
105
|
+
if (lineNum === undefined || hits === undefined)
|
|
106
|
+
continue;
|
|
107
|
+
entries.push({ line: lineNum, hits });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
out.push({
|
|
111
|
+
...(typeof filename === "string" ? { filename } : {}),
|
|
112
|
+
lines: entries,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
function numberAttr(v) {
|
|
121
|
+
if (typeof v === "number")
|
|
122
|
+
return Number.isFinite(v) ? v : undefined;
|
|
123
|
+
if (typeof v === "string") {
|
|
124
|
+
const n = Number.parseInt(v, 10);
|
|
125
|
+
return Number.isInteger(n) ? n : undefined;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
function normalisePath(raw, repoRoot) {
|
|
130
|
+
const posix = raw.replace(/\\/g, "/");
|
|
131
|
+
if (!posix.startsWith("/"))
|
|
132
|
+
return posix;
|
|
133
|
+
const rootPosix = repoRoot.replace(/\\/g, "/");
|
|
134
|
+
const prefix = rootPosix.endsWith("/") ? rootPosix : `${rootPosix}/`;
|
|
135
|
+
if (posix.startsWith(prefix))
|
|
136
|
+
return posix.slice(prefix.length);
|
|
137
|
+
return posix;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=cobertura.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobertura.js","sourceRoot":"","sources":["../../../../src/pipeline/phases/coverage-parsers/cobertura.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAqB,KAAK,EAAE,MAAM,YAAY,CAAC;AAOlE,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,QAAgB;IAC1D,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,gBAAgB,EAAE,KAAK;QACvB,mBAAmB,EAAE,IAAI;QACzB,wDAAwD;QACxD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAChB,IAAI,KAAK,SAAS;YAClB,IAAI,KAAK,OAAO;YAChB,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,UAAU;YACnB,IAAI,KAAK,SAAS;YAClB,IAAI,KAAK,OAAO;KACnB,CAAC,CAAC;IACH,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC5B,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAC9D,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,S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.py JSON report parser.
|
|
3
|
+
*
|
|
4
|
+
* Shape emitted by `coverage json` (a.k.a. `coverage report --format=json`):
|
|
5
|
+
* {
|
|
6
|
+
* "files": {
|
|
7
|
+
* "src/foo.py": {
|
|
8
|
+
* "executed_lines": [1, 2, 3],
|
|
9
|
+
* "missing_lines": [7, 10],
|
|
10
|
+
* "summary": { "covered_lines": 3, "num_statements": 5, ... }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* We key on `executed_lines` for the covered set and sum
|
|
16
|
+
* `executed_lines + missing_lines` to get the total. That matches coverage.py
|
|
17
|
+
* semantics more precisely than the `summary.num_statements` field, which
|
|
18
|
+
* excludes excluded-but-executable lines.
|
|
19
|
+
*
|
|
20
|
+
* Paths are already repo-relative POSIX in coverage.py output, so no
|
|
21
|
+
* rewriting is necessary.
|
|
22
|
+
*/
|
|
23
|
+
import { type FileCoverage } from "./types.js";
|
|
24
|
+
export declare function parseCoveragePy(raw: string, _repoRoot: string): ReadonlyMap<string, FileCoverage>;
|
|
25
|
+
//# sourceMappingURL=coverage-py.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-py.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/phases/coverage-parsers/coverage-py.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAS,MAAM,YAAY,CAAC;AAWlE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAwBjG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* coverage.py JSON report parser.
|
|
3
|
+
*
|
|
4
|
+
* Shape emitted by `coverage json` (a.k.a. `coverage report --format=json`):
|
|
5
|
+
* {
|
|
6
|
+
* "files": {
|
|
7
|
+
* "src/foo.py": {
|
|
8
|
+
* "executed_lines": [1, 2, 3],
|
|
9
|
+
* "missing_lines": [7, 10],
|
|
10
|
+
* "summary": { "covered_lines": 3, "num_statements": 5, ... }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* We key on `executed_lines` for the covered set and sum
|
|
16
|
+
* `executed_lines + missing_lines` to get the total. That matches coverage.py
|
|
17
|
+
* semantics more precisely than the `summary.num_statements` field, which
|
|
18
|
+
* excludes excluded-but-executable lines.
|
|
19
|
+
*
|
|
20
|
+
* Paths are already repo-relative POSIX in coverage.py output, so no
|
|
21
|
+
* rewriting is necessary.
|
|
22
|
+
*/
|
|
23
|
+
import { canonLines, ratio } from "./types.js";
|
|
24
|
+
export function parseCoveragePy(raw, _repoRoot) {
|
|
25
|
+
const out = new Map();
|
|
26
|
+
let parsed;
|
|
27
|
+
try {
|
|
28
|
+
parsed = JSON.parse(raw);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
const files = parsed?.files;
|
|
34
|
+
if (files === undefined || typeof files !== "object")
|
|
35
|
+
return out;
|
|
36
|
+
for (const [path, rec] of Object.entries(files)) {
|
|
37
|
+
const executed = Array.isArray(rec?.executed_lines) ? rec.executed_lines : [];
|
|
38
|
+
const missing = Array.isArray(rec?.missing_lines) ? rec.missing_lines : [];
|
|
39
|
+
const total = executed.length + missing.length;
|
|
40
|
+
if (total === 0)
|
|
41
|
+
continue;
|
|
42
|
+
out.set(path, {
|
|
43
|
+
filePath: path,
|
|
44
|
+
coveredLines: canonLines(executed),
|
|
45
|
+
totalLines: total,
|
|
46
|
+
coveragePercent: ratio(executed.length, total),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=coverage-py.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-py.js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AC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JaCoCo XML parser.
|
|
3
|
+
*
|
|
4
|
+
* JaCoCo's XML report tree:
|
|
5
|
+
* <report>
|
|
6
|
+
* <package name="com/foo">
|
|
7
|
+
* <sourcefile name="Bar.java">
|
|
8
|
+
* <line nr="12" mi="0" ci="3" mb="0" cb="0"/>
|
|
9
|
+
* ...
|
|
10
|
+
* </sourcefile>
|
|
11
|
+
*
|
|
12
|
+
* Per the JaCoCo DTD, `mi` is missed-instructions, `ci` is covered-
|
|
13
|
+
* instructions. We treat a line as covered when `ci > 0`. Total is the
|
|
14
|
+
* count of `<line>` elements for the sourcefile.
|
|
15
|
+
*
|
|
16
|
+
* Path assembly: the JaCoCo `name` attribute on `<package>` is slash-joined
|
|
17
|
+
* (e.g. `com/foo`), and the `<sourcefile>` name is the basename. We join
|
|
18
|
+
* them into a single POSIX path for graph matching. Callers may additionally
|
|
19
|
+
* set a project-source-root prefix via `options.sourceRoot` so the returned
|
|
20
|
+
* path aligns with the scan output.
|
|
21
|
+
*/
|
|
22
|
+
import { type FileCoverage } from "./types.js";
|
|
23
|
+
export interface JacocoOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Optional repo-relative prefix to prepend when assembling the source path
|
|
26
|
+
* (e.g. `src/main/java`). Defaults to the empty string because JaCoCo's
|
|
27
|
+
* report layout varies by build tool.
|
|
28
|
+
*/
|
|
29
|
+
readonly sourceRoot?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function parseJacoco(raw: string, _repoRoot: string, options?: JacocoOptions): ReadonlyMap<string, FileCoverage>;
|
|
32
|
+
//# sourceMappingURL=jacoco.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jacoco.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/phases/coverage-parsers/jacoco.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAc,KAAK,YAAY,EAAS,MAAM,YAAY,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAkB,GAC1B,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAwDnC"}
|