@md-code/follow-architecture 0.1.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (487) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +202 -0
  3. package/README.md +1420 -139
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +18 -0
  7. package/dist/args.js +94 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/closure-project.d.ts +4 -0
  11. package/dist/closure-project.js +132 -0
  12. package/dist/code-entities/classify.d.ts +11 -0
  13. package/dist/code-entities/classify.js +45 -0
  14. package/dist/code-entities/connector.d.ts +8 -0
  15. package/dist/code-entities/connector.js +119 -0
  16. package/dist/code-entities/entities.d.ts +9 -0
  17. package/dist/code-entities/entities.js +227 -0
  18. package/dist/code-entities/project.d.ts +21 -0
  19. package/dist/code-entities/project.js +259 -0
  20. package/dist/code-entities/walk.d.ts +31 -0
  21. package/dist/code-entities/walk.js +105 -0
  22. package/dist/config-options.d.ts +76 -0
  23. package/dist/config-options.js +52 -0
  24. package/dist/config-project.d.ts +4 -0
  25. package/dist/config-project.js +92 -0
  26. package/dist/config-report.d.ts +19 -0
  27. package/dist/config-report.js +161 -0
  28. package/dist/config-rule.d.ts +95 -0
  29. package/dist/config-rule.js +211 -0
  30. package/dist/config-state.d.ts +25 -0
  31. package/dist/config-state.js +269 -0
  32. package/dist/config.d.ts +107 -0
  33. package/dist/config.js +38 -0
  34. package/dist/css/index.d.ts +31 -0
  35. package/dist/css/index.js +251 -0
  36. package/dist/css/syntax/css/gate.d.ts +2 -0
  37. package/dist/css/syntax/css/gate.js +69 -0
  38. package/dist/css/syntax/css/index.d.ts +7 -0
  39. package/dist/css/syntax/css/index.js +51 -0
  40. package/dist/css/syntax/css/reference.d.ts +3 -0
  41. package/dist/css/syntax/css/reference.js +36 -0
  42. package/dist/css/syntax/language.d.ts +25 -0
  43. package/dist/css/syntax/language.js +81 -0
  44. package/dist/css/syntax/scss/index.d.ts +25 -0
  45. package/dist/css/syntax/scss/index.js +95 -0
  46. package/dist/css/syntax/scss/reference.d.ts +3 -0
  47. package/dist/css/syntax/scss/reference.js +17 -0
  48. package/dist/css/syntax/styled/document.d.ts +68 -0
  49. package/dist/css/syntax/styled/document.js +261 -0
  50. package/dist/css/syntax/styled/markup.d.ts +6 -0
  51. package/dist/css/syntax/styled/markup.js +84 -0
  52. package/dist/css/syntax/styled/tags.d.ts +2 -0
  53. package/dist/css/syntax/styled/tags.js +22 -0
  54. package/dist/css/syntax/styled/template.d.ts +23 -0
  55. package/dist/css/syntax/styled/template.js +67 -0
  56. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  57. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  58. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  59. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  60. package/dist/css/value/check.d.ts +86 -0
  61. package/dist/css/value/check.js +122 -0
  62. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  63. package/dist/css/value/expression/arithmetic.js +73 -0
  64. package/dist/css/value/expression/block.d.ts +9 -0
  65. package/dist/css/value/expression/block.js +92 -0
  66. package/dist/css/value/expression/conditional.d.ts +8 -0
  67. package/dist/css/value/expression/conditional.js +53 -0
  68. package/dist/css/value/expression/index.d.ts +5 -0
  69. package/dist/css/value/expression/index.js +73 -0
  70. package/dist/css/value/expression/map.d.ts +7 -0
  71. package/dist/css/value/expression/map.js +113 -0
  72. package/dist/css/value/object/index.d.ts +5 -0
  73. package/dist/css/value/object/index.js +113 -0
  74. package/dist/css/value/object/members.d.ts +7 -0
  75. package/dist/css/value/object/members.js +103 -0
  76. package/dist/css/value/object/node.d.ts +8 -0
  77. package/dist/css/value/object/node.js +134 -0
  78. package/dist/css/value/object/path.d.ts +10 -0
  79. package/dist/css/value/object/path.js +152 -0
  80. package/dist/css/value/pieces.d.ts +61 -0
  81. package/dist/css/value/pieces.js +65 -0
  82. package/dist/css/value/resolve.d.ts +33 -0
  83. package/dist/css/value/resolve.js +104 -0
  84. package/dist/css/value/scope.d.ts +28 -0
  85. package/dist/css/value/scope.js +205 -0
  86. package/dist/css/value/substitute.d.ts +10 -0
  87. package/dist/css/value/substitute.js +145 -0
  88. package/dist/css/value/values.d.ts +23 -0
  89. package/dist/css/value/values.js +131 -0
  90. package/dist/entities/architecture.d.ts +165 -0
  91. package/dist/entities/architecture.js +2 -0
  92. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  93. package/dist/entities/ast/assignments-nodes.js +64 -0
  94. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  95. package/dist/entities/ast/assignments-raw.js +139 -0
  96. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  97. package/dist/entities/ast/assignments-tagged.js +195 -0
  98. package/dist/entities/ast/assignments.d.ts +9 -0
  99. package/dist/entities/ast/assignments.js +80 -0
  100. package/dist/entities/ast/branches.d.ts +4 -0
  101. package/dist/entities/ast/branches.js +32 -0
  102. package/dist/entities/ast/calls.d.ts +6 -0
  103. package/dist/entities/ast/calls.js +150 -0
  104. package/dist/entities/ast/classes.d.ts +5 -0
  105. package/dist/entities/ast/classes.js +61 -0
  106. package/dist/entities/ast/climb.d.ts +12 -0
  107. package/dist/entities/ast/climb.js +17 -0
  108. package/dist/entities/ast/comments.d.ts +5 -0
  109. package/dist/entities/ast/comments.js +130 -0
  110. package/dist/entities/ast/declaration.d.ts +4 -0
  111. package/dist/entities/ast/declaration.js +26 -0
  112. package/dist/entities/ast/depth.d.ts +17 -0
  113. package/dist/entities/ast/depth.js +166 -0
  114. package/dist/entities/ast/enums.d.ts +6 -0
  115. package/dist/entities/ast/enums.js +17 -0
  116. package/dist/entities/ast/export-chain.d.ts +15 -0
  117. package/dist/entities/ast/export-chain.js +171 -0
  118. package/dist/entities/ast/file-exports.d.ts +7 -0
  119. package/dist/entities/ast/file-exports.js +101 -0
  120. package/dist/entities/ast/file-facts.d.ts +16 -0
  121. package/dist/entities/ast/file-facts.js +64 -0
  122. package/dist/entities/ast/file-imports.d.ts +5 -0
  123. package/dist/entities/ast/file-imports.js +100 -0
  124. package/dist/entities/ast/file.d.ts +5 -0
  125. package/dist/entities/ast/file.js +23 -0
  126. package/dist/entities/ast/functions.d.ts +8 -0
  127. package/dist/entities/ast/functions.js +111 -0
  128. package/dist/entities/ast/heritage.d.ts +4 -0
  129. package/dist/entities/ast/heritage.js +44 -0
  130. package/dist/entities/ast/index.d.ts +9 -0
  131. package/dist/entities/ast/index.js +181 -0
  132. package/dist/entities/ast/kind.d.ts +5 -0
  133. package/dist/entities/ast/kind.js +34 -0
  134. package/dist/entities/ast/loose.d.ts +37 -0
  135. package/dist/entities/ast/loose.js +2 -0
  136. package/dist/entities/ast/modifiers.d.ts +5 -0
  137. package/dist/entities/ast/modifiers.js +32 -0
  138. package/dist/entities/ast/project.d.ts +9 -0
  139. package/dist/entities/ast/project.js +106 -0
  140. package/dist/entities/ast/properties.d.ts +11 -0
  141. package/dist/entities/ast/properties.js +176 -0
  142. package/dist/entities/ast/resolve.d.ts +16 -0
  143. package/dist/entities/ast/resolve.js +317 -0
  144. package/dist/entities/ast/tree.d.ts +31 -0
  145. package/dist/entities/ast/tree.js +518 -0
  146. package/dist/entities/ast/types.d.ts +6 -0
  147. package/dist/entities/ast/types.js +46 -0
  148. package/dist/entities/ast/usage.d.ts +11 -0
  149. package/dist/entities/ast/usage.js +81 -0
  150. package/dist/entities/ast/variables.d.ts +8 -0
  151. package/dist/entities/ast/variables.js +91 -0
  152. package/dist/entities/context.d.ts +29 -0
  153. package/dist/entities/context.js +2 -0
  154. package/dist/entities/facts.d.ts +284 -0
  155. package/dist/entities/facts.js +2 -0
  156. package/dist/entities/findings.d.ts +19 -0
  157. package/dist/entities/findings.js +2 -0
  158. package/dist/entities/kinds.d.ts +40 -0
  159. package/dist/entities/kinds.js +332 -0
  160. package/dist/entities/location/homes.d.ts +28 -0
  161. package/dist/entities/location/homes.js +195 -0
  162. package/dist/entities/location/place.d.ts +10 -0
  163. package/dist/entities/location/place.js +63 -0
  164. package/dist/entities/location/where.d.ts +19 -0
  165. package/dist/entities/location/where.js +277 -0
  166. package/dist/entities/location.d.ts +16 -0
  167. package/dist/entities/location.js +140 -0
  168. package/dist/entities/operators.d.ts +14 -0
  169. package/dist/entities/operators.js +30 -0
  170. package/dist/entities/overview/data.d.ts +43 -0
  171. package/dist/entities/overview/data.js +2 -0
  172. package/dist/entities/overview/decision.d.ts +60 -0
  173. package/dist/entities/overview/decision.js +2 -0
  174. package/dist/entities/overview/file-tree.d.ts +10 -0
  175. package/dist/entities/overview/file-tree.js +2 -0
  176. package/dist/entities/overview/finding.d.ts +58 -0
  177. package/dist/entities/overview/finding.js +2 -0
  178. package/dist/entities/overview/graph.d.ts +82 -0
  179. package/dist/entities/overview/graph.js +2 -0
  180. package/dist/entities/overview/input.d.ts +15 -0
  181. package/dist/entities/overview/input.js +2 -0
  182. package/dist/entities/overview/summaries.d.ts +81 -0
  183. package/dist/entities/overview/summaries.js +2 -0
  184. package/dist/entities/place.d.ts +5 -0
  185. package/dist/entities/place.js +2 -0
  186. package/dist/entities/queries.d.ts +9 -0
  187. package/dist/entities/queries.js +375 -0
  188. package/dist/entities/repair.d.ts +16 -0
  189. package/dist/entities/repair.js +29 -0
  190. package/dist/entities/schema.d.ts +22 -0
  191. package/dist/entities/schema.js +81 -0
  192. package/dist/entities/story.d.ts +47 -0
  193. package/dist/entities/story.js +2 -0
  194. package/dist/entities/structure-facts.d.ts +11 -0
  195. package/dist/entities/structure-facts.js +2 -0
  196. package/dist/entities/token.d.ts +23 -0
  197. package/dist/entities/token.js +2 -0
  198. package/dist/entities/tree/build.d.ts +6 -0
  199. package/dist/entities/tree/build.js +313 -0
  200. package/dist/entities/tree/entries.d.ts +7 -0
  201. package/dist/entities/tree/entries.js +145 -0
  202. package/dist/entities/tree/index.d.ts +6 -0
  203. package/dist/entities/tree/index.js +21 -0
  204. package/dist/entities/tree/match.d.ts +17 -0
  205. package/dist/entities/tree/match.js +190 -0
  206. package/dist/fa-index.d.ts +16 -0
  207. package/dist/fa-index.js +165 -0
  208. package/dist/fa-open.d.ts +51 -0
  209. package/dist/fa-open.js +242 -0
  210. package/dist/fa-store.d.ts +22 -0
  211. package/dist/fa-store.js +232 -0
  212. package/dist/fa-values.d.ts +37 -0
  213. package/dist/fa-values.js +104 -0
  214. package/dist/facts-record.d.ts +45 -0
  215. package/dist/facts-record.js +297 -0
  216. package/dist/frameworks/angular/index.d.ts +7 -0
  217. package/dist/frameworks/angular/index.js +18 -0
  218. package/dist/frameworks/facet.d.ts +18 -0
  219. package/dist/frameworks/facet.js +15 -0
  220. package/dist/frameworks/index.d.ts +9 -0
  221. package/dist/frameworks/index.js +134 -0
  222. package/dist/frameworks/react/index.d.ts +7 -0
  223. package/dist/frameworks/react/index.js +237 -0
  224. package/dist/frameworks/test/index.d.ts +6 -0
  225. package/dist/frameworks/test/index.js +157 -0
  226. package/dist/frameworks/vue/index.d.ts +7 -0
  227. package/dist/frameworks/vue/index.js +18 -0
  228. package/dist/ignore.d.ts +3 -0
  229. package/dist/ignore.js +62 -0
  230. package/dist/index-file.d.ts +43 -0
  231. package/dist/index-file.js +218 -0
  232. package/dist/index-run.d.ts +39 -0
  233. package/dist/index-run.js +217 -0
  234. package/dist/index-zone.d.ts +25 -0
  235. package/dist/index-zone.js +219 -0
  236. package/dist/main.d.ts +10 -0
  237. package/dist/main.js +411 -0
  238. package/dist/nodes/child-entities.d.ts +3 -0
  239. package/dist/nodes/child-entities.js +12 -0
  240. package/dist/nodes/children.d.ts +25 -0
  241. package/dist/nodes/children.js +165 -0
  242. package/dist/nodes/finally/emit.d.ts +6 -0
  243. package/dist/nodes/finally/emit.js +71 -0
  244. package/dist/nodes/finally/entities.d.ts +13 -0
  245. package/dist/nodes/finally/entities.js +42 -0
  246. package/dist/nodes/finally/index.d.ts +8 -0
  247. package/dist/nodes/finally/index.js +35 -0
  248. package/dist/nodes/finally/queries.d.ts +5 -0
  249. package/dist/nodes/finally/queries.js +25 -0
  250. package/dist/nodes/finally/relations-access.d.ts +5 -0
  251. package/dist/nodes/finally/relations-access.js +50 -0
  252. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  253. package/dist/nodes/finally/relations-edge.js +148 -0
  254. package/dist/nodes/finally/relations-group.d.ts +31 -0
  255. package/dist/nodes/finally/relations-group.js +106 -0
  256. package/dist/nodes/finally/relations.d.ts +5 -0
  257. package/dist/nodes/finally/relations.js +85 -0
  258. package/dist/nodes/finally/required.d.ts +5 -0
  259. package/dist/nodes/finally/required.js +92 -0
  260. package/dist/nodes/finally/violation.d.ts +17 -0
  261. package/dist/nodes/finally/violation.js +2 -0
  262. package/dist/nodes/similar.d.ts +21 -0
  263. package/dist/nodes/similar.js +178 -0
  264. package/dist/piece-forms.d.ts +9 -0
  265. package/dist/piece-forms.js +68 -0
  266. package/dist/pipeline-entities.d.ts +6 -0
  267. package/dist/pipeline-entities.js +79 -0
  268. package/dist/pipeline-facts.d.ts +12 -0
  269. package/dist/pipeline-facts.js +114 -0
  270. package/dist/pipeline-unclassified.d.ts +14 -0
  271. package/dist/pipeline-unclassified.js +188 -0
  272. package/dist/pipeline.d.ts +7 -0
  273. package/dist/pipeline.js +28 -0
  274. package/dist/plugin.d.ts +2 -0
  275. package/dist/plugin.js +3 -0
  276. package/dist/release-file.d.ts +3 -0
  277. package/dist/release-file.js +13 -0
  278. package/dist/report/asks.d.ts +55 -0
  279. package/dist/report/asks.js +60 -0
  280. package/dist/report/cli-report.d.ts +2 -0
  281. package/dist/report/cli-report.js +13 -0
  282. package/dist/report/config-error-guard.d.ts +8 -0
  283. package/dist/report/config-error-guard.js +5 -0
  284. package/dist/report/configErrors.d.ts +126 -0
  285. package/dist/report/configErrors.js +121 -0
  286. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  287. package/dist/report/errorTypes/codes/structure.js +76 -0
  288. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  289. package/dist/report/errorTypes/decision-maker.js +109 -0
  290. package/dist/report/errorTypes/destinations.d.ts +38 -0
  291. package/dist/report/errorTypes/destinations.js +165 -0
  292. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  293. package/dist/report/errorTypes/finding-type.js +2 -0
  294. package/dist/report/errorTypes/index.d.ts +15 -0
  295. package/dist/report/errorTypes/index.js +55 -0
  296. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  297. package/dist/report/errorTypes/types/fileContents.js +40 -0
  298. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  299. package/dist/report/errorTypes/types/unknownEntity.js +27 -0
  300. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  301. package/dist/report/errorTypes/types/wrongAction.js +140 -0
  302. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  303. package/dist/report/errorTypes/types/wrongPlacement.js +67 -0
  304. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  305. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  306. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  307. package/dist/report/errorTypes/vocabulary/phrases.js +187 -0
  308. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  309. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  310. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  311. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  312. package/dist/report/finding-from.d.ts +9 -0
  313. package/dist/report/finding-from.js +108 -0
  314. package/dist/report/notices.d.ts +9 -0
  315. package/dist/report/notices.js +57 -0
  316. package/dist/report/observed.d.ts +19 -0
  317. package/dist/report/observed.js +87 -0
  318. package/dist/report/render-report.d.ts +12 -0
  319. package/dist/report/render-report.js +145 -0
  320. package/dist/report/user-report/build/bundle.d.ts +3 -0
  321. package/dist/report/user-report/build/bundle.js +188 -0
  322. package/dist/report/user-report/build/bundle.prebuilt.js +1262 -0
  323. package/dist/report/user-report/data/collect.d.ts +4 -0
  324. package/dist/report/user-report/data/collect.js +93 -0
  325. package/dist/report/user-report/data/entities.d.ts +7 -0
  326. package/dist/report/user-report/data/entities.js +88 -0
  327. package/dist/report/user-report/data/entity-examples.d.ts +16 -0
  328. package/dist/report/user-report/data/entity-examples.js +136 -0
  329. package/dist/report/user-report/data/entity-filters.d.ts +15 -0
  330. package/dist/report/user-report/data/entity-filters.js +79 -0
  331. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  332. package/dist/report/user-report/data/entity-marks.js +79 -0
  333. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  334. package/dist/report/user-report/data/file-tree.js +80 -0
  335. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  336. package/dist/report/user-report/data/finding-boundary.js +21 -0
  337. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  338. package/dist/report/user-report/data/finding-plan.js +45 -0
  339. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  340. package/dist/report/user-report/data/finding-title.js +36 -0
  341. package/dist/report/user-report/data/findings.d.ts +10 -0
  342. package/dist/report/user-report/data/findings.js +181 -0
  343. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  344. package/dist/report/user-report/data/graph-edges.js +109 -0
  345. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  346. package/dist/report/user-report/data/graph-entities.js +158 -0
  347. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  348. package/dist/report/user-report/data/graph-helpers.js +67 -0
  349. package/dist/report/user-report/data/graph.d.ts +12 -0
  350. package/dist/report/user-report/data/graph.js +97 -0
  351. package/dist/report/user-report/data/nodes.d.ts +11 -0
  352. package/dist/report/user-report/data/nodes.js +116 -0
  353. package/dist/report/user-report/data/rules.d.ts +7 -0
  354. package/dist/report/user-report/data/rules.js +62 -0
  355. package/dist/report/user-report/data/scan.d.ts +8 -0
  356. package/dist/report/user-report/data/scan.js +69 -0
  357. package/dist/report/user-report/html/shell.d.ts +3 -0
  358. package/dist/report/user-report/html/shell.js +27 -0
  359. package/dist/report/user-report/index.d.ts +8 -0
  360. package/dist/report/user-report/index.js +58 -0
  361. package/dist/report/user-report/shared/describe.d.ts +7 -0
  362. package/dist/report/user-report/shared/describe.js +86 -0
  363. package/dist/rules/index.d.ts +7 -0
  364. package/dist/rules/index.js +327 -0
  365. package/dist/rules/list-vars.d.ts +5 -0
  366. package/dist/rules/list-vars.js +149 -0
  367. package/dist/rules/name.d.ts +16 -0
  368. package/dist/rules/name.js +18 -0
  369. package/dist/rules/normalize.d.ts +5 -0
  370. package/dist/rules/normalize.js +108 -0
  371. package/dist/rules/vars.d.ts +22 -0
  372. package/dist/rules/vars.js +117 -0
  373. package/dist/scan-run.d.ts +20 -0
  374. package/dist/scan-run.js +130 -0
  375. package/dist/scripts/audit-report.d.ts +2 -0
  376. package/dist/scripts/audit-report.js +157 -0
  377. package/dist/usage-index.d.ts +4 -0
  378. package/dist/usage-index.js +282 -0
  379. package/dist/usage-mode.d.ts +7 -0
  380. package/dist/usage-mode.js +16 -0
  381. package/dist/usage-pass.d.ts +19 -0
  382. package/dist/usage-pass.js +136 -0
  383. package/dist/usage-prepare.d.ts +2 -0
  384. package/dist/usage-prepare.js +22 -0
  385. package/dist/usage-sweep.d.ts +10 -0
  386. package/dist/usage-sweep.js +264 -0
  387. package/dist/utils/accumulate.d.ts +6 -0
  388. package/dist/utils/accumulate.js +18 -0
  389. package/dist/utils/aliases.d.ts +22 -0
  390. package/dist/utils/aliases.js +173 -0
  391. package/dist/utils/article.d.ts +2 -0
  392. package/dist/utils/article.js +12 -0
  393. package/dist/utils/classify.d.ts +12 -0
  394. package/dist/utils/classify.js +25 -0
  395. package/dist/utils/configs.d.ts +25 -0
  396. package/dist/utils/configs.js +97 -0
  397. package/dist/utils/count.d.ts +7 -0
  398. package/dist/utils/count.js +13 -0
  399. package/dist/utils/dispatch.d.ts +2 -0
  400. package/dist/utils/dispatch.js +27 -0
  401. package/dist/utils/distinct.d.ts +2 -0
  402. package/dist/utils/distinct.js +14 -0
  403. package/dist/utils/field.d.ts +14 -0
  404. package/dist/utils/field.js +60 -0
  405. package/dist/utils/file-name.d.ts +2 -0
  406. package/dist/utils/file-name.js +11 -0
  407. package/dist/utils/files.d.ts +7 -0
  408. package/dist/utils/files.js +77 -0
  409. package/dist/utils/fixpoint.d.ts +2 -0
  410. package/dist/utils/fixpoint.js +19 -0
  411. package/dist/utils/gate.d.ts +2 -0
  412. package/dist/utils/gate.js +12 -0
  413. package/dist/utils/group.d.ts +3 -0
  414. package/dist/utils/group.js +33 -0
  415. package/dist/utils/host.d.ts +3 -0
  416. package/dist/utils/host.js +16 -0
  417. package/dist/utils/imports.d.ts +12 -0
  418. package/dist/utils/imports.js +185 -0
  419. package/dist/utils/judged.d.ts +5 -0
  420. package/dist/utils/judged.js +19 -0
  421. package/dist/utils/keyed.d.ts +2 -0
  422. package/dist/utils/keyed.js +23 -0
  423. package/dist/utils/map-record.d.ts +2 -0
  424. package/dist/utils/map-record.js +11 -0
  425. package/dist/utils/packages.d.ts +15 -0
  426. package/dist/utils/packages.js +207 -0
  427. package/dist/utils/path-label.d.ts +6 -0
  428. package/dist/utils/path-label.js +37 -0
  429. package/dist/utils/pattern.d.ts +19 -0
  430. package/dist/utils/pattern.js +231 -0
  431. package/dist/utils/permission.d.ts +16 -0
  432. package/dist/utils/permission.js +18 -0
  433. package/dist/utils/plural.d.ts +2 -0
  434. package/dist/utils/plural.js +9 -0
  435. package/dist/utils/qualified.d.ts +2 -0
  436. package/dist/utils/qualified.js +21 -0
  437. package/dist/utils/rank.d.ts +2 -0
  438. package/dist/utils/rank.js +24 -0
  439. package/dist/utils/read-field.d.ts +12 -0
  440. package/dist/utils/read-field.js +50 -0
  441. package/dist/utils/read-when.d.ts +2 -0
  442. package/dist/utils/read-when.js +17 -0
  443. package/dist/utils/reason.d.ts +4 -0
  444. package/dist/utils/reason.js +9 -0
  445. package/dist/utils/record.d.ts +3 -0
  446. package/dist/utils/record.js +21 -0
  447. package/dist/utils/resolve.d.ts +2 -0
  448. package/dist/utils/resolve.js +24 -0
  449. package/dist/utils/search.d.ts +2 -0
  450. package/dist/utils/search.js +21 -0
  451. package/dist/utils/seen.d.ts +6 -0
  452. package/dist/utils/seen.js +27 -0
  453. package/dist/utils/span.d.ts +5 -0
  454. package/dist/utils/span.js +2 -0
  455. package/dist/utils/speak.d.ts +2 -0
  456. package/dist/utils/speak.js +18 -0
  457. package/dist/utils/split.d.ts +8 -0
  458. package/dist/utils/split.js +21 -0
  459. package/dist/utils/template.d.ts +5 -0
  460. package/dist/utils/template.js +5 -0
  461. package/dist/utils/text.d.ts +4 -0
  462. package/dist/utils/text.js +42 -0
  463. package/dist/utils/tokenize.d.ts +2 -0
  464. package/dist/utils/tokenize.js +18 -0
  465. package/dist/utils/try-read.d.ts +4 -0
  466. package/dist/utils/try-read.js +24 -0
  467. package/dist/utils/typed-field.d.ts +3 -0
  468. package/dist/utils/typed-field.js +16 -0
  469. package/dist/utils/verdicts.d.ts +4 -0
  470. package/dist/utils/verdicts.js +20 -0
  471. package/entities/operators.ts +31 -0
  472. package/package.json +101 -47
  473. package/report/errorTypes/vocabulary/ids.ts +17 -0
  474. package/report/errorTypes/vocabulary/phrases.ts +181 -0
  475. package/report/errorTypes/vocabulary/places.ts +51 -0
  476. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  477. package/report/user-report/shared/describe.ts +107 -0
  478. package/ast.js +0 -107
  479. package/bin/follow-architecture.js +0 -6
  480. package/config.js +0 -101
  481. package/entities/aliases.js +0 -10
  482. package/entities/invariants.js +0 -134
  483. package/entities/nodes.js +0 -112
  484. package/main.js +0 -96
  485. package/plugin.js +0 -5
  486. package/report.js +0 -73
  487. package/utils.js +0 -104
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.releaseFile = exports.collectCandidates = exports.collectFileFacts = exports.importNameModules = exports.loadSourceFile = exports.createTsProject = void 0;
4
+ // The entry point of the AST layer. Every entity module collects facts about
5
+ // ONE kind of node; this file puts them together into a candidate — the unit a
6
+ // entity classifies — and hands back the public API the pipeline uses.
7
+ //
8
+ // Facts are plain data: no comparisons, no predicates, no project rules. The
9
+ // YAML pairs a fact with a filter (entities/queries.js) to express any rule.
10
+ // Nothing here names a project, a framework, or an entity.
11
+ //
12
+ // A candidate describes a PIECE of code with four things and nothing else:
13
+ // location — where it is: `path` (the file) and `piece` (the piece it sits
14
+ // in, null at module scope)
15
+ // lines — the lines it spans, as one array: start, everything inside, end
16
+ // parameters — what it receives
17
+ // actions — what it does: `calls` here (running code), `assignments`
18
+ // (writing into a value), `returns` (the value it yields). The
19
+ // relations those actions form are produced in entities/kinds.js.
20
+ const ts_morph_1 = require("ts-morph");
21
+ const tree_1 = require("./tree");
22
+ const file_1 = require("./file");
23
+ Object.defineProperty(exports, "createTsProject", { enumerable: true, get: function () { return file_1.createTsProject; } });
24
+ Object.defineProperty(exports, "loadSourceFile", { enumerable: true, get: function () { return file_1.loadSourceFile; } });
25
+ Object.defineProperty(exports, "importNameModules", { enumerable: true, get: function () { return file_1.importNameModules; } });
26
+ Object.defineProperty(exports, "collectFileFacts", { enumerable: true, get: function () { return file_1.collectFileFacts; } });
27
+ const calls_1 = require("./calls");
28
+ const functions_1 = require("./functions");
29
+ const branches_1 = require("./branches");
30
+ const variables_1 = require("./variables");
31
+ const assignments_1 = require("./assignments");
32
+ const classes_1 = require("./classes");
33
+ const types_1 = require("./types");
34
+ const enums_1 = require("./enums");
35
+ const kind_1 = require("./kind");
36
+ const usage_1 = require("./usage");
37
+ const usage_index_1 = require("../../usage-index");
38
+ const usage_mode_1 = require("../../usage-mode");
39
+ const comments_1 = require("./comments");
40
+ // ts-morph beyond the tree: who USES the name, and who implements the shape.
41
+ // Asked only for published names — a local binding's reach is its own file. The
42
+ // paths a use lives in are repo-relative, so a rule can ask WHERE it is used.
43
+ const usageOf = (node, sf, repoRoot, usage, name = null) => {
44
+ if (!usage)
45
+ return { references: null, implementations: null };
46
+ // The cheap source counts occurrences of the NAME in the repo's text; the exact
47
+ // one asks the checker. Both answer only for a published name.
48
+ if ((0, usage_mode_1.usageMode)() === "index") {
49
+ const rel = (0, file_1.repoRelative)(sf.getFilePath(), repoRoot) ?? sf.getBaseName();
50
+ const declared = name ?? (0, functions_1.nameOf)(node);
51
+ return { references: (0, usage_index_1.usageFromIndex)(declared, rel, (0, tree_1.isExported)(node), node.getKindName()), implementations: null };
52
+ }
53
+ return (0, usage_1.usageFact)(node, sf, { exported: (0, tree_1.isExported)(node), relOf: (p) => (0, file_1.repoRelative)(p, repoRoot) ?? p });
54
+ };
55
+ // The name a candidate carries: a function-like node answers its own (an arrow
56
+ // takes its binding's name); anything else is its declaration's name.
57
+ const candidateName = (node, isFn) => {
58
+ if (isFn)
59
+ return (0, functions_1.nameOf)(node);
60
+ return node.getName?.() ?? null;
61
+ };
62
+ // Raw facts about a single candidate node. `rel` is the repo-relative file path
63
+ // — carried on the fact so location-aware operators (e.g. `location`) can match
64
+ // the candidate's position against node declarations.
65
+ const collectCandidateFacts = (node, { sf, importMap, rel, repoRoot, usage }) => {
66
+ const isFn = (0, tree_1.isFunctionNode)(node);
67
+ const enclosing = (0, functions_1.nearestFunction)(node);
68
+ return {
69
+ name: candidateName(node, isFn),
70
+ // Where the code is: ONE fact. `path` is the file, `piece` the piece it is
71
+ // nested in — `piece: null` means module scope, a fact and not a special case.
72
+ // `nested` separates "no enclosing function" from "an enclosing function
73
+ // without a name": a `const` inside `function () {…}` is still a LOCAL, and
74
+ // reading its `piece: null` as module scope made the report ask the reader to
75
+ // give an entity to a one-line alias.
76
+ location: { path: rel ?? null, piece: enclosing ? ((0, functions_1.nameOf)(enclosing) ?? null) : null, nested: Boolean(enclosing) },
77
+ lines: (0, tree_1.linesOf)(node),
78
+ // What it is, what is around and below it, and what it is SPELLED with.
79
+ kind: (0, kind_1.kindOf)(node, isFn ? null : (0, variables_1.variableInitializer)(node)),
80
+ returns: isFn ? (0, functions_1.returnsFact)(node) : [],
81
+ calls: isFn ? (0, calls_1.callsFact)(node, importMap, sf, repoRoot) : [],
82
+ // The control flow this piece runs ITSELF: a branch is what a name can hide.
83
+ branches: isFn ? (0, branches_1.branchesFact)(node) : [],
84
+ assignments: (0, assignments_1.assignmentsFact)(node, sf, importMap, { repoRoot, rel }),
85
+ parameters: isFn ? (0, functions_1.parametersFact)(node, sf, repoRoot) : [],
86
+ // Two facts about a DECLARATION that no action can express: is it
87
+ // published, and may the binding be reassigned. Both are what the
88
+ // language says, not a verdict.
89
+ exported: (0, tree_1.isExported)(node),
90
+ mutable: (0, tree_1.isMutable)(node),
91
+ // ts-morph beyond the tree: who USES the name, who IMPLEMENTS the shape.
92
+ // Not `kind`: these are answers from the checker, not the node's shape.
93
+ ...usageOf(node, sf, repoRoot, usage),
94
+ };
95
+ };
96
+ // Is this node a classification candidate? Function-like nodes, variable
97
+ // declarations, classes, types and enums — plus an export assignment that
98
+ // publishes a value with no binding of its own (`export default { … }`;
99
+ // `export default name` publishes an EXISTING piece, already a candidate).
100
+ const isCandidateNode = (n) => {
101
+ if (n.getKind() === tree_1.SK.ExportAssignment)
102
+ return ts_morph_1.Node.isExportAssignment(n) && n.getExpression()?.getKind() !== tree_1.SK.Identifier;
103
+ return ((0, tree_1.isFunctionNode)(n) || n.getKind() === tree_1.SK.VariableDeclaration || (0, types_1.isTypeNode)(n) || (0, tree_1.isClassNode)(n) || (0, enums_1.isEnumNode)(n));
104
+ };
105
+ // One declaration's facts: a class/type/enum adds only what its syntax has;
106
+ // everything else answers the generic candidate questions.
107
+ //
108
+ // The facts WITHOUT the checker's `references`/`implementations` are the same
109
+ // every time a file is walked, and a run walks the same file in several places
110
+ // (the linted file's pipeline, the project-wide entity index, the depth walk).
111
+ // So they are computed once per node and shared; the usage answer — the
112
+ // expensive, project-wide one — is layered only where a caller actually asks
113
+ // for it.
114
+ const BASE_CANDIDATE = new WeakMap();
115
+ const declarationCandidate = (n, ctx) => {
116
+ let base = BASE_CANDIDATE.get(n);
117
+ if (!base) {
118
+ // The facts WITHOUT the checker's `references`/`implementations`: those are
119
+ // the same every time a file is walked, and a run walks the same file in
120
+ // several places (the linted file's pipeline, the project-wide entity index,
121
+ // the depth walk). Usage is layered below only where a caller asks for it.
122
+ const bare = { ...ctx, usage: false };
123
+ const rel = ctx.rel ?? "";
124
+ if (ts_morph_1.Node.isClassDeclaration(n) || ts_morph_1.Node.isClassExpression(n))
125
+ base = (0, classes_1.classFact)(n, collectCandidateFacts(n, bare));
126
+ else if ((0, enums_1.isEnumNode)(n))
127
+ base = { ...(0, enums_1.enumFact)(n, rel), ...usageOf(n, ctx.sf, ctx.repoRoot, false) };
128
+ else if ((0, types_1.isTypeNode)(n))
129
+ base = { ...(0, types_1.typeFact)(n, rel), ...usageOf(n, ctx.sf, ctx.repoRoot, false) };
130
+ else
131
+ base = collectCandidateFacts(n, bare);
132
+ // An export assignment has no name node; the file's default export is
133
+ // what a reader (and an import map) calls it.
134
+ if (n.getKind() === tree_1.SK.ExportAssignment && !base.name)
135
+ base.name = "default";
136
+ // Where the node sits: a record carries no syntax, so the pair `at`/`len`
137
+ // is how the checks find this declaration again on the whole-repo project.
138
+ base.at = n.getStart();
139
+ base.len = n.getWidth();
140
+ BASE_CANDIDATE.set(n, base);
141
+ }
142
+ // A fresh top-level object per call: the pipeline and the facets attach fields
143
+ // (`framework`, `css`, `chain`, `file`) to the candidate they were handed, so
144
+ // two consumers must never share the mutable shell — only its facts are one.
145
+ if (!ctx.usage)
146
+ return { ...base };
147
+ // The name the record already carries is the one the checker keys a reference by
148
+ // and the one the occurrence index counts — not `nameOf`, which answers for
149
+ // function-like pieces only.
150
+ return { ...base, ...usageOf(n, ctx.sf, ctx.repoRoot, true, base.name) };
151
+ };
152
+ // Every classification candidate in the file (function-like nodes, variable
153
+ // declarations, classes and type declarations, and the comments), in document
154
+ // order.
155
+ //
156
+ // A comment is a candidate because a project may want to say things about it —
157
+ // this kind must carry a reason, that banner must separate sections, no comment
158
+ // may sit outside an action. Those are the same questions `location`, `lines`
159
+ // and `kind` already answer for code, so nothing new is invented for it: it is
160
+ // collected as a candidate and the YAML gives it an entity like anything else.
161
+ const collectCandidates = (...args) => {
162
+ const [sf, importMap, rel, repoRoot, opts] = args;
163
+ const ctx = { sf, importMap, rel, repoRoot, usage: opts?.usage !== false };
164
+ const declarations = (0, tree_1.fileDescendants)(sf)
165
+ .filter(isCandidateNode)
166
+ .map((n) => declarationCandidate(n, ctx));
167
+ const comments = (0, comments_1.commentsOf)(sf, rel);
168
+ return [...declarations, ...comments].sort((a, b) => (a.lines?.[0] ?? 0) - (b.lines?.[0] ?? 0));
169
+ };
170
+ exports.collectCandidates = collectCandidates;
171
+ // Give back everything this layer memoised for ONE file: the descendant list, the
172
+ // node-keyed memos under it (line, text, depth), the base candidate of every
173
+ // declaration, and the cached comment/fact lists. The facts a caller already got
174
+ // are plain data and stay valid.
175
+ const releaseFile = (sf) => {
176
+ for (const node of (0, tree_1.releaseTree)(sf))
177
+ BASE_CANDIDATE.delete(node);
178
+ (0, comments_1.releaseComments)(sf);
179
+ (0, file_1.releaseFileFacts)(sf);
180
+ };
181
+ exports.releaseFile = releaseFile;
@@ -0,0 +1,5 @@
1
+ import type { LooseNode } from "./loose";
2
+ import type { KindFact, Initializer } from "@md-code/follow-architecture/entities/facts";
3
+ declare const kindOf: (node: LooseNode, initializer?: Initializer | null) => KindFact;
4
+ declare const spelled: (kind: string) => Pick<KindFact, "own" | "modifiers" | "decorators" | "assertion" | "disposable">;
5
+ export { kindOf, spelled };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spelled = exports.kindOf = void 0;
4
+ // WHAT A DECLARATION IS, in one fact. `kind` is not only the AST node: it is
5
+ // also what the declaration is SPELLED with — `export`, `abstract`, `static`,
6
+ // `readonly`, the decorators above it, an assertion on its value, `using`. Those
7
+ // are all readable off the same node, so they live in the same place; a second
8
+ // top-level field would be the same fact spelled twice.
9
+ //
10
+ // `references` and `implementations` are NOT here: they come from the checker
11
+ // (ast/usage.js), and `kind` stays the answer the syntax tree alone can give.
12
+ const tree_1 = require("./tree");
13
+ const modifiers_1 = require("./modifiers");
14
+ const variables_1 = require("./variables");
15
+ // `initializer` — the variable's initializer, when the node has one: `as const`
16
+ // and `satisfies X` are written on the VALUE, and only a variable has one.
17
+ const kindOf = (node, initializer = null) => ({
18
+ ...(0, tree_1.kindFact)(node, initializer),
19
+ modifiers: (0, modifiers_1.modifiersOf)(node),
20
+ decorators: (0, modifiers_1.decoratorsOf)(node),
21
+ assertion: initializer ? (0, variables_1.assertionOf)(node) : null,
22
+ disposable: initializer ? (0, variables_1.isDisposable)(node) : false,
23
+ });
24
+ exports.kindOf = kindOf;
25
+ // The `kind` of something with no node of its own (a comment is trivia): the
26
+ // same four fields, empty, so every candidate answers the same questions.
27
+ const spelled = (kind) => ({
28
+ own: { is: kind },
29
+ modifiers: [],
30
+ decorators: [],
31
+ assertion: null,
32
+ disposable: false,
33
+ });
34
+ exports.spelled = spelled;
@@ -0,0 +1,37 @@
1
+ import type { Node, Decorator, CommentRange } from "ts-morph";
2
+ type LooseNode = Node & {
3
+ getName?: () => string | undefined;
4
+ getNameNode?: () => Node | undefined;
5
+ getModifiers?: () => Node[] | undefined;
6
+ getDecorators?: () => Decorator[] | undefined;
7
+ getInitializer?: () => Node | undefined;
8
+ getLiteralText?: () => string | undefined;
9
+ getJsDocs?: () => Node[] | undefined;
10
+ getBody?: () => Node | undefined;
11
+ getExpression?: () => Node | undefined;
12
+ getTypeNode?: () => Node | undefined;
13
+ getReturnTypeNode?: () => Node | undefined;
14
+ getMembers?: () => LooseNode[] | undefined;
15
+ getDeclarationKind?: () => string | undefined;
16
+ getExtends?: () => Node | Node[] | undefined;
17
+ getImplements?: () => Node[] | undefined;
18
+ getConstructors?: () => LooseNode[] | undefined;
19
+ getParameters?: () => LooseNode[] | undefined;
20
+ getElements?: () => LooseNode[] | undefined;
21
+ isOptional?: () => boolean;
22
+ isStatic?: () => boolean;
23
+ findReferencesAsNodes?: () => Node[];
24
+ getImplementations?: () => {
25
+ readonly length: number;
26
+ };
27
+ getLeadingCommentRanges?: () => CommentRange[] | undefined;
28
+ getTrailingCommentRanges?: () => CommentRange[] | undefined;
29
+ getTypeArguments?: () => Node[] | undefined;
30
+ getExprName?: () => Node | undefined;
31
+ getTypeName?: () => Node | undefined;
32
+ getTypeNodes?: () => Node[] | undefined;
33
+ getElementTypeNode?: () => Node | undefined;
34
+ getObjectTypeNode?: () => Node | undefined;
35
+ getConstraint?: () => Node | undefined;
36
+ };
37
+ export type { LooseNode };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import type { LooseNode } from "./loose";
2
+ import type { DecoratorFact } from "@md-code/follow-architecture/entities/facts";
3
+ declare const modifiersOf: (node: LooseNode) => string[];
4
+ declare const decoratorsOf: (node: LooseNode) => DecoratorFact[];
5
+ export { modifiersOf, decoratorsOf };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decoratorsOf = exports.modifiersOf = void 0;
4
+ // What a declaration is SPELLED with: `export`, `abstract`, `declare`, `async`,
5
+ // `static`, `readonly`, `accessor`, `override`, the visibility words — and the
6
+ // decorators above it. Facts, not verdicts: a rule decides what they mean.
7
+ const ts_morph_1 = require("ts-morph");
8
+ const tree_1 = require("./tree");
9
+ const properties_1 = require("./properties");
10
+ // A variable's words live on the STATEMENT that declares it: `export const x`
11
+ // and `declare const x` are written on `VariableStatement`, and the declaration
12
+ // node itself carries none. Asking only the node answered "nothing" for every
13
+ // `const`, while `exported` said the opposite about the same file.
14
+ // The declaration sits inside a `VariableDeclarationList`, and the list inside the
15
+ // statement — so the owner is a grandparent, not a parent.
16
+ const spelledBy = (node) => node.getKind?.() === tree_1.SK.VariableDeclaration ? (node.getFirstAncestorByKind?.(tree_1.SK.VariableStatement) ?? node) : node;
17
+ // `modifiersOf` answers with the words as written, in source order.
18
+ const modifiersOf = (node) => {
19
+ const owner = spelledBy(node);
20
+ return (typeof owner.getModifiers === "function" ? owner.getModifiers() : []).map((m) => m.getText());
21
+ };
22
+ exports.modifiersOf = modifiersOf;
23
+ // Decorators by the NAME a filter can match: `@Component({…})` → "Component",
24
+ // `@core.Input()` → "Input". Framework-agnostic — any decorator, any framework.
25
+ const decoratorsOf = (node) => (typeof node.getDecorators === "function" ? node.getDecorators() : []).map((d) => {
26
+ const expr = d.getExpression();
27
+ const name = ts_morph_1.Node.isCallExpression(expr)
28
+ ? ((0, properties_1.lastMemberName)(expr.getExpression()) ?? expr.getExpression().getText())
29
+ : ((0, properties_1.lastMemberName)(expr) ?? expr.getText());
30
+ return { name, full: expr.getText(), line: (0, tree_1.startLine)(d) };
31
+ });
32
+ exports.decoratorsOf = decoratorsOf;
@@ -0,0 +1,9 @@
1
+ import { Project, type SourceFile } from "ts-morph";
2
+ type AliasMap = Record<string, string>;
3
+ declare const createTsProject: ({ repoRoot, aliases }?: {
4
+ repoRoot?: string;
5
+ aliases?: AliasMap;
6
+ }) => Project;
7
+ declare const loadSourceFile: (project: Project, abs: string, text: string) => SourceFile;
8
+ export { createTsProject, loadSourceFile };
9
+ export type { AliasMap };
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadSourceFile = exports.createTsProject = void 0;
4
+ // LOADING a source file into the run's project. One Project per run, one
5
+ // reader per file; single-file components keep their line grid. Nothing here
6
+ // knows entities, folders or rules — it only answers "give me the parsed file".
7
+ const ts_morph_1 = require("ts-morph");
8
+ const imports_1 = require("@md-code/follow-architecture/utils/imports");
9
+ // Where a dependency begins.
10
+ const DEPENDENCY_DIR = "/node_modules/";
11
+ // Two kinds of declaration under it are NOT dependencies: the compiler's own
12
+ // library, which types the primitives every file uses, and the `@types`
13
+ // packages — ambient declarations (`console`, `process`, the JSX runtime) that
14
+ // no import resolves, yet every file's facts are written in.
15
+ const COMPILER_LIB = "/typescript/lib/lib.";
16
+ const TYPES_DIR = "/node_modules/@types/";
17
+ const isCompilerLib = (file) => file.includes(COMPILER_LIB) && file.endsWith(".d.ts");
18
+ // A module that resolved INTO a package: its `.d.ts` is a fact about a
19
+ // dependency, not a relation the architecture can describe. It is refused at
20
+ // the program's OWN resolution, so those files never enter the program at all —
21
+ // a value imported from a package then has no type (`any`), while a type
22
+ // declared in a neighbouring repo file stays the type it is.
23
+ const isDependency = (file) => file.includes(DEPENDENCY_DIR) && !file.includes(TYPES_DIR) && !isCompilerLib(file);
24
+ // The program's module resolution, with dependencies refused. `ts.resolveModuleName`
25
+ // does the real work through the host ts-morph hands over, so repo files, aliases
26
+ // and the compiler library resolve exactly as before; only the verdict on a
27
+ // dependency changes.
28
+ const resolutionHost = (host, getOptions) => ({
29
+ resolveModuleNames: (names, containingFile) => {
30
+ const options = getOptions();
31
+ return names.map((name) => {
32
+ const resolved = ts_morph_1.ts.resolveModuleName(name, containingFile, options, host).resolvedModule;
33
+ if (!resolved)
34
+ return undefined;
35
+ return isDependency(resolved.resolvedFileName) ? undefined : resolved;
36
+ });
37
+ },
38
+ });
39
+ // One Project per run. Files are added explicitly (never from tsconfig), so the
40
+ // engine is independent of the repo's build config; aliases come only from the
41
+ // YAML. `skipAddingFilesFromTsConfig` keeps the project empty until we add a file.
42
+ const createTsProject = ({ repoRoot, aliases } = {}) => new ts_morph_1.Project({
43
+ compilerOptions: {
44
+ allowJs: true,
45
+ jsx: ts_morph_1.ts.JsxEmit.Preserve,
46
+ esModuleInterop: true,
47
+ // The SAME aliases the facts resolve imports with, handed to the compiler
48
+ // that resolves them (`pathsOf`, in `utils/imports` — one translation). No
49
+ // tsconfig is read: the YAML is the only description of where a name
50
+ // points, so a project fact and an import fact cannot disagree.
51
+ ...(repoRoot ? { baseUrl: repoRoot, paths: (0, imports_1.pathsOf)(aliases) } : {}),
52
+ },
53
+ skipAddingFilesFromTsConfig: true,
54
+ useInMemoryFileSystem: false,
55
+ resolutionHost,
56
+ });
57
+ exports.createTsProject = createTsProject;
58
+ // The opening `<script …>` line: everything after the tag is script text; a
59
+ // same-line `</script>` closes the block again.
60
+ const openedLine = (line, state) => {
61
+ const after = line.slice(line.indexOf(">") + 1);
62
+ if (/<\/script>/.test(after)) {
63
+ state.inside = false;
64
+ return after.replace(/<\/script>[\s\S]*$/, "");
65
+ }
66
+ state.inside = true;
67
+ state.opened = true;
68
+ return after;
69
+ };
70
+ // A line INSIDE the script block: kept until `</script>` cuts it.
71
+ const insideLine = (line, state) => {
72
+ if (/<\/script>/.test(line)) {
73
+ state.inside = false;
74
+ return line.slice(0, line.indexOf("</script>"));
75
+ }
76
+ return line;
77
+ };
78
+ // A single-file component (.vue / .svelte) holds its TypeScript inside
79
+ // `<script>`. Only that block is parsed; every other line is blanked so the
80
+ // line numbers a finding reports still match the file the editor shows.
81
+ const extractScript = (text) => {
82
+ const lines = String(text).split("\n");
83
+ const state = { inside: false, opened: false };
84
+ const kept = lines.map((line) => {
85
+ if (!state.inside && /<script\b[^>]*>/.test(line))
86
+ return openedLine(line, state);
87
+ if (state.inside)
88
+ return insideLine(line, state);
89
+ return "";
90
+ });
91
+ return { text: kept.join("\n"), opened: state.opened };
92
+ };
93
+ const SFC_RE = /\.(vue|svelte)$/i;
94
+ const sourceTextFor = (abs, text) => (SFC_RE.test(abs) ? extractScript(text).text : text);
95
+ // A file already loaded with the SAME text is reused: the pipeline re-reads the
96
+ // linted file on every check, and replacing the source would forget every node
97
+ // other facts (a scope's object literals) still hold — a value resolver walking
98
+ // a cached literal of that very file would then crash on a removed node.
99
+ const loadSourceFile = (project, abs, text) => {
100
+ const source = sourceTextFor(abs, text);
101
+ const existing = project.getSourceFile(abs);
102
+ if (existing && existing.getFullText() === source)
103
+ return existing;
104
+ return project.createSourceFile(abs, source, { overwrite: true });
105
+ };
106
+ exports.loadSourceFile = loadSourceFile;
@@ -0,0 +1,11 @@
1
+ import { Node, type SourceFile } from "ts-morph";
2
+ import type { ReadFact } from "@md-code/follow-architecture/entities/facts";
3
+ type ImportMap = ReadonlyMap<string, string>;
4
+ declare const isPurePropertyPath: (node: Node) => boolean;
5
+ declare const leftmostOrigin: (expr: Node | null) => string | null;
6
+ declare const lastMemberName: (expr: Node | null) => string | null;
7
+ declare const isThisChain: (expr: Node) => boolean;
8
+ declare const importModuleOf: (expr: Node, importMap?: ImportMap) => string | null;
9
+ declare const enclosingPiece: (node: Node) => string | null;
10
+ declare const readsFact: (sf: SourceFile, importMap?: ImportMap) => ReadFact[];
11
+ export { isPurePropertyPath, leftmostOrigin, lastMemberName, isThisChain, importModuleOf, readsFact, enclosingPiece };
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enclosingPiece = exports.readsFact = exports.importModuleOf = exports.isThisChain = exports.lastMemberName = exports.leftmostOrigin = exports.isPurePropertyPath = void 0;
4
+ // Property access: what an expression chain is rooted at (`getRoot(self).x` →
5
+ // "getRoot"), what member is actually used (`store.doX()` → "doX"), and which
6
+ // chains reach state through a configured accessor.
7
+ const ts_morph_1 = require("ts-morph");
8
+ const tree_1 = require("./tree");
9
+ const gate_1 = require("@md-code/follow-architecture/utils/gate");
10
+ // Is this node a "pure property path" — dots only, rooted in an identifier?
11
+ // `a.b.c` → true; `arr[0].run` → false (element access); `f().x` → false (call).
12
+ const isPurePropertyPath = (node) => {
13
+ const k = node.getKind();
14
+ if (k === tree_1.SK.Identifier)
15
+ return true;
16
+ if (ts_morph_1.Node.isPropertyAccessExpression(node))
17
+ return isPurePropertyPath(node.getExpression());
18
+ return false;
19
+ };
20
+ exports.isPurePropertyPath = isPurePropertyPath;
21
+ // The origin a TERMINAL expression names on its own: a construction (`new F`),
22
+ // an element access (`arr[0]`), or a bare identifier (`state`). Null when the
23
+ // expression is not a terminal — it still has an inner expression to step into.
24
+ const terminalOrigin = (e) => {
25
+ if (ts_morph_1.Node.isNewExpression(e))
26
+ return `new ${(0, tree_1.nodeText)(e.getExpression())}`;
27
+ if (ts_morph_1.Node.isElementAccessExpression(e))
28
+ return (0, tree_1.nodeText)(e);
29
+ if (ts_morph_1.Node.isIdentifier(e))
30
+ return (0, tree_1.nodeText)(e);
31
+ return null;
32
+ };
33
+ // The one step INWARD an enclosing expression takes while walking to its root:
34
+ // a tagged template steps to its tag (`keyframes\`…\`` → `keyframes`), a call to
35
+ // its callee, a property access to its base. Null when there is no inner step.
36
+ const inwardStep = (e) => {
37
+ if (ts_morph_1.Node.isTaggedTemplateExpression(e))
38
+ return e.getTag();
39
+ if (ts_morph_1.Node.isCallExpression(e))
40
+ return e.getExpression();
41
+ if (ts_morph_1.Node.isPropertyAccessExpression(e))
42
+ return e.getExpression();
43
+ return null;
44
+ };
45
+ // The origin of any expression chain — what the expression acts on / is rooted at:
46
+ // `t.model("X", {...})` → `t.model` (pure property path = the function)
47
+ // `a.b.c()` → `a.b.c` (pure property path = the function)
48
+ // `arr[0].run()` → `arr[0]` (element access → the object)
49
+ // `new F(...)` / `new F({}).create()` → `new F` (construction → the class)
50
+ // `getRoot(self).store.doAction()` → `getRoot` (call in chain → the root call)
51
+ // `state` (bare identifier) → `state`
52
+ // `[1,2,3]` (array literal) → null
53
+ // The YAML can match any pattern: `origin: { equals: "t.model" }`,
54
+ // `origin: { startsWith: "new " }`, `origin: { endsWith: ".run" }`.
55
+ const leftmostOrigin = (expr) => {
56
+ let e = expr;
57
+ while (e) {
58
+ const terminal = terminalOrigin(e);
59
+ if (terminal !== null)
60
+ return terminal;
61
+ const step = inwardStep(e);
62
+ if (!step)
63
+ break;
64
+ // A call on a pure property path: the full chain IS the function name —
65
+ // `a.b.c()` is rooted at `a.b.c`, not at `a`.
66
+ if (ts_morph_1.Node.isCallExpression(e) && isPurePropertyPath(step))
67
+ return (0, tree_1.nodeText)(step);
68
+ // A property access whose base is a bare identifier answers the ACCESS
69
+ // (`a.b` → `a.b`), not the identifier alone.
70
+ if (ts_morph_1.Node.isPropertyAccessExpression(e) && step.getKind() === tree_1.SK.Identifier)
71
+ return (0, tree_1.nodeText)(e);
72
+ e = step;
73
+ }
74
+ return null;
75
+ };
76
+ exports.leftmostOrigin = leftmostOrigin;
77
+ // The rightmost member name of an expression chain: `store.doX` → "doX",
78
+ // `arr[0]` → null. null for a bare identifier (it is its own name).
79
+ const lastMemberName = (expr) => expr && ts_morph_1.Node.isPropertyAccessExpression(expr) ? expr.getName() : null;
80
+ exports.lastMemberName = lastMemberName;
81
+ // Is this expression `this.x…`? Writing there mutates the instance — the state
82
+ // of a component/service/store, in any framework.
83
+ const isThisChain = (expr) => {
84
+ let e = expr;
85
+ while (ts_morph_1.Node.isPropertyAccessExpression(e))
86
+ e = e.getExpression();
87
+ return e.getKind() === tree_1.SK.ThisKeyword;
88
+ };
89
+ exports.isThisChain = isThisChain;
90
+ // The module an expression's base identifier was imported from, if any.
91
+ const importModuleOf = (expr, importMap) => {
92
+ let base = expr;
93
+ while (ts_morph_1.Node.isPropertyAccessExpression(base))
94
+ base = base.getExpression();
95
+ if (!ts_morph_1.Node.isIdentifier(base))
96
+ return null;
97
+ return importMap?.get(base.getText()) ?? null;
98
+ };
99
+ exports.importModuleOf = importModuleOf;
100
+ // The module a MEMBER of an expression belongs to: `other.x`, `other().x`,
101
+ // `other.a.b` — the receiver is either an imported binding or the result of
102
+ // calling one (`requireRootStore().settings`). Null when the receiver is local.
103
+ const memberOwnerModule = (expr, importMap) => {
104
+ let base = expr;
105
+ while (ts_morph_1.Node.isPropertyAccessExpression(base) || ts_morph_1.Node.isElementAccessExpression(base))
106
+ base = base.getExpression();
107
+ if (ts_morph_1.Node.isIdentifier(base))
108
+ return importMap?.get(base.getText()) ?? null;
109
+ if (ts_morph_1.Node.isCallExpression(base))
110
+ return importModuleOf(base.getExpression(), importMap);
111
+ return null;
112
+ };
113
+ // Is this member access the WHOLE expression on its side — not the inner hop of
114
+ // a longer chain, not the callee of a call (that is `call`), not the target of a
115
+ // write (that is `mutate`)? Only the outermost access becomes one `read` edge;
116
+ // otherwise `store.a.b.c` would be three.
117
+ const isInnerHop = (parent, node) => {
118
+ if (ts_morph_1.Node.isPropertyAccessExpression(parent) || ts_morph_1.Node.isElementAccessExpression(parent))
119
+ return parent.getExpression() === node;
120
+ if (ts_morph_1.Node.isCallExpression(parent))
121
+ return parent.getExpression() === node;
122
+ return false;
123
+ };
124
+ const isWholeRead = (node) => {
125
+ const parent = node.getParent();
126
+ if (!parent)
127
+ return true;
128
+ // The decision ("a read when none of the write/inner-hop verdicts fires") is
129
+ // the shared gate; the verdicts are the AST's own.
130
+ const isWriteTarget = (p) => (ts_morph_1.Node.isBinaryExpression(p) && p.getLeft() === node) ||
131
+ ts_morph_1.Node.isDeleteExpression(p) ||
132
+ ((ts_morph_1.Node.isPrefixUnaryExpression(p) || ts_morph_1.Node.isPostfixUnaryExpression(p)) && p.getOperand() === node);
133
+ return (0, gate_1.admitsWhenNoneReject)(parent, [(p) => isInnerHop(p, node), isWriteTarget]);
134
+ };
135
+ // Every member of ANOTHER module this file looks at: `requireRootStore().settings`,
136
+ // `Settings.debug`, `host.workspace`. Reads are what a view does, so they are a
137
+ // relation of their own — "may read the store" is a permission an entity needs, and
138
+ // calling it a use made the permission impossible to state.
139
+ // The named declaration a node sits in — a function or a variable, the piece of
140
+ // code an entity belongs to. Null at module level, where the file itself is the
141
+ // only thing there is.
142
+ const FUNCTION_PIECE_KINDS = new Set([
143
+ tree_1.SK.FunctionDeclaration,
144
+ tree_1.SK.ArrowFunction,
145
+ tree_1.SK.FunctionExpression,
146
+ tree_1.SK.MethodDeclaration,
147
+ ]);
148
+ const enclosingPiece = (node) => {
149
+ let cur = node.getParent();
150
+ while (cur) {
151
+ const kind = cur.getKind();
152
+ if (FUNCTION_PIECE_KINDS.has(kind) || kind === tree_1.SK.VariableDeclaration) {
153
+ const name = cur.getName?.() ?? null;
154
+ if (name)
155
+ return name;
156
+ }
157
+ cur = cur.getParent?.();
158
+ }
159
+ return null;
160
+ };
161
+ exports.enclosingPiece = enclosingPiece;
162
+ const readsFact = (sf, importMap) => {
163
+ const out = [];
164
+ for (const node of sf.getDescendants()) {
165
+ if (!ts_morph_1.Node.isPropertyAccessExpression(node) && !ts_morph_1.Node.isElementAccessExpression(node))
166
+ continue;
167
+ if (!isWholeRead(node))
168
+ continue;
169
+ const module = memberOwnerModule(node, importMap);
170
+ if (!module)
171
+ continue;
172
+ out.push({ module, what: (0, tree_1.nodeText)(node), line: node.getStartLineNumber(), piece: enclosingPiece(node) });
173
+ }
174
+ return out;
175
+ };
176
+ exports.readsFact = readsFact;
@@ -0,0 +1,16 @@
1
+ import { type SourceFile, type TypeChecker, type Type } from "ts-morph";
2
+ import type { LooseNode } from "./loose";
3
+ type DeclInfo = {
4
+ kind: string;
5
+ file: string;
6
+ node: LooseNode;
7
+ };
8
+ declare const repoRelative: (file?: string | null, repoRoot?: string | null) => string | null;
9
+ declare const declaredFileOfNode: (typeNode: LooseNode | null | undefined, checker: TypeChecker, repoRoot: string) => DeclInfo | null;
10
+ declare const declaredFileOf: (param: LooseNode, checker: TypeChecker, repoRoot: string) => DeclInfo | null;
11
+ declare const declaredFileOfType: (type: Type | undefined, checker: TypeChecker, repoRoot: string) => DeclInfo | null;
12
+ declare const inRepo: (file?: string | null, repoRoot?: string | null) => boolean;
13
+ declare const declaredFileOfExpr: (expr: LooseNode | null, checker: TypeChecker, repoRoot: string, depth?: number) => DeclInfo | null;
14
+ declare const importNameModules: (sf: SourceFile, repoRoot: string, aliases?: Record<string, string>, repoFiles?: readonly string[]) => Map<string, string>;
15
+ export { importNameModules, declaredFileOfNode, declaredFileOf, declaredFileOfType, declaredFileOfExpr, repoRelative, inRepo, };
16
+ export type { DeclInfo };