@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,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.article = exports.pluralize = exports.relationMessage = exports.whyText = exports.subjectText = exports.factText = void 0;
4
+ // Facts → words: a relation fact becomes a phrase, a subject and a reason.
5
+ // The fact is the engine's own (`entities/kinds` producers); the words here are
6
+ // the ONE spelling the text and the picture read. Every field is read through
7
+ // the shared field readers — a fact is plain data, never an `any`.
8
+ const kinds_1 = require("../../../entities/kinds");
9
+ const field_1 = require("../../../utils/field");
10
+ const read_field_1 = require("../../../utils/read-field");
11
+ const article_1 = require("../../../utils/article");
12
+ Object.defineProperty(exports, "article", { enumerable: true, get: function () { return article_1.article; } });
13
+ const q = (s) => (s == null ? "—" : `\`${s}\``);
14
+ const list = (xs) => xs.map(q).join(", ");
15
+ // A sentence about SEVERAL pieces takes the plural: "`a`, `b` change …".
16
+ const PLURALS = {
17
+ "changes ": "change ",
18
+ "writes into ": "write into ",
19
+ "calls ": "call ",
20
+ "imports ": "import ",
21
+ "exports ": "export ",
22
+ "re-exports ": "re-export ",
23
+ "re-declares ": "re-declare ",
24
+ "names a type of ": "name a type of ",
25
+ "reads ": "read ",
26
+ "is exported": "are exported",
27
+ "is declared here": "are declared here",
28
+ };
29
+ const pluralize = (text) => {
30
+ for (const [one, many] of Object.entries(PLURALS)) {
31
+ if (text.startsWith(one))
32
+ return many + text.slice(one.length);
33
+ }
34
+ return text;
35
+ };
36
+ exports.pluralize = pluralize;
37
+ // The export forms that read as a re-export of a whole module / a default.
38
+ const exportFormText = (fact) => {
39
+ const form = (0, read_field_1.stringField)(fact, "form");
40
+ if (form === "namespace")
41
+ return `re-exports ${q((0, field_1.fieldOf)(fact, "source"))} as ${q((0, read_field_1.stringListField)(fact, "names")[0] ?? (0, field_1.fieldOf)(fact, "name"))}`;
42
+ if (form === "star")
43
+ return `re-exports ${q((0, field_1.fieldOf)(fact, "source"))}`;
44
+ if (form === "default")
45
+ return "is exported as its default";
46
+ if (form === "equals")
47
+ return "is exported with `export =`";
48
+ if (form === "declared")
49
+ return "is exported";
50
+ return null;
51
+ };
52
+ const exportText = (fact) => {
53
+ const form = exportFormText(fact);
54
+ if (form)
55
+ return form;
56
+ const names = (0, read_field_1.stringListField)(fact, "names");
57
+ if ((0, read_field_1.booleanField)(fact, "reExport")) {
58
+ const from = (0, field_1.fieldOf)(fact, "resolved") ?? (0, field_1.fieldOf)(fact, "source");
59
+ const what = names.length ? `re-exports ${list(names)}` : "re-exports its whole module";
60
+ return from ? `${what} from ${q(from)}` : what;
61
+ }
62
+ if (names.length)
63
+ return `exports ${list(names)}`;
64
+ const name = (0, field_1.fieldOf)(fact, "name");
65
+ if (name)
66
+ return `exports ${q(name)} through CommonJS`;
67
+ return "is exported through CommonJS";
68
+ };
69
+ // WHAT a call was given: the values that made it illegal. A built `.d.ts` names
70
+ // a shape, not a value with an owner, so it is left out.
71
+ const callGiven = (fact) => {
72
+ const given = (0, read_field_1.recordListField)(fact, "with")
73
+ .filter((w) => {
74
+ const type = (0, read_field_1.stringField)(w, "type");
75
+ return Boolean(type) && !type.endsWith(".d.ts");
76
+ })
77
+ .map((w) => `${q((0, field_1.fieldOf)(w, "text"))} of ${q((0, field_1.fieldOf)(w, "type"))}`);
78
+ return given.length ? ` with ${given.join(", ")}` : "";
79
+ };
80
+ const callText = (fact) => `calls ${q((0, field_1.fieldOf)(fact, "action"))} of ${q((0, field_1.fieldOf)(fact, "module"))}${callGiven(fact)}`;
81
+ const mutateText = (fact) => {
82
+ if ((0, read_field_1.booleanField)(fact, "onThis"))
83
+ return `changes ${q((0, field_1.fieldOf)(fact, "target"))} of its own file`;
84
+ const ownerRole = (0, field_1.fieldOf)(fact, "ownerRole");
85
+ if (ownerRole)
86
+ return `changes ${q((0, field_1.fieldOf)(fact, "target"))} of the ${q(ownerRole)} (${q((0, field_1.fieldOf)(fact, "module"))})`;
87
+ return `changes ${q((0, field_1.fieldOf)(fact, "target"))} of ${q((0, field_1.fieldOf)(fact, "module"))}`;
88
+ };
89
+ const declareText = (fact) => {
90
+ const renames = (0, read_field_1.recordField)(fact, "renames");
91
+ if (renames)
92
+ return `re-declares ${q((0, field_1.fieldOf)(renames, "action"))} of ${q((0, field_1.fieldOf)(renames, "module"))}`;
93
+ return "is declared here";
94
+ };
95
+ const importText = (fact) => (0, read_field_1.stringField)(fact, "form") === "statement" ? `imports ${q((0, field_1.fieldOf)(fact, "resolved"))}` : `requires ${q((0, field_1.fieldOf)(fact, "source"))}`;
96
+ const assignText = (fact) => {
97
+ const method = (0, field_1.fieldOf)(fact, "method");
98
+ return `writes into ${q((0, field_1.fieldOf)(fact, "target"))}${method ? ` through ${q(`${method}()`)}` : ""}`;
99
+ };
100
+ const readText = (fact) => {
101
+ const module = (0, field_1.fieldOf)(fact, "module");
102
+ return `reads ${q((0, field_1.fieldOf)(fact, "what"))}${module ? ` of ${q(module)}` : ""}`;
103
+ };
104
+ const factText = (fact) => {
105
+ if (!(0, field_1.isObj)(fact))
106
+ return "does something the architecture does not describe";
107
+ const kind = (0, read_field_1.stringField)(fact, "kind");
108
+ if (kind === kinds_1.RELATION.IMPORT)
109
+ return importText(fact);
110
+ if (kind === kinds_1.RELATION.TYPE_IMPORT)
111
+ return `names a type of ${q((0, field_1.fieldOf)(fact, "resolved"))}`;
112
+ if (kind === kinds_1.RELATION.EXPORT)
113
+ return exportText(fact);
114
+ if (kind === kinds_1.RELATION.DECLARE)
115
+ return declareText(fact);
116
+ if (kind === kinds_1.RELATION.CALL)
117
+ return callText(fact);
118
+ if (kind === kinds_1.RELATION.MUTATE)
119
+ return mutateText(fact);
120
+ if (kind === kinds_1.RELATION.ASSIGN)
121
+ return assignText(fact);
122
+ if (kind === kinds_1.RELATION.READ)
123
+ return readText(fact);
124
+ return `does a \`${kind}\` the architecture does not describe`;
125
+ };
126
+ exports.factText = factText;
127
+ const rolesSuffix = (roles) => {
128
+ if (!roles.length)
129
+ return "";
130
+ return roles.length === 1 ? ` (${roles[0]})` : ` (${roles.join(" / ")})`;
131
+ };
132
+ const subjectText = (subject, file) => {
133
+ const roleNames = (0, read_field_1.stringListField)(subject, "roles").filter(Boolean);
134
+ const roles = roleNames.map(q);
135
+ const rolesPart = rolesSuffix(roles);
136
+ if (!(0, field_1.isObj)(subject) || (0, read_field_1.booleanField)(subject, "scope")) {
137
+ return `the module scope of ${q(file)}${rolesPart}`;
138
+ }
139
+ const pieces = (0, read_field_1.stringListField)(subject, "pieces").filter(Boolean).map(q);
140
+ if (!pieces.length)
141
+ return `the module scope of ${q(file)}${rolesPart}`;
142
+ const who = roleNames.length === 1 ? ` (${(0, article_1.article)(roleNames[0])} ${q(roleNames[0])})` : rolesPart;
143
+ return `${pieces.join(", ")}${who || " (which no role describes)"}`;
144
+ };
145
+ exports.subjectText = subjectText;
146
+ // WHY it is refused — a code from the engine, not a sentence.
147
+ const whyText = (why) => {
148
+ if (!(0, field_1.isObj)(why))
149
+ return "it is not allowed";
150
+ if ((0, read_field_1.stringField)(why, "code") === "silent")
151
+ return "nothing in the architecture allows it";
152
+ const same = new Set((0, read_field_1.stringListField)(why, "sameRoles"));
153
+ // A role the rule limits to the SAME feature instance says so: without the
154
+ // limit the sentence reads as "this role may not do it at all", which is the
155
+ // opposite of what the architecture declares.
156
+ const roles = (0, read_field_1.stringListField)(why, "roles").filter(Boolean).map((r) => (same.has(r) ? `${q(r)} in the same feature` : q(r)));
157
+ // The role DOES allow the call — what it refuses is the value handed over.
158
+ if ((0, read_field_1.booleanField)(why, "outward"))
159
+ return "that value may not be handed to it";
160
+ if (!roles.length)
161
+ return (0, read_field_1.stringField)(why, "code") === "nobody" ? "no code may do it" : "it is not allowed";
162
+ if ((0, read_field_1.booleanField)(why, "self"))
163
+ return `only ${roles.join(", ")} may do it`;
164
+ return `only ${roles.join(", ")} may do it with ${q((0, field_1.fieldOf)(why, "targetNode"))} code`;
165
+ };
166
+ exports.whyText = whyText;
167
+ // The one sentence a refused relation gets.
168
+ const relationMessage = (token, ctx = {}) => {
169
+ const subject = (0, field_1.fieldOf)(token, "subject");
170
+ const what = factText((0, field_1.fieldOf)(token, "fact"));
171
+ const plural = (0, field_1.isObj)(subject) && (0, read_field_1.booleanField)(subject, "plural");
172
+ return `${subjectText(subject, ctx.file ?? "")} ${plural ? pluralize(what) : what}, but ${whyText((0, field_1.fieldOf)(token, "why"))}`;
173
+ };
174
+ exports.relationMessage = relationMessage;
@@ -0,0 +1,8 @@
1
+ import type { Arch } from "../../../entities/architecture";
2
+ import type { NodeSummary } from "../../../entities/overview/summaries";
3
+ import type { Places } from "../../../entities/overview/decision";
4
+ declare const make: ({ nodes, arch }: {
5
+ nodes: NodeSummary[];
6
+ arch: Arch;
7
+ }) => Places;
8
+ export { make };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.make = void 0;
4
+ // Engine names → report names: role → box, place → node.
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
+ const location_1 = require("../../../entities/location");
10
+ const make = ({ nodes, arch }) => {
11
+ const folderOf = (slug) => {
12
+ if (!slug)
13
+ return null;
14
+ if (nodes.some((n) => n.slug === slug))
15
+ return slug;
16
+ return (0, location_1.homesOf)(arch, slug)[0]?.node ?? null;
17
+ };
18
+ // A node slug as the path a human recognises.
19
+ const pathOf = (slug) => nodes.find((n) => n.slug === slug)?.paths?.[0] ?? slug;
20
+ // EVERY role that declares a place — the candidate set a destination decision
21
+ // may choose from ("какие есть").
22
+ const roles = () => Object.keys(arch.nodes.roleHomes);
23
+ // Roles whose declared home covers this path, most specific first: what this
24
+ // file already IS, according to the tree.
25
+ const rolesAtPath = (rel) => (0, location_1.rolesAtPath)(arch, rel);
26
+ // The path templates a role declares (`…/constants.ts`, `…/actions/**`).
27
+ const homeTemplates = (role) => (0, location_1.homesOf)(arch, role).map((h) => h.template);
28
+ // Where this role's code belongs FOR THIS FILE, and the box that hosts it —
29
+ // the engine's own answer, never a folder invented here.
30
+ const homeFor = (role, rel) => (0, location_1.homeForRole)(arch, role, rel);
31
+ // The box that HOLDS a path — `apps/backend/document/store.ts` → the node that
32
+ // owns `apps/backend/document`.
33
+ const nodeAtPath = (path) => (0, location_1.boxOfPlace)(arch, path);
34
+ return { folderOf, pathOf, roles, rolesAtPath, homeTemplates, homeFor, nodeAtPath };
35
+ };
36
+ exports.make = make;
@@ -0,0 +1,7 @@
1
+ declare const VERBS: Record<string, string>;
2
+ declare const NOUNS: Record<string, string>;
3
+ declare const BASES: Record<string, string>;
4
+ declare const verbOf: (kind: string) => string;
5
+ declare const nounOf: (kind: string) => string;
6
+ declare const baseVerbOf: (kind: string) => string;
7
+ export { VERBS, NOUNS, BASES, verbOf, nounOf, baseVerbOf };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.baseVerbOf = exports.nounOf = exports.verbOf = exports.BASES = exports.NOUNS = exports.VERBS = void 0;
4
+ // The words a relation is said with — third person, noun, and base form — as
5
+ // ONE table keyed by relation, so the three views below can never drift apart.
6
+ // A new relation is added once, here. The columns are DERIVED from the table,
7
+ // so a column and the table can never disagree.
8
+ const WORD = {
9
+ import: { verb: "imports", noun: "import", base: "import" },
10
+ typeImport: { verb: "names a type of", noun: "type import", base: "name a type of" },
11
+ export: { verb: "exports", noun: "export", base: "export" },
12
+ declare: { verb: "declares a name from", noun: "declaration", base: "declare a name from" },
13
+ call: { verb: "calls", noun: "call", base: "call" },
14
+ mutate: { verb: "changes", noun: "mutation", base: "change" },
15
+ assign: { verb: "writes into", noun: "assignment", base: "write into" },
16
+ read: { verb: "reads", noun: "read", base: "read" },
17
+ };
18
+ const column = (field) => Object.fromEntries(Object.entries(WORD).map(([kind, words]) => [kind, words[field]]));
19
+ const VERBS = column("verb");
20
+ exports.VERBS = VERBS;
21
+ const NOUNS = column("noun");
22
+ exports.NOUNS = NOUNS;
23
+ const BASES = column("base");
24
+ exports.BASES = BASES;
25
+ const verbOf = (kind) => VERBS[kind] ?? `uses (${kind})`;
26
+ exports.verbOf = verbOf;
27
+ const nounOf = (kind) => NOUNS[kind] ?? `use (${kind})`;
28
+ exports.nounOf = nounOf;
29
+ const baseVerbOf = (kind) => BASES[kind] ?? `use (${kind})`;
30
+ exports.baseVerbOf = baseVerbOf;
@@ -0,0 +1,9 @@
1
+ import { substitute, type TemplateVars } from "../utils/template";
2
+ import type { FindingFrom } from "../entities/findings";
3
+ import type { ReportObject } from "../entities/architecture";
4
+ declare const renderSpec: (spec: ReportObject | string, vars: TemplateVars) => {
5
+ message: string | null;
6
+ fix: string | null;
7
+ };
8
+ declare const findingFrom: FindingFrom;
9
+ export { findingFrom, renderSpec, substitute };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.substitute = exports.renderSpec = exports.findingFrom = void 0;
4
+ // ONE finding, built from what a checker states. A producer states the repair
5
+ // structurally (`to` boxes, `path`, `ask`) and `findingFrom` carries it as
6
+ // `data.repair` — the SAME object the CLI prints and the picture draws. A
7
+ // producer that only wrote a sentence still ends up with a repair (`rules` with
8
+ // no destination), so downstream never has to guess what a sentence meant.
9
+ //
10
+ // The report spec is the engine's own (`ReportObject`); the substitution is the
11
+ // shared template walk; the repair shape is the ONE contract in entities/repair.
12
+ const asks_1 = require("./asks");
13
+ const template_1 = require("../utils/template");
14
+ Object.defineProperty(exports, "substitute", { enumerable: true, get: function () { return template_1.substitute; } });
15
+ const field_1 = require("../utils/field");
16
+ const read_field_1 = require("../utils/read-field");
17
+ const resolve_1 = require("../utils/resolve");
18
+ // The fix text a spec states: a bare string, or the structured `{ message }`.
19
+ const fixTextOf = (spec) => {
20
+ const fix = spec.fix;
21
+ if (typeof fix === "string")
22
+ return fix;
23
+ return (0, field_1.isObj)(fix) ? (0, read_field_1.stringField)(fix, "message") || null : null;
24
+ };
25
+ const renderSpec = (spec, vars) => {
26
+ if (typeof spec === "string")
27
+ return { message: (0, template_1.substitute)(spec, vars), fix: null };
28
+ const message = spec.description ?? spec.message ?? null;
29
+ const fixText = fixTextOf(spec);
30
+ return { message: message != null ? (0, template_1.substitute)(message, vars) : null, fix: fixText != null ? (0, template_1.substitute)(fixText, vars) : null };
31
+ };
32
+ exports.renderSpec = renderSpec;
33
+ // The spec a finding item carries: an explicit `report`, or the legacy flat
34
+ // `message`/`fix` spelling on the item itself.
35
+ const specOf = (item) => {
36
+ if (item.report != null)
37
+ return item.report;
38
+ const message = item.message ?? "";
39
+ const fix = item.fix ?? "";
40
+ // The legacy flat spelling carries the WHOLE item as the spec — its `ask`,
41
+ // `to`, `from`, `path` are the repair the producer stated, not only words.
42
+ if (message || fix)
43
+ return { ...item, message: message || null, fix: fix || null };
44
+ return null;
45
+ };
46
+ // The place a spec names: `place` (already resolved) or `path`, never parsed
47
+ // out of the sentence. A string spec names no place.
48
+ const placeOf = (spec) => (0, resolve_1.resolveReference)(spec, (s) => (typeof s === "string" ? null : s), (s) => s.place ?? s.path ?? null);
49
+ // The finding's identity and subject: what it is about, and which role.
50
+ const subjectOf = (item, key, vars) => ({
51
+ what: (0, read_field_1.stringField)(vars, "what") || null,
52
+ role: /^role:([^:]+)/.exec(key)?.[1] ?? item.role ?? null,
53
+ });
54
+ // The message and fix sentences a finding carries: the rendered spec's, or the
55
+ // run's own vars, or the fallback.
56
+ const scopeOf = (vars, place) => (place ? { ...vars, destination: place } : vars);
57
+ const sentencesOf = (item, vars) => {
58
+ const spec = specOf(item);
59
+ const place = placeOf(spec);
60
+ const rep = spec != null ? renderSpec(spec, scopeOf(vars, place)) : null;
61
+ return {
62
+ message: rep?.message ?? ((0, read_field_1.stringField)(vars, "message") || "architecture violation"),
63
+ fix: rep?.fix ?? ((0, read_field_1.stringField)(vars, "fix") || null),
64
+ place,
65
+ spec: spec != null && typeof spec !== "string" ? spec : null,
66
+ };
67
+ };
68
+ // The evidence bag with the stated repair attached — the SAME object the CLI
69
+ // prints and the picture draws.
70
+ const dataOf = (item, spec, fix, place) => {
71
+ const stated = spec != null ? (0, asks_1.repair)({ code: spec.code ?? spec.ask, fix }, { to: spec.to ?? [], from: spec.from ?? null, path: place }) : null;
72
+ const evidence = (0, field_1.isObj)(item.data) ? item.data : null;
73
+ return stated ? { ...(evidence ?? {}), repair: { ...stated, text: fix } } : evidence;
74
+ };
75
+ // The span a matched fact named (set by the report-vars walk), so the browser can
76
+ // highlight the exact offending text in the sentence. Absent when none was named.
77
+ const highlightOf = (vars) => {
78
+ const text = (0, read_field_1.stringField)(vars, "highlightText");
79
+ const start = (0, read_field_1.numberField)(vars, "spanStart", -1);
80
+ const end = (0, read_field_1.numberField)(vars, "spanEnd", -1);
81
+ if (!text || start < 0 || end < start)
82
+ return null;
83
+ return { text, start, end, kind: (0, read_field_1.stringField)(vars, "highlightKind") || "problem" };
84
+ };
85
+ const findingFrom = (...args) => {
86
+ const [item, rule, node, key, vars] = args;
87
+ const { message, fix, place, spec } = sentencesOf(item, vars);
88
+ const highlight = highlightOf(vars);
89
+ return {
90
+ file: (0, read_field_1.stringField)(vars, "path") || node,
91
+ node,
92
+ rule,
93
+ key: item.key ?? key,
94
+ dedupeKey: key,
95
+ data: dataOf(item, spec, fix, place),
96
+ ...subjectOf(item, key, vars),
97
+ message,
98
+ fix,
99
+ pos: { line: item.line ?? 1, column: 1 },
100
+ ...(highlight ? { highlight } : {}),
101
+ };
102
+ };
103
+ exports.findingFrom = findingFrom;
@@ -0,0 +1,4 @@
1
+ declare const notice: (subject: string, reason: string) => string;
2
+ declare const takeNotices: () => string[];
3
+ declare const resetNotices: () => void;
4
+ export { notice, takeNotices, resetNotices };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resetNotices = exports.takeNotices = exports.notice = void 0;
4
+ // A NOTICE is NOT a finding. No rule was broken: the tool could not READ
5
+ // something — a facet threw on a file, a stylesheet parser rejected a value, a
6
+ // config file did not load. It still belongs to the report, because a reader has
7
+ // to be told that an answer is PARTIAL, and a bare `console.warn` only ever
8
+ // reached a terminal nobody looks at twice.
9
+ //
10
+ // One sentence, one place: whoever notices the problem states the subject (what
11
+ // was being read) and the reason. Nothing here decides wording per caller.
12
+ const lines = [];
13
+ const seen = new Set();
14
+ const notice = (subject, reason) => {
15
+ const line = `${subject}: ${reason}`;
16
+ if (seen.has(line))
17
+ return line;
18
+ seen.add(line);
19
+ lines.push(line);
20
+ return line;
21
+ };
22
+ exports.notice = notice;
23
+ // The run hands its notices to the report and starts clean: a second run in the
24
+ // same process starts with an empty list.
25
+ const takeNotices = () => lines.splice(0, lines.length);
26
+ exports.takeNotices = takeNotices;
27
+ const resetNotices = () => {
28
+ lines.length = 0;
29
+ seen.clear();
30
+ };
31
+ exports.resetNotices = resetNotices;
@@ -0,0 +1,12 @@
1
+ import type { Finding } from "../entities/findings";
2
+ declare const renderReport: (findings: readonly Finding[], repoRoot: string, opts?: {
3
+ orphans?: readonly string[];
4
+ }) => string;
5
+ declare const renderNotices: (notices: readonly string[] | null | undefined) => string;
6
+ declare const renderConfigError: (error: {
7
+ message?: string;
8
+ } | null | undefined) => string;
9
+ declare const renderCrashError: (error: {
10
+ stack?: string;
11
+ } | null | undefined) => string;
12
+ export { renderReport, renderNotices, renderConfigError, renderCrashError };
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderCrashError = exports.renderConfigError = exports.renderNotices = exports.renderReport = void 0;
4
+ // The terminal / --out report: findings grouped by what they are ABOUT (the code
5
+ // role first, then the piece), each with its message and its repairs. Wording
6
+ // comes from report/errorTypes; the finding bag is the engine's own.
7
+ const errorTypes_1 = require("./errorTypes");
8
+ const field_1 = require("../utils/field");
9
+ const read_field_1 = require("../utils/read-field");
10
+ const group_1 = require("../utils/group");
11
+ // The token as the report reads it: a plain record is the token (every field is
12
+ // optional, so any record qualifies), anything else is none.
13
+ const isToken = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
14
+ const tokenOf = (value) => (isToken(value) ? value : null);
15
+ const textFinding = (f) => {
16
+ const violations = (0, read_field_1.recordListField)((0, field_1.fieldOf)(f, "data"), "violations");
17
+ const withToken = violations.find((v) => (0, field_1.isObj)((0, field_1.fieldOf)(v, "token"))) ?? null;
18
+ return {
19
+ file: (0, read_field_1.stringField)(f, "file"),
20
+ message: (0, read_field_1.stringField)(f, "message"),
21
+ fix: (0, read_field_1.stringField)(f, "fix") || null,
22
+ what: (0, read_field_1.stringField)(f, "what") || null,
23
+ role: (0, read_field_1.stringField)(f, "role") || null,
24
+ node: (0, read_field_1.stringField)(f, "node") || null,
25
+ rule: (0, read_field_1.stringField)(f, "rule"),
26
+ line: (0, read_field_1.numberField)((0, field_1.fieldOf)(f, "pos"), "line", 1),
27
+ token: withToken ? tokenOf((0, field_1.fieldOf)(withToken, "token")) : null,
28
+ singularToken: tokenOf((0, field_1.fieldOf)(f, "data.violation.token")),
29
+ targetPath: withToken ? (0, read_field_1.stringField)(withToken, "targetPath") || null : null,
30
+ };
31
+ };
32
+ // The message and repairs one finding prints: the token's own words when the
33
+ // engine sent a verdict, else the finding's message and fix.
34
+ const renderFinding = (f) => {
35
+ const rendered = (0, errorTypes_1.renderToken)(f.token, { file: f.file, targetPath: f.targetPath });
36
+ if (!rendered)
37
+ return { message: f.message, fixes: f.fix ? [{ text: f.fix }] : [] };
38
+ return { message: rendered.message, fixes: rendered.fixes };
39
+ };
40
+ // The group a finding belongs to: its role, else its node, else "unroled".
41
+ // The token fallback reads `data.violation` (the SINGULAR bag a structure
42
+ // verdict carries) — a relation finding's `data.violations` list is the
43
+ // picture's evidence, not a grouping claim: its subject roles name the FILE's
44
+ // roles, and grouping by them moved module-scope relations out of their node.
45
+ const groupKeyOf = (f) => {
46
+ const role = f.role ?? (0, read_field_1.stringListField)((0, field_1.fieldOf)(f.singularToken, "subject"), "roles")[0] ?? null;
47
+ if (role)
48
+ return `role:${role}`;
49
+ return f.node ? `node:${f.node}` : "unroled";
50
+ };
51
+ const groupOrder = (k) => {
52
+ if (k === "unroled")
53
+ return 3;
54
+ return k.startsWith("role:") ? 0 : 1;
55
+ };
56
+ const groupHeading = (k) => {
57
+ if (k.startsWith("role:"))
58
+ return `\`${k.slice(5)}\` code`;
59
+ return k.startsWith("node:") ? `node \`${k.slice(5)}\`` : "not code a role describes";
60
+ };
61
+ // Within a role: by piece, then by place. One piece may have several findings.
62
+ const rankOf = (f) => {
63
+ if (f.rule === "invariant")
64
+ return 0;
65
+ return f.rule === "codeRoles" ? 1 : 2;
66
+ };
67
+ const byPiece = (a, b) => String(a.what ?? "").localeCompare(String(b.what ?? "")) || a.file.localeCompare(b.file) || rankOf(a) - rankOf(b) || a.line - b.line;
68
+ const findingLines = (f) => {
69
+ const shown = renderFinding(f);
70
+ const lines = ["", `#### ${f.what ? `\`${f.what}\`` : `\`${f.file}\``} — \`${f.file}:${f.line}\``, "", shown.message];
71
+ if (shown.fixes.length) {
72
+ lines.push("", `**Fix** — ${shown.fixes.length} option${shown.fixes.length === 1 ? "" : "s"}:`, "");
73
+ for (const option of shown.fixes)
74
+ lines.push(`- ${option.text}`);
75
+ }
76
+ lines.push("", "---");
77
+ return lines;
78
+ };
79
+ const groupLines = (key, list) => {
80
+ const lines = ["", `### ${groupHeading(key)}`];
81
+ for (const f of [...list].sort(byPiece))
82
+ lines.push(...findingLines(f));
83
+ return lines;
84
+ };
85
+ const orphanLines = (orphans) => {
86
+ if (!orphans.length)
87
+ return [];
88
+ const lines = ["## Orphan files", "", "Files the architecture says nothing about (no node prefix, no invariant `where`):"];
89
+ for (const o of orphans)
90
+ lines.push(`- \`${o}\``);
91
+ lines.push("");
92
+ return lines;
93
+ };
94
+ const invariantLines = (findings) => {
95
+ const invariants = findings.filter((f) => f.rule === "invariant");
96
+ if (!invariants.length)
97
+ return [];
98
+ const lines = ["## Invariants", ""];
99
+ for (const f of [...invariants].sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line)) {
100
+ lines.push(`- \`${f.file}\` (line ${f.line}) — ${f.message}`);
101
+ if (f.fix)
102
+ lines.push(` fix: ${f.fix}`);
103
+ }
104
+ lines.push("");
105
+ return lines;
106
+ };
107
+ const renderReport = (findings, repoRoot, opts = {}) => {
108
+ const text = findings.map(textFinding);
109
+ const lines = ["# follow-architecture report", "", `Generated against \`${repoRoot}\`.`, ""];
110
+ lines.push(...orphanLines(opts.orphans ?? []));
111
+ lines.push(...invariantLines(text));
112
+ lines.push("## Findings");
113
+ // GROUPED BY WHAT THE FINDING IS ABOUT — the code role first, then the piece.
114
+ const groups = (0, group_1.groupBy)(text, groupKeyOf).sort((a, b) => groupOrder(a[0]) - groupOrder(b[0]) || a[0].localeCompare(b[0]));
115
+ for (const [key, list] of groups)
116
+ lines.push(...groupLines(key, list));
117
+ lines.push("");
118
+ return lines.join("\n");
119
+ };
120
+ exports.renderReport = renderReport;
121
+ // The notices a run collected: what the tool could NOT read, so the reader knows
122
+ // an answer is partial. They print AFTER the findings.
123
+ const renderNotices = (notices) => {
124
+ if (!notices?.length)
125
+ return "";
126
+ const lines = ["", `## Not read (${notices.length})`, ""];
127
+ for (const line of notices)
128
+ lines.push(`- ${line}`);
129
+ lines.push("");
130
+ return lines.join("\n");
131
+ };
132
+ exports.renderNotices = renderNotices;
133
+ // A config the engine cannot use is a SENTENCE for the reader — they fix it by
134
+ // editing a file — so the message is the whole output.
135
+ const renderConfigError = (error) => (error && error.message ? error.message : String(error));
136
+ exports.renderConfigError = renderConfigError;
137
+ // Anything else is the engine failing at its own job: it keeps its stack.
138
+ const renderCrashError = (error) => {
139
+ const detail = error && error.stack ? error.stack : String(error);
140
+ return `follow-architecture: the run failed for a reason that is not in the architecture\n${detail}`;
141
+ };
142
+ exports.renderCrashError = renderCrashError;
@@ -0,0 +1,3 @@
1
+ declare const readPrebuiltBundle: () => string | null;
2
+ declare const getBundle: () => string;
3
+ export { getBundle, readPrebuiltBundle };