@driftsys/markspec 0.12.0 → 0.13.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 (317) hide show
  1. package/esm/ast/build.d.ts.map +1 -1
  2. package/esm/ast/build.js +19 -5
  3. package/esm/ast/equivalence.js +14 -2
  4. package/esm/ast/nodes.d.ts +15 -3
  5. package/esm/ast/nodes.d.ts.map +1 -1
  6. package/esm/compiler/inverses.d.ts.map +1 -1
  7. package/esm/compiler/inverses.js +18 -3
  8. package/esm/compiler/mod.d.ts +34 -1
  9. package/esm/compiler/mod.d.ts.map +1 -1
  10. package/esm/compiler/mod.js +112 -48
  11. package/esm/compiler/schema.d.ts +3 -2
  12. package/esm/compiler/schema.d.ts.map +1 -1
  13. package/esm/compiler/schema.js +6 -3
  14. package/esm/config/markspec.d.ts +2 -2
  15. package/esm/config/mod.d.ts.map +1 -1
  16. package/esm/config/mod.js +47 -5
  17. package/esm/criteria/scenarios.d.ts +55 -0
  18. package/esm/criteria/scenarios.d.ts.map +1 -0
  19. package/esm/criteria/scenarios.js +133 -0
  20. package/esm/discovery/mod.d.ts +20 -1
  21. package/esm/discovery/mod.d.ts.map +1 -1
  22. package/esm/discovery/mod.js +105 -17
  23. package/esm/discovery/projects.d.ts +6 -4
  24. package/esm/discovery/projects.d.ts.map +1 -1
  25. package/esm/discovery/projects.js +27 -17
  26. package/esm/formatter/entry_body.d.ts +13 -12
  27. package/esm/formatter/entry_body.d.ts.map +1 -1
  28. package/esm/formatter/entry_body.js +25 -17
  29. package/esm/formatter/feature_file.d.ts +40 -0
  30. package/esm/formatter/feature_file.d.ts.map +1 -0
  31. package/esm/formatter/feature_file.js +88 -0
  32. package/esm/formatter/md_equiv.d.ts +6 -5
  33. package/esm/formatter/md_equiv.d.ts.map +1 -1
  34. package/esm/formatter/md_equiv.js +6 -5
  35. package/esm/formatter/mod.d.ts +25 -3
  36. package/esm/formatter/mod.d.ts.map +1 -1
  37. package/esm/formatter/mod.js +267 -27
  38. package/esm/formatter/tab_markers.d.ts +15 -0
  39. package/esm/formatter/tab_markers.d.ts.map +1 -0
  40. package/esm/formatter/tab_markers.js +133 -0
  41. package/esm/gates/mod.d.ts +2 -2
  42. package/esm/gates/mod.d.ts.map +1 -1
  43. package/esm/gates/mod.js +18 -3
  44. package/esm/gherkin/load.d.ts +35 -0
  45. package/esm/gherkin/load.d.ts.map +1 -0
  46. package/esm/gherkin/load.js +39 -0
  47. package/esm/gherkin/parse.d.ts +11 -0
  48. package/esm/gherkin/parse.d.ts.map +1 -0
  49. package/esm/gherkin/parse.js +311 -0
  50. package/esm/gherkin/position.d.ts +23 -0
  51. package/esm/gherkin/position.d.ts.map +1 -0
  52. package/esm/gherkin/position.js +21 -0
  53. package/esm/gherkin/procedure.d.ts +76 -0
  54. package/esm/gherkin/procedure.d.ts.map +1 -0
  55. package/esm/gherkin/procedure.js +164 -0
  56. package/esm/gherkin/project.d.ts +35 -0
  57. package/esm/gherkin/project.d.ts.map +1 -0
  58. package/esm/gherkin/project.js +64 -0
  59. package/esm/gherkin/role.d.ts +23 -0
  60. package/esm/gherkin/role.d.ts.map +1 -0
  61. package/esm/gherkin/role.js +28 -0
  62. package/esm/gherkin/types.d.ts +118 -0
  63. package/esm/gherkin/types.d.ts.map +1 -0
  64. package/esm/gherkin/types.js +12 -0
  65. package/esm/lock/acquire_compile.d.ts +12 -4
  66. package/esm/lock/acquire_compile.d.ts.map +1 -1
  67. package/esm/lock/acquire_compile.js +15 -5
  68. package/esm/lock/canonical_edges.d.ts +6 -2
  69. package/esm/lock/canonical_edges.d.ts.map +1 -1
  70. package/esm/lock/canonical_edges.js +10 -3
  71. package/esm/lock/model.d.ts +5 -0
  72. package/esm/lock/model.d.ts.map +1 -1
  73. package/esm/lock/parser.d.ts.map +1 -1
  74. package/esm/lock/parser.js +2 -0
  75. package/esm/lock/resolve.d.ts +6 -2
  76. package/esm/lock/resolve.d.ts.map +1 -1
  77. package/esm/lock/resolve.js +36 -4
  78. package/esm/lock/serializer.d.ts.map +1 -1
  79. package/esm/lock/serializer.js +7 -1
  80. package/esm/lock/upstream_deps.js +1 -1
  81. package/esm/mod.d.ts +24 -6
  82. package/esm/mod.d.ts.map +1 -1
  83. package/esm/mod.js +19 -5
  84. package/esm/model/mod.d.ts +43 -2
  85. package/esm/model/mod.d.ts.map +1 -1
  86. package/esm/model/mod.js +1 -1
  87. package/esm/model/relations.d.ts +9 -0
  88. package/esm/model/relations.d.ts.map +1 -1
  89. package/esm/model/relations.js +16 -1
  90. package/esm/parser/attributes.d.ts +82 -3
  91. package/esm/parser/attributes.d.ts.map +1 -1
  92. package/esm/parser/attributes.js +199 -32
  93. package/esm/parser/body_tokens.d.ts +1 -1
  94. package/esm/parser/body_tokens.d.ts.map +1 -1
  95. package/esm/parser/body_tokens.js +49 -35
  96. package/esm/parser/feature_file.d.ts +116 -0
  97. package/esm/parser/feature_file.d.ts.map +1 -0
  98. package/esm/parser/feature_file.js +540 -0
  99. package/esm/parser/markdown.d.ts +7 -0
  100. package/esm/parser/markdown.d.ts.map +1 -1
  101. package/esm/parser/markdown.js +129 -40
  102. package/esm/parser/mod.d.ts +18 -0
  103. package/esm/parser/mod.d.ts.map +1 -1
  104. package/esm/parser/mod.js +51 -0
  105. package/esm/parser/translate.d.ts.map +1 -1
  106. package/esm/parser/translate.js +5 -0
  107. package/esm/refs/mod.d.ts +8 -3
  108. package/esm/refs/mod.d.ts.map +1 -1
  109. package/esm/refs/mod.js +20 -7
  110. package/esm/refs/split.d.ts +58 -0
  111. package/esm/refs/split.d.ts.map +1 -0
  112. package/esm/refs/split.js +137 -0
  113. package/esm/reporter/mod.d.ts +7 -0
  114. package/esm/reporter/mod.d.ts.map +1 -1
  115. package/esm/reporter/mod.js +113 -3
  116. package/esm/sync/mapping.d.ts +4 -3
  117. package/esm/sync/mapping.d.ts.map +1 -1
  118. package/esm/sync/mapping.js +52 -9
  119. package/esm/util/display_id.d.ts +20 -0
  120. package/esm/util/display_id.d.ts.map +1 -0
  121. package/esm/util/display_id.js +19 -0
  122. package/esm/validator/attributes.d.ts.map +1 -1
  123. package/esm/validator/attributes.js +4 -1
  124. package/esm/validator/block_role.d.ts +40 -0
  125. package/esm/validator/block_role.d.ts.map +1 -0
  126. package/esm/validator/block_role.js +109 -0
  127. package/esm/validator/feature_ac.d.ts.map +1 -1
  128. package/esm/validator/feature_ac.js +6 -1
  129. package/esm/validator/feature_parse.d.ts +35 -0
  130. package/esm/validator/feature_parse.d.ts.map +1 -0
  131. package/esm/validator/feature_parse.js +69 -0
  132. package/esm/validator/locators.d.ts +36 -0
  133. package/esm/validator/locators.d.ts.map +1 -0
  134. package/esm/validator/locators.js +184 -0
  135. package/esm/validator/mod.d.ts +10 -1
  136. package/esm/validator/mod.d.ts.map +1 -1
  137. package/esm/validator/mod.js +38 -14
  138. package/esm/validator/normalize.d.ts.map +1 -1
  139. package/esm/validator/normalize.js +8 -3
  140. package/esm/validator/per_type_attrs.d.ts +3 -3
  141. package/esm/validator/per_type_attrs.js +3 -3
  142. package/esm/validator/pipeline.d.ts +10 -16
  143. package/esm/validator/pipeline.d.ts.map +1 -1
  144. package/esm/validator/pipeline.js +37 -16
  145. package/esm/validator/procedure.d.ts +22 -0
  146. package/esm/validator/procedure.d.ts.map +1 -0
  147. package/esm/validator/procedure.js +58 -0
  148. package/esm/validator/trace_types.d.ts.map +1 -1
  149. package/esm/validator/trace_types.js +4 -3
  150. package/esm/validator/traceability.d.ts.map +1 -1
  151. package/esm/validator/traceability.js +4 -1
  152. package/esm/validator/type_resolution.d.ts +5 -3
  153. package/esm/validator/type_resolution.d.ts.map +1 -1
  154. package/esm/validator/type_resolution.js +14 -2
  155. package/esm/validator/types.d.ts +11 -0
  156. package/esm/validator/types.d.ts.map +1 -1
  157. package/esm/validator/types.js +26 -4
  158. package/esm/validator/uxil_family.d.ts +1 -1
  159. package/package.json +3 -1
  160. package/script/ast/build.d.ts.map +1 -1
  161. package/script/ast/build.js +19 -5
  162. package/script/ast/equivalence.js +14 -2
  163. package/script/ast/nodes.d.ts +15 -3
  164. package/script/ast/nodes.d.ts.map +1 -1
  165. package/script/compiler/inverses.d.ts.map +1 -1
  166. package/script/compiler/inverses.js +18 -3
  167. package/script/compiler/mod.d.ts +34 -1
  168. package/script/compiler/mod.d.ts.map +1 -1
  169. package/script/compiler/mod.js +110 -46
  170. package/script/compiler/schema.d.ts +3 -2
  171. package/script/compiler/schema.d.ts.map +1 -1
  172. package/script/compiler/schema.js +6 -3
  173. package/script/config/markspec.d.ts +2 -2
  174. package/script/config/mod.d.ts.map +1 -1
  175. package/script/config/mod.js +47 -5
  176. package/script/criteria/scenarios.d.ts +55 -0
  177. package/script/criteria/scenarios.d.ts.map +1 -0
  178. package/script/criteria/scenarios.js +139 -0
  179. package/script/discovery/mod.d.ts +20 -1
  180. package/script/discovery/mod.d.ts.map +1 -1
  181. package/script/discovery/mod.js +106 -17
  182. package/script/discovery/projects.d.ts +6 -4
  183. package/script/discovery/projects.d.ts.map +1 -1
  184. package/script/discovery/projects.js +27 -17
  185. package/script/formatter/entry_body.d.ts +13 -12
  186. package/script/formatter/entry_body.d.ts.map +1 -1
  187. package/script/formatter/entry_body.js +25 -17
  188. package/script/formatter/feature_file.d.ts +40 -0
  189. package/script/formatter/feature_file.d.ts.map +1 -0
  190. package/script/formatter/feature_file.js +92 -0
  191. package/script/formatter/md_equiv.d.ts +6 -5
  192. package/script/formatter/md_equiv.d.ts.map +1 -1
  193. package/script/formatter/md_equiv.js +6 -5
  194. package/script/formatter/mod.d.ts +25 -3
  195. package/script/formatter/mod.d.ts.map +1 -1
  196. package/script/formatter/mod.js +266 -26
  197. package/script/formatter/tab_markers.d.ts +15 -0
  198. package/script/formatter/tab_markers.d.ts.map +1 -0
  199. package/script/formatter/tab_markers.js +141 -0
  200. package/script/gates/mod.d.ts +2 -2
  201. package/script/gates/mod.d.ts.map +1 -1
  202. package/script/gates/mod.js +18 -3
  203. package/script/gherkin/load.d.ts +35 -0
  204. package/script/gherkin/load.d.ts.map +1 -0
  205. package/script/gherkin/load.js +76 -0
  206. package/script/gherkin/parse.d.ts +11 -0
  207. package/script/gherkin/parse.d.ts.map +1 -0
  208. package/script/gherkin/parse.js +314 -0
  209. package/script/gherkin/position.d.ts +23 -0
  210. package/script/gherkin/position.d.ts.map +1 -0
  211. package/script/gherkin/position.js +24 -0
  212. package/script/gherkin/procedure.d.ts +76 -0
  213. package/script/gherkin/procedure.d.ts.map +1 -0
  214. package/script/gherkin/procedure.js +169 -0
  215. package/script/gherkin/project.d.ts +35 -0
  216. package/script/gherkin/project.d.ts.map +1 -0
  217. package/script/gherkin/project.js +67 -0
  218. package/script/gherkin/role.d.ts +23 -0
  219. package/script/gherkin/role.d.ts.map +1 -0
  220. package/script/gherkin/role.js +31 -0
  221. package/script/gherkin/types.d.ts +118 -0
  222. package/script/gherkin/types.d.ts.map +1 -0
  223. package/script/gherkin/types.js +13 -0
  224. package/script/lock/acquire_compile.d.ts +12 -4
  225. package/script/lock/acquire_compile.d.ts.map +1 -1
  226. package/script/lock/acquire_compile.js +15 -5
  227. package/script/lock/canonical_edges.d.ts +6 -2
  228. package/script/lock/canonical_edges.d.ts.map +1 -1
  229. package/script/lock/canonical_edges.js +10 -3
  230. package/script/lock/model.d.ts +5 -0
  231. package/script/lock/model.d.ts.map +1 -1
  232. package/script/lock/parser.d.ts.map +1 -1
  233. package/script/lock/parser.js +2 -0
  234. package/script/lock/resolve.d.ts +6 -2
  235. package/script/lock/resolve.d.ts.map +1 -1
  236. package/script/lock/resolve.js +36 -4
  237. package/script/lock/serializer.d.ts.map +1 -1
  238. package/script/lock/serializer.js +7 -1
  239. package/script/lock/upstream_deps.js +1 -1
  240. package/script/mod.d.ts +24 -6
  241. package/script/mod.d.ts.map +1 -1
  242. package/script/mod.js +48 -6
  243. package/script/model/mod.d.ts +43 -2
  244. package/script/model/mod.d.ts.map +1 -1
  245. package/script/model/mod.js +2 -1
  246. package/script/model/relations.d.ts +9 -0
  247. package/script/model/relations.d.ts.map +1 -1
  248. package/script/model/relations.js +17 -1
  249. package/script/parser/attributes.d.ts +82 -3
  250. package/script/parser/attributes.d.ts.map +1 -1
  251. package/script/parser/attributes.js +205 -33
  252. package/script/parser/body_tokens.d.ts +1 -1
  253. package/script/parser/body_tokens.d.ts.map +1 -1
  254. package/script/parser/body_tokens.js +49 -35
  255. package/script/parser/feature_file.d.ts +116 -0
  256. package/script/parser/feature_file.d.ts.map +1 -0
  257. package/script/parser/feature_file.js +548 -0
  258. package/script/parser/markdown.d.ts +7 -0
  259. package/script/parser/markdown.d.ts.map +1 -1
  260. package/script/parser/markdown.js +128 -39
  261. package/script/parser/mod.d.ts +18 -0
  262. package/script/parser/mod.d.ts.map +1 -1
  263. package/script/parser/mod.js +52 -1
  264. package/script/parser/translate.d.ts.map +1 -1
  265. package/script/parser/translate.js +5 -0
  266. package/script/refs/mod.d.ts +8 -3
  267. package/script/refs/mod.d.ts.map +1 -1
  268. package/script/refs/mod.js +20 -7
  269. package/script/refs/split.d.ts +58 -0
  270. package/script/refs/split.d.ts.map +1 -0
  271. package/script/refs/split.js +145 -0
  272. package/script/reporter/mod.d.ts +7 -0
  273. package/script/reporter/mod.d.ts.map +1 -1
  274. package/script/reporter/mod.js +113 -3
  275. package/script/sync/mapping.d.ts +4 -3
  276. package/script/sync/mapping.d.ts.map +1 -1
  277. package/script/sync/mapping.js +52 -9
  278. package/script/util/display_id.d.ts +20 -0
  279. package/script/util/display_id.d.ts.map +1 -0
  280. package/script/util/display_id.js +22 -0
  281. package/script/validator/attributes.d.ts.map +1 -1
  282. package/script/validator/attributes.js +4 -1
  283. package/script/validator/block_role.d.ts +40 -0
  284. package/script/validator/block_role.d.ts.map +1 -0
  285. package/script/validator/block_role.js +112 -0
  286. package/script/validator/feature_ac.d.ts.map +1 -1
  287. package/script/validator/feature_ac.js +6 -1
  288. package/script/validator/feature_parse.d.ts +35 -0
  289. package/script/validator/feature_parse.d.ts.map +1 -0
  290. package/script/validator/feature_parse.js +73 -0
  291. package/script/validator/locators.d.ts +36 -0
  292. package/script/validator/locators.d.ts.map +1 -0
  293. package/script/validator/locators.js +188 -0
  294. package/script/validator/mod.d.ts +10 -1
  295. package/script/validator/mod.d.ts.map +1 -1
  296. package/script/validator/mod.js +38 -14
  297. package/script/validator/normalize.d.ts.map +1 -1
  298. package/script/validator/normalize.js +8 -3
  299. package/script/validator/per_type_attrs.d.ts +3 -3
  300. package/script/validator/per_type_attrs.js +3 -3
  301. package/script/validator/pipeline.d.ts +10 -16
  302. package/script/validator/pipeline.d.ts.map +1 -1
  303. package/script/validator/pipeline.js +36 -16
  304. package/script/validator/procedure.d.ts +22 -0
  305. package/script/validator/procedure.d.ts.map +1 -0
  306. package/script/validator/procedure.js +61 -0
  307. package/script/validator/trace_types.d.ts.map +1 -1
  308. package/script/validator/trace_types.js +4 -3
  309. package/script/validator/traceability.d.ts.map +1 -1
  310. package/script/validator/traceability.js +4 -1
  311. package/script/validator/type_resolution.d.ts +5 -3
  312. package/script/validator/type_resolution.d.ts.map +1 -1
  313. package/script/validator/type_resolution.js +14 -2
  314. package/script/validator/types.d.ts +11 -0
  315. package/script/validator/types.d.ts.map +1 -1
  316. package/script/validator/types.js +27 -4
  317. package/script/validator/uxil_family.d.ts +1 -1
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @module core/formatter/feature_file
3
+ *
4
+ * Write-back for `.feature` files (epic #915, Case B). The only change
5
+ * `fmt` makes is to insert a missing `# Id: <ULID>` line into the header
6
+ * comment of a headed entry. Gherkin text, other comments and line endings
7
+ * stay as they are. The Markdown entry formatter and the ADR-029 prose pass
8
+ * never run on `.feature` text.
9
+ */
10
+ import type { Entry } from "../model/mod.js";
11
+ /** Result of {@linkcode formatFeatureFile}. */
12
+ export interface FeatureFormatResult {
13
+ readonly output: string;
14
+ readonly changed: boolean;
15
+ }
16
+ /**
17
+ * Insert a missing `# Id: <ULID>` line into the header of each entry of a
18
+ * `.feature` file.
19
+ *
20
+ * The line goes before the first trailer line, with that line's comment
21
+ * prefix, so it matches the header's indentation and trailer spacing. A
22
+ * header without a trailer gets a `#` line (unless its last line is already
23
+ * an empty comment) and then the Id line, at the end of the header. An entry
24
+ * that has an Id, and every other part of the file, is left unchanged.
25
+ *
26
+ * @param text - The file text (LF or CRLF).
27
+ * @param entries - The entries parsed from `text`.
28
+ * @param generateUlid - ULID generator.
29
+ */
30
+ export declare function formatFeatureFile(text: string, entries: readonly Entry[], generateUlid?: () => string): FeatureFormatResult;
31
+ /**
32
+ * Parse a `.feature` file and stamp the missing Ids of its entries. A file
33
+ * that does not parse has no entries, so it comes back unchanged.
34
+ *
35
+ * @param text - The file text.
36
+ * @param file - File path, used for parsing and diagnostics.
37
+ * @param generateUlid - ULID generator.
38
+ */
39
+ export declare function formatFeatureText(text: string, file: string, generateUlid?: () => string): Promise<FeatureFormatResult>;
40
+ //# sourceMappingURL=feature_file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature_file.d.ts","sourceRoot":"","sources":["../../src/formatter/feature_file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAY7C,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAOD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,YAAY,GAAE,MAAM,MAAoB,GACvC,mBAAmB,CA0CrB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,GAAE,MAAM,MAAoB,GACvC,OAAO,CAAC,mBAAmB,CAAC,CAG9B"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/formatter/feature_file
4
+ *
5
+ * Write-back for `.feature` files (epic #915, Case B). The only change
6
+ * `fmt` makes is to insert a missing `# Id: <ULID>` line into the header
7
+ * comment of a headed entry. Gherkin text, other comments and line endings
8
+ * stay as they are. The Markdown entry formatter and the ADR-029 prose pass
9
+ * never run on `.feature` text.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.formatFeatureFile = formatFeatureFile;
13
+ exports.formatFeatureText = formatFeatureText;
14
+ const ulid_1 = require("@std/ulid");
15
+ const mod_js_1 = require("../parser/mod.js");
16
+ const feature_file_js_1 = require("../parser/feature_file.js");
17
+ const line_endings_js_1 = require("../util/line_endings.js");
18
+ /** Leading whitespace, `#`, and the spaces after it. */
19
+ const COMMENT_PREFIX_RE = /^(\s*#[ \t]*)/;
20
+ /** `true` when `line` is a comment line. */
21
+ function isComment(line) {
22
+ return line !== undefined && line.trimStart().startsWith("#");
23
+ }
24
+ /**
25
+ * Insert a missing `# Id: <ULID>` line into the header of each entry of a
26
+ * `.feature` file.
27
+ *
28
+ * The line goes before the first trailer line, with that line's comment
29
+ * prefix, so it matches the header's indentation and trailer spacing. A
30
+ * header without a trailer gets a `#` line (unless its last line is already
31
+ * an empty comment) and then the Id line, at the end of the header. An entry
32
+ * that has an Id, and every other part of the file, is left unchanged.
33
+ *
34
+ * @param text - The file text (LF or CRLF).
35
+ * @param entries - The entries parsed from `text`.
36
+ * @param generateUlid - ULID generator.
37
+ */
38
+ function formatFeatureFile(text, entries, generateUlid = ulid_1.ulid) {
39
+ const ending = (0, line_endings_js_1.detectLineEnding)(text);
40
+ const lines = (0, line_endings_js_1.normalizeLineEndings)(text).split("\n");
41
+ const missing = entries
42
+ .filter((e) => e.source.kind === "feature-file" && e.id === undefined &&
43
+ e.shape === "Authored")
44
+ .sort((a, b) => b.location.line - a.location.line);
45
+ if (missing.length === 0)
46
+ return { output: text, changed: false };
47
+ let changed = false;
48
+ for (const entry of missing) {
49
+ const titleIdx = entry.location.line - 1;
50
+ if (!isComment(lines[titleIdx]))
51
+ continue;
52
+ // End of the header run: consecutive comment lines, up to the next
53
+ // header start or a `# language:` line.
54
+ const endIdx = (0, feature_file_js_1.featureHeaderRunEnd)(lines, titleIdx) - 1;
55
+ const firstTrailer = entry.attributeLines?.[0];
56
+ const trailerIdx = firstTrailer === undefined
57
+ ? undefined
58
+ : firstTrailer - 1;
59
+ if (trailerIdx !== undefined && trailerIdx > titleIdx &&
60
+ trailerIdx <= endIdx) {
61
+ const prefix = COMMENT_PREFIX_RE.exec(lines[trailerIdx])[1];
62
+ lines.splice(trailerIdx, 0, `${prefix}Id: ${generateUlid()}`);
63
+ }
64
+ else {
65
+ const indent = /^\s*/.exec(lines[titleIdx])[0];
66
+ const added = [];
67
+ if (lines[endIdx].trim() !== "#")
68
+ added.push(`${indent}#`);
69
+ added.push(`${indent}# Id: ${generateUlid()}`);
70
+ lines.splice(endIdx + 1, 0, ...added);
71
+ }
72
+ changed = true;
73
+ }
74
+ if (!changed)
75
+ return { output: text, changed: false };
76
+ return {
77
+ output: (0, line_endings_js_1.applyLineEnding)(lines.join("\n"), ending),
78
+ changed: true,
79
+ };
80
+ }
81
+ /**
82
+ * Parse a `.feature` file and stamp the missing Ids of its entries. A file
83
+ * that does not parse has no entries, so it comes back unchanged.
84
+ *
85
+ * @param text - The file text.
86
+ * @param file - File path, used for parsing and diagnostics.
87
+ * @param generateUlid - ULID generator.
88
+ */
89
+ async function formatFeatureText(text, file, generateUlid = ulid_1.ulid) {
90
+ const { entries } = await (0, mod_js_1.parseFile)(text, { file });
91
+ return formatFeatureFile(text, entries, generateUlid);
92
+ }
@@ -2,8 +2,9 @@
2
2
  * @module formatter/md_equiv
3
3
  *
4
4
  * CommonMark-semantic Markdown equivalence — the gate for the ADR-029
5
- * dprint pass. Two fragments are equivalent when they parse to the
6
- * same mdast structure after eliding source `position`s and collapsing
5
+ * dprint pass and entry tab-marker normalization. Two fragments are equivalent
6
+ * when they parse to the same mdast structure after eliding source `position`s
7
+ * and collapsing
7
8
  * ASCII whitespace runs inside `text` node values. Only ASCII
8
9
  * whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
9
10
  * content, not wrap artifacts, and must not compare equal to a plain
@@ -15,9 +16,9 @@
15
16
  * and definition `url`s stay byte-exact.
16
17
  *
17
18
  * DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
18
- * inline markup). Used ONLY to accept/reject dprint output; the
19
- * ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
20
- * not be modified.
19
+ * inline markup). Used to accept/reject dprint output and tab-marker rewrites.
20
+ * The ADR-015 relation still guards §5.2 body emission (MSL-F900) and must not
21
+ * be modified.
21
22
  */
22
23
  /** True when `a` and `b` are the same Markdown, modulo presentation. */
23
24
  export declare function markdownSemanticallyEquivalent(a: string, b: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,wEAAwE;AACxE,wBAAgB,8BAA8B,CAC5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAMT"}
1
+ {"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,wEAAwE;AACxE,wBAAgB,8BAA8B,CAC5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAMT"}
@@ -3,8 +3,9 @@
3
3
  * @module formatter/md_equiv
4
4
  *
5
5
  * CommonMark-semantic Markdown equivalence — the gate for the ADR-029
6
- * dprint pass. Two fragments are equivalent when they parse to the
7
- * same mdast structure after eliding source `position`s and collapsing
6
+ * dprint pass and entry tab-marker normalization. Two fragments are equivalent
7
+ * when they parse to the same mdast structure after eliding source `position`s
8
+ * and collapsing
8
9
  * ASCII whitespace runs inside `text` node values. Only ASCII
9
10
  * whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
10
11
  * content, not wrap artifacts, and must not compare equal to a plain
@@ -16,9 +17,9 @@
16
17
  * and definition `url`s stay byte-exact.
17
18
  *
18
19
  * DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
19
- * inline markup). Used ONLY to accept/reject dprint output; the
20
- * ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
21
- * not be modified.
20
+ * inline markup). Used to accept/reject dprint output and tab-marker rewrites.
21
+ * The ADR-015 relation still guards §5.2 body emission (MSL-F900) and must not
22
+ * be modified.
22
23
  */
23
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -6,6 +6,7 @@
6
6
  * and requirement block insertion.
7
7
  */
8
8
  import type { Attribute, Diagnostic } from "../model/mod.js";
9
+ import { type EntryExtent } from "./prose.js";
9
10
  import { type ProseFormatter } from "./dprint.js";
10
11
  /**
11
12
  * Decide whether the EARS keyword at `offset` in `line` is at sentence
@@ -76,6 +77,8 @@ export interface FormatResult {
76
77
  readonly diagnostics: readonly Diagnostic[];
77
78
  /** Whether any changes were made. */
78
79
  readonly changed: boolean;
80
+ /** Output line spans (0-based, end exclusive) kept unchanged after refusal. */
81
+ readonly preservedRanges?: readonly EntryExtent[];
79
82
  }
80
83
  /**
81
84
  * Format a Markdown string — normalize attribute blocks,
@@ -90,7 +93,9 @@ export declare function format(markdown: string, options?: FormatOptions): Forma
90
93
  * Expand CSV values on repeatable-type attributes into one entry per value
91
94
  * per ADR-002 §2.6. `id-list` / `tag-list` / `external-id` accept CSV input
92
95
  * but must round-trip as multi-line output; `citation` is left alone
93
- * because locators may contain commas.
96
+ * because locators may contain commas. `id-list` values split with
97
+ * {@linkcode splitTraceValues}, so a comma inside a scenario locator does
98
+ * not split.
94
99
  */
95
100
  export declare function expandCsvValues(attrs: Attribute[]): Attribute[];
96
101
  /**
@@ -141,9 +146,26 @@ export declare function findItemEnd(lines: readonly string[], startIdx: number,
141
146
  * for an entry starting at the given line.
142
147
  *
143
148
  * Scans forward from the entry start to find the list item boundary,
144
- * then walks backwards to find the contiguous trailing attribute block.
149
+ * then passes the entry content below the last preserved range, with the
150
+ * list-item indent removed, to the parser's {@linkcode findTrailerStart}.
151
+ * The formatter and the parser therefore agree on which lines are the
152
+ * trailer, so `markspec fmt` never rewrites a line that the parser read as
153
+ * body, and never drops an attribute line that the parser read (#916).
154
+ * The LSP MSL-P023 quick fix uses it too.
155
+ *
156
+ * @param lines - Raw lines of the whole file.
157
+ * @param entryStartLine - 1-based line of the entry's title (`- [ID] ...`).
158
+ * @param indent - Content column of the list item: the 0-based column of
159
+ * the `[` that opens the display ID.
160
+ * @param itemEndFloor - Pass the parser's `Entry.endLine` (0 when unknown):
161
+ * the item end scan starts no earlier than this line index, so a lazy
162
+ * continuation line does not end the item early (see `findItemEnd`).
163
+ * @param preservedRanges - Ranges inside the entry that are kept verbatim
164
+ * (nested entries); the trailer is searched below the last one.
165
+ * @returns The 0-based, half-open line range `[start, end)` of the trailer
166
+ * over `lines`, or `undefined` when the entry has no trailer.
145
167
  */
146
- export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number): {
168
+ export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number, preservedRanges?: readonly EntryExtent[]): {
147
169
  start: number;
148
170
  end: number;
149
171
  } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,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