@agentshouse/mdmodel 0.1.0-alpha.16 → 0.1.0-alpha.17
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.
- package/API.md +44 -33
- package/README.md +2 -4
- package/dist/definition.d.ts +7 -3
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +83 -38
- package/dist/definition.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +0 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -7
- package/dist/paths.js.map +1 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +3 -15
- package/dist/project.js.map +1 -1
- package/dist/types.d.ts +6 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate.d.ts +2 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +42 -86
- package/dist/validate.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/yaml.js +1 -1
- package/dist/yaml.js.map +1 -1
- package/fixtures/README.md +45 -44
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-document-collision/schema.yaml +2 -0
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +2 -0
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
- package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +2 -0
- package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
- package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
- package/fixtures/cases/field-enum/schema.yaml +7 -0
- package/fixtures/cases/frontmatter-schema/expected.json +6 -0
- package/fixtures/cases/frontmatter-schema/schema.yaml +6 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +2 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +2 -0
- package/fixtures/cases/malformed-definition/expected.json +1 -2
- package/fixtures/cases/malformed-definition/schema.yaml +4 -0
- package/fixtures/cases/member-document/context.json +1 -0
- package/fixtures/cases/member-document/library/people/ana.md +5 -0
- package/fixtures/cases/member-document/schema.yaml +5 -0
- package/fixtures/cases/missing-binary-image/schema.yaml +2 -0
- package/fixtures/cases/missing-binary-link/schema.yaml +2 -0
- package/fixtures/cases/missing-required-field/schema.yaml +7 -0
- package/fixtures/cases/missing-section-item-kind/expected.json +1 -2
- package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +2 -0
- package/fixtures/cases/prototype-field/schema.yaml +6 -0
- package/fixtures/cases/quoted-link-definition/schema.yaml +2 -0
- package/fixtures/cases/referenced-missing-file/schema.yaml +10 -0
- package/fixtures/cases/second-member-document/context.json +1 -0
- package/fixtures/cases/second-member-document/expected.json +6 -0
- package/fixtures/cases/second-member-document/schema.yaml +5 -0
- package/fixtures/cases/structured-section/schema.yaml +7 -0
- package/fixtures/cases/submission-keys/schema.yaml +4 -0
- package/fixtures/cases/truncated-link-definition/schema.yaml +2 -0
- package/fixtures/cases/types-folder-content/schema.yaml +4 -0
- package/fixtures/cases/undeclared-field/schema.yaml +6 -0
- package/fixtures/cases/unknown-type/expected.json +7 -0
- package/fixtures/cases/unknown-type/schema.yaml +4 -0
- package/fixtures/cases/unlisted-reference-type/context.json +1 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +6 -0
- package/fixtures/cases/unlisted-reference-type/schema.yaml +4 -0
- package/fixtures/cases/unresolved-link/schema.yaml +6 -0
- package/fixtures/cases/valid-typed-document/schema.yaml +15 -0
- package/fixtures/cases/wide-item-fence-link/schema.yaml +2 -0
- package/fixtures/division.json +1 -21
- package/fixtures/projection.json +1 -24
- package/package.json +1 -1
- package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
- package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
- package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
- package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
- package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/external-invalid-model/definitions/schema/task.md +0 -5
- package/fixtures/cases/external-invalid-model/expected.json +0 -1
- package/fixtures/cases/external-invalid-model/library/note.md +0 -1
- package/fixtures/cases/external-unknown-type/definitions/schema/task.md +0 -5
- package/fixtures/cases/external-unknown-type/expected.json +0 -1
- package/fixtures/cases/external-valid/context.json +0 -1
- package/fixtures/cases/external-valid/definitions/types/task.md +0 -5
- package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/field-enum/library/types/task.md +0 -8
- package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
- package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
- package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
- package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
- package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
- package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/prd-definition/library/types/task.md +0 -16
- package/fixtures/cases/prototype-field/library/types/task.md +0 -7
- package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
- package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
- package/fixtures/cases/structured-section/library/types/task.md +0 -8
- package/fixtures/cases/submission-keys/library/types/note.md +0 -5
- package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
- package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
- package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
- package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
- package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
- /package/fixtures/cases/{prd-definition → frontmatter-schema}/context.json +0 -0
- /package/fixtures/cases/{prd-definition → member-document}/expected.json +0 -0
- /package/fixtures/cases/{external-invalid-model → types-folder-content}/context.json +0 -0
- /package/fixtures/cases/{external-valid → types-folder-content}/expected.json +0 -0
- /package/fixtures/cases/{external-valid → types-folder-content}/library/types/task.md +0 -0
- /package/fixtures/cases/{external-unknown-type → unknown-type}/context.json +0 -0
- /package/fixtures/cases/{external-unknown-type → unknown-type}/library/item.md +0 -0
package/fixtures/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Each directory under `cases/` is one text Library, one validation context,
|
|
4
4
|
and one expected verdict. Consumers load the files under `library/` as
|
|
5
|
-
path-to-content
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
path-to-content, an absent `library/` being the empty Library, and the
|
|
6
|
+
required `context.json` as `ValidationContext`. Cases with a `schema.yaml` call
|
|
7
|
+
`verify` with its text, then compare its refusal or
|
|
8
8
|
`validate(library, context, verified.model)` against `expected.json`. Other
|
|
9
9
|
cases compare `validate(library, context)` directly. Text-only cases carry
|
|
10
10
|
`{ "binaryTargets": [] }`. Binary targets are membership declarations; the
|
|
@@ -23,15 +23,15 @@ fenced headings, newline/source preservation, and a moved-export link rewrite.
|
|
|
23
23
|
## Projection
|
|
24
24
|
|
|
25
25
|
`projection.json` exercises the public `project` seam separately from the
|
|
26
|
-
validation Libraries. It carries `
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
validation Libraries. It carries `schema`, one schema text, and `cases`. Each
|
|
27
|
+
case carries `name`, the `file` the Document sits at, exact `source`, the
|
|
28
|
+
`documentTargets` the collection holds as Markdown documents, the `definition`
|
|
29
|
+
type name or `null`, an optional `move`, and `expected`.
|
|
30
30
|
A case carrying a `move` lists both the Path its target sits at and the Path the
|
|
31
31
|
move takes it to, because the collection holds that target either way.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
`
|
|
33
|
+
Verify the schema, parse the source, call `project(document, file, context)`
|
|
34
|
+
with `documentTargets` and the verified type `definition` names, and compare against `expected`, replacing the
|
|
35
35
|
`<package-version>` token in a refusal the same way `cases/` does. Then check
|
|
36
36
|
that the source is unchanged. Where `move` is present, apply
|
|
37
37
|
`{ kind: 'link', href, to }`, confirm the serialized Document changed, and
|
|
@@ -41,7 +41,7 @@ moved Path rewrites destinations and leaves the projection alone.
|
|
|
41
41
|
## Division
|
|
42
42
|
|
|
43
43
|
`division.json` exercises the public `divide` seam separately from the
|
|
44
|
-
validation Libraries. It carries `
|
|
44
|
+
validation Libraries. It carries `schema` and `cases` like `projection.json`,
|
|
45
45
|
and each case adds the `budget` the division runs under. Parse the source, call
|
|
46
46
|
`divide(document, file, context)` with `{ documentTargets, definition, budget }`,
|
|
47
47
|
and compare against `expected`: either `{ "ok": true, "spans": [...] }`, where
|
|
@@ -79,50 +79,51 @@ Refusal:
|
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
`location` is omitted when the rule is not about a field or section.
|
|
82
|
-
`referrers` is present only for `referenced-missing-file`.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
`referrers` is present only for `referenced-missing-file`. A schema refusal
|
|
83
|
+
carries no `file`; its `location`, when present, is the dotted path of the
|
|
84
|
+
schema part it concerns, such as `types.task.fields.title`, or `line <n>` for
|
|
85
|
+
`schema-yaml`.
|
|
86
86
|
The `version` field in these fixtures is the token `<package-version>`;
|
|
87
87
|
replace it with the package's semantic version before comparing.
|
|
88
88
|
|
|
89
89
|
## Rule ids
|
|
90
90
|
|
|
91
|
-
| Rule | When
|
|
92
|
-
| ------------------------- |
|
|
93
|
-
| `binary-target-document` | A path is declared as both a text Document and a binary target
|
|
94
|
-
| `frontmatter-fence` | A present frontmatter fence does not parse as the accepted YAML subset
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `definition-
|
|
99
|
-
| `definition-
|
|
100
|
-
| `definition-
|
|
101
|
-
| `definition-
|
|
102
|
-
| `definition-
|
|
103
|
-
| `definition-
|
|
104
|
-
| `definition-
|
|
105
|
-
| `definition-
|
|
106
|
-
| `definition-
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `required-
|
|
110
|
-
| `
|
|
111
|
-
| `field-
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `unresolved-
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
91
|
+
| Rule | When |
|
|
92
|
+
| ------------------------- | -------------------------------------------------------------------------------- |
|
|
93
|
+
| `binary-target-document` | A path is declared as both a text Document and a binary target |
|
|
94
|
+
| `frontmatter-fence` | A present frontmatter fence does not parse as the accepted YAML subset |
|
|
95
|
+
| `schema-yaml` | A schema text is not a mapping in the accepted YAML subset |
|
|
96
|
+
| `schema-shape` | A schema is not a mapping of exactly `types` to a mapping of non-empty names |
|
|
97
|
+
| `schema-member-document` | A second type is marked `member_document: true` |
|
|
98
|
+
| `definition-shape` | A type is not a mapping of `fields`, `sections`, and a boolean `member_document` |
|
|
99
|
+
| `definition-fields` | `fields` is not a mapping |
|
|
100
|
+
| `definition-field` | A field spec is not an object of the accepted keys |
|
|
101
|
+
| `definition-field-kind` | A field kind is not text, string, number, date, enum, reference, or list |
|
|
102
|
+
| `definition-enum-values` | An enum field has no non-empty string `values` |
|
|
103
|
+
| `definition-reference-to` | A reference has no `to` naming `any` or a type of the same schema |
|
|
104
|
+
| `definition-list-of` | A list field or list section has no `of` that is one scalar kind |
|
|
105
|
+
| `definition-sections` | `sections` is not a mapping |
|
|
106
|
+
| `definition-section` | A section spec is not an object of the accepted keys |
|
|
107
|
+
| `definition-section-kind` | A section kind is not `text` or `list` |
|
|
108
|
+
| `unknown-type` | A file declares a type absent from the governing schema |
|
|
109
|
+
| `required-field` | A required field is missing |
|
|
110
|
+
| `required-section` | A required section heading is missing |
|
|
111
|
+
| `field-kind` | A field value fails its kind, including date |
|
|
112
|
+
| `field-enum` | A field value is not one of the declared enum values |
|
|
113
|
+
| `undeclared-field` | A typed file carries a frontmatter field its type does not declare |
|
|
114
|
+
| `unresolved-reference` | A reference does not resolve to a current file of the required type |
|
|
115
|
+
| `unresolved-link` | A relative body link does not resolve to a current path |
|
|
116
|
+
| `structured-section` | A declared structured-list section does not parse as a list |
|
|
117
|
+
| `referenced-missing-file` | Remaining files still reference an absent path |
|
|
118
|
+
| `unwritable-link` | No Markdown destination form can carry a new link destination |
|
|
119
|
+
| `division-budget` | A division budget is not a whole number of at least 2 |
|
|
119
120
|
|
|
120
121
|
`unwritable-link` is refused by `apply` and `division-budget` by `divide`, not
|
|
121
122
|
by `validate`, so no case under `cases/` carries either.
|
|
122
123
|
|
|
123
124
|
## YAML subset
|
|
124
125
|
|
|
125
|
-
Frontmatter
|
|
126
|
+
Frontmatter and a schema text are each a mapping in a closed YAML subset: block and flow mappings,
|
|
126
127
|
block and flow sequences, plain and quoted scalars, `true`, `false`, `null`,
|
|
127
128
|
and decimal numbers. It does not take YAML 1.1 boolean or timestamp aliases,
|
|
128
|
-
octal numbers, anchors, tags, or block scalars.
|
|
129
|
+
octal numbers, anchors, tags, or block scalars. A mapping carries each key once.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "binaryTargets": [] }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
types:
|
|
2
|
+
person:
|
|
3
|
+
fields:
|
|
4
|
+
name: { kind: string, required: true }
|
|
5
|
+
task:
|
|
6
|
+
fields:
|
|
7
|
+
name: { kind: text }
|
|
8
|
+
title: { kind: string, required: true }
|
|
9
|
+
status: { kind: enum, values: [open, in-progress, done], required: true }
|
|
10
|
+
due: { kind: date }
|
|
11
|
+
owner: { kind: reference, to: person }
|
|
12
|
+
labels: { kind: list, of: string }
|
|
13
|
+
sections:
|
|
14
|
+
Description: { kind: text, required: true }
|
|
15
|
+
Acceptance: { kind: list, of: string }
|
package/fixtures/division.json
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"task": "---\ntype: definition\nfields:\n name: { kind: text }\n status: { kind: enum, values: [open, done], required: true }\nsections:\n Description: { kind: text, required: true }\n Acceptance: { kind: list, of: reference, to: person }\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 }\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",
|
|
6
3
|
"cases": [
|
|
7
4
|
{
|
|
8
5
|
"name": "a Document whose whole input fits the budget is one Span carrying its projection",
|
|
@@ -302,23 +299,6 @@
|
|
|
302
299
|
}
|
|
303
300
|
}
|
|
304
301
|
},
|
|
305
|
-
{
|
|
306
|
-
"name": "a definition the model cannot read is refused at that definition",
|
|
307
|
-
"file": "tasks/one.md",
|
|
308
|
-
"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",
|
|
309
|
-
"documentTargets": [],
|
|
310
|
-
"definition": "unreadable-task",
|
|
311
|
-
"budget": 4096,
|
|
312
|
-
"expected": {
|
|
313
|
-
"ok": false,
|
|
314
|
-
"refusal": {
|
|
315
|
-
"file": "types/task.md",
|
|
316
|
-
"rule": "definition-section-kind",
|
|
317
|
-
"version": "<package-version>",
|
|
318
|
-
"location": "Description"
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
302
|
{
|
|
323
303
|
"name": "a budget that cannot hold one whole character is refused before any division",
|
|
324
304
|
"file": "notes/one.md",
|
package/fixtures/projection.json
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
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",
|
|
@@ -144,26 +141,6 @@
|
|
|
144
141
|
}
|
|
145
142
|
}
|
|
146
143
|
},
|
|
147
|
-
{
|
|
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",
|
|
151
|
-
"documentTargets": [
|
|
152
|
-
"plans/q3.md",
|
|
153
|
-
"plans/2026-q3.md"
|
|
154
|
-
],
|
|
155
|
-
"definition": "unreadable-task",
|
|
156
|
-
"move": null,
|
|
157
|
-
"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
|
-
}
|
|
166
|
-
},
|
|
167
144
|
{
|
|
168
145
|
"name": "an image at a supplied Markdown document target is projected like its link",
|
|
169
146
|
"file": "notes/four.md",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdmodel",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.17",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"verdict":"refuse","source":"model","file":"schema/task.md","location":"title","rule":"definition-field-kind","version":"<package-version>"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Loose
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"verdict":"refuse","source":"content","file":"item.md","location":"type","rule":"unknown-type","version":"<package-version>"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"binaryTargets":[]}
|