@md-code/follow-architecture 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (437) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +584 -141
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +14 -0
  7. package/dist/args.js +77 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/code-roles/classify.d.ts +11 -0
  11. package/dist/code-roles/classify.js +43 -0
  12. package/dist/code-roles/connector.d.ts +5 -0
  13. package/dist/code-roles/connector.js +114 -0
  14. package/dist/code-roles/project.d.ts +12 -0
  15. package/dist/code-roles/project.js +122 -0
  16. package/dist/code-roles/roles.d.ts +8 -0
  17. package/dist/code-roles/roles.js +190 -0
  18. package/dist/config-options.d.ts +53 -0
  19. package/dist/config-options.js +35 -0
  20. package/dist/config-project.d.ts +4 -0
  21. package/dist/config-project.js +74 -0
  22. package/dist/config-report.d.ts +19 -0
  23. package/dist/config-report.js +134 -0
  24. package/dist/config-rule.d.ts +70 -0
  25. package/dist/config-rule.js +118 -0
  26. package/dist/config-state.d.ts +14 -0
  27. package/dist/config-state.js +96 -0
  28. package/dist/config.d.ts +82 -0
  29. package/dist/config.js +38 -0
  30. package/dist/css/index.d.ts +27 -0
  31. package/dist/css/index.js +140 -0
  32. package/dist/css/syntax/css/gate.d.ts +2 -0
  33. package/dist/css/syntax/css/gate.js +69 -0
  34. package/dist/css/syntax/css/index.d.ts +7 -0
  35. package/dist/css/syntax/css/index.js +41 -0
  36. package/dist/css/syntax/css/reference.d.ts +3 -0
  37. package/dist/css/syntax/css/reference.js +24 -0
  38. package/dist/css/syntax/language.d.ts +25 -0
  39. package/dist/css/syntax/language.js +69 -0
  40. package/dist/css/syntax/scss/index.d.ts +25 -0
  41. package/dist/css/syntax/scss/index.js +85 -0
  42. package/dist/css/syntax/scss/reference.d.ts +3 -0
  43. package/dist/css/syntax/scss/reference.js +11 -0
  44. package/dist/css/syntax/styled/document.d.ts +68 -0
  45. package/dist/css/syntax/styled/document.js +241 -0
  46. package/dist/css/syntax/styled/markup.d.ts +6 -0
  47. package/dist/css/syntax/styled/markup.js +76 -0
  48. package/dist/css/syntax/styled/template.d.ts +23 -0
  49. package/dist/css/syntax/styled/template.js +61 -0
  50. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  51. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  52. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  53. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  54. package/dist/css/value/check.d.ts +86 -0
  55. package/dist/css/value/check.js +122 -0
  56. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  57. package/dist/css/value/expression/arithmetic.js +69 -0
  58. package/dist/css/value/expression/block.d.ts +9 -0
  59. package/dist/css/value/expression/block.js +91 -0
  60. package/dist/css/value/expression/conditional.d.ts +8 -0
  61. package/dist/css/value/expression/conditional.js +53 -0
  62. package/dist/css/value/expression/index.d.ts +5 -0
  63. package/dist/css/value/expression/index.js +69 -0
  64. package/dist/css/value/expression/map.d.ts +7 -0
  65. package/dist/css/value/expression/map.js +113 -0
  66. package/dist/css/value/object/index.d.ts +5 -0
  67. package/dist/css/value/object/index.js +103 -0
  68. package/dist/css/value/object/members.d.ts +7 -0
  69. package/dist/css/value/object/members.js +103 -0
  70. package/dist/css/value/object/node.d.ts +8 -0
  71. package/dist/css/value/object/node.js +129 -0
  72. package/dist/css/value/object/path.d.ts +10 -0
  73. package/dist/css/value/object/path.js +146 -0
  74. package/dist/css/value/pieces.d.ts +61 -0
  75. package/dist/css/value/pieces.js +55 -0
  76. package/dist/css/value/resolve.d.ts +33 -0
  77. package/dist/css/value/resolve.js +94 -0
  78. package/dist/css/value/scope.d.ts +27 -0
  79. package/dist/css/value/scope.js +187 -0
  80. package/dist/css/value/substitute.d.ts +10 -0
  81. package/dist/css/value/substitute.js +113 -0
  82. package/dist/css/value/values.d.ts +23 -0
  83. package/dist/css/value/values.js +131 -0
  84. package/dist/entities/architecture.d.ts +162 -0
  85. package/dist/entities/architecture.js +2 -0
  86. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  87. package/dist/entities/ast/assignments-nodes.js +64 -0
  88. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  89. package/dist/entities/ast/assignments-raw.js +86 -0
  90. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  91. package/dist/entities/ast/assignments-tagged.js +180 -0
  92. package/dist/entities/ast/assignments.d.ts +9 -0
  93. package/dist/entities/ast/assignments.js +78 -0
  94. package/dist/entities/ast/branches.d.ts +4 -0
  95. package/dist/entities/ast/branches.js +32 -0
  96. package/dist/entities/ast/calls.d.ts +6 -0
  97. package/dist/entities/ast/calls.js +134 -0
  98. package/dist/entities/ast/classes.d.ts +5 -0
  99. package/dist/entities/ast/classes.js +57 -0
  100. package/dist/entities/ast/climb.d.ts +12 -0
  101. package/dist/entities/ast/climb.js +17 -0
  102. package/dist/entities/ast/comments.d.ts +4 -0
  103. package/dist/entities/ast/comments.js +100 -0
  104. package/dist/entities/ast/declaration.d.ts +4 -0
  105. package/dist/entities/ast/declaration.js +26 -0
  106. package/dist/entities/ast/depth.d.ts +17 -0
  107. package/dist/entities/ast/depth.js +149 -0
  108. package/dist/entities/ast/enums.d.ts +6 -0
  109. package/dist/entities/ast/enums.js +17 -0
  110. package/dist/entities/ast/file-exports.d.ts +7 -0
  111. package/dist/entities/ast/file-exports.js +78 -0
  112. package/dist/entities/ast/file-facts.d.ts +13 -0
  113. package/dist/entities/ast/file-facts.js +35 -0
  114. package/dist/entities/ast/file-imports.d.ts +5 -0
  115. package/dist/entities/ast/file-imports.js +77 -0
  116. package/dist/entities/ast/file.d.ts +5 -0
  117. package/dist/entities/ast/file.js +22 -0
  118. package/dist/entities/ast/functions.d.ts +8 -0
  119. package/dist/entities/ast/functions.js +102 -0
  120. package/dist/entities/ast/heritage.d.ts +4 -0
  121. package/dist/entities/ast/heritage.js +36 -0
  122. package/dist/entities/ast/index.d.ts +6 -0
  123. package/dist/entities/ast/index.js +125 -0
  124. package/dist/entities/ast/kind.d.ts +5 -0
  125. package/dist/entities/ast/kind.js +28 -0
  126. package/dist/entities/ast/loose.d.ts +37 -0
  127. package/dist/entities/ast/loose.js +2 -0
  128. package/dist/entities/ast/modifiers.d.ts +5 -0
  129. package/dist/entities/ast/modifiers.js +32 -0
  130. package/dist/entities/ast/project.d.ts +9 -0
  131. package/dist/entities/ast/project.js +75 -0
  132. package/dist/entities/ast/properties.d.ts +11 -0
  133. package/dist/entities/ast/properties.js +171 -0
  134. package/dist/entities/ast/resolve.d.ts +16 -0
  135. package/dist/entities/ast/resolve.js +307 -0
  136. package/dist/entities/ast/tree.d.ts +29 -0
  137. package/dist/entities/ast/tree.js +351 -0
  138. package/dist/entities/ast/types.d.ts +6 -0
  139. package/dist/entities/ast/types.js +45 -0
  140. package/dist/entities/ast/usage.d.ts +11 -0
  141. package/dist/entities/ast/usage.js +81 -0
  142. package/dist/entities/ast/variables.d.ts +8 -0
  143. package/dist/entities/ast/variables.js +91 -0
  144. package/dist/entities/context.d.ts +29 -0
  145. package/dist/entities/context.js +2 -0
  146. package/dist/entities/facts.d.ts +261 -0
  147. package/dist/entities/facts.js +2 -0
  148. package/dist/entities/findings.d.ts +19 -0
  149. package/dist/entities/findings.js +2 -0
  150. package/dist/entities/kinds.d.ts +40 -0
  151. package/dist/entities/kinds.js +221 -0
  152. package/dist/entities/location/homes.d.ts +28 -0
  153. package/dist/entities/location/homes.js +169 -0
  154. package/dist/entities/location/place.d.ts +10 -0
  155. package/dist/entities/location/place.js +56 -0
  156. package/dist/entities/location/where.d.ts +17 -0
  157. package/dist/entities/location/where.js +218 -0
  158. package/dist/entities/location.d.ts +16 -0
  159. package/dist/entities/location.js +140 -0
  160. package/dist/entities/operators.d.ts +14 -0
  161. package/dist/entities/operators.js +30 -0
  162. package/dist/entities/overview/data.d.ts +43 -0
  163. package/dist/entities/overview/data.js +2 -0
  164. package/dist/entities/overview/decision.d.ts +60 -0
  165. package/dist/entities/overview/decision.js +2 -0
  166. package/dist/entities/overview/file-tree.d.ts +10 -0
  167. package/dist/entities/overview/file-tree.js +2 -0
  168. package/dist/entities/overview/finding.d.ts +58 -0
  169. package/dist/entities/overview/finding.js +2 -0
  170. package/dist/entities/overview/graph.d.ts +65 -0
  171. package/dist/entities/overview/graph.js +2 -0
  172. package/dist/entities/overview/input.d.ts +15 -0
  173. package/dist/entities/overview/input.js +2 -0
  174. package/dist/entities/overview/summaries.d.ts +79 -0
  175. package/dist/entities/overview/summaries.js +2 -0
  176. package/dist/entities/place.d.ts +5 -0
  177. package/dist/entities/place.js +2 -0
  178. package/dist/entities/queries.d.ts +9 -0
  179. package/dist/entities/queries.js +305 -0
  180. package/dist/entities/repair.d.ts +16 -0
  181. package/dist/entities/repair.js +23 -0
  182. package/dist/entities/schema.d.ts +8 -0
  183. package/dist/entities/schema.js +23 -0
  184. package/dist/entities/story.d.ts +47 -0
  185. package/dist/entities/story.js +2 -0
  186. package/dist/entities/structure-facts.d.ts +11 -0
  187. package/dist/entities/structure-facts.js +2 -0
  188. package/dist/entities/token.d.ts +23 -0
  189. package/dist/entities/token.js +2 -0
  190. package/dist/entities/tree/build.d.ts +5 -0
  191. package/dist/entities/tree/build.js +252 -0
  192. package/dist/entities/tree/entries.d.ts +7 -0
  193. package/dist/entities/tree/entries.js +120 -0
  194. package/dist/entities/tree/index.d.ts +6 -0
  195. package/dist/entities/tree/index.js +21 -0
  196. package/dist/entities/tree/match.d.ts +17 -0
  197. package/dist/entities/tree/match.js +176 -0
  198. package/dist/frameworks/angular/index.d.ts +7 -0
  199. package/dist/frameworks/angular/index.js +17 -0
  200. package/dist/frameworks/facet.d.ts +16 -0
  201. package/dist/frameworks/facet.js +2 -0
  202. package/dist/frameworks/index.d.ts +9 -0
  203. package/dist/frameworks/index.js +120 -0
  204. package/dist/frameworks/react/index.d.ts +7 -0
  205. package/dist/frameworks/react/index.js +214 -0
  206. package/dist/frameworks/vue/index.d.ts +7 -0
  207. package/dist/frameworks/vue/index.js +17 -0
  208. package/dist/invariants/index.d.ts +6 -0
  209. package/dist/invariants/index.js +299 -0
  210. package/dist/invariants/list-vars.d.ts +5 -0
  211. package/dist/invariants/list-vars.js +143 -0
  212. package/dist/invariants/name.d.ts +16 -0
  213. package/dist/invariants/name.js +18 -0
  214. package/dist/invariants/normalize.d.ts +4 -0
  215. package/dist/invariants/normalize.js +95 -0
  216. package/dist/invariants/vars.d.ts +20 -0
  217. package/dist/invariants/vars.js +117 -0
  218. package/dist/main.d.ts +7 -0
  219. package/dist/main.js +229 -0
  220. package/dist/nodes/child-roles.d.ts +3 -0
  221. package/dist/nodes/child-roles.js +12 -0
  222. package/dist/nodes/children.d.ts +25 -0
  223. package/dist/nodes/children.js +112 -0
  224. package/dist/nodes/finally/emit.d.ts +6 -0
  225. package/dist/nodes/finally/emit.js +55 -0
  226. package/dist/nodes/finally/index.d.ts +8 -0
  227. package/dist/nodes/finally/index.js +35 -0
  228. package/dist/nodes/finally/queries.d.ts +5 -0
  229. package/dist/nodes/finally/queries.js +22 -0
  230. package/dist/nodes/finally/relations-access.d.ts +5 -0
  231. package/dist/nodes/finally/relations-access.js +46 -0
  232. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  233. package/dist/nodes/finally/relations-edge.js +125 -0
  234. package/dist/nodes/finally/relations-group.d.ts +31 -0
  235. package/dist/nodes/finally/relations-group.js +103 -0
  236. package/dist/nodes/finally/relations.d.ts +5 -0
  237. package/dist/nodes/finally/relations.js +81 -0
  238. package/dist/nodes/finally/required.d.ts +5 -0
  239. package/dist/nodes/finally/required.js +90 -0
  240. package/dist/nodes/finally/roles.d.ts +13 -0
  241. package/dist/nodes/finally/roles.js +41 -0
  242. package/dist/nodes/finally/violation.d.ts +17 -0
  243. package/dist/nodes/finally/violation.js +2 -0
  244. package/dist/nodes/similar.d.ts +21 -0
  245. package/dist/nodes/similar.js +156 -0
  246. package/dist/pipeline-facts.d.ts +11 -0
  247. package/dist/pipeline-facts.js +112 -0
  248. package/dist/pipeline-roles.d.ts +6 -0
  249. package/dist/pipeline-roles.js +75 -0
  250. package/dist/pipeline-unroled.d.ts +14 -0
  251. package/dist/pipeline-unroled.js +193 -0
  252. package/dist/pipeline.d.ts +7 -0
  253. package/dist/pipeline.js +73 -0
  254. package/dist/plugin.d.ts +2 -0
  255. package/dist/plugin.js +3 -0
  256. package/dist/report/asks.d.ts +55 -0
  257. package/dist/report/asks.js +50 -0
  258. package/dist/report/cli-report.d.ts +2 -0
  259. package/dist/report/cli-report.js +13 -0
  260. package/dist/report/config-error-guard.d.ts +8 -0
  261. package/dist/report/config-error-guard.js +5 -0
  262. package/dist/report/configErrors.d.ts +98 -0
  263. package/dist/report/configErrors.js +75 -0
  264. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  265. package/dist/report/errorTypes/codes/structure.js +76 -0
  266. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  267. package/dist/report/errorTypes/decision-maker.js +99 -0
  268. package/dist/report/errorTypes/destinations.d.ts +38 -0
  269. package/dist/report/errorTypes/destinations.js +147 -0
  270. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  271. package/dist/report/errorTypes/finding-type.js +2 -0
  272. package/dist/report/errorTypes/index.d.ts +15 -0
  273. package/dist/report/errorTypes/index.js +45 -0
  274. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  275. package/dist/report/errorTypes/types/fileContents.js +34 -0
  276. package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
  277. package/dist/report/errorTypes/types/unknownRole.js +22 -0
  278. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  279. package/dist/report/errorTypes/types/wrongAction.js +135 -0
  280. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  281. package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
  282. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  283. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  284. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  285. package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
  286. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  287. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  288. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  289. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  290. package/dist/report/finding-from.d.ts +9 -0
  291. package/dist/report/finding-from.js +103 -0
  292. package/dist/report/notices.d.ts +4 -0
  293. package/dist/report/notices.js +31 -0
  294. package/dist/report/render-report.d.ts +12 -0
  295. package/dist/report/render-report.js +142 -0
  296. package/dist/report/user-report/build/bundle.d.ts +3 -0
  297. package/dist/report/user-report/build/bundle.js +169 -0
  298. package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
  299. package/dist/report/user-report/data/collect.d.ts +4 -0
  300. package/dist/report/user-report/data/collect.js +80 -0
  301. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  302. package/dist/report/user-report/data/file-tree.js +72 -0
  303. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  304. package/dist/report/user-report/data/finding-boundary.js +21 -0
  305. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  306. package/dist/report/user-report/data/finding-plan.js +45 -0
  307. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  308. package/dist/report/user-report/data/finding-title.js +36 -0
  309. package/dist/report/user-report/data/findings.d.ts +10 -0
  310. package/dist/report/user-report/data/findings.js +171 -0
  311. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  312. package/dist/report/user-report/data/graph-edges.js +109 -0
  313. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  314. package/dist/report/user-report/data/graph-helpers.js +67 -0
  315. package/dist/report/user-report/data/graph-roles.d.ts +5 -0
  316. package/dist/report/user-report/data/graph-roles.js +71 -0
  317. package/dist/report/user-report/data/graph.d.ts +11 -0
  318. package/dist/report/user-report/data/graph.js +90 -0
  319. package/dist/report/user-report/data/invariants.d.ts +7 -0
  320. package/dist/report/user-report/data/invariants.js +62 -0
  321. package/dist/report/user-report/data/nodes.d.ts +11 -0
  322. package/dist/report/user-report/data/nodes.js +106 -0
  323. package/dist/report/user-report/data/role-examples.d.ts +16 -0
  324. package/dist/report/user-report/data/role-examples.js +94 -0
  325. package/dist/report/user-report/data/role-filters.d.ts +15 -0
  326. package/dist/report/user-report/data/role-filters.js +79 -0
  327. package/dist/report/user-report/data/role-marks.d.ts +5 -0
  328. package/dist/report/user-report/data/role-marks.js +79 -0
  329. package/dist/report/user-report/data/roles.d.ts +7 -0
  330. package/dist/report/user-report/data/roles.js +83 -0
  331. package/dist/report/user-report/data/scan.d.ts +8 -0
  332. package/dist/report/user-report/data/scan.js +59 -0
  333. package/dist/report/user-report/html/shell.d.ts +3 -0
  334. package/dist/report/user-report/html/shell.js +27 -0
  335. package/dist/report/user-report/index.d.ts +8 -0
  336. package/dist/report/user-report/index.js +48 -0
  337. package/dist/report/user-report/shared/describe.d.ts +7 -0
  338. package/dist/report/user-report/shared/describe.js +86 -0
  339. package/dist/scripts/audit-report.d.ts +2 -0
  340. package/dist/scripts/audit-report.js +147 -0
  341. package/dist/utils/accumulate.d.ts +6 -0
  342. package/dist/utils/accumulate.js +18 -0
  343. package/dist/utils/article.d.ts +2 -0
  344. package/dist/utils/article.js +12 -0
  345. package/dist/utils/classify.d.ts +12 -0
  346. package/dist/utils/classify.js +25 -0
  347. package/dist/utils/configs.d.ts +25 -0
  348. package/dist/utils/configs.js +87 -0
  349. package/dist/utils/count.d.ts +7 -0
  350. package/dist/utils/count.js +13 -0
  351. package/dist/utils/dispatch.d.ts +2 -0
  352. package/dist/utils/dispatch.js +27 -0
  353. package/dist/utils/distinct.d.ts +2 -0
  354. package/dist/utils/distinct.js +12 -0
  355. package/dist/utils/field.d.ts +14 -0
  356. package/dist/utils/field.js +60 -0
  357. package/dist/utils/file-name.d.ts +2 -0
  358. package/dist/utils/file-name.js +11 -0
  359. package/dist/utils/files.d.ts +7 -0
  360. package/dist/utils/files.js +73 -0
  361. package/dist/utils/fixpoint.d.ts +2 -0
  362. package/dist/utils/fixpoint.js +19 -0
  363. package/dist/utils/gate.d.ts +2 -0
  364. package/dist/utils/gate.js +12 -0
  365. package/dist/utils/group.d.ts +3 -0
  366. package/dist/utils/group.js +33 -0
  367. package/dist/utils/host.d.ts +3 -0
  368. package/dist/utils/host.js +13 -0
  369. package/dist/utils/imports.d.ts +12 -0
  370. package/dist/utils/imports.js +121 -0
  371. package/dist/utils/judged.d.ts +5 -0
  372. package/dist/utils/judged.js +19 -0
  373. package/dist/utils/keyed.d.ts +2 -0
  374. package/dist/utils/keyed.js +23 -0
  375. package/dist/utils/map-record.d.ts +2 -0
  376. package/dist/utils/map-record.js +11 -0
  377. package/dist/utils/path-label.d.ts +6 -0
  378. package/dist/utils/path-label.js +35 -0
  379. package/dist/utils/pattern.d.ts +18 -0
  380. package/dist/utils/pattern.js +191 -0
  381. package/dist/utils/permission.d.ts +16 -0
  382. package/dist/utils/permission.js +16 -0
  383. package/dist/utils/plural.d.ts +2 -0
  384. package/dist/utils/plural.js +9 -0
  385. package/dist/utils/qualified.d.ts +2 -0
  386. package/dist/utils/qualified.js +21 -0
  387. package/dist/utils/rank.d.ts +2 -0
  388. package/dist/utils/rank.js +24 -0
  389. package/dist/utils/read-field.d.ts +12 -0
  390. package/dist/utils/read-field.js +50 -0
  391. package/dist/utils/read-when.d.ts +2 -0
  392. package/dist/utils/read-when.js +17 -0
  393. package/dist/utils/reason.d.ts +4 -0
  394. package/dist/utils/reason.js +9 -0
  395. package/dist/utils/record.d.ts +3 -0
  396. package/dist/utils/record.js +21 -0
  397. package/dist/utils/resolve.d.ts +2 -0
  398. package/dist/utils/resolve.js +24 -0
  399. package/dist/utils/search.d.ts +2 -0
  400. package/dist/utils/search.js +16 -0
  401. package/dist/utils/seen.d.ts +6 -0
  402. package/dist/utils/seen.js +27 -0
  403. package/dist/utils/span.d.ts +5 -0
  404. package/dist/utils/span.js +2 -0
  405. package/dist/utils/speak.d.ts +2 -0
  406. package/dist/utils/speak.js +18 -0
  407. package/dist/utils/split.d.ts +8 -0
  408. package/dist/utils/split.js +8 -0
  409. package/dist/utils/template.d.ts +5 -0
  410. package/dist/utils/template.js +5 -0
  411. package/dist/utils/text.d.ts +4 -0
  412. package/dist/utils/text.js +42 -0
  413. package/dist/utils/tokenize.d.ts +2 -0
  414. package/dist/utils/tokenize.js +13 -0
  415. package/dist/utils/try-read.d.ts +4 -0
  416. package/dist/utils/try-read.js +24 -0
  417. package/dist/utils/typed-field.d.ts +3 -0
  418. package/dist/utils/typed-field.js +16 -0
  419. package/dist/utils/verdicts.d.ts +4 -0
  420. package/dist/utils/verdicts.js +20 -0
  421. package/entities/operators.ts +31 -0
  422. package/package.json +61 -18
  423. package/report/errorTypes/vocabulary/ids.ts +12 -0
  424. package/report/errorTypes/vocabulary/phrases.ts +161 -0
  425. package/report/errorTypes/vocabulary/places.ts +46 -0
  426. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  427. package/report/user-report/shared/describe.ts +107 -0
  428. package/ast.js +0 -107
  429. package/bin/follow-architecture.js +0 -6
  430. package/config.js +0 -101
  431. package/entities/aliases.js +0 -10
  432. package/entities/invariants.js +0 -134
  433. package/entities/nodes.js +0 -112
  434. package/main.js +0 -96
  435. package/plugin.js +0 -5
  436. package/report.js +0 -73
  437. package/utils.js +0 -104
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.judgedItems = void 0;
4
+ // A JUDGED ITEM is one mechanism: a list of items is walked, each is judged,
5
+ // and only the ones that earn a verdict are kept — the rest are silent. The
6
+ // relation check judges every edge of a fact kind and groups the refusals
7
+ // (`nodes/finally/relations`); any consumer that filters a list by a verdict
8
+ // asks the same question. The walk is the same — judge, keep the answered —
9
+ // so it lives here once. What a verdict IS is the caller's own.
10
+ const judgedItems = (items, judge) => {
11
+ const out = [];
12
+ for (const item of items) {
13
+ const verdict = judge(item);
14
+ if (verdict != null)
15
+ out.push({ item, verdict });
16
+ }
17
+ return out;
18
+ };
19
+ exports.judgedItems = judgedItems;
@@ -0,0 +1,2 @@
1
+ declare const keyedDefs: <T>(section: readonly T[] | Record<string, T> | null | undefined) => (T | null)[];
2
+ export { keyedDefs };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.keyedDefs = void 0;
4
+ // A KEYED SECTION is one mechanism: the YAML may write a section as a LIST of
5
+ // `{ slug, … }` entries or as a MAP keyed by slug, and both spellings describe
6
+ // the same defs. The nodes section reads it one way (`entities/tree/build`),
7
+ // the codeRoles section the same way (`code-roles/roles`) — so the walk lives
8
+ // here once: a list is itself; a map's entries take their key as the slug when
9
+ // the entry does not name one. What a def IS and what is validated afterwards
10
+ // is the caller's own; nothing here knows nodes or roles.
11
+ const field_1 = require("./field");
12
+ // The defs a list-or-map section declares, in declared order. The caller's def
13
+ // type `T` flows through untouched; a map value that is not a record is kept
14
+ // as-is (null) — the caller's validation names it.
15
+ const isListSection = (section) => Array.isArray(section);
16
+ const keyedDefs = (section) => {
17
+ if (section == null)
18
+ return [];
19
+ if (isListSection(section))
20
+ return [...section];
21
+ return Object.entries(section).map(([k, v]) => ((0, field_1.isObj)(v) ? { ...v, slug: v.slug ?? k } : null));
22
+ };
23
+ exports.keyedDefs = keyedDefs;
@@ -0,0 +1,2 @@
1
+ declare const mapRecord: <Value, Answer>(record: Record<string, Value>, read: (key: string, value: Value) => Answer) => Record<string, Answer>;
2
+ export { mapRecord };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapRecord = void 0;
4
+ // A MAPPED RECORD is one mechanism: a record's entries are each read into a
5
+ // value, and the answers are collected under the same keys. The aliases
6
+ // section maps each name to a normalized path (`aliases`); a role's actions
7
+ // map each kind to its normalized action (`code-roles/roles`). The walk is the
8
+ // same — read each entry, keep the key — so it lives here once. What an entry
9
+ // IS and how it is read is the caller's own.
10
+ const mapRecord = (record, read) => Object.fromEntries(Object.entries(record).map(([k, v]) => [k, read(k, v)]));
11
+ exports.mapRecord = mapRecord;
@@ -0,0 +1,6 @@
1
+ declare const pathTemplate: (paths: readonly (string | null | undefined)[] | null | undefined) => string;
2
+ declare const tailPath: (template: string | null | undefined, keep?: number) => string;
3
+ declare const nodeLabel: (node: {
4
+ paths?: readonly (string | null | undefined)[] | null;
5
+ } | null | undefined, keep?: number) => string;
6
+ export { pathTemplate, tailPath, nodeLabel };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nodeLabel = exports.tailPath = exports.pathTemplate = void 0;
4
+ // A PATH LABEL is one mechanism: a node's path(s) read as the shortest string
5
+ // that still says WHERE it is. A node that fans out over several parents reads
6
+ // as a template (`apps/backend/*/store.ts`); the label keeps the last N
7
+ // segments. The browser labels boxes / cards / badges (`utils/format`); any
8
+ // consumer that names a place asks the same question. The walk lives here once.
9
+ // One label for a node's path(s): a template when the node fans out over
10
+ // several parents, otherwise the path itself.
11
+ const pathTemplate = (paths) => {
12
+ const list = (paths ?? []).filter((p) => Boolean(p));
13
+ if (!list.length)
14
+ return "";
15
+ if (list.length === 1)
16
+ return list[0];
17
+ const split = list.map((p) => p.split("/"));
18
+ const len = Math.max(...split.map((p) => p.length));
19
+ const out = [];
20
+ for (let i = 0; i < len; i += 1) {
21
+ const seg = split[0][i];
22
+ out.push(split.every((p) => p[i] === seg) ? seg : "*");
23
+ }
24
+ return out.join("/");
25
+ };
26
+ exports.pathTemplate = pathTemplate;
27
+ // Shortest label that still says WHERE it is: the last N path segments.
28
+ const tailPath = (template, keep = 2) => {
29
+ const segs = String(template ?? "").split("/").filter(Boolean);
30
+ return segs.length <= keep ? segs.join("/") : segs.slice(-keep).join("/");
31
+ };
32
+ exports.tailPath = tailPath;
33
+ // The label for a node-like `{ paths }`: its template, shortened to the tail.
34
+ const nodeLabel = (node, keep = 2) => tailPath(pathTemplate(node?.paths), keep);
35
+ exports.nodeLabel = nodeLabel;
@@ -0,0 +1,18 @@
1
+ declare const DEFAULT_IGNORE_DIRS: string[];
2
+ declare const DEFAULT_SIMILARITY = 0.6;
3
+ declare const DEFAULT_EXTS: string[];
4
+ declare const expandBraces: (s: string) => string[];
5
+ declare const globToRegex: (glob: string) => string;
6
+ declare const conventionOf: (name: string) => string | null;
7
+ declare const placeholderRe: (n: string) => string;
8
+ declare const PLACEHOLDER: RegExp;
9
+ declare const patternBody: (pattern: string) => {
10
+ body: string;
11
+ names: string[];
12
+ };
13
+ declare const compilePattern: (pattern: string) => {
14
+ re: RegExp;
15
+ names: string[];
16
+ };
17
+ declare const checkRegex: (p: string, where: string) => void;
18
+ export { DEFAULT_EXTS, DEFAULT_SIMILARITY, DEFAULT_IGNORE_DIRS, globToRegex, conventionOf, placeholderRe, compilePattern, patternBody, PLACEHOLDER, expandBraces, checkRegex };
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.checkRegex = exports.expandBraces = exports.PLACEHOLDER = exports.patternBody = exports.compilePattern = exports.placeholderRe = exports.conventionOf = exports.globToRegex = exports.DEFAULT_IGNORE_DIRS = exports.DEFAULT_SIMILARITY = exports.DEFAULT_EXTS = void 0;
27
+ const configError = __importStar(require("../report/configErrors"));
28
+ // Glob → regex and the naming-convention placeholder machinery shared by
29
+ // every entity that matches file paths (nodes, invariants, fileSpecs).
30
+ // Directories that never contain source code. A repo may add more via `ignoreDirs`.
31
+ const DEFAULT_IGNORE_DIRS = ["node_modules", ".git", ".vscode-test", "out", "dist", "build", "coverage"];
32
+ exports.DEFAULT_IGNORE_DIRS = DEFAULT_IGNORE_DIRS;
33
+ // Source extensions the TOOL scans by default. Scan scope is a tool concern, not
34
+ // architecture (the yaml must not carry it) — and it is an option, not a fact of
35
+ // the tool's code: `--ext <ext>` / the rule's `exts` add to this list.
36
+ // How much a folder has to look like a declared entity before a rule may offer it
37
+ // as a destination (see nodes/similar.js). A rule option; this is the default.
38
+ const DEFAULT_SIMILARITY = 0.6;
39
+ exports.DEFAULT_SIMILARITY = DEFAULT_SIMILARITY;
40
+ const DEFAULT_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".vue", ".svelte"];
41
+ exports.DEFAULT_EXTS = DEFAULT_EXTS;
42
+ // Brace expansion: `{a,b,c}` → alternation of the alternatives. Nested
43
+ // braces are not supported (no architecture needs them).
44
+ const expandBraces = (s) => {
45
+ const open = s.indexOf("{");
46
+ if (open === -1)
47
+ return [s];
48
+ const close = s.indexOf("}", open);
49
+ if (close === -1)
50
+ return [s];
51
+ const prefix = s.slice(0, open);
52
+ const suffix = s.slice(close + 1);
53
+ const parts = s
54
+ .slice(open + 1, close)
55
+ .split(",")
56
+ .map((p) => p.trim());
57
+ const out = [];
58
+ for (const p of parts)
59
+ for (const rest of expandBraces(prefix + p + suffix))
60
+ out.push(rest);
61
+ return out;
62
+ };
63
+ exports.expandBraces = expandBraces;
64
+ const braceToken = (glob, i) => {
65
+ if (glob[i] !== "{")
66
+ return null;
67
+ const close = glob.indexOf("}", i);
68
+ if (close === -1)
69
+ return null;
70
+ const alts = expandBraces(glob.slice(i, close + 1)).map((a) => globToRegex(a));
71
+ return { text: alts.length > 1 ? `(?:${alts.join("|")})` : alts[0], next: close };
72
+ };
73
+ const globToken = (glob, i) => {
74
+ const c = glob[i];
75
+ if (glob.startsWith("**/", i))
76
+ return { text: "(?:.*/)?", advance: 3 };
77
+ if (glob.startsWith("**", i))
78
+ return { text: ".*", advance: 2 };
79
+ if (c === "*")
80
+ return { text: "[^/]*", advance: 1 };
81
+ if (c === "?")
82
+ return { text: "[^/]", advance: 1 };
83
+ if ("\\.+^$|()[]".includes(c))
84
+ return { text: `\\${c}`, advance: 1 };
85
+ return { text: c, advance: 1 };
86
+ };
87
+ const globToRegex = (glob) => {
88
+ let out = "";
89
+ for (let i = 0; i < glob.length;) {
90
+ const brace = braceToken(glob, i);
91
+ if (brace) {
92
+ out += brace.text;
93
+ i = brace.next + 1;
94
+ continue;
95
+ }
96
+ const tok = globToken(glob, i);
97
+ out += tok.text;
98
+ i += tok.advance;
99
+ }
100
+ return out;
101
+ };
102
+ exports.globToRegex = globToRegex;
103
+ // A placeholder is written IN the convention it asks for, so the convention is
104
+ // read off the name itself: `{kebab-case}` is kebab because it is spelled in
105
+ // kebab, and `{feature-name}` means the same thing for the same reason. There is
106
+ // no list of known conventions to keep in sync — add `{UPPER_CASE}`,
107
+ // `{snake_case}`, `{myCase}`, `{PascalCase}` and they all compile.
108
+ const CASES = {
109
+ // lowercase, joined by dashes: `feature-name`
110
+ kebab: "[a-z0-9]+(?:-[a-z0-9]+)*",
111
+ // lowercase, joined by underscores: `feature_name`
112
+ snake: "[a-z0-9]+(?:_[a-z0-9]+)*",
113
+ // uppercase, joined by underscores: `FEATURE_NAME`
114
+ screaming: "[A-Z0-9]+(?:_[A-Z0-9]+)*",
115
+ // uppercase, joined by dashes: `FEATURE-NAME`
116
+ screamingKebab: "[A-Z0-9]+(?:-[A-Z0-9]+)*",
117
+ // one lowercase word, then capitals: `featureName`
118
+ camel: "[a-z][a-zA-Z0-9]*",
119
+ // a capitalised word: `FeatureName`, and `NAME`
120
+ pascal: "[A-Z][a-zA-Z0-9]*",
121
+ };
122
+ const allMatch = (words, re) => words.length > 0 && words.every((w) => re.test(w));
123
+ // The convention a placeholder NAME states, or null when it states none (a
124
+ // single word with mixed case, a digit-only name, anything unrecognised) — then
125
+ // the placeholder still captures, it just enforces nothing.
126
+ const underscoreConvention = (words) => {
127
+ if (allMatch(words, /^[A-Z0-9]+$/))
128
+ return CASES.screaming;
129
+ if (allMatch(words, /^[a-z0-9]+$/))
130
+ return CASES.snake;
131
+ return null;
132
+ };
133
+ const dashConvention = (words) => {
134
+ if (allMatch(words, /^[a-z0-9]+$/))
135
+ return CASES.kebab;
136
+ if (allMatch(words, /^[A-Z0-9]+$/))
137
+ return CASES.screamingKebab;
138
+ return null;
139
+ };
140
+ const conventionOf = (name) => {
141
+ if (name.includes("_"))
142
+ return underscoreConvention(name.split("_"));
143
+ if (name.includes("-"))
144
+ return dashConvention(name.split("-"));
145
+ if (/^[A-Z0-9]+$/.test(name))
146
+ return CASES.pascal; // `NAME`, `ID2`
147
+ if (/^[a-z0-9]+$/.test(name))
148
+ return CASES.kebab; // `name` — kebab, snake and camel of one word agree
149
+ if (/^[a-z][a-zA-Z0-9]*$/.test(name))
150
+ return CASES.camel; // `featureName`
151
+ if (/^[A-Za-z0-9]+$/.test(name))
152
+ return CASES.pascal; // `FeatureName`
153
+ return null;
154
+ };
155
+ exports.conventionOf = conventionOf;
156
+ const placeholderRe = (n) => conventionOf(n) ?? "[^/]+";
157
+ exports.placeholderRe = placeholderRe;
158
+ // What a placeholder looks like inside a path template: `{kebab-case}`,
159
+ // `{camelCase}`, `{UPPER_CASE}`, `{anything-you-like}`.
160
+ const PLACEHOLDER = /\{([A-Za-z][A-Za-z0-9_-]*)\}/g;
161
+ exports.PLACEHOLDER = PLACEHOLDER;
162
+ // The regex BODY a path template compiles to, plus the placeholder names it
163
+ // captured — the ONE implementation of "placeholders inside a glob", shared by
164
+ // patterns, node paths and node children. A placeholder is swapped for a sentinel
165
+ // before the glob is compiled so its own characters survive, then put back as a
166
+ // capture group of the convention it asks for.
167
+ const patternBody = (pattern) => {
168
+ const names = [];
169
+ const glob = String(pattern).replace(/\\/g, "/").replace(PLACEHOLDER, (_, n) => {
170
+ names.push(n);
171
+ return `\u0000${n}\u0000`;
172
+ });
173
+ const body = globToRegex(glob).replace(/\u0000([A-Za-z][A-Za-z0-9_-]*)\u0000/g, (_, n) => `(${placeholderRe(n)})`);
174
+ return { body, names };
175
+ };
176
+ exports.patternBody = patternBody;
177
+ const compilePattern = (pattern) => {
178
+ const { body, names } = patternBody(pattern);
179
+ return { re: new RegExp(`^${body}$`), names };
180
+ };
181
+ exports.compilePattern = compilePattern;
182
+ const checkRegex = (p, where) => {
183
+ try {
184
+ new RegExp(p);
185
+ }
186
+ catch (err) {
187
+ const e = err;
188
+ throw configError.invalidPattern({ where, pattern: p, reason: e.message ?? String(e) });
189
+ }
190
+ };
191
+ exports.checkRegex = checkRegex;
@@ -0,0 +1,16 @@
1
+ import type { Arch, ActionDef } from "../entities/architecture";
2
+ import type { FileFacts } from "../entities/facts";
3
+ import type { Caps } from "../entities/location/where";
4
+ type Permission = {
5
+ allowed: boolean;
6
+ denied: boolean;
7
+ };
8
+ type PermissionAsk = {
9
+ rel: string;
10
+ arch: Arch;
11
+ scope: FileFacts | null | undefined;
12
+ caps: Caps | null;
13
+ };
14
+ declare const permissionOf: (action: ActionDef, ask: PermissionAsk) => Permission;
15
+ export { permissionOf };
16
+ export type { Permission };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.permissionOf = void 0;
4
+ // A PERMISSION is one mechanism: an action's `where` says who may do it, and
5
+ // its `except` says when that allowance stops. The relation check asks it of
6
+ // one edge (`nodes/finally/relations-edge`); any consumer that judges an act
7
+ // against a declared allowance asks the same two questions. The walk — allow
8
+ // when some `where` entry admits, then refuse when some `except` entry admits —
9
+ // lives here once. What the entries MEAN is the shared `where` grammar's own.
10
+ const location_1 = require("../entities/location");
11
+ const permissionOf = (action, ask) => {
12
+ const allowed = !(0, location_1.checkWhere)(action.where, ask.rel, ask.arch, ask.scope, ask.caps);
13
+ const denied = (action.except ?? []).length ? !(0, location_1.checkWhere)(action.except, ask.rel, ask.arch, ask.scope, ask.caps) : false;
14
+ return { allowed, denied };
15
+ };
16
+ exports.permissionOf = permissionOf;
@@ -0,0 +1,2 @@
1
+ declare const plural: (n: number, one: string, many?: string) => string;
2
+ export { plural };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.plural = void 0;
4
+ // A PLURAL is one mechanism: a count read as "1 thing" / "N things". The browser
5
+ // counts roles / rules / matches (`utils/format`); any consumer that names a
6
+ // count asks the same question. The irregular plural is the caller's own; the
7
+ // regular one adds `s`.
8
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : many ?? `${one}s`}`;
9
+ exports.plural = plural;
@@ -0,0 +1,2 @@
1
+ declare const answerWhenAllPass: <Subject, Answer>(subject: Subject, guards: readonly ((subject: Subject) => boolean)[], answer: (subject: Subject) => Answer) => Answer | null;
2
+ export { answerWhenAllPass };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.answerWhenAllPass = void 0;
4
+ // A QUALIFIED ANSWER is one mechanism: a subject must pass every guard before
5
+ // it earns an answer; the first guard that refuses ends the question with
6
+ // nothing. A misfit role is a named candidate of a declared role with homes
7
+ // that sits outside them (`pipeline-roles`); a scope accessor is a record whose
8
+ // scope is one of the declared kinds (`code-roles/roles`). The walk is the same
9
+ // — ask each guard in order, answer only when all pass — so it lives here once.
10
+ // What the guards ARE and what the answer is is the caller's own; nothing here
11
+ // knows roles or accessors.
12
+ // The answer when every guard passes; null the moment one refuses. Guards are
13
+ // asked in order, so a cheap refusal short-circuits the rest.
14
+ const answerWhenAllPass = (subject, guards, answer) => {
15
+ for (const guard of guards) {
16
+ if (!guard(subject))
17
+ return null;
18
+ }
19
+ return answer(subject);
20
+ };
21
+ exports.answerWhenAllPass = answerWhenAllPass;
@@ -0,0 +1,2 @@
1
+ declare const rankedOffers: <Candidate, Offer>(candidates: readonly Candidate[], offer: (candidate: Candidate) => Offer | null, rank: (a: Offer, b: Offer) => number) => Offer[];
2
+ export { rankedOffers };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rankedOffers = void 0;
4
+ // A RANKED SHORTLIST is one mechanism: candidates are scored against a subject,
5
+ // the ones below the bar are dropped, and the rest are offered best first. A
6
+ // role's destinations are its homes scored by branch and prefix
7
+ // (`entities/location/homes`); a folder's lookalikes are the declared entities
8
+ // scored by the share of their roles it holds (`nodes/similar`). The walk is
9
+ // the same — score, keep, rank — so it lives here once. What a candidate IS,
10
+ // how it is scored and what the bar means are the caller's own.
11
+ // Score every candidate, keep the ones the scorer offers (non-null), and sort
12
+ // them by the caller's ranking. The scorer's own verdict decides inclusion;
13
+ // nothing here knows homes or entities.
14
+ const rankedOffers = (candidates, offer, rank) => {
15
+ const offers = [];
16
+ for (const candidate of candidates) {
17
+ const hit = offer(candidate);
18
+ if (hit != null)
19
+ offers.push(hit);
20
+ }
21
+ offers.sort(rank);
22
+ return offers;
23
+ };
24
+ exports.rankedOffers = rankedOffers;
@@ -0,0 +1,12 @@
1
+ import { type FieldValue } from "./field";
2
+ declare const stringField: (record: FieldValue, key: string, fallback?: string) => string;
3
+ declare const numberField: (record: FieldValue, key: string, fallback?: number) => number;
4
+ declare const booleanField: (record: FieldValue, key: string, fallback?: boolean) => boolean;
5
+ declare const recordField: (record: FieldValue, key: string) => {
6
+ readonly [key: string]: FieldValue;
7
+ } | null;
8
+ declare const recordListField: (record: FieldValue, key: string) => {
9
+ readonly [key: string]: FieldValue;
10
+ }[];
11
+ declare const stringListField: (record: FieldValue, key: string) => string[];
12
+ export { stringField, numberField, booleanField, recordField, recordListField, stringListField };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringListField = exports.recordListField = exports.recordField = exports.booleanField = exports.numberField = exports.stringField = void 0;
4
+ // Reading a TYPED field off a plain-data bag. A finding, a violation, a token
5
+ // and a fact are all `FieldValue` records at the boundary; a consumer that
6
+ // wants one field as a string / number / record / list asks the same question
7
+ // every time — read it, qualify the shape, keep it or take the fallback. The
8
+ // walk lives here once so no reader re-spells `typeof x === "string" ? x : …`
9
+ // (and none meets an `any`). What the field MEANS is the caller's own.
10
+ const field_1 = require("./field");
11
+ // The value at `key` when it is a string; the fallback otherwise.
12
+ const stringField = (record, key, fallback = "") => {
13
+ const value = (0, field_1.fieldOf)(record, key);
14
+ return typeof value === "string" ? value : fallback;
15
+ };
16
+ exports.stringField = stringField;
17
+ // The value at `key` when it is a number; the fallback otherwise.
18
+ const numberField = (record, key, fallback = 0) => {
19
+ const value = (0, field_1.fieldOf)(record, key);
20
+ return typeof value === "number" ? value : fallback;
21
+ };
22
+ exports.numberField = numberField;
23
+ // The value at `key` when it is a boolean; the fallback otherwise.
24
+ const booleanField = (record, key, fallback = false) => {
25
+ const value = (0, field_1.fieldOf)(record, key);
26
+ return typeof value === "boolean" ? value : fallback;
27
+ };
28
+ exports.booleanField = booleanField;
29
+ // The value at `key` when it is a record (never a list); null otherwise.
30
+ const recordField = (record, key) => {
31
+ const value = (0, field_1.fieldOf)(record, key);
32
+ return (0, field_1.isObj)(value) ? value : null;
33
+ };
34
+ exports.recordField = recordField;
35
+ // The value at `key` as a list: a list is itself, a single value becomes one
36
+ // item, nothing is no items. The ONE spelling of "list-or-single" for a field.
37
+ const itemsOf = (value) => {
38
+ if ((0, field_1.isList)(value))
39
+ return [...value];
40
+ if (value == null)
41
+ return [];
42
+ return [value];
43
+ };
44
+ // The value at `key` as a list of records: non-record items are dropped — a
45
+ // reader that wants records never meets a scalar.
46
+ const recordListField = (record, key) => itemsOf((0, field_1.fieldOf)(record, key)).filter((item) => (0, field_1.isObj)(item));
47
+ exports.recordListField = recordListField;
48
+ // The value at `key` as a list of strings: non-string items are dropped.
49
+ const stringListField = (record, key) => itemsOf((0, field_1.fieldOf)(record, key)).filter((item) => typeof item === "string");
50
+ exports.stringListField = stringListField;
@@ -0,0 +1,2 @@
1
+ declare const readWhen: <Subject, Answer>(subject: Subject | null | undefined, qualifies: (subject: Subject | null | undefined) => boolean, read: (subject: Subject) => Answer, fallback: Answer) => Answer;
2
+ export { readWhen };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readWhen = void 0;
4
+ // A QUALIFIED READ is one mechanism: a subject must first qualify as the kind
5
+ // of thing a reader understands, and only then is it read — otherwise the
6
+ // answer is a stated fallback, never a guess. The filter engine's `where`
7
+ // reads its expected value only when it is a record (`entities/queries`); the
8
+ // CSS content gate reads a document only when the syntax's parser accepts the
9
+ // text (`css/syntax/gate`). The walk is the same — qualify, then read, else
10
+ // fall back — so it lives here once. What "qualifies" means, how the subject is
11
+ // read and what the fallback is are the caller's own.
12
+ const readWhen = (subject, qualifies, read, fallback) => {
13
+ if (subject == null || !qualifies(subject))
14
+ return fallback;
15
+ return read(subject);
16
+ };
17
+ exports.readWhen = readWhen;
@@ -0,0 +1,4 @@
1
+ declare const reasonOf: (error: {
2
+ message?: string;
3
+ }) => string;
4
+ export { reasonOf };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reasonOf = void 0;
4
+ // The reason a caught error carries, as one string. A reader that swallows an
5
+ // error states the subject (what it was reading) and the reason; this is the ONE
6
+ // spelling of "the reason", so every notice reads the same way. An error with no
7
+ // message is still reported — by its string form, never as silence.
8
+ const reasonOf = (error) => error.message ?? String(error);
9
+ exports.reasonOf = reasonOf;
@@ -0,0 +1,3 @@
1
+ import { type FieldValue } from "./field";
2
+ declare const recordWithout: (record: FieldValue, omitted: readonly string[]) => FieldValue;
3
+ export { recordWithout };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.recordWithout = void 0;
4
+ // A RECORD WITHOUT KEYS is one mechanism: a record carries some keys that are
5
+ // NOT data (a report template beside a filter, an `arch` beside the facts),
6
+ // and a reader that wants only the data takes the record minus those keys.
7
+ // The invariant runtime strips `report` before matching (`invariants/vars`);
8
+ // the query engine strips `arch` before resolving a `$ref`
9
+ // (`entities/queries`). The walk is the same — copy every key except the named
10
+ // ones — so it lives here once. Which keys are not data is the caller's own.
11
+ const field_1 = require("./field");
12
+ const recordWithout = (record, omitted) => {
13
+ if (!(0, field_1.isRecordValue)(record))
14
+ return record;
15
+ const out = {};
16
+ for (const [k, v] of Object.entries(record))
17
+ if (!omitted.includes(k))
18
+ out[k] = v;
19
+ return out;
20
+ };
21
+ exports.recordWithout = recordWithout;
@@ -0,0 +1,2 @@
1
+ declare const resolveReference: <Reference, Target, Answer>(reference: Reference | null | undefined, find: (reference: Reference) => Target | null | undefined, read: (target: Target) => Answer | null) => Answer | null;
2
+ export { resolveReference };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveReference = void 0;
4
+ // A REFERENCE is one mechanism: a name points at something declared elsewhere,
5
+ // and a reader follows it to an answer. An import follows a module specifier to
6
+ // a scanned file (`utils/imports`); a class attribute follows a binding name to
7
+ // the static string it was initialised with (`css/markup`). The walk is the
8
+ // same — the reference must exist, a target must be found for it, and the target
9
+ // is read only when it yields an answer — so it lives here once. What a target
10
+ // IS and how it is read are the caller's own; nothing here knows imports,
11
+ // candidates or CSS.
12
+ // Follow `reference` to an answer: find its target and read it. A missing
13
+ // reference, a missing target or an unreadable one is null — never a guess.
14
+ // The reader's own acceptance policy lives inside `read` (it returns null when
15
+ // the target does not qualify), so this walk stays the same for every consumer.
16
+ const resolveReference = (reference, find, read) => {
17
+ if (reference == null)
18
+ return null;
19
+ const target = find(reference);
20
+ if (target == null)
21
+ return null;
22
+ return read(target);
23
+ };
24
+ exports.resolveReference = resolveReference;
@@ -0,0 +1,2 @@
1
+ declare const matchesText: (haystack: string | null | undefined, needle: string) => boolean;
2
+ export { matchesText };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchesText = void 0;
4
+ // A TEXT SEARCH is one mechanism: does a haystack contain a needle, ignoring
5
+ // case? An empty needle matches everything (no filter). The browser searches
6
+ // findings / roles / nodes (`utils/format`); any consumer that filters text by
7
+ // a substring asks the same question. The decision is the shared gate — admit
8
+ // when none of the refusals fires (no needle to filter by, or the needle is
9
+ // absent) — the same `admitsWhenNoneReject` the AST read gate uses.
10
+ const gate_1 = require("./gate");
11
+ // One refusal, not two: an EMPTY needle has nothing to refuse it, so the gate
12
+ // admits every haystack (no filter). A non-empty needle is refused only when
13
+ // the haystack does not contain it. Spelling the empty case as its own `!n`
14
+ // refusal would invert it — the refusal fires first and the list empties.
15
+ const matchesText = (haystack, needle) => (0, gate_1.admitsWhenNoneReject)(needle, [(n) => Boolean(n) && !String(haystack ?? "").toLowerCase().includes(n.toLowerCase())]);
16
+ exports.matchesText = matchesText;
@@ -0,0 +1,6 @@
1
+ type SeenStore = Map<string, Set<string>>;
2
+ declare const seenHas: (store: SeenStore | null | undefined, id: string, value: string) => boolean;
3
+ declare const seenAdd: (store: SeenStore | null | undefined, id: string, value: string) => void;
4
+ declare const seenOnce: (store: SeenStore | null | undefined, id: string, value: string) => boolean;
5
+ export { seenHas, seenAdd, seenOnce };
6
+ export type { SeenStore };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.seenOnce = exports.seenAdd = exports.seenHas = void 0;
4
+ // Has this id already spoken for this value? A missing store never dedupes.
5
+ const seenHas = (store, id, value) => store?.get(id)?.has(value) ?? false;
6
+ exports.seenHas = seenHas;
7
+ // Remember the value for this id (creating the bucket's set on first use).
8
+ // A missing store remembers nothing — the caller decided not to dedupe.
9
+ const seenAdd = (store, id, value) => {
10
+ if (!store)
11
+ return;
12
+ const set = store.get(id) ?? new Set();
13
+ set.add(value);
14
+ store.set(id, set);
15
+ };
16
+ exports.seenAdd = seenAdd;
17
+ // Has this id already spoken for this value — and if not, remember it? One
18
+ // ask-and-remember step: true when the value was already there (the caller
19
+ // stays silent), false when it is newly spoken (the caller answers). A missing
20
+ // store never dedupes: every value is newly spoken.
21
+ const seenOnce = (store, id, value) => {
22
+ if (seenHas(store, id, value))
23
+ return true;
24
+ seenAdd(store, id, value);
25
+ return false;
26
+ };
27
+ exports.seenOnce = seenOnce;