@md-code/follow-architecture 0.1.1 → 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 (437) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +584 -141
  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 +61 -18
  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 -101
  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 -96
  435. package/plugin.js +0 -5
  436. package/report.js +0 -73
  437. package/utils.js +0 -104
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkInvariants = void 0;
4
+ // The invariant runtime. Gates (ignore, where, when) run first; then the
5
+ // check blocks are evaluated as plain filters against the file's raw facts
6
+ // (collected by ast/, attached to the ctx by the pipeline). No named rule
7
+ // kinds, no domain logic — every check is a filter from the YAML.
8
+ //
9
+ // infer: [ <filter>, ... ] — a finding when a filter MATCHES the facts.
10
+ // "This must be true" is the same filter under
11
+ // `not:` — one check, one direction.
12
+ //
13
+ // A filter is asked of the FILE first; only when the file does not answer is it
14
+ // asked of each candidate in facts.candidates, and the matching candidate
15
+ // supplies the line and name for the finding. Nothing declares which fact lives
16
+ // where: the facts answer for themselves.
17
+ const queries_1 = require("../entities/queries");
18
+ const css_1 = require("../css");
19
+ const name_1 = require("./name");
20
+ const location_1 = require("../entities/location");
21
+ const field_1 = require("../utils/field");
22
+ const seen_1 = require("../utils/seen");
23
+ const speak_1 = require("../utils/speak");
24
+ const typed_field_1 = require("../utils/typed-field");
25
+ const vars_1 = require("./vars");
26
+ const list_vars_1 = require("./list-vars");
27
+ // When an invariant sets `dedupeBy`, file-level findings are reported once per
28
+ // distinct PLACE across the whole run (the dedupe map is shared across files).
29
+ // The place is whatever the `where` entry designates — `{ node: feature }` is
30
+ // that feature's folder, a glob its matched folder — so this is the same
31
+ // vocabulary as the roles, not a second one. Falling back to the file's own
32
+ // directory keeps a plain per-folder rule per-folder even outside any node.
33
+ // The ask-and-remember step is the shared `seenOnce` core.
34
+ const dedupePlaceOf = (inv, ctx) => inv.dedupeBy.map((entry) => (0, location_1.entryKey)(entry, ctx.rel, ctx.arch, ctx.facts)).find(Boolean) ?? String(ctx.dir ?? "");
35
+ const deduped = (inv, ctx, dedupe) => {
36
+ if (!inv.dedupeBy?.length || !dedupe)
37
+ return false;
38
+ return (0, seen_1.seenOnce)(dedupe, inv.id, dedupePlaceOf(inv, ctx));
39
+ };
40
+ // The `fix.location` a report states, read as the place vocabulary: a glob, a
41
+ // `{ role }` / `{ node }` entry, or a list of alternatives. Anything else is
42
+ // not a place the tree can resolve.
43
+ const locationEntryOf = (v) => {
44
+ if (typeof v === "string")
45
+ return v;
46
+ if (!(0, field_1.isRecordValue)(v))
47
+ return null;
48
+ if (typeof v.role === "string")
49
+ return { type: "role", role: v.role, same: v.same === true };
50
+ if (typeof v.node === "string")
51
+ return { type: "node", node: v.node };
52
+ return null;
53
+ };
54
+ const fixLocationOf = (fix) => {
55
+ if (!(0, field_1.isRecordValue)(fix))
56
+ return null;
57
+ const location = fix.location;
58
+ if ((0, field_1.isList)(location))
59
+ return location.map(locationEntryOf).filter((e) => e != null);
60
+ return locationEntryOf(location);
61
+ };
62
+ // A rule's destination, resolved BY THE TREE — one implementation, in
63
+ // `entities/location.js`, shared with the `location:` filter. `fix.location`
64
+ // (`{ role }` / `{ node }` / a glob, or a list of alternatives) becomes the place
65
+ // and the box for THIS file, so the sentence and the picture get one place.
66
+ // The report's fields are read through `fieldOf` — the ONE plain-data reader —
67
+ // because the typed model also carries compiled regexes some readers expect,
68
+ // which are not data.
69
+ const resolvePlace = (report, ctx) => {
70
+ if (!(0, queries_1.isObj)(report) || !ctx.arch)
71
+ return report;
72
+ const location = fixLocationOf((0, field_1.fieldOf)(report, "fix"));
73
+ if (location == null)
74
+ return report;
75
+ const hit = (0, location_1.resolveLocation)(ctx.arch, location, ctx.rel);
76
+ if (!hit?.node)
77
+ return report;
78
+ const stated = { to: [hit.node], place: hit.path };
79
+ return Object.assign({}, report, stated);
80
+ };
81
+ // Which list values are the problem? For each top-level field whose filter is a
82
+ // bare `every: <sub>` (e.g. `roles: { every: { in: [...] } }`), return the
83
+ // items of that fact's list that do not match `<sub>` — so the report can name
84
+ // `{violations}` instead of making the reader open the file. Works through a
85
+ // leading `not:` too, so a "must" rule names its offenders as well. Fully
86
+ // generic: any fact field.
87
+ const violationsOf = (facts, inner, scope) => {
88
+ const out = [];
89
+ const filter = (0, queries_1.isObj)(inner) && (0, queries_1.isObj)(inner.not) ? inner.not : inner;
90
+ if (!(0, queries_1.isObj)(filter))
91
+ return out;
92
+ for (const [field, sub] of Object.entries(filter)) {
93
+ // The items this entry refutes are the ones the engine says do NOT match
94
+ // its demand — asked as a query (`not:`), not recomputed by hand.
95
+ const demand = (0, queries_1.innerFilterOf)(sub);
96
+ const list = (0, field_1.fieldOf)(facts, field);
97
+ if (demand == null || !(0, field_1.isList)(list))
98
+ continue;
99
+ for (const item of list)
100
+ if ((0, queries_1.matches)(item, { not: demand }, scope))
101
+ out.push(item);
102
+ }
103
+ return out;
104
+ };
105
+ // The variables one matched CANDIDATE's finding names: the file's path vars,
106
+ // `{what}` (its own name, else its piece, else what it is and where), the items
107
+ // the filter caught, its own scalars, and the writes the rule CAUGHT.
108
+ const candidateVars = (c, filter, scope, ctx) => {
109
+ const vars = { ...(0, name_1.fileVars)(ctx), what: c.name ?? c.location?.piece ?? (0, vars_1.describePiece)(c) };
110
+ (0, list_vars_1.listFactVars)(vars, c, filter, scope);
111
+ (0, vars_1.collectScalars)(c, vars);
112
+ // `{assignments}`: the values this code writes into. Only the writes the rule
113
+ // CAUGHT: naming the piece's private locals too described one param write as
114
+ // a list of everything the function ever touched.
115
+ const written = [...new Set((0, vars_1.listHit)(c.assignments ?? [], filter, "assignments", scope).map((a) => ((0, queries_1.isObj)(a) ? (a.value ?? a.target) : undefined)).filter((v) => typeof v === "string" && Boolean(v)))];
116
+ if (written.length)
117
+ vars.assignments = written.join(", ");
118
+ return vars;
119
+ };
120
+ // The variables one FILE-level finding names: every scalar fact, the roles the
121
+ // file holds, the items the filter refutes.
122
+ const fileLevelVars = (ctx, filter, scope) => {
123
+ const vars = (0, vars_1.enrichedVars)(ctx);
124
+ const facts = ctx.facts;
125
+ const roles = [...new Set(facts?.roles ?? [])].join(" + ");
126
+ const violations = violationsOf(facts ?? {}, filter, scope).join(", ");
127
+ if (roles)
128
+ vars.roles = roles;
129
+ if (violations)
130
+ vars.violations = violations;
131
+ return (0, list_vars_1.listFactVars)(vars, facts ?? {}, filter, scope);
132
+ };
133
+ // The entry's own report template, when it carries one. The string fields are
134
+ // read through the shared typed-field walk; the list and the fix keep their
135
+ // own shapes.
136
+ const REPORT_STRING_KEYS = ["description", "message", "ask", "code", "path", "place", "from"];
137
+ const isString = (v) => typeof v === "string";
138
+ const reportOf = (entry) => {
139
+ const report = (0, field_1.fieldOf)(entry, "report");
140
+ if (typeof report === "string")
141
+ return report;
142
+ if (!(0, field_1.isRecordValue)(report))
143
+ return null;
144
+ const obj = {};
145
+ for (const key of REPORT_STRING_KEYS) {
146
+ const v = (0, typed_field_1.typedField)(report, key, isString);
147
+ if (v !== undefined)
148
+ obj[key] = v;
149
+ }
150
+ if ((0, field_1.isList)(report.to))
151
+ obj.to = report.to.filter(isString);
152
+ const fix = report.fix;
153
+ if (typeof fix === "string" || (0, field_1.isRecordValue)(fix))
154
+ obj.fix = fix;
155
+ return obj;
156
+ };
157
+ // The file answered the filter: one finding about the FILE, unless its place
158
+ // was already spoken for across the run.
159
+ const fileFinding = (entry, ask) => {
160
+ const { inv, ctx, filter, scope, sink } = ask;
161
+ if (deduped(inv, ctx, sink.dedupe))
162
+ return;
163
+ const stated = resolvePlace(reportOf(entry) ?? inv.report ?? null, ctx);
164
+ sink.out.push(sink.findingFrom({ key: "infer", report: stated }, "invariant", ctx.rel, `invariant:${inv.id}:infer`, fileLevelVars(ctx, filter, scope)));
165
+ };
166
+ // One matched candidate's finding — once per piece: two factories in one file
167
+ // are two things to delete; the same piece answering two entries is one.
168
+ const candidateFinding = (c, entry, ask) => {
169
+ const { inv, ctx, filter, scope, sink, spoken } = ask;
170
+ const who = c.name ?? c.location?.piece ?? "?";
171
+ if (!(0, speak_1.speakOnce)(spoken, who))
172
+ return;
173
+ const report = resolvePlace(reportOf(entry) ?? inv.report ?? null, ctx);
174
+ sink.out.push(sink.findingFrom({ key: "infer", report, line: c.lines?.[0] ?? 1 }, "invariant", ctx.rel, `invariant:${inv.id}:infer:${who}`, candidateVars(c, filter, scope, ctx)));
175
+ };
176
+ // One infer entry, asked of the file first, then of every candidate. A filter
177
+ // that answers for the file is a finding about the file; one that only answers
178
+ // for a declaration is a finding about that declaration. No list of "which
179
+ // facts exist where" is needed — the facts answer for themselves.
180
+ const checkEntry = (entry, inv, ctx, run) => {
181
+ const facts = ctx.facts;
182
+ if (!facts)
183
+ return;
184
+ const filter = (0, vars_1.filterOf)(entry);
185
+ // The scope IS the file's facts (plus the tree), so a rule can compare one
186
+ // fact with another — `$location.fileName` against `location.files`. A
187
+ // `location:` filter needs the architecture to resolve a node slug to paths.
188
+ const scope = { ...facts, arch: ctx.arch, fileRel: ctx.rel };
189
+ const ask = { inv, ctx, filter, scope, sink: run.sink };
190
+ if ((0, queries_1.matches)(facts, filter, scope)) {
191
+ fileFinding(entry, ask);
192
+ return;
193
+ }
194
+ for (const c of facts.candidates ?? []) {
195
+ // `$` inside a candidate filter names the candidate's OWN facts too, so a
196
+ // rule can compare a function with itself. File facts keep priority on a
197
+ // key clash (`{ ...c, ...scope }`).
198
+ const candidateScope = { ...c, ...facts, arch: ctx.arch, fileRel: ctx.rel };
199
+ if (!(0, queries_1.matches)(c, filter, candidateScope))
200
+ continue;
201
+ candidateFinding(c, entry, { ...ask, spoken: run.spoken });
202
+ }
203
+ };
204
+ const checkInfer = (inv, ctx, sink) => {
205
+ // ONE finding per PIECE per rule. A piece can answer two `infer` entries of
206
+ // the same rule (a `const` holding an arrow is the variable and the function),
207
+ // and the reader does not need the same sentence twice with the same name.
208
+ const spoken = new Set();
209
+ for (const entry of inv.infer)
210
+ checkEntry(entry, inv, ctx, { spoken, sink });
211
+ };
212
+ // Does this filter read a declaration's `resolution` fact? Then the lazy
213
+ // resolution must be materialised before the filter is asked.
214
+ const namesResolution = (filter) => {
215
+ if ((0, field_1.isList)(filter))
216
+ return filter.some(namesResolution);
217
+ if (!(0, queries_1.isObj)(filter))
218
+ return false;
219
+ return Object.keys(filter).some((key) => key === "resolution" || namesResolution((0, field_1.fieldOf)(filter, key)));
220
+ };
221
+ // The code-role slugs a filter names — `{ codeRole: { <slug>: … } }` (the keys
222
+ // of the `codeRole` object are slugs) or a `$codeRole.<slug>` reference. These
223
+ // are the roles whose object literals resolution resolves against.
224
+ const codeRoleSlugs = (filter, out) => {
225
+ if (typeof filter === "string") {
226
+ const match = /\$codeRole\.([\w-]+)/.exec(filter);
227
+ if (match)
228
+ out.add(match[1]);
229
+ return;
230
+ }
231
+ if ((0, field_1.isList)(filter)) {
232
+ for (const entry of filter)
233
+ codeRoleSlugs(entry, out);
234
+ return;
235
+ }
236
+ if (!(0, queries_1.isObj)(filter))
237
+ return;
238
+ for (const key of Object.keys(filter)) {
239
+ const value = (0, field_1.fieldOf)(filter, key);
240
+ if (key === "codeRole" && (0, queries_1.isObj)(value))
241
+ for (const slug of Object.keys(value))
242
+ out.add(slug);
243
+ else
244
+ codeRoleSlugs(value, out);
245
+ }
246
+ };
247
+ // The object-role slugs an invariant names (in `when` or any `infer` entry).
248
+ const invariantObjectSlugs = (inv) => {
249
+ const slugs = new Set();
250
+ if (inv.when != null)
251
+ codeRoleSlugs(inv.when, slugs);
252
+ for (const entry of inv.infer)
253
+ codeRoleSlugs(entry, slugs);
254
+ return [...slugs];
255
+ };
256
+ // Every css template the file's candidates carry.
257
+ const templatesOf = (ctx) => (ctx.facts?.candidates ?? []).flatMap((candidate) => candidate.css?.templates ?? []);
258
+ // Materialise `resolution` on the file's css templates for an invariant that
259
+ // reads it. The objects are the literals of the roles the invariant NAMES — a
260
+ // filter that references no role gets no objects (reported as such, never
261
+ // silently resolved against a project-wide scan).
262
+ const materialiseInvariantResolution = (inv, ctx) => {
263
+ if (!(namesResolution(inv.when ?? null) || inv.infer.some(namesResolution)))
264
+ return;
265
+ const objects = ctx.objectsFor ? ctx.objectsFor(invariantObjectSlugs(inv)) : [];
266
+ for (const template of templatesOf(ctx))
267
+ (0, css_1.materialiseResolution)(template, objects);
268
+ };
269
+ // The top-level `report` is the message template for the checks' findings —
270
+ // not a standalone finding of its own. The gates (ignore/where/when) only
271
+ // decide whether the checks run at all. Exception: an invariant with NO
272
+ // checks (no infer) IS its own finding — passing the gates is
273
+ // the violation (e.g. a `when: { roles: { some: ... } }` rule).
274
+ const checkInvariant = (inv, ctx, sink) => {
275
+ // The two gates are the ONE `where` question, asked both ways: "is this file
276
+ // exempt" and "does the rule apply". `checkWhere` answers it; looping over the
277
+ // entries here was a second reading of the same list.
278
+ if (!(0, location_1.checkWhere)(inv.ignore, ctx.rel, ctx.arch, ctx.facts))
279
+ return;
280
+ if (inv.where.length && (0, location_1.checkWhere)(inv.where, ctx.rel, ctx.arch, ctx.facts))
281
+ return;
282
+ if (inv.when != null && !(0, queries_1.matches)(ctx.facts ?? {}, inv.when))
283
+ return;
284
+ // Resolution is LAZY: computed only for an invariant that asks about it, and
285
+ // only against the object roles that invariant names.
286
+ materialiseInvariantResolution(inv, ctx);
287
+ if (!inv.infer.length && inv.report) {
288
+ sink.out.push(sink.findingFrom({ key: null, report: inv.report }, "invariant", ctx.rel, `root:${inv.id}`, (0, vars_1.enrichedVars)(ctx)));
289
+ }
290
+ checkInfer(inv, ctx, sink);
291
+ for (const child of inv.children)
292
+ checkInvariant(child, ctx, sink);
293
+ };
294
+ const checkInvariants = (...args) => {
295
+ const [invariants, ctx, out, findingFrom, dedupe] = args;
296
+ for (const inv of invariants)
297
+ checkInvariant(inv, ctx, { out, findingFrom, dedupe });
298
+ };
299
+ exports.checkInvariants = checkInvariants;
@@ -0,0 +1,5 @@
1
+ import { type FieldValue } from "../utils/field";
2
+ import { type ReportVars } from "./vars";
3
+ import type { QueryScope } from "../entities/architecture";
4
+ declare const listFactVars: (vars: ReportVars, target: FieldValue, filter: FieldValue, scope: QueryScope) => ReportVars;
5
+ export { listFactVars };
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listFactVars = void 0;
4
+ // The LIST half of the report-variable walk: a rule names a fact field, the
5
+ // engine narrows the list the same way the filter did, and every string the
6
+ // matched items carry becomes a placeholder. The walk follows the same path
7
+ // the filter took — through objects, through quantifiers, through `where`/`by`
8
+ // — so a message naming `{ <field> }` and the check itself cannot disagree.
9
+ const queries_1 = require("../entities/queries");
10
+ const field_1 = require("../utils/field");
11
+ const vars_1 = require("./vars");
12
+ // The `where` narrowing of a list entry, when it has one: `{ where: { filter,
13
+ // by } }` narrows before `by` judges.
14
+ const narrowingOf = (sub) => {
15
+ const where = sub.where;
16
+ if (!(0, queries_1.isObj)(where) || !(0, queries_1.isObj)(where.filter))
17
+ return null;
18
+ return { filter: where.filter, by: where.by };
19
+ };
20
+ // The items the rule talks about, and the demand the walk into them reads.
21
+ const hitsOf = (list, sub, ask) => {
22
+ const narrowing = narrowingOf(sub);
23
+ if (narrowing) {
24
+ return { hit: (0, queries_1.hitOf)(list, { where: { filter: narrowing.filter } }, ask.scope), walkFilter: (0, vars_1.branchOf)(narrowing.by) };
25
+ }
26
+ return { hit: (0, vars_1.listHit)(list, ask.filter, ask.field, ask.scope), walkFilter: (0, vars_1.branchOf)(sub) };
27
+ };
28
+ // One string field of the matched items, as one variable: the distinct values,
29
+ // joined. Which word stands for an item is the item's own business.
30
+ const spokenOf = (hit, read) => {
31
+ const values = hit.map(read).filter((v) => typeof v === "string" && Boolean(v));
32
+ return [...new Set(values)].join(", ");
33
+ };
34
+ // The word an item is spoken by: its name, else the text it holds, else the
35
+ // raw token it was written as (a class), else the property or selector it is.
36
+ const itemWord = (item) => {
37
+ if (!(0, queries_1.isObj)(item))
38
+ return undefined;
39
+ return item.name ?? item.text ?? item.raw ?? item.prop ?? item.selector ?? item.tag;
40
+ };
41
+ // The numeric `{ start, end }` a value names, or null when it is not one. One
42
+ // guard, so the span readers below stay flat.
43
+ const numericSpan = (value) => {
44
+ if (!(0, queries_1.isObj)(value))
45
+ return null;
46
+ const { start, end } = value;
47
+ return typeof start === "number" && typeof end === "number" ? { start, end } : null;
48
+ };
49
+ const kindOf = (item) => ((0, queries_1.isObj)(item) && typeof item.kind === "string" ? item.kind : "");
50
+ // A SPAN a matched fact names, so the report can highlight exactly the offending
51
+ // text. A fact may carry `span` on itself, or on the first problem it lists
52
+ // (`problems[].span`) — e.g. a resolved value whose problem marks the `calc(…)`.
53
+ const spanOfItem = (item) => {
54
+ if (!(0, queries_1.isObj)(item))
55
+ return null;
56
+ const direct = numericSpan(item.span);
57
+ if (direct)
58
+ return { ...direct, kind: kindOf(item) };
59
+ for (const problem of (0, field_1.isList)(item.problems) ? item.problems : []) {
60
+ const span = numericSpan((0, queries_1.isObj)(problem) ? problem.span : undefined);
61
+ if (span)
62
+ return { ...span, kind: kindOf(problem) || kindOf(item) };
63
+ }
64
+ return null;
65
+ };
66
+ // The highlight vars for the first hit fact that names both a span and the text
67
+ // it applies to. Generic: any fact shaped `{ value|text, span }` earns it.
68
+ const spanVars = (vars, hit) => {
69
+ for (const item of hit) {
70
+ const span = spanOfItem(item);
71
+ if (!span || !(0, queries_1.isObj)(item))
72
+ continue;
73
+ const text = item.value ?? item.text ?? item.raw;
74
+ if (typeof text !== "string" || !text)
75
+ continue;
76
+ vars.highlightText = text;
77
+ vars.spanStart = span.start;
78
+ vars.spanEnd = span.end;
79
+ if (span.kind)
80
+ vars.highlightKind = span.kind;
81
+ return;
82
+ }
83
+ };
84
+ // Every string field the matched items carry becomes a placeholder; `{what}`
85
+ // names the thing the rule caught; the tested field prints as the words it
86
+ // caught. Then one level down, into the items themselves.
87
+ const hitVars = (vars, hit, walk) => {
88
+ const keys = [...new Set(hit.flatMap((item) => ((0, queries_1.isObj)(item) ? Object.entries(item).filter(([, v]) => typeof v === "string" && v).map(([k]) => k) : [])))];
89
+ for (const key of keys) {
90
+ const found = spokenOf(hit, (x) => ((0, queries_1.isObj)(x) ? x[key] : undefined));
91
+ if (found)
92
+ vars[key] = found;
93
+ }
94
+ if (vars.what == null) {
95
+ const named = spokenOf(hit, (x) => ((0, queries_1.isObj)(x) ? x.name : undefined));
96
+ if (named)
97
+ vars.what = named;
98
+ }
99
+ if (vars[walk.field] == null) {
100
+ const spokenItems = spokenOf(hit, itemWord);
101
+ if (spokenItems)
102
+ vars[walk.field] = spokenItems;
103
+ }
104
+ spanVars(vars, hit);
105
+ if ((0, queries_1.isObj)(walk.walkFilter))
106
+ for (const item of hit)
107
+ listFactVars(vars, item, walk.walkFilter, walk.scope);
108
+ };
109
+ // A COMPOSITION op is not a fact field: the walk looks THROUGH it, descending
110
+ // into the sub-filters against the SAME target. A LIST of filters names the
111
+ // branches that matched; a single filter names the demand it wraps (`not:`).
112
+ const compositionBranches = (sub, target, scope) => {
113
+ if ((0, field_1.isList)(sub))
114
+ return sub.filter((f) => (0, queries_1.matches)(target, f, scope));
115
+ return (0, queries_1.isObj)(sub) ? [sub] : [];
116
+ };
117
+ const listFactVars = (vars, target, filter, scope) => {
118
+ if (!(0, queries_1.isObj)(filter))
119
+ return vars;
120
+ for (const [field, sub] of Object.entries(filter)) {
121
+ if (queries_1.COMPOSITION_OPS.has(field)) {
122
+ for (const f of compositionBranches(sub, target, scope))
123
+ listFactVars(vars, target, f, scope);
124
+ continue;
125
+ }
126
+ if (!(0, queries_1.isObj)(sub))
127
+ continue;
128
+ const value = (0, field_1.fieldOf)(target, field);
129
+ // A field that is not a list is still a ROAD: a rule reaches a list through
130
+ // the objects on the way (`css` → `templates` → `declarations` → `reads`).
131
+ if ((0, queries_1.isObj)(value)) {
132
+ listFactVars(vars, value, (0, vars_1.branchOf)(sub), scope);
133
+ continue;
134
+ }
135
+ if (!(0, field_1.isList)(value))
136
+ continue;
137
+ const { hit, walkFilter } = hitsOf(value, sub, { filter, field, scope });
138
+ if (hit.length)
139
+ hitVars(vars, hit, { field, walkFilter, scope });
140
+ }
141
+ return vars;
142
+ };
143
+ exports.listFactVars = listFactVars;
@@ -0,0 +1,16 @@
1
+ type FileVarsCtx = {
2
+ facts?: {
3
+ location?: {
4
+ path?: string;
5
+ } | null;
6
+ } | null;
7
+ rel?: string | null;
8
+ basename?: string;
9
+ };
10
+ type FileVars = {
11
+ path: string | undefined;
12
+ dir: string;
13
+ basename: string | undefined;
14
+ };
15
+ declare const fileVars: (ctx: FileVarsCtx) => FileVars;
16
+ export { fileVars };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fileVars = void 0;
4
+ // Name and variable helpers for the invariant gates: the capture variables a
5
+ // file contributes to reports.
6
+ const location_1 = require("../entities/location");
7
+ const fileVars = (ctx) => {
8
+ // The file's `location` is the one place fact (it is what `location:` filters
9
+ // and `{fileName}`/`{files}` read), so the report takes its path and folder
10
+ // from there — not from a second copy of the same two strings.
11
+ const loc = ctx.facts?.location ?? {};
12
+ const path = loc.path ?? ctx.rel ?? undefined;
13
+ // The folder is the path minus its last segment — derived here, not stored on
14
+ // the place: `location` keeps `path` and `segments`, and a `dir` field beside
15
+ // them would be the same string twice.
16
+ return { path, dir: (0, location_1.dirOf)(path), basename: ctx.basename };
17
+ };
18
+ exports.fileVars = fileVars;
@@ -0,0 +1,4 @@
1
+ import { type FieldValue } from "../utils/field";
2
+ import type { Invariant } from "../entities/architecture";
3
+ declare const normalizeInvariant: (raw: FieldValue, roles?: Set<string> | null) => Invariant;
4
+ export { normalizeInvariant };
@@ -0,0 +1,95 @@
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.normalizeInvariant = void 0;
27
+ // Normalize an invariant from the YAML into the runtime shape the gates and
28
+ // checkers consume.
29
+ //
30
+ // An invariant is: WHERE it applies (`where`), where it does NOT (`ignore`),
31
+ // and what it forbids (`infer`). Both `where` and `ignore` are the same
32
+ // mechanism the code roles use (utils/where.js).
33
+ //
34
+ // `infer` is the SAME key as in a codeRole, because it is the SAME filter
35
+ // language: the difference is only what a match means. In a role a match says
36
+ // "this code IS that role"; in an invariant it says "this file breaks the
37
+ // rule". There is one check: a finding when the filter matches. "This must be
38
+ // true" is the same filter under `not:` — the language already has it, so a
39
+ // second key would be a second way to say one thing.
40
+ const location_1 = require("../entities/location");
41
+ const schema_1 = require("../entities/schema");
42
+ const field_1 = require("../utils/field");
43
+ const configError = __importStar(require("../report/configErrors"));
44
+ // Every key an invariant may carry — anything else is a declaration the config
45
+ // believes it made, so it fails loudly instead of doing nothing.
46
+ const INVARIANT_KEYS = new Set(schema_1.SCHEMA.invariant);
47
+ const checkKeys = (raw) => {
48
+ for (const key of Object.keys(raw)) {
49
+ if (INVARIANT_KEYS.has(key))
50
+ continue;
51
+ throw configError.unknownInvariantKey({ id: raw.id, key, allowed: schema_1.SCHEMA.invariant });
52
+ }
53
+ };
54
+ // `dedupeBy` is `where` vocabulary, not a fact name. A bare string that is not
55
+ // a declared role and not a path is a mistake worth failing on: `path.dir`
56
+ // used to be a fact name and would now silently match no path at all.
57
+ const parseDedupe = (raw, roles) => {
58
+ const entries = (0, location_1.parseWhere)(raw, roles);
59
+ for (const entry of entries) {
60
+ if (entry.type !== "glob")
61
+ continue;
62
+ if (!entry.glob?.includes("/") && !entry.glob?.includes("*")) {
63
+ throw configError.dedupeByNotAPlace({ value: entry.glob });
64
+ }
65
+ }
66
+ return entries;
67
+ };
68
+ // `roles` (a Set of declared slugs) is only needed so a bare string naming a
69
+ // role is read as a role reference instead of a glob — the same rule the
70
+ // code-role actions follow.
71
+ const normalizeInvariant = (raw, roles = null) => {
72
+ if (!(0, field_1.isObj)(raw))
73
+ throw configError.invariantNotAnObject();
74
+ if (!raw.id)
75
+ throw configError.invariantWithoutId();
76
+ checkKeys(raw);
77
+ return {
78
+ id: String(raw.id),
79
+ // The SAME `where` mechanism the code-role actions use.
80
+ where: (0, location_1.parseWhere)(raw.where, roles),
81
+ ignore: (0, location_1.parseWhere)(raw.ignore, roles),
82
+ when: raw.when ?? null,
83
+ // A finding when a filter MATCHES. "Must be true" is the same filter
84
+ // under `not:` — one check, one direction, negation in the filter.
85
+ infer: (0, location_1.toList)(raw.infer),
86
+ report: typeof raw.report === "string" || (0, field_1.isObj)(raw.report) ? raw.report : null,
87
+ // WHERE the findings are counted: a `where` entry, the same vocabulary
88
+ // the roles use. `{ node: feature }` = one finding per feature folder,
89
+ // a glob = one per matched folder, a filter = one per file's folder.
90
+ // The engine only counts — the entry says which place.
91
+ dedupeBy: parseDedupe(raw.dedupeBy, roles),
92
+ children: (0, location_1.toList)(raw.children).map((c) => normalizeInvariant(c, roles)),
93
+ };
94
+ };
95
+ exports.normalizeInvariant = normalizeInvariant;
@@ -0,0 +1,20 @@
1
+ import { type FieldValue } from "../utils/field";
2
+ import type { QueryScope } from "../entities/architecture";
3
+ import type { FileContext } from "../entities/context";
4
+ type ReportVars = Record<string, string | number>;
5
+ declare const filterOf: (entry: FieldValue) => FieldValue;
6
+ declare const enrichedVars: (ctx: FileContext) => ReportVars;
7
+ declare const listHit: (list: readonly FieldValue[], filter: FieldValue, field: string, scope: QueryScope) => FieldValue[];
8
+ declare const collectScalars: (value: FieldValue, vars: ReportVars, depth?: number) => void;
9
+ declare const QUANTIFIERS: Set<string>;
10
+ declare const branchOf: (sub: FieldValue) => FieldValue;
11
+ declare const describePiece: (c: {
12
+ lines?: number[];
13
+ css?: {
14
+ templates?: {
15
+ tag?: string;
16
+ }[];
17
+ };
18
+ }) => string;
19
+ export { filterOf, enrichedVars, listHit, collectScalars, branchOf, describePiece, QUANTIFIERS };
20
+ export type { ReportVars };