@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,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COBOL regex hot path.
|
|
3
|
+
*
|
|
4
|
+
* Pure-function extractor for fixed-format COBOL files (`.cbl`, `.cob`,
|
|
5
|
+
* `.cpy`). Emits {@link CobolElement} records for the five targets that a
|
|
6
|
+
* human reader would use to navigate a legacy mainframe program:
|
|
7
|
+
*
|
|
8
|
+
* - `program-id` — `PROGRAM-ID. <name>.`, one per file
|
|
9
|
+
* - `paragraph` — labels in Area A: `^[ ]{7}[A-Z0-9][A-Z0-9-]*\.`
|
|
10
|
+
* - `perform` — `PERFORM <identifier>`, each occurrence (heuristic
|
|
11
|
+
* CALL-like reference; the enclosing paragraph is the
|
|
12
|
+
* caller)
|
|
13
|
+
* - `copy` — `COPY <name>`, each occurrence (copybook inclusion)
|
|
14
|
+
* - `cics` — `EXEC CICS ... END-EXEC` spans (multi-line aware)
|
|
15
|
+
*
|
|
16
|
+
* ## Fixed-format COBOL refresher
|
|
17
|
+
*
|
|
18
|
+
* Columns 1-6 sequence numbers (ignored)
|
|
19
|
+
* Column 7 indicator area: `*` or `/` = comment line, `-` =
|
|
20
|
+
* continuation, `D` = debugging aid, ` ` = normal
|
|
21
|
+
* Columns 8-11 Area A: divisions, sections, paragraphs
|
|
22
|
+
* Columns 12-72 Area B: statements
|
|
23
|
+
* Columns 73-80 identification (ignored)
|
|
24
|
+
*
|
|
25
|
+
* The default parse path runs at ≤ 1 ms on 1000-line fixtures; a p50
|
|
26
|
+
* regression in that number is a graph-ingestion regression.
|
|
27
|
+
*
|
|
28
|
+
* ## Anti-goals
|
|
29
|
+
*
|
|
30
|
+
* - NOT a full parse: `PERFORM ... THRU ... VARYING`, `COPY ... REPLACING
|
|
31
|
+
* ==tag== BY ==value==`, and nested `EXEC SQL` blocks are all resolved
|
|
32
|
+
* heuristically. The deep-parse path (ProLeap, when wired in) owns the
|
|
33
|
+
* precise AST.
|
|
34
|
+
* - NOT free-format aware: the 99% legacy estate is fixed-format;
|
|
35
|
+
* free-format COBOL (column-0 start) lands with the ProLeap backend.
|
|
36
|
+
* - NO filesystem I/O, NO subprocesses, NO external deps. The function
|
|
37
|
+
* is pure over `(path, content)`.
|
|
38
|
+
*
|
|
39
|
+
* ## Author's note
|
|
40
|
+
*
|
|
41
|
+
* The regex vocabulary here (PROGRAM-ID, PARAGRAPH, PERFORM, COPY, CICS) is
|
|
42
|
+
* explicitly allow-listed in `scripts/check-banned-strings.sh` (U2 in spec
|
|
43
|
+
* 004) because it's the standard public COBOL surface.
|
|
44
|
+
*/
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Regexes (all case-insensitive; the `/i` flag is set at the source below).
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
/**
|
|
49
|
+
* PROGRAM-ID. <name>. May have spaces around the period.
|
|
50
|
+
* We intentionally match the full line rather than positional columns so a
|
|
51
|
+
* mildly-misaligned fixture still classifies. A well-formed PROGRAM-ID sits
|
|
52
|
+
* in Area A (column 8), and the matcher still works there too.
|
|
53
|
+
*/
|
|
54
|
+
const PROGRAM_ID_RE = /\bPROGRAM-ID\s*\.\s*([A-Z0-9][A-Z0-9-]*)/i;
|
|
55
|
+
/**
|
|
56
|
+
* Paragraph label: 6 arbitrary chars (sequence area), a blank indicator
|
|
57
|
+
* column, then a bare identifier plus a period at the start of Area A.
|
|
58
|
+
* Legacy fixed-format lines often put digits in the sequence area
|
|
59
|
+
* (`000100 MAIN-PARA.`), so we allow any character there rather than
|
|
60
|
+
* insisting on 6 spaces. The matcher is applied only to non-comment
|
|
61
|
+
* lines whose column 7 is blank — enforced via the explicit ` ` after
|
|
62
|
+
* the `.{6}` anchor.
|
|
63
|
+
*/
|
|
64
|
+
const PARAGRAPH_RE = /^.{6} ([A-Z0-9][A-Z0-9-]*)\.\s*$/i;
|
|
65
|
+
/**
|
|
66
|
+
* PERFORM <identifier>. We strip the `VARYING`, `UNTIL`, `TIMES`, `THRU`,
|
|
67
|
+
* `THROUGH`, `WITH`, `TEST` keywords out of the set of valid target names
|
|
68
|
+
* so they don't masquerade as paragraphs. Occurrence-based — one emission
|
|
69
|
+
* per PERFORM, even if the same paragraph is called from multiple sites.
|
|
70
|
+
*/
|
|
71
|
+
const PERFORM_RE = /\bPERFORM\s+([A-Z0-9][A-Z0-9-]*)/gi;
|
|
72
|
+
/**
|
|
73
|
+
* COPY <name> — both simple (`COPY BOOKFILE.`) and REPLACING variants
|
|
74
|
+
* (the REPLACING clause is ignored here; deep parse handles it).
|
|
75
|
+
*/
|
|
76
|
+
const COPY_RE = /\bCOPY\s+([A-Z0-9][A-Z0-9-]*)/gi;
|
|
77
|
+
/**
|
|
78
|
+
* `EXEC CICS` opener — the closing `END-EXEC` is matched separately so we
|
|
79
|
+
* can span multiple lines. A missing `END-EXEC` emits a diagnostic.
|
|
80
|
+
*/
|
|
81
|
+
const EXEC_CICS_OPEN_RE = /\bEXEC\s+CICS\b/i;
|
|
82
|
+
const END_EXEC_RE = /\bEND-EXEC\b/i;
|
|
83
|
+
/**
|
|
84
|
+
* PERFORM modifiers that must NOT be reported as target paragraphs. COBOL
|
|
85
|
+
* allows e.g. `PERFORM VARYING I FROM 1` or `PERFORM UNTIL DONE` where the
|
|
86
|
+
* first token after PERFORM is a keyword, not a paragraph name.
|
|
87
|
+
*/
|
|
88
|
+
const PERFORM_KEYWORD_TARGETS = new Set([
|
|
89
|
+
"VARYING",
|
|
90
|
+
"UNTIL",
|
|
91
|
+
"TIMES",
|
|
92
|
+
"THRU",
|
|
93
|
+
"THROUGH",
|
|
94
|
+
"WITH",
|
|
95
|
+
"TEST",
|
|
96
|
+
]);
|
|
97
|
+
const MAX_SNIPPET_LENGTH = 120;
|
|
98
|
+
const MAX_FILE_BYTES_FOR_REGEX = 5 * 1024 * 1024; // 5 MB — matches parse-worker cap.
|
|
99
|
+
/**
|
|
100
|
+
* Parse a COBOL file and return the extracted element set. Pure function;
|
|
101
|
+
* safe to call from any thread / worker.
|
|
102
|
+
*/
|
|
103
|
+
export function parseCobolFile(path, content) {
|
|
104
|
+
const diagnostics = [];
|
|
105
|
+
// Binary / oversize early exit — cheaper than splitting into lines first.
|
|
106
|
+
if (content.length === 0) {
|
|
107
|
+
return { elements: [], copybookRefs: [], diagnostics: [] };
|
|
108
|
+
}
|
|
109
|
+
if (content.length > MAX_FILE_BYTES_FOR_REGEX) {
|
|
110
|
+
return {
|
|
111
|
+
elements: [],
|
|
112
|
+
copybookRefs: [],
|
|
113
|
+
diagnostics: [`cobol-regex: ${path} exceeds ${MAX_FILE_BYTES_FOR_REGEX}-byte cap; skipping`],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (looksBinary(content)) {
|
|
117
|
+
return {
|
|
118
|
+
elements: [],
|
|
119
|
+
copybookRefs: [],
|
|
120
|
+
diagnostics: [`cobol-regex: ${path} looks binary; skipping`],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const lines = content.split(/\r?\n/);
|
|
124
|
+
const elements = [];
|
|
125
|
+
const copybookSet = new Set();
|
|
126
|
+
let programIdEmitted = false;
|
|
127
|
+
let cicsOpenLine;
|
|
128
|
+
let cicsOpenSnippet;
|
|
129
|
+
for (let i = 0; i < lines.length; i++) {
|
|
130
|
+
const raw = lines[i] ?? "";
|
|
131
|
+
const lineNo = i + 1;
|
|
132
|
+
// Comment lines: `*` or `/` in column 7 (0-indexed position 6). We also
|
|
133
|
+
// honor `*>` at any column (the rare free-format-style inline comment).
|
|
134
|
+
if (isCommentLine(raw))
|
|
135
|
+
continue;
|
|
136
|
+
// Strip the sequence area (columns 1-6) and indicator (column 7) before
|
|
137
|
+
// running pattern matches, so PROGRAM-ID / PERFORM / COPY matches in
|
|
138
|
+
// Area A + B are indifferent to column bookkeeping. We KEEP the raw
|
|
139
|
+
// line for the paragraph-label matcher, which cares about column
|
|
140
|
+
// alignment.
|
|
141
|
+
const stripped = stripSequenceAndIndicator(raw);
|
|
142
|
+
// --- PROGRAM-ID ---
|
|
143
|
+
// Only the first PROGRAM-ID counts (per the COBOL spec there is exactly
|
|
144
|
+
// one per file). We still warn on extras as a diagnostic.
|
|
145
|
+
if (!programIdEmitted) {
|
|
146
|
+
const m = stripped.match(PROGRAM_ID_RE);
|
|
147
|
+
if (m !== null && m[1] !== undefined) {
|
|
148
|
+
elements.push({
|
|
149
|
+
kind: "program-id",
|
|
150
|
+
name: m[1],
|
|
151
|
+
filePath: path,
|
|
152
|
+
startLine: lineNo,
|
|
153
|
+
endLine: lineNo,
|
|
154
|
+
language: "cobol",
|
|
155
|
+
confidence: "heuristic",
|
|
156
|
+
snippet: trimSnippet(raw),
|
|
157
|
+
});
|
|
158
|
+
programIdEmitted = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (PROGRAM_ID_RE.test(stripped)) {
|
|
162
|
+
diagnostics.push(`cobol-regex: ${path}:${lineNo}: duplicate PROGRAM-ID ignored`);
|
|
163
|
+
}
|
|
164
|
+
// --- Paragraph label (strict column-alignment matcher on the raw line) ---
|
|
165
|
+
const paraMatch = raw.match(PARAGRAPH_RE);
|
|
166
|
+
if (paraMatch !== null && paraMatch[1] !== undefined) {
|
|
167
|
+
// Skip reserved division / section headers — they also match the
|
|
168
|
+
// grammar but live in their own COBOL level. The usual suspects are
|
|
169
|
+
// "IDENTIFICATION", "ENVIRONMENT", "DATA", "PROCEDURE", "WORKING-STORAGE",
|
|
170
|
+
// "LINKAGE", "FILE", "LOCAL-STORAGE" — see ISO/IEC 1989:2014 §8.
|
|
171
|
+
if (!isReservedDivisionOrSection(paraMatch[1])) {
|
|
172
|
+
elements.push({
|
|
173
|
+
kind: "paragraph",
|
|
174
|
+
name: paraMatch[1],
|
|
175
|
+
filePath: path,
|
|
176
|
+
startLine: lineNo,
|
|
177
|
+
endLine: lineNo,
|
|
178
|
+
language: "cobol",
|
|
179
|
+
confidence: "heuristic",
|
|
180
|
+
snippet: trimSnippet(raw),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// --- PERFORM target(s) on this line ---
|
|
185
|
+
// Reset regex state per line because of the `g` flag.
|
|
186
|
+
PERFORM_RE.lastIndex = 0;
|
|
187
|
+
for (let m = PERFORM_RE.exec(stripped); m !== null; m = PERFORM_RE.exec(stripped)) {
|
|
188
|
+
const target = m[1];
|
|
189
|
+
if (target === undefined)
|
|
190
|
+
continue;
|
|
191
|
+
if (PERFORM_KEYWORD_TARGETS.has(target.toUpperCase()))
|
|
192
|
+
continue;
|
|
193
|
+
elements.push({
|
|
194
|
+
kind: "perform",
|
|
195
|
+
name: target,
|
|
196
|
+
filePath: path,
|
|
197
|
+
startLine: lineNo,
|
|
198
|
+
endLine: lineNo,
|
|
199
|
+
language: "cobol",
|
|
200
|
+
confidence: "heuristic",
|
|
201
|
+
snippet: trimSnippet(raw),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// --- COPY target(s) on this line ---
|
|
205
|
+
COPY_RE.lastIndex = 0;
|
|
206
|
+
for (let m = COPY_RE.exec(stripped); m !== null; m = COPY_RE.exec(stripped)) {
|
|
207
|
+
const target = m[1];
|
|
208
|
+
if (target === undefined)
|
|
209
|
+
continue;
|
|
210
|
+
copybookSet.add(target);
|
|
211
|
+
elements.push({
|
|
212
|
+
kind: "copy",
|
|
213
|
+
name: target,
|
|
214
|
+
filePath: path,
|
|
215
|
+
startLine: lineNo,
|
|
216
|
+
endLine: lineNo,
|
|
217
|
+
language: "cobol",
|
|
218
|
+
confidence: "heuristic",
|
|
219
|
+
snippet: trimSnippet(raw),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
// --- EXEC CICS ... END-EXEC spans ---
|
|
223
|
+
// State machine: when we hit EXEC CICS (without an inline END-EXEC on
|
|
224
|
+
// the same line), remember the opening line and look for END-EXEC on
|
|
225
|
+
// subsequent lines. If the closing token shows up on the same line
|
|
226
|
+
// (single-line inline block), emit immediately.
|
|
227
|
+
if (cicsOpenLine === undefined) {
|
|
228
|
+
if (EXEC_CICS_OPEN_RE.test(stripped)) {
|
|
229
|
+
if (END_EXEC_RE.test(stripped)) {
|
|
230
|
+
elements.push({
|
|
231
|
+
kind: "cics",
|
|
232
|
+
name: inferCicsVerb(stripped),
|
|
233
|
+
filePath: path,
|
|
234
|
+
startLine: lineNo,
|
|
235
|
+
endLine: lineNo,
|
|
236
|
+
language: "cobol",
|
|
237
|
+
confidence: "heuristic",
|
|
238
|
+
snippet: trimSnippet(raw),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
cicsOpenLine = lineNo;
|
|
243
|
+
cicsOpenSnippet = trimSnippet(raw);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
if (END_EXEC_RE.test(stripped)) {
|
|
249
|
+
elements.push({
|
|
250
|
+
kind: "cics",
|
|
251
|
+
name: cicsOpenSnippet !== undefined ? inferCicsVerb(cicsOpenSnippet) : "CICS",
|
|
252
|
+
filePath: path,
|
|
253
|
+
startLine: cicsOpenLine,
|
|
254
|
+
endLine: lineNo,
|
|
255
|
+
language: "cobol",
|
|
256
|
+
confidence: "heuristic",
|
|
257
|
+
...(cicsOpenSnippet !== undefined ? { snippet: cicsOpenSnippet } : {}),
|
|
258
|
+
});
|
|
259
|
+
cicsOpenLine = undefined;
|
|
260
|
+
cicsOpenSnippet = undefined;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// Dangling EXEC CICS block — record a diagnostic but emit nothing.
|
|
265
|
+
if (cicsOpenLine !== undefined) {
|
|
266
|
+
diagnostics.push(`cobol-regex: ${path}:${cicsOpenLine}: EXEC CICS without matching END-EXEC`);
|
|
267
|
+
}
|
|
268
|
+
const copybookRefs = [...copybookSet].sort();
|
|
269
|
+
return { elements, copybookRefs, diagnostics };
|
|
270
|
+
}
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// helpers
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
/**
|
|
275
|
+
* `true` if the line is a COBOL comment (col 7 = `*` or `/`) OR if it's
|
|
276
|
+
* whitespace-only (cheaper to skip than to match).
|
|
277
|
+
*/
|
|
278
|
+
function isCommentLine(raw) {
|
|
279
|
+
if (raw.length === 0)
|
|
280
|
+
return true;
|
|
281
|
+
if (/^\s*$/.test(raw))
|
|
282
|
+
return true;
|
|
283
|
+
// Column 7 (0-indexed 6) — guard length before peeking.
|
|
284
|
+
const indicator = raw.length >= 7 ? raw.charAt(6) : "";
|
|
285
|
+
if (indicator === "*" || indicator === "/")
|
|
286
|
+
return true;
|
|
287
|
+
// Rare inline marker used by some dialects; cheap extra check.
|
|
288
|
+
if (raw.trimStart().startsWith("*>"))
|
|
289
|
+
return true;
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Strip columns 1-7 (sequence + indicator areas) from a fixed-format line.
|
|
294
|
+
* Shorter lines return empty — caller handles that gracefully.
|
|
295
|
+
*/
|
|
296
|
+
function stripSequenceAndIndicator(raw) {
|
|
297
|
+
if (raw.length <= 7)
|
|
298
|
+
return "";
|
|
299
|
+
return raw.slice(7);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* COBOL reserved division + section headers that would otherwise trip the
|
|
303
|
+
* paragraph matcher. Upper-case set for O(1) lookup; caller uppercases.
|
|
304
|
+
*/
|
|
305
|
+
const RESERVED_AREA_A = new Set([
|
|
306
|
+
"IDENTIFICATION",
|
|
307
|
+
"ENVIRONMENT",
|
|
308
|
+
"DATA",
|
|
309
|
+
"PROCEDURE",
|
|
310
|
+
"WORKING-STORAGE",
|
|
311
|
+
"LINKAGE",
|
|
312
|
+
"FILE",
|
|
313
|
+
"LOCAL-STORAGE",
|
|
314
|
+
"CONFIGURATION",
|
|
315
|
+
"INPUT-OUTPUT",
|
|
316
|
+
"FILE-CONTROL",
|
|
317
|
+
"SPECIAL-NAMES",
|
|
318
|
+
"REPORT",
|
|
319
|
+
"SCREEN",
|
|
320
|
+
"COMMUNICATION",
|
|
321
|
+
]);
|
|
322
|
+
function isReservedDivisionOrSection(name) {
|
|
323
|
+
return RESERVED_AREA_A.has(name.toUpperCase());
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Heuristic — pull the first CICS verb (`READ`, `WRITE`, `LINK`, `XCTL`,
|
|
327
|
+
* `RETURN`, `SEND`, `RECEIVE`, etc.) out of the `EXEC CICS` opener so the
|
|
328
|
+
* graph node carries a human-readable name rather than a bare `"CICS"`.
|
|
329
|
+
*/
|
|
330
|
+
function inferCicsVerb(stripped) {
|
|
331
|
+
const m = stripped.match(/\bEXEC\s+CICS\s+([A-Z][A-Z0-9-]*)/i);
|
|
332
|
+
if (m === null || m[1] === undefined)
|
|
333
|
+
return "CICS";
|
|
334
|
+
return `CICS ${m[1].toUpperCase()}`;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Peek the first ~2 KB for NUL bytes — matches the scan-phase binary
|
|
338
|
+
* heuristic. Cheaper than the 8 KB probe the scan phase uses, but fine
|
|
339
|
+
* here since the scan phase already filtered obvious binaries upstream.
|
|
340
|
+
*/
|
|
341
|
+
function looksBinary(content) {
|
|
342
|
+
const probeLen = Math.min(content.length, 2048);
|
|
343
|
+
for (let i = 0; i < probeLen; i++) {
|
|
344
|
+
if (content.charCodeAt(i) === 0)
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
function trimSnippet(raw) {
|
|
350
|
+
const trimmed = raw.trim();
|
|
351
|
+
if (trimmed.length <= MAX_SNIPPET_LENGTH)
|
|
352
|
+
return trimmed;
|
|
353
|
+
return `${trimmed.slice(0, MAX_SNIPPET_LENGTH - 3)}...`;
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=cobol-regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobol-regex.js","sourceRoot":"","sources":["../../src/parse/cobol-regex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAyCH,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,aAAa,GAAG,2CAA2C,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD;;;GAGG;AACH,MAAM,OAAO,GAAG,iCAAiC,CAAC;AAElD;;;GAGG;AACH,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAC7C,MAAM,WAAW,GAAG,eAAe,CAAC;AAEpC;;;;GAIG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAC3D,SAAS;IACT,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,wBAAwB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,mCAAmC;AAErF;;;GAGG;AACH,MAAM,UAAU,cAAc,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CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,IAAI,kBAAkB;QAAE,OAAO,OAAO,CAAC;IACzD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy grammar loader.
|
|
3
|
+
*
|
|
4
|
+
* Imports the native tree-sitter grammar modules on demand — the first call
|
|
5
|
+
* to `loadGrammar('python')` pulls in `tree-sitter-python`, subsequent calls
|
|
6
|
+
* hit the in-process cache. This keeps the cold-start cost of the parse
|
|
7
|
+
* subsystem low: importing `grammar-registry` alone does not load any grammar
|
|
8
|
+
* `.node` file.
|
|
9
|
+
*
|
|
10
|
+
* Each grammar package exposes its tree-sitter `Language` object differently:
|
|
11
|
+
* - typescript: module has `.typescript` and `.tsx` properties
|
|
12
|
+
* - javascript/python/go/go/java/rust: module IS the Language
|
|
13
|
+
* - c-sharp: ESM default export IS the Language
|
|
14
|
+
* - c, cpp, ruby, kotlin, swift: module IS the Language (CJS require)
|
|
15
|
+
* - php: module has `.php` and `.php_only` — we load `.php_only` (pure PHP,
|
|
16
|
+
* no HTML template injection; better for static analysis)
|
|
17
|
+
* - dart: git-pinned CJS module that IS the Language
|
|
18
|
+
*
|
|
19
|
+
* This module abstracts those differences behind {@link loadGrammar}.
|
|
20
|
+
*
|
|
21
|
+
* ## Regex-provider escape hatch
|
|
22
|
+
*
|
|
23
|
+
* Some languages — COBOL is the first — have no maintained tree-sitter
|
|
24
|
+
* grammar and ship via a pure-regex extractor instead. The registry encodes
|
|
25
|
+
* that split with a {@link LanguageProviderSpec} discriminated union:
|
|
26
|
+
*
|
|
27
|
+
* - `{ kind: "tree-sitter", package: string }` — the classic path; the
|
|
28
|
+
* grammar package is resolved lazily from npm and hashed into the
|
|
29
|
+
* parse-cache key via {@link getGrammarSha}.
|
|
30
|
+
* - `{ kind: "regex" }` — the escape hatch; {@link loadGrammar} refuses
|
|
31
|
+
* to build a `GrammarHandle`, {@link getGrammarSha} returns `null`
|
|
32
|
+
* (disables parse-cache keying), and upstream parse-phase code is
|
|
33
|
+
* expected to route the file through the language-specific regex
|
|
34
|
+
* extractor instead of the worker pool.
|
|
35
|
+
*
|
|
36
|
+
* This keeps every tree-sitter consumer of the registry working unchanged
|
|
37
|
+
* while giving downstream code a typed way to detect regex-only languages.
|
|
38
|
+
*/
|
|
39
|
+
import type { LanguageId } from "./types.js";
|
|
40
|
+
/**
|
|
41
|
+
* Provider spec for a single language. Discriminated on `kind`:
|
|
42
|
+
* - `"tree-sitter"` — the language has an npm-published tree-sitter
|
|
43
|
+
* grammar. `package` names the package whose `package.json` supplies
|
|
44
|
+
* the parse-cache fingerprint.
|
|
45
|
+
* - `"regex"` — the language has no tree-sitter grammar; the parse
|
|
46
|
+
* pipeline routes its files through a bespoke regex extractor. No
|
|
47
|
+
* grammar package to fingerprint, so parse-cache keying is disabled
|
|
48
|
+
* (see {@link getGrammarSha}).
|
|
49
|
+
*
|
|
50
|
+
* Named `LanguageProviderSpec` to avoid colliding with the broader
|
|
51
|
+
* `LanguageProvider` interface in `providers/types.ts` (which covers
|
|
52
|
+
* extract-* hooks, MRO strategy, and other provider-wide behavior).
|
|
53
|
+
*/
|
|
54
|
+
export type LanguageProviderSpec = {
|
|
55
|
+
readonly kind: "tree-sitter";
|
|
56
|
+
readonly package: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "regex";
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Narrow a language's provider spec to its discriminated union. Exported so
|
|
62
|
+
* upstream parse-phase code can branch on the provider kind without
|
|
63
|
+
* re-implementing the registry lookup. Typical use:
|
|
64
|
+
* `getLanguageProvider(lang).kind === "regex"` to guard the regex-dispatch
|
|
65
|
+
* path.
|
|
66
|
+
*/
|
|
67
|
+
export declare function getLanguageProvider(lang: LanguageId): LanguageProviderSpec;
|
|
68
|
+
/** `true` iff `lang` ships via the regex hot path rather than tree-sitter. */
|
|
69
|
+
export declare function isRegexProviderLanguage(lang: LanguageId): boolean;
|
|
70
|
+
/** Opaque wrapper holding everything a worker needs for one language. */
|
|
71
|
+
export interface GrammarHandle {
|
|
72
|
+
readonly language: LanguageId;
|
|
73
|
+
/** tree-sitter Language object (opaque to callers). */
|
|
74
|
+
readonly tsLanguage: unknown;
|
|
75
|
+
/** Unified S-expression query body for this language. */
|
|
76
|
+
readonly queryText: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Load and cache the tree-sitter grammar for a language.
|
|
80
|
+
*
|
|
81
|
+
* Thread/context note: the cache is per-module-instance, so in the
|
|
82
|
+
* piscina worker model each worker has its own cache — which matches
|
|
83
|
+
* tree-sitter's thread-safety rules (one Parser per worker_thread).
|
|
84
|
+
*
|
|
85
|
+
* Regex-provider languages (see {@link isRegexProviderLanguage}) throw
|
|
86
|
+
* on entry: they have no tree-sitter grammar to load, and reaching this
|
|
87
|
+
* function means the caller skipped the `kind === "regex"` dispatch
|
|
88
|
+
* guard. That is a bug on the call site, not a runtime condition to
|
|
89
|
+
* recover from.
|
|
90
|
+
*/
|
|
91
|
+
export declare function loadGrammar(lang: LanguageId): Promise<GrammarHandle>;
|
|
92
|
+
/**
|
|
93
|
+
* Preload a list of grammars in parallel. Useful as a warm-up hint during
|
|
94
|
+
* indexing start-up, but not required — {@link loadGrammar} is safe to call
|
|
95
|
+
* lazily during parsing.
|
|
96
|
+
*/
|
|
97
|
+
export declare function preloadGrammars(langs: readonly LanguageId[]): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Compute a stable SHA for the grammar backing `lang`. The SHA is derived
|
|
100
|
+
* from `sha256(JSON.stringify({ name, version }))` of the grammar's
|
|
101
|
+
* `package.json` — bumping the grammar version in the workspace therefore
|
|
102
|
+
* produces a new SHA, which is what the content-addressed parse cache
|
|
103
|
+
* needs in its composite key.
|
|
104
|
+
*
|
|
105
|
+
* Returns `null` when:
|
|
106
|
+
* - the grammar package is not installed (e.g. languages whose provider
|
|
107
|
+
* track has not landed yet), OR
|
|
108
|
+
* - the package.json could not be read/parsed.
|
|
109
|
+
*
|
|
110
|
+
* Result is memoized per-process. Idempotent across concurrent callers.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getGrammarSha(lang: LanguageId): Promise<string | null>;
|
|
113
|
+
/** For tests: drop the cache so the next load() re-imports fresh. */
|
|
114
|
+
export declare function _resetGrammarCacheForTests(): void;
|
|
115
|
+
//# sourceMappingURL=grammar-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar-registry.d.ts","sourceRoot":"","sources":["../../src/parse/grammar-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAoC/B;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,oBAAoB,CAE1E;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAEjE;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,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