@driftsys/markspec 0.3.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 (331) 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 +56 -6
  34. package/esm/formatter/mod.d.ts.map +1 -1
  35. package/esm/formatter/mod.js +372 -41
  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 +21 -8
  58. package/esm/mod.d.ts.map +1 -1
  59. package/esm/mod.js +16 -5
  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 +100 -3
  66. package/esm/model/mod.d.ts.map +1 -1
  67. package/esm/model/mod.js +58 -2
  68. package/esm/model/palette.d.ts +18 -0
  69. package/esm/model/palette.d.ts.map +1 -0
  70. package/esm/model/palette.js +23 -0
  71. package/esm/model/profile.d.ts +33 -27
  72. package/esm/model/profile.d.ts.map +1 -1
  73. package/esm/model/source_introspection.d.ts +26 -0
  74. package/esm/model/source_introspection.d.ts.map +1 -0
  75. package/esm/model/source_introspection.js +77 -0
  76. package/esm/model/type_hierarchy.d.ts +51 -0
  77. package/esm/model/type_hierarchy.d.ts.map +1 -0
  78. package/esm/model/type_hierarchy.js +126 -0
  79. package/esm/model/uri_scheme_map.d.ts +21 -0
  80. package/esm/model/uri_scheme_map.d.ts.map +1 -0
  81. package/esm/model/uri_scheme_map.js +66 -0
  82. package/esm/parser/attributes.d.ts.map +1 -1
  83. package/esm/parser/attributes.js +9 -6
  84. package/esm/parser/entity_refs.d.ts +53 -0
  85. package/esm/parser/entity_refs.d.ts.map +1 -0
  86. package/esm/parser/entity_refs.js +151 -0
  87. package/esm/parser/glossary.d.ts +43 -0
  88. package/esm/parser/glossary.d.ts.map +1 -0
  89. package/esm/parser/glossary.js +217 -0
  90. package/esm/parser/markdown.d.ts +10 -3
  91. package/esm/parser/markdown.d.ts.map +1 -1
  92. package/esm/parser/markdown.js +241 -11
  93. package/esm/parser/mod.d.ts +1 -0
  94. package/esm/parser/mod.d.ts.map +1 -1
  95. package/esm/parser/mod.js +4 -3
  96. package/esm/parser/source.d.ts +20 -0
  97. package/esm/parser/source.d.ts.map +1 -1
  98. package/esm/parser/source.js +4 -4
  99. package/esm/profile/chain.js +3 -13
  100. package/esm/profile/colors.d.ts +26 -0
  101. package/esm/profile/colors.d.ts.map +1 -0
  102. package/esm/profile/colors.js +46 -0
  103. package/esm/profile/introspect.d.ts +135 -0
  104. package/esm/profile/introspect.d.ts.map +1 -0
  105. package/esm/profile/introspect.js +378 -0
  106. package/esm/profile/load.d.ts.map +1 -1
  107. package/esm/profile/load.js +67 -0
  108. package/esm/profile/manifest.d.ts.map +1 -1
  109. package/esm/profile/manifest.js +278 -104
  110. package/esm/profile/merge.js +139 -39
  111. package/esm/profile/mod.d.ts +3 -4
  112. package/esm/profile/mod.d.ts.map +1 -1
  113. package/esm/profile/mod.js +6 -2
  114. package/esm/reporter/mod.js +4 -4
  115. package/esm/util/fence.d.ts +30 -0
  116. package/esm/util/fence.d.ts.map +1 -0
  117. package/esm/util/fence.js +40 -0
  118. package/esm/validator/attributes.d.ts +3 -3
  119. package/esm/validator/attributes.d.ts.map +1 -1
  120. package/esm/validator/attributes.js +1 -18
  121. package/esm/validator/body_blocks.d.ts +38 -0
  122. package/esm/validator/body_blocks.d.ts.map +1 -0
  123. package/esm/validator/body_blocks.js +218 -0
  124. package/esm/validator/caption_convention.d.ts +29 -0
  125. package/esm/validator/caption_convention.d.ts.map +1 -0
  126. package/esm/validator/caption_convention.js +58 -0
  127. package/esm/validator/captions.d.ts +22 -0
  128. package/esm/validator/captions.d.ts.map +1 -0
  129. package/esm/validator/captions.js +137 -0
  130. package/esm/validator/component_schemes.d.ts +73 -0
  131. package/esm/validator/component_schemes.d.ts.map +1 -0
  132. package/esm/validator/component_schemes.js +375 -0
  133. package/esm/validator/feature_ac.d.ts +28 -0
  134. package/esm/validator/feature_ac.d.ts.map +1 -0
  135. package/esm/validator/feature_ac.js +102 -0
  136. package/esm/validator/listing.d.ts +42 -0
  137. package/esm/validator/listing.d.ts.map +1 -0
  138. package/esm/validator/listing.js +295 -0
  139. package/esm/validator/mod.d.ts +2 -0
  140. package/esm/validator/mod.d.ts.map +1 -1
  141. package/esm/validator/mod.js +253 -12
  142. package/esm/validator/modal_keywords.d.ts +23 -0
  143. package/esm/validator/modal_keywords.d.ts.map +1 -0
  144. package/esm/validator/modal_keywords.js +137 -0
  145. package/esm/validator/per_type_attrs.d.ts +29 -0
  146. package/esm/validator/per_type_attrs.d.ts.map +1 -0
  147. package/esm/validator/per_type_attrs.js +75 -0
  148. package/esm/validator/pipeline.d.ts +7 -2
  149. package/esm/validator/pipeline.d.ts.map +1 -1
  150. package/esm/validator/pipeline.js +40 -7
  151. package/esm/validator/trace_types.d.ts +26 -0
  152. package/esm/validator/trace_types.d.ts.map +1 -0
  153. package/esm/validator/trace_types.js +232 -0
  154. package/esm/validator/traceability.d.ts +3 -4
  155. package/esm/validator/traceability.d.ts.map +1 -1
  156. package/esm/validator/traceability.js +5 -10
  157. package/esm/validator/type_resolution.d.ts +67 -0
  158. package/esm/validator/type_resolution.d.ts.map +1 -0
  159. package/esm/validator/type_resolution.js +140 -0
  160. package/esm/validator/types.d.ts +45 -0
  161. package/esm/validator/types.d.ts.map +1 -1
  162. package/esm/validator/types.js +128 -16
  163. package/esm/validator/value_types.d.ts +8 -0
  164. package/esm/validator/value_types.d.ts.map +1 -1
  165. package/esm/validator/value_types.js +8 -1
  166. package/package.json +1 -1
  167. package/script/ast/build.d.ts +70 -0
  168. package/script/ast/build.d.ts.map +1 -0
  169. package/script/ast/build.js +610 -0
  170. package/script/ast/equivalence.d.ts +18 -0
  171. package/script/ast/equivalence.d.ts.map +1 -0
  172. package/script/ast/equivalence.js +59 -0
  173. package/script/ast/nodes.d.ts +221 -0
  174. package/script/ast/nodes.d.ts.map +1 -0
  175. package/script/ast/nodes.js +13 -0
  176. package/script/ast/normalize.d.ts +67 -0
  177. package/script/ast/normalize.d.ts.map +1 -0
  178. package/script/ast/normalize.js +258 -0
  179. package/script/ast/render.d.ts +34 -0
  180. package/script/ast/render.d.ts.map +1 -0
  181. package/script/ast/render.js +218 -0
  182. package/script/compiler/inverses.d.ts +2 -8
  183. package/script/compiler/inverses.d.ts.map +1 -1
  184. package/script/compiler/inverses.js +50 -14
  185. package/script/compiler/manifest.d.ts +59 -0
  186. package/script/compiler/manifest.d.ts.map +1 -0
  187. package/script/compiler/manifest.js +51 -0
  188. package/script/compiler/mod.d.ts +9 -1
  189. package/script/compiler/mod.d.ts.map +1 -1
  190. package/script/compiler/mod.js +21 -2
  191. package/script/compiler/ndjson_writer.d.ts +50 -0
  192. package/script/compiler/ndjson_writer.d.ts.map +1 -0
  193. package/script/compiler/ndjson_writer.js +78 -0
  194. package/script/compiler/schema.d.ts +18 -1
  195. package/script/compiler/schema.d.ts.map +1 -1
  196. package/script/compiler/schema.js +18 -8
  197. package/script/config/mod.d.ts.map +1 -1
  198. package/script/config/mod.js +54 -0
  199. package/script/formatter/mod.d.ts +56 -6
  200. package/script/formatter/mod.d.ts.map +1 -1
  201. package/script/formatter/mod.js +375 -41
  202. package/script/formatter/synth_ulid.d.ts +21 -0
  203. package/script/formatter/synth_ulid.d.ts.map +1 -0
  204. package/script/formatter/synth_ulid.js +67 -0
  205. package/script/lint/mod.d.ts +10 -0
  206. package/script/lint/mod.d.ts.map +1 -0
  207. package/script/lint/mod.js +12 -0
  208. package/script/lint/rules/lexicon.d.ts +24 -0
  209. package/script/lint/rules/lexicon.d.ts.map +1 -0
  210. package/script/lint/rules/lexicon.js +240 -0
  211. package/script/lint/rules/struct.d.ts +17 -0
  212. package/script/lint/rules/struct.d.ts.map +1 -0
  213. package/script/lint/rules/struct.js +59 -0
  214. package/script/lint/rules/suppression.d.ts +19 -0
  215. package/script/lint/rules/suppression.d.ts.map +1 -0
  216. package/script/lint/rules/suppression.js +80 -0
  217. package/script/lint/runner.d.ts +39 -0
  218. package/script/lint/runner.d.ts.map +1 -0
  219. package/script/lint/runner.js +116 -0
  220. package/script/lint/types.d.ts +19 -0
  221. package/script/lint/types.d.ts.map +1 -0
  222. package/script/lint/types.js +10 -0
  223. package/script/mod.d.ts +21 -8
  224. package/script/mod.d.ts.map +1 -1
  225. package/script/mod.js +58 -32
  226. package/script/model/attributes.d.ts.map +1 -1
  227. package/script/model/attributes.js +163 -2
  228. package/script/model/discriminating_attr.d.ts +33 -0
  229. package/script/model/discriminating_attr.d.ts.map +1 -0
  230. package/script/model/discriminating_attr.js +77 -0
  231. package/script/model/mod.d.ts +100 -3
  232. package/script/model/mod.d.ts.map +1 -1
  233. package/script/model/mod.js +67 -3
  234. package/script/model/palette.d.ts +18 -0
  235. package/script/model/palette.d.ts.map +1 -0
  236. package/script/model/palette.js +26 -0
  237. package/script/model/profile.d.ts +33 -27
  238. package/script/model/profile.d.ts.map +1 -1
  239. package/script/model/source_introspection.d.ts +26 -0
  240. package/script/model/source_introspection.d.ts.map +1 -0
  241. package/script/model/source_introspection.js +80 -0
  242. package/script/model/type_hierarchy.d.ts +51 -0
  243. package/script/model/type_hierarchy.d.ts.map +1 -0
  244. package/script/model/type_hierarchy.js +130 -0
  245. package/script/model/uri_scheme_map.d.ts +21 -0
  246. package/script/model/uri_scheme_map.d.ts.map +1 -0
  247. package/script/model/uri_scheme_map.js +69 -0
  248. package/script/parser/attributes.d.ts.map +1 -1
  249. package/script/parser/attributes.js +9 -6
  250. package/script/parser/entity_refs.d.ts +53 -0
  251. package/script/parser/entity_refs.d.ts.map +1 -0
  252. package/script/parser/entity_refs.js +155 -0
  253. package/script/parser/glossary.d.ts +43 -0
  254. package/script/parser/glossary.d.ts.map +1 -0
  255. package/script/parser/glossary.js +221 -0
  256. package/script/parser/markdown.d.ts +10 -3
  257. package/script/parser/markdown.d.ts.map +1 -1
  258. package/script/parser/markdown.js +240 -10
  259. package/script/parser/mod.d.ts +1 -0
  260. package/script/parser/mod.d.ts.map +1 -1
  261. package/script/parser/mod.js +8 -4
  262. package/script/parser/source.d.ts +20 -0
  263. package/script/parser/source.d.ts.map +1 -1
  264. package/script/parser/source.js +4 -1
  265. package/script/profile/chain.js +3 -13
  266. package/script/profile/colors.d.ts +26 -0
  267. package/script/profile/colors.d.ts.map +1 -0
  268. package/script/profile/colors.js +49 -0
  269. package/script/profile/introspect.d.ts +135 -0
  270. package/script/profile/introspect.d.ts.map +1 -0
  271. package/script/profile/introspect.js +381 -0
  272. package/script/profile/load.d.ts.map +1 -1
  273. package/script/profile/load.js +67 -0
  274. package/script/profile/manifest.d.ts.map +1 -1
  275. package/script/profile/manifest.js +280 -106
  276. package/script/profile/merge.js +139 -39
  277. package/script/profile/mod.d.ts +3 -4
  278. package/script/profile/mod.d.ts.map +1 -1
  279. package/script/profile/mod.js +9 -6
  280. package/script/reporter/mod.js +4 -4
  281. package/script/util/fence.d.ts +30 -0
  282. package/script/util/fence.d.ts.map +1 -0
  283. package/script/util/fence.js +44 -0
  284. package/script/validator/attributes.d.ts +3 -3
  285. package/script/validator/attributes.d.ts.map +1 -1
  286. package/script/validator/attributes.js +1 -18
  287. package/script/validator/body_blocks.d.ts +38 -0
  288. package/script/validator/body_blocks.d.ts.map +1 -0
  289. package/script/validator/body_blocks.js +221 -0
  290. package/script/validator/caption_convention.d.ts +29 -0
  291. package/script/validator/caption_convention.d.ts.map +1 -0
  292. package/script/validator/caption_convention.js +61 -0
  293. package/script/validator/captions.d.ts +22 -0
  294. package/script/validator/captions.d.ts.map +1 -0
  295. package/script/validator/captions.js +140 -0
  296. package/script/validator/component_schemes.d.ts +73 -0
  297. package/script/validator/component_schemes.d.ts.map +1 -0
  298. package/script/validator/component_schemes.js +384 -0
  299. package/script/validator/feature_ac.d.ts +28 -0
  300. package/script/validator/feature_ac.d.ts.map +1 -0
  301. package/script/validator/feature_ac.js +105 -0
  302. package/script/validator/listing.d.ts +42 -0
  303. package/script/validator/listing.d.ts.map +1 -0
  304. package/script/validator/listing.js +298 -0
  305. package/script/validator/mod.d.ts +2 -0
  306. package/script/validator/mod.d.ts.map +1 -1
  307. package/script/validator/mod.js +256 -14
  308. package/script/validator/modal_keywords.d.ts +23 -0
  309. package/script/validator/modal_keywords.d.ts.map +1 -0
  310. package/script/validator/modal_keywords.js +140 -0
  311. package/script/validator/per_type_attrs.d.ts +29 -0
  312. package/script/validator/per_type_attrs.d.ts.map +1 -0
  313. package/script/validator/per_type_attrs.js +78 -0
  314. package/script/validator/pipeline.d.ts +7 -2
  315. package/script/validator/pipeline.d.ts.map +1 -1
  316. package/script/validator/pipeline.js +39 -6
  317. package/script/validator/trace_types.d.ts +26 -0
  318. package/script/validator/trace_types.d.ts.map +1 -0
  319. package/script/validator/trace_types.js +235 -0
  320. package/script/validator/traceability.d.ts +3 -4
  321. package/script/validator/traceability.d.ts.map +1 -1
  322. package/script/validator/traceability.js +5 -10
  323. package/script/validator/type_resolution.d.ts +67 -0
  324. package/script/validator/type_resolution.d.ts.map +1 -0
  325. package/script/validator/type_resolution.js +146 -0
  326. package/script/validator/types.d.ts +45 -0
  327. package/script/validator/types.d.ts.map +1 -1
  328. package/script/validator/types.js +131 -16
  329. package/script/validator/value_types.d.ts +8 -0
  330. package/script/validator/value_types.d.ts.map +1 -1
  331. package/script/validator/value_types.js +10 -2
@@ -9,7 +9,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.parseMarkdown = parseMarkdown;
10
10
  const mod_js_1 = require("../model/mod.js");
11
11
  const attributes_js_1 = require("./attributes.js");
12
+ const entity_refs_js_1 = require("./entity_refs.js");
12
13
  const remark_js_1 = require("./remark.js");
14
+ const build_js_1 = require("../ast/build.js");
13
15
  /**
14
16
  * Slug pattern for referenced-entry display IDs.
15
17
  *
@@ -20,6 +22,10 @@ const remark_js_1 = require("./remark.js");
20
22
  const SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
21
23
  /** Match `[...]` at the start of a list item paragraph. Captures: [1] = display ID, [2] = title. */
22
24
  const ENTRY_START_RE = /^\[([^\]]+)\]\s*(.*)$/;
25
+ /** Match `[]` at the start — empty brackets. */
26
+ const EMPTY_BRACKET_RE = /^\[\]\s*(.*)$/;
27
+ /** Match `[` at the start without a closing `]` on the same logical content — unterminated. */
28
+ const UNTERMINATED_BRACKET_RE = /^\[[^\]]*$/;
23
29
  /**
24
30
  * Find the `Id:` attribute on an entry. Returns undefined when absent. If
25
31
  * more than one `Id:` is present, returns the first — the validator flags
@@ -42,13 +48,14 @@ function findIdentityAttribute(attributes) {
42
48
  *
43
49
  * @param markdown - Markdown source text
44
50
  * @param options - Parse options (file path for source locations)
45
- * @returns Array of parsed entries
51
+ * @returns Parsed entries and any parse-level diagnostics
46
52
  */
47
53
  function parseMarkdown(markdown, options) {
48
54
  const file = options?.file ?? "<unknown>";
49
55
  const isReferencesDoc = detectReferencesDocument(file, options?.isReferencesDoc);
50
56
  const tree = remark_js_1.processor.parse(markdown);
51
57
  const entries = [];
58
+ const diagnostics = [];
52
59
  // Collect link definition identifiers for shortcut reference exclusion.
53
60
  const definitions = new Set(tree.children
54
61
  .filter((n) => n.type === "definition")
@@ -61,12 +68,12 @@ function parseMarkdown(markdown, options) {
61
68
  if (list.ordered)
62
69
  continue;
63
70
  for (const item of list.children) {
64
- const entry = extractEntry(item, markdown, file, definitions, isReferencesDoc);
71
+ const entry = extractEntry(item, markdown, file, definitions, isReferencesDoc, diagnostics);
65
72
  if (entry)
66
73
  entries.push(entry);
67
74
  }
68
75
  }
69
- return entries;
76
+ return { entries, diagnostics };
70
77
  }
71
78
  /**
72
79
  * Detect if a file is a references document.
@@ -83,8 +90,9 @@ function detectReferencesDocument(file, explicit) {
83
90
  /**
84
91
  * Attempt to extract a MarkSpec entry from a list item.
85
92
  * Returns undefined if the list item is not an entry block.
93
+ * Diagnostics (e.g., deprecation warnings) are pushed into the accumulator.
86
94
  */
87
- function extractEntry(item, markdown, file, definitions, isReferencesDoc) {
95
+ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagnostics) {
88
96
  // Task list items (remark-gfm sets checked to true/false) are not entries.
89
97
  if (item.checked != null)
90
98
  return undefined;
@@ -106,11 +114,36 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc) {
106
114
  let title;
107
115
  if (firstInline.type === "text") {
108
116
  // remark may parse `[ID] Title` as a single text node
109
- const match = ENTRY_START_RE.exec(firstInline.value);
117
+ const textValue = firstInline.value;
118
+ const match = ENTRY_START_RE.exec(textValue);
110
119
  if (match) {
111
120
  displayId = match[1];
112
121
  title = match[2].trim();
113
122
  }
123
+ else if (EMPTY_BRACKET_RE.test(textValue)) {
124
+ // MSL-P001: bracketed content is empty — `- [] Title`
125
+ const entryLine = item.position?.start.line ?? 1;
126
+ diagnostics.push({
127
+ code: "MSL-P001",
128
+ severity: "error",
129
+ message: "list item starts with `[]` but the bracketed content is empty " +
130
+ "(spec section 4.1)",
131
+ location: { file, line: entryLine, column: 1 },
132
+ });
133
+ return undefined;
134
+ }
135
+ else if (UNTERMINATED_BRACKET_RE.test(textValue)) {
136
+ // MSL-P003: display-ID brackets unterminated (missing `]`)
137
+ const entryLine = item.position?.start.line ?? 1;
138
+ diagnostics.push({
139
+ code: "MSL-P003",
140
+ severity: "error",
141
+ message: "display-ID brackets unterminated -- missing `]` before end of " +
142
+ "title line (spec section 4.1)",
143
+ location: { file, line: entryLine, column: 1 },
144
+ });
145
+ return undefined;
146
+ }
114
147
  }
115
148
  // Try linkReference pattern: remark sometimes parses [ID] as a linkReference
116
149
  if (!displayId && firstInline.type === "linkReference") {
@@ -141,10 +174,180 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc) {
141
174
  // citation compatibility. Canonical slug never contains `@`.
142
175
  if (displayId.startsWith("@"))
143
176
  displayId = displayId.slice(1);
177
+ // MSL-I005: Display ID is empty (after `@` stripping).
178
+ if (displayId.length === 0) {
179
+ const entryLine = item.position?.start.line ?? 1;
180
+ diagnostics.push({
181
+ code: "MSL-I005",
182
+ severity: "error",
183
+ message: "display ID is empty (spec section 4.2)",
184
+ location: { file, line: entryLine, column: 1 },
185
+ });
186
+ return undefined;
187
+ }
188
+ // MSL-P002: title text missing after `]`. The title capture is empty
189
+ // and was not populated from subsequent nodes (linkReference path sets
190
+ // title from rest nodes).
191
+ if (title !== undefined && title.length === 0) {
192
+ const entryLine = item.position?.start.line ?? 1;
193
+ diagnostics.push({
194
+ code: "MSL-P002",
195
+ severity: "error",
196
+ message: `${displayId}: title line missing title text after ']' (spec section 4.1)`,
197
+ location: { file, line: entryLine, column: 1 },
198
+ });
199
+ // Continue parsing — entry is still structurally valid for downstream
200
+ // validation (MSL-P010 also fires from the validator for empty titles).
201
+ }
144
202
  // Extract body content and attributes.
145
203
  const bodyContent = extractBodyContent(item, markdown);
146
204
  const [body, attrLines] = (0, attributes_js_1.splitBodyAndAttributes)(bodyContent);
147
205
  const attributes = (0, attributes_js_1.parseAttributes)(attrLines);
206
+ const bodyAst = (0, build_js_1.buildBodyAst)(body);
207
+ const entryLine = item.position?.start.line ?? 1;
208
+ // MSL-P020: trailers block is not the final indented code block.
209
+ // Detect `Key: Value` lines in the body that likely should be trailers
210
+ // but are not at the final position (body content follows them).
211
+ // Exclude caption keywords (Figure:, Table:, etc.) which are legitimate
212
+ // body content, not misplaced trailer attributes.
213
+ const CAPTION_KEYWORDS = new Set([
214
+ "Figure",
215
+ "Table",
216
+ "Listing",
217
+ "Feature",
218
+ "Equation",
219
+ "List",
220
+ ]);
221
+ if (body.length > 0) {
222
+ const bodyLines = body.split("\n");
223
+ let inFencedBlock = false;
224
+ for (let i = 0; i < bodyLines.length; i++) {
225
+ const trimmed = bodyLines[i].trim();
226
+ // Track fenced code blocks (``` or ~~~) to skip their contents
227
+ if (/^(`{3,}|~{3,})/.test(trimmed)) {
228
+ inFencedBlock = !inFencedBlock;
229
+ continue;
230
+ }
231
+ if (inFencedBlock)
232
+ continue;
233
+ if (!attributes_js_1.ATTR_LINE_RE.test(trimmed))
234
+ continue;
235
+ // Extract the key portion to check against caption keywords
236
+ const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
237
+ if (keyMatch && CAPTION_KEYWORDS.has(keyMatch[1]))
238
+ continue;
239
+ // Found a Key: Value line in the body — non-final position
240
+ diagnostics.push({
241
+ code: "MSL-P020",
242
+ severity: "error",
243
+ message: `${displayId}: trailers block is not the final indented code ` +
244
+ `block of the entry -- content appears after trailer-like ` +
245
+ `lines (spec section 4.1)`,
246
+ location: { file, line: entryLine, column: 1 },
247
+ });
248
+ break; // One diagnostic per entry is sufficient
249
+ }
250
+ }
251
+ // MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
252
+ // The trailer block is the final indented code block. Lines within it
253
+ // should all match `Key: Value` syntax. We check both the parsed
254
+ // attrLines AND the trailing body lines that might be in a code block
255
+ // but failed ATTR_LINE_RE (thus stayed in the body).
256
+ const TRAILER_KEY_RE = /^[A-Za-z][A-Za-z0-9-]*$/;
257
+ const COLON_SPLIT_RE = /^([^:]+):\s*(.*)$/;
258
+ // Check lines that DID end up in attrLines but might have key issues
259
+ for (const rawLine of attrLines) {
260
+ const trimmed = rawLine.trim();
261
+ if (!trimmed)
262
+ continue;
263
+ if (!attributes_js_1.ATTR_LINE_RE.test(trimmed)) {
264
+ const colonMatch = COLON_SPLIT_RE.exec(trimmed);
265
+ if (colonMatch) {
266
+ const key = colonMatch[1].trim();
267
+ if (!TRAILER_KEY_RE.test(key)) {
268
+ diagnostics.push({
269
+ code: "MSL-P022",
270
+ severity: "error",
271
+ message: `${displayId}: trailer key '${key}' contains characters ` +
272
+ `outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
273
+ location: { file, line: entryLine, column: 1 },
274
+ });
275
+ }
276
+ else {
277
+ diagnostics.push({
278
+ code: "MSL-P021",
279
+ severity: "error",
280
+ message: `${displayId}: trailer line does not match 'Key: Value' ` +
281
+ `syntax (spec section 4.1): "${trimmed}"`,
282
+ location: { file, line: entryLine, column: 1 },
283
+ });
284
+ }
285
+ }
286
+ else {
287
+ diagnostics.push({
288
+ code: "MSL-P021",
289
+ severity: "error",
290
+ message: `${displayId}: trailer line does not match 'Key: Value' ` +
291
+ `syntax (spec section 4.1): "${trimmed}"`,
292
+ location: { file, line: entryLine, column: 1 },
293
+ });
294
+ }
295
+ }
296
+ }
297
+ // Also scan trailing body lines for suspected misplaced trailers.
298
+ // If the body's last non-empty lines look like they belong to an
299
+ // indented code block with colon-separated content that has invalid
300
+ // keys, emit P022. Lines without colons that appear in what looks
301
+ // like a trailer block emit P021.
302
+ if (body.length > 0) {
303
+ const bodyLines = body.split("\n");
304
+ // Walk backward from the end of the body to find lines in a trailing
305
+ // code-block-like region that have colons (suspected trailers).
306
+ for (let i = bodyLines.length - 1; i >= 0; i--) {
307
+ const trimmed = bodyLines[i].trim();
308
+ if (!trimmed)
309
+ continue; // skip trailing blanks
310
+ const colonMatch = COLON_SPLIT_RE.exec(trimmed);
311
+ if (!colonMatch)
312
+ break; // stop at non-colon line
313
+ const key = colonMatch[1].trim();
314
+ if (attributes_js_1.ATTR_LINE_RE.test(trimmed)) {
315
+ // Valid attr line in body → already caught by P020
316
+ continue;
317
+ }
318
+ if (!TRAILER_KEY_RE.test(key)) {
319
+ diagnostics.push({
320
+ code: "MSL-P022",
321
+ severity: "error",
322
+ message: `${displayId}: trailer key '${key}' contains characters ` +
323
+ `outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
324
+ location: { file, line: entryLine, column: 1 },
325
+ });
326
+ }
327
+ else if (colonMatch[2].trim().length === 0) {
328
+ diagnostics.push({
329
+ code: "MSL-P021",
330
+ severity: "error",
331
+ message: `${displayId}: trailer line does not match 'Key: Value' ` +
332
+ `syntax (spec section 4.1): "${trimmed}"`,
333
+ location: { file, line: entryLine, column: 1 },
334
+ });
335
+ }
336
+ break; // one diagnostic per trailing suspect line is sufficient
337
+ }
338
+ }
339
+ // Detect legacy paragraph + trailing-backslash attribute form and warn.
340
+ if (attributes.length > 0 &&
341
+ attrLines.some((line) => line.trimEnd().endsWith("\\"))) {
342
+ const entryLine = item.position?.start.line ?? 1;
343
+ diagnostics.push({
344
+ code: "MSL-DEPRECATED-ATTR-001",
345
+ severity: "warning",
346
+ message: "legacy attribute block (paragraph with trailing `\\`) is deprecated; " +
347
+ "run `markspec format` to convert to the canonical indented code block",
348
+ location: { file, line: entryLine, column: 1 },
349
+ });
350
+ }
148
351
  // Discriminate shape by the `Id:` attribute's value format.
149
352
  let shape;
150
353
  let id;
@@ -156,45 +359,72 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc) {
156
359
  // `Id:` is neither a ULID nor a scheme-qualified URI. Accept as an
157
360
  // identified entry so the validator can surface MSL-R004; missing
158
361
  // shape on a parsed entry is not useful downstream.
159
- shape = "identified";
362
+ shape = "Authored";
160
363
  }
161
364
  }
162
365
  else {
163
366
  // No `Id:`. Fall back on display-ID shape + document context to decide
164
367
  // whether to admit the entry at all.
165
368
  if (isReferencesDoc && SLUG_RE.test(displayId)) {
166
- shape = "referenced";
369
+ shape = "Reference";
167
370
  }
168
371
  else {
169
372
  // No identity attribute and no references-doc context — admit as
170
373
  // identified so the validator can surface the missing-`Id:` error.
171
- shape = "identified";
374
+ shape = "Authored";
172
375
  }
173
376
  }
174
377
  // Inferred type from display-ID prefix — left to the profile layer. For
175
378
  // now the core records no type; downstream profile-aware code populates
176
379
  // this field when a profile is loaded.
177
380
  const type = undefined;
381
+ // MSL-P030: Authored entry has no body block (title + trailers only).
382
+ // For Reference shape, body is optional (ADR-002 section Part 3). For Authored,
383
+ // the body is required. We also emit P030 when the body is empty (all
384
+ // content was consumed as attributes).
385
+ if (shape === "Authored" && body.trim().length === 0) {
386
+ diagnostics.push({
387
+ code: "MSL-P030",
388
+ severity: "error",
389
+ message: `${displayId}: Authored entry has no body block -- entries must ` +
390
+ `have body content between title and trailers (spec section 4.1)`,
391
+ location: { file, line: entryLine, column: 1 },
392
+ });
393
+ }
178
394
  // Body requirement: identified entries require a body; referenced entries
179
395
  // may omit it. If there's only one child (the title paragraph), admit
180
396
  // only referenced entries.
181
- if (shape !== "referenced" && item.children.length < 2)
397
+ if (shape !== "Reference" && item.children.length < 2)
182
398
  return undefined;
183
399
  // Source location
184
400
  const line = item.position?.start.line ?? 1;
185
401
  const column = item.position?.start.column ?? 1;
402
+ const entryLocation = { file, line, column };
403
+ // Inline `$Identifier` entity references (spec section 2.5.2). Resolution
404
+ // into the project's entity registry is left to the validator's
405
+ // marker pass; the parser only emits the lexical hits.
406
+ // Pass the already-built bodyAst to avoid a redundant mdast parse.
407
+ const entityRefs = (0, entity_refs_js_1.extractEntityRefs)(body, {
408
+ file,
409
+ // Body content starts on the line after the title; +1 keeps
410
+ // emitted line numbers 1-based relative to the file.
411
+ line: line + 1,
412
+ column: 1,
413
+ }, bodyAst);
186
414
  return {
187
415
  displayId,
188
416
  title: title ?? "",
189
417
  body,
418
+ bodyAst,
190
419
  rawAttributes: attributes,
191
420
  typedAttributes: (0, attributes_js_1.collateAttributes)(attributes),
192
421
  id,
193
422
  type,
194
423
  shape,
195
- location: { file, line, column },
424
+ location: entryLocation,
196
425
  source: "markdown",
197
426
  properties: { file: { path: file, line, column } },
427
+ entityRefs: entityRefs.length > 0 ? entityRefs : undefined,
198
428
  };
199
429
  }
200
430
  /**
@@ -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,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAK5E,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAElE,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;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"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAK5E,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAElE,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;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"}
@@ -11,7 +11,7 @@
11
11
  * - source: doc comment extraction from Rust, Kotlin, C, C++, Java
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.loadGrammar = exports.isSupportedExtension = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
14
+ exports.loadGrammar = exports.isSupportedExtension = exports.wrapAsListItem = exports.stripLineCommentPrefix = exports.stripBlockCommentPrefix = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
15
15
  exports.parse = parse;
16
16
  exports.parseFile = parseFile;
17
17
  exports.detectCaptions = detectCaptions;
@@ -29,6 +29,10 @@ var references_js_1 = require("./references.js");
29
29
  Object.defineProperty(exports, "detectInlineRefs", { enumerable: true, get: function () { return references_js_1.detectInlineRefs; } });
30
30
  var source_js_2 = require("./source.js");
31
31
  Object.defineProperty(exports, "parseSource", { enumerable: true, get: function () { return source_js_2.parseSource; } });
32
+ var source_js_3 = require("./source.js");
33
+ Object.defineProperty(exports, "stripBlockCommentPrefix", { enumerable: true, get: function () { return source_js_3.stripBlockCommentPrefix; } });
34
+ Object.defineProperty(exports, "stripLineCommentPrefix", { enumerable: true, get: function () { return source_js_3.stripLineCommentPrefix; } });
35
+ Object.defineProperty(exports, "wrapAsListItem", { enumerable: true, get: function () { return source_js_3.wrapAsListItem; } });
32
36
  var grammars_js_2 = require("./grammars.js");
33
37
  Object.defineProperty(exports, "isSupportedExtension", { enumerable: true, get: function () { return grammars_js_2.isSupportedExtension; } });
34
38
  Object.defineProperty(exports, "loadGrammar", { enumerable: true, get: function () { return grammars_js_2.loadGrammar; } });
@@ -40,7 +44,7 @@ Object.defineProperty(exports, "loadGrammar", { enumerable: true, get: function
40
44
  * @returns Array of parsed entries
41
45
  */
42
46
  function parse(markdown, options) {
43
- return (0, markdown_js_1.parseMarkdown)(markdown, options);
47
+ return (0, markdown_js_1.parseMarkdown)(markdown, options).entries;
44
48
  }
45
49
  /**
46
50
  * Detect if a file is a references document.
@@ -72,7 +76,7 @@ async function parseFile(content, options) {
72
76
  const fm = (0, frontmatter_js_1.extractFrontMatter)(content, { file: options.file });
73
77
  const body = fm.hadFrontMatter ? fm.markdown : content;
74
78
  const isReferencesDoc = isReferencesDocument(options.file);
75
- const entries = (0, markdown_js_1.parseMarkdown)(body, {
79
+ const { entries, diagnostics: parseDiagnostics } = (0, markdown_js_1.parseMarkdown)(body, {
76
80
  file: options.file,
77
81
  isReferencesDoc,
78
82
  });
@@ -86,7 +90,7 @@ async function parseFile(content, options) {
86
90
  return {
87
91
  entries,
88
92
  document,
89
- diagnostics: fm.diagnostics,
93
+ diagnostics: [...fm.diagnostics, ...parseDiagnostics],
90
94
  };
91
95
  }
92
96
  /**
@@ -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"}
@@ -11,6 +11,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.parseSource = parseSource;
14
+ exports.stripLineCommentPrefix = stripLineCommentPrefix;
15
+ exports.stripBlockCommentPrefix = stripBlockCommentPrefix;
16
+ exports.wrapAsListItem = wrapAsListItem;
14
17
  const web_tree_sitter_1 = __importDefault(require("web-tree-sitter"));
15
18
  const markdown_js_1 = require("./markdown.js");
16
19
  /**
@@ -33,7 +36,7 @@ function parseSource(content, options) {
33
36
  const entries = [];
34
37
  for (const block of blocks) {
35
38
  const markdown = wrapAsListItem(block.lines);
36
- const parsed = (0, markdown_js_1.parseMarkdown)(markdown, { file });
39
+ const { entries: parsed } = (0, markdown_js_1.parseMarkdown)(markdown, { file });
37
40
  for (const entry of parsed) {
38
41
  const location = {
39
42
  file,
@@ -207,22 +207,12 @@ function stringifySpec(spec) {
207
207
  * contents are irrelevant.
208
208
  */
209
209
  function buildPlaceholderEffective(tiers) {
210
- const leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
210
+ const _leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
211
211
  return {
212
- required: { value: [], origin: leafOrigin },
213
212
  attributes: new Map(),
214
- labels: { value: [], origin: leafOrigin },
213
+ labels: new Map(),
214
+ conventions: new Map(),
215
215
  colors: new Map(),
216
- identified: {
217
- required: { value: [], origin: leafOrigin },
218
- attributes: new Map(),
219
- traceability: new Map(),
220
- },
221
- referenced: {
222
- required: { value: [], origin: leafOrigin },
223
- attributes: new Map(),
224
- traceability: new Map(),
225
- },
226
216
  types: new Map(),
227
217
  documents: { types: new Map(), frontMatter: new Map() },
228
218
  };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @module core/profile/colors
3
+ *
4
+ * Profile-driven entry color resolution. Pure function that maps an entry
5
+ * and the active profile to a palette hue name (or `null` for uncolored).
6
+ *
7
+ * Lives in core/profile so both rendering layers (Typst PDF and HTML book)
8
+ * can call it without crossing the peer-module boundary defined in AGENTS.md.
9
+ *
10
+ * See docs/superpowers/specs/2026-05-06-profile-driven-entry-colors-design.md
11
+ * for the resolution table.
12
+ */
13
+ import type { EffectiveProfile, Entry } from "../model/mod.js";
14
+ import { type PaletteHue } from "../model/palette.js";
15
+ /**
16
+ * Resolve the palette hue for an entry under the active profile.
17
+ *
18
+ * Returns `null` for referenced-shape entries (uncolored block).
19
+ * Returns a palette hue name for identified entries — using the type's
20
+ * declared color when available, falling back to `"blue"` otherwise.
21
+ *
22
+ * The fallback is the palette hue directly (not the `primary` semantic
23
+ * name) so the renderer works for files compiled without a profile.
24
+ */
25
+ export declare function resolveEntryColor(entry: Entry, profile: EffectiveProfile | undefined): PaletteHue | null;
26
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/profile/colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKpE;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,SAAS,GACpC,UAAU,GAAG,IAAI,CAmBnB"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/profile/colors
4
+ *
5
+ * Profile-driven entry color resolution. Pure function that maps an entry
6
+ * and the active profile to a palette hue name (or `null` for uncolored).
7
+ *
8
+ * Lives in core/profile so both rendering layers (Typst PDF and HTML book)
9
+ * can call it without crossing the peer-module boundary defined in AGENTS.md.
10
+ *
11
+ * See docs/superpowers/specs/2026-05-06-profile-driven-entry-colors-design.md
12
+ * for the resolution table.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.resolveEntryColor = resolveEntryColor;
16
+ const palette_js_1 = require("../model/palette.js");
17
+ /** Default identified-entry hue when no profile / no type color resolves. */
18
+ const DEFAULT_HUE = "blue";
19
+ /**
20
+ * Resolve the palette hue for an entry under the active profile.
21
+ *
22
+ * Returns `null` for referenced-shape entries (uncolored block).
23
+ * Returns a palette hue name for identified entries — using the type's
24
+ * declared color when available, falling back to `"blue"` otherwise.
25
+ *
26
+ * The fallback is the palette hue directly (not the `primary` semantic
27
+ * name) so the renderer works for files compiled without a profile.
28
+ */
29
+ function resolveEntryColor(entry, profile) {
30
+ if (entry.shape === "Reference")
31
+ return null;
32
+ if (!profile || !entry.type)
33
+ return DEFAULT_HUE;
34
+ const typeDef = profile.types.get(entry.type);
35
+ const colorName = typeDef?.value.color.value;
36
+ if (!colorName)
37
+ return DEFAULT_HUE;
38
+ const hueEntry = profile.colors.get(colorName);
39
+ if (!hueEntry)
40
+ return DEFAULT_HUE;
41
+ // Defense in depth: the manifest parser already enforces PALETTE_HUES, but
42
+ // EffectiveProfile can in principle be constructed programmatically (tests,
43
+ // future APIs) without going through parseManifest. Guard the cast so an
44
+ // invalid hue can never reach downstream interpolation.
45
+ const hue = hueEntry.value;
46
+ if (!palette_js_1.PALETTE_HUES.includes(hue))
47
+ return DEFAULT_HUE;
48
+ return hue;
49
+ }