@md-code/follow-architecture 0.3.0 → 0.3.2

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 (387) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1310 -472
  3. package/dist/args.d.ts +4 -0
  4. package/dist/args.js +18 -1
  5. package/dist/bin/follow-architecture.js +3 -3
  6. package/dist/closure-project.d.ts +4 -0
  7. package/dist/closure-project.js +132 -0
  8. package/dist/code-entities/classify.d.ts +11 -0
  9. package/dist/code-entities/classify.js +45 -0
  10. package/dist/code-entities/connector.d.ts +8 -0
  11. package/dist/code-entities/connector.js +119 -0
  12. package/dist/code-entities/entities.d.ts +9 -0
  13. package/dist/{code-roles/roles.js → code-entities/entities.js} +98 -61
  14. package/dist/code-entities/project.d.ts +21 -0
  15. package/dist/code-entities/project.js +259 -0
  16. package/dist/code-entities/walk.d.ts +31 -0
  17. package/dist/code-entities/walk.js +105 -0
  18. package/dist/config-options.d.ts +23 -0
  19. package/dist/config-options.js +18 -1
  20. package/dist/config-project.js +27 -9
  21. package/dist/config-report.d.ts +1 -1
  22. package/dist/config-report.js +37 -10
  23. package/dist/config-rule.d.ts +25 -0
  24. package/dist/config-rule.js +106 -13
  25. package/dist/config-state.d.ts +14 -3
  26. package/dist/config-state.js +197 -24
  27. package/dist/config.d.ts +25 -0
  28. package/dist/css/index.d.ts +11 -7
  29. package/dist/css/index.js +141 -30
  30. package/dist/css/syntax/css/gate.js +5 -5
  31. package/dist/css/syntax/css/index.d.ts +1 -1
  32. package/dist/css/syntax/css/index.js +18 -8
  33. package/dist/css/syntax/css/reference.d.ts +1 -1
  34. package/dist/css/syntax/css/reference.js +15 -3
  35. package/dist/css/syntax/language.d.ts +1 -1
  36. package/dist/css/syntax/language.js +21 -9
  37. package/dist/css/syntax/scss/index.d.ts +2 -2
  38. package/dist/css/syntax/scss/index.js +18 -8
  39. package/dist/css/syntax/scss/reference.d.ts +1 -1
  40. package/dist/css/syntax/scss/reference.js +7 -1
  41. package/dist/css/syntax/styled/document.d.ts +3 -3
  42. package/dist/css/syntax/styled/document.js +34 -14
  43. package/dist/css/syntax/styled/markup.d.ts +1 -1
  44. package/dist/css/syntax/styled/markup.js +22 -14
  45. package/dist/css/syntax/styled/tags.d.ts +2 -0
  46. package/dist/css/syntax/styled/tags.js +22 -0
  47. package/dist/css/syntax/styled/template.js +10 -4
  48. package/dist/css/syntax/tailwind/tailwind.js +4 -4
  49. package/dist/css/value/check.d.ts +1 -1
  50. package/dist/css/value/check.js +1 -1
  51. package/dist/css/value/expression/arithmetic.d.ts +2 -2
  52. package/dist/css/value/expression/arithmetic.js +7 -3
  53. package/dist/css/value/expression/block.d.ts +2 -2
  54. package/dist/css/value/expression/block.js +4 -3
  55. package/dist/css/value/expression/conditional.d.ts +2 -2
  56. package/dist/css/value/expression/conditional.js +1 -1
  57. package/dist/css/value/expression/index.d.ts +2 -2
  58. package/dist/css/value/expression/index.js +10 -6
  59. package/dist/css/value/expression/map.d.ts +2 -2
  60. package/dist/css/value/expression/map.js +2 -2
  61. package/dist/css/value/object/index.d.ts +2 -2
  62. package/dist/css/value/object/index.js +14 -4
  63. package/dist/css/value/object/members.d.ts +2 -2
  64. package/dist/css/value/object/node.js +9 -4
  65. package/dist/css/value/object/path.d.ts +3 -3
  66. package/dist/css/value/object/path.js +10 -4
  67. package/dist/css/value/pieces.d.ts +3 -3
  68. package/dist/css/value/pieces.js +14 -4
  69. package/dist/css/value/resolve.js +15 -5
  70. package/dist/css/value/scope.d.ts +3 -2
  71. package/dist/css/value/scope.js +25 -7
  72. package/dist/css/value/substitute.js +43 -11
  73. package/dist/entities/architecture.d.ts +28 -25
  74. package/dist/entities/ast/assignments-raw.d.ts +1 -1
  75. package/dist/entities/ast/assignments-raw.js +61 -8
  76. package/dist/entities/ast/assignments-tagged.d.ts +1 -1
  77. package/dist/entities/ast/assignments-tagged.js +22 -7
  78. package/dist/entities/ast/assignments.d.ts +1 -1
  79. package/dist/entities/ast/assignments.js +6 -4
  80. package/dist/entities/ast/branches.d.ts +1 -1
  81. package/dist/entities/ast/calls.d.ts +1 -1
  82. package/dist/entities/ast/calls.js +19 -3
  83. package/dist/entities/ast/classes.d.ts +1 -1
  84. package/dist/entities/ast/classes.js +5 -1
  85. package/dist/entities/ast/comments.d.ts +3 -2
  86. package/dist/entities/ast/comments.js +47 -17
  87. package/dist/entities/ast/declaration.d.ts +1 -1
  88. package/dist/entities/ast/depth.d.ts +2 -2
  89. package/dist/entities/ast/depth.js +32 -15
  90. package/dist/entities/ast/enums.d.ts +1 -1
  91. package/dist/entities/ast/export-chain.d.ts +15 -0
  92. package/dist/entities/ast/export-chain.js +171 -0
  93. package/dist/entities/ast/file-exports.d.ts +1 -1
  94. package/dist/entities/ast/file-exports.js +26 -3
  95. package/dist/entities/ast/file-facts.d.ts +6 -3
  96. package/dist/entities/ast/file-facts.js +33 -4
  97. package/dist/entities/ast/file-imports.d.ts +1 -1
  98. package/dist/entities/ast/file-imports.js +26 -3
  99. package/dist/entities/ast/file.d.ts +2 -2
  100. package/dist/entities/ast/file.js +2 -1
  101. package/dist/entities/ast/functions.d.ts +1 -1
  102. package/dist/entities/ast/functions.js +13 -4
  103. package/dist/entities/ast/heritage.d.ts +1 -1
  104. package/dist/entities/ast/heritage.js +9 -1
  105. package/dist/entities/ast/index.d.ts +6 -3
  106. package/dist/entities/ast/index.js +82 -26
  107. package/dist/entities/ast/kind.d.ts +1 -1
  108. package/dist/entities/ast/kind.js +7 -1
  109. package/dist/entities/ast/modifiers.d.ts +1 -1
  110. package/dist/entities/ast/modifiers.js +4 -4
  111. package/dist/entities/ast/project.js +33 -2
  112. package/dist/entities/ast/properties.d.ts +1 -1
  113. package/dist/entities/ast/properties.js +10 -5
  114. package/dist/entities/ast/resolve.d.ts +1 -1
  115. package/dist/entities/ast/resolve.js +21 -11
  116. package/dist/entities/ast/tree.d.ts +4 -2
  117. package/dist/entities/ast/tree.js +184 -17
  118. package/dist/entities/ast/types.d.ts +1 -1
  119. package/dist/entities/ast/types.js +2 -1
  120. package/dist/entities/ast/usage.d.ts +1 -1
  121. package/dist/entities/ast/usage.js +1 -1
  122. package/dist/entities/ast/variables.d.ts +1 -1
  123. package/dist/entities/context.d.ts +4 -4
  124. package/dist/entities/facts.d.ts +36 -13
  125. package/dist/entities/findings.d.ts +3 -3
  126. package/dist/entities/kinds.d.ts +1 -1
  127. package/dist/entities/kinds.js +148 -37
  128. package/dist/entities/location/homes.d.ts +10 -10
  129. package/dist/entities/location/homes.js +74 -48
  130. package/dist/entities/location/place.d.ts +1 -1
  131. package/dist/entities/location/place.js +10 -3
  132. package/dist/entities/location/where.d.ts +10 -8
  133. package/dist/entities/location/where.js +89 -30
  134. package/dist/entities/location.d.ts +3 -3
  135. package/dist/entities/location.js +17 -17
  136. package/dist/entities/operators.js +1 -1
  137. package/dist/entities/overview/data.d.ts +6 -6
  138. package/dist/entities/overview/decision.d.ts +11 -11
  139. package/dist/entities/overview/finding.d.ts +10 -10
  140. package/dist/entities/overview/graph.d.ts +28 -11
  141. package/dist/entities/overview/input.d.ts +2 -2
  142. package/dist/entities/overview/summaries.d.ts +17 -15
  143. package/dist/entities/queries.d.ts +1 -1
  144. package/dist/entities/queries.js +89 -19
  145. package/dist/entities/repair.d.ts +1 -1
  146. package/dist/entities/repair.js +8 -2
  147. package/dist/entities/schema.d.ts +17 -3
  148. package/dist/entities/schema.js +74 -16
  149. package/dist/entities/story.d.ts +5 -5
  150. package/dist/entities/structure-facts.d.ts +1 -1
  151. package/dist/entities/token.d.ts +4 -4
  152. package/dist/entities/tree/build.d.ts +4 -3
  153. package/dist/entities/tree/build.js +112 -51
  154. package/dist/entities/tree/entries.d.ts +4 -4
  155. package/dist/entities/tree/entries.js +41 -16
  156. package/dist/entities/tree/index.d.ts +2 -2
  157. package/dist/entities/tree/index.js +1 -1
  158. package/dist/entities/tree/match.d.ts +2 -2
  159. package/dist/entities/tree/match.js +26 -12
  160. package/dist/fa-index.d.ts +16 -0
  161. package/dist/fa-index.js +165 -0
  162. package/dist/fa-open.d.ts +51 -0
  163. package/dist/fa-open.js +242 -0
  164. package/dist/fa-store.d.ts +22 -0
  165. package/dist/fa-store.js +232 -0
  166. package/dist/fa-values.d.ts +37 -0
  167. package/dist/fa-values.js +104 -0
  168. package/dist/facts-record.d.ts +45 -0
  169. package/dist/facts-record.js +297 -0
  170. package/dist/frameworks/angular/index.d.ts +2 -2
  171. package/dist/frameworks/angular/index.js +2 -1
  172. package/dist/frameworks/facet.d.ts +3 -1
  173. package/dist/frameworks/facet.js +13 -0
  174. package/dist/frameworks/index.d.ts +1 -1
  175. package/dist/frameworks/index.js +25 -11
  176. package/dist/frameworks/react/index.d.ts +2 -2
  177. package/dist/frameworks/react/index.js +33 -10
  178. package/dist/frameworks/test/index.d.ts +6 -0
  179. package/dist/frameworks/test/index.js +157 -0
  180. package/dist/frameworks/vue/index.d.ts +2 -2
  181. package/dist/frameworks/vue/index.js +2 -1
  182. package/dist/ignore.d.ts +3 -0
  183. package/dist/ignore.js +62 -0
  184. package/dist/index-file.d.ts +43 -0
  185. package/dist/index-file.js +218 -0
  186. package/dist/index-run.d.ts +39 -0
  187. package/dist/index-run.js +217 -0
  188. package/dist/index-zone.d.ts +25 -0
  189. package/dist/index-zone.js +219 -0
  190. package/dist/main.d.ts +5 -2
  191. package/dist/main.js +223 -41
  192. package/dist/nodes/child-entities.d.ts +3 -0
  193. package/dist/nodes/child-entities.js +12 -0
  194. package/dist/nodes/children.d.ts +4 -4
  195. package/dist/nodes/children.js +64 -11
  196. package/dist/nodes/finally/emit.d.ts +4 -4
  197. package/dist/nodes/finally/emit.js +26 -10
  198. package/dist/nodes/finally/entities.d.ts +13 -0
  199. package/dist/nodes/finally/entities.js +42 -0
  200. package/dist/nodes/finally/index.d.ts +6 -6
  201. package/dist/nodes/finally/index.js +8 -8
  202. package/dist/nodes/finally/queries.d.ts +2 -2
  203. package/dist/nodes/finally/queries.js +7 -4
  204. package/dist/nodes/finally/relations-access.d.ts +2 -2
  205. package/dist/nodes/finally/relations-access.js +22 -18
  206. package/dist/nodes/finally/relations-edge.d.ts +5 -5
  207. package/dist/nodes/finally/relations-edge.js +67 -44
  208. package/dist/nodes/finally/relations-group.d.ts +7 -7
  209. package/dist/nodes/finally/relations-group.js +28 -25
  210. package/dist/nodes/finally/relations.d.ts +2 -2
  211. package/dist/nodes/finally/relations.js +16 -12
  212. package/dist/nodes/finally/required.d.ts +3 -3
  213. package/dist/nodes/finally/required.js +9 -7
  214. package/dist/nodes/finally/violation.d.ts +2 -2
  215. package/dist/nodes/similar.d.ts +3 -3
  216. package/dist/nodes/similar.js +78 -56
  217. package/dist/piece-forms.d.ts +9 -0
  218. package/dist/piece-forms.js +68 -0
  219. package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
  220. package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
  221. package/dist/pipeline-facts.d.ts +4 -3
  222. package/dist/pipeline-facts.js +64 -62
  223. package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
  224. package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
  225. package/dist/pipeline.d.ts +1 -1
  226. package/dist/pipeline.js +19 -64
  227. package/dist/release-file.d.ts +3 -0
  228. package/dist/release-file.js +13 -0
  229. package/dist/report/asks.d.ts +3 -3
  230. package/dist/report/asks.js +16 -6
  231. package/dist/report/configErrors.d.ts +55 -27
  232. package/dist/report/configErrors.js +81 -35
  233. package/dist/report/errorTypes/codes/structure.d.ts +1 -1
  234. package/dist/report/errorTypes/codes/structure.js +9 -9
  235. package/dist/report/errorTypes/decision-maker.d.ts +5 -5
  236. package/dist/report/errorTypes/decision-maker.js +21 -11
  237. package/dist/report/errorTypes/destinations.d.ts +5 -5
  238. package/dist/report/errorTypes/destinations.js +52 -34
  239. package/dist/report/errorTypes/finding-type.d.ts +3 -3
  240. package/dist/report/errorTypes/index.d.ts +1 -1
  241. package/dist/report/errorTypes/index.js +17 -7
  242. package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
  243. package/dist/report/errorTypes/types/fileContents.js +11 -5
  244. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  245. package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
  246. package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
  247. package/dist/report/errorTypes/types/wrongAction.js +18 -13
  248. package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
  249. package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
  250. package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
  251. package/dist/report/errorTypes/vocabulary/ids.js +3 -3
  252. package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
  253. package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
  254. package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
  255. package/dist/report/errorTypes/vocabulary/places.js +13 -13
  256. package/dist/report/finding-from.d.ts +3 -3
  257. package/dist/report/finding-from.js +14 -9
  258. package/dist/report/notices.d.ts +6 -1
  259. package/dist/report/notices.js +46 -20
  260. package/dist/report/observed.d.ts +19 -0
  261. package/dist/report/observed.js +87 -0
  262. package/dist/report/render-report.d.ts +1 -1
  263. package/dist/report/render-report.js +33 -30
  264. package/dist/report/user-report/build/bundle.js +26 -7
  265. package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
  266. package/dist/report/user-report/data/collect.d.ts +2 -2
  267. package/dist/report/user-report/data/collect.js +32 -19
  268. package/dist/report/user-report/data/entities.d.ts +7 -0
  269. package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
  270. package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
  271. package/dist/report/user-report/data/entity-examples.js +136 -0
  272. package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
  273. package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
  274. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  275. package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
  276. package/dist/report/user-report/data/file-tree.d.ts +3 -3
  277. package/dist/report/user-report/data/file-tree.js +13 -5
  278. package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
  279. package/dist/report/user-report/data/finding-boundary.js +2 -2
  280. package/dist/report/user-report/data/finding-plan.d.ts +5 -5
  281. package/dist/report/user-report/data/finding-plan.js +10 -10
  282. package/dist/report/user-report/data/finding-title.d.ts +2 -2
  283. package/dist/report/user-report/data/finding-title.js +8 -8
  284. package/dist/report/user-report/data/findings.d.ts +4 -4
  285. package/dist/report/user-report/data/findings.js +30 -20
  286. package/dist/report/user-report/data/graph-edges.d.ts +4 -4
  287. package/dist/report/user-report/data/graph-edges.js +19 -19
  288. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  289. package/dist/report/user-report/data/graph-entities.js +158 -0
  290. package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
  291. package/dist/report/user-report/data/graph-helpers.js +15 -15
  292. package/dist/report/user-report/data/graph.d.ts +5 -4
  293. package/dist/report/user-report/data/graph.js +28 -21
  294. package/dist/report/user-report/data/nodes.d.ts +2 -2
  295. package/dist/report/user-report/data/nodes.js +33 -23
  296. package/dist/report/user-report/data/rules.d.ts +7 -0
  297. package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
  298. package/dist/report/user-report/data/scan.d.ts +1 -1
  299. package/dist/report/user-report/data/scan.js +19 -9
  300. package/dist/report/user-report/html/shell.d.ts +1 -1
  301. package/dist/report/user-report/html/shell.js +1 -1
  302. package/dist/report/user-report/index.d.ts +1 -1
  303. package/dist/report/user-report/index.js +17 -7
  304. package/dist/report/user-report/shared/describe.d.ts +1 -1
  305. package/dist/report/user-report/shared/describe.js +6 -6
  306. package/dist/rules/index.d.ts +7 -0
  307. package/dist/{invariants → rules}/index.js +85 -57
  308. package/dist/{invariants → rules}/list-vars.d.ts +2 -2
  309. package/dist/{invariants → rules}/list-vars.js +9 -3
  310. package/dist/{invariants → rules}/name.js +2 -2
  311. package/dist/rules/normalize.d.ts +5 -0
  312. package/dist/rules/normalize.js +108 -0
  313. package/dist/{invariants → rules}/vars.d.ts +9 -7
  314. package/dist/{invariants → rules}/vars.js +5 -5
  315. package/dist/scan-run.d.ts +20 -0
  316. package/dist/scan-run.js +130 -0
  317. package/dist/scripts/audit-report.js +19 -9
  318. package/dist/usage-index.d.ts +4 -0
  319. package/dist/usage-index.js +282 -0
  320. package/dist/usage-mode.d.ts +7 -0
  321. package/dist/usage-mode.js +16 -0
  322. package/dist/usage-pass.d.ts +19 -0
  323. package/dist/usage-pass.js +136 -0
  324. package/dist/usage-prepare.d.ts +2 -0
  325. package/dist/usage-prepare.js +22 -0
  326. package/dist/usage-sweep.d.ts +10 -0
  327. package/dist/usage-sweep.js +264 -0
  328. package/dist/utils/aliases.d.ts +22 -0
  329. package/dist/utils/aliases.js +173 -0
  330. package/dist/utils/classify.d.ts +2 -2
  331. package/dist/utils/classify.js +4 -4
  332. package/dist/utils/configs.js +17 -7
  333. package/dist/utils/distinct.js +4 -2
  334. package/dist/utils/files.js +41 -37
  335. package/dist/utils/fixpoint.js +2 -2
  336. package/dist/utils/host.d.ts +1 -1
  337. package/dist/utils/host.js +4 -1
  338. package/dist/utils/imports.js +83 -19
  339. package/dist/utils/keyed.js +2 -2
  340. package/dist/utils/map-record.js +2 -2
  341. package/dist/utils/packages.d.ts +15 -0
  342. package/dist/utils/packages.js +207 -0
  343. package/dist/utils/path-label.js +3 -1
  344. package/dist/utils/pattern.d.ts +5 -4
  345. package/dist/utils/pattern.js +55 -15
  346. package/dist/utils/permission.d.ts +3 -3
  347. package/dist/utils/permission.js +4 -2
  348. package/dist/utils/plural.js +2 -2
  349. package/dist/utils/qualified.js +4 -4
  350. package/dist/utils/rank.js +2 -2
  351. package/dist/utils/record.js +1 -1
  352. package/dist/utils/search.js +7 -2
  353. package/dist/utils/speak.js +1 -1
  354. package/dist/utils/split.js +14 -1
  355. package/dist/utils/template.d.ts +1 -1
  356. package/dist/utils/template.js +1 -1
  357. package/dist/utils/tokenize.js +6 -1
  358. package/dist/utils/typed-field.js +2 -2
  359. package/dist/utils/verdicts.js +1 -1
  360. package/entities/operators.ts +1 -1
  361. package/package.json +101 -90
  362. package/report/errorTypes/vocabulary/ids.ts +7 -2
  363. package/report/errorTypes/vocabulary/phrases.ts +47 -27
  364. package/report/errorTypes/vocabulary/places.ts +21 -16
  365. package/report/user-report/shared/describe.ts +7 -7
  366. package/dist/code-roles/classify.d.ts +0 -11
  367. package/dist/code-roles/classify.js +0 -43
  368. package/dist/code-roles/connector.d.ts +0 -5
  369. package/dist/code-roles/connector.js +0 -114
  370. package/dist/code-roles/project.d.ts +0 -12
  371. package/dist/code-roles/project.js +0 -122
  372. package/dist/code-roles/roles.d.ts +0 -8
  373. package/dist/invariants/index.d.ts +0 -6
  374. package/dist/invariants/normalize.d.ts +0 -4
  375. package/dist/invariants/normalize.js +0 -95
  376. package/dist/nodes/child-roles.d.ts +0 -3
  377. package/dist/nodes/child-roles.js +0 -12
  378. package/dist/nodes/finally/roles.d.ts +0 -13
  379. package/dist/nodes/finally/roles.js +0 -41
  380. package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
  381. package/dist/report/user-report/data/graph-roles.d.ts +0 -5
  382. package/dist/report/user-report/data/graph-roles.js +0 -71
  383. package/dist/report/user-report/data/invariants.d.ts +0 -7
  384. package/dist/report/user-report/data/role-examples.js +0 -94
  385. package/dist/report/user-report/data/role-marks.d.ts +0 -5
  386. package/dist/report/user-report/data/roles.d.ts +0 -7
  387. /package/dist/{invariants → rules}/name.d.ts +0 -0
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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];
4
+ const spansLine = (candidate, line) => Array.isArray(candidate.lines) &&
5
+ candidate.lines.length > 0 &&
6
+ candidate.lines[0] <= line &&
7
+ line <= candidate.lines[candidate.lines.length - 1];
5
8
  const isLater = (a, b, list) => list.indexOf(b) - list.indexOf(a);
6
9
  const hostOf = (candidates, line) => {
7
10
  if (line === null)
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.pathsOf = exports.toRel = exports.resolveImport = void 0;
27
37
  // Import resolution — the one mechanism by which any entity points at another
@@ -36,8 +46,10 @@ exports.pathsOf = exports.toRel = exports.resolveImport = void 0;
36
46
  // escapes the architecture's own file set.
37
47
  const path = __importStar(require("node:path"));
38
48
  const ts_morph_1 = require("ts-morph");
39
- const notices_1 = require("../report/notices");
49
+ const notices_1 = require("@md-code/follow-architecture/report/notices");
40
50
  const resolve_1 = require("./resolve");
51
+ const aliases_1 = require("./aliases");
52
+ const packages_1 = require("./packages");
41
53
  const norm = (p) => String(p).replace(/\\/g, "/");
42
54
  const toRel = (repoRoot, filePath) => norm(path.relative(repoRoot, filePath));
43
55
  exports.toRel = toRel;
@@ -48,14 +60,13 @@ exports.toRel = toRel;
48
60
  // An alias that names a FILE (`"@md/styles": packages/styles/index.ts`) is the
49
61
  // common case, and its subpaths go through that file's DIRECTORY: `index.ts/*`
50
62
  // 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?$/;
63
+ // and the checker failed on it later. Where a target sits is the alias module's
64
+ // answer (`folderOf`), not a second reading of it here.
53
65
  const pathsOf = (aliases) => {
54
66
  const paths = {};
55
67
  for (const [alias, target] of Object.entries(aliases ?? {})) {
56
68
  paths[alias] = [target];
57
- const base = ENTRY_FILE.test(target) ? target.replace(/\/[^/]*$/, "") : target;
58
- paths[`${alias}/*`] = [`${base}/*`];
69
+ paths[`${alias}/*`] = [`${(0, packages_1.folderOf)(target)}/*`];
59
70
  }
60
71
  return paths;
61
72
  };
@@ -107,15 +118,68 @@ const resolutionHost = (project, repoRoot, repoFiles) => {
107
118
  useCaseSensitiveFileNames: () => true,
108
119
  };
109
120
  };
121
+ const setups = new WeakMap();
122
+ // The setup is keyed by the ARRAY the caller passes: the same reference means the
123
+ // same scanned set (the caller must not mutate an array it handed in). A default
124
+ // `[]` would be a fresh reference per call and would miss the cache every time,
125
+ // so the empty case has one constant.
126
+ const NO_FILES = [];
127
+ const setupOf = (project, repoRoot, aliases, repoFiles = NO_FILES) => {
128
+ const cached = setups.get(project);
129
+ if (cached && cached.repoFiles === repoFiles && cached.repoRoot === repoRoot && cached.aliases === aliases)
130
+ return cached;
131
+ const setup = {
132
+ repoRoot,
133
+ repoFiles,
134
+ aliases,
135
+ scanned: new Set(repoFiles),
136
+ options: {
137
+ baseUrl: repoRoot,
138
+ paths: pathsOf(aliases),
139
+ moduleResolution: ts_morph_1.ts.ModuleResolutionKind.Node10,
140
+ allowJs: true,
141
+ },
142
+ host: resolutionHost(project, repoRoot, repoFiles),
143
+ };
144
+ setups.set(project, setup);
145
+ return setup;
146
+ };
110
147
  // Resolve an import source (relative path or alias) to a repo-relative file.
111
148
  // A resolution that lands outside the scanned set (a `.d.ts`, a file in an
112
149
  // 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))
150
+ //
151
+ // The compiler answers for folders, entry files and plain module paths. A package
152
+ // that publishes SUBPATHS has neither a root file nor a folder per subpath —
153
+ // `"./chip"` is `dist/types/atoms/Chip/index.d.ts`, built from
154
+ // `atoms/Chip/index.tsx` — so those subpaths are asked of the package's own
155
+ // `exports`, through the ONE alias reader (`utils/aliases`), never a second one.
156
+ const aliasedSource = (specifier, setup) => {
157
+ const alias = (0, aliases_1.splitAlias)(setup.aliases, specifier);
158
+ if (!alias || !setup.repoFiles.length)
118
159
  return null;
119
- return rel;
120
- });
160
+ const place = (0, aliases_1.locateAlias)(setup.aliases, alias.name, alias.rest, {
161
+ repoRoot: setup.repoRoot,
162
+ repoFiles: setup.repoFiles,
163
+ });
164
+ for (const file of place?.files ?? [])
165
+ if (setup.scanned.has(file))
166
+ return file;
167
+ return null;
168
+ };
169
+ const resolveImport = (sf, source, { repoRoot, aliases, repoFiles }) => {
170
+ const setup = setupOf(sf.getProject(), repoRoot, aliases, repoFiles);
171
+ return (0, resolve_1.resolveReference)(source || null, (specifier) => {
172
+ const hit = ts_morph_1.ts.resolveModuleName(specifier, sf.getFilePath(), setup.options, setup.host).resolvedModule;
173
+ const rel = hit ? toRel(repoRoot, hit.resolvedFileName) : null;
174
+ // The compiler's answer IS the relation — unless it lands outside the
175
+ // scanned set (a built mirror of a published subpath) or nowhere at all.
176
+ if (rel != null && (!repoFiles || setup.scanned.has(rel)))
177
+ return rel;
178
+ // Without a scanned set there is nothing to check an answer against: the
179
+ // compiler's own answer stands, as it always did.
180
+ if (!repoFiles)
181
+ return rel;
182
+ return aliasedSource(specifier, setup);
183
+ }, (rel) => rel);
184
+ };
121
185
  exports.resolveImport = resolveImport;
@@ -4,10 +4,10 @@ exports.keyedDefs = void 0;
4
4
  // A KEYED SECTION is one mechanism: the YAML may write a section as a LIST of
5
5
  // `{ slug, … }` entries or as a MAP keyed by slug, and both spellings describe
6
6
  // the same defs. The nodes section reads it one way (`entities/tree/build`),
7
- // the codeRoles section the same way (`code-roles/roles`) — so the walk lives
7
+ // the entities section the same way (`code-entities/entities`) — so the walk lives
8
8
  // here once: a list is itself; a map's entries take their key as the slug when
9
9
  // the entry does not name one. What a def IS and what is validated afterwards
10
- // is the caller's own; nothing here knows nodes or roles.
10
+ // is the caller's own; nothing here knows nodes or entities.
11
11
  const field_1 = require("./field");
12
12
  // The defs a list-or-map section declares, in declared order. The caller's def
13
13
  // type `T` flows through untouched; a map value that is not a record is kept
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapRecord = void 0;
4
4
  // A MAPPED RECORD is one mechanism: a record's entries are each read into a
5
5
  // value, and the answers are collected under the same keys. The aliases
6
- // section maps each name to a normalized path (`aliases`); a role's actions
7
- // map each kind to its normalized action (`code-roles/roles`). The walk is the
6
+ // section maps each name to a normalized path (`aliases`); an entity's actions
7
+ // map each kind to its normalized action (`code-entities/entities`). The walk is the
8
8
  // same — read each entry, keep the key — so it lives here once. What an entry
9
9
  // IS and how it is read is the caller's own.
10
10
  const mapRecord = (record, read) => Object.fromEntries(Object.entries(record).map(([k, v]) => [k, read(k, v)]));
@@ -0,0 +1,15 @@
1
+ import { type FieldValue } from "@md-code/follow-architecture/utils/field";
2
+ declare const ENTRY_FILE: RegExp;
3
+ declare const norm: (p: string | null | undefined) => string;
4
+ declare const isFile: (p: string) => boolean;
5
+ declare const folderOf: (target: string) => string;
6
+ type Manifest = {
7
+ exports?: FieldValue;
8
+ typesVersions?: FieldValue;
9
+ };
10
+ declare const manifestOf: (repoRoot: string | null | undefined, folder: string) => Manifest | null;
11
+ declare const exportsPath: (manifest: Manifest | null, rest: string) => string | null;
12
+ declare const typesVersionPath: (manifest: Manifest | null, rest: string) => string | null;
13
+ declare const sourceOf: (folder: string, artifact: string, repoFiles: readonly string[]) => string | null;
14
+ declare const publicSources: (folder: string, manifest: Manifest | null, repoFiles: readonly string[]) => string[];
15
+ export { ENTRY_FILE, norm, isFile, folderOf, manifestOf, exportsPath, typesVersionPath, sourceOf, publicSources, type Manifest, };
@@ -0,0 +1,207 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.publicSources = exports.sourceOf = exports.typesVersionPath = exports.exportsPath = exports.manifestOf = exports.folderOf = exports.isFile = exports.norm = exports.ENTRY_FILE = void 0;
37
+ // What a package folder says about its own entry points. An alias target is a
38
+ // folder or an entry file; a SUBPATH of that package is described by the package's
39
+ // manifest (`exports`, `typesVersions`), which names BUILD artifacts — while the
40
+ // architecture talks about the sources those artifacts were built from. So the
41
+ // artifact's path tail is matched against the scanned files of that package.
42
+ //
43
+ // This is the ONE reader of a package manifest: the import resolver and the
44
+ // config's alias patterns both ask it, so neither grows its own copy.
45
+ const fs = __importStar(require("node:fs"));
46
+ const path = __importStar(require("node:path"));
47
+ const field_1 = require("@md-code/follow-architecture/utils/field");
48
+ // A target that ends in a source extension names a FILE; anything else a folder.
49
+ const ENTRY_FILE = /\.[cm]?[jt]sx?$/;
50
+ exports.ENTRY_FILE = ENTRY_FILE;
51
+ const norm = (p) => String(p ?? "")
52
+ .replace(/\\/g, "/")
53
+ .replace(/^\.\//, "")
54
+ .replace(/\/+$/, "");
55
+ exports.norm = norm;
56
+ const isFile = (p) => ENTRY_FILE.test(norm(p));
57
+ exports.isFile = isFile;
58
+ // The folder an alias target names: the target itself, or the entry file's own.
59
+ const folderOf = (target) => (isFile(target) ? norm(target).replace(/\/[^/]*$/, "") : norm(target));
60
+ exports.folderOf = folderOf;
61
+ // Read once per folder per process: a run asks the same package hundreds of times
62
+ // (one question per import) and the file cannot change under a run.
63
+ const manifests = new Map();
64
+ const manifestOf = (repoRoot, folder) => {
65
+ if (repoRoot == null)
66
+ return null;
67
+ const key = `${repoRoot}\u0000${folder}`;
68
+ const cached = manifests.get(key);
69
+ if (cached !== undefined)
70
+ return cached;
71
+ let manifest = null;
72
+ try {
73
+ manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, folder, "package.json"), "utf8"));
74
+ }
75
+ catch {
76
+ // A package without a manifest publishes no subpaths; the folder reading
77
+ // still answers, so this is not worth a notice.
78
+ manifest = null;
79
+ }
80
+ manifests.set(key, manifest);
81
+ return manifest;
82
+ };
83
+ exports.manifestOf = manifestOf;
84
+ // The path a condition object names. `types` first: the source mirror is what the
85
+ // architecture talks about, the built file is an artifact of it.
86
+ const CONDITIONS = ["types", "import", "default", "node", "require"];
87
+ const pathIn = (value) => {
88
+ if (typeof value === "string")
89
+ return value;
90
+ if ((0, field_1.isList)(value)) {
91
+ for (const item of value) {
92
+ const found = pathIn(item);
93
+ if (found)
94
+ return found;
95
+ }
96
+ return null;
97
+ }
98
+ if (!(0, field_1.isObj)(value))
99
+ return null;
100
+ for (const condition of CONDITIONS) {
101
+ const found = pathIn(value[condition]);
102
+ if (found)
103
+ return found;
104
+ }
105
+ return null;
106
+ };
107
+ // `exports["./subpath"]` — the public entry a subpath names, if the package has
108
+ // one. An import may spell the built file's extension (`@pkg/chip.js`); the
109
+ // manifest never does, so the extension-less spelling is asked too.
110
+ const exportsPath = (manifest, rest) => {
111
+ const entries = manifest?.exports;
112
+ if (!(0, field_1.isObj)(entries))
113
+ return null;
114
+ const bare = norm(rest).replace(ENTRY_FILE, "");
115
+ for (const name of bare === rest ? [rest] : [rest, bare]) {
116
+ for (const key of [`./${name}`, `./${name}.js`, `./${name}/index`, `./${name}.ts`]) {
117
+ const found = key in entries ? pathIn(entries[key]) : null;
118
+ if (found)
119
+ return found;
120
+ }
121
+ }
122
+ return null;
123
+ };
124
+ exports.exportsPath = exportsPath;
125
+ // One `typesVersions` pattern: an exact name, or a `*` that captures the middle.
126
+ const fromPattern = (pattern, target, rest) => {
127
+ const name = norm(pattern);
128
+ const star = name.indexOf("*");
129
+ if (star === -1)
130
+ return name === rest ? pathIn(target) : null;
131
+ const head = name.slice(0, star);
132
+ const tail = name.slice(star + 1);
133
+ if (!rest.startsWith(head) || !rest.endsWith(tail))
134
+ return null;
135
+ const found = pathIn(target);
136
+ const captured = rest.slice(head.length, rest.length - tail.length);
137
+ return found ? norm(found).replace("*", captured) : null;
138
+ };
139
+ // `typesVersions[version][pattern]` — the second place a package may describe a
140
+ // subpath, read with the SAME tail rule once a pattern names a path.
141
+ const typesVersionPath = (manifest, rest) => {
142
+ const versions = manifest?.typesVersions;
143
+ if (!(0, field_1.isObj)(versions))
144
+ return null;
145
+ for (const table of Object.values(versions)) {
146
+ if (!(0, field_1.isObj)(table))
147
+ continue;
148
+ for (const [pattern, target] of Object.entries(table)) {
149
+ const found = fromPattern(pattern, target, rest);
150
+ if (found)
151
+ return found;
152
+ }
153
+ }
154
+ return null;
155
+ };
156
+ exports.typesVersionPath = typesVersionPath;
157
+ // ── artifact → source ───────────────────────────────────────────────────────
158
+ const SOURCE_EXTS = [".tsx", ".ts", ".d.ts"];
159
+ const scannedSets = new WeakMap();
160
+ const scannedOf = (repoFiles) => {
161
+ let scanned = scannedSets.get(repoFiles);
162
+ if (!scanned) {
163
+ scanned = new Set(repoFiles.map(norm));
164
+ scannedSets.set(repoFiles, scanned);
165
+ }
166
+ return scanned;
167
+ };
168
+ // The scanned file an artifact was built from: the artifact's own segments, tried
169
+ // from the LONGEST suffix down, against the files of that package. The build
170
+ // folder (`dist/types/…`) is in no source path, so the first suffix a source file
171
+ // ends with is the answer.
172
+ const sourceOf = (folder, artifact, repoFiles) => {
173
+ const segments = norm(artifact)
174
+ .replace(/\.d\.ts$/, "")
175
+ .replace(ENTRY_FILE, "")
176
+ .split("/")
177
+ .filter(Boolean);
178
+ const scanned = scannedOf(repoFiles);
179
+ for (let i = 0; i < segments.length; i += 1) {
180
+ const tail = segments.slice(i).join("/");
181
+ for (const ext of SOURCE_EXTS) {
182
+ const file = `${folder}/${tail}${ext}`;
183
+ if (scanned.has(file))
184
+ return file;
185
+ }
186
+ }
187
+ return null;
188
+ };
189
+ exports.sourceOf = sourceOf;
190
+ // Every public subpath a package publishes, as sources — what `@pkg/*` means for
191
+ // a package that has no folders to walk.
192
+ const publicSources = (folder, manifest, repoFiles) => {
193
+ const entries = manifest?.exports;
194
+ if (!(0, field_1.isObj)(entries))
195
+ return [];
196
+ const out = [];
197
+ for (const [key, value] of Object.entries(entries)) {
198
+ if (!key.startsWith("./"))
199
+ continue;
200
+ const artifact = pathIn(value);
201
+ const source = artifact ? sourceOf(folder, artifact, repoFiles) : null;
202
+ if (source)
203
+ out.push(source);
204
+ }
205
+ return out;
206
+ };
207
+ exports.publicSources = publicSources;
@@ -26,7 +26,9 @@ const pathTemplate = (paths) => {
26
26
  exports.pathTemplate = pathTemplate;
27
27
  // Shortest label that still says WHERE it is: the last N path segments.
28
28
  const tailPath = (template, keep = 2) => {
29
- const segs = String(template ?? "").split("/").filter(Boolean);
29
+ const segs = String(template ?? "")
30
+ .split("/")
31
+ .filter(Boolean);
30
32
  return segs.length <= keep ? segs.join("/") : segs.slice(-keep).join("/");
31
33
  };
32
34
  exports.tailPath = tailPath;
@@ -1,4 +1,5 @@
1
- declare const DEFAULT_IGNORE_DIRS: string[];
1
+ declare const DEFAULT_IGNORE_DIRS: readonly string[];
2
+ declare const DEFAULT_IGNORE_PATHS: readonly string[];
2
3
  declare const DEFAULT_SIMILARITY = 0.6;
3
4
  declare const DEFAULT_EXTS: string[];
4
5
  declare const expandBraces: (s: string) => string[];
@@ -8,11 +9,11 @@ declare const placeholderRe: (n: string) => string;
8
9
  declare const PLACEHOLDER: RegExp;
9
10
  declare const patternBody: (pattern: string) => {
10
11
  body: string;
11
- names: string[];
12
+ names: readonly string[];
12
13
  };
13
14
  declare const compilePattern: (pattern: string) => {
14
15
  re: RegExp;
15
- names: string[];
16
+ names: readonly string[];
16
17
  };
17
18
  declare const checkRegex: (p: string, where: string) => void;
18
- export { DEFAULT_EXTS, DEFAULT_SIMILARITY, DEFAULT_IGNORE_DIRS, globToRegex, conventionOf, placeholderRe, compilePattern, patternBody, PLACEHOLDER, expandBraces, checkRegex };
19
+ export { DEFAULT_EXTS, DEFAULT_SIMILARITY, DEFAULT_IGNORE_DIRS, DEFAULT_IGNORE_PATHS, globToRegex, conventionOf, placeholderRe, compilePattern, patternBody, PLACEHOLDER, expandBraces, checkRegex, };
@@ -15,21 +15,38 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.checkRegex = exports.expandBraces = exports.PLACEHOLDER = exports.patternBody = exports.compilePattern = exports.placeholderRe = exports.conventionOf = exports.globToRegex = exports.DEFAULT_IGNORE_DIRS = exports.DEFAULT_SIMILARITY = exports.DEFAULT_EXTS = void 0;
27
- const configError = __importStar(require("../report/configErrors"));
36
+ exports.checkRegex = exports.expandBraces = exports.PLACEHOLDER = exports.patternBody = exports.compilePattern = exports.placeholderRe = exports.conventionOf = exports.globToRegex = exports.DEFAULT_IGNORE_PATHS = exports.DEFAULT_IGNORE_DIRS = exports.DEFAULT_SIMILARITY = exports.DEFAULT_EXTS = void 0;
37
+ const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
38
+ const ignore_1 = require("@md-code/follow-architecture/ignore");
28
39
  // Glob → regex and the naming-convention placeholder machinery shared by
29
- // every entity that matches file paths (nodes, invariants, fileSpecs).
30
- // Directories that never contain source code. A repo may add more via `ignoreDirs`.
31
- const DEFAULT_IGNORE_DIRS = ["node_modules", ".git", ".vscode-test", "out", "dist", "build", "coverage"];
40
+ // every entity that matches file paths (nodes, rules, fileSpecs).
41
+ // Directories that never contain source code. The list lives in `ignore.ts`
42
+ // because the ESLint rule skips exactly the same folders; a repo may add more
43
+ // via `ignoreDirs`.
44
+ const DEFAULT_IGNORE_DIRS = ignore_1.IGNORE_DIRS;
32
45
  exports.DEFAULT_IGNORE_DIRS = DEFAULT_IGNORE_DIRS;
46
+ // Repo-relative paths that are outside the contract, from the same list: the CLI
47
+ // and the rule skip them unless a caller adds its own `--ignore` / `ignores`.
48
+ const DEFAULT_IGNORE_PATHS = ignore_1.IGNORE_PATHS;
49
+ exports.DEFAULT_IGNORE_PATHS = DEFAULT_IGNORE_PATHS;
33
50
  // Source extensions the TOOL scans by default. Scan scope is a tool concern, not
34
51
  // architecture (the yaml must not carry it) — and it is an option, not a fact of
35
52
  // the tool's code: `--ext <ext>` / the rule's `exts` add to this list.
@@ -164,19 +181,42 @@ exports.PLACEHOLDER = PLACEHOLDER;
164
181
  // patterns, node paths and node children. A placeholder is swapped for a sentinel
165
182
  // before the glob is compiled so its own characters survive, then put back as a
166
183
  // capture group of the convention it asks for.
184
+ // The same templates are compiled again and again: every file is matched against
185
+ // every node path, every finding against the rule's patterns. Compilation is pure
186
+ // (a template always yields the same body and names), so it is memoised; the
187
+ // produced expressions have no `g` flag, so one instance is safe to reuse.
188
+ // The memo is MODULE-wide and grows to the number of distinct templates the run
189
+ // meets (bounded by the working tree — a CLI run dies with it); the captured
190
+ // names are handed out READ-ONLY, so one caller cannot edit another's.
191
+ const bodies = new Map();
167
192
  const patternBody = (pattern) => {
193
+ const key = String(pattern);
194
+ const cached = bodies.get(key);
195
+ if (cached)
196
+ return cached;
168
197
  const names = [];
169
- const glob = String(pattern).replace(/\\/g, "/").replace(PLACEHOLDER, (_, n) => {
198
+ const glob = String(pattern)
199
+ .replace(/\\/g, "/")
200
+ .replace(PLACEHOLDER, (_, n) => {
170
201
  names.push(n);
171
202
  return `\u0000${n}\u0000`;
172
203
  });
173
204
  const body = globToRegex(glob).replace(/\u0000([A-Za-z][A-Za-z0-9_-]*)\u0000/g, (_, n) => `(${placeholderRe(n)})`);
174
- return { body, names };
205
+ const compiled = { body, names };
206
+ bodies.set(key, compiled);
207
+ return compiled;
175
208
  };
176
209
  exports.patternBody = patternBody;
210
+ const patterns = new Map();
177
211
  const compilePattern = (pattern) => {
212
+ const key = String(pattern);
213
+ const cached = patterns.get(key);
214
+ if (cached)
215
+ return cached;
178
216
  const { body, names } = patternBody(pattern);
179
- return { re: new RegExp(`^${body}$`), names };
217
+ const compiled = { re: new RegExp(`^${body}$`), names };
218
+ patterns.set(key, compiled);
219
+ return compiled;
180
220
  };
181
221
  exports.compilePattern = compilePattern;
182
222
  const checkRegex = (p, where) => {
@@ -1,6 +1,6 @@
1
- import type { Arch, ActionDef } from "../entities/architecture";
2
- import type { FileFacts } from "../entities/facts";
3
- import type { Caps } from "../entities/location/where";
1
+ import type { Arch, ActionDef } from "@md-code/follow-architecture/entities/architecture";
2
+ import type { FileFacts } from "@md-code/follow-architecture/entities/facts";
3
+ import type { Caps } from "@md-code/follow-architecture/entities/location/where";
4
4
  type Permission = {
5
5
  allowed: boolean;
6
6
  denied: boolean;
@@ -7,10 +7,12 @@ exports.permissionOf = void 0;
7
7
  // against a declared allowance asks the same two questions. The walk — allow
8
8
  // when some `where` entry admits, then refuse when some `except` entry admits —
9
9
  // lives here once. What the entries MEAN is the shared `where` grammar's own.
10
- const location_1 = require("../entities/location");
10
+ const location_1 = require("@md-code/follow-architecture/entities/location");
11
11
  const permissionOf = (action, ask) => {
12
12
  const allowed = !(0, location_1.checkWhere)(action.where, ask.rel, ask.arch, ask.scope, ask.caps);
13
- const denied = (action.except ?? []).length ? !(0, location_1.checkWhere)(action.except, ask.rel, ask.arch, ask.scope, ask.caps) : false;
13
+ const denied = (action.except ?? []).length
14
+ ? !(0, location_1.checkWhere)(action.except, ask.rel, ask.arch, ask.scope, ask.caps)
15
+ : false;
14
16
  return { allowed, denied };
15
17
  };
16
18
  exports.permissionOf = permissionOf;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.plural = void 0;
4
4
  // A PLURAL is one mechanism: a count read as "1 thing" / "N things". The browser
5
- // counts roles / rules / matches (`utils/format`); any consumer that names a
5
+ // counts entities / rules / matches (`utils/format`); any consumer that names a
6
6
  // count asks the same question. The irregular plural is the caller's own; the
7
7
  // regular one adds `s`.
8
- const plural = (n, one, many) => `${n} ${n === 1 ? one : many ?? `${one}s`}`;
8
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : (many ?? `${one}s`)}`;
9
9
  exports.plural = plural;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.answerWhenAllPass = void 0;
4
4
  // A QUALIFIED ANSWER is one mechanism: a subject must pass every guard before
5
5
  // it earns an answer; the first guard that refuses ends the question with
6
- // nothing. A misfit role is a named candidate of a declared role with homes
7
- // that sits outside them (`pipeline-roles`); a scope accessor is a record whose
8
- // scope is one of the declared kinds (`code-roles/roles`). The walk is the same
6
+ // nothing. A misfit entity is a named candidate of a declared entity with homes
7
+ // that sits outside them (`pipeline-entities`); a scope accessor is a record whose
8
+ // scope is one of the declared kinds (`code-entities/entities`). The walk is the same
9
9
  // — ask each guard in order, answer only when all pass — so it lives here once.
10
10
  // What the guards ARE and what the answer is is the caller's own; nothing here
11
- // knows roles or accessors.
11
+ // knows entities or accessors.
12
12
  // The answer when every guard passes; null the moment one refuses. Guards are
13
13
  // asked in order, so a cheap refusal short-circuits the rest.
14
14
  const answerWhenAllPass = (subject, guards, answer) => {
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rankedOffers = void 0;
4
4
  // A RANKED SHORTLIST is one mechanism: candidates are scored against a subject,
5
5
  // the ones below the bar are dropped, and the rest are offered best first. A
6
- // role's destinations are its homes scored by branch and prefix
6
+ // entity's destinations are its homes scored by branch and prefix
7
7
  // (`entities/location/homes`); a folder's lookalikes are the declared entities
8
- // scored by the share of their roles it holds (`nodes/similar`). The walk is
8
+ // scored by the share of their entities it holds (`nodes/similar`). The walk is
9
9
  // the same — score, keep, rank — so it lives here once. What a candidate IS,
10
10
  // how it is scored and what the bar means are the caller's own.
11
11
  // Score every candidate, keep the ones the scorer offers (non-null), and sort
@@ -4,7 +4,7 @@ exports.recordWithout = void 0;
4
4
  // A RECORD WITHOUT KEYS is one mechanism: a record carries some keys that are
5
5
  // NOT data (a report template beside a filter, an `arch` beside the facts),
6
6
  // and a reader that wants only the data takes the record minus those keys.
7
- // The invariant runtime strips `report` before matching (`invariants/vars`);
7
+ // The rule runtime strips `report` before matching (`rules/vars`);
8
8
  // the query engine strips `arch` before resolving a `$ref`
9
9
  // (`entities/queries`). The walk is the same — copy every key except the named
10
10
  // ones — so it lives here once. Which keys are not data is the caller's own.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.matchesText = void 0;
4
4
  // A TEXT SEARCH is one mechanism: does a haystack contain a needle, ignoring
5
5
  // case? An empty needle matches everything (no filter). The browser searches
6
- // findings / roles / nodes (`utils/format`); any consumer that filters text by
6
+ // findings / entities / nodes (`utils/format`); any consumer that filters text by
7
7
  // a substring asks the same question. The decision is the shared gate — admit
8
8
  // when none of the refusals fires (no needle to filter by, or the needle is
9
9
  // absent) — the same `admitsWhenNoneReject` the AST read gate uses.
@@ -12,5 +12,10 @@ const gate_1 = require("./gate");
12
12
  // admits every haystack (no filter). A non-empty needle is refused only when
13
13
  // the haystack does not contain it. Spelling the empty case as its own `!n`
14
14
  // refusal would invert it — the refusal fires first and the list empties.
15
- const matchesText = (haystack, needle) => (0, gate_1.admitsWhenNoneReject)(needle, [(n) => Boolean(n) && !String(haystack ?? "").toLowerCase().includes(n.toLowerCase())]);
15
+ const matchesText = (haystack, needle) => (0, gate_1.admitsWhenNoneReject)(needle, [
16
+ (n) => Boolean(n) &&
17
+ !String(haystack ?? "")
18
+ .toLowerCase()
19
+ .includes(n.toLowerCase()),
20
+ ]);
16
21
  exports.matchesText = matchesText;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.speakOnce = void 0;
4
4
  // A SPOKEN SET is one mechanism: a subject is named once — the first time it
5
5
  // answers, it is remembered; every later answer of the same subject is silent.
6
- // The invariant runtime speaks once per PIECE per rule (a `const` holding an
6
+ // The rule runtime speaks once per PIECE per rule (a `const` holding an
7
7
  // arrow answers two entries, the reader needs one sentence); any consumer that
8
8
  // names subjects without repeating itself asks the same question. The walk is
9
9
  // the same — ask, remember, answer — so it lives here once. What a subject IS