@driftsys/markspec 0.4.0 → 0.5.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 (319) hide show
  1. package/esm/ast/build.d.ts +70 -0
  2. package/esm/ast/build.d.ts.map +1 -0
  3. package/esm/ast/build.js +605 -0
  4. package/esm/ast/equivalence.d.ts +18 -0
  5. package/esm/ast/equivalence.d.ts.map +1 -0
  6. package/esm/ast/equivalence.js +56 -0
  7. package/esm/ast/nodes.d.ts +221 -0
  8. package/esm/ast/nodes.d.ts.map +1 -0
  9. package/esm/ast/nodes.js +12 -0
  10. package/esm/ast/normalize.d.ts +67 -0
  11. package/esm/ast/normalize.d.ts.map +1 -0
  12. package/esm/ast/normalize.js +255 -0
  13. package/esm/ast/render.d.ts +34 -0
  14. package/esm/ast/render.d.ts.map +1 -0
  15. package/esm/ast/render.js +215 -0
  16. package/esm/compiler/inverses.d.ts +2 -8
  17. package/esm/compiler/inverses.d.ts.map +1 -1
  18. package/esm/compiler/inverses.js +50 -14
  19. package/esm/compiler/manifest.d.ts +59 -0
  20. package/esm/compiler/manifest.d.ts.map +1 -0
  21. package/esm/compiler/manifest.js +48 -0
  22. package/esm/compiler/mod.d.ts +9 -1
  23. package/esm/compiler/mod.d.ts.map +1 -1
  24. package/esm/compiler/mod.js +21 -2
  25. package/esm/compiler/ndjson_writer.d.ts +50 -0
  26. package/esm/compiler/ndjson_writer.d.ts.map +1 -0
  27. package/esm/compiler/ndjson_writer.js +73 -0
  28. package/esm/compiler/schema.d.ts +18 -1
  29. package/esm/compiler/schema.d.ts.map +1 -1
  30. package/esm/compiler/schema.js +18 -9
  31. package/esm/config/mod.d.ts.map +1 -1
  32. package/esm/config/mod.js +54 -0
  33. package/esm/formatter/mod.d.ts +49 -4
  34. package/esm/formatter/mod.d.ts.map +1 -1
  35. package/esm/formatter/mod.js +362 -33
  36. package/esm/formatter/synth_ulid.d.ts +21 -0
  37. package/esm/formatter/synth_ulid.d.ts.map +1 -0
  38. package/esm/formatter/synth_ulid.js +64 -0
  39. package/esm/lint/mod.d.ts +10 -0
  40. package/esm/lint/mod.d.ts.map +1 -0
  41. package/esm/lint/mod.js +7 -0
  42. package/esm/lint/rules/lexicon.d.ts +24 -0
  43. package/esm/lint/rules/lexicon.d.ts.map +1 -0
  44. package/esm/lint/rules/lexicon.js +236 -0
  45. package/esm/lint/rules/struct.d.ts +17 -0
  46. package/esm/lint/rules/struct.d.ts.map +1 -0
  47. package/esm/lint/rules/struct.js +55 -0
  48. package/esm/lint/rules/suppression.d.ts +19 -0
  49. package/esm/lint/rules/suppression.d.ts.map +1 -0
  50. package/esm/lint/rules/suppression.js +75 -0
  51. package/esm/lint/runner.d.ts +39 -0
  52. package/esm/lint/runner.d.ts.map +1 -0
  53. package/esm/lint/runner.js +112 -0
  54. package/esm/lint/types.d.ts +19 -0
  55. package/esm/lint/types.d.ts.map +1 -0
  56. package/esm/lint/types.js +9 -0
  57. package/esm/mod.d.ts +19 -6
  58. package/esm/mod.d.ts.map +1 -1
  59. package/esm/mod.js +14 -3
  60. package/esm/model/attributes.d.ts.map +1 -1
  61. package/esm/model/attributes.js +163 -2
  62. package/esm/model/discriminating_attr.d.ts +33 -0
  63. package/esm/model/discriminating_attr.d.ts.map +1 -0
  64. package/esm/model/discriminating_attr.js +74 -0
  65. package/esm/model/mod.d.ts +98 -3
  66. package/esm/model/mod.d.ts.map +1 -1
  67. package/esm/model/mod.js +57 -2
  68. package/esm/model/profile.d.ts +33 -27
  69. package/esm/model/profile.d.ts.map +1 -1
  70. package/esm/model/source_introspection.d.ts +26 -0
  71. package/esm/model/source_introspection.d.ts.map +1 -0
  72. package/esm/model/source_introspection.js +77 -0
  73. package/esm/model/type_hierarchy.d.ts +51 -0
  74. package/esm/model/type_hierarchy.d.ts.map +1 -0
  75. package/esm/model/type_hierarchy.js +126 -0
  76. package/esm/model/uri_scheme_map.d.ts +21 -0
  77. package/esm/model/uri_scheme_map.d.ts.map +1 -0
  78. package/esm/model/uri_scheme_map.js +66 -0
  79. package/esm/parser/attributes.d.ts.map +1 -1
  80. package/esm/parser/attributes.js +9 -6
  81. package/esm/parser/entity_refs.d.ts +53 -0
  82. package/esm/parser/entity_refs.d.ts.map +1 -0
  83. package/esm/parser/entity_refs.js +151 -0
  84. package/esm/parser/glossary.d.ts +43 -0
  85. package/esm/parser/glossary.d.ts.map +1 -0
  86. package/esm/parser/glossary.js +217 -0
  87. package/esm/parser/markdown.d.ts.map +1 -1
  88. package/esm/parser/markdown.js +223 -7
  89. package/esm/parser/mod.d.ts +1 -0
  90. package/esm/parser/mod.d.ts.map +1 -1
  91. package/esm/parser/mod.js +1 -0
  92. package/esm/parser/source.d.ts +20 -0
  93. package/esm/parser/source.d.ts.map +1 -1
  94. package/esm/parser/source.js +3 -3
  95. package/esm/profile/chain.js +3 -13
  96. package/esm/profile/colors.js +1 -1
  97. package/esm/profile/introspect.d.ts +135 -0
  98. package/esm/profile/introspect.d.ts.map +1 -0
  99. package/esm/profile/introspect.js +378 -0
  100. package/esm/profile/load.d.ts.map +1 -1
  101. package/esm/profile/load.js +67 -0
  102. package/esm/profile/manifest.d.ts.map +1 -1
  103. package/esm/profile/manifest.js +277 -88
  104. package/esm/profile/merge.js +139 -39
  105. package/esm/profile/mod.d.ts +2 -4
  106. package/esm/profile/mod.d.ts.map +1 -1
  107. package/esm/profile/mod.js +5 -2
  108. package/esm/reporter/mod.js +4 -4
  109. package/esm/util/fence.d.ts +30 -0
  110. package/esm/util/fence.d.ts.map +1 -0
  111. package/esm/util/fence.js +40 -0
  112. package/esm/validator/attributes.d.ts +3 -3
  113. package/esm/validator/attributes.d.ts.map +1 -1
  114. package/esm/validator/attributes.js +1 -18
  115. package/esm/validator/body_blocks.d.ts +38 -0
  116. package/esm/validator/body_blocks.d.ts.map +1 -0
  117. package/esm/validator/body_blocks.js +218 -0
  118. package/esm/validator/caption_convention.d.ts +29 -0
  119. package/esm/validator/caption_convention.d.ts.map +1 -0
  120. package/esm/validator/caption_convention.js +58 -0
  121. package/esm/validator/captions.d.ts +22 -0
  122. package/esm/validator/captions.d.ts.map +1 -0
  123. package/esm/validator/captions.js +137 -0
  124. package/esm/validator/component_schemes.d.ts +73 -0
  125. package/esm/validator/component_schemes.d.ts.map +1 -0
  126. package/esm/validator/component_schemes.js +375 -0
  127. package/esm/validator/feature_ac.d.ts +28 -0
  128. package/esm/validator/feature_ac.d.ts.map +1 -0
  129. package/esm/validator/feature_ac.js +102 -0
  130. package/esm/validator/listing.d.ts +42 -0
  131. package/esm/validator/listing.d.ts.map +1 -0
  132. package/esm/validator/listing.js +295 -0
  133. package/esm/validator/mod.d.ts +2 -0
  134. package/esm/validator/mod.d.ts.map +1 -1
  135. package/esm/validator/mod.js +253 -12
  136. package/esm/validator/modal_keywords.d.ts +23 -0
  137. package/esm/validator/modal_keywords.d.ts.map +1 -0
  138. package/esm/validator/modal_keywords.js +137 -0
  139. package/esm/validator/per_type_attrs.d.ts +29 -0
  140. package/esm/validator/per_type_attrs.d.ts.map +1 -0
  141. package/esm/validator/per_type_attrs.js +75 -0
  142. package/esm/validator/pipeline.d.ts +7 -2
  143. package/esm/validator/pipeline.d.ts.map +1 -1
  144. package/esm/validator/pipeline.js +40 -7
  145. package/esm/validator/trace_types.d.ts +26 -0
  146. package/esm/validator/trace_types.d.ts.map +1 -0
  147. package/esm/validator/trace_types.js +232 -0
  148. package/esm/validator/traceability.d.ts +3 -4
  149. package/esm/validator/traceability.d.ts.map +1 -1
  150. package/esm/validator/traceability.js +5 -10
  151. package/esm/validator/type_resolution.d.ts +67 -0
  152. package/esm/validator/type_resolution.d.ts.map +1 -0
  153. package/esm/validator/type_resolution.js +140 -0
  154. package/esm/validator/types.d.ts +45 -0
  155. package/esm/validator/types.d.ts.map +1 -1
  156. package/esm/validator/types.js +128 -16
  157. package/esm/validator/value_types.d.ts +8 -0
  158. package/esm/validator/value_types.d.ts.map +1 -1
  159. package/esm/validator/value_types.js +8 -1
  160. package/package.json +1 -1
  161. package/script/ast/build.d.ts +70 -0
  162. package/script/ast/build.d.ts.map +1 -0
  163. package/script/ast/build.js +610 -0
  164. package/script/ast/equivalence.d.ts +18 -0
  165. package/script/ast/equivalence.d.ts.map +1 -0
  166. package/script/ast/equivalence.js +59 -0
  167. package/script/ast/nodes.d.ts +221 -0
  168. package/script/ast/nodes.d.ts.map +1 -0
  169. package/script/ast/nodes.js +13 -0
  170. package/script/ast/normalize.d.ts +67 -0
  171. package/script/ast/normalize.d.ts.map +1 -0
  172. package/script/ast/normalize.js +258 -0
  173. package/script/ast/render.d.ts +34 -0
  174. package/script/ast/render.d.ts.map +1 -0
  175. package/script/ast/render.js +218 -0
  176. package/script/compiler/inverses.d.ts +2 -8
  177. package/script/compiler/inverses.d.ts.map +1 -1
  178. package/script/compiler/inverses.js +50 -14
  179. package/script/compiler/manifest.d.ts +59 -0
  180. package/script/compiler/manifest.d.ts.map +1 -0
  181. package/script/compiler/manifest.js +51 -0
  182. package/script/compiler/mod.d.ts +9 -1
  183. package/script/compiler/mod.d.ts.map +1 -1
  184. package/script/compiler/mod.js +21 -2
  185. package/script/compiler/ndjson_writer.d.ts +50 -0
  186. package/script/compiler/ndjson_writer.d.ts.map +1 -0
  187. package/script/compiler/ndjson_writer.js +78 -0
  188. package/script/compiler/schema.d.ts +18 -1
  189. package/script/compiler/schema.d.ts.map +1 -1
  190. package/script/compiler/schema.js +18 -8
  191. package/script/config/mod.d.ts.map +1 -1
  192. package/script/config/mod.js +54 -0
  193. package/script/formatter/mod.d.ts +49 -4
  194. package/script/formatter/mod.d.ts.map +1 -1
  195. package/script/formatter/mod.js +365 -33
  196. package/script/formatter/synth_ulid.d.ts +21 -0
  197. package/script/formatter/synth_ulid.d.ts.map +1 -0
  198. package/script/formatter/synth_ulid.js +67 -0
  199. package/script/lint/mod.d.ts +10 -0
  200. package/script/lint/mod.d.ts.map +1 -0
  201. package/script/lint/mod.js +12 -0
  202. package/script/lint/rules/lexicon.d.ts +24 -0
  203. package/script/lint/rules/lexicon.d.ts.map +1 -0
  204. package/script/lint/rules/lexicon.js +240 -0
  205. package/script/lint/rules/struct.d.ts +17 -0
  206. package/script/lint/rules/struct.d.ts.map +1 -0
  207. package/script/lint/rules/struct.js +59 -0
  208. package/script/lint/rules/suppression.d.ts +19 -0
  209. package/script/lint/rules/suppression.d.ts.map +1 -0
  210. package/script/lint/rules/suppression.js +80 -0
  211. package/script/lint/runner.d.ts +39 -0
  212. package/script/lint/runner.d.ts.map +1 -0
  213. package/script/lint/runner.js +116 -0
  214. package/script/lint/types.d.ts +19 -0
  215. package/script/lint/types.d.ts.map +1 -0
  216. package/script/lint/types.js +10 -0
  217. package/script/mod.d.ts +19 -6
  218. package/script/mod.d.ts.map +1 -1
  219. package/script/mod.js +56 -32
  220. package/script/model/attributes.d.ts.map +1 -1
  221. package/script/model/attributes.js +163 -2
  222. package/script/model/discriminating_attr.d.ts +33 -0
  223. package/script/model/discriminating_attr.d.ts.map +1 -0
  224. package/script/model/discriminating_attr.js +77 -0
  225. package/script/model/mod.d.ts +98 -3
  226. package/script/model/mod.d.ts.map +1 -1
  227. package/script/model/mod.js +64 -3
  228. package/script/model/profile.d.ts +33 -27
  229. package/script/model/profile.d.ts.map +1 -1
  230. package/script/model/source_introspection.d.ts +26 -0
  231. package/script/model/source_introspection.d.ts.map +1 -0
  232. package/script/model/source_introspection.js +80 -0
  233. package/script/model/type_hierarchy.d.ts +51 -0
  234. package/script/model/type_hierarchy.d.ts.map +1 -0
  235. package/script/model/type_hierarchy.js +130 -0
  236. package/script/model/uri_scheme_map.d.ts +21 -0
  237. package/script/model/uri_scheme_map.d.ts.map +1 -0
  238. package/script/model/uri_scheme_map.js +69 -0
  239. package/script/parser/attributes.d.ts.map +1 -1
  240. package/script/parser/attributes.js +9 -6
  241. package/script/parser/entity_refs.d.ts +53 -0
  242. package/script/parser/entity_refs.d.ts.map +1 -0
  243. package/script/parser/entity_refs.js +155 -0
  244. package/script/parser/glossary.d.ts +43 -0
  245. package/script/parser/glossary.d.ts.map +1 -0
  246. package/script/parser/glossary.js +221 -0
  247. package/script/parser/markdown.d.ts.map +1 -1
  248. package/script/parser/markdown.js +222 -6
  249. package/script/parser/mod.d.ts +1 -0
  250. package/script/parser/mod.d.ts.map +1 -1
  251. package/script/parser/mod.js +5 -1
  252. package/script/parser/source.d.ts +20 -0
  253. package/script/parser/source.d.ts.map +1 -1
  254. package/script/parser/source.js +3 -0
  255. package/script/profile/chain.js +3 -13
  256. package/script/profile/colors.js +1 -1
  257. package/script/profile/introspect.d.ts +135 -0
  258. package/script/profile/introspect.d.ts.map +1 -0
  259. package/script/profile/introspect.js +381 -0
  260. package/script/profile/load.d.ts.map +1 -1
  261. package/script/profile/load.js +67 -0
  262. package/script/profile/manifest.d.ts.map +1 -1
  263. package/script/profile/manifest.js +276 -87
  264. package/script/profile/merge.js +139 -39
  265. package/script/profile/mod.d.ts +2 -4
  266. package/script/profile/mod.d.ts.map +1 -1
  267. package/script/profile/mod.js +7 -6
  268. package/script/reporter/mod.js +4 -4
  269. package/script/util/fence.d.ts +30 -0
  270. package/script/util/fence.d.ts.map +1 -0
  271. package/script/util/fence.js +44 -0
  272. package/script/validator/attributes.d.ts +3 -3
  273. package/script/validator/attributes.d.ts.map +1 -1
  274. package/script/validator/attributes.js +1 -18
  275. package/script/validator/body_blocks.d.ts +38 -0
  276. package/script/validator/body_blocks.d.ts.map +1 -0
  277. package/script/validator/body_blocks.js +221 -0
  278. package/script/validator/caption_convention.d.ts +29 -0
  279. package/script/validator/caption_convention.d.ts.map +1 -0
  280. package/script/validator/caption_convention.js +61 -0
  281. package/script/validator/captions.d.ts +22 -0
  282. package/script/validator/captions.d.ts.map +1 -0
  283. package/script/validator/captions.js +140 -0
  284. package/script/validator/component_schemes.d.ts +73 -0
  285. package/script/validator/component_schemes.d.ts.map +1 -0
  286. package/script/validator/component_schemes.js +384 -0
  287. package/script/validator/feature_ac.d.ts +28 -0
  288. package/script/validator/feature_ac.d.ts.map +1 -0
  289. package/script/validator/feature_ac.js +105 -0
  290. package/script/validator/listing.d.ts +42 -0
  291. package/script/validator/listing.d.ts.map +1 -0
  292. package/script/validator/listing.js +298 -0
  293. package/script/validator/mod.d.ts +2 -0
  294. package/script/validator/mod.d.ts.map +1 -1
  295. package/script/validator/mod.js +256 -14
  296. package/script/validator/modal_keywords.d.ts +23 -0
  297. package/script/validator/modal_keywords.d.ts.map +1 -0
  298. package/script/validator/modal_keywords.js +140 -0
  299. package/script/validator/per_type_attrs.d.ts +29 -0
  300. package/script/validator/per_type_attrs.d.ts.map +1 -0
  301. package/script/validator/per_type_attrs.js +78 -0
  302. package/script/validator/pipeline.d.ts +7 -2
  303. package/script/validator/pipeline.d.ts.map +1 -1
  304. package/script/validator/pipeline.js +39 -6
  305. package/script/validator/trace_types.d.ts +26 -0
  306. package/script/validator/trace_types.d.ts.map +1 -0
  307. package/script/validator/trace_types.js +235 -0
  308. package/script/validator/traceability.d.ts +3 -4
  309. package/script/validator/traceability.d.ts.map +1 -1
  310. package/script/validator/traceability.js +5 -10
  311. package/script/validator/type_resolution.d.ts +67 -0
  312. package/script/validator/type_resolution.d.ts.map +1 -0
  313. package/script/validator/type_resolution.js +146 -0
  314. package/script/validator/types.d.ts +45 -0
  315. package/script/validator/types.d.ts.map +1 -1
  316. package/script/validator/types.js +131 -16
  317. package/script/validator/value_types.d.ts +8 -0
  318. package/script/validator/value_types.d.ts.map +1 -1
  319. package/script/validator/value_types.js +10 -2
@@ -5,8 +5,10 @@
5
5
  * `- [DISPLAY_ID] Title` entry blocks and extract structured attributes.
6
6
  */
7
7
  import { IDENTITY_KEY, shapeFromIdValue } from "../model/mod.js";
8
- import { collateAttributes, parseAttributes, splitBodyAndAttributes, } from "./attributes.js";
8
+ import { ATTR_LINE_RE, collateAttributes, parseAttributes, splitBodyAndAttributes, } from "./attributes.js";
9
+ import { extractEntityRefs } from "./entity_refs.js";
9
10
  import { processor } from "./remark.js";
11
+ import { buildBodyAst } from "../ast/build.js";
10
12
  /**
11
13
  * Slug pattern for referenced-entry display IDs.
12
14
  *
@@ -17,6 +19,10 @@ import { processor } from "./remark.js";
17
19
  const SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
18
20
  /** Match `[...]` at the start of a list item paragraph. Captures: [1] = display ID, [2] = title. */
19
21
  const ENTRY_START_RE = /^\[([^\]]+)\]\s*(.*)$/;
22
+ /** Match `[]` at the start — empty brackets. */
23
+ const EMPTY_BRACKET_RE = /^\[\]\s*(.*)$/;
24
+ /** Match `[` at the start without a closing `]` on the same logical content — unterminated. */
25
+ const UNTERMINATED_BRACKET_RE = /^\[[^\]]*$/;
20
26
  /**
21
27
  * Find the `Id:` attribute on an entry. Returns undefined when absent. If
22
28
  * more than one `Id:` is present, returns the first — the validator flags
@@ -105,11 +111,36 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
105
111
  let title;
106
112
  if (firstInline.type === "text") {
107
113
  // remark may parse `[ID] Title` as a single text node
108
- const match = ENTRY_START_RE.exec(firstInline.value);
114
+ const textValue = firstInline.value;
115
+ const match = ENTRY_START_RE.exec(textValue);
109
116
  if (match) {
110
117
  displayId = match[1];
111
118
  title = match[2].trim();
112
119
  }
120
+ else if (EMPTY_BRACKET_RE.test(textValue)) {
121
+ // MSL-P001: bracketed content is empty — `- [] Title`
122
+ const entryLine = item.position?.start.line ?? 1;
123
+ diagnostics.push({
124
+ code: "MSL-P001",
125
+ severity: "error",
126
+ message: "list item starts with `[]` but the bracketed content is empty " +
127
+ "(spec section 4.1)",
128
+ location: { file, line: entryLine, column: 1 },
129
+ });
130
+ return undefined;
131
+ }
132
+ else if (UNTERMINATED_BRACKET_RE.test(textValue)) {
133
+ // MSL-P003: display-ID brackets unterminated (missing `]`)
134
+ const entryLine = item.position?.start.line ?? 1;
135
+ diagnostics.push({
136
+ code: "MSL-P003",
137
+ severity: "error",
138
+ message: "display-ID brackets unterminated -- missing `]` before end of " +
139
+ "title line (spec section 4.1)",
140
+ location: { file, line: entryLine, column: 1 },
141
+ });
142
+ return undefined;
143
+ }
113
144
  }
114
145
  // Try linkReference pattern: remark sometimes parses [ID] as a linkReference
115
146
  if (!displayId && firstInline.type === "linkReference") {
@@ -140,10 +171,168 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
140
171
  // citation compatibility. Canonical slug never contains `@`.
141
172
  if (displayId.startsWith("@"))
142
173
  displayId = displayId.slice(1);
174
+ // MSL-I005: Display ID is empty (after `@` stripping).
175
+ if (displayId.length === 0) {
176
+ const entryLine = item.position?.start.line ?? 1;
177
+ diagnostics.push({
178
+ code: "MSL-I005",
179
+ severity: "error",
180
+ message: "display ID is empty (spec section 4.2)",
181
+ location: { file, line: entryLine, column: 1 },
182
+ });
183
+ return undefined;
184
+ }
185
+ // MSL-P002: title text missing after `]`. The title capture is empty
186
+ // and was not populated from subsequent nodes (linkReference path sets
187
+ // title from rest nodes).
188
+ if (title !== undefined && title.length === 0) {
189
+ const entryLine = item.position?.start.line ?? 1;
190
+ diagnostics.push({
191
+ code: "MSL-P002",
192
+ severity: "error",
193
+ message: `${displayId}: title line missing title text after ']' (spec section 4.1)`,
194
+ location: { file, line: entryLine, column: 1 },
195
+ });
196
+ // Continue parsing — entry is still structurally valid for downstream
197
+ // validation (MSL-P010 also fires from the validator for empty titles).
198
+ }
143
199
  // Extract body content and attributes.
144
200
  const bodyContent = extractBodyContent(item, markdown);
145
201
  const [body, attrLines] = splitBodyAndAttributes(bodyContent);
146
202
  const attributes = parseAttributes(attrLines);
203
+ const bodyAst = buildBodyAst(body);
204
+ const entryLine = item.position?.start.line ?? 1;
205
+ // MSL-P020: trailers block is not the final indented code block.
206
+ // Detect `Key: Value` lines in the body that likely should be trailers
207
+ // but are not at the final position (body content follows them).
208
+ // Exclude caption keywords (Figure:, Table:, etc.) which are legitimate
209
+ // body content, not misplaced trailer attributes.
210
+ const CAPTION_KEYWORDS = new Set([
211
+ "Figure",
212
+ "Table",
213
+ "Listing",
214
+ "Feature",
215
+ "Equation",
216
+ "List",
217
+ ]);
218
+ if (body.length > 0) {
219
+ const bodyLines = body.split("\n");
220
+ let inFencedBlock = false;
221
+ for (let i = 0; i < bodyLines.length; i++) {
222
+ const trimmed = bodyLines[i].trim();
223
+ // Track fenced code blocks (``` or ~~~) to skip their contents
224
+ if (/^(`{3,}|~{3,})/.test(trimmed)) {
225
+ inFencedBlock = !inFencedBlock;
226
+ continue;
227
+ }
228
+ if (inFencedBlock)
229
+ continue;
230
+ if (!ATTR_LINE_RE.test(trimmed))
231
+ continue;
232
+ // Extract the key portion to check against caption keywords
233
+ const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
234
+ if (keyMatch && CAPTION_KEYWORDS.has(keyMatch[1]))
235
+ continue;
236
+ // Found a Key: Value line in the body — non-final position
237
+ diagnostics.push({
238
+ code: "MSL-P020",
239
+ severity: "error",
240
+ message: `${displayId}: trailers block is not the final indented code ` +
241
+ `block of the entry -- content appears after trailer-like ` +
242
+ `lines (spec section 4.1)`,
243
+ location: { file, line: entryLine, column: 1 },
244
+ });
245
+ break; // One diagnostic per entry is sufficient
246
+ }
247
+ }
248
+ // MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
249
+ // The trailer block is the final indented code block. Lines within it
250
+ // should all match `Key: Value` syntax. We check both the parsed
251
+ // attrLines AND the trailing body lines that might be in a code block
252
+ // but failed ATTR_LINE_RE (thus stayed in the body).
253
+ const TRAILER_KEY_RE = /^[A-Za-z][A-Za-z0-9-]*$/;
254
+ const COLON_SPLIT_RE = /^([^:]+):\s*(.*)$/;
255
+ // Check lines that DID end up in attrLines but might have key issues
256
+ for (const rawLine of attrLines) {
257
+ const trimmed = rawLine.trim();
258
+ if (!trimmed)
259
+ continue;
260
+ if (!ATTR_LINE_RE.test(trimmed)) {
261
+ const colonMatch = COLON_SPLIT_RE.exec(trimmed);
262
+ if (colonMatch) {
263
+ const key = colonMatch[1].trim();
264
+ if (!TRAILER_KEY_RE.test(key)) {
265
+ diagnostics.push({
266
+ code: "MSL-P022",
267
+ severity: "error",
268
+ message: `${displayId}: trailer key '${key}' contains characters ` +
269
+ `outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
270
+ location: { file, line: entryLine, column: 1 },
271
+ });
272
+ }
273
+ else {
274
+ diagnostics.push({
275
+ code: "MSL-P021",
276
+ severity: "error",
277
+ message: `${displayId}: trailer line does not match 'Key: Value' ` +
278
+ `syntax (spec section 4.1): "${trimmed}"`,
279
+ location: { file, line: entryLine, column: 1 },
280
+ });
281
+ }
282
+ }
283
+ else {
284
+ diagnostics.push({
285
+ code: "MSL-P021",
286
+ severity: "error",
287
+ message: `${displayId}: trailer line does not match 'Key: Value' ` +
288
+ `syntax (spec section 4.1): "${trimmed}"`,
289
+ location: { file, line: entryLine, column: 1 },
290
+ });
291
+ }
292
+ }
293
+ }
294
+ // Also scan trailing body lines for suspected misplaced trailers.
295
+ // If the body's last non-empty lines look like they belong to an
296
+ // indented code block with colon-separated content that has invalid
297
+ // keys, emit P022. Lines without colons that appear in what looks
298
+ // like a trailer block emit P021.
299
+ if (body.length > 0) {
300
+ const bodyLines = body.split("\n");
301
+ // Walk backward from the end of the body to find lines in a trailing
302
+ // code-block-like region that have colons (suspected trailers).
303
+ for (let i = bodyLines.length - 1; i >= 0; i--) {
304
+ const trimmed = bodyLines[i].trim();
305
+ if (!trimmed)
306
+ continue; // skip trailing blanks
307
+ const colonMatch = COLON_SPLIT_RE.exec(trimmed);
308
+ if (!colonMatch)
309
+ break; // stop at non-colon line
310
+ const key = colonMatch[1].trim();
311
+ if (ATTR_LINE_RE.test(trimmed)) {
312
+ // Valid attr line in body → already caught by P020
313
+ continue;
314
+ }
315
+ if (!TRAILER_KEY_RE.test(key)) {
316
+ diagnostics.push({
317
+ code: "MSL-P022",
318
+ severity: "error",
319
+ message: `${displayId}: trailer key '${key}' contains characters ` +
320
+ `outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
321
+ location: { file, line: entryLine, column: 1 },
322
+ });
323
+ }
324
+ else if (colonMatch[2].trim().length === 0) {
325
+ diagnostics.push({
326
+ code: "MSL-P021",
327
+ severity: "error",
328
+ message: `${displayId}: trailer line does not match 'Key: Value' ` +
329
+ `syntax (spec section 4.1): "${trimmed}"`,
330
+ location: { file, line: entryLine, column: 1 },
331
+ });
332
+ }
333
+ break; // one diagnostic per trailing suspect line is sufficient
334
+ }
335
+ }
147
336
  // Detect legacy paragraph + trailing-backslash attribute form and warn.
148
337
  if (attributes.length > 0 &&
149
338
  attrLines.some((line) => line.trimEnd().endsWith("\\"))) {
@@ -167,45 +356,72 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
167
356
  // `Id:` is neither a ULID nor a scheme-qualified URI. Accept as an
168
357
  // identified entry so the validator can surface MSL-R004; missing
169
358
  // shape on a parsed entry is not useful downstream.
170
- shape = "identified";
359
+ shape = "Authored";
171
360
  }
172
361
  }
173
362
  else {
174
363
  // No `Id:`. Fall back on display-ID shape + document context to decide
175
364
  // whether to admit the entry at all.
176
365
  if (isReferencesDoc && SLUG_RE.test(displayId)) {
177
- shape = "referenced";
366
+ shape = "Reference";
178
367
  }
179
368
  else {
180
369
  // No identity attribute and no references-doc context — admit as
181
370
  // identified so the validator can surface the missing-`Id:` error.
182
- shape = "identified";
371
+ shape = "Authored";
183
372
  }
184
373
  }
185
374
  // Inferred type from display-ID prefix — left to the profile layer. For
186
375
  // now the core records no type; downstream profile-aware code populates
187
376
  // this field when a profile is loaded.
188
377
  const type = undefined;
378
+ // MSL-P030: Authored entry has no body block (title + trailers only).
379
+ // For Reference shape, body is optional (ADR-002 section Part 3). For Authored,
380
+ // the body is required. We also emit P030 when the body is empty (all
381
+ // content was consumed as attributes).
382
+ if (shape === "Authored" && body.trim().length === 0) {
383
+ diagnostics.push({
384
+ code: "MSL-P030",
385
+ severity: "error",
386
+ message: `${displayId}: Authored entry has no body block -- entries must ` +
387
+ `have body content between title and trailers (spec section 4.1)`,
388
+ location: { file, line: entryLine, column: 1 },
389
+ });
390
+ }
189
391
  // Body requirement: identified entries require a body; referenced entries
190
392
  // may omit it. If there's only one child (the title paragraph), admit
191
393
  // only referenced entries.
192
- if (shape !== "referenced" && item.children.length < 2)
394
+ if (shape !== "Reference" && item.children.length < 2)
193
395
  return undefined;
194
396
  // Source location
195
397
  const line = item.position?.start.line ?? 1;
196
398
  const column = item.position?.start.column ?? 1;
399
+ const entryLocation = { file, line, column };
400
+ // Inline `$Identifier` entity references (spec section 2.5.2). Resolution
401
+ // into the project's entity registry is left to the validator's
402
+ // marker pass; the parser only emits the lexical hits.
403
+ // Pass the already-built bodyAst to avoid a redundant mdast parse.
404
+ const entityRefs = extractEntityRefs(body, {
405
+ file,
406
+ // Body content starts on the line after the title; +1 keeps
407
+ // emitted line numbers 1-based relative to the file.
408
+ line: line + 1,
409
+ column: 1,
410
+ }, bodyAst);
197
411
  return {
198
412
  displayId,
199
413
  title: title ?? "",
200
414
  body,
415
+ bodyAst,
201
416
  rawAttributes: attributes,
202
417
  typedAttributes: collateAttributes(attributes),
203
418
  id,
204
419
  type,
205
420
  shape,
206
- location: { file, line, column },
421
+ location: entryLocation,
207
422
  source: "markdown",
208
423
  properties: { file: { path: file, line, column } },
424
+ entityRefs: entityRefs.length > 0 ? entityRefs : undefined,
209
425
  };
210
426
  }
211
427
  /**
@@ -20,6 +20,7 @@ export { detectInlineRefs } from "./references.js";
20
20
  export type { DetectInlineRefsOptions } from "./references.js";
21
21
  export { parseSource } from "./source.js";
22
22
  export type { ParseSourceOptions, ParseSourceResult } from "./source.js";
23
+ export { stripBlockCommentPrefix, stripLineCommentPrefix, wrapAsListItem, } from "./source.js";
23
24
  export { isSupportedExtension, loadGrammar } from "./grammars.js";
24
25
  /** Options for {@linkcode parse}. */
25
26
  export interface ParseOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EA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;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,YAAY,GACrB,KAAK,EAAE,CAET;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAYD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC,eAAe,CAAC,CAiC1B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,EAAE,CAEX"}
package/esm/parser/mod.js CHANGED
@@ -19,6 +19,7 @@ export { detectDirectives } from "./directives.js";
19
19
  export { extractFrontMatter } from "./frontmatter.js";
20
20
  export { detectInlineRefs } from "./references.js";
21
21
  export { parseSource } from "./source.js";
22
+ export { stripBlockCommentPrefix, stripLineCommentPrefix, wrapAsListItem, } from "./source.js";
22
23
  export { isSupportedExtension, loadGrammar } from "./grammars.js";
23
24
  /**
24
25
  * Parse a Markdown string and return all MarkSpec entries found.
@@ -5,6 +5,7 @@
5
5
  * comments in Rust, Kotlin, C, C++, and Java source files. Delegates parsed
6
6
  * content to the markdown parser for entry extraction.
7
7
  */
8
+ import type { SyntaxNode } from "web-tree-sitter";
8
9
  import Parser from "web-tree-sitter";
9
10
  import type { Entry } from "../model/mod.js";
10
11
  /** Options for {@linkcode parseSource}. */
@@ -30,4 +31,23 @@ export interface ParseSourceResult {
30
31
  * @param options - Parse options (language grammar, file path)
31
32
  */
32
33
  export declare function parseSource(content: string, options: ParseSourceOptions): ParseSourceResult;
34
+ /**
35
+ * Strip the `///` prefix from a line comment node.
36
+ * Uses the `doc_comment` child if available, otherwise strips manually.
37
+ */
38
+ export declare function stripLineCommentPrefix(node: SyntaxNode): string;
39
+ /**
40
+ * Strip block comment delimiters and leading ` * ` prefixes.
41
+ * Returns cleaned lines.
42
+ */
43
+ export declare function stripBlockCommentPrefix(text: string): string[];
44
+ /**
45
+ * Wrap cleaned doc comment lines as a Markdown list item so the
46
+ * existing `parseMarkdown()` can extract entries.
47
+ *
48
+ * Doc comments use `[DISPLAY_ID] Title` without the `- ` bullet.
49
+ * This wraps to `- [DISPLAY_ID] Title\n\n body...` which parseMarkdown
50
+ * recognizes as an entry block.
51
+ */
52
+ export declare function wrapAsListItem(lines: string[]): string;
33
53
  //# sourceMappingURL=source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CACpC;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;CAC3B;AAYD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAsCnB"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CACpC;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;CAC3B;AAYD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAsCnB;AAiFD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAe/D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgC9D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAKtD"}
@@ -122,7 +122,7 @@ function isOuterDocComment(node) {
122
122
  * Strip the `///` prefix from a line comment node.
123
123
  * Uses the `doc_comment` child if available, otherwise strips manually.
124
124
  */
125
- function stripLineCommentPrefix(node) {
125
+ export function stripLineCommentPrefix(node) {
126
126
  for (let i = 0; i < node.childCount; i++) {
127
127
  const child = node.child(i);
128
128
  if (child.type === "doc_comment") {
@@ -145,7 +145,7 @@ function stripLineCommentPrefix(node) {
145
145
  * Strip block comment delimiters and leading ` * ` prefixes.
146
146
  * Returns cleaned lines.
147
147
  */
148
- function stripBlockCommentPrefix(text) {
148
+ export function stripBlockCommentPrefix(text) {
149
149
  const rawLines = text.split("\n");
150
150
  const result = [];
151
151
  for (let i = 0; i < rawLines.length; i++) {
@@ -183,7 +183,7 @@ function stripBlockCommentPrefix(text) {
183
183
  * This wraps to `- [DISPLAY_ID] Title\n\n body...` which parseMarkdown
184
184
  * recognizes as an entry block.
185
185
  */
186
- function wrapAsListItem(lines) {
186
+ export function wrapAsListItem(lines) {
187
187
  if (lines.length === 0)
188
188
  return "";
189
189
  const first = `- ${lines[0]}`;
@@ -171,22 +171,12 @@ function stringifySpec(spec) {
171
171
  * contents are irrelevant.
172
172
  */
173
173
  function buildPlaceholderEffective(tiers) {
174
- const leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
174
+ const _leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
175
175
  return {
176
- required: { value: [], origin: leafOrigin },
177
176
  attributes: new Map(),
178
- labels: { value: [], origin: leafOrigin },
177
+ labels: new Map(),
178
+ conventions: new Map(),
179
179
  colors: new Map(),
180
- identified: {
181
- required: { value: [], origin: leafOrigin },
182
- attributes: new Map(),
183
- traceability: new Map(),
184
- },
185
- referenced: {
186
- required: { value: [], origin: leafOrigin },
187
- attributes: new Map(),
188
- traceability: new Map(),
189
- },
190
180
  types: new Map(),
191
181
  documents: { types: new Map(), frontMatter: new Map() },
192
182
  };
@@ -24,7 +24,7 @@ const DEFAULT_HUE = "blue";
24
24
  * name) so the renderer works for files compiled without a profile.
25
25
  */
26
26
  export function resolveEntryColor(entry, profile) {
27
- if (entry.shape === "referenced")
27
+ if (entry.shape === "Reference")
28
28
  return null;
29
29
  if (!profile || !entry.type)
30
30
  return DEFAULT_HUE;
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @module core/profile/introspect
3
+ *
4
+ * Unified introspection API for profile chains. All discovery surfaces
5
+ * (CLI, MCP, LSP) consume this module instead of re-walking EffectiveProfile.
6
+ *
7
+ * Node-safe: no Deno.* APIs.
8
+ */
9
+ import type { LabelConcernKind, ProfileChain } from "../model/mod.js";
10
+ /** Discriminant for the five kinds of profile elements. */
11
+ export type ProfileElementKind = "type" | "attribute" | "relation" | "label-concern" | "convention";
12
+ /**
13
+ * A human-readable description with provenance: which profile tier contributed
14
+ * it and which tiers it overrides.
15
+ */
16
+ export interface ProvenancedDescription {
17
+ readonly text?: string;
18
+ readonly origin?: string;
19
+ readonly overrides?: string[];
20
+ }
21
+ /**
22
+ * A lightweight reference to a profile element, used in overview lists and
23
+ * resolve results. `ref` is `"<kind>/<name>"`, e.g. `"type/software-requirement"`.
24
+ */
25
+ export interface ProfileElementRef {
26
+ readonly kind: ProfileElementKind;
27
+ readonly name: string;
28
+ readonly summary: string;
29
+ /** `"<kind>/<name>"`, e.g. `"type/software-requirement"`. */
30
+ readonly ref: string;
31
+ }
32
+ /**
33
+ * High-level snapshot of the active profile chain: chain tiers and all
34
+ * declared elements as lightweight refs.
35
+ */
36
+ export interface ProfileOverview {
37
+ readonly tiers: readonly {
38
+ id: string;
39
+ version: string;
40
+ summary: string;
41
+ }[];
42
+ readonly elements: readonly ProfileElementRef[];
43
+ }
44
+ /** Detailed description of a profile-declared entry type. */
45
+ export interface TypeDetail {
46
+ readonly kind: "type";
47
+ readonly name: string;
48
+ readonly description: ProvenancedDescription;
49
+ readonly extendsTarget: string;
50
+ readonly shape: string;
51
+ readonly displayIdPattern?: string;
52
+ readonly color?: string;
53
+ readonly requiredAttributes: readonly ProfileElementRef[];
54
+ readonly allowedAttributes: readonly ProfileElementRef[];
55
+ readonly outgoingRelations: readonly ProfileElementRef[];
56
+ readonly incomingRelations: readonly ProfileElementRef[];
57
+ }
58
+ /** Detailed description of a universal or type-scoped attribute declaration. */
59
+ export interface AttributeDetail {
60
+ readonly kind: "attribute";
61
+ readonly name: string;
62
+ readonly description: ProvenancedDescription;
63
+ readonly valueType: string;
64
+ readonly cardinality: string;
65
+ readonly required: boolean;
66
+ readonly enumValues?: readonly string[];
67
+ readonly inverse?: {
68
+ name: string;
69
+ category: string;
70
+ };
71
+ readonly declaredBy: readonly string[];
72
+ }
73
+ /**
74
+ * Detailed description of a traceability relation, aggregated across all types
75
+ * that declare it.
76
+ */
77
+ export interface RelationDetail {
78
+ readonly kind: "relation";
79
+ readonly name: string;
80
+ readonly description: ProvenancedDescription;
81
+ readonly targets: readonly string[];
82
+ readonly cardinality?: string;
83
+ readonly required: boolean;
84
+ readonly declaredBy: readonly string[];
85
+ }
86
+ /** Detailed description of a label concern (enum, set, or flag). */
87
+ export interface LabelConcernDetail {
88
+ readonly kind: "label-concern";
89
+ readonly name: string;
90
+ readonly description: ProvenancedDescription;
91
+ readonly concernKind: LabelConcernKind;
92
+ readonly values: readonly {
93
+ name: string;
94
+ description?: string;
95
+ }[];
96
+ }
97
+ /**
98
+ * Detailed description of a named profile convention (e.g. `modal-keywords`).
99
+ */
100
+ export interface ConventionDetail {
101
+ readonly kind: "convention";
102
+ readonly name: string;
103
+ readonly description: ProvenancedDescription;
104
+ readonly settings: Readonly<Record<string, string>>;
105
+ }
106
+ /**
107
+ * Discriminated union of all per-element detail types returned by
108
+ * `ProfileIntrospection.describe`.
109
+ */
110
+ export type ProfileElementDetail = TypeDetail | AttributeDetail | RelationDetail | LabelConcernDetail | ConventionDetail;
111
+ /**
112
+ * Unified read-only view of a profile chain. Consumed by CLI, MCP, and LSP
113
+ * instead of walking `EffectiveProfile` directly.
114
+ */
115
+ export interface ProfileIntrospection {
116
+ /** Return a lazily computed, cached overview of all profile elements. */
117
+ overview(): ProfileOverview;
118
+ /**
119
+ * Return full detail for the named element, or `undefined` if not found.
120
+ */
121
+ describe(kind: ProfileElementKind, name: string): ProfileElementDetail | undefined;
122
+ /**
123
+ * Return elements whose kind/name/summary contain all whitespace-separated
124
+ * query tokens (case-insensitive).
125
+ */
126
+ resolve(query: string): ProfileElementRef[];
127
+ }
128
+ /**
129
+ * Build a `ProfileIntrospection` from a profile chain (or `null` when
130
+ * no profile is configured for the project).
131
+ *
132
+ * The returned object is lazy — `overview()` caches after the first call.
133
+ */
134
+ export declare function buildProfileIntrospection(chain: ProfileChain | null): ProfileIntrospection;
135
+ //# sourceMappingURL=introspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../src/profile/introspect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAGV,gBAAgB,EAChB,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAMzB,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,WAAW,GACX,UAAU,GACV,eAAe,GACf,YAAY,CAAC;AAEjB;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACjD;AAED,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;I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