@md-code/follow-architecture 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +597 -126
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +14 -0
  7. package/dist/args.js +77 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/code-roles/classify.d.ts +11 -0
  11. package/dist/code-roles/classify.js +43 -0
  12. package/dist/code-roles/connector.d.ts +5 -0
  13. package/dist/code-roles/connector.js +114 -0
  14. package/dist/code-roles/project.d.ts +12 -0
  15. package/dist/code-roles/project.js +122 -0
  16. package/dist/code-roles/roles.d.ts +8 -0
  17. package/dist/code-roles/roles.js +190 -0
  18. package/dist/config-options.d.ts +53 -0
  19. package/dist/config-options.js +35 -0
  20. package/dist/config-project.d.ts +4 -0
  21. package/dist/config-project.js +74 -0
  22. package/dist/config-report.d.ts +19 -0
  23. package/dist/config-report.js +134 -0
  24. package/dist/config-rule.d.ts +70 -0
  25. package/dist/config-rule.js +118 -0
  26. package/dist/config-state.d.ts +14 -0
  27. package/dist/config-state.js +96 -0
  28. package/dist/config.d.ts +82 -0
  29. package/dist/config.js +38 -0
  30. package/dist/css/index.d.ts +27 -0
  31. package/dist/css/index.js +140 -0
  32. package/dist/css/syntax/css/gate.d.ts +2 -0
  33. package/dist/css/syntax/css/gate.js +69 -0
  34. package/dist/css/syntax/css/index.d.ts +7 -0
  35. package/dist/css/syntax/css/index.js +41 -0
  36. package/dist/css/syntax/css/reference.d.ts +3 -0
  37. package/dist/css/syntax/css/reference.js +24 -0
  38. package/dist/css/syntax/language.d.ts +25 -0
  39. package/dist/css/syntax/language.js +69 -0
  40. package/dist/css/syntax/scss/index.d.ts +25 -0
  41. package/dist/css/syntax/scss/index.js +85 -0
  42. package/dist/css/syntax/scss/reference.d.ts +3 -0
  43. package/dist/css/syntax/scss/reference.js +11 -0
  44. package/dist/css/syntax/styled/document.d.ts +68 -0
  45. package/dist/css/syntax/styled/document.js +241 -0
  46. package/dist/css/syntax/styled/markup.d.ts +6 -0
  47. package/dist/css/syntax/styled/markup.js +76 -0
  48. package/dist/css/syntax/styled/template.d.ts +23 -0
  49. package/dist/css/syntax/styled/template.js +61 -0
  50. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  51. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  52. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  53. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  54. package/dist/css/value/check.d.ts +86 -0
  55. package/dist/css/value/check.js +122 -0
  56. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  57. package/dist/css/value/expression/arithmetic.js +69 -0
  58. package/dist/css/value/expression/block.d.ts +9 -0
  59. package/dist/css/value/expression/block.js +91 -0
  60. package/dist/css/value/expression/conditional.d.ts +8 -0
  61. package/dist/css/value/expression/conditional.js +53 -0
  62. package/dist/css/value/expression/index.d.ts +5 -0
  63. package/dist/css/value/expression/index.js +69 -0
  64. package/dist/css/value/expression/map.d.ts +7 -0
  65. package/dist/css/value/expression/map.js +113 -0
  66. package/dist/css/value/object/index.d.ts +5 -0
  67. package/dist/css/value/object/index.js +103 -0
  68. package/dist/css/value/object/members.d.ts +7 -0
  69. package/dist/css/value/object/members.js +103 -0
  70. package/dist/css/value/object/node.d.ts +8 -0
  71. package/dist/css/value/object/node.js +129 -0
  72. package/dist/css/value/object/path.d.ts +10 -0
  73. package/dist/css/value/object/path.js +146 -0
  74. package/dist/css/value/pieces.d.ts +61 -0
  75. package/dist/css/value/pieces.js +55 -0
  76. package/dist/css/value/resolve.d.ts +33 -0
  77. package/dist/css/value/resolve.js +94 -0
  78. package/dist/css/value/scope.d.ts +27 -0
  79. package/dist/css/value/scope.js +187 -0
  80. package/dist/css/value/substitute.d.ts +10 -0
  81. package/dist/css/value/substitute.js +113 -0
  82. package/dist/css/value/values.d.ts +23 -0
  83. package/dist/css/value/values.js +131 -0
  84. package/dist/entities/architecture.d.ts +162 -0
  85. package/dist/entities/architecture.js +2 -0
  86. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  87. package/dist/entities/ast/assignments-nodes.js +64 -0
  88. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  89. package/dist/entities/ast/assignments-raw.js +86 -0
  90. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  91. package/dist/entities/ast/assignments-tagged.js +180 -0
  92. package/dist/entities/ast/assignments.d.ts +9 -0
  93. package/dist/entities/ast/assignments.js +78 -0
  94. package/dist/entities/ast/branches.d.ts +4 -0
  95. package/dist/entities/ast/branches.js +32 -0
  96. package/dist/entities/ast/calls.d.ts +6 -0
  97. package/dist/entities/ast/calls.js +134 -0
  98. package/dist/entities/ast/classes.d.ts +5 -0
  99. package/dist/entities/ast/classes.js +57 -0
  100. package/dist/entities/ast/climb.d.ts +12 -0
  101. package/dist/entities/ast/climb.js +17 -0
  102. package/dist/entities/ast/comments.d.ts +4 -0
  103. package/dist/entities/ast/comments.js +100 -0
  104. package/dist/entities/ast/declaration.d.ts +4 -0
  105. package/dist/entities/ast/declaration.js +26 -0
  106. package/dist/entities/ast/depth.d.ts +17 -0
  107. package/dist/entities/ast/depth.js +149 -0
  108. package/dist/entities/ast/enums.d.ts +6 -0
  109. package/dist/entities/ast/enums.js +17 -0
  110. package/dist/entities/ast/file-exports.d.ts +7 -0
  111. package/dist/entities/ast/file-exports.js +78 -0
  112. package/dist/entities/ast/file-facts.d.ts +13 -0
  113. package/dist/entities/ast/file-facts.js +35 -0
  114. package/dist/entities/ast/file-imports.d.ts +5 -0
  115. package/dist/entities/ast/file-imports.js +77 -0
  116. package/dist/entities/ast/file.d.ts +5 -0
  117. package/dist/entities/ast/file.js +22 -0
  118. package/dist/entities/ast/functions.d.ts +8 -0
  119. package/dist/entities/ast/functions.js +102 -0
  120. package/dist/entities/ast/heritage.d.ts +4 -0
  121. package/dist/entities/ast/heritage.js +36 -0
  122. package/dist/entities/ast/index.d.ts +6 -0
  123. package/dist/entities/ast/index.js +125 -0
  124. package/dist/entities/ast/kind.d.ts +5 -0
  125. package/dist/entities/ast/kind.js +28 -0
  126. package/dist/entities/ast/loose.d.ts +37 -0
  127. package/dist/entities/ast/loose.js +2 -0
  128. package/dist/entities/ast/modifiers.d.ts +5 -0
  129. package/dist/entities/ast/modifiers.js +32 -0
  130. package/dist/entities/ast/project.d.ts +9 -0
  131. package/dist/entities/ast/project.js +75 -0
  132. package/dist/entities/ast/properties.d.ts +11 -0
  133. package/dist/entities/ast/properties.js +171 -0
  134. package/dist/entities/ast/resolve.d.ts +16 -0
  135. package/dist/entities/ast/resolve.js +307 -0
  136. package/dist/entities/ast/tree.d.ts +29 -0
  137. package/dist/entities/ast/tree.js +351 -0
  138. package/dist/entities/ast/types.d.ts +6 -0
  139. package/dist/entities/ast/types.js +45 -0
  140. package/dist/entities/ast/usage.d.ts +11 -0
  141. package/dist/entities/ast/usage.js +81 -0
  142. package/dist/entities/ast/variables.d.ts +8 -0
  143. package/dist/entities/ast/variables.js +91 -0
  144. package/dist/entities/context.d.ts +29 -0
  145. package/dist/entities/context.js +2 -0
  146. package/dist/entities/facts.d.ts +261 -0
  147. package/dist/entities/facts.js +2 -0
  148. package/dist/entities/findings.d.ts +19 -0
  149. package/dist/entities/findings.js +2 -0
  150. package/dist/entities/kinds.d.ts +40 -0
  151. package/dist/entities/kinds.js +221 -0
  152. package/dist/entities/location/homes.d.ts +28 -0
  153. package/dist/entities/location/homes.js +169 -0
  154. package/dist/entities/location/place.d.ts +10 -0
  155. package/dist/entities/location/place.js +56 -0
  156. package/dist/entities/location/where.d.ts +17 -0
  157. package/dist/entities/location/where.js +218 -0
  158. package/dist/entities/location.d.ts +16 -0
  159. package/dist/entities/location.js +140 -0
  160. package/dist/entities/operators.d.ts +14 -0
  161. package/dist/entities/operators.js +30 -0
  162. package/dist/entities/overview/data.d.ts +43 -0
  163. package/dist/entities/overview/data.js +2 -0
  164. package/dist/entities/overview/decision.d.ts +60 -0
  165. package/dist/entities/overview/decision.js +2 -0
  166. package/dist/entities/overview/file-tree.d.ts +10 -0
  167. package/dist/entities/overview/file-tree.js +2 -0
  168. package/dist/entities/overview/finding.d.ts +58 -0
  169. package/dist/entities/overview/finding.js +2 -0
  170. package/dist/entities/overview/graph.d.ts +65 -0
  171. package/dist/entities/overview/graph.js +2 -0
  172. package/dist/entities/overview/input.d.ts +15 -0
  173. package/dist/entities/overview/input.js +2 -0
  174. package/dist/entities/overview/summaries.d.ts +79 -0
  175. package/dist/entities/overview/summaries.js +2 -0
  176. package/dist/entities/place.d.ts +5 -0
  177. package/dist/entities/place.js +2 -0
  178. package/dist/entities/queries.d.ts +9 -0
  179. package/dist/entities/queries.js +305 -0
  180. package/dist/entities/repair.d.ts +16 -0
  181. package/dist/entities/repair.js +23 -0
  182. package/dist/entities/schema.d.ts +8 -0
  183. package/dist/entities/schema.js +23 -0
  184. package/dist/entities/story.d.ts +47 -0
  185. package/dist/entities/story.js +2 -0
  186. package/dist/entities/structure-facts.d.ts +11 -0
  187. package/dist/entities/structure-facts.js +2 -0
  188. package/dist/entities/token.d.ts +23 -0
  189. package/dist/entities/token.js +2 -0
  190. package/dist/entities/tree/build.d.ts +5 -0
  191. package/dist/entities/tree/build.js +252 -0
  192. package/dist/entities/tree/entries.d.ts +7 -0
  193. package/dist/entities/tree/entries.js +120 -0
  194. package/dist/entities/tree/index.d.ts +6 -0
  195. package/dist/entities/tree/index.js +21 -0
  196. package/dist/entities/tree/match.d.ts +17 -0
  197. package/dist/entities/tree/match.js +176 -0
  198. package/dist/frameworks/angular/index.d.ts +7 -0
  199. package/dist/frameworks/angular/index.js +17 -0
  200. package/dist/frameworks/facet.d.ts +16 -0
  201. package/dist/frameworks/facet.js +2 -0
  202. package/dist/frameworks/index.d.ts +9 -0
  203. package/dist/frameworks/index.js +120 -0
  204. package/dist/frameworks/react/index.d.ts +7 -0
  205. package/dist/frameworks/react/index.js +214 -0
  206. package/dist/frameworks/vue/index.d.ts +7 -0
  207. package/dist/frameworks/vue/index.js +17 -0
  208. package/dist/invariants/index.d.ts +6 -0
  209. package/dist/invariants/index.js +299 -0
  210. package/dist/invariants/list-vars.d.ts +5 -0
  211. package/dist/invariants/list-vars.js +143 -0
  212. package/dist/invariants/name.d.ts +16 -0
  213. package/dist/invariants/name.js +18 -0
  214. package/dist/invariants/normalize.d.ts +4 -0
  215. package/dist/invariants/normalize.js +95 -0
  216. package/dist/invariants/vars.d.ts +20 -0
  217. package/dist/invariants/vars.js +117 -0
  218. package/dist/main.d.ts +7 -0
  219. package/dist/main.js +229 -0
  220. package/dist/nodes/child-roles.d.ts +3 -0
  221. package/dist/nodes/child-roles.js +12 -0
  222. package/dist/nodes/children.d.ts +25 -0
  223. package/dist/nodes/children.js +112 -0
  224. package/dist/nodes/finally/emit.d.ts +6 -0
  225. package/dist/nodes/finally/emit.js +55 -0
  226. package/dist/nodes/finally/index.d.ts +8 -0
  227. package/dist/nodes/finally/index.js +35 -0
  228. package/dist/nodes/finally/queries.d.ts +5 -0
  229. package/dist/nodes/finally/queries.js +22 -0
  230. package/dist/nodes/finally/relations-access.d.ts +5 -0
  231. package/dist/nodes/finally/relations-access.js +46 -0
  232. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  233. package/dist/nodes/finally/relations-edge.js +125 -0
  234. package/dist/nodes/finally/relations-group.d.ts +31 -0
  235. package/dist/nodes/finally/relations-group.js +103 -0
  236. package/dist/nodes/finally/relations.d.ts +5 -0
  237. package/dist/nodes/finally/relations.js +81 -0
  238. package/dist/nodes/finally/required.d.ts +5 -0
  239. package/dist/nodes/finally/required.js +90 -0
  240. package/dist/nodes/finally/roles.d.ts +13 -0
  241. package/dist/nodes/finally/roles.js +41 -0
  242. package/dist/nodes/finally/violation.d.ts +17 -0
  243. package/dist/nodes/finally/violation.js +2 -0
  244. package/dist/nodes/similar.d.ts +21 -0
  245. package/dist/nodes/similar.js +156 -0
  246. package/dist/pipeline-facts.d.ts +11 -0
  247. package/dist/pipeline-facts.js +112 -0
  248. package/dist/pipeline-roles.d.ts +6 -0
  249. package/dist/pipeline-roles.js +75 -0
  250. package/dist/pipeline-unroled.d.ts +14 -0
  251. package/dist/pipeline-unroled.js +193 -0
  252. package/dist/pipeline.d.ts +7 -0
  253. package/dist/pipeline.js +73 -0
  254. package/dist/plugin.d.ts +2 -0
  255. package/dist/plugin.js +3 -0
  256. package/dist/report/asks.d.ts +55 -0
  257. package/dist/report/asks.js +50 -0
  258. package/dist/report/cli-report.d.ts +2 -0
  259. package/dist/report/cli-report.js +13 -0
  260. package/dist/report/config-error-guard.d.ts +8 -0
  261. package/dist/report/config-error-guard.js +5 -0
  262. package/dist/report/configErrors.d.ts +98 -0
  263. package/dist/report/configErrors.js +75 -0
  264. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  265. package/dist/report/errorTypes/codes/structure.js +76 -0
  266. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  267. package/dist/report/errorTypes/decision-maker.js +99 -0
  268. package/dist/report/errorTypes/destinations.d.ts +38 -0
  269. package/dist/report/errorTypes/destinations.js +147 -0
  270. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  271. package/dist/report/errorTypes/finding-type.js +2 -0
  272. package/dist/report/errorTypes/index.d.ts +15 -0
  273. package/dist/report/errorTypes/index.js +45 -0
  274. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  275. package/dist/report/errorTypes/types/fileContents.js +34 -0
  276. package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
  277. package/dist/report/errorTypes/types/unknownRole.js +22 -0
  278. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  279. package/dist/report/errorTypes/types/wrongAction.js +135 -0
  280. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  281. package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
  282. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  283. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  284. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  285. package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
  286. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  287. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  288. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  289. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  290. package/dist/report/finding-from.d.ts +9 -0
  291. package/dist/report/finding-from.js +103 -0
  292. package/dist/report/notices.d.ts +4 -0
  293. package/dist/report/notices.js +31 -0
  294. package/dist/report/render-report.d.ts +12 -0
  295. package/dist/report/render-report.js +142 -0
  296. package/dist/report/user-report/build/bundle.d.ts +3 -0
  297. package/dist/report/user-report/build/bundle.js +169 -0
  298. package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
  299. package/dist/report/user-report/data/collect.d.ts +4 -0
  300. package/dist/report/user-report/data/collect.js +80 -0
  301. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  302. package/dist/report/user-report/data/file-tree.js +72 -0
  303. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  304. package/dist/report/user-report/data/finding-boundary.js +21 -0
  305. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  306. package/dist/report/user-report/data/finding-plan.js +45 -0
  307. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  308. package/dist/report/user-report/data/finding-title.js +36 -0
  309. package/dist/report/user-report/data/findings.d.ts +10 -0
  310. package/dist/report/user-report/data/findings.js +171 -0
  311. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  312. package/dist/report/user-report/data/graph-edges.js +109 -0
  313. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  314. package/dist/report/user-report/data/graph-helpers.js +67 -0
  315. package/dist/report/user-report/data/graph-roles.d.ts +5 -0
  316. package/dist/report/user-report/data/graph-roles.js +71 -0
  317. package/dist/report/user-report/data/graph.d.ts +11 -0
  318. package/dist/report/user-report/data/graph.js +90 -0
  319. package/dist/report/user-report/data/invariants.d.ts +7 -0
  320. package/dist/report/user-report/data/invariants.js +62 -0
  321. package/dist/report/user-report/data/nodes.d.ts +11 -0
  322. package/dist/report/user-report/data/nodes.js +106 -0
  323. package/dist/report/user-report/data/role-examples.d.ts +16 -0
  324. package/dist/report/user-report/data/role-examples.js +94 -0
  325. package/dist/report/user-report/data/role-filters.d.ts +15 -0
  326. package/dist/report/user-report/data/role-filters.js +79 -0
  327. package/dist/report/user-report/data/role-marks.d.ts +5 -0
  328. package/dist/report/user-report/data/role-marks.js +79 -0
  329. package/dist/report/user-report/data/roles.d.ts +7 -0
  330. package/dist/report/user-report/data/roles.js +83 -0
  331. package/dist/report/user-report/data/scan.d.ts +8 -0
  332. package/dist/report/user-report/data/scan.js +59 -0
  333. package/dist/report/user-report/html/shell.d.ts +3 -0
  334. package/dist/report/user-report/html/shell.js +27 -0
  335. package/dist/report/user-report/index.d.ts +8 -0
  336. package/dist/report/user-report/index.js +48 -0
  337. package/dist/report/user-report/shared/describe.d.ts +7 -0
  338. package/dist/report/user-report/shared/describe.js +86 -0
  339. package/dist/scripts/audit-report.d.ts +2 -0
  340. package/dist/scripts/audit-report.js +147 -0
  341. package/dist/utils/accumulate.d.ts +6 -0
  342. package/dist/utils/accumulate.js +18 -0
  343. package/dist/utils/article.d.ts +2 -0
  344. package/dist/utils/article.js +12 -0
  345. package/dist/utils/classify.d.ts +12 -0
  346. package/dist/utils/classify.js +25 -0
  347. package/dist/utils/configs.d.ts +25 -0
  348. package/dist/utils/configs.js +87 -0
  349. package/dist/utils/count.d.ts +7 -0
  350. package/dist/utils/count.js +13 -0
  351. package/dist/utils/dispatch.d.ts +2 -0
  352. package/dist/utils/dispatch.js +27 -0
  353. package/dist/utils/distinct.d.ts +2 -0
  354. package/dist/utils/distinct.js +12 -0
  355. package/dist/utils/field.d.ts +14 -0
  356. package/dist/utils/field.js +60 -0
  357. package/dist/utils/file-name.d.ts +2 -0
  358. package/dist/utils/file-name.js +11 -0
  359. package/dist/utils/files.d.ts +7 -0
  360. package/dist/utils/files.js +73 -0
  361. package/dist/utils/fixpoint.d.ts +2 -0
  362. package/dist/utils/fixpoint.js +19 -0
  363. package/dist/utils/gate.d.ts +2 -0
  364. package/dist/utils/gate.js +12 -0
  365. package/dist/utils/group.d.ts +3 -0
  366. package/dist/utils/group.js +33 -0
  367. package/dist/utils/host.d.ts +3 -0
  368. package/dist/utils/host.js +13 -0
  369. package/dist/utils/imports.d.ts +12 -0
  370. package/dist/utils/imports.js +121 -0
  371. package/dist/utils/judged.d.ts +5 -0
  372. package/dist/utils/judged.js +19 -0
  373. package/dist/utils/keyed.d.ts +2 -0
  374. package/dist/utils/keyed.js +23 -0
  375. package/dist/utils/map-record.d.ts +2 -0
  376. package/dist/utils/map-record.js +11 -0
  377. package/dist/utils/path-label.d.ts +6 -0
  378. package/dist/utils/path-label.js +35 -0
  379. package/dist/utils/pattern.d.ts +18 -0
  380. package/dist/utils/pattern.js +191 -0
  381. package/dist/utils/permission.d.ts +16 -0
  382. package/dist/utils/permission.js +16 -0
  383. package/dist/utils/plural.d.ts +2 -0
  384. package/dist/utils/plural.js +9 -0
  385. package/dist/utils/qualified.d.ts +2 -0
  386. package/dist/utils/qualified.js +21 -0
  387. package/dist/utils/rank.d.ts +2 -0
  388. package/dist/utils/rank.js +24 -0
  389. package/dist/utils/read-field.d.ts +12 -0
  390. package/dist/utils/read-field.js +50 -0
  391. package/dist/utils/read-when.d.ts +2 -0
  392. package/dist/utils/read-when.js +17 -0
  393. package/dist/utils/reason.d.ts +4 -0
  394. package/dist/utils/reason.js +9 -0
  395. package/dist/utils/record.d.ts +3 -0
  396. package/dist/utils/record.js +21 -0
  397. package/dist/utils/resolve.d.ts +2 -0
  398. package/dist/utils/resolve.js +24 -0
  399. package/dist/utils/search.d.ts +2 -0
  400. package/dist/utils/search.js +16 -0
  401. package/dist/utils/seen.d.ts +6 -0
  402. package/dist/utils/seen.js +27 -0
  403. package/dist/utils/span.d.ts +5 -0
  404. package/dist/utils/span.js +2 -0
  405. package/dist/utils/speak.d.ts +2 -0
  406. package/dist/utils/speak.js +18 -0
  407. package/dist/utils/split.d.ts +8 -0
  408. package/dist/utils/split.js +8 -0
  409. package/dist/utils/template.d.ts +5 -0
  410. package/dist/utils/template.js +5 -0
  411. package/dist/utils/text.d.ts +4 -0
  412. package/dist/utils/text.js +42 -0
  413. package/dist/utils/tokenize.d.ts +2 -0
  414. package/dist/utils/tokenize.js +13 -0
  415. package/dist/utils/try-read.d.ts +4 -0
  416. package/dist/utils/try-read.js +24 -0
  417. package/dist/utils/typed-field.d.ts +3 -0
  418. package/dist/utils/typed-field.js +16 -0
  419. package/dist/utils/verdicts.d.ts +4 -0
  420. package/dist/utils/verdicts.js +20 -0
  421. package/entities/operators.ts +31 -0
  422. package/package.json +62 -19
  423. package/report/errorTypes/vocabulary/ids.ts +12 -0
  424. package/report/errorTypes/vocabulary/phrases.ts +161 -0
  425. package/report/errorTypes/vocabulary/places.ts +46 -0
  426. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  427. package/report/user-report/shared/describe.ts +107 -0
  428. package/ast.js +0 -107
  429. package/bin/follow-architecture.js +0 -6
  430. package/config.js +0 -82
  431. package/entities/aliases.js +0 -10
  432. package/entities/invariants.js +0 -134
  433. package/entities/nodes.js +0 -112
  434. package/main.js +0 -95
  435. package/report.js +0 -73
  436. package/utils.js +0 -104
@@ -0,0 +1,5 @@
1
+ type Span = {
2
+ start: number;
3
+ end: number;
4
+ };
5
+ export type { Span };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ declare const speakOnce: (spoken: Set<string>, subject: string) => boolean;
2
+ export { speakOnce };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.speakOnce = void 0;
4
+ // A SPOKEN SET is one mechanism: a subject is named once — the first time it
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
7
+ // arrow answers two entries, the reader needs one sentence); any consumer that
8
+ // names subjects without repeating itself asks the same question. The walk is
9
+ // the same — ask, remember, answer — so it lives here once. What a subject IS
10
+ // is the caller's own.
11
+ // True the FIRST time this subject is offered; false every time after.
12
+ const speakOnce = (spoken, subject) => {
13
+ if (spoken.has(subject))
14
+ return false;
15
+ spoken.add(subject);
16
+ return true;
17
+ };
18
+ exports.speakOnce = speakOnce;
@@ -0,0 +1,8 @@
1
+ type Parts = {
2
+ all: string[];
3
+ head: string[];
4
+ last: string;
5
+ };
6
+ declare const partsOf: (text: string | null | undefined, separator: string) => Parts;
7
+ export { partsOf };
8
+ export type { Parts };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.partsOf = void 0;
4
+ const partsOf = (text, separator) => {
5
+ const all = String(text ?? "").split(separator);
6
+ return { all, head: all.slice(0, -1), last: all[all.length - 1] ?? "" };
7
+ };
8
+ exports.partsOf = partsOf;
@@ -0,0 +1,5 @@
1
+ import type { FieldValue } from "../utils/field";
2
+ type TemplateVars = Record<string, FieldValue>;
3
+ declare const substitute: (text: string, vars: TemplateVars) => string;
4
+ export { substitute };
5
+ export type { TemplateVars };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.substitute = void 0;
4
+ const substitute = (text, vars) => String(text).replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g, (whole, k) => (vars[k] != null ? String(vars[k]) : whole));
5
+ exports.substitute = substitute;
@@ -0,0 +1,4 @@
1
+ declare const firstLine: (text: string) => string;
2
+ declare const closingParen: (text: string, open: number) => number;
3
+ declare const topLevelComma: (text: string) => number;
4
+ export { firstLine, closingParen, topLevelComma };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.topLevelComma = exports.closingParen = exports.firstLine = void 0;
4
+ // Small text scans shared by more than one domain. Each one is a single reading
5
+ // of a string that the resolver, the grammar checker and the report all need;
6
+ // keeping them here means one implementation of "the first line", "where a
7
+ // parenthesised group ends", "the first top-level comma".
8
+ // The first line of a multi-line message — what a report quotes when it names a
9
+ // parser error without the caret drawing under it.
10
+ const firstLine = (text) => text.split("\n")[0].trim();
11
+ exports.firstLine = firstLine;
12
+ // The index of the `)` that closes the `(` at `open`, or -1. Nested groups are
13
+ // counted, so `calc((a - b) / 2)` closes where it looks like it does.
14
+ const closingParen = (text, open) => {
15
+ let depth = 0;
16
+ for (let index = open; index < text.length; index += 1) {
17
+ if (text[index] === "(")
18
+ depth += 1;
19
+ else if (text[index] === ")") {
20
+ depth -= 1;
21
+ if (depth === 0)
22
+ return index;
23
+ }
24
+ }
25
+ return -1;
26
+ };
27
+ exports.closingParen = closingParen;
28
+ // The first comma not inside a nested group — the separator of `var(--x, 8px)`.
29
+ const topLevelComma = (text) => {
30
+ let depth = 0;
31
+ for (let index = 0; index < text.length; index += 1) {
32
+ const char = text[index];
33
+ if (char === "(")
34
+ depth += 1;
35
+ else if (char === ")")
36
+ depth -= 1;
37
+ else if (char === "," && depth === 0)
38
+ return index;
39
+ }
40
+ return -1;
41
+ };
42
+ exports.topLevelComma = topLevelComma;
@@ -0,0 +1,2 @@
1
+ declare const tokenize: (text: string | null | undefined) => string[];
2
+ export { tokenize };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tokenize = void 0;
4
+ // Split a string into its whitespace-separated tokens, as written, without
5
+ // duplicates. A class list is the case this was born from, but the reading is
6
+ // any string of tokens: `md:hover:grid-cols-3` is ONE token with variants —
7
+ // splitting it further would turn a token into things that are not tokens. What
8
+ // a token MEANS is the caller's question, not the split's.
9
+ //
10
+ // A GLOBAL utility: tailwind, a class attribute, any facet reads a token list
11
+ // the same way.
12
+ const tokenize = (text) => [...new Set(String(text ?? "").trim().split(/\s+/).filter(Boolean))];
13
+ exports.tokenize = tokenize;
@@ -0,0 +1,4 @@
1
+ declare const readOrFallback: <Subject, Answer>(subject: Subject, read: (subject: Subject) => Answer, fallback: Answer, onError?: (error: {
2
+ message?: string;
3
+ }) => void) => Answer;
4
+ export { readOrFallback };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readOrFallback = void 0;
4
+ // A GUARDED READ is one mechanism: a reader may fail on a subject it cannot
5
+ // read, and the answer then is a stated fallback — never a crash, never a
6
+ // guess. The CSS content gate reads a document through a parser that throws on
7
+ // SQL or prose (`css/syntax/gate`); the document reader reads text through the
8
+ // syntax's own parser (`css/document`). The walk is the same — try the read,
9
+ // on failure take the fallback — so it lives here once. What is read, what the
10
+ // fallback is, and whether the failure is also REPORTED are the caller's own.
11
+ // Read `subject`, or take the fallback when the read throws. `onError` is the
12
+ // caller's voice: a gate stays silent (a non-CSS template is normal), a document
13
+ // reader reports (a stylesheet nobody can parse must not pass for a clean one).
14
+ const readOrFallback = (subject, read, fallback, onError) => {
15
+ try {
16
+ return read(subject);
17
+ }
18
+ catch (error) {
19
+ const e = error;
20
+ onError?.(e);
21
+ return fallback;
22
+ }
23
+ };
24
+ exports.readOrFallback = readOrFallback;
@@ -0,0 +1,3 @@
1
+ import { type FieldValue } from "./field";
2
+ declare const typedField: <T extends FieldValue>(record: FieldValue, key: string, qualifies: (value: FieldValue) => value is T) => T | undefined;
3
+ export { typedField };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typedField = void 0;
4
+ // A TYPED FIELD is one mechanism: a record's field is read as plain data, and
5
+ // only the value of the expected shape is kept — anything else is nothing. A
6
+ // report template's string fields are read this way (`invariants/index`); a
7
+ // scope accessor's `scope` is read this way (`code-roles/roles`). The walk is
8
+ // the same — read, qualify, keep or drop — so it lives here once. What the
9
+ // field IS and which shape qualifies is the caller's own.
10
+ const field_1 = require("./field");
11
+ // The field's value when it has the expected shape; undefined otherwise.
12
+ const typedField = (record, key, qualifies) => {
13
+ const value = (0, field_1.fieldOf)(record, key);
14
+ return qualifies(value) ? value : undefined;
15
+ };
16
+ exports.typedField = typedField;
@@ -0,0 +1,4 @@
1
+ declare const worstWhenAllRefuse: <T extends {
2
+ violation: boolean;
3
+ }>(entries: T[], rank: (a: T, b: T) => number) => T | null;
4
+ export { worstWhenAllRefuse };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.worstWhenAllRefuse = void 0;
4
+ // A VERDICT LIST is one mechanism: entries are judged, the refusals are ranked
5
+ // by how well they EXPLAIN the rule, and the best explanation is the one the
6
+ // reader gets. The relation check ranks the target roles an edge could be
7
+ // judged by (`nodes/finally/relations`); any consumer that must pick the most
8
+ // informative refusal asks the same question. The ranking is the caller's own
9
+ // policy; the walk — rank, then take the head only when EVERY entry refuses —
10
+ // lives here once.
11
+ // Rank refusals best-explanation-first and return the head, but only when the
12
+ // list is non-empty and every entry is a refusal. One dissenting entry means
13
+ // the subject is allowed somewhere, and there is nothing to report.
14
+ const worstWhenAllRefuse = (entries, rank) => {
15
+ if (!entries.length || !entries.every((e) => e.violation))
16
+ return null;
17
+ const sorted = [...entries].sort(rank);
18
+ return sorted[0];
19
+ };
20
+ exports.worstWhenAllRefuse = worstWhenAllRefuse;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ // The operator vocabulary AS THE REPORT READS IT: which keys stand for a list,
4
+ // which of them say "one of them", and how a scalar operator is spelled for a
5
+ // human. Two readers share it — the Node-side summarizer (`data/invariants.js`)
6
+ // and the browser describer (`src/utils/describe.js`) — because they used to
7
+ // carry the same three tables twice and printed two different truths.
8
+ //
9
+ // The ENGINE's own operator sets stay in `entities/queries.js`: the matcher
10
+ // knows more than it can print, and printing is not matching.
11
+
12
+ // A key that walks INTO a list rather than addressing a field.
13
+ const CONTAINERS = new Set(["some", "every", "none", "length", "where", "filter", "by"]);
14
+
15
+ // …of those, the ones that say "one of them": they read as `[*]` in a path.
16
+ const QUANTIFIERS = new Set(["some", "every", "none", "any"]);
17
+
18
+ // A scalar operator, spelled the way a reader expects to see it.
19
+ const SCALAR_OPS = {
20
+ gt: ">",
21
+ gte: "≥",
22
+ lt: "<",
23
+ lte: "≤",
24
+ equals: "=",
25
+ in: "in",
26
+ not: "≠",
27
+ isSet: "is set",
28
+ matches: "matches",
29
+ };
30
+
31
+ export { CONTAINERS, QUANTIFIERS, SCALAR_OPS };
package/package.json CHANGED
@@ -1,40 +1,85 @@
1
1
  {
2
2
  "name": "@md-code/follow-architecture",
3
- "version": "0.1.0",
4
- "description": "ESLint rule + CLI that enforces the vertical-slice architecture: every slice has a .resource.ts CRUD binding, every .rm.ts imports and calls it, and nothing bypasses it.",
5
- "license": "MIT",
6
- "main": "config.js",
3
+ "version": "0.3.0",
4
+ "private": false,
5
+ "description": "ESLint rule + CLI that enforces a declarative architecture: where files may live, what they may be named, and what they may contain.",
6
+ "license": "Apache-2.0",
7
+ "author": "DrBoria <dr.boria@gmail.com>",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/DrBoria/follow-architecture.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/DrBoria/follow-architecture/issues"
14
+ },
15
+ "homepage": "https://github.com/DrBoria/follow-architecture#readme",
16
+ "main": "dist/plugin.js",
17
+ "types": "dist/plugin.d.ts",
7
18
  "engines": {
8
19
  "node": ">=18"
9
20
  },
10
21
  "bin": {
11
- "follow-architecture": "bin/follow-architecture.js"
22
+ "follow-architecture": "dist/bin/follow-architecture.js"
12
23
  },
13
24
  "files": [
14
- "config.js",
15
- "main.js",
16
- "utils.js",
17
- "report.js",
18
- "ast.js",
19
- "entities",
20
- "bin",
21
- "README.md"
25
+ "dist/",
26
+ "report/user-report/shared/",
27
+ "report/errorTypes/vocabulary/",
28
+ "entities/operators.ts",
29
+ "README.md",
30
+ "CHANGELOG.md"
22
31
  ],
23
32
  "exports": {
24
- ".": "./config.js",
25
- "./config": "./config.js",
26
- "./main": "./main.js",
33
+ ".": "./dist/plugin.js",
34
+ "./plugin": "./dist/plugin.js",
35
+ "./config": "./dist/config.js",
36
+ "./main": "./dist/main.js",
27
37
  "./package.json": "./package.json"
28
38
  },
29
39
  "dependencies": {
30
40
  "@typescript-eslint/parser": "^8.71.0",
31
- "remeda": "^2.50.0",
41
+ "css-tree": "^3.2.1",
42
+ "highlight.js": "^11.12.0",
43
+ "js-yaml": "^5.4.2",
32
44
  "minimatch": "^9.0.4",
45
+ "postcss": "^8.5.32",
46
+ "postcss-scss": "^4.0.9",
47
+ "postcss-selector-parser": "^7.1.7",
48
+ "postcss-value-parser": "^4.2.0",
49
+ "remeda": "^2.50.0",
50
+ "stylis": "^4.4.0",
51
+ "tailwindcss": "^3.4.0",
33
52
  "ts-morph": "^24.0.0"
34
53
  },
35
54
  "peerDependencies": {
36
55
  "eslint": ">=8.40.0"
37
56
  },
57
+ "scripts": {
58
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
59
+ "build": "npm run clean && tsc -p tsconfig.json && npm run prebuild:report",
60
+ "prebuild:report": "node scripts/build-report-bundle.mjs",
61
+ "typecheck": "tsc -p tsconfig.json --noEmit",
62
+ "test": "vitest run",
63
+ "overview": "node dist/bin/follow-architecture.js --overview architecture-overview.html",
64
+ "prepublishOnly": "npm run build && vitest run --no-file-parallelism",
65
+ "lint": "eslint ."
66
+ },
67
+ "devDependencies": {
68
+ "@md-code/component-uniqueness": "workspace:*",
69
+ "@md-code/entities-uniqueness": "workspace:*",
70
+ "@md-code/utils-uniqueness": "workspace:*",
71
+ "@types/node": "^26.6.6",
72
+ "@types/react": "^18",
73
+ "@types/react-dom": "^18",
74
+ "esbuild": "^0.25.12",
75
+ "react": "^18.3.1",
76
+ "react-dom": "^18.3.1",
77
+ "styled-components": "^6.6.0",
78
+ "typescript": "^5.5",
79
+ "typescript-eslint": "^8.73.0",
80
+ "vite": "^6.4.5",
81
+ "vitest": "^5.0.3"
82
+ },
38
83
  "publishConfig": {
39
84
  "access": "public"
40
85
  },
@@ -42,8 +87,6 @@
42
87
  "eslint",
43
88
  "eslint-rule",
44
89
  "architecture",
45
- "vertical-slice",
46
- "fhir",
47
90
  "typescript"
48
91
  ]
49
92
  }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ // The ids shared by the report and the picture.
4
+ // a relation the architecture forbids
5
+ // the code is in the wrong place (move, or split between places)
6
+ // nothing declares this kind of code here
7
+ // the finding judges the file's own contents
8
+ const __exported_WRONG_ACTION = "wrongAction";
9
+ const __exported_WRONG_PLACEMENT = "wrongPlacement";
10
+ const __exported_UNKNOWN_ROLE = "unknownRole";
11
+ const __exported_FILE_CONTENTS = "fileContents";
12
+ export { __exported_WRONG_ACTION as WRONG_ACTION, __exported_WRONG_PLACEMENT as WRONG_PLACEMENT, __exported_UNKNOWN_ROLE as UNKNOWN_ROLE, __exported_FILE_CONTENTS as FILE_CONTENTS };
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+
3
+ // Facts → words: a relation fact becomes a phrase, a subject and a reason.
4
+ // The fact is the engine's own (`entities/kinds` producers); the words here are
5
+ // the ONE spelling the text and the picture read. Every field is read through
6
+ // the shared field readers — a fact is plain data, never an `any`.
7
+
8
+ import { RELATION } from "../../../entities/kinds";
9
+ import { fieldOf, isObj, type FieldValue } from "../../../utils/field";
10
+ import { stringField, stringListField, recordField, recordListField, booleanField } from "../../../utils/read-field";
11
+ import { article } from "../../../utils/article";
12
+
13
+ const q = (s: FieldValue): string => (s == null ? "—" : `\`${s}\``);
14
+ const list = (xs: readonly FieldValue[]): string => xs.map(q).join(", ");
15
+
16
+ // A sentence about SEVERAL pieces takes the plural: "`a`, `b` change …".
17
+ const PLURALS: Record<string, string> = {
18
+ "changes ": "change ",
19
+ "writes into ": "write into ",
20
+ "calls ": "call ",
21
+ "imports ": "import ",
22
+ "exports ": "export ",
23
+ "re-exports ": "re-export ",
24
+ "re-declares ": "re-declare ",
25
+ "names a type of ": "name a type of ",
26
+ "reads ": "read ",
27
+ "is exported": "are exported",
28
+ "is declared here": "are declared here",
29
+ };
30
+
31
+ const pluralize = (text: string): string => {
32
+ for (const [one, many] of Object.entries(PLURALS)) {
33
+ if (text.startsWith(one)) return many + text.slice(one.length);
34
+ }
35
+ return text;
36
+ };
37
+
38
+ // The export forms that read as a re-export of a whole module / a default.
39
+ const exportFormText = (fact: FieldValue): string | null => {
40
+ const form = stringField(fact, "form");
41
+ if (form === "namespace") return `re-exports ${q(fieldOf(fact, "source"))} as ${q(stringListField(fact, "names")[0] ?? fieldOf(fact, "name"))}`;
42
+ if (form === "star") return `re-exports ${q(fieldOf(fact, "source"))}`;
43
+ if (form === "default") return "is exported as its default";
44
+ if (form === "equals") return "is exported with `export =`";
45
+ if (form === "declared") return "is exported";
46
+ return null;
47
+ };
48
+
49
+ const exportText = (fact: FieldValue): string => {
50
+ const form = exportFormText(fact);
51
+ if (form) return form;
52
+ const names = stringListField(fact, "names");
53
+ if (booleanField(fact, "reExport")) {
54
+ const from = fieldOf(fact, "resolved") ?? fieldOf(fact, "source");
55
+ const what = names.length ? `re-exports ${list(names)}` : "re-exports its whole module";
56
+ return from ? `${what} from ${q(from)}` : what;
57
+ }
58
+ if (names.length) return `exports ${list(names)}`;
59
+ const name = fieldOf(fact, "name");
60
+ if (name) return `exports ${q(name)} through CommonJS`;
61
+ return "is exported through CommonJS";
62
+ };
63
+
64
+ // WHAT a call was given: the values that made it illegal. A built `.d.ts` names
65
+ // a shape, not a value with an owner, so it is left out.
66
+ const callGiven = (fact: FieldValue): string => {
67
+ const given = recordListField(fact, "with")
68
+ .filter((w) => {
69
+ const type = stringField(w, "type");
70
+ return Boolean(type) && !type.endsWith(".d.ts");
71
+ })
72
+ .map((w) => `${q(fieldOf(w, "text"))} of ${q(fieldOf(w, "type"))}`);
73
+ return given.length ? ` with ${given.join(", ")}` : "";
74
+ };
75
+
76
+ const callText = (fact: FieldValue): string =>
77
+ `calls ${q(fieldOf(fact, "action"))} of ${q(fieldOf(fact, "module"))}${callGiven(fact)}`;
78
+
79
+ const mutateText = (fact: FieldValue): string => {
80
+ if (booleanField(fact, "onThis")) return `changes ${q(fieldOf(fact, "target"))} of its own file`;
81
+ const ownerRole = fieldOf(fact, "ownerRole");
82
+ if (ownerRole) return `changes ${q(fieldOf(fact, "target"))} of the ${q(ownerRole)} (${q(fieldOf(fact, "module"))})`;
83
+ return `changes ${q(fieldOf(fact, "target"))} of ${q(fieldOf(fact, "module"))}`;
84
+ };
85
+
86
+ const declareText = (fact: FieldValue): string => {
87
+ const renames = recordField(fact, "renames");
88
+ if (renames) return `re-declares ${q(fieldOf(renames, "action"))} of ${q(fieldOf(renames, "module"))}`;
89
+ return "is declared here";
90
+ };
91
+
92
+ const importText = (fact: FieldValue): string =>
93
+ stringField(fact, "form") === "statement" ? `imports ${q(fieldOf(fact, "resolved"))}` : `requires ${q(fieldOf(fact, "source"))}`;
94
+
95
+ const assignText = (fact: FieldValue): string => {
96
+ const method = fieldOf(fact, "method");
97
+ return `writes into ${q(fieldOf(fact, "target"))}${method ? ` through ${q(`${method}()`)}` : ""}`;
98
+ };
99
+
100
+ const readText = (fact: FieldValue): string => {
101
+ const module = fieldOf(fact, "module");
102
+ return `reads ${q(fieldOf(fact, "what"))}${module ? ` of ${q(module)}` : ""}`;
103
+ };
104
+
105
+ const factText = (fact: FieldValue): string => {
106
+ if (!isObj(fact)) return "does something the architecture does not describe";
107
+ const kind = stringField(fact, "kind");
108
+ if (kind === RELATION.IMPORT) return importText(fact);
109
+ if (kind === RELATION.TYPE_IMPORT) return `names a type of ${q(fieldOf(fact, "resolved"))}`;
110
+ if (kind === RELATION.EXPORT) return exportText(fact);
111
+ if (kind === RELATION.DECLARE) return declareText(fact);
112
+ if (kind === RELATION.CALL) return callText(fact);
113
+ if (kind === RELATION.MUTATE) return mutateText(fact);
114
+ if (kind === RELATION.ASSIGN) return assignText(fact);
115
+ if (kind === RELATION.READ) return readText(fact);
116
+ return `does a \`${kind}\` the architecture does not describe`;
117
+ };
118
+
119
+ const rolesSuffix = (roles: string[]): string => {
120
+ if (!roles.length) return "";
121
+ return roles.length === 1 ? ` (${roles[0]})` : ` (${roles.join(" / ")})`;
122
+ };
123
+
124
+ const subjectText = (subject: FieldValue, file: string): string => {
125
+ const roleNames = stringListField(subject, "roles").filter(Boolean);
126
+ const roles = roleNames.map(q);
127
+ const rolesPart = rolesSuffix(roles);
128
+ if (!isObj(subject) || booleanField(subject, "scope")) {
129
+ return `the module scope of ${q(file)}${rolesPart}`;
130
+ }
131
+ const pieces = stringListField(subject, "pieces").filter(Boolean).map(q);
132
+ if (!pieces.length) return `the module scope of ${q(file)}${rolesPart}`;
133
+ const who = roleNames.length === 1 ? ` (${article(roleNames[0])} ${q(roleNames[0])})` : rolesPart;
134
+ return `${pieces.join(", ")}${who || " (which no role describes)"}`;
135
+ };
136
+
137
+ // WHY it is refused — a code from the engine, not a sentence.
138
+ const whyText = (why: FieldValue): string => {
139
+ if (!isObj(why)) return "it is not allowed";
140
+ if (stringField(why, "code") === "silent") return "nothing in the architecture allows it";
141
+ const same = new Set(stringListField(why, "sameRoles"));
142
+ // A role the rule limits to the SAME feature instance says so: without the
143
+ // limit the sentence reads as "this role may not do it at all", which is the
144
+ // opposite of what the architecture declares.
145
+ const roles = stringListField(why, "roles").filter(Boolean).map((r) => (same.has(r) ? `${q(r)} in the same feature` : q(r)));
146
+ // The role DOES allow the call — what it refuses is the value handed over.
147
+ if (booleanField(why, "outward")) return "that value may not be handed to it";
148
+ if (!roles.length) return stringField(why, "code") === "nobody" ? "no code may do it" : "it is not allowed";
149
+ if (booleanField(why, "self")) return `only ${roles.join(", ")} may do it`;
150
+ return `only ${roles.join(", ")} may do it with ${q(fieldOf(why, "targetNode"))} code`;
151
+ };
152
+
153
+ // The one sentence a refused relation gets.
154
+ const relationMessage = (token: FieldValue, ctx: { file?: string } = {}): string => {
155
+ const subject = fieldOf(token, "subject");
156
+ const what = factText(fieldOf(token, "fact"));
157
+ const plural = isObj(subject) && booleanField(subject, "plural");
158
+ return `${subjectText(subject, ctx.file ?? "")} ${plural ? pluralize(what) : what}, but ${whyText(fieldOf(token, "why"))}`;
159
+ };
160
+
161
+ export { factText, subjectText, whyText, relationMessage, pluralize, article };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ // Engine names → report names: role → box, place → node.
4
+
5
+ // ONE source for every place question. `homeFor`, `nodeAtPath`, `homeTemplates`
6
+ // and `pathOf` used to be spelled again here, in a second wording, next to the
7
+ // real ones in `entities/location.js` — the report and the engine then disagreed
8
+ // about where a role lives. This file only NAMES things now.
9
+ import { homesOf, rolesAtPath as rolesDeclaredAt, homeForRole, boxOfPlace } from "../../../entities/location";
10
+ import type { Arch } from "../../../entities/architecture";
11
+ import type { NodeSummary } from "../../../entities/overview/summaries";
12
+ import type { Places } from "../../../entities/overview/decision";
13
+
14
+ const make = ({ nodes, arch }: { nodes: NodeSummary[]; arch: Arch }): Places => {
15
+ const folderOf = (slug: string | null | undefined): string | null => {
16
+ if (!slug) return null;
17
+ if (nodes.some((n) => n.slug === slug)) return slug;
18
+ return homesOf(arch, slug)[0]?.node ?? null;
19
+ };
20
+
21
+ // A node slug as the path a human recognises.
22
+ const pathOf = (slug: string): string => nodes.find((n) => n.slug === slug)?.paths?.[0] ?? slug;
23
+
24
+ // EVERY role that declares a place — the candidate set a destination decision
25
+ // may choose from ("какие есть").
26
+ const roles = (): string[] => Object.keys(arch.nodes.roleHomes);
27
+
28
+ // Roles whose declared home covers this path, most specific first: what this
29
+ // file already IS, according to the tree.
30
+ const rolesAtPath = (rel: string): string[] => rolesDeclaredAt(arch, rel);
31
+
32
+ // The path templates a role declares (`…/constants.ts`, `…/actions/**`).
33
+ const homeTemplates = (role: string): string[] => homesOf(arch, role).map((h) => h.template);
34
+
35
+ // Where this role's code belongs FOR THIS FILE, and the box that hosts it —
36
+ // the engine's own answer, never a folder invented here.
37
+ const homeFor = (role: string, rel: string) => homeForRole(arch, role, rel);
38
+
39
+ // The box that HOLDS a path — `apps/backend/document/store.ts` → the node that
40
+ // owns `apps/backend/document`.
41
+ const nodeAtPath = (path: string | null | undefined): string | null => boxOfPlace(arch, path);
42
+
43
+ return { folderOf, pathOf, roles, rolesAtPath, homeTemplates, homeFor, nodeAtPath };
44
+ };
45
+
46
+ export { make };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ // The words a relation is said with — third person, noun, and base form — as
4
+ // ONE table keyed by relation, so the three views below can never drift apart.
5
+ // A new relation is added once, here. The columns are DERIVED from the table,
6
+ // so a column and the table can never disagree.
7
+ const WORD = {
8
+ import: { verb: "imports", noun: "import", base: "import" },
9
+ typeImport: { verb: "names a type of", noun: "type import", base: "name a type of" },
10
+ export: { verb: "exports", noun: "export", base: "export" },
11
+ declare: { verb: "declares a name from", noun: "declaration", base: "declare a name from" },
12
+ call: { verb: "calls", noun: "call", base: "call" },
13
+ mutate: { verb: "changes", noun: "mutation", base: "change" },
14
+ assign: { verb: "writes into", noun: "assignment", base: "write into" },
15
+ read: { verb: "reads", noun: "read", base: "read" },
16
+ };
17
+
18
+ type WordField = keyof (typeof WORD)["import"];
19
+
20
+ const column = (field: WordField): Record<string, string> =>
21
+ Object.fromEntries(Object.entries(WORD).map(([kind, words]) => [kind, words[field]]));
22
+
23
+ const VERBS = column("verb");
24
+ const NOUNS = column("noun");
25
+ const BASES = column("base");
26
+
27
+ const verbOf = (kind: string): string => VERBS[kind] ?? `uses (${kind})`;
28
+ const nounOf = (kind: string): string => NOUNS[kind] ?? `use (${kind})`;
29
+ const baseVerbOf = (kind: string): string => BASES[kind] ?? `use (${kind})`;
30
+
31
+ export { VERBS, NOUNS, BASES, verbOf, nounOf, baseVerbOf };