projscan 4.4.0 → 4.6.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 (611) hide show
  1. package/README.md +36 -12
  2. package/dist/analyzers/pythonDependencyRiskCheck.js +1 -1
  3. package/dist/analyzers/pythonDependencyRiskCheck.js.map +1 -1
  4. package/dist/cli/_shared.d.ts +4 -5
  5. package/dist/cli/_shared.js +41 -188
  6. package/dist/cli/_shared.js.map +1 -1
  7. package/dist/cli/architectureLayers.d.ts +2 -0
  8. package/dist/cli/architectureLayers.js +112 -0
  9. package/dist/cli/architectureLayers.js.map +1 -0
  10. package/dist/cli/bannerDisplay.d.ts +9 -0
  11. package/dist/cli/bannerDisplay.js +18 -0
  12. package/dist/cli/bannerDisplay.js.map +1 -0
  13. package/dist/cli/changedIssueFilter.d.ts +10 -0
  14. package/dist/cli/changedIssueFilter.js +24 -0
  15. package/dist/cli/changedIssueFilter.js.map +1 -0
  16. package/dist/cli/commandPath.d.ts +2 -0
  17. package/dist/cli/commandPath.js +12 -0
  18. package/dist/cli/commandPath.js.map +1 -0
  19. package/dist/cli/commands/agentBrief.js +11 -0
  20. package/dist/cli/commands/agentBrief.js.map +1 -1
  21. package/dist/cli/commands/analyze.js +17 -6
  22. package/dist/cli/commands/analyze.js.map +1 -1
  23. package/dist/cli/commands/ci.js +15 -3
  24. package/dist/cli/commands/ci.js.map +1 -1
  25. package/dist/cli/commands/coordinate.js +27 -0
  26. package/dist/cli/commands/coordinate.js.map +1 -1
  27. package/dist/cli/commands/doctor.js +16 -4
  28. package/dist/cli/commands/doctor.js.map +1 -1
  29. package/dist/cli/commands/upgrade.js +1 -1
  30. package/dist/cli/commands/upgrade.js.map +1 -1
  31. package/dist/cli/pluginReporter.d.ts +14 -0
  32. package/dist/cli/pluginReporter.js +46 -0
  33. package/dist/cli/pluginReporter.js.map +1 -0
  34. package/dist/cli/projectConfig.d.ts +12 -0
  35. package/dist/cli/projectConfig.js +41 -0
  36. package/dist/cli/projectConfig.js.map +1 -0
  37. package/dist/cli/treeSlice.d.ts +3 -0
  38. package/dist/cli/treeSlice.js +12 -0
  39. package/dist/cli/treeSlice.js.map +1 -0
  40. package/dist/core/ast.d.ts +4 -76
  41. package/dist/core/ast.js +11 -630
  42. package/dist/core/ast.js.map +1 -1
  43. package/dist/core/astBodySignals.d.ts +17 -0
  44. package/dist/core/astBodySignals.js +107 -0
  45. package/dist/core/astBodySignals.js.map +1 -0
  46. package/dist/core/astFunctionCollector.d.ts +11 -0
  47. package/dist/core/astFunctionCollector.js +140 -0
  48. package/dist/core/astFunctionCollector.js.map +1 -0
  49. package/dist/core/astFunctionNames.d.ts +2 -0
  50. package/dist/core/astFunctionNames.js +53 -0
  51. package/dist/core/astFunctionNames.js.map +1 -0
  52. package/dist/core/astFunctionNodes.d.ts +2 -0
  53. package/dist/core/astFunctionNodes.js +12 -0
  54. package/dist/core/astFunctionNodes.js.map +1 -0
  55. package/dist/core/astMembers.d.ts +13 -0
  56. package/dist/core/astMembers.js +116 -0
  57. package/dist/core/astMembers.js.map +1 -0
  58. package/dist/core/astModuleSignals.d.ts +3 -0
  59. package/dist/core/astModuleSignals.js +140 -0
  60. package/dist/core/astModuleSignals.js.map +1 -0
  61. package/dist/core/astParser.d.ts +11 -0
  62. package/dist/core/astParser.js +38 -0
  63. package/dist/core/astParser.js.map +1 -0
  64. package/dist/core/astProgramSignals.d.ts +11 -0
  65. package/dist/core/astProgramSignals.js +97 -0
  66. package/dist/core/astProgramSignals.js.map +1 -0
  67. package/dist/core/astTypes.d.ts +78 -0
  68. package/dist/core/astTypes.js +2 -0
  69. package/dist/core/astTypes.js.map +1 -0
  70. package/dist/core/codeGraph.d.ts +3 -28
  71. package/dist/core/codeGraph.js +3 -231
  72. package/dist/core/codeGraph.js.map +1 -1
  73. package/dist/core/codeGraphFanMetrics.d.ts +17 -0
  74. package/dist/core/codeGraphFanMetrics.js +89 -0
  75. package/dist/core/codeGraphFanMetrics.js.map +1 -0
  76. package/dist/core/codeGraphIndexes.d.ts +23 -0
  77. package/dist/core/codeGraphIndexes.js +57 -0
  78. package/dist/core/codeGraphIndexes.js.map +1 -0
  79. package/dist/core/codeGraphParsing.d.ts +20 -0
  80. package/dist/core/codeGraphParsing.js +104 -0
  81. package/dist/core/codeGraphParsing.js.map +1 -0
  82. package/dist/core/codeGraphTypes.d.ts +28 -0
  83. package/dist/core/codeGraphTypes.js +2 -0
  84. package/dist/core/codeGraphTypes.js.map +1 -0
  85. package/dist/core/collisionDetector.d.ts +2 -0
  86. package/dist/core/collisionDetector.js +17 -12
  87. package/dist/core/collisionDetector.js.map +1 -1
  88. package/dist/core/coordination.d.ts +4 -2
  89. package/dist/core/coordination.js +40 -4
  90. package/dist/core/coordination.js.map +1 -1
  91. package/dist/core/coordinationEvidence.d.ts +32 -0
  92. package/dist/core/coordinationEvidence.js +101 -0
  93. package/dist/core/coordinationEvidence.js.map +1 -0
  94. package/dist/core/dataflow.js +2 -1
  95. package/dist/core/dataflow.js.map +1 -1
  96. package/dist/core/fileAccess.d.ts +16 -0
  97. package/dist/core/fileAccess.js +78 -0
  98. package/dist/core/fileAccess.js.map +1 -0
  99. package/dist/core/fileExportTypes.d.ts +2 -0
  100. package/dist/core/fileExportTypes.js +16 -0
  101. package/dist/core/fileExportTypes.js.map +1 -0
  102. package/dist/core/fileGraphMetrics.d.ts +4 -0
  103. package/dist/core/fileGraphMetrics.js +34 -0
  104. package/dist/core/fileGraphMetrics.js.map +1 -0
  105. package/dist/core/fileInspectionEvidence.d.ts +13 -0
  106. package/dist/core/fileInspectionEvidence.js +14 -0
  107. package/dist/core/fileInspectionEvidence.js.map +1 -0
  108. package/dist/core/fileInspectionGraph.d.ts +5 -0
  109. package/dist/core/fileInspectionGraph.js +29 -0
  110. package/dist/core/fileInspectionGraph.js.map +1 -0
  111. package/dist/core/fileInspector.d.ts +4 -4
  112. package/dist/core/fileInspector.js +28 -215
  113. package/dist/core/fileInspector.js.map +1 -1
  114. package/dist/core/fileIssues.d.ts +1 -0
  115. package/dist/core/fileIssues.js +18 -0
  116. package/dist/core/fileIssues.js.map +1 -0
  117. package/dist/core/filePurpose.d.ts +2 -0
  118. package/dist/core/filePurpose.js +61 -0
  119. package/dist/core/filePurpose.js.map +1 -0
  120. package/dist/core/frameworkExpressSources.d.ts +4 -0
  121. package/dist/core/frameworkExpressSources.js +95 -0
  122. package/dist/core/frameworkExpressSources.js.map +1 -0
  123. package/dist/core/frameworkFastifySources.d.ts +4 -0
  124. package/dist/core/frameworkFastifySources.js +74 -0
  125. package/dist/core/frameworkFastifySources.js.map +1 -0
  126. package/dist/core/frameworkHonoSources.d.ts +4 -0
  127. package/dist/core/frameworkHonoSources.js +73 -0
  128. package/dist/core/frameworkHonoSources.js.map +1 -0
  129. package/dist/core/frameworkKoaSources.d.ts +4 -0
  130. package/dist/core/frameworkKoaSources.js +81 -0
  131. package/dist/core/frameworkKoaSources.js.map +1 -0
  132. package/dist/core/frameworkNextRouteSources.d.ts +2 -0
  133. package/dist/core/frameworkNextRouteSources.js +55 -0
  134. package/dist/core/frameworkNextRouteSources.js.map +1 -0
  135. package/dist/core/frameworkSources.d.ts +1 -1
  136. package/dist/core/frameworkSources.js +16 -125
  137. package/dist/core/frameworkSources.js.map +1 -1
  138. package/dist/core/hotspotAnalyzer.d.ts +2 -18
  139. package/dist/core/hotspotAnalyzer.js +15 -477
  140. package/dist/core/hotspotAnalyzer.js.map +1 -1
  141. package/dist/core/hotspotBuilder.d.ts +14 -0
  142. package/dist/core/hotspotBuilder.js +70 -0
  143. package/dist/core/hotspotBuilder.js.map +1 -0
  144. package/dist/core/hotspotCandidates.d.ts +9 -0
  145. package/dist/core/hotspotCandidates.js +63 -0
  146. package/dist/core/hotspotCandidates.js.map +1 -0
  147. package/dist/core/hotspotGit.d.ts +10 -0
  148. package/dist/core/hotspotGit.js +152 -0
  149. package/dist/core/hotspotGit.js.map +1 -0
  150. package/dist/core/hotspotIssues.d.ts +2 -0
  151. package/dist/core/hotspotIssues.js +83 -0
  152. package/dist/core/hotspotIssues.js.map +1 -0
  153. package/dist/core/hotspotLines.d.ts +2 -0
  154. package/dist/core/hotspotLines.js +24 -0
  155. package/dist/core/hotspotLines.js.map +1 -0
  156. package/dist/core/hotspotMemory.d.ts +2 -0
  157. package/dist/core/hotspotMemory.js +21 -0
  158. package/dist/core/hotspotMemory.js.map +1 -0
  159. package/dist/core/hotspotRanking.d.ts +13 -0
  160. package/dist/core/hotspotRanking.js +44 -0
  161. package/dist/core/hotspotRanking.js.map +1 -0
  162. package/dist/core/hotspotScoring.d.ts +23 -0
  163. package/dist/core/hotspotScoring.js +128 -0
  164. package/dist/core/hotspotScoring.js.map +1 -0
  165. package/dist/core/indexCache.js +4 -1
  166. package/dist/core/indexCache.js.map +1 -1
  167. package/dist/core/intentRouter.d.ts +3 -16
  168. package/dist/core/intentRouter.js +5 -7348
  169. package/dist/core/intentRouter.js.map +1 -1
  170. package/dist/core/intentRouterCatalog.d.ts +16 -0
  171. package/dist/core/intentRouterCatalog.js +1692 -0
  172. package/dist/core/intentRouterCatalog.js.map +1 -0
  173. package/dist/core/intentRouterCoordinationSignals.d.ts +12 -0
  174. package/dist/core/intentRouterCoordinationSignals.js +111 -0
  175. package/dist/core/intentRouterCoordinationSignals.js.map +1 -0
  176. package/dist/core/intentRouterDependencySignals.d.ts +9 -0
  177. package/dist/core/intentRouterDependencySignals.js +226 -0
  178. package/dist/core/intentRouterDependencySignals.js.map +1 -0
  179. package/dist/core/intentRouterKeywordContext.d.ts +14 -0
  180. package/dist/core/intentRouterKeywordContext.js +2 -0
  181. package/dist/core/intentRouterKeywordContext.js.map +1 -0
  182. package/dist/core/intentRouterKeywordEarlyGuards.d.ts +2 -0
  183. package/dist/core/intentRouterKeywordEarlyGuards.js +127 -0
  184. package/dist/core/intentRouterKeywordEarlyGuards.js.map +1 -0
  185. package/dist/core/intentRouterKeywordMatches.d.ts +3 -0
  186. package/dist/core/intentRouterKeywordMatches.js +31 -0
  187. package/dist/core/intentRouterKeywordMatches.js.map +1 -0
  188. package/dist/core/intentRouterKeywordSearchGuards.d.ts +2 -0
  189. package/dist/core/intentRouterKeywordSearchGuards.js +239 -0
  190. package/dist/core/intentRouterKeywordSearchGuards.js.map +1 -0
  191. package/dist/core/intentRouterKeywordTargetGuards.d.ts +2 -0
  192. package/dist/core/intentRouterKeywordTargetGuards.js +191 -0
  193. package/dist/core/intentRouterKeywordTargetGuards.js.map +1 -0
  194. package/dist/core/intentRouterKeywordToolGuards.d.ts +2 -0
  195. package/dist/core/intentRouterKeywordToolGuards.js +133 -0
  196. package/dist/core/intentRouterKeywordToolGuards.js.map +1 -0
  197. package/dist/core/intentRouterKeywordWeights.d.ts +4 -0
  198. package/dist/core/intentRouterKeywordWeights.js +1184 -0
  199. package/dist/core/intentRouterKeywordWeights.js.map +1 -0
  200. package/dist/core/intentRouterPlanningSignals.d.ts +7 -0
  201. package/dist/core/intentRouterPlanningSignals.js +268 -0
  202. package/dist/core/intentRouterPlanningSignals.js.map +1 -0
  203. package/dist/core/intentRouterPrDiffSignals.d.ts +1 -0
  204. package/dist/core/intentRouterPrDiffSignals.js +41 -0
  205. package/dist/core/intentRouterPrDiffSignals.js.map +1 -0
  206. package/dist/core/intentRouterPreflightSignals.d.ts +3 -0
  207. package/dist/core/intentRouterPreflightSignals.js +54 -0
  208. package/dist/core/intentRouterPreflightSignals.js.map +1 -0
  209. package/dist/core/intentRouterRegressionKeywordMatches.d.ts +1 -0
  210. package/dist/core/intentRouterRegressionKeywordMatches.js +176 -0
  211. package/dist/core/intentRouterRegressionKeywordMatches.js.map +1 -0
  212. package/dist/core/intentRouterRegressionSignals.d.ts +10 -0
  213. package/dist/core/intentRouterRegressionSignals.js +207 -0
  214. package/dist/core/intentRouterRegressionSignals.js.map +1 -0
  215. package/dist/core/intentRouterReleaseSignals.d.ts +8 -0
  216. package/dist/core/intentRouterReleaseSignals.js +59 -0
  217. package/dist/core/intentRouterReleaseSignals.js.map +1 -0
  218. package/dist/core/intentRouterRepoSignals.d.ts +8 -0
  219. package/dist/core/intentRouterRepoSignals.js +226 -0
  220. package/dist/core/intentRouterRepoSignals.js.map +1 -0
  221. package/dist/core/intentRouterReviewSignals.d.ts +2 -0
  222. package/dist/core/intentRouterReviewSignals.js +109 -0
  223. package/dist/core/intentRouterReviewSignals.js.map +1 -0
  224. package/dist/core/intentRouterRiskSignals.d.ts +12 -0
  225. package/dist/core/intentRouterRiskSignals.js +242 -0
  226. package/dist/core/intentRouterRiskSignals.js.map +1 -0
  227. package/dist/core/intentRouterScoring.d.ts +9 -0
  228. package/dist/core/intentRouterScoring.js +40 -0
  229. package/dist/core/intentRouterScoring.js.map +1 -0
  230. package/dist/core/intentRouterSearchApiSignals.d.ts +1 -0
  231. package/dist/core/intentRouterSearchApiSignals.js +62 -0
  232. package/dist/core/intentRouterSearchApiSignals.js.map +1 -0
  233. package/dist/core/intentRouterSearchBackgroundSignals.d.ts +1 -0
  234. package/dist/core/intentRouterSearchBackgroundSignals.js +55 -0
  235. package/dist/core/intentRouterSearchBackgroundSignals.js.map +1 -0
  236. package/dist/core/intentRouterSearchCommunicationSignals.d.ts +1 -0
  237. package/dist/core/intentRouterSearchCommunicationSignals.js +74 -0
  238. package/dist/core/intentRouterSearchCommunicationSignals.js.map +1 -0
  239. package/dist/core/intentRouterSearchDataSignals.d.ts +2 -0
  240. package/dist/core/intentRouterSearchDataSignals.js +98 -0
  241. package/dist/core/intentRouterSearchDataSignals.js.map +1 -0
  242. package/dist/core/intentRouterSearchDomainSignals.d.ts +1 -0
  243. package/dist/core/intentRouterSearchDomainSignals.js +71 -0
  244. package/dist/core/intentRouterSearchDomainSignals.js.map +1 -0
  245. package/dist/core/intentRouterSearchInfraSignals.d.ts +1 -0
  246. package/dist/core/intentRouterSearchInfraSignals.js +79 -0
  247. package/dist/core/intentRouterSearchInfraSignals.js.map +1 -0
  248. package/dist/core/intentRouterSearchIntegrationSignals.d.ts +1 -0
  249. package/dist/core/intentRouterSearchIntegrationSignals.js +117 -0
  250. package/dist/core/intentRouterSearchIntegrationSignals.js.map +1 -0
  251. package/dist/core/intentRouterSearchLookupSignals.d.ts +10 -0
  252. package/dist/core/intentRouterSearchLookupSignals.js +310 -0
  253. package/dist/core/intentRouterSearchLookupSignals.js.map +1 -0
  254. package/dist/core/intentRouterSearchNavigationSignals.d.ts +1 -0
  255. package/dist/core/intentRouterSearchNavigationSignals.js +62 -0
  256. package/dist/core/intentRouterSearchNavigationSignals.js.map +1 -0
  257. package/dist/core/intentRouterSearchOwnershipSignals.d.ts +1 -0
  258. package/dist/core/intentRouterSearchOwnershipSignals.js +15 -0
  259. package/dist/core/intentRouterSearchOwnershipSignals.js.map +1 -0
  260. package/dist/core/intentRouterSearchPageSignals.d.ts +1 -0
  261. package/dist/core/intentRouterSearchPageSignals.js +84 -0
  262. package/dist/core/intentRouterSearchPageSignals.js.map +1 -0
  263. package/dist/core/intentRouterSearchReliabilitySignals.d.ts +1 -0
  264. package/dist/core/intentRouterSearchReliabilitySignals.js +94 -0
  265. package/dist/core/intentRouterSearchReliabilitySignals.js.map +1 -0
  266. package/dist/core/intentRouterSearchStateSignals.d.ts +1 -0
  267. package/dist/core/intentRouterSearchStateSignals.js +107 -0
  268. package/dist/core/intentRouterSearchStateSignals.js.map +1 -0
  269. package/dist/core/intentRouterSearchStyleSignals.d.ts +1 -0
  270. package/dist/core/intentRouterSearchStyleSignals.js +99 -0
  271. package/dist/core/intentRouterSearchStyleSignals.js.map +1 -0
  272. package/dist/core/intentRouterSearchTestSignals.d.ts +1 -0
  273. package/dist/core/intentRouterSearchTestSignals.js +34 -0
  274. package/dist/core/intentRouterSearchTestSignals.js.map +1 -0
  275. package/dist/core/intentRouterSearchToolingSignals.d.ts +1 -0
  276. package/dist/core/intentRouterSearchToolingSignals.js +106 -0
  277. package/dist/core/intentRouterSearchToolingSignals.js.map +1 -0
  278. package/dist/core/intentRouterSearchUiSignals.d.ts +1 -0
  279. package/dist/core/intentRouterSearchUiSignals.js +77 -0
  280. package/dist/core/intentRouterSearchUiSignals.js.map +1 -0
  281. package/dist/core/intentRouterSecuritySignals.d.ts +4 -0
  282. package/dist/core/intentRouterSecuritySignals.js +235 -0
  283. package/dist/core/intentRouterSecuritySignals.js.map +1 -0
  284. package/dist/core/intentRouterTargetSignals.d.ts +5 -0
  285. package/dist/core/intentRouterTargetSignals.js +76 -0
  286. package/dist/core/intentRouterTargetSignals.js.map +1 -0
  287. package/dist/core/intentRouterTokens.d.ts +1 -0
  288. package/dist/core/intentRouterTokens.js +36 -0
  289. package/dist/core/intentRouterTokens.js.map +1 -0
  290. package/dist/core/intentRouterUnderstandSignals.d.ts +1 -0
  291. package/dist/core/intentRouterUnderstandSignals.js +171 -0
  292. package/dist/core/intentRouterUnderstandSignals.js.map +1 -0
  293. package/dist/core/intentRouterVerificationSignals.d.ts +8 -0
  294. package/dist/core/intentRouterVerificationSignals.js +119 -0
  295. package/dist/core/intentRouterVerificationSignals.js.map +1 -0
  296. package/dist/core/intentRouterWorkSignals.d.ts +4 -0
  297. package/dist/core/intentRouterWorkSignals.js +157 -0
  298. package/dist/core/intentRouterWorkSignals.js.map +1 -0
  299. package/dist/core/languages/pythonLockfiles.d.ts +11 -0
  300. package/dist/core/languages/pythonLockfiles.js +206 -0
  301. package/dist/core/languages/pythonLockfiles.js.map +1 -0
  302. package/dist/core/languages/pythonManifestText.d.ts +7 -0
  303. package/dist/core/languages/pythonManifestText.js +25 -0
  304. package/dist/core/languages/pythonManifestText.js.map +1 -0
  305. package/dist/core/languages/pythonManifests.d.ts +6 -27
  306. package/dist/core/languages/pythonManifests.js +29 -303
  307. package/dist/core/languages/pythonManifests.js.map +1 -1
  308. package/dist/core/languages/pythonPep508.d.ts +4 -0
  309. package/dist/core/languages/pythonPep508.js +14 -0
  310. package/dist/core/languages/pythonPep508.js.map +1 -0
  311. package/dist/core/languages/pythonProjectEvidence.d.ts +2 -0
  312. package/dist/core/languages/pythonProjectEvidence.js +29 -0
  313. package/dist/core/languages/pythonProjectEvidence.js.map +1 -0
  314. package/dist/core/languages/pythonProjectTypes.d.ts +31 -0
  315. package/dist/core/languages/pythonProjectTypes.js +2 -0
  316. package/dist/core/languages/pythonProjectTypes.js.map +1 -0
  317. package/dist/core/languages/pythonPyproject.d.ts +2 -0
  318. package/dist/core/languages/pythonPyproject.js +160 -0
  319. package/dist/core/languages/pythonPyproject.js.map +1 -0
  320. package/dist/core/languages/pythonRequirements.d.ts +9 -0
  321. package/dist/core/languages/pythonRequirements.js +86 -0
  322. package/dist/core/languages/pythonRequirements.js.map +1 -0
  323. package/dist/core/languages/pythonRoots.d.ts +3 -0
  324. package/dist/core/languages/pythonRoots.js +83 -0
  325. package/dist/core/languages/pythonRoots.js.map +1 -0
  326. package/dist/core/languages/pythonSetuptools.d.ts +6 -0
  327. package/dist/core/languages/pythonSetuptools.js +58 -0
  328. package/dist/core/languages/pythonSetuptools.js.map +1 -0
  329. package/dist/core/prDiff.js +12 -0
  330. package/dist/core/prDiff.js.map +1 -1
  331. package/dist/core/preflight.d.ts +3 -3
  332. package/dist/core/preflight.js +28 -542
  333. package/dist/core/preflight.js.map +1 -1
  334. package/dist/core/preflightChangedFileReasons.d.ts +14 -0
  335. package/dist/core/preflightChangedFileReasons.js +75 -0
  336. package/dist/core/preflightChangedFileReasons.js.map +1 -0
  337. package/dist/core/preflightChangedFiles.d.ts +9 -0
  338. package/dist/core/preflightChangedFiles.js +34 -0
  339. package/dist/core/preflightChangedFiles.js.map +1 -0
  340. package/dist/core/preflightContextReasons.d.ts +17 -0
  341. package/dist/core/preflightContextReasons.js +73 -0
  342. package/dist/core/preflightContextReasons.js.map +1 -0
  343. package/dist/core/preflightEvidence.d.ts +34 -0
  344. package/dist/core/preflightEvidence.js +119 -0
  345. package/dist/core/preflightEvidence.js.map +1 -0
  346. package/dist/core/preflightInputs.d.ts +15 -0
  347. package/dist/core/preflightInputs.js +31 -0
  348. package/dist/core/preflightInputs.js.map +1 -0
  349. package/dist/core/preflightIssueReasons.d.ts +2 -0
  350. package/dist/core/preflightIssueReasons.js +39 -0
  351. package/dist/core/preflightIssueReasons.js.map +1 -0
  352. package/dist/core/preflightLocalEvidence.d.ts +12 -0
  353. package/dist/core/preflightLocalEvidence.js +36 -0
  354. package/dist/core/preflightLocalEvidence.js.map +1 -0
  355. package/dist/core/preflightReleaseScale.d.ts +28 -0
  356. package/dist/core/preflightReleaseScale.js +95 -0
  357. package/dist/core/preflightReleaseScale.js.map +1 -0
  358. package/dist/core/preflightRequiredChecks.d.ts +26 -0
  359. package/dist/core/preflightRequiredChecks.js +96 -0
  360. package/dist/core/preflightRequiredChecks.js.map +1 -0
  361. package/dist/core/preflightReviewEvidence.d.ts +16 -0
  362. package/dist/core/preflightReviewEvidence.js +31 -0
  363. package/dist/core/preflightReviewEvidence.js.map +1 -0
  364. package/dist/core/preflightReviewReasons.d.ts +15 -0
  365. package/dist/core/preflightReviewReasons.js +76 -0
  366. package/dist/core/preflightReviewReasons.js.map +1 -0
  367. package/dist/core/preflightSuggestedActions.d.ts +15 -0
  368. package/dist/core/preflightSuggestedActions.js +84 -0
  369. package/dist/core/preflightSuggestedActions.js.map +1 -0
  370. package/dist/core/preflightTruncation.d.ts +6 -0
  371. package/dist/core/preflightTruncation.js +7 -0
  372. package/dist/core/preflightTruncation.js.map +1 -0
  373. package/dist/core/preflightVerdict.d.ts +3 -0
  374. package/dist/core/preflightVerdict.js +17 -0
  375. package/dist/core/preflightVerdict.js.map +1 -0
  376. package/dist/core/releaseEvidence.d.ts +4 -3
  377. package/dist/core/releaseEvidence.js +12 -263
  378. package/dist/core/releaseEvidence.js.map +1 -1
  379. package/dist/core/releaseEvidenceBaseline.d.ts +2 -0
  380. package/dist/core/releaseEvidenceBaseline.js +28 -0
  381. package/dist/core/releaseEvidenceBaseline.js.map +1 -0
  382. package/dist/core/releaseEvidencePrSummary.d.ts +13 -0
  383. package/dist/core/releaseEvidencePrSummary.js +240 -0
  384. package/dist/core/releaseEvidencePrSummary.js.map +1 -0
  385. package/dist/core/releaseTrain.js +3 -317
  386. package/dist/core/releaseTrain.js.map +1 -1
  387. package/dist/core/releaseTrainFallbacks.d.ts +3 -0
  388. package/dist/core/releaseTrainFallbacks.js +318 -0
  389. package/dist/core/releaseTrainFallbacks.js.map +1 -0
  390. package/dist/core/reportScope.d.ts +24 -0
  391. package/dist/core/reportScope.js +234 -0
  392. package/dist/core/reportScope.js.map +1 -0
  393. package/dist/core/review.d.ts +2 -25
  394. package/dist/core/review.js +34 -1034
  395. package/dist/core/review.js.map +1 -1
  396. package/dist/core/reviewBaseSnapshot.d.ts +14 -0
  397. package/dist/core/reviewBaseSnapshot.js +41 -0
  398. package/dist/core/reviewBaseSnapshot.js.map +1 -0
  399. package/dist/core/reviewChangedFiles.d.ts +8 -0
  400. package/dist/core/reviewChangedFiles.js +63 -0
  401. package/dist/core/reviewChangedFiles.js.map +1 -0
  402. package/dist/core/reviewContractChanges.d.ts +5 -0
  403. package/dist/core/reviewContractChanges.js +114 -0
  404. package/dist/core/reviewContractChanges.js.map +1 -0
  405. package/dist/core/reviewCycles.d.ts +7 -0
  406. package/dist/core/reviewCycles.js +53 -0
  407. package/dist/core/reviewCycles.js.map +1 -0
  408. package/dist/core/reviewFindings.d.ts +17 -0
  409. package/dist/core/reviewFindings.js +49 -0
  410. package/dist/core/reviewFindings.js.map +1 -0
  411. package/dist/core/reviewFlowDiffs.d.ts +4 -0
  412. package/dist/core/reviewFlowDiffs.js +99 -0
  413. package/dist/core/reviewFlowDiffs.js.map +1 -0
  414. package/dist/core/reviewGit.d.ts +7 -0
  415. package/dist/core/reviewGit.js +45 -0
  416. package/dist/core/reviewGit.js.map +1 -0
  417. package/dist/core/reviewGraphEvidence.d.ts +3 -0
  418. package/dist/core/reviewGraphEvidence.js +55 -0
  419. package/dist/core/reviewGraphEvidence.js.map +1 -0
  420. package/dist/core/reviewHeadSnapshot.d.ts +8 -0
  421. package/dist/core/reviewHeadSnapshot.js +15 -0
  422. package/dist/core/reviewHeadSnapshot.js.map +1 -0
  423. package/dist/core/reviewIntent.d.ts +2 -0
  424. package/dist/core/reviewIntent.js +18 -0
  425. package/dist/core/reviewIntent.js.map +1 -0
  426. package/dist/core/reviewManifests.d.ts +12 -0
  427. package/dist/core/reviewManifests.js +124 -0
  428. package/dist/core/reviewManifests.js.map +1 -0
  429. package/dist/core/reviewNoChanges.d.ts +9 -0
  430. package/dist/core/reviewNoChanges.js +26 -0
  431. package/dist/core/reviewNoChanges.js.map +1 -0
  432. package/dist/core/reviewPackageScope.d.ts +4 -0
  433. package/dist/core/reviewPackageScope.js +24 -0
  434. package/dist/core/reviewPackageScope.js.map +1 -0
  435. package/dist/core/reviewRefs.d.ts +4 -0
  436. package/dist/core/reviewRefs.js +65 -0
  437. package/dist/core/reviewRefs.js.map +1 -0
  438. package/dist/core/reviewRiskyFunctions.d.ts +8 -0
  439. package/dist/core/reviewRiskyFunctions.js +83 -0
  440. package/dist/core/reviewRiskyFunctions.js.map +1 -0
  441. package/dist/core/reviewState.d.ts +21 -0
  442. package/dist/core/reviewState.js +96 -0
  443. package/dist/core/reviewState.js.map +1 -0
  444. package/dist/core/reviewTier.d.ts +18 -0
  445. package/dist/core/reviewTier.js +99 -0
  446. package/dist/core/reviewTier.js.map +1 -0
  447. package/dist/core/reviewVerdict.d.ts +9 -0
  448. package/dist/core/reviewVerdict.js +121 -0
  449. package/dist/core/reviewVerdict.js.map +1 -0
  450. package/dist/core/roadmapCatalog.d.ts +1 -0
  451. package/dist/core/roadmapCatalog.js +227 -7
  452. package/dist/core/roadmapCatalog.js.map +1 -1
  453. package/dist/core/start.d.ts +1 -1
  454. package/dist/core/start.js +26 -63
  455. package/dist/core/start.js.map +1 -1
  456. package/dist/core/startAdoptionGaps.d.ts +3 -0
  457. package/dist/core/startAdoptionGaps.js +12 -0
  458. package/dist/core/startAdoptionGaps.js.map +1 -0
  459. package/dist/core/startInputs.d.ts +31 -0
  460. package/dist/core/startInputs.js +27 -0
  461. package/dist/core/startInputs.js.map +1 -0
  462. package/dist/core/startMode.js +7 -1
  463. package/dist/core/startMode.js.map +1 -1
  464. package/dist/core/startNextActions.d.ts +13 -0
  465. package/dist/core/startNextActions.js +19 -0
  466. package/dist/core/startNextActions.js.map +1 -0
  467. package/dist/core/startReportBuilder.d.ts +25 -0
  468. package/dist/core/startReportBuilder.js +44 -0
  469. package/dist/core/startReportBuilder.js.map +1 -0
  470. package/dist/core/taint.js +14 -125
  471. package/dist/core/taint.js.map +1 -1
  472. package/dist/core/taintMatching.d.ts +11 -0
  473. package/dist/core/taintMatching.js +126 -0
  474. package/dist/core/taintMatching.js.map +1 -0
  475. package/dist/core/upgradePreview.d.ts +1 -12
  476. package/dist/core/upgradePreview.js +12 -160
  477. package/dist/core/upgradePreview.js.map +1 -1
  478. package/dist/core/upgradePreviewNpmEvidence.d.ts +19 -0
  479. package/dist/core/upgradePreviewNpmEvidence.js +164 -0
  480. package/dist/core/upgradePreviewNpmEvidence.js.map +1 -0
  481. package/dist/core/upgradePreviewPython.d.ts +2 -0
  482. package/dist/core/upgradePreviewPython.js +71 -0
  483. package/dist/core/upgradePreviewPython.js.map +1 -0
  484. package/dist/index.d.ts +6 -12
  485. package/dist/index.js +2 -3
  486. package/dist/index.js.map +1 -1
  487. package/dist/mcp/server.d.ts +3 -24
  488. package/dist/mcp/server.js +32 -414
  489. package/dist/mcp/server.js.map +1 -1
  490. package/dist/mcp/serverContext.d.ts +6 -0
  491. package/dist/mcp/serverContext.js +55 -0
  492. package/dist/mcp/serverContext.js.map +1 -0
  493. package/dist/mcp/serverDispatch.d.ts +39 -0
  494. package/dist/mcp/serverDispatch.js +74 -0
  495. package/dist/mcp/serverDispatch.js.map +1 -0
  496. package/dist/mcp/serverHandlers.d.ts +15 -0
  497. package/dist/mcp/serverHandlers.js +94 -0
  498. package/dist/mcp/serverHandlers.js.map +1 -0
  499. package/dist/mcp/serverLifecycle.d.ts +14 -0
  500. package/dist/mcp/serverLifecycle.js +65 -0
  501. package/dist/mcp/serverLifecycle.js.map +1 -0
  502. package/dist/mcp/serverMessage.d.ts +11 -0
  503. package/dist/mcp/serverMessage.js +37 -0
  504. package/dist/mcp/serverMessage.js.map +1 -0
  505. package/dist/mcp/serverSession.d.ts +6 -0
  506. package/dist/mcp/serverSession.js +77 -0
  507. package/dist/mcp/serverSession.js.map +1 -0
  508. package/dist/mcp/serverStdio.d.ts +7 -0
  509. package/dist/mcp/serverStdio.js +34 -0
  510. package/dist/mcp/serverStdio.js.map +1 -0
  511. package/dist/mcp/serverTypes.d.ts +18 -0
  512. package/dist/mcp/serverTypes.js +2 -0
  513. package/dist/mcp/serverTypes.js.map +1 -0
  514. package/dist/mcp/serverVersion.d.ts +1 -0
  515. package/dist/mcp/serverVersion.js +17 -0
  516. package/dist/mcp/serverVersion.js.map +1 -0
  517. package/dist/mcp/toolCatalog.d.ts +2 -0
  518. package/dist/mcp/toolCatalog.js +93 -0
  519. package/dist/mcp/toolCatalog.js.map +1 -0
  520. package/dist/mcp/tools/upgrade.d.ts +1 -1
  521. package/dist/mcp/tools/upgrade.js +2 -16
  522. package/dist/mcp/tools/upgrade.js.map +1 -1
  523. package/dist/mcp/tools.d.ts +2 -3
  524. package/dist/mcp/tools.js +5 -97
  525. package/dist/mcp/tools.js.map +1 -1
  526. package/dist/projscan-sbom.cdx.json +6 -6
  527. package/dist/reporters/consoleUpgradeReporter.js +24 -2
  528. package/dist/reporters/consoleUpgradeReporter.js.map +1 -1
  529. package/dist/reporters/htmlReporter.d.ts +3 -2
  530. package/dist/reporters/htmlReporter.js +14 -2
  531. package/dist/reporters/htmlReporter.js.map +1 -1
  532. package/dist/reporters/jsonReporter.d.ts +4 -3
  533. package/dist/reporters/jsonReporter.js +9 -4
  534. package/dist/reporters/jsonReporter.js.map +1 -1
  535. package/dist/reporters/markdownAnalysisReporter.d.ts +2 -1
  536. package/dist/reporters/markdownAnalysisReporter.js +8 -1
  537. package/dist/reporters/markdownAnalysisReporter.js.map +1 -1
  538. package/dist/reporters/markdownArchitectureReporter.d.ts +3 -0
  539. package/dist/reporters/markdownArchitectureReporter.js +33 -0
  540. package/dist/reporters/markdownArchitectureReporter.js.map +1 -0
  541. package/dist/reporters/markdownCouplingReporter.d.ts +2 -0
  542. package/dist/reporters/markdownCouplingReporter.js +43 -0
  543. package/dist/reporters/markdownCouplingReporter.js.map +1 -0
  544. package/dist/reporters/markdownCoverageReporter.d.ts +2 -0
  545. package/dist/reporters/markdownCoverageReporter.js +40 -0
  546. package/dist/reporters/markdownCoverageReporter.js.map +1 -0
  547. package/dist/reporters/markdownExplanationReporter.d.ts +2 -0
  548. package/dist/reporters/markdownExplanationReporter.js +37 -0
  549. package/dist/reporters/markdownExplanationReporter.js.map +1 -0
  550. package/dist/reporters/markdownHealthReporter.d.ts +4 -0
  551. package/dist/reporters/markdownHealthReporter.js +66 -0
  552. package/dist/reporters/markdownHealthReporter.js.map +1 -0
  553. package/dist/reporters/markdownHotspotReporter.d.ts +2 -0
  554. package/dist/reporters/markdownHotspotReporter.js +36 -0
  555. package/dist/reporters/markdownHotspotReporter.js.map +1 -0
  556. package/dist/reporters/markdownOutdatedReporter.d.ts +2 -0
  557. package/dist/reporters/markdownOutdatedReporter.js +31 -0
  558. package/dist/reporters/markdownOutdatedReporter.js.map +1 -0
  559. package/dist/reporters/markdownPrDiffReporter.d.ts +2 -0
  560. package/dist/reporters/markdownPrDiffReporter.js +63 -0
  561. package/dist/reporters/markdownPrDiffReporter.js.map +1 -0
  562. package/dist/reporters/markdownReporter.d.ts +9 -12
  563. package/dist/reporters/markdownReporter.js +9 -288
  564. package/dist/reporters/markdownReporter.js.map +1 -1
  565. package/dist/reporters/markdownUpgradeReporter.js +19 -4
  566. package/dist/reporters/markdownUpgradeReporter.js.map +1 -1
  567. package/dist/reporters/markdownWorkspaceReporter.d.ts +2 -0
  568. package/dist/reporters/markdownWorkspaceReporter.js +25 -0
  569. package/dist/reporters/markdownWorkspaceReporter.js.map +1 -0
  570. package/dist/reporters/sarifReporter.d.ts +6 -4
  571. package/dist/reporters/sarifReporter.js +8 -7
  572. package/dist/reporters/sarifReporter.js.map +1 -1
  573. package/dist/tool-manifest.json +4 -4
  574. package/dist/types/config.d.ts +10 -0
  575. package/dist/types/dependencyHealth.d.ts +12 -0
  576. package/dist/types.d.ts +34 -34
  577. package/dist/utils/config.d.ts +2 -8
  578. package/dist/utils/config.js +14 -180
  579. package/dist/utils/config.js.map +1 -1
  580. package/dist/utils/configBasics.d.ts +5 -0
  581. package/dist/utils/configBasics.js +21 -0
  582. package/dist/utils/configBasics.js.map +1 -0
  583. package/dist/utils/configHotspots.d.ts +2 -0
  584. package/dist/utils/configHotspots.js +15 -0
  585. package/dist/utils/configHotspots.js.map +1 -0
  586. package/dist/utils/configIssueRules.d.ts +8 -0
  587. package/dist/utils/configIssueRules.js +24 -0
  588. package/dist/utils/configIssueRules.js.map +1 -0
  589. package/dist/utils/configMonorepo.d.ts +2 -0
  590. package/dist/utils/configMonorepo.js +38 -0
  591. package/dist/utils/configMonorepo.js.map +1 -0
  592. package/dist/utils/configReportPolicies.d.ts +2 -0
  593. package/dist/utils/configReportPolicies.js +32 -0
  594. package/dist/utils/configReportPolicies.js.map +1 -0
  595. package/dist/utils/configScan.d.ts +2 -0
  596. package/dist/utils/configScan.js +15 -0
  597. package/dist/utils/configScan.js.map +1 -0
  598. package/dist/utils/configSeverity.d.ts +2 -0
  599. package/dist/utils/configSeverity.js +15 -0
  600. package/dist/utils/configSeverity.js.map +1 -0
  601. package/dist/utils/configSources.d.ts +5 -0
  602. package/dist/utils/configSources.js +55 -0
  603. package/dist/utils/configSources.js.map +1 -0
  604. package/dist/utils/configTaint.d.ts +2 -0
  605. package/dist/utils/configTaint.js +15 -0
  606. package/dist/utils/configTaint.js.map +1 -0
  607. package/docs/GUIDE.md +39 -4
  608. package/docs/ROADMAP.md +54 -21
  609. package/docs/examples/adoption-workflows.md +128 -0
  610. package/docs/examples/swarm-coordination.md +120 -0
  611. package/package.json +3 -1
package/dist/core/ast.js CHANGED
@@ -1,5 +1,7 @@
1
- import { parse } from '@babel/parser';
2
- import path from 'node:path';
1
+ import { extractFunctionsFromBabel } from './astFunctionCollector.js';
2
+ import { visitTopLevel } from './astModuleSignals.js';
3
+ import { isParseable, parseBabelFile } from './astParser.js';
4
+ import { collectProgramSignals } from './astProgramSignals.js';
3
5
  const EMPTY = {
4
6
  ok: false,
5
7
  reason: 'unparsed',
@@ -10,15 +12,11 @@ const EMPTY = {
10
12
  cyclomaticComplexity: 0,
11
13
  functions: [],
12
14
  };
13
- const SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts']);
14
- /** Is this a file we should try to AST-parse at all? */
15
- export function isParseable(filePath) {
16
- return SOURCE_EXTENSIONS.has(path.extname(filePath).toLowerCase());
17
- }
15
+ export { isParseable } from './astParser.js';
18
16
  /**
19
17
  * Parse a source file and extract imports, exports, and call sites.
20
18
  *
21
- * Uses @babel/parser with generous options so we accept real-world code:
19
+ * Uses the Babel parser helper with generous options so we accept real-world code:
22
20
  * TypeScript, JSX, decorators, top-level await, class properties, etc.
23
21
  *
24
22
  * Failures return ok:false with a reason - callers decide whether to fall
@@ -28,77 +26,17 @@ export function parseSource(filePath, content) {
28
26
  if (!isParseable(filePath)) {
29
27
  return { ...EMPTY, reason: 'non-source extension' };
30
28
  }
31
- const ext = path.extname(filePath).toLowerCase();
32
- const isTypeScript = ext === '.ts' || ext === '.tsx' || ext === '.mts' || ext === '.cts';
33
- const isJSX = ext === '.tsx' || ext === '.jsx';
34
- const plugins = [];
35
- if (isTypeScript)
36
- plugins.push('typescript');
37
- if (isJSX)
38
- plugins.push('jsx');
39
- plugins.push('decorators-legacy', 'dynamicImport', 'topLevelAwait');
40
- let ast;
41
- try {
42
- ast = parse(content, {
43
- sourceType: 'module',
44
- allowImportExportEverywhere: true,
45
- allowAwaitOutsideFunction: true,
46
- allowReturnOutsideFunction: true,
47
- allowSuperOutsideMethod: true,
48
- errorRecovery: true,
49
- plugins,
50
- });
51
- }
52
- catch (err) {
53
- const msg = err instanceof Error ? err.message : String(err);
54
- return { ...EMPTY, reason: `parse error: ${msg.slice(0, 120)}` };
55
- }
29
+ const parsed = parseBabelFile(filePath, content);
30
+ if (!parsed.ok)
31
+ return { ...EMPTY, reason: parsed.reason };
32
+ const ast = parsed.ast;
56
33
  const imports = [];
57
34
  const exports = [];
58
35
  const callSites = [];
59
- let decisionPoints = 0;
60
36
  for (const node of ast.program.body) {
61
37
  visitTopLevel(node, imports, exports);
62
38
  }
63
- // Second pass: extract dynamic imports + call sites + cyclomatic decision
64
- // points. Walk the whole tree (cheap - we already have the AST in memory).
65
- walk(ast.program, (n) => {
66
- if (n.type === 'CallExpression') {
67
- const callee = n.callee;
68
- if (callee.type === 'Identifier') {
69
- callSites.push(callee.name);
70
- }
71
- else if (callee.type === 'MemberExpression' && callee.property.type === 'Identifier') {
72
- callSites.push(callee.property.name);
73
- }
74
- else if (callee.type === 'Import' &&
75
- n.arguments[0] &&
76
- n.arguments[0].type === 'StringLiteral') {
77
- imports.push({
78
- source: n.arguments[0].value,
79
- kind: 'dynamic',
80
- specifiers: [],
81
- typeOnly: false,
82
- line: n.loc?.start.line ?? 0,
83
- });
84
- }
85
- // CommonJS require()
86
- if (callee.type === 'Identifier' &&
87
- callee.name === 'require' &&
88
- n.arguments[0] &&
89
- n.arguments[0].type === 'StringLiteral') {
90
- imports.push({
91
- source: n.arguments[0].value,
92
- kind: 'require',
93
- specifiers: [],
94
- typeOnly: false,
95
- line: n.loc?.start.line ?? 0,
96
- });
97
- }
98
- }
99
- if (isDecisionPoint(n))
100
- decisionPoints++;
101
- });
39
+ const decisionPoints = collectProgramSignals(ast.program, imports, callSites);
102
40
  const functions = extractFunctionsFromBabel(ast.program);
103
41
  return {
104
42
  ok: true,
@@ -110,561 +48,4 @@ export function parseSource(filePath, content) {
110
48
  functions,
111
49
  };
112
50
  }
113
- /**
114
- * Walk a Babel program and emit one FunctionInfo per function-like node:
115
- * FunctionDeclaration, FunctionExpression, ArrowFunctionExpression,
116
- * ClassMethod, ObjectMethod. Each function's CC is computed over its own
117
- * body only - decision points inside a nested function belong to that
118
- * nested function, not its parent. This matches eslint's `complexity` rule
119
- * and most static analyzers.
120
- */
121
- function extractFunctionsFromBabel(program) {
122
- const out = [];
123
- collectFunctions(program, null, null, out, null);
124
- return out;
125
- }
126
- const FUNCTION_TYPES = new Set([
127
- 'FunctionDeclaration',
128
- 'FunctionExpression',
129
- 'ArrowFunctionExpression',
130
- 'ClassMethod',
131
- 'ObjectMethod',
132
- 'ClassPrivateMethod',
133
- ]);
134
- function isFunctionNode(n) {
135
- return FUNCTION_TYPES.has(n.type);
136
- }
137
- function collectFunctions(node, parentClassName, bindingName, out, contextualCallSite) {
138
- if (!node || typeof node !== 'object')
139
- return;
140
- if (isFunctionNode(node)) {
141
- const name = nameForFunctionNode(node, parentClassName, bindingName);
142
- const line = node.loc?.start.line ?? 0;
143
- const endLine = node.loc?.end.line ?? line;
144
- const { cc, callSites, memberCallSites, directCallSites, memberAliases, references } = analyzeBabelBody(node);
145
- const parameters = functionParamNames(node);
146
- out.push({
147
- name,
148
- line,
149
- endLine,
150
- cyclomaticComplexity: cc,
151
- callSites,
152
- memberCallSites,
153
- directCallSites,
154
- memberAliases,
155
- parameters,
156
- ...(contextualCallSite ? { contextualCallSite } : {}),
157
- references,
158
- });
159
- // Recurse into nested functions so they emit their own entries. The body
160
- // walker (`countCcInBody`) skips nested functions for CC, but we still need
161
- // to descend the whole tree to find all functions.
162
- descendForNestedFunctions(node, parentClassName, out);
163
- return;
164
- }
165
- // Track context so nested functions get a useful name.
166
- if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression') {
167
- const className = node.id?.name ?? null;
168
- const body = node.body;
169
- if (body)
170
- collectFunctions(body, className, null, out, null);
171
- return;
172
- }
173
- if (node.type === 'VariableDeclarator') {
174
- const id = node.id;
175
- const init = node.init;
176
- const name = id && id.type === 'Identifier' ? (id.name ?? null) : null;
177
- if (init)
178
- collectFunctions(init, parentClassName, name, out, null);
179
- return;
180
- }
181
- if (node.type === 'AssignmentExpression') {
182
- const left = node.left;
183
- const right = node.right;
184
- const name = left && left.type === 'Identifier' ? (left.name ?? null) : null;
185
- if (right)
186
- collectFunctions(right, parentClassName, name, out, null);
187
- return;
188
- }
189
- if (node.type === 'ExportDefaultDeclaration') {
190
- const decl = node.declaration;
191
- if (decl)
192
- collectFunctions(decl, parentClassName, 'default', out, null);
193
- return;
194
- }
195
- const callContext = callExpressionContext(node);
196
- if (callContext) {
197
- const args = node.arguments ?? [];
198
- for (const arg of args) {
199
- if (arg && typeof arg === 'object' && 'type' in arg) {
200
- collectFunctions(arg, parentClassName, null, out, callContext);
201
- }
202
- }
203
- return;
204
- }
205
- for (const key of Object.keys(node)) {
206
- if (key === 'loc' || key === 'range' || key === 'leadingComments' || key === 'trailingComments')
207
- continue;
208
- const child = node[key];
209
- if (!child)
210
- continue;
211
- if (Array.isArray(child)) {
212
- for (const item of child) {
213
- if (item && typeof item === 'object' && 'type' in item) {
214
- collectFunctions(item, parentClassName, null, out, null);
215
- }
216
- }
217
- }
218
- else if (typeof child === 'object' && 'type' in child) {
219
- collectFunctions(child, parentClassName, null, out, null);
220
- }
221
- }
222
- }
223
- function callExpressionContext(node) {
224
- if (node.type !== 'CallExpression' &&
225
- node.type !== 'OptionalCallExpression' &&
226
- node.type !== 'NewExpression') {
227
- return null;
228
- }
229
- const callee = node.callee;
230
- return babelQualifiedMemberName(callee) ?? babelCalleeName(callee);
231
- }
232
- function descendForNestedFunctions(fnNode, parentClassName, out) {
233
- const body = fnNode.body;
234
- if (!body)
235
- return;
236
- // Body of a function expression/declaration is a BlockStatement (or, for
237
- // arrows, possibly an Expression). Either way, walk it.
238
- walkChildren(body, (child) => collectFunctions(child, parentClassName, null, out, null));
239
- }
240
- function nameForFunctionNode(node, parentClassName, bindingName) {
241
- // FunctionDeclaration: function foo() {}
242
- if (node.type === 'FunctionDeclaration') {
243
- const id = node.id;
244
- return id?.name ?? bindingName ?? '<anonymous>';
245
- }
246
- // ClassMethod / ObjectMethod / ClassPrivateMethod
247
- if (node.type === 'ClassMethod' ||
248
- node.type === 'ObjectMethod' ||
249
- node.type === 'ClassPrivateMethod') {
250
- const key = node.key;
251
- let methodName = '<anonymous>';
252
- if (key) {
253
- if (key.type === 'Identifier')
254
- methodName = key.name ?? '<anonymous>';
255
- else if (key.type === 'StringLiteral')
256
- methodName = key.value ?? '<anonymous>';
257
- else if (key.type === 'PrivateName') {
258
- const inner = key.id;
259
- methodName = inner?.name ? `#${inner.name}` : '<anonymous>';
260
- }
261
- }
262
- return parentClassName ? `${parentClassName}.${methodName}` : methodName;
263
- }
264
- // FunctionExpression with an inner id: const x = function named() {}
265
- if (node.type === 'FunctionExpression') {
266
- const id = node.id;
267
- if (id?.name)
268
- return id.name;
269
- }
270
- // Arrow / unnamed function expression: use the binding name if we have it.
271
- return bindingName ?? '<anonymous>';
272
- }
273
- /**
274
- * Count McCabe decision points and collect call-site bare names in a
275
- * function body. Nested functions are opaque (their decisions and calls
276
- * belong to them). Used to populate per-function CC + fan-out.
277
- */
278
- function analyzeBabelBody(fnNode) {
279
- const body = fnNode.body;
280
- if (!body)
281
- return {
282
- cc: 1,
283
- callSites: [],
284
- memberCallSites: [],
285
- directCallSites: [],
286
- memberAliases: [],
287
- references: [],
288
- };
289
- let decisions = 0;
290
- const calls = new Set();
291
- const directCalls = new Set();
292
- const memberCalls = new Set();
293
- const aliases = new Set();
294
- const refs = new Set();
295
- // MemberExpression nodes that ARE in callee position get their rightmost
296
- // identifier added to callSites instead of references — track them here so
297
- // we can skip them during the read walk.
298
- const calleeMembers = new Set();
299
- walkSkippingNestedFunctions(body, (n) => {
300
- if (isDecisionPoint(n)) {
301
- decisions++;
302
- return;
303
- }
304
- if (n.type === 'CallExpression' ||
305
- n.type === 'OptionalCallExpression' ||
306
- n.type === 'NewExpression') {
307
- const callee = n.callee;
308
- const name = babelCalleeName(callee);
309
- if (name)
310
- calls.add(name);
311
- if (name && callee?.type === 'Identifier')
312
- directCalls.add(name);
313
- const memberName = babelQualifiedMemberName(callee);
314
- if (memberName)
315
- memberCalls.add(memberName);
316
- if (callee &&
317
- (callee.type === 'MemberExpression' || callee.type === 'OptionalMemberExpression')) {
318
- calleeMembers.add(callee);
319
- }
320
- }
321
- if (n.type === 'VariableDeclarator')
322
- collectMemberAliases(n, aliases);
323
- if (n.type === 'MemberExpression' || n.type === 'OptionalMemberExpression') {
324
- if (calleeMembers.has(n))
325
- return;
326
- collectMemberReadIdents(n, refs);
327
- }
328
- });
329
- return {
330
- cc: decisions + 1,
331
- callSites: [...calls],
332
- memberCallSites: [...memberCalls],
333
- directCallSites: [...directCalls],
334
- memberAliases: [...aliases],
335
- references: [...refs],
336
- };
337
- }
338
- function functionParamNames(fnNode) {
339
- const params = fnNode.params ?? [];
340
- const out = new Set();
341
- for (const param of params) {
342
- const name = bindingIdentifierName(param);
343
- if (name)
344
- out.add(name);
345
- }
346
- return [...out];
347
- }
348
- function bindingIdentifierName(node) {
349
- if (!node)
350
- return null;
351
- if (node.type === 'Identifier')
352
- return node.name ?? null;
353
- if (node.type === 'AssignmentPattern') {
354
- return bindingIdentifierName(node.left);
355
- }
356
- if (node.type === 'RestElement') {
357
- return bindingIdentifierName(node.argument);
358
- }
359
- return null;
360
- }
361
- /**
362
- * Walk a member-expression chain (`a.b.c`, `req.body.x`, `process.env.SECRET`)
363
- * and add the rightmost ident of each link to `out`. Skips the leftmost root
364
- * (which is usually a binding name like `req` or `obj` — not interesting for
365
- * taint matching). Computed-property accesses (`a[i]`) contribute nothing.
366
- */
367
- function collectMemberReadIdents(node, out) {
368
- let cur = node;
369
- while (cur && (cur.type === 'MemberExpression' || cur.type === 'OptionalMemberExpression')) {
370
- const m = cur;
371
- if (!m.computed && m.property && m.property.type === 'Identifier') {
372
- const name = m.property.name;
373
- if (name)
374
- out.add(name);
375
- }
376
- cur = m.object ?? null;
377
- }
378
- }
379
- function collectMemberAliases(node, out) {
380
- const decl = node;
381
- if (!decl.id || decl.id.type !== 'ObjectPattern' || !decl.init)
382
- return;
383
- const objectName = babelQualifiedMemberName(decl.init) ?? babelCalleeName(decl.init);
384
- if (!objectName)
385
- return;
386
- const properties = decl.id.properties ?? [];
387
- for (const property of properties) {
388
- if (!property || property.type !== 'ObjectProperty')
389
- continue;
390
- const prop = property;
391
- if (prop.computed || !prop.key || !prop.value)
392
- continue;
393
- const keyName = babelMemberPropertyName(prop.key);
394
- const aliasName = bindingIdentifierName(prop.value);
395
- if (keyName && aliasName)
396
- out.add(aliasName + '=' + objectName + '.' + keyName);
397
- }
398
- }
399
- function babelCalleeName(node) {
400
- if (!node)
401
- return null;
402
- if (node.type === 'Identifier')
403
- return node.name ?? null;
404
- if (node.type === 'MemberExpression' || node.type === 'OptionalMemberExpression') {
405
- const property = node.property;
406
- if (property)
407
- return babelCalleeName(property);
408
- }
409
- return null;
410
- }
411
- function babelQualifiedMemberName(node) {
412
- if (!node || (node.type !== 'MemberExpression' && node.type !== 'OptionalMemberExpression')) {
413
- return null;
414
- }
415
- const member = node;
416
- if (member.computed || !member.object || !member.property)
417
- return null;
418
- const objectName = babelMemberObjectName(member.object);
419
- const propertyName = babelMemberPropertyName(member.property);
420
- return objectName && propertyName ? `${objectName}.${propertyName}` : null;
421
- }
422
- function babelMemberObjectName(node) {
423
- if (node.type === 'Identifier' || node.type === 'ThisExpression')
424
- return babelCalleeName(node);
425
- return babelQualifiedMemberName(node);
426
- }
427
- function babelMemberPropertyName(node) {
428
- if (node.type === 'Identifier')
429
- return node.name ?? null;
430
- if (node.type === 'StringLiteral')
431
- return node.value ?? null;
432
- return null;
433
- }
434
- function walkChildren(node, visit) {
435
- if (!node || typeof node !== 'object')
436
- return;
437
- for (const key of Object.keys(node)) {
438
- if (key === 'loc' || key === 'range' || key === 'leadingComments' || key === 'trailingComments')
439
- continue;
440
- const child = node[key];
441
- if (!child)
442
- continue;
443
- if (Array.isArray(child)) {
444
- for (const item of child) {
445
- if (item && typeof item === 'object' && 'type' in item)
446
- visit(item);
447
- }
448
- }
449
- else if (typeof child === 'object' && 'type' in child) {
450
- visit(child);
451
- }
452
- }
453
- }
454
- function walkSkippingNestedFunctions(node, visit) {
455
- if (!node || typeof node !== 'object')
456
- return;
457
- visit(node);
458
- for (const key of Object.keys(node)) {
459
- if (key === 'loc' || key === 'range' || key === 'leadingComments' || key === 'trailingComments')
460
- continue;
461
- const child = node[key];
462
- if (!child)
463
- continue;
464
- if (Array.isArray(child)) {
465
- for (const item of child) {
466
- if (item && typeof item === 'object' && 'type' in item) {
467
- if (isFunctionNode(item))
468
- continue;
469
- walkSkippingNestedFunctions(item, visit);
470
- }
471
- }
472
- }
473
- else if (typeof child === 'object' && 'type' in child) {
474
- if (isFunctionNode(child))
475
- continue;
476
- walkSkippingNestedFunctions(child, visit);
477
- }
478
- }
479
- }
480
- /**
481
- * McCabe decision points for JavaScript/TypeScript. Default switch cases and
482
- * optional-chaining do NOT count - this matches eslint's `complexity` rule
483
- * and most static analyzers. The result is summed across the whole file
484
- * (module + all nested functions) and offset by +1 in the caller.
485
- */
486
- function isDecisionPoint(n) {
487
- switch (n.type) {
488
- case 'IfStatement':
489
- case 'ConditionalExpression':
490
- case 'ForStatement':
491
- case 'ForInStatement':
492
- case 'ForOfStatement':
493
- case 'WhileStatement':
494
- case 'DoWhileStatement':
495
- case 'CatchClause':
496
- return true;
497
- case 'SwitchCase':
498
- // Default case is the fall-through path, not a branch.
499
- return n.test !== null;
500
- case 'LogicalExpression': {
501
- const op = n.operator;
502
- return op === '&&' || op === '||' || op === '??';
503
- }
504
- default:
505
- return false;
506
- }
507
- }
508
- function visitTopLevel(node, imports, exports) {
509
- switch (node.type) {
510
- case 'ImportDeclaration': {
511
- imports.push(importFromNode(node));
512
- return;
513
- }
514
- case 'ExportNamedDeclaration': {
515
- collectNamedExport(node, exports, imports);
516
- return;
517
- }
518
- case 'ExportDefaultDeclaration': {
519
- exports.push({
520
- name: 'default',
521
- kind: 'default',
522
- typeOnly: false,
523
- line: node.loc?.start.line ?? 0,
524
- });
525
- return;
526
- }
527
- case 'ExportAllDeclaration': {
528
- const source = node.source.value;
529
- imports.push({
530
- source,
531
- kind: 'reexport',
532
- specifiers: [],
533
- typeOnly: Boolean(node.exportKind === 'type'),
534
- line: node.loc?.start.line ?? 0,
535
- });
536
- return;
537
- }
538
- default:
539
- return;
540
- }
541
- }
542
- function importFromNode(node) {
543
- const specifiers = node.specifiers.map((s) => {
544
- if (s.type === 'ImportDefaultSpecifier')
545
- return 'default';
546
- if (s.type === 'ImportNamespaceSpecifier')
547
- return '*';
548
- if (s.type === 'ImportSpecifier') {
549
- const imported = s.imported;
550
- if (imported.type === 'Identifier')
551
- return imported.name;
552
- return imported.value;
553
- }
554
- return '';
555
- });
556
- return {
557
- source: node.source.value,
558
- kind: 'static',
559
- specifiers: specifiers.filter(Boolean),
560
- typeOnly: node.importKind === 'type',
561
- line: node.loc?.start.line ?? 0,
562
- };
563
- }
564
- function collectNamedExport(node, exports, imports) {
565
- // Re-export: export { X } from 'source'
566
- if (node.source) {
567
- imports.push({
568
- source: node.source.value,
569
- kind: 'reexport',
570
- specifiers: node.specifiers
571
- .map((s) => {
572
- if (s.type === 'ExportSpecifier') {
573
- const exported = s.exported;
574
- return exported.type === 'Identifier'
575
- ? exported.name
576
- : exported.value;
577
- }
578
- return '';
579
- })
580
- .filter(Boolean),
581
- typeOnly: node.exportKind === 'type',
582
- line: node.loc?.start.line ?? 0,
583
- });
584
- }
585
- // Inline declaration: export function foo() {} / export const x = ... / etc.
586
- if (node.declaration) {
587
- const typeOnly = node.exportKind === 'type';
588
- const line = node.declaration.loc?.start.line ?? node.loc?.start.line ?? 0;
589
- switch (node.declaration.type) {
590
- case 'FunctionDeclaration': {
591
- const name = node.declaration.id?.name;
592
- if (name)
593
- exports.push({ name, kind: 'function', typeOnly, line });
594
- return;
595
- }
596
- case 'ClassDeclaration': {
597
- const name = node.declaration.id?.name;
598
- if (name)
599
- exports.push({ name, kind: 'class', typeOnly, line });
600
- return;
601
- }
602
- case 'VariableDeclaration': {
603
- for (const decl of node.declaration.declarations) {
604
- if (decl.id.type === 'Identifier') {
605
- exports.push({ name: decl.id.name, kind: 'variable', typeOnly, line });
606
- }
607
- }
608
- return;
609
- }
610
- case 'TSInterfaceDeclaration': {
611
- const name = node.declaration.id.name;
612
- exports.push({ name, kind: 'interface', typeOnly: true, line });
613
- return;
614
- }
615
- case 'TSTypeAliasDeclaration': {
616
- const name = node.declaration.id.name;
617
- exports.push({ name, kind: 'type', typeOnly: true, line });
618
- return;
619
- }
620
- case 'TSEnumDeclaration': {
621
- const name = node.declaration.id.name;
622
- exports.push({ name, kind: 'enum', typeOnly, line });
623
- return;
624
- }
625
- default:
626
- return;
627
- }
628
- }
629
- // Named re-export of local symbols: export { foo, bar }
630
- for (const spec of node.specifiers) {
631
- if (spec.type !== 'ExportSpecifier')
632
- continue;
633
- const exported = spec.exported;
634
- const name = exported.type === 'Identifier' ? exported.name : exported.value;
635
- exports.push({
636
- name,
637
- kind: 'unknown',
638
- typeOnly: node.exportKind === 'type',
639
- line: spec.loc?.start.line ?? node.loc?.start.line ?? 0,
640
- });
641
- }
642
- }
643
- /**
644
- * Lightweight AST walker. We only care about recursing through node properties
645
- * to find CallExpressions (for call sites + dynamic imports + require).
646
- * Avoids the full babel-traverse dependency.
647
- */
648
- function walk(node, visit) {
649
- if (!node || typeof node !== 'object')
650
- return;
651
- visit(node);
652
- for (const key of Object.keys(node)) {
653
- if (key === 'loc' || key === 'range' || key === 'leadingComments' || key === 'trailingComments')
654
- continue;
655
- const child = node[key];
656
- if (!child)
657
- continue;
658
- if (Array.isArray(child)) {
659
- for (const item of child) {
660
- if (item && typeof item === 'object' && 'type' in item) {
661
- walk(item, visit);
662
- }
663
- }
664
- }
665
- else if (typeof child === 'object' && 'type' in child) {
666
- walk(child, visit);
667
- }
668
- }
669
- }
670
51
  //# sourceMappingURL=ast.js.map