@agentshouse/mdmodel 0.1.0-alpha.8 → 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 (205) hide show
  1. package/API.md +298 -0
  2. package/README.md +29 -172
  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 +15 -9
  7. package/dist/definition.d.ts.map +1 -1
  8. package/dist/definition.js +148 -133
  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 +83 -73
  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 +45 -67
  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 -122
  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 +196 -187
  51. package/fixtures/README.md +77 -52
  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/context.json +1 -0
  84. package/fixtures/cases/missing-section-item-kind/expected.json +5 -0
  85. package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
  86. package/fixtures/cases/paragraph-link-definition/schema.yaml +2 -0
  87. package/fixtures/cases/prototype-field/context.json +1 -0
  88. package/fixtures/cases/prototype-field/expected.json +6 -0
  89. package/fixtures/cases/prototype-field/library/item.md +9 -0
  90. package/fixtures/cases/prototype-field/schema.yaml +6 -0
  91. package/fixtures/cases/quoted-link-definition/expected.json +1 -2
  92. package/fixtures/cases/quoted-link-definition/schema.yaml +2 -0
  93. package/fixtures/cases/referenced-missing-file/expected.json +0 -1
  94. package/fixtures/cases/referenced-missing-file/schema.yaml +10 -0
  95. package/fixtures/cases/second-member-document/context.json +1 -0
  96. package/fixtures/cases/second-member-document/expected.json +5 -0
  97. package/fixtures/cases/second-member-document/schema.yaml +5 -0
  98. package/fixtures/cases/section-item-enum/context.json +1 -0
  99. package/fixtures/cases/section-item-enum/expected.json +6 -0
  100. package/fixtures/cases/section-item-enum/library/task.md +8 -0
  101. package/fixtures/cases/section-item-enum/schema.yaml +4 -0
  102. package/fixtures/cases/section-item-kind/context.json +1 -0
  103. package/fixtures/cases/section-item-kind/expected.json +6 -0
  104. package/fixtures/cases/section-item-kind/library/task.md +8 -0
  105. package/fixtures/cases/section-item-kind/schema.yaml +4 -0
  106. package/fixtures/cases/section-items/context.json +1 -0
  107. package/fixtures/cases/section-items/expected.json +1 -0
  108. package/fixtures/cases/section-items/library/other.md +3 -0
  109. package/fixtures/cases/section-items/library/page.md +28 -0
  110. package/fixtures/cases/section-items/schema.yaml +8 -0
  111. package/fixtures/cases/section-reference-path/context.json +1 -0
  112. package/fixtures/cases/section-reference-path/expected.json +6 -0
  113. package/fixtures/cases/section-reference-path/library/other.md +3 -0
  114. package/fixtures/cases/section-reference-path/library/page.md +7 -0
  115. package/fixtures/cases/section-reference-path/schema.yaml +4 -0
  116. package/fixtures/cases/section-reference-type/context.json +1 -0
  117. package/fixtures/cases/section-reference-type/expected.json +6 -0
  118. package/fixtures/cases/section-reference-type/library/note.md +1 -0
  119. package/fixtures/cases/section-reference-type/library/page.md +7 -0
  120. package/fixtures/cases/section-reference-type/schema.yaml +4 -0
  121. package/fixtures/cases/shortcut-reference-link/context.json +1 -0
  122. package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
  123. package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
  124. package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
  125. package/fixtures/cases/structured-section/expected.json +1 -2
  126. package/fixtures/cases/structured-section/schema.yaml +7 -0
  127. package/fixtures/cases/submission-keys/context.json +1 -0
  128. package/fixtures/cases/submission-keys/expected.json +1 -0
  129. package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
  130. package/fixtures/cases/submission-keys/schema.yaml +4 -0
  131. package/fixtures/cases/text-field-kind/context.json +1 -0
  132. package/fixtures/cases/text-field-kind/expected.json +6 -0
  133. package/fixtures/cases/text-field-kind/library/page.md +4 -0
  134. package/fixtures/cases/text-field-kind/schema.yaml +4 -0
  135. package/fixtures/cases/truncated-link-definition/expected.json +1 -2
  136. package/fixtures/cases/truncated-link-definition/schema.yaml +2 -0
  137. package/fixtures/cases/types-folder-content/context.json +1 -0
  138. package/fixtures/cases/types-folder-content/expected.json +1 -0
  139. package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
  140. package/fixtures/cases/types-folder-content/schema.yaml +4 -0
  141. package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
  142. package/fixtures/cases/undeclared-field/context.json +1 -0
  143. package/fixtures/cases/undeclared-field/expected.json +6 -0
  144. package/fixtures/cases/undeclared-field/library/item.md +9 -0
  145. package/fixtures/cases/undeclared-field/schema.yaml +6 -0
  146. package/fixtures/cases/unknown-type/context.json +1 -0
  147. package/fixtures/cases/unknown-type/expected.json +6 -0
  148. package/fixtures/cases/unknown-type/library/item.md +3 -0
  149. package/fixtures/cases/unknown-type/schema.yaml +4 -0
  150. package/fixtures/cases/unlisted-reference-type/context.json +1 -0
  151. package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
  152. package/fixtures/cases/unlisted-reference-type/schema.yaml +4 -0
  153. package/fixtures/cases/unresolved-link/expected.json +1 -2
  154. package/fixtures/cases/unresolved-link/schema.yaml +6 -0
  155. package/fixtures/cases/valid-typed-document/library/tasks/one.md +1 -0
  156. package/fixtures/cases/valid-typed-document/schema.yaml +15 -0
  157. package/fixtures/cases/wide-item-fence-link/schema.yaml +2 -0
  158. package/fixtures/division.json +409 -0
  159. package/fixtures/projection.json +77 -28
  160. package/package.json +3 -12
  161. package/dist/definition.js.map +0 -1
  162. package/dist/document.js.map +0 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist/links.js.map +0 -1
  165. package/dist/paths.js.map +0 -1
  166. package/dist/profile.js.map +0 -1
  167. package/dist/project.js.map +0 -1
  168. package/dist/refuse.js.map +0 -1
  169. package/dist/schema.js.map +0 -1
  170. package/dist/sections.js.map +0 -1
  171. package/dist/types.js.map +0 -1
  172. package/dist/validate.js.map +0 -1
  173. package/dist/version.js.map +0 -1
  174. package/dist/yaml.js.map +0 -1
  175. package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
  176. package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
  177. package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
  178. package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
  179. package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
  180. package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
  181. package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
  182. package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
  183. package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
  184. package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
  185. package/fixtures/cases/field-enum/library/types/task.md +0 -8
  186. package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
  187. package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
  188. package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
  189. package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
  190. package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
  191. package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
  192. package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
  193. package/fixtures/cases/prd-definition/library/types/task.md +0 -15
  194. package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
  195. package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
  196. package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
  197. package/fixtures/cases/structured-section/library/types/task.md +0 -8
  198. package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
  199. package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
  200. package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
  201. package/fixtures/cases/valid-typed-document/library/types/task.md +0 -12
  202. package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
  203. package/markdown-syntax-profile.md +0 -9
  204. /package/fixtures/cases/{prd-definition → frontmatter-schema}/context.json +0 -0
  205. /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 title: { kind: string, required: true }\n status: { kind: enum, values: [open, done], required: true }\n owner: { kind: reference, to: person }\nsections:\n Description: { kind: text, required: true }\n Acceptance: { kind: list }\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",
@@ -59,9 +56,21 @@
59
56
  }
60
57
  },
61
58
  {
62
- "name": "typed Document takes its declared free-text sections alone",
59
+ "name": "a typed Document projects its free-text field values as bare values and no other kind",
60
+ "file": "tasks/four.md",
61
+ "source": "---\ntype: task\nname: Ship the release\naliases: [\"Launch day\", Cutover]\ntitle: Ship it\nstatus: open\nowner: ../people/ana.md\ndue: 2026-09-30\nestimate: 3\nlabels: [core, urgent]\n---\n",
62
+ "documentTargets": [],
63
+ "definition": "task",
64
+ "move": null,
65
+ "expected": {
66
+ "ok": true,
67
+ "text": "Ship the release\n\nLaunch day\n\nCutover\n\n"
68
+ }
69
+ },
70
+ {
71
+ "name": "a typed Document projects its preamble and every section its type does not declare as structure",
63
72
  "file": "tasks/one.md",
64
- "source": "---\ntype: task\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## Notes\n\nUndeclared prose about [the plan](../plans/q3.md).\n",
73
+ "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",
65
74
  "documentTargets": [
66
75
  "plans/q3.md",
67
76
  "plans/2026-q3.md"
@@ -71,13 +80,21 @@
71
80
  "href": "../plans/q3.md",
72
81
  "to": "../plans/2026-q3.md"
73
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
+ },
74
91
  "expected": {
75
92
  "ok": true,
76
- "text": "## Description\n\nFollow the plan and the plan again, then read it.\n\n\n"
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"
77
94
  }
78
95
  },
79
96
  {
80
- "name": "a link definition outside the projected sections still resolves its use",
97
+ "name": "a link definition in another section resolves its use and leaves the projection",
81
98
  "file": "tasks/two.md",
82
99
  "source": "---\ntype: task\ntitle: Ship it\nstatus: open\n---\n\n## Description\n\nFollow [the plan][plan].\n\n## Notes\n\n[plan]: ../plans/q3.md\n",
83
100
  "documentTargets": [
@@ -91,7 +108,7 @@
91
108
  },
92
109
  "expected": {
93
110
  "ok": true,
94
- "text": "## Description\n\nFollow the plan.\n\n"
111
+ "text": "\n## Description\n\nFollow the plan.\n\n## Notes\n\n"
95
112
  }
96
113
  },
97
114
  {
@@ -109,13 +126,13 @@
109
126
  },
110
127
  "expected": {
111
128
  "ok": true,
112
- "text": "## Description\n\nFirst plan.\n\n## Description\n\nSecond note.\n"
129
+ "text": "\n## Description\n\nFirst plan.\n\n## Description\n\nSecond note.\n"
113
130
  }
114
131
  },
115
132
  {
116
133
  "name": "a declared type the caller does not supply is refused",
117
134
  "file": "tasks/one.md",
118
- "source": "---\ntype: task\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## Notes\n\nUndeclared prose about [the plan](../plans/q3.md).\n",
135
+ "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",
119
136
  "documentTargets": [
120
137
  "plans/q3.md",
121
138
  "plans/2026-q3.md"
@@ -127,35 +144,32 @@
127
144
  "refusal": {
128
145
  "file": "tasks/one.md",
129
146
  "rule": "unknown-type",
130
- "version": "<package-version>",
131
147
  "location": "type"
132
148
  }
133
149
  }
134
150
  },
135
151
  {
136
- "name": "a definition the model cannot read is refused at that definition",
137
- "file": "tasks/one.md",
138
- "source": "---\ntype: task\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## 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",
139
155
  "documentTargets": [
140
156
  "plans/q3.md",
141
157
  "plans/2026-q3.md"
142
158
  ],
143
- "definition": "unreadable-task",
144
- "move": null,
159
+ "definition": null,
160
+ "move": {
161
+ "href": "../plans/q3.md",
162
+ "to": "../plans/2026-q3.md"
163
+ },
145
164
  "expected": {
146
- "ok": false,
147
- "refusal": {
148
- "file": "types/task.md",
149
- "rule": "definition-section-kind",
150
- "version": "<package-version>",
151
- "location": "Description"
152
- }
165
+ "ok": true,
166
+ "text": "Read the plan and the chart.\nAlso the plan and the chart.\n\n"
153
167
  }
154
168
  },
155
169
  {
156
- "name": "an image at a supplied Markdown document target is projected like its link",
157
- "file": "notes/four.md",
158
- "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",
159
173
  "documentTargets": [
160
174
  "plans/q3.md",
161
175
  "plans/2026-q3.md"
@@ -165,9 +179,44 @@
165
179
  "href": "../plans/q3.md",
166
180
  "to": "../plans/2026-q3.md"
167
181
  },
182
+ "links": [
183
+ {
184
+ "href": "../plans/q3.md",
185
+ "target": "plans/q3.md"
186
+ }
187
+ ],
168
188
  "expected": {
169
189
  "ok": true,
170
- "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"
171
220
  }
172
221
  }
173
222
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdmodel",
3
- "version": "0.1.0-alpha.8",
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 ScalarSpec =\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 FieldSpec =\n | ScalarSpec\n | { readonly kind: 'list'; readonly required: boolean; readonly of: ScalarSpec };\n\nexport type SectionSpec = { readonly kind: 'text' | 'list'; readonly required: boolean };\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(['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 === '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 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') {\n if (typeof value.of !== 'string' || !SCALAR_KINDS.has(value.of)) {\n return refuse(file, 'definition-list-of', location);\n }\n const allowed =\n value.of === 'enum'\n ? ['kind', 'required', 'of', 'values']\n : value.of === 'reference'\n ? ['kind', 'required', 'of', 'to']\n : ['kind', 'required', 'of'];\n if (extraKeys(value, allowed)) return refuse(file, 'definition-field', location);\n const inner = parseScalar(file, location, { ...value, kind: value.of }, false);\n if ('rule' in inner) return inner;\n return { kind: 'list', required, of: inner };\n }\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 || extraKeys(value, ['kind', 'required'])) {\n return refuse(file, 'definition-section', location);\n }\n return { kind: value.kind, 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> = {};\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> = {};\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","parseField","of","has","inner","parseSection","readDefinition","document","type","name","fields","fieldsValue","sectionsValue","sections","fieldName","entries","parsed","sectionName"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAC9C,SAASC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