@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.
Files changed (563) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +69 -0
  3. package/dist/extract/index.d.ts +8 -0
  4. package/dist/extract/index.d.ts.map +1 -0
  5. package/dist/extract/index.js +6 -0
  6. package/dist/extract/index.js.map +1 -0
  7. package/dist/extract/orm-detector.d.ts +19 -0
  8. package/dist/extract/orm-detector.d.ts.map +1 -0
  9. package/dist/extract/orm-detector.js +209 -0
  10. package/dist/extract/orm-detector.js.map +1 -0
  11. package/dist/extract/property-access.d.ts +76 -0
  12. package/dist/extract/property-access.d.ts.map +1 -0
  13. package/dist/extract/property-access.js +260 -0
  14. package/dist/extract/property-access.js.map +1 -0
  15. package/dist/extract/receiver-resolver.d.ts +86 -0
  16. package/dist/extract/receiver-resolver.d.ts.map +1 -0
  17. package/dist/extract/receiver-resolver.js +77 -0
  18. package/dist/extract/receiver-resolver.js.map +1 -0
  19. package/dist/extract/route-detector-java.d.ts +29 -0
  20. package/dist/extract/route-detector-java.d.ts.map +1 -0
  21. package/dist/extract/route-detector-java.js +190 -0
  22. package/dist/extract/route-detector-java.js.map +1 -0
  23. package/dist/extract/route-detector-nestjs.d.ts +30 -0
  24. package/dist/extract/route-detector-nestjs.d.ts.map +1 -0
  25. package/dist/extract/route-detector-nestjs.js +134 -0
  26. package/dist/extract/route-detector-nestjs.js.map +1 -0
  27. package/dist/extract/route-detector-python.d.ts +28 -0
  28. package/dist/extract/route-detector-python.d.ts.map +1 -0
  29. package/dist/extract/route-detector-python.js +100 -0
  30. package/dist/extract/route-detector-python.js.map +1 -0
  31. package/dist/extract/route-detector-rails.d.ts +28 -0
  32. package/dist/extract/route-detector-rails.d.ts.map +1 -0
  33. package/dist/extract/route-detector-rails.js +162 -0
  34. package/dist/extract/route-detector-rails.js.map +1 -0
  35. package/dist/extract/route-detector.d.ts +45 -0
  36. package/dist/extract/route-detector.d.ts.map +1 -0
  37. package/dist/extract/route-detector.js +467 -0
  38. package/dist/extract/route-detector.js.map +1 -0
  39. package/dist/extract/tool-detector.d.ts +26 -0
  40. package/dist/extract/tool-detector.d.ts.map +1 -0
  41. package/dist/extract/tool-detector.js +364 -0
  42. package/dist/extract/tool-detector.js.map +1 -0
  43. package/dist/extract/types.d.ts +89 -0
  44. package/dist/extract/types.d.ts.map +1 -0
  45. package/dist/extract/types.js +11 -0
  46. package/dist/extract/types.js.map +1 -0
  47. package/dist/index.d.ts +10 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +10 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/parse/cobol-regex.d.ts +85 -0
  52. package/dist/parse/cobol-regex.d.ts.map +1 -0
  53. package/dist/parse/cobol-regex.js +355 -0
  54. package/dist/parse/cobol-regex.js.map +1 -0
  55. package/dist/parse/grammar-registry.d.ts +115 -0
  56. package/dist/parse/grammar-registry.d.ts.map +1 -0
  57. package/dist/parse/grammar-registry.js +278 -0
  58. package/dist/parse/grammar-registry.js.map +1 -0
  59. package/dist/parse/index.d.ts +14 -0
  60. package/dist/parse/index.d.ts.map +1 -0
  61. package/dist/parse/index.js +10 -0
  62. package/dist/parse/index.js.map +1 -0
  63. package/dist/parse/language-detector.d.ts +17 -0
  64. package/dist/parse/language-detector.d.ts.map +1 -0
  65. package/dist/parse/language-detector.js +104 -0
  66. package/dist/parse/language-detector.js.map +1 -0
  67. package/dist/parse/parse-worker.d.ts +24 -0
  68. package/dist/parse/parse-worker.d.ts.map +1 -0
  69. package/dist/parse/parse-worker.js +230 -0
  70. package/dist/parse/parse-worker.js.map +1 -0
  71. package/dist/parse/types.d.ts +49 -0
  72. package/dist/parse/types.d.ts.map +1 -0
  73. package/dist/parse/types.js +11 -0
  74. package/dist/parse/types.js.map +1 -0
  75. package/dist/parse/unified-queries.d.ts +37 -0
  76. package/dist/parse/unified-queries.d.ts.map +1 -0
  77. package/dist/parse/unified-queries.js +623 -0
  78. package/dist/parse/unified-queries.js.map +1 -0
  79. package/dist/parse/wasm-fallback.d.ts +88 -0
  80. package/dist/parse/wasm-fallback.d.ts.map +1 -0
  81. package/dist/parse/wasm-fallback.js +258 -0
  82. package/dist/parse/wasm-fallback.js.map +1 -0
  83. package/dist/parse/worker-pool.d.ts +48 -0
  84. package/dist/parse/worker-pool.d.ts.map +1 -0
  85. package/dist/parse/worker-pool.js +97 -0
  86. package/dist/parse/worker-pool.js.map +1 -0
  87. package/dist/pipeline/dep-parsers/go.d.ts +25 -0
  88. package/dist/pipeline/dep-parsers/go.d.ts.map +1 -0
  89. package/dist/pipeline/dep-parsers/go.js +146 -0
  90. package/dist/pipeline/dep-parsers/go.js.map +1 -0
  91. package/dist/pipeline/dep-parsers/index.d.ts +17 -0
  92. package/dist/pipeline/dep-parsers/index.d.ts.map +1 -0
  93. package/dist/pipeline/dep-parsers/index.js +16 -0
  94. package/dist/pipeline/dep-parsers/index.js.map +1 -0
  95. package/dist/pipeline/dep-parsers/maven.d.ts +24 -0
  96. package/dist/pipeline/dep-parsers/maven.d.ts.map +1 -0
  97. package/dist/pipeline/dep-parsers/maven.js +131 -0
  98. package/dist/pipeline/dep-parsers/maven.js.map +1 -0
  99. package/dist/pipeline/dep-parsers/npm.d.ts +30 -0
  100. package/dist/pipeline/dep-parsers/npm.d.ts.map +1 -0
  101. package/dist/pipeline/dep-parsers/npm.js +309 -0
  102. package/dist/pipeline/dep-parsers/npm.js.map +1 -0
  103. package/dist/pipeline/dep-parsers/nuget.d.ts +24 -0
  104. package/dist/pipeline/dep-parsers/nuget.d.ts.map +1 -0
  105. package/dist/pipeline/dep-parsers/nuget.js +178 -0
  106. package/dist/pipeline/dep-parsers/nuget.js.map +1 -0
  107. package/dist/pipeline/dep-parsers/python.d.ts +21 -0
  108. package/dist/pipeline/dep-parsers/python.d.ts.map +1 -0
  109. package/dist/pipeline/dep-parsers/python.js +369 -0
  110. package/dist/pipeline/dep-parsers/python.js.map +1 -0
  111. package/dist/pipeline/dep-parsers/rust.d.ts +18 -0
  112. package/dist/pipeline/dep-parsers/rust.d.ts.map +1 -0
  113. package/dist/pipeline/dep-parsers/rust.js +134 -0
  114. package/dist/pipeline/dep-parsers/rust.js.map +1 -0
  115. package/dist/pipeline/dep-parsers/spdx-normalize.d.ts +15 -0
  116. package/dist/pipeline/dep-parsers/spdx-normalize.d.ts.map +1 -0
  117. package/dist/pipeline/dep-parsers/spdx-normalize.js +31 -0
  118. package/dist/pipeline/dep-parsers/spdx-normalize.js.map +1 -0
  119. package/dist/pipeline/dep-parsers/types.d.ts +63 -0
  120. package/dist/pipeline/dep-parsers/types.d.ts.map +1 -0
  121. package/dist/pipeline/dep-parsers/types.js +56 -0
  122. package/dist/pipeline/dep-parsers/types.js.map +1 -0
  123. package/dist/pipeline/gitignore-stack.d.ts +44 -0
  124. package/dist/pipeline/gitignore-stack.d.ts.map +1 -0
  125. package/dist/pipeline/gitignore-stack.js +69 -0
  126. package/dist/pipeline/gitignore-stack.js.map +1 -0
  127. package/dist/pipeline/gitignore.d.ts +67 -0
  128. package/dist/pipeline/gitignore.d.ts.map +1 -0
  129. package/dist/pipeline/gitignore.js +210 -0
  130. package/dist/pipeline/gitignore.js.map +1 -0
  131. package/dist/pipeline/index.d.ts +53 -0
  132. package/dist/pipeline/index.d.ts.map +1 -0
  133. package/dist/pipeline/index.js +29 -0
  134. package/dist/pipeline/index.js.map +1 -0
  135. package/dist/pipeline/orchestrator.d.ts +105 -0
  136. package/dist/pipeline/orchestrator.d.ts.map +1 -0
  137. package/dist/pipeline/orchestrator.js +175 -0
  138. package/dist/pipeline/orchestrator.js.map +1 -0
  139. package/dist/pipeline/ownership-helpers/drift.d.ts +41 -0
  140. package/dist/pipeline/ownership-helpers/drift.d.ts.map +1 -0
  141. package/dist/pipeline/ownership-helpers/drift.js +122 -0
  142. package/dist/pipeline/ownership-helpers/drift.js.map +1 -0
  143. package/dist/pipeline/ownership-helpers/gini-community.d.ts +24 -0
  144. package/dist/pipeline/ownership-helpers/gini-community.d.ts.map +1 -0
  145. package/dist/pipeline/ownership-helpers/gini-community.js +32 -0
  146. package/dist/pipeline/ownership-helpers/gini-community.js.map +1 -0
  147. package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts +71 -0
  148. package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts.map +1 -0
  149. package/dist/pipeline/ownership-helpers/git-blame-batcher.js +178 -0
  150. package/dist/pipeline/ownership-helpers/git-blame-batcher.js.map +1 -0
  151. package/dist/pipeline/ownership-helpers/line-overlap.d.ts +35 -0
  152. package/dist/pipeline/ownership-helpers/line-overlap.d.ts.map +1 -0
  153. package/dist/pipeline/ownership-helpers/line-overlap.js +62 -0
  154. package/dist/pipeline/ownership-helpers/line-overlap.js.map +1 -0
  155. package/dist/pipeline/ownership-helpers/orphan.d.ts +73 -0
  156. package/dist/pipeline/ownership-helpers/orphan.d.ts.map +1 -0
  157. package/dist/pipeline/ownership-helpers/orphan.js +117 -0
  158. package/dist/pipeline/ownership-helpers/orphan.js.map +1 -0
  159. package/dist/pipeline/phases/accesses.d.ts +44 -0
  160. package/dist/pipeline/phases/accesses.d.ts.map +1 -0
  161. package/dist/pipeline/phases/accesses.js +194 -0
  162. package/dist/pipeline/phases/accesses.js.map +1 -0
  163. package/dist/pipeline/phases/annotate.d.ts +28 -0
  164. package/dist/pipeline/phases/annotate.d.ts.map +1 -0
  165. package/dist/pipeline/phases/annotate.js +60 -0
  166. package/dist/pipeline/phases/annotate.js.map +1 -0
  167. package/dist/pipeline/phases/cochange.d.ts +42 -0
  168. package/dist/pipeline/phases/cochange.d.ts.map +1 -0
  169. package/dist/pipeline/phases/cochange.js +0 -0
  170. package/dist/pipeline/phases/cochange.js.map +1 -0
  171. package/dist/pipeline/phases/communities.d.ts +34 -0
  172. package/dist/pipeline/phases/communities.d.ts.map +1 -0
  173. package/dist/pipeline/phases/communities.js +412 -0
  174. package/dist/pipeline/phases/communities.js.map +1 -0
  175. package/dist/pipeline/phases/complexity.d.ts +50 -0
  176. package/dist/pipeline/phases/complexity.d.ts.map +1 -0
  177. package/dist/pipeline/phases/complexity.js +794 -0
  178. package/dist/pipeline/phases/complexity.js.map +1 -0
  179. package/dist/pipeline/phases/confidence-demote.d.ts +23 -0
  180. package/dist/pipeline/phases/confidence-demote.d.ts.map +1 -0
  181. package/dist/pipeline/phases/confidence-demote.js +113 -0
  182. package/dist/pipeline/phases/confidence-demote.js.map +1 -0
  183. package/dist/pipeline/phases/content-cache.d.ts +166 -0
  184. package/dist/pipeline/phases/content-cache.d.ts.map +1 -0
  185. package/dist/pipeline/phases/content-cache.js +323 -0
  186. package/dist/pipeline/phases/content-cache.js.map +1 -0
  187. package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts +25 -0
  188. package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts.map +1 -0
  189. package/dist/pipeline/phases/coverage-parsers/cobertura.js +139 -0
  190. package/dist/pipeline/phases/coverage-parsers/cobertura.js.map +1 -0
  191. package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts +25 -0
  192. package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts.map +1 -0
  193. package/dist/pipeline/phases/coverage-parsers/coverage-py.js +51 -0
  194. package/dist/pipeline/phases/coverage-parsers/coverage-py.js.map +1 -0
  195. package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts +32 -0
  196. package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts.map +1 -0
  197. package/dist/pipeline/phases/coverage-parsers/jacoco.js +98 -0
  198. package/dist/pipeline/phases/coverage-parsers/jacoco.js.map +1 -0
  199. package/dist/pipeline/phases/coverage-parsers/lcov.d.ts +21 -0
  200. package/dist/pipeline/phases/coverage-parsers/lcov.d.ts.map +1 -0
  201. package/dist/pipeline/phases/coverage-parsers/lcov.js +104 -0
  202. package/dist/pipeline/phases/coverage-parsers/lcov.js.map +1 -0
  203. package/dist/pipeline/phases/coverage-parsers/types.d.ts +27 -0
  204. package/dist/pipeline/phases/coverage-parsers/types.d.ts.map +1 -0
  205. package/dist/pipeline/phases/coverage-parsers/types.js +39 -0
  206. package/dist/pipeline/phases/coverage-parsers/types.js.map +1 -0
  207. package/dist/pipeline/phases/coverage.d.ts +39 -0
  208. package/dist/pipeline/phases/coverage.d.ts.map +1 -0
  209. package/dist/pipeline/phases/coverage.js +154 -0
  210. package/dist/pipeline/phases/coverage.js.map +1 -0
  211. package/dist/pipeline/phases/cross-file.d.ts +40 -0
  212. package/dist/pipeline/phases/cross-file.d.ts.map +1 -0
  213. package/dist/pipeline/phases/cross-file.js +411 -0
  214. package/dist/pipeline/phases/cross-file.js.map +1 -0
  215. package/dist/pipeline/phases/dead-code.d.ts +28 -0
  216. package/dist/pipeline/phases/dead-code.d.ts.map +1 -0
  217. package/dist/pipeline/phases/dead-code.js +157 -0
  218. package/dist/pipeline/phases/dead-code.js.map +1 -0
  219. package/dist/pipeline/phases/default-set.d.ts +24 -0
  220. package/dist/pipeline/phases/default-set.d.ts.map +1 -0
  221. package/dist/pipeline/phases/default-set.js +133 -0
  222. package/dist/pipeline/phases/default-set.js.map +1 -0
  223. package/dist/pipeline/phases/dependencies.d.ts +59 -0
  224. package/dist/pipeline/phases/dependencies.d.ts.map +1 -0
  225. package/dist/pipeline/phases/dependencies.js +281 -0
  226. package/dist/pipeline/phases/dependencies.js.map +1 -0
  227. package/dist/pipeline/phases/embedder-pool.d.ts +31 -0
  228. package/dist/pipeline/phases/embedder-pool.d.ts.map +1 -0
  229. package/dist/pipeline/phases/embedder-pool.js +79 -0
  230. package/dist/pipeline/phases/embedder-pool.js.map +1 -0
  231. package/dist/pipeline/phases/embedder-worker.d.ts +28 -0
  232. package/dist/pipeline/phases/embedder-worker.d.ts.map +1 -0
  233. package/dist/pipeline/phases/embedder-worker.js +43 -0
  234. package/dist/pipeline/phases/embedder-worker.js.map +1 -0
  235. package/dist/pipeline/phases/embeddings.d.ts +117 -0
  236. package/dist/pipeline/phases/embeddings.d.ts.map +1 -0
  237. package/dist/pipeline/phases/embeddings.js +697 -0
  238. package/dist/pipeline/phases/embeddings.js.map +1 -0
  239. package/dist/pipeline/phases/fetches.d.ts +47 -0
  240. package/dist/pipeline/phases/fetches.d.ts.map +1 -0
  241. package/dist/pipeline/phases/fetches.js +207 -0
  242. package/dist/pipeline/phases/fetches.js.map +1 -0
  243. package/dist/pipeline/phases/incremental-helper.d.ts +96 -0
  244. package/dist/pipeline/phases/incremental-helper.d.ts.map +1 -0
  245. package/dist/pipeline/phases/incremental-helper.js +125 -0
  246. package/dist/pipeline/phases/incremental-helper.js.map +1 -0
  247. package/dist/pipeline/phases/incremental-scope.d.ts +67 -0
  248. package/dist/pipeline/phases/incremental-scope.d.ts.map +1 -0
  249. package/dist/pipeline/phases/incremental-scope.js +225 -0
  250. package/dist/pipeline/phases/incremental-scope.js.map +1 -0
  251. package/dist/pipeline/phases/markdown.d.ts +29 -0
  252. package/dist/pipeline/phases/markdown.d.ts.map +1 -0
  253. package/dist/pipeline/phases/markdown.js +298 -0
  254. package/dist/pipeline/phases/markdown.js.map +1 -0
  255. package/dist/pipeline/phases/mro.d.ts +24 -0
  256. package/dist/pipeline/phases/mro.d.ts.map +1 -0
  257. package/dist/pipeline/phases/mro.js +303 -0
  258. package/dist/pipeline/phases/mro.js.map +1 -0
  259. package/dist/pipeline/phases/openapi.d.ts +52 -0
  260. package/dist/pipeline/phases/openapi.d.ts.map +1 -0
  261. package/dist/pipeline/phases/openapi.js +285 -0
  262. package/dist/pipeline/phases/openapi.js.map +1 -0
  263. package/dist/pipeline/phases/orm.d.ts +26 -0
  264. package/dist/pipeline/phases/orm.d.ts.map +1 -0
  265. package/dist/pipeline/phases/orm.js +183 -0
  266. package/dist/pipeline/phases/orm.js.map +1 -0
  267. package/dist/pipeline/phases/ownership.d.ts +88 -0
  268. package/dist/pipeline/phases/ownership.d.ts.map +1 -0
  269. package/dist/pipeline/phases/ownership.js +479 -0
  270. package/dist/pipeline/phases/ownership.js.map +1 -0
  271. package/dist/pipeline/phases/parse.d.ts +63 -0
  272. package/dist/pipeline/phases/parse.d.ts.map +1 -0
  273. package/dist/pipeline/phases/parse.js +994 -0
  274. package/dist/pipeline/phases/parse.js.map +1 -0
  275. package/dist/pipeline/phases/processes.d.ts +47 -0
  276. package/dist/pipeline/phases/processes.d.ts.map +1 -0
  277. package/dist/pipeline/phases/processes.js +620 -0
  278. package/dist/pipeline/phases/processes.js.map +1 -0
  279. package/dist/pipeline/phases/profile.d.ts +33 -0
  280. package/dist/pipeline/phases/profile.d.ts.map +1 -0
  281. package/dist/pipeline/phases/profile.js +91 -0
  282. package/dist/pipeline/phases/profile.js.map +1 -0
  283. package/dist/pipeline/phases/repo-node.d.ts +112 -0
  284. package/dist/pipeline/phases/repo-node.d.ts.map +1 -0
  285. package/dist/pipeline/phases/repo-node.js +272 -0
  286. package/dist/pipeline/phases/repo-node.js.map +1 -0
  287. package/dist/pipeline/phases/risk-snapshot.d.ts +34 -0
  288. package/dist/pipeline/phases/risk-snapshot.d.ts.map +1 -0
  289. package/dist/pipeline/phases/risk-snapshot.js +63 -0
  290. package/dist/pipeline/phases/risk-snapshot.js.map +1 -0
  291. package/dist/pipeline/phases/routes.d.ts +31 -0
  292. package/dist/pipeline/phases/routes.d.ts.map +1 -0
  293. package/dist/pipeline/phases/routes.js +262 -0
  294. package/dist/pipeline/phases/routes.js.map +1 -0
  295. package/dist/pipeline/phases/sbom.d.ts +45 -0
  296. package/dist/pipeline/phases/sbom.d.ts.map +1 -0
  297. package/dist/pipeline/phases/sbom.js +289 -0
  298. package/dist/pipeline/phases/sbom.js.map +1 -0
  299. package/dist/pipeline/phases/scan.d.ts +54 -0
  300. package/dist/pipeline/phases/scan.d.ts.map +1 -0
  301. package/dist/pipeline/phases/scan.js +340 -0
  302. package/dist/pipeline/phases/scan.js.map +1 -0
  303. package/dist/pipeline/phases/scip-index.d.ts +54 -0
  304. package/dist/pipeline/phases/scip-index.d.ts.map +1 -0
  305. package/dist/pipeline/phases/scip-index.js +469 -0
  306. package/dist/pipeline/phases/scip-index.js.map +1 -0
  307. package/dist/pipeline/phases/structure.d.ts +21 -0
  308. package/dist/pipeline/phases/structure.d.ts.map +1 -0
  309. package/dist/pipeline/phases/structure.js +115 -0
  310. package/dist/pipeline/phases/structure.js.map +1 -0
  311. package/dist/pipeline/phases/summarize.d.ts +126 -0
  312. package/dist/pipeline/phases/summarize.d.ts.map +1 -0
  313. package/dist/pipeline/phases/summarize.js +401 -0
  314. package/dist/pipeline/phases/summarize.js.map +1 -0
  315. package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts +42 -0
  316. package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts.map +1 -0
  317. package/dist/pipeline/phases/temporal-helpers/branch-divergence.js +96 -0
  318. package/dist/pipeline/phases/temporal-helpers/branch-divergence.js.map +1 -0
  319. package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts +22 -0
  320. package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts.map +1 -0
  321. package/dist/pipeline/phases/temporal-helpers/churn-decay.js +32 -0
  322. package/dist/pipeline/phases/temporal-helpers/churn-decay.js.map +1 -0
  323. package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts +21 -0
  324. package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts.map +1 -0
  325. package/dist/pipeline/phases/temporal-helpers/conventional-commits.js +37 -0
  326. package/dist/pipeline/phases/temporal-helpers/conventional-commits.js.map +1 -0
  327. package/dist/pipeline/phases/temporal-helpers/gini.d.ts +32 -0
  328. package/dist/pipeline/phases/temporal-helpers/gini.d.ts.map +1 -0
  329. package/dist/pipeline/phases/temporal-helpers/gini.js +78 -0
  330. package/dist/pipeline/phases/temporal-helpers/gini.js.map +1 -0
  331. package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts +14 -0
  332. package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts.map +1 -0
  333. package/dist/pipeline/phases/temporal-helpers/revert-detect.js +25 -0
  334. package/dist/pipeline/phases/temporal-helpers/revert-detect.js.map +1 -0
  335. package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts +18 -0
  336. package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts.map +1 -0
  337. package/dist/pipeline/phases/temporal-helpers/test-pair.js +119 -0
  338. package/dist/pipeline/phases/temporal-helpers/test-pair.js.map +1 -0
  339. package/dist/pipeline/phases/temporal.d.ts +65 -0
  340. package/dist/pipeline/phases/temporal.d.ts.map +1 -0
  341. package/dist/pipeline/phases/temporal.js +621 -0
  342. package/dist/pipeline/phases/temporal.js.map +1 -0
  343. package/dist/pipeline/phases/tools.d.ts +21 -0
  344. package/dist/pipeline/phases/tools.d.ts.map +1 -0
  345. package/dist/pipeline/phases/tools.js +118 -0
  346. package/dist/pipeline/phases/tools.js.map +1 -0
  347. package/dist/pipeline/profile-detectors/api-contracts.d.ts +18 -0
  348. package/dist/pipeline/profile-detectors/api-contracts.d.ts.map +1 -0
  349. package/dist/pipeline/profile-detectors/api-contracts.js +78 -0
  350. package/dist/pipeline/profile-detectors/api-contracts.js.map +1 -0
  351. package/dist/pipeline/profile-detectors/framework-detector.d.ts +11 -0
  352. package/dist/pipeline/profile-detectors/framework-detector.d.ts.map +1 -0
  353. package/dist/pipeline/profile-detectors/framework-detector.js +11 -0
  354. package/dist/pipeline/profile-detectors/framework-detector.js.map +1 -0
  355. package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts +7 -0
  356. package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts.map +1 -0
  357. package/dist/pipeline/profile-detectors/frameworks-catalog.js +7 -0
  358. package/dist/pipeline/profile-detectors/frameworks-catalog.js.map +1 -0
  359. package/dist/pipeline/profile-detectors/frameworks.d.ts +7 -0
  360. package/dist/pipeline/profile-detectors/frameworks.d.ts.map +1 -0
  361. package/dist/pipeline/profile-detectors/frameworks.js +7 -0
  362. package/dist/pipeline/profile-detectors/frameworks.js.map +1 -0
  363. package/dist/pipeline/profile-detectors/iac.d.ts +22 -0
  364. package/dist/pipeline/profile-detectors/iac.d.ts.map +1 -0
  365. package/dist/pipeline/profile-detectors/iac.js +97 -0
  366. package/dist/pipeline/profile-detectors/iac.js.map +1 -0
  367. package/dist/pipeline/profile-detectors/languages.d.ts +18 -0
  368. package/dist/pipeline/profile-detectors/languages.d.ts.map +1 -0
  369. package/dist/pipeline/profile-detectors/languages.js +60 -0
  370. package/dist/pipeline/profile-detectors/languages.js.map +1 -0
  371. package/dist/pipeline/profile-detectors/manifests.d.ts +7 -0
  372. package/dist/pipeline/profile-detectors/manifests.d.ts.map +1 -0
  373. package/dist/pipeline/profile-detectors/manifests.js +7 -0
  374. package/dist/pipeline/profile-detectors/manifests.js.map +1 -0
  375. package/dist/pipeline/profile-detectors/src-dirs.d.ts +17 -0
  376. package/dist/pipeline/profile-detectors/src-dirs.d.ts.map +1 -0
  377. package/dist/pipeline/profile-detectors/src-dirs.js +89 -0
  378. package/dist/pipeline/profile-detectors/src-dirs.js.map +1 -0
  379. package/dist/pipeline/profile-detectors/variant-detectors.d.ts +7 -0
  380. package/dist/pipeline/profile-detectors/variant-detectors.d.ts.map +1 -0
  381. package/dist/pipeline/profile-detectors/variant-detectors.js +7 -0
  382. package/dist/pipeline/profile-detectors/variant-detectors.js.map +1 -0
  383. package/dist/pipeline/runner.d.ts +54 -0
  384. package/dist/pipeline/runner.d.ts.map +1 -0
  385. package/dist/pipeline/runner.js +247 -0
  386. package/dist/pipeline/runner.js.map +1 -0
  387. package/dist/pipeline/types.d.ts +235 -0
  388. package/dist/pipeline/types.d.ts.map +1 -0
  389. package/dist/pipeline/types.js +15 -0
  390. package/dist/pipeline/types.js.map +1 -0
  391. package/dist/providers/c.d.ts +3 -0
  392. package/dist/providers/c.d.ts.map +1 -0
  393. package/dist/providers/c.js +162 -0
  394. package/dist/providers/c.js.map +1 -0
  395. package/dist/providers/cobol.d.ts +19 -0
  396. package/dist/providers/cobol.d.ts.map +1 -0
  397. package/dist/providers/cobol.js +44 -0
  398. package/dist/providers/cobol.js.map +1 -0
  399. package/dist/providers/cpp.d.ts +3 -0
  400. package/dist/providers/cpp.d.ts.map +1 -0
  401. package/dist/providers/cpp.js +200 -0
  402. package/dist/providers/cpp.js.map +1 -0
  403. package/dist/providers/csharp.d.ts +3 -0
  404. package/dist/providers/csharp.d.ts.map +1 -0
  405. package/dist/providers/csharp.js +292 -0
  406. package/dist/providers/csharp.js.map +1 -0
  407. package/dist/providers/dart.d.ts +3 -0
  408. package/dist/providers/dart.d.ts.map +1 -0
  409. package/dist/providers/dart.js +214 -0
  410. package/dist/providers/dart.js.map +1 -0
  411. package/dist/providers/definition-ids.d.ts +18 -0
  412. package/dist/providers/definition-ids.d.ts.map +1 -0
  413. package/dist/providers/definition-ids.js +23 -0
  414. package/dist/providers/definition-ids.js.map +1 -0
  415. package/dist/providers/extract-helpers.d.ts +60 -0
  416. package/dist/providers/extract-helpers.d.ts.map +1 -0
  417. package/dist/providers/extract-helpers.js +296 -0
  418. package/dist/providers/extract-helpers.js.map +1 -0
  419. package/dist/providers/extraction-types.d.ts +85 -0
  420. package/dist/providers/extraction-types.d.ts.map +1 -0
  421. package/dist/providers/extraction-types.js +13 -0
  422. package/dist/providers/extraction-types.js.map +1 -0
  423. package/dist/providers/go.d.ts +3 -0
  424. package/dist/providers/go.d.ts.map +1 -0
  425. package/dist/providers/go.js +359 -0
  426. package/dist/providers/go.js.map +1 -0
  427. package/dist/providers/http-detect.d.ts +44 -0
  428. package/dist/providers/http-detect.d.ts.map +1 -0
  429. package/dist/providers/http-detect.js +307 -0
  430. package/dist/providers/http-detect.js.map +1 -0
  431. package/dist/providers/index.d.ts +38 -0
  432. package/dist/providers/index.d.ts.map +1 -0
  433. package/dist/providers/index.js +33 -0
  434. package/dist/providers/index.js.map +1 -0
  435. package/dist/providers/java.d.ts +3 -0
  436. package/dist/providers/java.d.ts.map +1 -0
  437. package/dist/providers/java.js +259 -0
  438. package/dist/providers/java.js.map +1 -0
  439. package/dist/providers/javascript.d.ts +3 -0
  440. package/dist/providers/javascript.d.ts.map +1 -0
  441. package/dist/providers/javascript.js +139 -0
  442. package/dist/providers/javascript.js.map +1 -0
  443. package/dist/providers/kotlin.d.ts +3 -0
  444. package/dist/providers/kotlin.d.ts.map +1 -0
  445. package/dist/providers/kotlin.js +175 -0
  446. package/dist/providers/kotlin.js.map +1 -0
  447. package/dist/providers/php.d.ts +3 -0
  448. package/dist/providers/php.d.ts.map +1 -0
  449. package/dist/providers/php.js +218 -0
  450. package/dist/providers/php.js.map +1 -0
  451. package/dist/providers/python-accesses.d.ts +9 -0
  452. package/dist/providers/python-accesses.d.ts.map +1 -0
  453. package/dist/providers/python-accesses.js +22 -0
  454. package/dist/providers/python-accesses.js.map +1 -0
  455. package/dist/providers/python.d.ts +3 -0
  456. package/dist/providers/python.d.ts.map +1 -0
  457. package/dist/providers/python.js +323 -0
  458. package/dist/providers/python.js.map +1 -0
  459. package/dist/providers/registry.d.ts +4 -0
  460. package/dist/providers/registry.d.ts.map +1 -0
  461. package/dist/providers/registry.js +46 -0
  462. package/dist/providers/registry.js.map +1 -0
  463. package/dist/providers/resolution/c3.d.ts +6 -0
  464. package/dist/providers/resolution/c3.d.ts.map +1 -0
  465. package/dist/providers/resolution/c3.js +76 -0
  466. package/dist/providers/resolution/c3.js.map +1 -0
  467. package/dist/providers/resolution/context.d.ts +38 -0
  468. package/dist/providers/resolution/context.d.ts.map +1 -0
  469. package/dist/providers/resolution/context.js +45 -0
  470. package/dist/providers/resolution/context.js.map +1 -0
  471. package/dist/providers/resolution/first-wins.d.ts +3 -0
  472. package/dist/providers/resolution/first-wins.d.ts.map +1 -0
  473. package/dist/providers/resolution/first-wins.js +27 -0
  474. package/dist/providers/resolution/first-wins.js.map +1 -0
  475. package/dist/providers/resolution/mro.d.ts +16 -0
  476. package/dist/providers/resolution/mro.d.ts.map +1 -0
  477. package/dist/providers/resolution/mro.js +14 -0
  478. package/dist/providers/resolution/mro.js.map +1 -0
  479. package/dist/providers/resolution/none.d.ts +3 -0
  480. package/dist/providers/resolution/none.d.ts.map +1 -0
  481. package/dist/providers/resolution/none.js +11 -0
  482. package/dist/providers/resolution/none.js.map +1 -0
  483. package/dist/providers/resolution/python-all-filter.d.ts +25 -0
  484. package/dist/providers/resolution/python-all-filter.d.ts.map +1 -0
  485. package/dist/providers/resolution/python-all-filter.js +64 -0
  486. package/dist/providers/resolution/python-all-filter.js.map +1 -0
  487. package/dist/providers/resolution/resolver-strategy.d.ts +42 -0
  488. package/dist/providers/resolution/resolver-strategy.d.ts.map +1 -0
  489. package/dist/providers/resolution/resolver-strategy.js +50 -0
  490. package/dist/providers/resolution/resolver-strategy.js.map +1 -0
  491. package/dist/providers/resolution/single-inheritance.d.ts +3 -0
  492. package/dist/providers/resolution/single-inheritance.d.ts.map +1 -0
  493. package/dist/providers/resolution/single-inheritance.js +21 -0
  494. package/dist/providers/resolution/single-inheritance.js.map +1 -0
  495. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts +16 -0
  496. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts.map +1 -0
  497. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js +50 -0
  498. package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js.map +1 -0
  499. package/dist/providers/resolution/stack-graphs/glue.d.ts +15 -0
  500. package/dist/providers/resolution/stack-graphs/glue.d.ts.map +1 -0
  501. package/dist/providers/resolution/stack-graphs/glue.js +44 -0
  502. package/dist/providers/resolution/stack-graphs/glue.js.map +1 -0
  503. package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts +30 -0
  504. package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts.map +1 -0
  505. package/dist/providers/resolution/stack-graphs/node-edge-builder.js +366 -0
  506. package/dist/providers/resolution/stack-graphs/node-edge-builder.js.map +1 -0
  507. package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts +9 -0
  508. package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts.map +1 -0
  509. package/dist/providers/resolution/stack-graphs/partial-path-engine.js +152 -0
  510. package/dist/providers/resolution/stack-graphs/partial-path-engine.js.map +1 -0
  511. package/dist/providers/resolution/stack-graphs/rule-parser.d.ts +11 -0
  512. package/dist/providers/resolution/stack-graphs/rule-parser.d.ts.map +1 -0
  513. package/dist/providers/resolution/stack-graphs/rule-parser.js +247 -0
  514. package/dist/providers/resolution/stack-graphs/rule-parser.js.map +1 -0
  515. package/dist/providers/resolution/stack-graphs/types.d.ts +93 -0
  516. package/dist/providers/resolution/stack-graphs/types.d.ts.map +1 -0
  517. package/dist/providers/resolution/stack-graphs/types.js +11 -0
  518. package/dist/providers/resolution/stack-graphs/types.js.map +1 -0
  519. package/dist/providers/resolution/stack-graphs-python.d.ts +27 -0
  520. package/dist/providers/resolution/stack-graphs-python.d.ts.map +1 -0
  521. package/dist/providers/resolution/stack-graphs-python.js +104 -0
  522. package/dist/providers/resolution/stack-graphs-python.js.map +1 -0
  523. package/dist/providers/resolution/stack-graphs-ts.d.ts +134 -0
  524. package/dist/providers/resolution/stack-graphs-ts.d.ts.map +1 -0
  525. package/dist/providers/resolution/stack-graphs-ts.js +372 -0
  526. package/dist/providers/resolution/stack-graphs-ts.js.map +1 -0
  527. package/dist/providers/ruby.d.ts +3 -0
  528. package/dist/providers/ruby.d.ts.map +1 -0
  529. package/dist/providers/ruby.js +259 -0
  530. package/dist/providers/ruby.js.map +1 -0
  531. package/dist/providers/rust.d.ts +3 -0
  532. package/dist/providers/rust.d.ts.map +1 -0
  533. package/dist/providers/rust.js +318 -0
  534. package/dist/providers/rust.js.map +1 -0
  535. package/dist/providers/swift.d.ts +3 -0
  536. package/dist/providers/swift.d.ts.map +1 -0
  537. package/dist/providers/swift.js +177 -0
  538. package/dist/providers/swift.js.map +1 -0
  539. package/dist/providers/test-helpers.d.ts +24 -0
  540. package/dist/providers/test-helpers.d.ts.map +1 -0
  541. package/dist/providers/test-helpers.js +33 -0
  542. package/dist/providers/test-helpers.js.map +1 -0
  543. package/dist/providers/ts-shared.d.ts +30 -0
  544. package/dist/providers/ts-shared.d.ts.map +1 -0
  545. package/dist/providers/ts-shared.js +328 -0
  546. package/dist/providers/ts-shared.js.map +1 -0
  547. package/dist/providers/tsx.d.ts +7 -0
  548. package/dist/providers/tsx.d.ts.map +1 -0
  549. package/dist/providers/tsx.js +79 -0
  550. package/dist/providers/tsx.js.map +1 -0
  551. package/dist/providers/types.d.ts +166 -0
  552. package/dist/providers/types.d.ts.map +1 -0
  553. package/dist/providers/types.js +7 -0
  554. package/dist/providers/types.js.map +1 -0
  555. package/dist/providers/typescript-family-accesses.d.ts +14 -0
  556. package/dist/providers/typescript-family-accesses.d.ts.map +1 -0
  557. package/dist/providers/typescript-family-accesses.js +27 -0
  558. package/dist/providers/typescript-family-accesses.js.map +1 -0
  559. package/dist/providers/typescript.d.ts +9 -0
  560. package/dist/providers/typescript.d.ts.map +1 -0
  561. package/dist/providers/typescript.js +84 -0
  562. package/dist/providers/typescript.js.map +1 -0
  563. 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,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GAAG,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,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