@md-code/follow-architecture 0.1.0 → 0.3.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 (436) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +597 -126
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +14 -0
  7. package/dist/args.js +77 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/code-roles/classify.d.ts +11 -0
  11. package/dist/code-roles/classify.js +43 -0
  12. package/dist/code-roles/connector.d.ts +5 -0
  13. package/dist/code-roles/connector.js +114 -0
  14. package/dist/code-roles/project.d.ts +12 -0
  15. package/dist/code-roles/project.js +122 -0
  16. package/dist/code-roles/roles.d.ts +8 -0
  17. package/dist/code-roles/roles.js +190 -0
  18. package/dist/config-options.d.ts +53 -0
  19. package/dist/config-options.js +35 -0
  20. package/dist/config-project.d.ts +4 -0
  21. package/dist/config-project.js +74 -0
  22. package/dist/config-report.d.ts +19 -0
  23. package/dist/config-report.js +134 -0
  24. package/dist/config-rule.d.ts +70 -0
  25. package/dist/config-rule.js +118 -0
  26. package/dist/config-state.d.ts +14 -0
  27. package/dist/config-state.js +96 -0
  28. package/dist/config.d.ts +82 -0
  29. package/dist/config.js +38 -0
  30. package/dist/css/index.d.ts +27 -0
  31. package/dist/css/index.js +140 -0
  32. package/dist/css/syntax/css/gate.d.ts +2 -0
  33. package/dist/css/syntax/css/gate.js +69 -0
  34. package/dist/css/syntax/css/index.d.ts +7 -0
  35. package/dist/css/syntax/css/index.js +41 -0
  36. package/dist/css/syntax/css/reference.d.ts +3 -0
  37. package/dist/css/syntax/css/reference.js +24 -0
  38. package/dist/css/syntax/language.d.ts +25 -0
  39. package/dist/css/syntax/language.js +69 -0
  40. package/dist/css/syntax/scss/index.d.ts +25 -0
  41. package/dist/css/syntax/scss/index.js +85 -0
  42. package/dist/css/syntax/scss/reference.d.ts +3 -0
  43. package/dist/css/syntax/scss/reference.js +11 -0
  44. package/dist/css/syntax/styled/document.d.ts +68 -0
  45. package/dist/css/syntax/styled/document.js +241 -0
  46. package/dist/css/syntax/styled/markup.d.ts +6 -0
  47. package/dist/css/syntax/styled/markup.js +76 -0
  48. package/dist/css/syntax/styled/template.d.ts +23 -0
  49. package/dist/css/syntax/styled/template.js +61 -0
  50. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  51. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  52. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  53. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  54. package/dist/css/value/check.d.ts +86 -0
  55. package/dist/css/value/check.js +122 -0
  56. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  57. package/dist/css/value/expression/arithmetic.js +69 -0
  58. package/dist/css/value/expression/block.d.ts +9 -0
  59. package/dist/css/value/expression/block.js +91 -0
  60. package/dist/css/value/expression/conditional.d.ts +8 -0
  61. package/dist/css/value/expression/conditional.js +53 -0
  62. package/dist/css/value/expression/index.d.ts +5 -0
  63. package/dist/css/value/expression/index.js +69 -0
  64. package/dist/css/value/expression/map.d.ts +7 -0
  65. package/dist/css/value/expression/map.js +113 -0
  66. package/dist/css/value/object/index.d.ts +5 -0
  67. package/dist/css/value/object/index.js +103 -0
  68. package/dist/css/value/object/members.d.ts +7 -0
  69. package/dist/css/value/object/members.js +103 -0
  70. package/dist/css/value/object/node.d.ts +8 -0
  71. package/dist/css/value/object/node.js +129 -0
  72. package/dist/css/value/object/path.d.ts +10 -0
  73. package/dist/css/value/object/path.js +146 -0
  74. package/dist/css/value/pieces.d.ts +61 -0
  75. package/dist/css/value/pieces.js +55 -0
  76. package/dist/css/value/resolve.d.ts +33 -0
  77. package/dist/css/value/resolve.js +94 -0
  78. package/dist/css/value/scope.d.ts +27 -0
  79. package/dist/css/value/scope.js +187 -0
  80. package/dist/css/value/substitute.d.ts +10 -0
  81. package/dist/css/value/substitute.js +113 -0
  82. package/dist/css/value/values.d.ts +23 -0
  83. package/dist/css/value/values.js +131 -0
  84. package/dist/entities/architecture.d.ts +162 -0
  85. package/dist/entities/architecture.js +2 -0
  86. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  87. package/dist/entities/ast/assignments-nodes.js +64 -0
  88. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  89. package/dist/entities/ast/assignments-raw.js +86 -0
  90. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  91. package/dist/entities/ast/assignments-tagged.js +180 -0
  92. package/dist/entities/ast/assignments.d.ts +9 -0
  93. package/dist/entities/ast/assignments.js +78 -0
  94. package/dist/entities/ast/branches.d.ts +4 -0
  95. package/dist/entities/ast/branches.js +32 -0
  96. package/dist/entities/ast/calls.d.ts +6 -0
  97. package/dist/entities/ast/calls.js +134 -0
  98. package/dist/entities/ast/classes.d.ts +5 -0
  99. package/dist/entities/ast/classes.js +57 -0
  100. package/dist/entities/ast/climb.d.ts +12 -0
  101. package/dist/entities/ast/climb.js +17 -0
  102. package/dist/entities/ast/comments.d.ts +4 -0
  103. package/dist/entities/ast/comments.js +100 -0
  104. package/dist/entities/ast/declaration.d.ts +4 -0
  105. package/dist/entities/ast/declaration.js +26 -0
  106. package/dist/entities/ast/depth.d.ts +17 -0
  107. package/dist/entities/ast/depth.js +149 -0
  108. package/dist/entities/ast/enums.d.ts +6 -0
  109. package/dist/entities/ast/enums.js +17 -0
  110. package/dist/entities/ast/file-exports.d.ts +7 -0
  111. package/dist/entities/ast/file-exports.js +78 -0
  112. package/dist/entities/ast/file-facts.d.ts +13 -0
  113. package/dist/entities/ast/file-facts.js +35 -0
  114. package/dist/entities/ast/file-imports.d.ts +5 -0
  115. package/dist/entities/ast/file-imports.js +77 -0
  116. package/dist/entities/ast/file.d.ts +5 -0
  117. package/dist/entities/ast/file.js +22 -0
  118. package/dist/entities/ast/functions.d.ts +8 -0
  119. package/dist/entities/ast/functions.js +102 -0
  120. package/dist/entities/ast/heritage.d.ts +4 -0
  121. package/dist/entities/ast/heritage.js +36 -0
  122. package/dist/entities/ast/index.d.ts +6 -0
  123. package/dist/entities/ast/index.js +125 -0
  124. package/dist/entities/ast/kind.d.ts +5 -0
  125. package/dist/entities/ast/kind.js +28 -0
  126. package/dist/entities/ast/loose.d.ts +37 -0
  127. package/dist/entities/ast/loose.js +2 -0
  128. package/dist/entities/ast/modifiers.d.ts +5 -0
  129. package/dist/entities/ast/modifiers.js +32 -0
  130. package/dist/entities/ast/project.d.ts +9 -0
  131. package/dist/entities/ast/project.js +75 -0
  132. package/dist/entities/ast/properties.d.ts +11 -0
  133. package/dist/entities/ast/properties.js +171 -0
  134. package/dist/entities/ast/resolve.d.ts +16 -0
  135. package/dist/entities/ast/resolve.js +307 -0
  136. package/dist/entities/ast/tree.d.ts +29 -0
  137. package/dist/entities/ast/tree.js +351 -0
  138. package/dist/entities/ast/types.d.ts +6 -0
  139. package/dist/entities/ast/types.js +45 -0
  140. package/dist/entities/ast/usage.d.ts +11 -0
  141. package/dist/entities/ast/usage.js +81 -0
  142. package/dist/entities/ast/variables.d.ts +8 -0
  143. package/dist/entities/ast/variables.js +91 -0
  144. package/dist/entities/context.d.ts +29 -0
  145. package/dist/entities/context.js +2 -0
  146. package/dist/entities/facts.d.ts +261 -0
  147. package/dist/entities/facts.js +2 -0
  148. package/dist/entities/findings.d.ts +19 -0
  149. package/dist/entities/findings.js +2 -0
  150. package/dist/entities/kinds.d.ts +40 -0
  151. package/dist/entities/kinds.js +221 -0
  152. package/dist/entities/location/homes.d.ts +28 -0
  153. package/dist/entities/location/homes.js +169 -0
  154. package/dist/entities/location/place.d.ts +10 -0
  155. package/dist/entities/location/place.js +56 -0
  156. package/dist/entities/location/where.d.ts +17 -0
  157. package/dist/entities/location/where.js +218 -0
  158. package/dist/entities/location.d.ts +16 -0
  159. package/dist/entities/location.js +140 -0
  160. package/dist/entities/operators.d.ts +14 -0
  161. package/dist/entities/operators.js +30 -0
  162. package/dist/entities/overview/data.d.ts +43 -0
  163. package/dist/entities/overview/data.js +2 -0
  164. package/dist/entities/overview/decision.d.ts +60 -0
  165. package/dist/entities/overview/decision.js +2 -0
  166. package/dist/entities/overview/file-tree.d.ts +10 -0
  167. package/dist/entities/overview/file-tree.js +2 -0
  168. package/dist/entities/overview/finding.d.ts +58 -0
  169. package/dist/entities/overview/finding.js +2 -0
  170. package/dist/entities/overview/graph.d.ts +65 -0
  171. package/dist/entities/overview/graph.js +2 -0
  172. package/dist/entities/overview/input.d.ts +15 -0
  173. package/dist/entities/overview/input.js +2 -0
  174. package/dist/entities/overview/summaries.d.ts +79 -0
  175. package/dist/entities/overview/summaries.js +2 -0
  176. package/dist/entities/place.d.ts +5 -0
  177. package/dist/entities/place.js +2 -0
  178. package/dist/entities/queries.d.ts +9 -0
  179. package/dist/entities/queries.js +305 -0
  180. package/dist/entities/repair.d.ts +16 -0
  181. package/dist/entities/repair.js +23 -0
  182. package/dist/entities/schema.d.ts +8 -0
  183. package/dist/entities/schema.js +23 -0
  184. package/dist/entities/story.d.ts +47 -0
  185. package/dist/entities/story.js +2 -0
  186. package/dist/entities/structure-facts.d.ts +11 -0
  187. package/dist/entities/structure-facts.js +2 -0
  188. package/dist/entities/token.d.ts +23 -0
  189. package/dist/entities/token.js +2 -0
  190. package/dist/entities/tree/build.d.ts +5 -0
  191. package/dist/entities/tree/build.js +252 -0
  192. package/dist/entities/tree/entries.d.ts +7 -0
  193. package/dist/entities/tree/entries.js +120 -0
  194. package/dist/entities/tree/index.d.ts +6 -0
  195. package/dist/entities/tree/index.js +21 -0
  196. package/dist/entities/tree/match.d.ts +17 -0
  197. package/dist/entities/tree/match.js +176 -0
  198. package/dist/frameworks/angular/index.d.ts +7 -0
  199. package/dist/frameworks/angular/index.js +17 -0
  200. package/dist/frameworks/facet.d.ts +16 -0
  201. package/dist/frameworks/facet.js +2 -0
  202. package/dist/frameworks/index.d.ts +9 -0
  203. package/dist/frameworks/index.js +120 -0
  204. package/dist/frameworks/react/index.d.ts +7 -0
  205. package/dist/frameworks/react/index.js +214 -0
  206. package/dist/frameworks/vue/index.d.ts +7 -0
  207. package/dist/frameworks/vue/index.js +17 -0
  208. package/dist/invariants/index.d.ts +6 -0
  209. package/dist/invariants/index.js +299 -0
  210. package/dist/invariants/list-vars.d.ts +5 -0
  211. package/dist/invariants/list-vars.js +143 -0
  212. package/dist/invariants/name.d.ts +16 -0
  213. package/dist/invariants/name.js +18 -0
  214. package/dist/invariants/normalize.d.ts +4 -0
  215. package/dist/invariants/normalize.js +95 -0
  216. package/dist/invariants/vars.d.ts +20 -0
  217. package/dist/invariants/vars.js +117 -0
  218. package/dist/main.d.ts +7 -0
  219. package/dist/main.js +229 -0
  220. package/dist/nodes/child-roles.d.ts +3 -0
  221. package/dist/nodes/child-roles.js +12 -0
  222. package/dist/nodes/children.d.ts +25 -0
  223. package/dist/nodes/children.js +112 -0
  224. package/dist/nodes/finally/emit.d.ts +6 -0
  225. package/dist/nodes/finally/emit.js +55 -0
  226. package/dist/nodes/finally/index.d.ts +8 -0
  227. package/dist/nodes/finally/index.js +35 -0
  228. package/dist/nodes/finally/queries.d.ts +5 -0
  229. package/dist/nodes/finally/queries.js +22 -0
  230. package/dist/nodes/finally/relations-access.d.ts +5 -0
  231. package/dist/nodes/finally/relations-access.js +46 -0
  232. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  233. package/dist/nodes/finally/relations-edge.js +125 -0
  234. package/dist/nodes/finally/relations-group.d.ts +31 -0
  235. package/dist/nodes/finally/relations-group.js +103 -0
  236. package/dist/nodes/finally/relations.d.ts +5 -0
  237. package/dist/nodes/finally/relations.js +81 -0
  238. package/dist/nodes/finally/required.d.ts +5 -0
  239. package/dist/nodes/finally/required.js +90 -0
  240. package/dist/nodes/finally/roles.d.ts +13 -0
  241. package/dist/nodes/finally/roles.js +41 -0
  242. package/dist/nodes/finally/violation.d.ts +17 -0
  243. package/dist/nodes/finally/violation.js +2 -0
  244. package/dist/nodes/similar.d.ts +21 -0
  245. package/dist/nodes/similar.js +156 -0
  246. package/dist/pipeline-facts.d.ts +11 -0
  247. package/dist/pipeline-facts.js +112 -0
  248. package/dist/pipeline-roles.d.ts +6 -0
  249. package/dist/pipeline-roles.js +75 -0
  250. package/dist/pipeline-unroled.d.ts +14 -0
  251. package/dist/pipeline-unroled.js +193 -0
  252. package/dist/pipeline.d.ts +7 -0
  253. package/dist/pipeline.js +73 -0
  254. package/dist/plugin.d.ts +2 -0
  255. package/dist/plugin.js +3 -0
  256. package/dist/report/asks.d.ts +55 -0
  257. package/dist/report/asks.js +50 -0
  258. package/dist/report/cli-report.d.ts +2 -0
  259. package/dist/report/cli-report.js +13 -0
  260. package/dist/report/config-error-guard.d.ts +8 -0
  261. package/dist/report/config-error-guard.js +5 -0
  262. package/dist/report/configErrors.d.ts +98 -0
  263. package/dist/report/configErrors.js +75 -0
  264. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  265. package/dist/report/errorTypes/codes/structure.js +76 -0
  266. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  267. package/dist/report/errorTypes/decision-maker.js +99 -0
  268. package/dist/report/errorTypes/destinations.d.ts +38 -0
  269. package/dist/report/errorTypes/destinations.js +147 -0
  270. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  271. package/dist/report/errorTypes/finding-type.js +2 -0
  272. package/dist/report/errorTypes/index.d.ts +15 -0
  273. package/dist/report/errorTypes/index.js +45 -0
  274. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  275. package/dist/report/errorTypes/types/fileContents.js +34 -0
  276. package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
  277. package/dist/report/errorTypes/types/unknownRole.js +22 -0
  278. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  279. package/dist/report/errorTypes/types/wrongAction.js +135 -0
  280. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  281. package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
  282. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  283. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  284. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  285. package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
  286. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  287. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  288. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  289. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  290. package/dist/report/finding-from.d.ts +9 -0
  291. package/dist/report/finding-from.js +103 -0
  292. package/dist/report/notices.d.ts +4 -0
  293. package/dist/report/notices.js +31 -0
  294. package/dist/report/render-report.d.ts +12 -0
  295. package/dist/report/render-report.js +142 -0
  296. package/dist/report/user-report/build/bundle.d.ts +3 -0
  297. package/dist/report/user-report/build/bundle.js +169 -0
  298. package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
  299. package/dist/report/user-report/data/collect.d.ts +4 -0
  300. package/dist/report/user-report/data/collect.js +80 -0
  301. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  302. package/dist/report/user-report/data/file-tree.js +72 -0
  303. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  304. package/dist/report/user-report/data/finding-boundary.js +21 -0
  305. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  306. package/dist/report/user-report/data/finding-plan.js +45 -0
  307. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  308. package/dist/report/user-report/data/finding-title.js +36 -0
  309. package/dist/report/user-report/data/findings.d.ts +10 -0
  310. package/dist/report/user-report/data/findings.js +171 -0
  311. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  312. package/dist/report/user-report/data/graph-edges.js +109 -0
  313. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  314. package/dist/report/user-report/data/graph-helpers.js +67 -0
  315. package/dist/report/user-report/data/graph-roles.d.ts +5 -0
  316. package/dist/report/user-report/data/graph-roles.js +71 -0
  317. package/dist/report/user-report/data/graph.d.ts +11 -0
  318. package/dist/report/user-report/data/graph.js +90 -0
  319. package/dist/report/user-report/data/invariants.d.ts +7 -0
  320. package/dist/report/user-report/data/invariants.js +62 -0
  321. package/dist/report/user-report/data/nodes.d.ts +11 -0
  322. package/dist/report/user-report/data/nodes.js +106 -0
  323. package/dist/report/user-report/data/role-examples.d.ts +16 -0
  324. package/dist/report/user-report/data/role-examples.js +94 -0
  325. package/dist/report/user-report/data/role-filters.d.ts +15 -0
  326. package/dist/report/user-report/data/role-filters.js +79 -0
  327. package/dist/report/user-report/data/role-marks.d.ts +5 -0
  328. package/dist/report/user-report/data/role-marks.js +79 -0
  329. package/dist/report/user-report/data/roles.d.ts +7 -0
  330. package/dist/report/user-report/data/roles.js +83 -0
  331. package/dist/report/user-report/data/scan.d.ts +8 -0
  332. package/dist/report/user-report/data/scan.js +59 -0
  333. package/dist/report/user-report/html/shell.d.ts +3 -0
  334. package/dist/report/user-report/html/shell.js +27 -0
  335. package/dist/report/user-report/index.d.ts +8 -0
  336. package/dist/report/user-report/index.js +48 -0
  337. package/dist/report/user-report/shared/describe.d.ts +7 -0
  338. package/dist/report/user-report/shared/describe.js +86 -0
  339. package/dist/scripts/audit-report.d.ts +2 -0
  340. package/dist/scripts/audit-report.js +147 -0
  341. package/dist/utils/accumulate.d.ts +6 -0
  342. package/dist/utils/accumulate.js +18 -0
  343. package/dist/utils/article.d.ts +2 -0
  344. package/dist/utils/article.js +12 -0
  345. package/dist/utils/classify.d.ts +12 -0
  346. package/dist/utils/classify.js +25 -0
  347. package/dist/utils/configs.d.ts +25 -0
  348. package/dist/utils/configs.js +87 -0
  349. package/dist/utils/count.d.ts +7 -0
  350. package/dist/utils/count.js +13 -0
  351. package/dist/utils/dispatch.d.ts +2 -0
  352. package/dist/utils/dispatch.js +27 -0
  353. package/dist/utils/distinct.d.ts +2 -0
  354. package/dist/utils/distinct.js +12 -0
  355. package/dist/utils/field.d.ts +14 -0
  356. package/dist/utils/field.js +60 -0
  357. package/dist/utils/file-name.d.ts +2 -0
  358. package/dist/utils/file-name.js +11 -0
  359. package/dist/utils/files.d.ts +7 -0
  360. package/dist/utils/files.js +73 -0
  361. package/dist/utils/fixpoint.d.ts +2 -0
  362. package/dist/utils/fixpoint.js +19 -0
  363. package/dist/utils/gate.d.ts +2 -0
  364. package/dist/utils/gate.js +12 -0
  365. package/dist/utils/group.d.ts +3 -0
  366. package/dist/utils/group.js +33 -0
  367. package/dist/utils/host.d.ts +3 -0
  368. package/dist/utils/host.js +13 -0
  369. package/dist/utils/imports.d.ts +12 -0
  370. package/dist/utils/imports.js +121 -0
  371. package/dist/utils/judged.d.ts +5 -0
  372. package/dist/utils/judged.js +19 -0
  373. package/dist/utils/keyed.d.ts +2 -0
  374. package/dist/utils/keyed.js +23 -0
  375. package/dist/utils/map-record.d.ts +2 -0
  376. package/dist/utils/map-record.js +11 -0
  377. package/dist/utils/path-label.d.ts +6 -0
  378. package/dist/utils/path-label.js +35 -0
  379. package/dist/utils/pattern.d.ts +18 -0
  380. package/dist/utils/pattern.js +191 -0
  381. package/dist/utils/permission.d.ts +16 -0
  382. package/dist/utils/permission.js +16 -0
  383. package/dist/utils/plural.d.ts +2 -0
  384. package/dist/utils/plural.js +9 -0
  385. package/dist/utils/qualified.d.ts +2 -0
  386. package/dist/utils/qualified.js +21 -0
  387. package/dist/utils/rank.d.ts +2 -0
  388. package/dist/utils/rank.js +24 -0
  389. package/dist/utils/read-field.d.ts +12 -0
  390. package/dist/utils/read-field.js +50 -0
  391. package/dist/utils/read-when.d.ts +2 -0
  392. package/dist/utils/read-when.js +17 -0
  393. package/dist/utils/reason.d.ts +4 -0
  394. package/dist/utils/reason.js +9 -0
  395. package/dist/utils/record.d.ts +3 -0
  396. package/dist/utils/record.js +21 -0
  397. package/dist/utils/resolve.d.ts +2 -0
  398. package/dist/utils/resolve.js +24 -0
  399. package/dist/utils/search.d.ts +2 -0
  400. package/dist/utils/search.js +16 -0
  401. package/dist/utils/seen.d.ts +6 -0
  402. package/dist/utils/seen.js +27 -0
  403. package/dist/utils/span.d.ts +5 -0
  404. package/dist/utils/span.js +2 -0
  405. package/dist/utils/speak.d.ts +2 -0
  406. package/dist/utils/speak.js +18 -0
  407. package/dist/utils/split.d.ts +8 -0
  408. package/dist/utils/split.js +8 -0
  409. package/dist/utils/template.d.ts +5 -0
  410. package/dist/utils/template.js +5 -0
  411. package/dist/utils/text.d.ts +4 -0
  412. package/dist/utils/text.js +42 -0
  413. package/dist/utils/tokenize.d.ts +2 -0
  414. package/dist/utils/tokenize.js +13 -0
  415. package/dist/utils/try-read.d.ts +4 -0
  416. package/dist/utils/try-read.js +24 -0
  417. package/dist/utils/typed-field.d.ts +3 -0
  418. package/dist/utils/typed-field.js +16 -0
  419. package/dist/utils/verdicts.d.ts +4 -0
  420. package/dist/utils/verdicts.js +20 -0
  421. package/entities/operators.ts +31 -0
  422. package/package.json +62 -19
  423. package/report/errorTypes/vocabulary/ids.ts +12 -0
  424. package/report/errorTypes/vocabulary/phrases.ts +161 -0
  425. package/report/errorTypes/vocabulary/places.ts +46 -0
  426. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  427. package/report/user-report/shared/describe.ts +107 -0
  428. package/ast.js +0 -107
  429. package/bin/follow-architecture.js +0 -6
  430. package/config.js +0 -82
  431. package/entities/aliases.js +0 -10
  432. package/entities/invariants.js +0 -134
  433. package/entities/nodes.js +0 -112
  434. package/main.js +0 -95
  435. package/report.js +0 -73
  436. package/utils.js +0 -104
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.firstMatch = exports.definitionsOf = void 0;
4
+ // A CLASSIFICATION is one mechanism: definitions are tried in DECLARED ORDER
5
+ // against a subject, and the FIRST whose `infer` filter matches names it. A
6
+ // code role classifies a piece of code (`code-roles/connector`), a file's own
7
+ // facts (`code-roles/classify`), and the roles a folder's files hold
8
+ // (`nodes/similar`) — all three ask the same question of the same filter
9
+ // engine, so the walk lives here once. What the definitions ARE and what a
10
+ // match MEANS is the caller's own; nothing here knows roles.
11
+ const queries_1 = require("../entities/queries");
12
+ // The definitions a record of `{ infer }` specs declares, in the record's own
13
+ // (YAML) order. A spec without an infer filter can never match.
14
+ const definitionsOf = (defs) => Object.entries(defs ?? {}).map(([name, def]) => ({ name, infer: def?.infer ?? null }));
15
+ exports.definitionsOf = definitionsOf;
16
+ // The first definition whose infer matches the subject, or null. A null/absent
17
+ // infer never matches — a definition that recognises nothing names nothing.
18
+ const firstMatch = (subject, defs, scope) => {
19
+ for (const def of defs) {
20
+ if (def.infer != null && (0, queries_1.matches)(subject, def.infer, scope))
21
+ return def.name;
22
+ }
23
+ return null;
24
+ };
25
+ exports.firstMatch = firstMatch;
@@ -0,0 +1,25 @@
1
+ import { type FieldValue } from "./field";
2
+ interface LoadConfigsOptions {
3
+ repoRoot?: string;
4
+ configs?: Record<string, string>;
5
+ }
6
+ interface ConfigEntry {
7
+ path: string;
8
+ abs: string;
9
+ data: FieldValue;
10
+ }
11
+ interface ConfigIssue {
12
+ key: string;
13
+ path: string;
14
+ message?: string;
15
+ }
16
+ interface LoadConfigsResult {
17
+ values: Record<string, ConfigEntry | null>;
18
+ missing: ConfigIssue[];
19
+ errors: ConfigIssue[];
20
+ }
21
+ declare const loadConfigs: ({ repoRoot, configs }: LoadConfigsOptions) => LoadConfigsResult;
22
+ declare const configFacts: ({ values }: {
23
+ values: Record<string, ConfigEntry | null>;
24
+ }) => Record<string, FieldValue>;
25
+ export { loadConfigs, configFacts };
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.configFacts = exports.loadConfigs = void 0;
27
+ // The tool's own configs, declared in the ESLint RULE OPTIONS (and in the CLI
28
+ // flags) — never in `architecture.yaml`. The architecture says what the code may
29
+ // be; the rule says where its own inputs live:
30
+ //
31
+ // "md-code/follow-architecture": ["error", { configs: { tailwind: "…" } }]
32
+ //
33
+ // Two answers are the caller's business, not the rule's:
34
+ // missing — the key was declared and the file is not there
35
+ // errors — the file is there and cannot be read or parsed
36
+ // Both name the KEY and the PATH, because "no config" and "a config with nothing
37
+ // in it" produce the same wrong conclusions and must not look alike.
38
+ const fs = __importStar(require("node:fs"));
39
+ const path = __importStar(require("node:path"));
40
+ const node_module_1 = require("node:module");
41
+ const field_1 = require("./field");
42
+ // `require` for the runtime, taken from `node:module` so the config loader can
43
+ // still read a JS config module without the linter treating it as a require call.
44
+ const requireModule = (0, node_module_1.createRequire)(__filename);
45
+ // A JSON file is data; a JS module is data too — loaded by the runtime, not
46
+ // re-implemented here.
47
+ const readOf = (abs) => {
48
+ if (/\.json$/i.test(abs)) {
49
+ const parsed = JSON.parse(fs.readFileSync(abs, "utf8"));
50
+ return parsed;
51
+ }
52
+ // The module cache is fine for a config: it is read once per run.
53
+ const loaded = requireModule(abs);
54
+ return (0, field_1.isRecordValue)(loaded) && loaded.default !== undefined ? loaded.default : loaded;
55
+ };
56
+ const loadConfigs = ({ repoRoot, configs }) => {
57
+ const values = {};
58
+ const missing = [];
59
+ const errors = [];
60
+ for (const [key, rel] of Object.entries(configs ?? {})) {
61
+ const abs = path.isAbsolute(rel) ? rel : path.resolve(repoRoot ?? ".", rel);
62
+ if (!fs.existsSync(abs)) {
63
+ values[key] = null;
64
+ missing.push({ key, path: rel });
65
+ continue;
66
+ }
67
+ try {
68
+ values[key] = { path: rel, abs, data: readOf(abs) };
69
+ }
70
+ catch (error) {
71
+ const e = error;
72
+ values[key] = null;
73
+ errors.push({ key, path: rel, message: (e.message ?? "").split("\n")[0] });
74
+ }
75
+ }
76
+ return { values, missing, errors };
77
+ };
78
+ exports.loadConfigs = loadConfigs;
79
+ // What a rule sees: `configs.tailwind` is the data, `null` when a declared key
80
+ // could not be read, and the whole object absent when nothing was declared.
81
+ const configFacts = ({ values }) => {
82
+ const facts = {};
83
+ for (const [key, value] of Object.entries(values))
84
+ facts[key] = value ? value.data : null;
85
+ return facts;
86
+ };
87
+ exports.configFacts = configFacts;
@@ -0,0 +1,7 @@
1
+ type Count = {
2
+ key: string;
3
+ count: number;
4
+ };
5
+ declare const countBy: <Item>(items: readonly Item[], keyOf: (item: Item) => string) => Count[];
6
+ export { countBy };
7
+ export type { Count };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countBy = void 0;
4
+ // Count `items` by `keyOf`, most frequent first (ties keep first-seen order).
5
+ const countBy = (items, keyOf) => {
6
+ const map = new Map();
7
+ for (const item of items) {
8
+ const key = keyOf(item);
9
+ map.set(key, (map.get(key) ?? 0) + 1);
10
+ }
11
+ return [...map.entries()].sort((a, b) => b[1] - a[1]).map(([key, count]) => ({ key, count }));
12
+ };
13
+ exports.countBy = countBy;
@@ -0,0 +1,2 @@
1
+ declare const dispatchOn: <Subject, Discriminant extends string | number, Answer>(subject: Subject | null | undefined, discriminantOf: (subject: Subject) => Discriminant | null | undefined, readers: ReadonlyMap<Discriminant, (subject: Subject) => Answer>, fallback: (subject: Subject | null | undefined) => Answer) => Answer;
2
+ export { dispatchOn };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dispatchOn = void 0;
4
+ // A DISPATCH is one mechanism: a subject carries a discriminant, a table says
5
+ // which reader answers which case, and anything unclaimed falls to one default
6
+ // reading. A function-like node dispatches on the parser's kind to find its name
7
+ // (a named kind answers its own, anything else asks its parent —
8
+ // `entities/ast/functions`); a class attribute's initializer dispatches on the
9
+ // parser's kind to read its text (a literal, a `{expr}` — `css/markup`). The walk
10
+ // is the same — read the discriminant, ask the claiming reader, otherwise the
11
+ // default — so it lives here once. What the cases ARE and how each is read is the
12
+ // caller's own; nothing here knows functions or JSX.
13
+ // Answer `subject` by its discriminant: the claiming reader's answer when a
14
+ // reader claims the case, the default reading otherwise (including a missing
15
+ // subject or discriminant — an absent thing is nobody's case). The fallback is
16
+ // LAZY: a claiming reader's own answer (even null) is final and never overridden,
17
+ // and the default is computed only when no reader claims the case.
18
+ const dispatchOn = (subject, discriminantOf, readers, fallback) => {
19
+ if (subject == null)
20
+ return fallback(subject);
21
+ const discriminant = discriminantOf(subject);
22
+ const reader = discriminant == null ? undefined : readers.get(discriminant);
23
+ if (!reader)
24
+ return fallback(subject);
25
+ return reader(subject);
26
+ };
27
+ exports.dispatchOn = dispatchOn;
@@ -0,0 +1,2 @@
1
+ declare const distinctFlat: <T>(items: readonly T[], namesOf: (item: T) => readonly string[]) => string[];
2
+ export { distinctFlat };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.distinctFlat = void 0;
4
+ // A DISTINCT COLLECT is one mechanism: every item of a list contributes names
5
+ // (zero, one, or many), and the answer is the names in first-seen order, each
6
+ // once. A component's props are the distinct names its parameters contribute
7
+ // (`frameworks/react`); an entity's shape is the distinct roles its children
8
+ // declare (`nodes/similar`). The walk is the same — flatMap the contributions,
9
+ // keep the first of each — so it lives here once. What a name IS and where it
10
+ // comes from is the caller's own.
11
+ const distinctFlat = (items, namesOf) => [...new Set(items.flatMap(namesOf))];
12
+ exports.distinctFlat = distinctFlat;
@@ -0,0 +1,14 @@
1
+ type FieldValue = string | number | boolean | null | undefined | readonly FieldValue[] | {
2
+ readonly [key: string]: FieldValue;
3
+ };
4
+ declare const isList: <V>(v: V) => v is V & readonly FieldValue[];
5
+ declare const isObj: <V>(v: V) => v is V & {
6
+ readonly [key: string]: FieldValue;
7
+ };
8
+ declare const isRecordValue: (v: FieldValue) => v is {
9
+ readonly [key: string]: FieldValue;
10
+ };
11
+ declare const toList: (v: FieldValue) => FieldValue[];
12
+ declare const fieldOf: (item: FieldValue, key: string) => FieldValue;
13
+ export { fieldOf, isObj, isRecordValue, isList, toList };
14
+ export type { FieldValue };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toList = exports.isList = exports.isRecordValue = exports.isObj = exports.fieldOf = void 0;
4
+ // The generic narrowing guards: they keep the caller's own type (`V`) while
5
+ // adding the list/record view, so a typed fact stays typed through the walk.
6
+ // `isObj` is the ONE record guard — every "is this a record" question reads it.
7
+ const isList = (v) => Array.isArray(v);
8
+ exports.isList = isList;
9
+ const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
10
+ exports.isObj = isObj;
11
+ // A record view of a plain value (never an array): the typed specialisation of
12
+ // `isObj` for the `FieldValue` model, used where a key would otherwise collide
13
+ // with an Array method (`filter`, `length`, …).
14
+ const isRecordValue = (v) => isObj(v);
15
+ exports.isRecordValue = isRecordValue;
16
+ // A value as a list: null/undefined → nothing, a list → its items, a scalar → one
17
+ // item. The ONE spelling of "list-or-single", shared by every `where`/`infer` reader.
18
+ const toList = (v) => {
19
+ if (v == null)
20
+ return [];
21
+ if (isList(v))
22
+ return [...v];
23
+ return [v];
24
+ };
25
+ exports.toList = toList;
26
+ const ARRAY_INDEX = /^\d+$/;
27
+ // Read ONE key off a value: a list answers `length` and its own indices, an
28
+ // object answers its keys, anything else answers nothing.
29
+ const readOne = (acc, k) => {
30
+ if (isList(acc)) {
31
+ if (k === "length")
32
+ return acc.length;
33
+ return ARRAY_INDEX.test(k) && Number(k) < acc.length ? acc[Number(k)] : undefined;
34
+ }
35
+ return isRecordValue(acc) ? acc[k] : undefined;
36
+ };
37
+ // The value of a key that is NOT present on a list: what the segment names in
38
+ // every element, flattened one level. `fieldOf` already answers `undefined` for a
39
+ // null element, and `toList` turns that into nothing — so the walk is one call.
40
+ const acrossList = (acc, k) => acc.flatMap((entry) => toList(fieldOf(entry, k)));
41
+ const fieldOf = (item, key) => {
42
+ if (item == null)
43
+ return undefined;
44
+ if (!String(key).includes("."))
45
+ return readOne(item, key);
46
+ return String(key)
47
+ .split(".")
48
+ .reduce((acc, k) => {
49
+ if (acc == null)
50
+ return undefined;
51
+ // A segment a list ITSELF answers (`length`, an index) is read; any other
52
+ // segment is collected across the list.
53
+ if (isList(acc) && (k === "length" || (ARRAY_INDEX.test(k) && Number(k) < acc.length)))
54
+ return readOne(acc, k);
55
+ if (isList(acc))
56
+ return acrossList(acc, k);
57
+ return readOne(acc, k);
58
+ }, item);
59
+ };
60
+ exports.fieldOf = fieldOf;
@@ -0,0 +1,2 @@
1
+ declare const fileName: (p: string | null | undefined) => string;
2
+ export { fileName };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fileName = void 0;
4
+ // A FILE NAME is one mechanism: the last segment of a path. The browser names a
5
+ // place-box by its file (`graph/representation/fileContents`); any consumer that
6
+ // reads a path's leaf asks the same question. The split is the shared `partsOf`
7
+ // core; nothing here knows what the path MEANS.
8
+ const split_1 = require("./split");
9
+ // The last segment of a path (`a/b/c.ts` → `c.ts`); an empty path names nothing.
10
+ const fileName = (p) => (p ? (0, split_1.partsOf)(p, "/").last : "");
11
+ exports.fileName = fileName;
@@ -0,0 +1,7 @@
1
+ interface ScanOptions {
2
+ exts: string[];
3
+ ignoreDirs: string[];
4
+ ignoreGlobs?: string[];
5
+ }
6
+ declare const collectFiles: (repoRoot: string, { exts, ignoreDirs, ignoreGlobs }: ScanOptions) => string[];
7
+ export { collectFiles };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.collectFiles = void 0;
27
+ // The ONE directory walk: which files of a repo the tool looks at. Scan scope is
28
+ // the tool's (extensions, skipped folders, skipped globs), never the
29
+ // architecture's — so there is one walker and two callers.
30
+ const fs = __importStar(require("node:fs"));
31
+ const path = __importStar(require("node:path"));
32
+ const minimatch_1 = require("minimatch");
33
+ const imports_1 = require("./imports");
34
+ const notices_1 = require("../report/notices");
35
+ // Absolute paths of every scanned file under `repoRoot`.
36
+ const collectFiles = (repoRoot, { exts, ignoreDirs, ignoreGlobs = [] }) => {
37
+ const extSet = new Set(exts);
38
+ const ignoreSet = new Set(ignoreDirs);
39
+ const out = [];
40
+ const walk = (dir) => {
41
+ let entries = [];
42
+ try {
43
+ entries = fs.readdirSync(dir, { withFileTypes: true });
44
+ }
45
+ catch (error) {
46
+ const e = error;
47
+ // An unreadable folder is not a scan error: the file list just does not
48
+ // include it (folder facts degrade, the rule still runs). The reason is
49
+ // reported, so a short list never looks like a complete one.
50
+ (0, notices_1.notice)(`the folder ${dir} could not be read`, e.message ?? String(e));
51
+ return;
52
+ }
53
+ for (const entry of entries) {
54
+ const abs = path.join(dir, entry.name);
55
+ if (entry.isDirectory()) {
56
+ if (!ignoreSet.has(entry.name))
57
+ walk(abs);
58
+ }
59
+ else if (extSet.has(path.extname(entry.name)) && !(ignoreGlobs ?? []).some((g) => (0, minimatch_1.minimatch)((0, imports_1.toRel)(repoRoot, abs), g))) {
60
+ out.push(abs);
61
+ }
62
+ }
63
+ };
64
+ walk(repoRoot);
65
+ // SORTED, always: `readdirSync` returns whatever order the filesystem
66
+ // happens to keep (hashed on btrfs, insertion on ext4), so without this the
67
+ // same tree produced a different report from one machine — or one run — to
68
+ // the next. The order is not cosmetic: a `dedupeBy` finding is reported for
69
+ // the FIRST file that reaches a place, so an unstable list moves the
70
+ // finding between files.
71
+ return out.sort();
72
+ };
73
+ exports.collectFiles = collectFiles;
@@ -0,0 +1,2 @@
1
+ declare const untilStable: (step: () => boolean, maxPasses: number) => void;
2
+ export { untilStable };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.untilStable = void 0;
4
+ // A FIXPOINT is one mechanism: a step changes state and reports whether it did,
5
+ // and the walk repeats until a step changes nothing (or a stated pass limit is
6
+ // reached). Role assignment and call-target resolution feed each other — a
7
+ // role may be inferred from the roles of the callees, while a callee's role is
8
+ // what classification resolves — so the passes repeat until nothing moves.
9
+ // The walk is the same for any mutually-feeding enrichment; what a step DOES
10
+ // is the caller's own.
11
+ // Run `step` until it reports no change, at most `maxPasses` times. The first
12
+ // pass always runs; the step's own verdict decides every next one.
13
+ const untilStable = (step, maxPasses) => {
14
+ for (let pass = 0; pass < maxPasses; pass += 1) {
15
+ if (!step())
16
+ return;
17
+ }
18
+ };
19
+ exports.untilStable = untilStable;
@@ -0,0 +1,2 @@
1
+ declare const admitsWhenNoneReject: <Subject>(subject: Subject, rejects: readonly ((subject: Subject) => boolean)[]) => boolean;
2
+ export { admitsWhenNoneReject };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.admitsWhenNoneReject = void 0;
4
+ // A GATE is one mechanism: a subject is admitted when NONE of the rejection
5
+ // verdicts fires. The CSS content gate rejects a document with no structure, a
6
+ // data-format selector, or no grammar-known property (`css/syntax/css`); the AST
7
+ // read gate rejects a member access that is an inner hop, a write target or an
8
+ // operand (`entities/ast/properties`). The decision is the same — run every
9
+ // verdict, admit only when all pass — so it lives here once. What counts as a
10
+ // rejection is the caller's own policy; nothing here knows CSS or the AST.
11
+ const admitsWhenNoneReject = (subject, rejects) => !rejects.some((reject) => reject(subject));
12
+ exports.admitsWhenNoneReject = admitsWhenNoneReject;
@@ -0,0 +1,3 @@
1
+ declare const groupBy: <Item, Key>(items: readonly Item[], keyOf: (item: Item) => Key) => [Key, Item[]][];
2
+ declare const pushGroup: <Key, Item>(map: Map<Key, Item[]>, key: Key, item: Item) => void;
3
+ export { groupBy, pushGroup };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pushGroup = exports.groupBy = void 0;
4
+ // A GROUPED LIST is one mechanism: items arrive with a key, and the answer is
5
+ // the buckets in first-seen order, each holding its items. The browser groups
6
+ // edges / findings by a key (`utils/format`); any consumer that folds a list
7
+ // into ordered buckets asks the same question. The walk lives here once; what
8
+ // the key MEANS is the caller's own.
9
+ // Group `items` by `keyOf`, preserving first-seen bucket order.
10
+ const groupBy = (items, keyOf) => {
11
+ const map = new Map();
12
+ for (const item of items) {
13
+ const key = keyOf(item);
14
+ const bucket = map.get(key);
15
+ if (bucket)
16
+ bucket.push(item);
17
+ else
18
+ map.set(key, [item]);
19
+ }
20
+ return [...map.entries()];
21
+ };
22
+ exports.groupBy = groupBy;
23
+ // Push ONE item into the bucket `key` names, creating the bucket on first use —
24
+ // the in-place counterpart of `groupBy` for a map built across several calls
25
+ // (a provider set, a scope's variables). One spelling of get-or-create.
26
+ const pushGroup = (map, key, item) => {
27
+ const bucket = map.get(key);
28
+ if (bucket)
29
+ bucket.push(item);
30
+ else
31
+ map.set(key, [item]);
32
+ };
33
+ exports.pushGroup = pushGroup;
@@ -0,0 +1,3 @@
1
+ import type { Candidate } from "../entities/facts";
2
+ declare const hostOf: (candidates: readonly Candidate[], line: number | null) => Candidate | undefined;
3
+ export { hostOf };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hostOf = void 0;
4
+ const spansLine = (candidate, line) => Array.isArray(candidate.lines) && candidate.lines.length > 0 && candidate.lines[0] <= line && line <= candidate.lines[candidate.lines.length - 1];
5
+ const isLater = (a, b, list) => list.indexOf(b) - list.indexOf(a);
6
+ const hostOf = (candidates, line) => {
7
+ if (line === null)
8
+ return undefined;
9
+ return [...candidates]
10
+ .filter((candidate) => spansLine(candidate, line))
11
+ .sort((a, b) => (a.lines?.length ?? 0) - (b.lines?.length ?? 0) || isLater(a, b, candidates))[0];
12
+ };
13
+ exports.hostOf = hostOf;
@@ -0,0 +1,12 @@
1
+ import { type SourceFile } from "ts-morph";
2
+ type Aliases = Record<string, string>;
3
+ declare const toRel: (repoRoot: string, filePath: string) => string;
4
+ declare const pathsOf: (aliases?: Aliases) => Record<string, string[]>;
5
+ interface ResolveContext {
6
+ repoRoot: string;
7
+ aliases?: Aliases;
8
+ repoFiles?: readonly string[];
9
+ }
10
+ declare const resolveImport: (sf: SourceFile, source: string, { repoRoot, aliases, repoFiles }: ResolveContext) => string | null;
11
+ export { resolveImport, toRel, pathsOf };
12
+ export type { ResolveContext };
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.pathsOf = exports.toRel = exports.resolveImport = void 0;
27
+ // Import resolution — the one mechanism by which any entity points at another
28
+ // file. A reference is either an alias (see the `aliases` entity) or a relative
29
+ // module path.
30
+ //
31
+ // The lookup itself is TypeScript's (`resolveModuleName` with the aliases
32
+ // injected as `paths`), so the engine never keeps its own list of extensions or
33
+ // index files — the compiler that parses the code decides where an import
34
+ // points. The files it may find are the ones the tool actually scans
35
+ // (`repoFiles`) plus whatever the project has loaded, so a resolution never
36
+ // escapes the architecture's own file set.
37
+ const path = __importStar(require("node:path"));
38
+ const ts_morph_1 = require("ts-morph");
39
+ const notices_1 = require("../report/notices");
40
+ const resolve_1 = require("./resolve");
41
+ const norm = (p) => String(p).replace(/\\/g, "/");
42
+ const toRel = (repoRoot, filePath) => norm(path.relative(repoRoot, filePath));
43
+ exports.toRel = toRel;
44
+ // The YAML `aliases` map says `alias → folder or entry file`, which is exactly
45
+ // what TypeScript's `paths` expresses in two entries: the alias itself and its
46
+ // subpaths (`alias/x` → `folder/x`).
47
+ //
48
+ // An alias that names a FILE (`"@md/styles": packages/styles/index.ts`) is the
49
+ // common case, and its subpaths go through that file's DIRECTORY: `index.ts/*`
50
+ // names a folder that cannot exist, so `@md/styles/themes/viking` never resolved
51
+ // and the checker failed on it later.
52
+ const ENTRY_FILE = /\.[cm]?[jt]sx?$/;
53
+ const pathsOf = (aliases) => {
54
+ const paths = {};
55
+ for (const [alias, target] of Object.entries(aliases ?? {})) {
56
+ paths[alias] = [target];
57
+ const base = ENTRY_FILE.test(target) ? target.replace(/\/[^/]*$/, "") : target;
58
+ paths[`${alias}/*`] = [`${base}/*`];
59
+ }
60
+ return paths;
61
+ };
62
+ exports.pathsOf = pathsOf;
63
+ // The folders the scanned files live in, derived once per file list: the
64
+ // resolver asks "does this folder exist" far more often than it asks anything
65
+ // else, and a folder exists here when the architecture has a file in it.
66
+ const foldersCache = new WeakMap();
67
+ const foldersOf = (repoFiles) => {
68
+ let folders = foldersCache.get(repoFiles);
69
+ if (!folders) {
70
+ folders = new Set([""]);
71
+ for (const file of repoFiles ?? []) {
72
+ const parts = file.split("/");
73
+ for (let i = 1; i < parts.length; i += 1)
74
+ folders.add(parts.slice(0, i).join("/"));
75
+ }
76
+ foldersCache.set(repoFiles, folders);
77
+ }
78
+ return folders;
79
+ };
80
+ // Where the resolver may look: the scanned file list, plus the project's own
81
+ // file system (a real project reads the disk, a test project reads memory).
82
+ const resolutionHost = (project, repoRoot, repoFiles) => {
83
+ const files = project.getFileSystem();
84
+ const scanned = new Set(repoFiles ?? []);
85
+ const folders = foldersOf(repoFiles ?? []);
86
+ return {
87
+ fileExists: (p) => scanned.has(toRel(repoRoot, p)) || files.fileExistsSync(p),
88
+ readFile: (p) => {
89
+ try {
90
+ return files.readFileSync(p);
91
+ }
92
+ catch (error) {
93
+ const e = error;
94
+ // The resolver PROBES paths, so a missing file is an answer, not a
95
+ // failure. Any other reason is reported: that file exists and is
96
+ // unreadable, which changes what the analysis knows.
97
+ if (e.code !== "ENOENT")
98
+ (0, notices_1.notice)(`the file ${p} could not be read`, e.message ?? String(e));
99
+ return undefined;
100
+ }
101
+ },
102
+ directoryExists: (p) => folders.has(toRel(repoRoot, p)) || files.directoryExistsSync(p),
103
+ // `node_modules` walks are not a relation the architecture can describe:
104
+ // anything resolved outside the scanned set is dropped below anyway.
105
+ getDirectories: () => [],
106
+ realpath: (p) => p,
107
+ useCaseSensitiveFileNames: () => true,
108
+ };
109
+ };
110
+ // Resolve an import source (relative path or alias) to a repo-relative file.
111
+ // A resolution that lands outside the scanned set (a `.d.ts`, a file in an
112
+ // ignored folder) is not a relation the architecture can talk about → null.
113
+ // The walk (reference → target → answer) is the shared `resolveReference`; the
114
+ // compiler lookup and the scanned-set verdict are this reader's own.
115
+ const resolveImport = (sf, source, { repoRoot, aliases, repoFiles }) => (0, resolve_1.resolveReference)(source || null, (specifier) => ts_morph_1.ts.resolveModuleName(specifier, sf.getFilePath(), { baseUrl: repoRoot, paths: pathsOf(aliases), moduleResolution: ts_morph_1.ts.ModuleResolutionKind.Node10, allowJs: true }, resolutionHost(sf.getProject(), repoRoot, repoFiles ?? [])).resolvedModule, (resolved) => {
116
+ const rel = toRel(repoRoot, resolved.resolvedFileName);
117
+ if (repoFiles && !repoFiles.includes(rel))
118
+ return null;
119
+ return rel;
120
+ });
121
+ exports.resolveImport = resolveImport;
@@ -0,0 +1,5 @@
1
+ declare const judgedItems: <Item, Verdict>(items: readonly Item[], judge: (item: Item) => Verdict | null) => {
2
+ item: Item;
3
+ verdict: Verdict;
4
+ }[];
5
+ export { judgedItems };