@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c83456e1cebfb

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 (202) hide show
  1. package/API.md +298 -0
  2. package/README.md +29 -186
  3. package/dist/blocks.d.ts +11 -0
  4. package/dist/blocks.d.ts.map +1 -0
  5. package/dist/blocks.js +62 -0
  6. package/dist/definition.d.ts +7 -3
  7. package/dist/definition.d.ts.map +1 -1
  8. package/dist/definition.js +143 -134
  9. package/dist/divide.d.ts +3 -0
  10. package/dist/divide.d.ts.map +1 -0
  11. package/dist/divide.js +310 -0
  12. package/dist/document.d.ts +2 -0
  13. package/dist/document.d.ts.map +1 -1
  14. package/dist/document.js +89 -120
  15. package/dist/fields.d.ts +4 -0
  16. package/dist/fields.d.ts.map +1 -0
  17. package/dist/fields.js +3 -0
  18. package/dist/index.d.ts +6 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +4 -3
  21. package/dist/links.d.ts +1 -0
  22. package/dist/links.d.ts.map +1 -1
  23. package/dist/links.js +618 -224
  24. package/dist/paths.d.ts +2 -3
  25. package/dist/paths.d.ts.map +1 -1
  26. package/dist/paths.js +27 -37
  27. package/dist/profile.js +1 -3
  28. package/dist/project.d.ts +19 -1
  29. package/dist/project.d.ts.map +1 -1
  30. package/dist/project.js +75 -91
  31. package/dist/refuse.d.ts.map +1 -1
  32. package/dist/refuse.js +2 -10
  33. package/dist/schema.d.ts +2 -1
  34. package/dist/schema.d.ts.map +1 -1
  35. package/dist/schema.js +22 -33
  36. package/dist/sections.d.ts +2 -1
  37. package/dist/sections.d.ts.map +1 -1
  38. package/dist/sections.js +44 -66
  39. package/dist/types.d.ts +30 -2
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/types.js +1 -3
  42. package/dist/validate.d.ts +3 -2
  43. package/dist/validate.d.ts.map +1 -1
  44. package/dist/validate.js +145 -127
  45. package/dist/version.d.ts +1 -1
  46. package/dist/version.d.ts.map +1 -1
  47. package/dist/version.js +1 -3
  48. package/dist/yaml.d.ts +1 -0
  49. package/dist/yaml.d.ts.map +1 -1
  50. package/dist/yaml.js +195 -186
  51. package/fixtures/README.md +77 -53
  52. package/fixtures/cases/binary-any-reference/expected.json +0 -1
  53. package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
  54. package/fixtures/cases/binary-document-collision/expected.json +1 -2
  55. package/fixtures/cases/binary-document-collision/schema.yaml +2 -0
  56. package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
  57. package/fixtures/cases/binary-link-outside-collection/schema.yaml +2 -0
  58. package/fixtures/cases/binary-prototype-reference/expected.json +0 -1
  59. package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
  60. package/fixtures/cases/binary-typed-reference/expected.json +0 -1
  61. package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
  62. package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
  63. package/fixtures/cases/declared-binary-links/schema.yaml +2 -0
  64. package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
  65. package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
  66. package/fixtures/cases/field-enum/expected.json +1 -2
  67. package/fixtures/cases/field-enum/schema.yaml +7 -0
  68. package/fixtures/cases/frontmatter-schema/expected.json +5 -0
  69. package/fixtures/cases/frontmatter-schema/schema.yaml +6 -0
  70. package/fixtures/cases/interrupted-link-definition/schema.yaml +2 -0
  71. package/fixtures/cases/long-fence-link-definition/schema.yaml +2 -0
  72. package/fixtures/cases/malformed-definition/expected.json +2 -4
  73. package/fixtures/cases/malformed-definition/schema.yaml +4 -0
  74. package/fixtures/cases/member-document/context.json +1 -0
  75. package/fixtures/cases/member-document/library/people/ana.md +5 -0
  76. package/fixtures/cases/member-document/schema.yaml +5 -0
  77. package/fixtures/cases/missing-binary-image/expected.json +1 -2
  78. package/fixtures/cases/missing-binary-image/schema.yaml +2 -0
  79. package/fixtures/cases/missing-binary-link/expected.json +1 -2
  80. package/fixtures/cases/missing-binary-link/schema.yaml +2 -0
  81. package/fixtures/cases/missing-required-field/expected.json +1 -2
  82. package/fixtures/cases/missing-required-field/schema.yaml +7 -0
  83. package/fixtures/cases/missing-section-item-kind/expected.json +2 -4
  84. package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
  85. package/fixtures/cases/paragraph-link-definition/schema.yaml +2 -0
  86. package/fixtures/cases/prototype-field/expected.json +1 -2
  87. package/fixtures/cases/prototype-field/schema.yaml +6 -0
  88. package/fixtures/cases/quoted-link-definition/expected.json +1 -2
  89. package/fixtures/cases/quoted-link-definition/schema.yaml +2 -0
  90. package/fixtures/cases/referenced-missing-file/expected.json +0 -1
  91. package/fixtures/cases/referenced-missing-file/schema.yaml +10 -0
  92. package/fixtures/cases/second-member-document/context.json +1 -0
  93. package/fixtures/cases/second-member-document/expected.json +5 -0
  94. package/fixtures/cases/second-member-document/schema.yaml +5 -0
  95. package/fixtures/cases/section-item-enum/context.json +1 -0
  96. package/fixtures/cases/section-item-enum/expected.json +6 -0
  97. package/fixtures/cases/section-item-enum/library/task.md +8 -0
  98. package/fixtures/cases/section-item-enum/schema.yaml +4 -0
  99. package/fixtures/cases/section-item-kind/context.json +1 -0
  100. package/fixtures/cases/section-item-kind/expected.json +6 -0
  101. package/fixtures/cases/section-item-kind/library/task.md +8 -0
  102. package/fixtures/cases/section-item-kind/schema.yaml +4 -0
  103. package/fixtures/cases/section-items/context.json +1 -0
  104. package/fixtures/cases/section-items/expected.json +1 -0
  105. package/fixtures/cases/section-items/library/other.md +3 -0
  106. package/fixtures/cases/section-items/library/page.md +28 -0
  107. package/fixtures/cases/section-items/schema.yaml +8 -0
  108. package/fixtures/cases/section-reference-path/context.json +1 -0
  109. package/fixtures/cases/section-reference-path/expected.json +6 -0
  110. package/fixtures/cases/section-reference-path/library/other.md +3 -0
  111. package/fixtures/cases/section-reference-path/library/page.md +7 -0
  112. package/fixtures/cases/section-reference-path/schema.yaml +4 -0
  113. package/fixtures/cases/section-reference-type/context.json +1 -0
  114. package/fixtures/cases/section-reference-type/expected.json +6 -0
  115. package/fixtures/cases/section-reference-type/library/note.md +1 -0
  116. package/fixtures/cases/section-reference-type/library/page.md +7 -0
  117. package/fixtures/cases/section-reference-type/schema.yaml +4 -0
  118. package/fixtures/cases/shortcut-reference-link/context.json +1 -0
  119. package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
  120. package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
  121. package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
  122. package/fixtures/cases/structured-section/expected.json +1 -2
  123. package/fixtures/cases/structured-section/schema.yaml +7 -0
  124. package/fixtures/cases/submission-keys/context.json +1 -0
  125. package/fixtures/cases/submission-keys/expected.json +1 -0
  126. package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
  127. package/fixtures/cases/submission-keys/schema.yaml +4 -0
  128. package/fixtures/cases/text-field-kind/context.json +1 -0
  129. package/fixtures/cases/text-field-kind/expected.json +6 -0
  130. package/fixtures/cases/text-field-kind/library/page.md +4 -0
  131. package/fixtures/cases/text-field-kind/schema.yaml +4 -0
  132. package/fixtures/cases/truncated-link-definition/expected.json +1 -2
  133. package/fixtures/cases/truncated-link-definition/schema.yaml +2 -0
  134. package/fixtures/cases/types-folder-content/context.json +1 -0
  135. package/fixtures/cases/types-folder-content/expected.json +1 -0
  136. package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
  137. package/fixtures/cases/types-folder-content/schema.yaml +4 -0
  138. package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
  139. package/fixtures/cases/undeclared-field/expected.json +1 -2
  140. package/fixtures/cases/undeclared-field/schema.yaml +6 -0
  141. package/fixtures/cases/unknown-type/context.json +1 -0
  142. package/fixtures/cases/unknown-type/expected.json +6 -0
  143. package/fixtures/cases/unknown-type/library/item.md +3 -0
  144. package/fixtures/cases/unknown-type/schema.yaml +4 -0
  145. package/fixtures/cases/unlisted-reference-type/context.json +1 -0
  146. package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
  147. package/fixtures/cases/unlisted-reference-type/schema.yaml +4 -0
  148. package/fixtures/cases/unresolved-link/expected.json +1 -2
  149. package/fixtures/cases/unresolved-link/schema.yaml +6 -0
  150. package/fixtures/cases/valid-typed-document/schema.yaml +15 -0
  151. package/fixtures/cases/wide-item-fence-link/schema.yaml +2 -0
  152. package/fixtures/division.json +409 -0
  153. package/fixtures/projection.json +58 -21
  154. package/package.json +3 -12
  155. package/dist/definition.js.map +0 -1
  156. package/dist/document.js.map +0 -1
  157. package/dist/index.js.map +0 -1
  158. package/dist/links.js.map +0 -1
  159. package/dist/paths.js.map +0 -1
  160. package/dist/profile.js.map +0 -1
  161. package/dist/project.js.map +0 -1
  162. package/dist/refuse.js.map +0 -1
  163. package/dist/schema.js.map +0 -1
  164. package/dist/sections.js.map +0 -1
  165. package/dist/types.js.map +0 -1
  166. package/dist/validate.js.map +0 -1
  167. package/dist/version.js.map +0 -1
  168. package/dist/yaml.js.map +0 -1
  169. package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
  170. package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
  171. package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
  172. package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
  173. package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
  174. package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
  175. package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
  176. package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
  177. package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
  178. package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
  179. package/fixtures/cases/field-enum/library/types/task.md +0 -8
  180. package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
  181. package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
  182. package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
  183. package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
  184. package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
  185. package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
  186. package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
  187. package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
  188. package/fixtures/cases/prd-definition/library/types/task.md +0 -16
  189. package/fixtures/cases/prototype-field/library/types/task.md +0 -7
  190. package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
  191. package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
  192. package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
  193. package/fixtures/cases/structured-section/library/types/task.md +0 -8
  194. package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
  195. package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
  196. package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
  197. package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
  198. package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
  199. package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
  200. package/markdown-syntax-profile.md +0 -9
  201. /package/fixtures/cases/{prd-definition → frontmatter-schema}/context.json +0 -0
  202. /package/fixtures/cases/{prd-definition → member-document}/expected.json +0 -0
@@ -0,0 +1,409 @@
1
+ {
2
+ "schema": "types:\n task:\n fields:\n name: { kind: text }\n status: { kind: enum, values: [open, done], required: true }\n sections:\n Description: { kind: text, required: true }\n Acceptance: { kind: list, of: reference, to: person }\n person: {}\n",
3
+ "cases": [
4
+ {
5
+ "name": "a Document whose whole input fits the budget is one Span carrying its projection",
6
+ "file": "tasks/one.md",
7
+ "source": "---\ntype: task\nname: Ship the release\nstatus: open\n---\n\nPreamble prose.\n\n## Description\n\nBody of the description.\n\n## Acceptance\n\n- people/ana.md\n",
8
+ "documentTargets": [],
9
+ "definition": "task",
10
+ "budget": 4096,
11
+ "expected": {
12
+ "ok": true,
13
+ "spans": [
14
+ {
15
+ "text": "Ship the release\n\n\nPreamble prose.\n\n## Description\n\nBody of the description.\n\n",
16
+ "source": "Ship the release\nstatus: open\n---\n\nPreamble prose.\n\n## Description\n\nBody of the description.\n\n"
17
+ }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ "name": "an input over the budget descends to whole heading nodes and packs adjacent siblings",
23
+ "file": "tasks/one.md",
24
+ "source": "---\ntype: task\nname: Ship the release\nstatus: open\n---\n\nPreamble prose.\n\n## Description\n\nBody of the description.\n\n## Notes\n\nNotes prose.\n\n## Acceptance\n\n- people/ana.md\n",
25
+ "documentTargets": [],
26
+ "definition": "task",
27
+ "budget": 45,
28
+ "expected": {
29
+ "ok": true,
30
+ "spans": [
31
+ {
32
+ "text": "Ship the release\n\n\nPreamble prose.\n\n",
33
+ "source": "Ship the release\nstatus: open\n---\n\nPreamble prose.\n\n"
34
+ },
35
+ {
36
+ "text": "## Description\n\nBody of the description.\n\n",
37
+ "source": "## Description\n\nBody of the description.\n\n"
38
+ },
39
+ {
40
+ "text": "## Notes\n\nNotes prose.\n\n",
41
+ "source": "## Notes\n\nNotes prose.\n\n"
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "name": "a heading node over the budget divides into adjacent blocks carrying its own heading",
48
+ "file": "tasks/one.md",
49
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\n## Overview\n\nFirst paragraph of the overview.\n\nSecond paragraph of the overview.\n\n## Notes\n\nShort note.\n",
50
+ "documentTargets": [],
51
+ "definition": "task",
52
+ "budget": 50,
53
+ "expected": {
54
+ "ok": true,
55
+ "spans": [
56
+ {
57
+ "text": "Task\n\n\n",
58
+ "source": "Task\nstatus: open\n---\n\n"
59
+ },
60
+ {
61
+ "text": "## Overview\n\nFirst paragraph of the overview.\n\n",
62
+ "source": "## Overview\n\nFirst paragraph of the overview.\n\n"
63
+ },
64
+ {
65
+ "text": "## Overview\n\nSecond paragraph of the overview.\n\n",
66
+ "source": "Second paragraph of the overview.\n\n"
67
+ },
68
+ {
69
+ "text": "## Notes\n\nShort note.\n",
70
+ "source": "## Notes\n\nShort note.\n"
71
+ }
72
+ ]
73
+ }
74
+ },
75
+ {
76
+ "name": "a node continuation and the next whole sibling stay in their own Spans",
77
+ "file": "tasks/one.md",
78
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\n## Overview\n\nFirst paragraph of the overview.\n\nSecond paragraph of the overview.\n\n## Notes\n\nShort note.\n",
79
+ "documentTargets": [],
80
+ "definition": "task",
81
+ "budget": 75,
82
+ "expected": {
83
+ "ok": true,
84
+ "spans": [
85
+ {
86
+ "text": "Task\n\n\n",
87
+ "source": "Task\nstatus: open\n---\n\n"
88
+ },
89
+ {
90
+ "text": "## Overview\n\nFirst paragraph of the overview.\n\n",
91
+ "source": "## Overview\n\nFirst paragraph of the overview.\n\n"
92
+ },
93
+ {
94
+ "text": "## Overview\n\nSecond paragraph of the overview.\n\n",
95
+ "source": "Second paragraph of the overview.\n\n"
96
+ },
97
+ {
98
+ "text": "## Notes\n\nShort note.\n",
99
+ "source": "## Notes\n\nShort note.\n"
100
+ }
101
+ ]
102
+ }
103
+ },
104
+ {
105
+ "name": "a continuation Span carries its own node heading and never an ancestor heading",
106
+ "file": "tasks/one.md",
107
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\n## Overview\n\nIntro line.\n\n### Detail\n\nDetail paragraph one.\n\nDetail paragraph two.\n",
108
+ "documentTargets": [],
109
+ "definition": "task",
110
+ "budget": 40,
111
+ "expected": {
112
+ "ok": true,
113
+ "spans": [
114
+ {
115
+ "text": "Task\n\n\n",
116
+ "source": "Task\nstatus: open\n---\n\n"
117
+ },
118
+ {
119
+ "text": "## Overview\n\nIntro line.\n\n",
120
+ "source": "## Overview\n\nIntro line.\n\n"
121
+ },
122
+ {
123
+ "text": "### Detail\n\nDetail paragraph one.\n\n",
124
+ "source": "### Detail\n\nDetail paragraph one.\n\n"
125
+ },
126
+ {
127
+ "text": "### Detail\n\nDetail paragraph two.\n",
128
+ "source": "Detail paragraph two.\n"
129
+ }
130
+ ]
131
+ }
132
+ },
133
+ {
134
+ "name": "a block over the budget divides into sentences that repeat their predecessor",
135
+ "file": "tasks/one.md",
136
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\n## Overview\n\nOne. Two. Three. Four.\n",
137
+ "documentTargets": [],
138
+ "definition": "task",
139
+ "budget": 30,
140
+ "expected": {
141
+ "ok": true,
142
+ "spans": [
143
+ {
144
+ "text": "Task\n\n\n",
145
+ "source": "Task\nstatus: open\n---\n\n"
146
+ },
147
+ {
148
+ "text": "## Overview\n\nOne. Two. Three. ",
149
+ "source": "## Overview\n\nOne. Two. Three. "
150
+ },
151
+ {
152
+ "text": "## Overview\n\nThree. Four.\n",
153
+ "source": "Three. Four.\n"
154
+ }
155
+ ]
156
+ }
157
+ },
158
+ {
159
+ "name": "a single sentence over the budget divides at a bound cut inside it",
160
+ "file": "tasks/one.md",
161
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\n## Overview\n\naaaa bbbb cccc dddd eeee\n",
162
+ "documentTargets": [],
163
+ "definition": "task",
164
+ "budget": 20,
165
+ "expected": {
166
+ "ok": true,
167
+ "spans": [
168
+ {
169
+ "text": "Task\n\n\n",
170
+ "source": "Task\nstatus: open\n---\n\n"
171
+ },
172
+ {
173
+ "text": "## Overview\n\naaaa",
174
+ "source": "## Overview\n\naaaa"
175
+ },
176
+ {
177
+ "text": "## Overview\n\n bbbb",
178
+ "source": " bbbb"
179
+ },
180
+ {
181
+ "text": "## Overview\n\n cccc",
182
+ "source": " cccc"
183
+ },
184
+ {
185
+ "text": "## Overview\n\n dddd",
186
+ "source": " dddd"
187
+ },
188
+ {
189
+ "text": "## Overview\n\n eeee\n",
190
+ "source": " eeee\n"
191
+ }
192
+ ]
193
+ }
194
+ },
195
+ {
196
+ "name": "an untyped input with no definition descends the same ladder",
197
+ "file": "notes/one.md",
198
+ "source": "# Title\n\nIntro paragraph about the whole thing.\n\n## Alpha\n\nAlpha one. Alpha two.\n\n### Deep\n\nDeep prose here.\n\n## Beta\n\nBeta prose.\n",
199
+ "documentTargets": [],
200
+ "definition": null,
201
+ "budget": 60,
202
+ "expected": {
203
+ "ok": true,
204
+ "spans": [
205
+ {
206
+ "text": "# Title\n\nIntro paragraph about the whole thing.\n\n",
207
+ "source": "# Title\n\nIntro paragraph about the whole thing.\n\n"
208
+ },
209
+ {
210
+ "text": "## Alpha\n\nAlpha one. Alpha two.\n\n",
211
+ "source": "## Alpha\n\nAlpha one. Alpha two.\n\n"
212
+ },
213
+ {
214
+ "text": "### Deep\n\nDeep prose here.\n\n",
215
+ "source": "### Deep\n\nDeep prose here.\n\n"
216
+ },
217
+ {
218
+ "text": "## Beta\n\nBeta prose.\n",
219
+ "source": "## Beta\n\nBeta prose.\n"
220
+ }
221
+ ]
222
+ }
223
+ },
224
+ {
225
+ "name": "a Document that declares the built-in any type divides its body after the fence",
226
+ "file": "notes/two.md",
227
+ "source": "---\ntype: any\ntitle: Note\n---\n\n## Notes\n\nRead it.\n",
228
+ "documentTargets": [],
229
+ "definition": null,
230
+ "budget": 4096,
231
+ "expected": {
232
+ "ok": true,
233
+ "spans": [
234
+ {
235
+ "text": "\n## Notes\n\nRead it.\n",
236
+ "source": "\n## Notes\n\nRead it.\n"
237
+ }
238
+ ]
239
+ }
240
+ },
241
+ {
242
+ "name": "an internal link embeds its label and addresses the destination the author wrote",
243
+ "file": "tasks/one.md",
244
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\n## Overview\n\nRead [the plan](../plans/q3.md) before starting.\n\n## Notes\n\nShort note.\n",
245
+ "documentTargets": [
246
+ "plans/q3.md"
247
+ ],
248
+ "definition": "task",
249
+ "budget": 50,
250
+ "expected": {
251
+ "ok": true,
252
+ "spans": [
253
+ {
254
+ "text": "Task\n\n\n",
255
+ "source": "Task\nstatus: open\n---\n\n"
256
+ },
257
+ {
258
+ "text": "## Overview\n\nRead the plan before starting.\n\n",
259
+ "source": "## Overview\n\nRead [the plan](../plans/q3.md) before starting.\n\n"
260
+ },
261
+ {
262
+ "text": "## Notes\n\nShort note.\n",
263
+ "source": "## Notes\n\nShort note.\n"
264
+ }
265
+ ]
266
+ }
267
+ },
268
+ {
269
+ "name": "a declared structured section stays outside the text and inside the extent",
270
+ "file": "tasks/one.md",
271
+ "source": "---\ntype: task\nname: Task\nstatus: open\n---\n\nPreamble prose.\n\n## Acceptance\n\n- people/ana.md\n\n## Notes\n\nShort note.\n",
272
+ "documentTargets": [],
273
+ "definition": "task",
274
+ "budget": 4096,
275
+ "expected": {
276
+ "ok": true,
277
+ "spans": [
278
+ {
279
+ "text": "Task\n\n\nPreamble prose.\n\n## Notes\n\nShort note.\n",
280
+ "source": "Task\nstatus: open\n---\n\nPreamble prose.\n\n## Acceptance\n\n- people/ana.md\n\n## Notes\n\nShort note.\n"
281
+ }
282
+ ]
283
+ }
284
+ },
285
+ {
286
+ "name": "a Document that declares a type the caller supplies no definition for is refused",
287
+ "file": "tasks/one.md",
288
+ "source": "---\ntype: task\nname: Ship the release\nstatus: open\n---\n\nPreamble prose.\n\n## Description\n\nBody of the description.\n\n## Acceptance\n\n- people/ana.md\n",
289
+ "documentTargets": [],
290
+ "definition": null,
291
+ "budget": 4096,
292
+ "expected": {
293
+ "ok": false,
294
+ "refusal": {
295
+ "file": "tasks/one.md",
296
+ "rule": "unknown-type",
297
+ "location": "type"
298
+ }
299
+ }
300
+ },
301
+ {
302
+ "name": "a budget that cannot hold one whole character is refused before any division",
303
+ "file": "notes/one.md",
304
+ "source": "## Notes\n\nShort note.\n",
305
+ "documentTargets": [],
306
+ "definition": null,
307
+ "budget": 1,
308
+ "expected": {
309
+ "ok": false,
310
+ "refusal": {
311
+ "file": "notes/one.md",
312
+ "rule": "division-budget"
313
+ }
314
+ }
315
+ },
316
+ {
317
+ "name": "a free-text value the author quoted embeds bare and addresses the quotes it was written with",
318
+ "file": "tasks/one.md",
319
+ "source": "---\ntype: task\nname: \"Ship: the release\"\nstatus: open\n---\n\nBody prose.\n",
320
+ "documentTargets": [],
321
+ "definition": "task",
322
+ "budget": 4096,
323
+ "expected": {
324
+ "ok": true,
325
+ "spans": [
326
+ {
327
+ "text": "Ship: the release\n\n\nBody prose.\n",
328
+ "source": "\"Ship: the release\"\nstatus: open\n---\n\nBody prose.\n"
329
+ }
330
+ ]
331
+ }
332
+ },
333
+ {
334
+ "name": "sentence division reads every terminator and closer and drops a carry the budget cannot hold",
335
+ "file": "notes/three.md",
336
+ "source": "## Ask\n\nReady? Go! He said \"no.\" Then (silence.) Done.\n",
337
+ "documentTargets": [],
338
+ "definition": null,
339
+ "budget": 30,
340
+ "expected": {
341
+ "ok": true,
342
+ "spans": [
343
+ {
344
+ "text": "## Ask\n\nReady? Go! ",
345
+ "source": "## Ask\n\nReady? Go! "
346
+ },
347
+ {
348
+ "text": "## Ask\n\nGo! He said \"no.\" ",
349
+ "source": "Go! He said \"no.\" "
350
+ },
351
+ {
352
+ "text": "## Ask\n\nThen (silence.) Done.\n",
353
+ "source": "Then (silence.) Done.\n"
354
+ }
355
+ ]
356
+ }
357
+ },
358
+ {
359
+ "name": "a heading with no body of its own leads the first child node instead of standing alone",
360
+ "file": "notes/four.md",
361
+ "source": "## Part\n\n### Alpha\n\nAlpha prose that is long enough to matter.\n\n### Beta\n\nBeta prose.\n",
362
+ "documentTargets": [],
363
+ "definition": null,
364
+ "budget": 70,
365
+ "expected": {
366
+ "ok": true,
367
+ "spans": [
368
+ {
369
+ "text": "## Part\n\n### Alpha\n\nAlpha prose that is long enough to matter.\n\n",
370
+ "source": "## Part\n\n### Alpha\n\nAlpha prose that is long enough to matter.\n\n"
371
+ },
372
+ {
373
+ "text": "### Beta\n\nBeta prose.\n",
374
+ "source": "### Beta\n\nBeta prose.\n"
375
+ }
376
+ ]
377
+ }
378
+ },
379
+ {
380
+ "name": "a heading the budget cannot hold beside any text is not repeated",
381
+ "file": "notes/five.md",
382
+ "source": "## An overview of the release\n\nFirst paragraph here.\n\nSecond paragraph here.\n",
383
+ "documentTargets": [],
384
+ "definition": null,
385
+ "budget": 25,
386
+ "expected": {
387
+ "ok": true,
388
+ "spans": [
389
+ {
390
+ "text": "## An overview of the",
391
+ "source": "## An overview of the"
392
+ },
393
+ {
394
+ "text": " release\n\nFirst paragraph",
395
+ "source": " release\n\nFirst paragraph"
396
+ },
397
+ {
398
+ "text": " here.\n\n",
399
+ "source": " here.\n\n"
400
+ },
401
+ {
402
+ "text": "Second paragraph here.\n",
403
+ "source": "Second paragraph here.\n"
404
+ }
405
+ ]
406
+ }
407
+ }
408
+ ]
409
+ }
@@ -1,8 +1,5 @@
1
1
  {
2
- "definitions": {
3
- "task": "---\ntype: definition\nfields:\n name: { kind: text, required: true }\n aliases: { kind: list, of: text }\n title: { kind: string, required: true }\n status: { kind: enum, values: [open, done], required: true }\n owner: { kind: reference, to: person }\n due: { kind: date }\n estimate: { kind: number }\n labels: { kind: list, of: string }\nsections:\n Description: { kind: text, required: true }\n Acceptance: { kind: list, of: reference, to: person }\n Checklist: { kind: list, of: text }\n---\n",
4
- "unreadable-task": "---\ntype: definition\nsections:\n Description: { kind: prose }\n---\n"
5
- },
2
+ "schema": "types:\n task:\n fields:\n name: { kind: text, required: true }\n aliases: { kind: list, of: text }\n title: { kind: string, required: true }\n status: { kind: enum, values: [open, done], required: true }\n owner: { kind: reference, to: person }\n due: { kind: date }\n estimate: { kind: number }\n labels: { kind: list, of: string }\n sections:\n Description: { kind: text, required: true }\n Acceptance: { kind: list, of: reference, to: person }\n Checklist: { kind: list, of: text }\n person: {}\n",
6
3
  "cases": [
7
4
  {
8
5
  "name": "any body keeps labels and leaves every unsupplied destination authored",
@@ -83,6 +80,14 @@
83
80
  "href": "../plans/q3.md",
84
81
  "to": "../plans/2026-q3.md"
85
82
  },
83
+ "relabel": {
84
+ "from": "[the plan][plan] and",
85
+ "to": "[the roadmap][plan] and",
86
+ "expected": {
87
+ "ok": true,
88
+ "text": "Shipping the release\n\n\nPreamble prose that mentions the plan.\n\n## Description\n\nFollow the roadmap and the plan again, then read it.\n\n\n## Checklist\n\n- the plan is read\n\n## Notes\n\nUndeclared prose about the plan.\n"
89
+ }
90
+ },
86
91
  "expected": {
87
92
  "ok": true,
88
93
  "text": "Shipping the release\n\n\nPreamble prose that mentions the plan.\n\n## Description\n\nFollow the plan and the plan again, then read it.\n\n\n## Checklist\n\n- the plan is read\n\n## Notes\n\nUndeclared prose about the plan.\n"
@@ -139,35 +144,32 @@
139
144
  "refusal": {
140
145
  "file": "tasks/one.md",
141
146
  "rule": "unknown-type",
142
- "version": "<package-version>",
143
147
  "location": "type"
144
148
  }
145
149
  }
146
150
  },
147
151
  {
148
- "name": "a definition the model cannot read is refused at that definition",
149
- "file": "tasks/one.md",
150
- "source": "---\ntype: task\nname: Shipping the release\ntitle: Ship it\nstatus: open\nowner: ../people/ana.md\n---\n\nPreamble prose that mentions [the plan](../plans/q3.md).\n\n## Description\n\nFollow [the plan][plan] and [the plan][plan] again, then [read it][].\n\n[plan]: ../plans/q3.md \"Plan\"\n[read it]: ../plans/q3.md\n\n## Acceptance\n\n- [the plan](../plans/q3.md) is linked\n\n## Checklist\n\n- [the plan](../plans/q3.md) is read\n\n## Notes\n\nUndeclared prose about [the plan](../plans/q3.md).\n",
152
+ "name": "an image at a supplied Markdown document target is projected like its link",
153
+ "file": "notes/four.md",
154
+ "source": "Read [the plan](../plans/q3.md) and ![the chart](../plans/q3.md).\nAlso [the plan][plan] and ![the chart][plan].\n\n[plan]: ../plans/q3.md\n",
151
155
  "documentTargets": [
152
156
  "plans/q3.md",
153
157
  "plans/2026-q3.md"
154
158
  ],
155
- "definition": "unreadable-task",
156
- "move": null,
159
+ "definition": null,
160
+ "move": {
161
+ "href": "../plans/q3.md",
162
+ "to": "../plans/2026-q3.md"
163
+ },
157
164
  "expected": {
158
- "ok": false,
159
- "refusal": {
160
- "file": "types/task.md",
161
- "rule": "definition-section-kind",
162
- "version": "<package-version>",
163
- "location": "Description"
164
- }
165
+ "ok": true,
166
+ "text": "Read the plan and the chart.\nAlso the plan and the chart.\n\n"
165
167
  }
166
168
  },
167
169
  {
168
- "name": "an image at a supplied Markdown document target is projected like its link",
169
- "file": "notes/four.md",
170
- "source": "Read [the plan](../plans/q3.md) and ![the chart](../plans/q3.md).\nAlso [the plan][plan] and ![the chart][plan].\n\n[plan]: ../plans/q3.md\n",
170
+ "name": "a shortcut reference link projects its label and its definition leaves the projection",
171
+ "file": "notes/five.md",
172
+ "source": "Read [Plan] and [the draft], then [plan](not a link).\nAlso [[Plan]], [ plan ], \\[Plan] and [Release plan].\n\n[plan]: ../plans/q3.md\n[release plan]: ../plans/q3.md\n",
171
173
  "documentTargets": [
172
174
  "plans/q3.md",
173
175
  "plans/2026-q3.md"
@@ -177,9 +179,44 @@
177
179
  "href": "../plans/q3.md",
178
180
  "to": "../plans/2026-q3.md"
179
181
  },
182
+ "links": [
183
+ {
184
+ "href": "../plans/q3.md",
185
+ "target": "plans/q3.md"
186
+ }
187
+ ],
180
188
  "expected": {
181
189
  "ok": true,
182
- "text": "Read the plan and the chart.\nAlso the plan and the chart.\n\n"
190
+ "text": "Read Plan and [the draft], then plan(not a link).\nAlso [Plan], plan , \\[Plan] and Release plan.\n\n"
191
+ }
192
+ },
193
+ {
194
+ "name": "an image whose description holds a link projects both labels",
195
+ "file": "notes/six.md",
196
+ "source": "Read ![outer [Plan](../plans/q3.md)](../plans/q4.md).\n",
197
+ "documentTargets": [
198
+ "plans/q3.md",
199
+ "plans/2026-q3.md",
200
+ "plans/q4.md"
201
+ ],
202
+ "definition": null,
203
+ "move": {
204
+ "href": "../plans/q3.md",
205
+ "to": "../plans/2026-q3.md"
206
+ },
207
+ "links": [
208
+ {
209
+ "href": "../plans/q3.md",
210
+ "target": "plans/q3.md"
211
+ },
212
+ {
213
+ "href": "../plans/q4.md",
214
+ "target": "plans/q4.md"
215
+ }
216
+ ],
217
+ "expected": {
218
+ "ok": true,
219
+ "text": "Read outer Plan.\n"
183
220
  }
184
221
  }
185
222
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdmodel",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-c83456e1cebfb",
4
4
  "description": "MD Type language, parser, validator, structured change application, Markdown syntax profile, and conformance fixtures",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,19 +21,10 @@
21
21
  "files": [
22
22
  "dist",
23
23
  "fixtures",
24
+ "API.md",
24
25
  "LICENSE",
25
- "README.md",
26
- "markdown-syntax-profile.md"
26
+ "README.md"
27
27
  ],
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/agentshouse/mdmodel.git",
31
- "directory": "packages/mdmodel"
32
- },
33
- "homepage": "https://github.com/agentshouse/mdmodel#readme",
34
- "bugs": {
35
- "url": "https://github.com/agentshouse/mdmodel/issues"
36
- },
37
28
  "dependencies": {
38
29
  "@cfworker/json-schema": "4.1.1"
39
30
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/workspace/packages/mdmodel/src/definition.ts"],"sourcesContent":["import { typeNameFromPath } from './paths.js';\nimport { refusal } from './refuse.js';\nimport type { Document, Refusal } from './types.js';\n\nexport type TextSpec = { readonly kind: 'text'; readonly required: boolean };\n\nexport type ScalarSpec =\n | TextSpec\n | { readonly kind: 'string'; readonly required: boolean }\n | { readonly kind: 'number'; readonly required: boolean }\n | { readonly kind: 'date'; readonly required: boolean }\n | { readonly kind: 'enum'; readonly required: boolean; readonly values: readonly string[] }\n | { readonly kind: 'reference'; readonly required: boolean; readonly to: string };\n\nexport type ListSpec = {\n readonly kind: 'list';\n readonly required: boolean;\n readonly of: ScalarSpec;\n};\n\nexport type FieldSpec = ScalarSpec | ListSpec;\n\nexport type SectionSpec = TextSpec | ListSpec;\n\nexport type Definition = {\n readonly name: string;\n readonly file: string;\n readonly fields: Readonly<Record<string, FieldSpec>>;\n readonly sections: Readonly<Record<string, SectionSpec>>;\n};\n\nfunction refuse(file: string, rule: string, location?: string): Refusal {\n return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction requiredFlag(value: unknown): boolean | undefined {\n if (value === undefined) return false;\n if (typeof value === 'boolean') return value;\n return undefined;\n}\n\nfunction stringList(value: unknown): string[] | undefined {\n if (!Array.isArray(value) || value.length === 0) return undefined;\n if (!value.every((item) => typeof item === 'string' && item !== '')) return undefined;\n return value;\n}\n\nconst SCALAR_KINDS = new Set(['text', 'string', 'number', 'date', 'enum', 'reference']);\n\nfunction parseScalar(\n file: string,\n location: string,\n spec: Record<string, unknown>,\n required: boolean,\n): ScalarSpec | Refusal {\n const kind = spec.kind;\n if (kind === 'text') return { kind: 'text', required };\n if (kind === 'string') return { kind: 'string', required };\n if (kind === 'number') return { kind: 'number', required };\n if (kind === 'date') return { kind: 'date', required };\n if (kind === 'enum') {\n const values = stringList(spec.values);\n if (values === undefined) return refuse(file, 'definition-enum-values', location);\n return { kind: 'enum', required, values };\n }\n if (kind === 'reference') {\n if (typeof spec.to !== 'string' || spec.to === '')\n return refuse(file, 'definition-reference-to', location);\n return { kind: 'reference', required, to: spec.to };\n }\n return refuse(file, 'definition-field-kind', location);\n}\n\nfunction extraKeys(spec: Record<string, unknown>, allowed: readonly string[]): boolean {\n return Object.keys(spec).some((key) => !allowed.includes(key));\n}\n\nfunction parseList(\n file: string,\n location: string,\n spec: Record<string, unknown>,\n required: boolean,\n malformed: string,\n): ListSpec | Refusal {\n if (typeof spec.of !== 'string' || !SCALAR_KINDS.has(spec.of)) {\n return refuse(file, 'definition-list-of', location);\n }\n const allowed =\n spec.of === 'enum'\n ? ['kind', 'required', 'of', 'values']\n : spec.of === 'reference'\n ? ['kind', 'required', 'of', 'to']\n : ['kind', 'required', 'of'];\n if (extraKeys(spec, allowed)) return refuse(file, malformed, location);\n const inner = parseScalar(file, location, { ...spec, kind: spec.of }, false);\n if ('rule' in inner) return inner;\n return { kind: 'list', required, of: inner };\n}\n\nfunction parseField(file: string, location: string, value: unknown): FieldSpec | Refusal {\n if (!isRecord(value) || typeof value.kind !== 'string')\n return refuse(file, 'definition-field', location);\n const required = requiredFlag(value.required);\n if (required === undefined) return refuse(file, 'definition-field', location);\n if (value.kind === 'list') return parseList(file, location, value, required, 'definition-field');\n const allowed =\n value.kind === 'enum'\n ? ['kind', 'required', 'values']\n : value.kind === 'reference'\n ? ['kind', 'required', 'to']\n : ['kind', 'required'];\n if (extraKeys(value, allowed)) return refuse(file, 'definition-field', location);\n return parseScalar(file, location, value, required);\n}\n\nfunction parseSection(file: string, location: string, value: unknown): SectionSpec | Refusal {\n if (!isRecord(value) || (value.kind !== 'text' && value.kind !== 'list')) {\n return refuse(file, 'definition-section-kind', location);\n }\n const required = requiredFlag(value.required);\n if (required === undefined) return refuse(file, 'definition-section', location);\n if (value.kind === 'list')\n return parseList(file, location, value, required, 'definition-section');\n if (extraKeys(value, ['kind', 'required'])) return refuse(file, 'definition-section', location);\n return { kind: 'text', required };\n}\n\nexport function readDefinition(file: string, document: Document): Definition | Refusal {\n if (document.type !== 'definition') return refuse(file, 'definition-type');\n const name = typeNameFromPath(file);\n if (name === '') return refuse(file, 'definition-type');\n for (const key of Object.keys(document.fields)) {\n if (key !== 'type' && key !== 'fields' && key !== 'sections') {\n return refuse(file, 'definition-shape', key);\n }\n }\n const fieldsValue = document.fields.fields;\n const sectionsValue = document.fields.sections;\n if (fieldsValue !== undefined && !isRecord(fieldsValue))\n return refuse(file, 'definition-fields', 'fields');\n if (sectionsValue !== undefined && !isRecord(sectionsValue)) {\n return refuse(file, 'definition-sections', 'sections');\n }\n const fields: Record<string, FieldSpec> = Object.create(null);\n for (const [fieldName, spec] of Object.entries(fieldsValue ?? {})) {\n const parsed = parseField(file, fieldName, spec);\n if ('rule' in parsed) return parsed;\n fields[fieldName] = parsed;\n }\n const sections: Record<string, SectionSpec> = Object.create(null);\n for (const [sectionName, spec] of Object.entries(sectionsValue ?? {})) {\n const parsed = parseSection(file, sectionName, spec);\n if ('rule' in parsed) return parsed;\n sections[sectionName] = parsed;\n }\n return { name, file, fields, sections };\n}\n"],"names":["typeNameFromPath","refusal","refuse","file","rule","location","undefined","isRecord","value","Array","isArray","requiredFlag","stringList","length","every","item","SCALAR_KINDS","Set","parseScalar","spec","required","kind","values","to","extraKeys","allowed","Object","keys","some","key","includes","parseList","malformed","of","has","inner","parseField","parseSection","readDefinition","document","type","name","fields","fieldsValue","sectionsValue","sections","create","fieldName","entries","parsed","sectionName"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,OAAO,QAAQ,cAAc;AA8BtC,SAASC,OAAOC,IAAY,EAAEC,IAAY,EAAEC,QAAiB;IAC3D,OAAOA,aAAaC,YAAYL,QAAQE,MAAMC,QAAQH,QAAQE,MAAMC,MAAM;QAAEC;IAAS;AACvF;AAEA,SAASE,SAASC,KAAc;IAC9B,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,CAACC,MAAMC,OAAO,CAACF;AACvE;AAEA,SAASG,aAAaH,KAAc;IAClC,IAAIA,UAAUF,WAAW,OAAO;IAChC,IAAI,OAAOE,UAAU,WAAW,OAAOA;IACvC,OAAOF;AACT;AAEA,SAASM,WAAWJ,KAAc;IAChC,IAAI,CAACC,MAAMC,OAAO,CAACF,UAAUA,MAAMK,MAAM,KAAK,GAAG,OAAOP;IACxD,IAAI,CAACE,MAAMM,KAAK,CAAC,CAACC,OAAS,OAAOA,SAAS,YAAYA,SAAS,KAAK,OAAOT;IAC5E,OAAOE;AACT;AAEA,MAAMQ,eAAe,IAAIC,IAAI;IAAC;IAAQ;IAAU;IAAU;IAAQ;IAAQ;CAAY;AAEtF,SAASC,YACPf,IAAY,EACZE,QAAgB,EAChBc,IAA6B,EAC7BC,QAAiB;IAEjB,MAAMC,OAAOF,KAAKE,IAAI;IACtB,IAAIA,SAAS,QAAQ,OAAO;QAAEA,MAAM;QAAQD;IAAS;IACrD,IAAIC,SAAS,U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/packages/mdmodel/src/document.ts"],"sourcesContent":["import { hrefOccurrences } from './links.js';\nimport { classifyHref, hrefSuffix } from './paths.js';\nimport { headingSpans, sectionsRecord } from './sections.js';\nimport { refusal } from './refuse.js';\nimport type { ApplyResult, Change, Document, Link, ParseResult } from './types.js';\nimport {\n bodyStartAfterYaml,\n bodyStartOf,\n equalValue,\n extractFrontmatter,\n jsValue,\n lineEnding,\n mapEntry,\n parseYamlMapping,\n serializeJs,\n serializeKey,\n YamlError,\n type YamlMap,\n} from './yaml.js';\n\ntype Internal = {\n readonly root: YamlMap | null;\n readonly yamlEnd: number;\n readonly bodyStart: number;\n};\n\nconst internals = new WeakMap<Document, Internal>();\n\nfunction refuse(file: string, rule: string, location?: string) {\n return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });\n}\n\nfunction freezeDocument(\n content: string,\n type: string | undefined,\n fields: Record<string, unknown>,\n preamble: string,\n sections: Record<string, string>,\n internal: Internal,\n): Document {\n const document: Document = Object.freeze({\n content,\n type,\n fields: Object.freeze(fields),\n preamble,\n sections: Object.freeze(sections),\n });\n internals.set(document, internal);\n return document;\n}\n\nfunction declaredType(fields: Record<string, unknown>): string | undefined {\n const value = fields.type;\n if (value === undefined || value === null) return undefined;\n if (typeof value !== 'string' || value === '') return undefined;\n return value;\n}\n\nexport function parse(content: string, file = ''): ParseResult {\n const fence = extractFrontmatter(content);\n if (fence.kind === 'none') {\n const spans = headingSpans(content, 0);\n return {\n ok: true,\n document: freezeDocument(\n content,\n undefined,\n {},\n content.slice(0, spans[0]?.headingStart),\n sectionsRecord(spans, content),\n {\n root: null,\n yamlEnd: 0,\n bodyStart: 0,\n },\n ),\n };\n }\n if (fence.kind === 'unclosed') return { ok: false, refusal: refuse(file, 'frontmatter-fence') };\n try {\n const root = parseYamlMapping(content, fence.yamlStart, fence.yamlEnd);\n const fields = jsValue(root);\n if (fields === null || typeof fields !== 'object' || Array.isArray(fields)) {\n return { ok: false, refusal: refuse(file, 'frontmatter-fence') };\n }\n const bodyStart = bodyStartAfterYaml(content, fence.yamlEnd);\n const spans = headingSpans(content, bodyStart);\n const record = fields as Record<string, unknown>;\n return {\n ok: true,\n document: freezeDocument(\n content,\n declaredType(record),\n record,\n content.slice(bodyStart, spans[0]?.headingStart),\n sectionsRecord(spans, content),\n {\n root,\n yamlEnd: fence.yamlEnd,\n bodyStart,\n },\n ),\n };\n } catch (error) {\n if (error instanceof YamlError)\n return { ok: false, refusal: refuse(file, 'frontmatter-fence') };\n throw error;\n }\n}\n\nfunction splice(content: string, start: number, end: number, insert: string): string {\n return content.slice(0, start) + insert + content.slice(end);\n}\n\nfunction applyField(document: Document, name: string, value: unknown, prior: unknown): ApplyResult {\n const internal = internals.get(document);\n if (internal === undefined || internal.root === null) {\n return { outcome: 'refuse', refusal: refuse('', 'frontmatter-fence', name) };\n }\n if (!equalValue(document.fields[name], prior)) {\n return { outcome: 'stale', document };\n }\n let nextContent: string;\n const existing = mapEntry(internal.root, name);\n if (existing !== undefined) {\n nextContent = splice(\n document.content,\n existing.value.start,\n existing.value.end,\n serializeJs(value),\n );\n } else {\n const nl = lineEnding(document.content);\n const line = `${serializeKey(name)}: ${serializeJs(value)}${nl}`;\n const before = document.content.slice(0, internal.yamlEnd);\n const prefix = before.endsWith('\\n') || before.endsWith('\\r\\n') ? '' : nl;\n nextContent = splice(document.content, internal.yamlEnd, internal.yamlEnd, `${prefix}${line}`);\n }\n const parsed = parse(nextContent);\n if (!parsed.ok) return { outcome: 'refuse', refusal: parsed.refusal };\n return { outcome: 'applied', document: parsed.document };\n}\n\nfunction applySection(document: Document, name: string, value: string, prior: string): ApplyResult {\n const internal = internals.get(document);\n if (internal === undefined)\n return { outcome: 'refuse', refusal: refuse('', 'required-section', name) };\n const spans = headingSpans(document.content, internal.bodyStart);\n const span = spans.find((item) => item.name === name);\n if (span === undefined)\n return { outcome: 'refuse', refusal: refuse('', 'required-section', name) };\n const current = document.content.slice(span.bodyStart, span.bodyEnd);\n if (current !== prior) return { outcome: 'stale', document };\n const parsed = parse(splice(document.content, span.bodyStart, span.bodyEnd, value));\n if (!parsed.ok) return { outcome: 'refuse', refusal: parsed.refusal };\n return { outcome: 'applied', document: parsed.document };\n}\n\nfunction applyPreamble(document: Document, value: string, prior: string): ApplyResult {\n if (document.preamble !== prior) return { outcome: 'stale', document };\n const start = bodyStartOf(document.content);\n const parsed = parse(splice(document.content, start, start + document.preamble.length, value));\n if (!parsed.ok) return { outcome: 'refuse', refusal: parsed.refusal };\n return { outcome: 'applied', document: parsed.document };\n}\n\nfunction fitsBare(to: string): boolean {\n if (to === '' || to.startsWith('<')) return false;\n let depth = 0;\n for (const character of to) {\n if (/[\\s\\u0000-\\u001f\\u007f]/.test(character)) return false;\n if (character === '(') depth += 1;\n else if (character === ')') {\n if (depth === 0) return false;\n depth -= 1;\n }\n }\n return depth === 0;\n}\n\nfunction fitsBrackets(to: string): boolean {\n return to !== '' && !/[<>\\n\\r]/.test(to);\n}\n\nfunction destinationText(to: string, bracketed: boolean): string | null {\n if (fitsBare(to)) return bracketed && fitsBrackets(to) ? `<${to}>` : to;\n if (fitsBrackets(to)) return `<${to}>`;\n return null;\n}\n\nfunction applyLink(document: Document, href: string, to: string): ApplyResult {\n const content = document.content;\n const bodyStart = bodyStartOf(content);\n const matches = hrefOccurrences(content.slice(bodyStart)).filter(\n (occurrence) => occurrence.href === href,\n );\n if (matches.length === 0) return { outcome: 'stale', document };\n const written = to + hrefSuffix(href);\n let rewritten = '';\n let cursor = 0;\n for (const match of matches) {\n const text = destinationText(written, match.bracketed);\n if (text === null)\n return { outcome: 'refuse', refusal: refuse('', 'unwritable-link', written) };\n rewritten += content.slice(cursor, bodyStart + match.start);\n rewritten += text;\n cursor = bodyStart + match.end;\n }\n const parsed = parse(rewritten + content.slice(cursor));\n if (!parsed.ok) return { outcome: 'refuse', refusal: parsed.refusal };\n return { outcome: 'applied', document: parsed.document };\n}\n\nexport function links(document: Document, file: string): readonly Link[] {\n const found: Link[] = [];\n const seen = new Set<string>();\n for (const occurrence of hrefOccurrences(document.content.slice(bodyStartOf(document.content)))) {\n if (seen.has(occurrence.href)) continue;\n const resolved = classifyHref(file, occurrence.href);\n if (resolved.kind !== 'path') continue;\n seen.add(occurrence.href);\n found.push({ href: occurrence.href, target: resolved.path });\n }\n return found;\n}\n\nexport function apply(document: Document, change: Change): ApplyResult {\n if (change.kind === 'link') return applyLink(document, change.href, change.to);\n if (change.kind === 'preamble') return applyPreamble(document, change.value, change.prior);\n try {\n if (change.kind === 'field')\n return applyField(document, change.name, change.value, change.prior);\n return applySection(document, change.name, change.value, change.prior);\n } catch (error) {\n if (error instanceof YamlError) {\n return { outcome: 'refuse', refusal: refuse('', 'frontmatter-fence', change.name) };\n }\n throw error;\n }\n}\n\nexport function serialize(document: Document): string {\n return document.content;\n}\n"],"names":["hrefOccurrences","classifyHref","hrefSuffix","headingSpans","sectionsRecord","refusal","bodyStartAfterYaml","bodyStartOf","equalValue","extractFrontmatter","jsValue","lineEnding","mapEntry","parseYamlMapping","serializeJs","serializeKey","YamlError","internals","WeakMap","refuse","file","rule","location","undefined","freezeDocument","content","type","fields","preamble","sections","internal","document","Object","freeze","set","declaredType","value","parse","fence","kind","spans","ok","slice","headingStart","root","yamlEnd","bodyStart","yamlStart","Array","isArray","record","error","splice","start","end","insert","applyField","name","prior","get","outcome","nextContent","existing","nl","line","before","prefix","endsWith","parsed","applySection","span","find","item","current","bodyEnd","applyPreamble","length","fitsBare","to","startsWith","depth","character","test","fitsBrackets","destinationText","bracketed","applyLink","href","matches","filter","occurrence","written","rewritten","cursor","match","text","links","found","seen","Set","has","resolved","add","push","target","path","apply","change","serialize"],"mappings":"AAAA,SAASA,eAAe,QAAQ,aAAa;AAC7C,SAASC,YAAY,EAAEC,UAAU,QAAQ,aAAa;AACtD,SAASC,YAAY,EAAEC,cAAc,QAAQ,gBAAgB;AAC7D,SAASC,OAAO,QAAQ,cAAc;AAEtC,SACEC,kBAAkB,EAClBC,WAAW,EACXC,UAAU,EACVC,kBA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],"sourcesContent":["export { apply, links, parse, serialize } from './document.js';\nexport { MARKDOWN_SYNTAX_PROFILE } from './profile.js';\nexport { project } from './project.js';\nexport type {\n ApplyResult,\n Change,\n Document,\n Library,\n Link,\n ParseResult,\n Projection,\n ProjectionContext,\n Refusal,\n Validation,\n ValidationContext,\n} from './types.js';\nexport { validate } from './validate.js';\nexport { VERSION } from './version.js';\n"],"names":["apply","links","parse","serialize","MARKDOWN_SYNTAX_PROFILE","project","validate","VERSION"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC/D,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,OAAO,QAAQ,eAAe;AAcvC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,OAAO,QAAQ,eAAe"}