@leo-studio/leo-markup 0.0.0-stage → 0.1.1

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 (57) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +18 -2
  3. package/dist/agent-support.d.ts +10 -0
  4. package/dist/agent-support.d.ts.map +1 -0
  5. package/dist/agent-support.js +27 -0
  6. package/dist/agent-support.js.map +1 -0
  7. package/dist/ast-json.d.ts +104 -0
  8. package/dist/ast-json.d.ts.map +1 -0
  9. package/dist/ast-json.js +203 -0
  10. package/dist/ast-json.js.map +1 -0
  11. package/dist/authoring-lints.d.ts +79 -0
  12. package/dist/authoring-lints.d.ts.map +1 -0
  13. package/dist/authoring-lints.js +145 -0
  14. package/dist/authoring-lints.js.map +1 -0
  15. package/dist/block-inline.d.ts +74 -0
  16. package/dist/block-inline.d.ts.map +1 -0
  17. package/dist/block-inline.js +171 -0
  18. package/dist/block-inline.js.map +1 -0
  19. package/dist/fence.d.ts +14 -0
  20. package/dist/fence.d.ts.map +1 -0
  21. package/dist/fence.js +55 -0
  22. package/dist/fence.js.map +1 -0
  23. package/dist/index.d.ts +20 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +20 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/parity.d.ts +44 -0
  28. package/dist/parity.d.ts.map +1 -0
  29. package/dist/parity.js +80 -0
  30. package/dist/parity.js.map +1 -0
  31. package/dist/product-spec.d.ts +164 -0
  32. package/dist/product-spec.d.ts.map +1 -0
  33. package/dist/product-spec.js +240 -0
  34. package/dist/product-spec.js.map +1 -0
  35. package/dist/registry.d.ts +53 -0
  36. package/dist/registry.d.ts.map +1 -0
  37. package/dist/registry.js +483 -0
  38. package/dist/registry.js.map +1 -0
  39. package/dist/scanner.d.ts +40 -0
  40. package/dist/scanner.d.ts.map +1 -0
  41. package/dist/scanner.js +291 -0
  42. package/dist/scanner.js.map +1 -0
  43. package/dist/schema/leo-markup-ast.schema.json +217 -0
  44. package/dist/schema/vocabulary.json +382 -0
  45. package/dist/tree-text.d.ts +16 -0
  46. package/dist/tree-text.d.ts.map +1 -0
  47. package/dist/tree-text.js +320 -0
  48. package/dist/tree-text.js.map +1 -0
  49. package/dist/types.d.ts +211 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/types.js +34 -0
  52. package/dist/types.js.map +1 -0
  53. package/dist/vocabulary.d.ts +293 -0
  54. package/dist/vocabulary.d.ts.map +1 -0
  55. package/dist/vocabulary.js +226 -0
  56. package/dist/vocabulary.js.map +1 -0
  57. package/package.json +43 -3
@@ -0,0 +1,293 @@
1
+ /**
2
+ * The closed `leo.ref` vocabulary: relations, target families and the
3
+ * relation/target matrix of product-spec schema v1 (leo-mono
4
+ * docs/product/product-spec-syntax/01-suite-schema-and-components.md,
5
+ * "Reference addressing"), plus the repository-qualified code target
6
+ * `repo/<repo-id>/<repo-path>`. schema/vocabulary.json at the repository root is
7
+ * generated from `buildVocabulary()` (`pnpm vocabulary:generate`).
8
+ */
9
+ /** The relations a `leo.ref` may name. */
10
+ export declare const REF_RELATIONS: readonly ['decision', 'derived-from', 'supersedes', 'superseded-by', 'adr', 'implements', 'depends-on', 'amends', 'exists', 'todo'];
11
+ export type RefRelation = (typeof REF_RELATIONS)[number];
12
+ /** Relations a `[relation: target]` bracket in a `leo.tree` / `leo.journey` fence becomes a ref for. */
13
+ export declare const ANNOTATION_RELATIONS: readonly ['exists', 'todo', 'deferred', 'depends-on', 'supersedes', 'superseded-by'];
14
+ /** Families a suite exports under `<slug>/<family>/…`, with the number of id segments each takes. */
15
+ export declare const SUITE_EXPORT_FAMILIES: {
16
+ readonly decision: 1;
17
+ readonly journey: 1;
18
+ readonly step: 2;
19
+ readonly tree: 1;
20
+ readonly node: 2;
21
+ readonly failure: 1;
22
+ readonly fork: 1;
23
+ };
24
+ export type SuiteExportFamily = keyof typeof SUITE_EXPORT_FAMILIES;
25
+ /** Reserved first segments. A suite slug equal to one of these is invalid. */
26
+ export declare const TARGET_FAMILIES: {
27
+ readonly decision: {
28
+ readonly form: 'decision/<id>';
29
+ readonly meaning: 'Decision in the current suite';
30
+ };
31
+ readonly journey: {
32
+ readonly form: '<slug>/journey/<id>';
33
+ readonly meaning: 'Journey exported by a suite';
34
+ };
35
+ readonly step: {
36
+ readonly form: '<slug>/step/<journey-id>/<step-id>';
37
+ readonly meaning: 'Step exported by a suite';
38
+ };
39
+ readonly tree: {
40
+ readonly form: '<slug>/tree/<id>';
41
+ readonly meaning: 'IA tree exported by a suite';
42
+ };
43
+ readonly node: {
44
+ readonly form: '<slug>/node/<tree-id>/<node-id>';
45
+ readonly meaning: 'Identified IA node exported by a suite';
46
+ };
47
+ readonly failure: {
48
+ readonly form: 'failure/<id>';
49
+ readonly meaning: 'Failure-mode row in the current suite';
50
+ };
51
+ readonly fork: {
52
+ readonly form: 'fork/<id>';
53
+ readonly meaning: 'Review-fork marker in the current suite';
54
+ };
55
+ readonly adr: {
56
+ readonly form: 'adr/<id>';
57
+ readonly meaning: 'ADR draft (D-<ulid>) or canonical ID';
58
+ };
59
+ readonly path: {
60
+ readonly form: 'path/<repo-path>[#L<a>[-L<b>]]';
61
+ readonly meaning: "File or directory in the document's own repository";
62
+ };
63
+ readonly repo: {
64
+ readonly form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]';
65
+ readonly meaning: 'File or directory in the named repository';
66
+ };
67
+ readonly artifact: {
68
+ readonly form: 'artifact/<key>';
69
+ readonly meaning: 'Logical implementation or evidence artifact';
70
+ };
71
+ readonly audit: {
72
+ readonly form: 'audit/question/<ulid>';
73
+ readonly meaning: 'Durable question identity in the audit ledger';
74
+ };
75
+ };
76
+ export type TargetFamily = keyof typeof TARGET_FAMILIES;
77
+ export interface LineRange {
78
+ readonly start: number;
79
+ readonly end?: number;
80
+ }
81
+ /** A parsed `leo.ref` target. Unknown and malformed targets are reported as values, never dropped. */
82
+ export type RefTarget =
83
+ /** A single segment: a local ID (`D12`) or a suite slug; resolution decides which. comment-lint-ignore: literal target example */
84
+ {
85
+ readonly kind: 'bare';
86
+ readonly id: string;
87
+ } | {
88
+ readonly kind: 'decision' | 'failure' | 'fork' | 'adr' | 'artifact';
89
+ readonly id: string;
90
+ } | {
91
+ readonly kind: 'audit-question';
92
+ readonly id: string;
93
+ } | {
94
+ readonly kind: 'path';
95
+ readonly path: string;
96
+ readonly lines?: LineRange;
97
+ } | {
98
+ readonly kind: 'repo';
99
+ readonly repo: string;
100
+ readonly path: string;
101
+ readonly lines?: LineRange;
102
+ } | {
103
+ readonly kind: 'suite-export';
104
+ readonly suite: string;
105
+ readonly family: SuiteExportFamily;
106
+ readonly ids: readonly string[];
107
+ }
108
+ /** A first segment that is neither a reserved family nor followed by a suite export family. */
109
+ | {
110
+ readonly kind: 'unknown';
111
+ readonly family: string;
112
+ readonly rest: string;
113
+ }
114
+ /** A reserved family whose remainder does not fit its form. */
115
+ | {
116
+ readonly kind: 'invalid';
117
+ readonly family: string;
118
+ readonly rest: string;
119
+ readonly reason: string;
120
+ };
121
+ export type RefTargetKind = RefTarget['kind'];
122
+ /** Target kinds each relation accepts (`bare` stands for `<slug>`). */
123
+ export declare const RELATION_TARGETS: Readonly<Record<RefRelation, readonly RefTargetKind[]>>;
124
+ /** One example per target form; both parsers must round-trip each. */
125
+ export declare const TARGET_EXAMPLES: Readonly<Record<RefTargetKind, readonly string[]>>;
126
+ /** Parse a `leo.ref` target into its family. Never throws. */
127
+ export declare function parseRefTarget(target: string): RefTarget;
128
+ /** The canonical string form of a parsed target; `formatRefTarget(parseRefTarget(t)) === t`. */
129
+ export declare function formatRefTarget(target: RefTarget): string;
130
+ /** The data written to schema/vocabulary.json. */
131
+ export declare function buildVocabulary(): {
132
+ version: number;
133
+ relations: {
134
+ name: "adr" | "amends" | "decision" | "depends-on" | "derived-from" | "exists" | "implements" | "superseded-by" | "supersedes" | "todo";
135
+ targets: readonly ("adr" | "artifact" | "audit-question" | "bare" | "decision" | "failure" | "fork" | "invalid" | "path" | "repo" | "suite-export" | "unknown")[];
136
+ }[];
137
+ annotationRelations: readonly ["exists", "todo", "deferred", "depends-on", "supersedes", "superseded-by"];
138
+ targetFamilies: ({
139
+ form: 'decision/<id>';
140
+ meaning: 'Decision in the current suite';
141
+ family: string;
142
+ } | {
143
+ form: '<slug>/journey/<id>';
144
+ meaning: 'Journey exported by a suite';
145
+ family: string;
146
+ } | {
147
+ form: '<slug>/step/<journey-id>/<step-id>';
148
+ meaning: 'Step exported by a suite';
149
+ family: string;
150
+ } | {
151
+ form: '<slug>/tree/<id>';
152
+ meaning: 'IA tree exported by a suite';
153
+ family: string;
154
+ } | {
155
+ form: '<slug>/node/<tree-id>/<node-id>';
156
+ meaning: 'Identified IA node exported by a suite';
157
+ family: string;
158
+ } | {
159
+ form: 'failure/<id>';
160
+ meaning: 'Failure-mode row in the current suite';
161
+ family: string;
162
+ } | {
163
+ form: 'fork/<id>';
164
+ meaning: 'Review-fork marker in the current suite';
165
+ family: string;
166
+ } | {
167
+ form: 'adr/<id>';
168
+ meaning: 'ADR draft (D-<ulid>) or canonical ID';
169
+ family: string;
170
+ } | {
171
+ form: 'path/<repo-path>[#L<a>[-L<b>]]';
172
+ meaning: "File or directory in the document's own repository";
173
+ family: string;
174
+ } | {
175
+ form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]';
176
+ meaning: 'File or directory in the named repository';
177
+ family: string;
178
+ } | {
179
+ form: 'artifact/<key>';
180
+ meaning: 'Logical implementation or evidence artifact';
181
+ family: string;
182
+ } | {
183
+ form: 'audit/question/<ulid>';
184
+ meaning: 'Durable question identity in the audit ledger';
185
+ family: string;
186
+ })[];
187
+ suiteExportFamilies: {
188
+ readonly decision: 1;
189
+ readonly journey: 1;
190
+ readonly step: 2;
191
+ readonly tree: 1;
192
+ readonly node: 2;
193
+ readonly failure: 1;
194
+ readonly fork: 1;
195
+ };
196
+ targetExamples: Readonly<Record<"adr" | "artifact" | "audit-question" | "bare" | "decision" | "failure" | "fork" | "invalid" | "path" | "repo" | "suite-export" | "unknown", readonly string[]>>;
197
+ productSpecComponents: {
198
+ [k: string]: {
199
+ props: {} | {
200
+ readonly path: {
201
+ readonly kind: 'string';
202
+ readonly required: true;
203
+ };
204
+ readonly title: {
205
+ readonly kind: 'string';
206
+ readonly required: true;
207
+ };
208
+ readonly role: {
209
+ readonly kind: 'enum';
210
+ readonly required: true;
211
+ readonly values: readonly ["index", "decisions", "detail", "glossary", "audit"];
212
+ };
213
+ } | {
214
+ readonly id: {
215
+ readonly kind: 'string';
216
+ readonly required: true;
217
+ };
218
+ readonly title: {
219
+ readonly kind: 'string';
220
+ readonly required: true;
221
+ };
222
+ } | {
223
+ readonly id: {
224
+ readonly kind: 'string';
225
+ readonly required: true;
226
+ };
227
+ } | {
228
+ readonly to: {
229
+ readonly kind: 'string';
230
+ readonly required: true;
231
+ };
232
+ readonly when: {
233
+ readonly kind: 'string';
234
+ readonly required: true;
235
+ };
236
+ } | {
237
+ readonly id: {
238
+ readonly kind: 'string';
239
+ readonly required: true;
240
+ };
241
+ readonly title: {
242
+ readonly kind: 'string';
243
+ };
244
+ } | {
245
+ readonly label: {
246
+ readonly kind: 'string';
247
+ readonly required: true;
248
+ };
249
+ readonly id: {
250
+ readonly kind: 'string';
251
+ };
252
+ } | {
253
+ readonly increment: {
254
+ readonly kind: 'string';
255
+ };
256
+ readonly deferred: {
257
+ readonly kind: 'boolean';
258
+ };
259
+ readonly unassigned: {
260
+ readonly kind: 'boolean';
261
+ };
262
+ } | {
263
+ readonly relation: {
264
+ readonly kind: 'string';
265
+ readonly required: true;
266
+ };
267
+ readonly target: {
268
+ readonly kind: 'string';
269
+ readonly required: true;
270
+ };
271
+ } | {} | {
272
+ readonly id: {
273
+ readonly kind: 'string';
274
+ readonly required: true;
275
+ };
276
+ readonly title: {
277
+ readonly kind: 'string';
278
+ readonly required: true;
279
+ };
280
+ readonly status: {
281
+ readonly kind: 'enum';
282
+ readonly required: true;
283
+ readonly values: readonly ["accepted", "superseded"];
284
+ };
285
+ readonly architectural: {
286
+ readonly kind: 'boolean';
287
+ };
288
+ } | {} | {};
289
+ children?: readonly ("decision" | "decisions" | "document" | "documents" | "journey" | "node" | "rationale" | "ref" | "scope" | "statement" | "step" | "transition" | "tree")[] | undefined;
290
+ };
291
+ };
292
+ };
293
+ //# sourceMappingURL=vocabulary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocabulary.d.ts","sourceRoot":"","sources":["../src/vocabulary.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,0CAA0C;AAC1C,eAAO,MAAM,aAAa,YACtB,UAAU,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,MAAM,CACA,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,YAC7B,QAAQ,EACR,MAAM,EACN,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,CACT,CAAC;AAEX,qGAAqG;AACrG,eAAO,MAAM,qBAAqB;aAC9B,QAAQ,EAAE,CAAC;aACX,OAAO,EAAE,CAAC;aACV,IAAI,EAAE,CAAC;aACP,IAAI,EAAE,CAAC;aACP,IAAI,EAAE,CAAC;aACP,OAAO,EAAE,CAAC;aACV,IAAI,EAAE,CAAC;CACD,CAAC;AACX,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,qBAAqB,CAAC;AAEnE,8EAA8E;AAC9E,eAAO,MAAM,eAAe;aACxB,QAAQ;iBAAI,IAAI,EAAE,eAAe;iBAAE,OAAO,EAAE,+BAA+B;;aAC3E,OAAO;iBAAI,IAAI,EAAE,qBAAqB;iBAAE,OAAO,EAAE,6BAA6B;;aAC9E,IAAI;iBAAI,IAAI,EAAE,oCAAoC;iBAAE,OAAO,EAAE,0BAA0B;;aACvF,I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AAS,CAiDxD;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAoBzD;AAED,kDAAkD;AAClD,wBAAgB,eAAe;IAEvB,OAAO;IACP,SAAS;;;;IACT,mBAAmB;IACnB,cAAc;cApNA,eAAe;iBAAW,+BAA+B;;;cAC1D,qBAAqB;iBAAW,6BAA6B;;;cAChE,oCAAoC;iBAAW,0BAA0B;;;cACzE,kBAAkB;iBAAW,6BAA6B;;;cAE9D,iCAAiC;iBAC9B,wCAAwC;;;cAEpC,cAAc;iBAAW,uCAAuC;;;cACnE,WAAW;iBAAW,yCAAyC;;;cAChE,UAAU;iBAAW,sCAAsC;;;cAE9D,gCAAgC;iBAC7B,oDAAoD;;;cAGvD,0CAA0C;iBACvC,2CAA2C;;;cAEtC,gBAAgB;iBAAW,6CAA6C;;;cAEhF,uBAAuB;iBACpB,+CAA+C;;;IAkMxD,mBAAmB;2BApOb,CAAC;0BACF,CAAC;uBACJ,CAAC;uBACD,CAAC;uBACD,CAAC;0BACE,CAAC;uBACJ,CAAC;;IA+NH,cAAc;IACd,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe5B"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * The closed `leo.ref` vocabulary: relations, target families and the
3
+ * relation/target matrix of product-spec schema v1 (leo-mono
4
+ * docs/product/product-spec-syntax/01-suite-schema-and-components.md,
5
+ * "Reference addressing"), plus the repository-qualified code target
6
+ * `repo/<repo-id>/<repo-path>`. schema/vocabulary.json at the repository root is
7
+ * generated from `buildVocabulary()` (`pnpm vocabulary:generate`).
8
+ */
9
+ import { productSpecChildren, productSpecSchemas } from './product-spec.js';
10
+ /** The relations a `leo.ref` may name. */
11
+ export const REF_RELATIONS = [
12
+ 'decision',
13
+ 'derived-from',
14
+ 'supersedes',
15
+ 'superseded-by',
16
+ 'adr',
17
+ 'implements',
18
+ 'depends-on',
19
+ 'amends',
20
+ 'exists',
21
+ 'todo',
22
+ ];
23
+ /** Relations a `[relation: target]` bracket in a `leo.tree` / `leo.journey` fence becomes a ref for. */
24
+ export const ANNOTATION_RELATIONS = [
25
+ 'exists',
26
+ 'todo',
27
+ 'deferred',
28
+ 'depends-on',
29
+ 'supersedes',
30
+ 'superseded-by',
31
+ ];
32
+ /** Families a suite exports under `<slug>/<family>/…`, with the number of id segments each takes. */
33
+ export const SUITE_EXPORT_FAMILIES = {
34
+ decision: 1,
35
+ journey: 1,
36
+ step: 2,
37
+ tree: 1,
38
+ node: 2,
39
+ failure: 1,
40
+ fork: 1,
41
+ };
42
+ /** Reserved first segments. A suite slug equal to one of these is invalid. */
43
+ export const TARGET_FAMILIES = {
44
+ decision: { form: 'decision/<id>', meaning: 'Decision in the current suite' },
45
+ journey: { form: '<slug>/journey/<id>', meaning: 'Journey exported by a suite' },
46
+ step: { form: '<slug>/step/<journey-id>/<step-id>', meaning: 'Step exported by a suite' },
47
+ tree: { form: '<slug>/tree/<id>', meaning: 'IA tree exported by a suite' },
48
+ node: {
49
+ form: '<slug>/node/<tree-id>/<node-id>',
50
+ meaning: 'Identified IA node exported by a suite',
51
+ },
52
+ failure: { form: 'failure/<id>', meaning: 'Failure-mode row in the current suite' },
53
+ fork: { form: 'fork/<id>', meaning: 'Review-fork marker in the current suite' },
54
+ adr: { form: 'adr/<id>', meaning: 'ADR draft (D-<ulid>) or canonical ID' },
55
+ path: {
56
+ form: 'path/<repo-path>[#L<a>[-L<b>]]',
57
+ meaning: "File or directory in the document's own repository",
58
+ },
59
+ repo: {
60
+ form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]',
61
+ meaning: 'File or directory in the named repository',
62
+ },
63
+ artifact: { form: 'artifact/<key>', meaning: 'Logical implementation or evidence artifact' },
64
+ audit: {
65
+ form: 'audit/question/<ulid>',
66
+ meaning: 'Durable question identity in the audit ledger',
67
+ },
68
+ };
69
+ /** Target kinds each relation accepts (`bare` stands for `<slug>`). */
70
+ export const RELATION_TARGETS = {
71
+ todo: ['artifact'],
72
+ exists: ['artifact', 'path', 'repo', 'bare', 'adr'],
73
+ decision: ['decision', 'suite-export'],
74
+ 'derived-from': ['audit-question'],
75
+ supersedes: ['decision'],
76
+ 'superseded-by': ['decision'],
77
+ adr: ['adr'],
78
+ implements: ['artifact', 'path', 'repo', 'bare', 'adr'],
79
+ 'depends-on': ['artifact', 'path', 'repo', 'bare', 'adr'],
80
+ amends: ['decision', 'bare', 'adr'],
81
+ };
82
+ /** One example per target form; both parsers must round-trip each. */
83
+ export const TARGET_EXAMPLES = {
84
+ bare: ['D12', 'leo-studio'],
85
+ decision: ['decision/D12'],
86
+ failure: ['failure/stale-cache'],
87
+ fork: ['fork/review-1'],
88
+ adr: ['adr/D-01KVQHTWH8MQ', 'adr/00042'],
89
+ artifact: ['artifact/spec-matrix'],
90
+ 'audit-question': ['audit/question/01KVQHTWH8MQ'],
91
+ path: ['path/packages/leo-markup', 'path/src/scanner.ts#L12', 'path/src/scanner.ts#L12-L40'],
92
+ repo: [
93
+ 'repo/leo-mono/packages/leo-doc-core/src/scanner.ts',
94
+ 'repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#L3-L9',
95
+ ],
96
+ 'suite-export': [
97
+ 'leo-studio/decision/D3',
98
+ 'leo-studio/journey/onboarding',
99
+ 'leo-studio/step/onboarding/step-2',
100
+ 'leo-studio/tree/ia',
101
+ 'leo-studio/node/ia/sidebar',
102
+ 'leo-studio/failure/stale-cache',
103
+ 'leo-studio/fork/review-1',
104
+ ],
105
+ unknown: ['ticket/LEO-12'],
106
+ invalid: ['path/', 'repo/leo-mono', 'path/a.ts#L9-L3', 'audit/D1', 'journey/onboarding'],
107
+ };
108
+ const LINES = /^L([1-9][0-9]*)(?:-L([1-9][0-9]*))?$/u;
109
+ function invalid(family, rest, reason) {
110
+ return { kind: 'invalid', family, rest, reason };
111
+ }
112
+ /** Split `<path>[#L<a>[-L<b>]]`, or return the reason it is malformed. */
113
+ function codeLocation(text) {
114
+ const hash = text.indexOf('#');
115
+ const path = hash === -1 ? text : text.slice(0, hash);
116
+ if (!path) {
117
+ return 'missing path';
118
+ }
119
+ if (hash === -1) {
120
+ return { path };
121
+ }
122
+ const match = LINES.exec(text.slice(hash + 1));
123
+ const start = Number(match?.[1]);
124
+ const end = match?.[2] === undefined ? undefined : Number(match[2]);
125
+ if (!match || (end !== undefined && end < start)) {
126
+ return 'line fragment must be #L<a> or #L<a>-L<b> with a <= b';
127
+ }
128
+ return { path, lines: end === undefined ? { start } : { start, end } };
129
+ }
130
+ /** Parse a `leo.ref` target into its family. Never throws. */
131
+ export function parseRefTarget(target) {
132
+ const slash = target.indexOf('/');
133
+ if (slash === -1) {
134
+ return target ? { kind: 'bare', id: target } : invalid('', '', 'empty target');
135
+ }
136
+ const family = target.slice(0, slash);
137
+ const rest = target.slice(slash + 1);
138
+ const segments = rest.split('/');
139
+ const single = segments.length === 1 && segments[0] !== '';
140
+ switch (family) {
141
+ case 'decision':
142
+ case 'failure':
143
+ case 'fork':
144
+ case 'adr':
145
+ case 'artifact':
146
+ return single ? { kind: family, id: rest } : invalid(family, rest, 'expected one id');
147
+ case 'audit':
148
+ return segments.length === 2 && segments[0] === 'question' && segments[1]
149
+ ? { kind: 'audit-question', id: segments[1] }
150
+ : invalid(family, rest, 'expected question/<ulid>');
151
+ case 'path': {
152
+ const location = codeLocation(rest);
153
+ return typeof location === 'string'
154
+ ? invalid(family, rest, location)
155
+ : { kind: 'path', ...location };
156
+ }
157
+ case 'repo': {
158
+ const split = rest.indexOf('/');
159
+ const location = split > 0 ? codeLocation(rest.slice(split + 1)) : 'expected <repo-id>/<repo-path>';
160
+ return typeof location === 'string'
161
+ ? invalid(family, rest, location)
162
+ : { kind: 'repo', repo: rest.slice(0, split), ...location };
163
+ }
164
+ case 'journey':
165
+ case 'step':
166
+ case 'tree':
167
+ case 'node':
168
+ return invalid(family, rest, 'only addressable as <slug>/' + family + '/…');
169
+ }
170
+ const exported = segments[0] ?? '';
171
+ if (family && Object.hasOwn(SUITE_EXPORT_FAMILIES, exported)) {
172
+ const ids = segments.slice(1);
173
+ const expected = SUITE_EXPORT_FAMILIES[exported];
174
+ return ids.length === expected && ids.every(Boolean)
175
+ ? { kind: 'suite-export', suite: family, family: exported, ids }
176
+ : invalid(family, rest, `expected ${expected} id segment(s) after ${exported}/`);
177
+ }
178
+ return { kind: 'unknown', family, rest };
179
+ }
180
+ /** The canonical string form of a parsed target; `formatRefTarget(parseRefTarget(t)) === t`. */
181
+ export function formatRefTarget(target) {
182
+ const lines = (range) => range ? `#L${range.start}${range.end === undefined ? '' : `-L${range.end}`}` : '';
183
+ switch (target.kind) {
184
+ case 'bare':
185
+ return target.id;
186
+ case 'audit-question':
187
+ return `audit/question/${target.id}`;
188
+ case 'path':
189
+ return `path/${target.path}${lines(target.lines)}`;
190
+ case 'repo':
191
+ return `repo/${target.repo}/${target.path}${lines(target.lines)}`;
192
+ case 'suite-export':
193
+ return [target.suite, target.family, ...target.ids].join('/');
194
+ case 'unknown':
195
+ case 'invalid':
196
+ return target.family ? `${target.family}/${target.rest}` : target.rest;
197
+ default:
198
+ return `${target.kind}/${target.id}`;
199
+ }
200
+ }
201
+ /** The data written to schema/vocabulary.json. */
202
+ export function buildVocabulary() {
203
+ return {
204
+ version: 1,
205
+ relations: REF_RELATIONS.map((name) => ({ name, targets: RELATION_TARGETS[name] })),
206
+ annotationRelations: ANNOTATION_RELATIONS,
207
+ targetFamilies: Object.entries(TARGET_FAMILIES).map(([family, entry]) => ({
208
+ family,
209
+ ...entry,
210
+ })),
211
+ suiteExportFamilies: SUITE_EXPORT_FAMILIES,
212
+ targetExamples: TARGET_EXAMPLES,
213
+ productSpecComponents: Object.fromEntries(Object.entries(productSpecSchemas).map(([name, props]) => [
214
+ name,
215
+ {
216
+ props,
217
+ ...(name in productSpecChildren
218
+ ? {
219
+ children: productSpecChildren[name],
220
+ }
221
+ : {}),
222
+ },
223
+ ])),
224
+ };
225
+ }
226
+ //# sourceMappingURL=vocabulary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocabulary.js","sourceRoot":"","sources":["../src/vocabulary.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,0CAA0C;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,eAAe;IACf,KAAK;IACL,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,MAAM;CACA,CAAC;AAGX,wGAAwG;AACxG,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,QAAQ;IACR,MAAM;IACN,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,eAAe;CACT,CAAC;AAEX,qGAAqG;AACrG,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,CAAC;CACD,CAAC;AAGX,8EAA8E;AAC9E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,+BAA+B,EAAE;IAC7E,OAAO,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAChF,IAAI,EAAE,EAAE,IAAI,EAAE,oCAAoC,EAAE,OAAO,EAAE,0BAA0B,EAAE;IACzF,IAAI,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAC1E,IAAI,EAAE;QACF,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,wCAAwC;KACpD;IACD,O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AAE,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnF,mBAAmB,EAAE,oBAAoB;QACzC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YACtE,MAAM;YACN,GAAG,KAAK;SACX,CAAC,CAAC;QACH,mBAAmB,EAAE,qBAAqB;QAC1C,cAAc,EAAE,eAAe;QAC/B,qBAAqB,EAAE,MAAM,CAAC,WAAW,CACrC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YACtD,IAAI;YACJ;gBACI,KAAK;gBACL,GAAG,CAAC,IAAI,IAAI,mBAAmB;oBAC3B,CAAC,CAAC;wBACI,QAAQ,EACJ,mBAAmB,CAAC,IAAwC,CAAC;qBACpE;oBACH,CAAC,CAAC,EAAE,CAAC;aACZ;SACJ,CAAC,CACL;KACJ,CAAC;AACN,CAAC","sourcesContent":["/**\n * The closed `leo.ref` vocabulary: relations, target families and the\n * relation/target matrix of product-spec schema v1 (leo-mono\n * docs/product/product-spec-syntax/01-suite-schema-and-components.md,\n * \"Reference addressing\"), plus the repository-qualified code target\n * `repo/<repo-id>/<repo-path>`. schema/vocabulary.json at the repository root is\n * generated from `buildVocabulary()` (`pnpm vocabulary:generate`).\n */\n\nimport { productSpecChildren, productSpecSchemas } from './product-spec.js';\n\n/** The relations a `leo.ref` may name. */\nexport const REF_RELATIONS = [\n 'decision',\n 'derived-from',\n 'supersedes',\n 'superseded-by',\n 'adr',\n 'implements',\n 'depends-on',\n 'amends',\n 'exists',\n 'todo',\n] as const;\nexport type RefRelation = (typeof REF_RELATIONS)[number];\n\n/** Relations a `[relation: target]` bracket in a `leo.tree` / `leo.journey` fence becomes a ref for. */\nexport const ANNOTATION_RELATIONS = [\n 'exists',\n 'todo',\n 'deferred',\n 'depends-on',\n 'supersedes',\n 'superseded-by',\n] as const;\n\n/** Families a suite exports under `<slug>/<family>/…`, with the number of id segments each takes. */\nexport const SUITE_EXPORT_FAMILIES = {\n decision: 1,\n journey: 1,\n step: 2,\n tree: 1,\n node: 2,\n failure: 1,\n fork: 1,\n} as const;\nexport type SuiteExportFamily = keyof typeof SUITE_EXPORT_FAMILIES;\n\n/** Reserved first segments. A suite slug equal to one of these is invalid. */\nexport const TARGET_FAMILIES = {\n decision: { form: 'decision/<id>', meaning: 'Decision in the current suite' },\n journey: { form: '<slug>/journey/<id>', meaning: 'Journey exported by a suite' },\n step: { form: '<slug>/step/<journey-id>/<step-id>', meaning: 'Step exported by a suite' },\n tree: { form: '<slug>/tree/<id>', meaning: 'IA tree exported by a suite' },\n node: {\n form: '<slug>/node/<tree-id>/<node-id>',\n meaning: 'Identified IA node exported by a suite',\n },\n failure: { form: 'failure/<id>', meaning: 'Failure-mode row in the current suite' },\n fork: { form: 'fork/<id>', meaning: 'Review-fork marker in the current suite' },\n adr: { form: 'adr/<id>', meaning: 'ADR draft (D-<ulid>) or canonical ID' },\n path: {\n form: 'path/<repo-path>[#L<a>[-L<b>]]',\n meaning: \"File or directory in the document's own repository\",\n },\n repo: {\n form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]',\n meaning: 'File or directory in the named repository',\n },\n artifact: { form: 'artifact/<key>', meaning: 'Logical implementation or evidence artifact' },\n audit: {\n form: 'audit/question/<ulid>',\n meaning: 'Durable question identity in the audit ledger',\n },\n} as const;\nexport type TargetFamily = keyof typeof TARGET_FAMILIES;\n\nexport interface LineRange {\n readonly start: number;\n readonly end?: number;\n}\n\n/** A parsed `leo.ref` target. Unknown and malformed targets are reported as values, never dropped. */\nexport type RefTarget =\n /** A single segment: a local ID (`D12`) or a suite slug; resolution decides which. comment-lint-ignore: literal target example */\n | { readonly kind: 'bare'; readonly id: string }\n | {\n readonly kind: 'decision' | 'failure' | 'fork' | 'adr' | 'artifact';\n readonly id: string;\n }\n | { readonly kind: 'audit-question'; readonly id: string }\n | { readonly kind: 'path'; readonly path: string; readonly lines?: LineRange }\n | {\n readonly kind: 'repo';\n readonly repo: string;\n readonly path: string;\n readonly lines?: LineRange;\n }\n | {\n readonly kind: 'suite-export';\n readonly suite: string;\n readonly family: SuiteExportFamily;\n readonly ids: readonly string[];\n }\n /** A first segment that is neither a reserved family nor followed by a suite export family. */\n | { readonly kind: 'unknown'; readonly family: string; readonly rest: string }\n /** A reserved family whose remainder does not fit its form. */\n | {\n readonly kind: 'invalid';\n readonly family: string;\n readonly rest: string;\n readonly reason: string;\n };\nexport type RefTargetKind = RefTarget['kind'];\n\n/** Target kinds each relation accepts (`bare` stands for `<slug>`). */\nexport const RELATION_TARGETS: Readonly<Record<RefRelation, readonly RefTargetKind[]>> = {\n todo: ['artifact'],\n exists: ['artifact', 'path', 'repo', 'bare', 'adr'],\n decision: ['decision', 'suite-export'],\n 'derived-from': ['audit-question'],\n supersedes: ['decision'],\n 'superseded-by': ['decision'],\n adr: ['adr'],\n implements: ['artifact', 'path', 'repo', 'bare', 'adr'],\n 'depends-on': ['artifact', 'path', 'repo', 'bare', 'adr'],\n amends: ['decision', 'bare', 'adr'],\n};\n\n/** One example per target form; both parsers must round-trip each. */\nexport const TARGET_EXAMPLES: Readonly<Record<RefTargetKind, readonly string[]>> = {\n bare: ['D12', 'leo-studio'],\n decision: ['decision/D12'],\n failure: ['failure/stale-cache'],\n fork: ['fork/review-1'],\n adr: ['adr/D-01KVQHTWH8MQ', 'adr/00042'],\n artifact: ['artifact/spec-matrix'],\n 'audit-question': ['audit/question/01KVQHTWH8MQ'],\n path: ['path/packages/leo-markup', 'path/src/scanner.ts#L12', 'path/src/scanner.ts#L12-L40'],\n repo: [\n 'repo/leo-mono/packages/leo-doc-core/src/scanner.ts',\n 'repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#L3-L9',\n ],\n 'suite-export': [\n 'leo-studio/decision/D3',\n 'leo-studio/journey/onboarding',\n 'leo-studio/step/onboarding/step-2',\n 'leo-studio/tree/ia',\n 'leo-studio/node/ia/sidebar',\n 'leo-studio/failure/stale-cache',\n 'leo-studio/fork/review-1',\n ],\n unknown: ['ticket/LEO-12'],\n invalid: ['path/', 'repo/leo-mono', 'path/a.ts#L9-L3', 'audit/D1', 'journey/onboarding'],\n};\n\nconst LINES = /^L([1-9][0-9]*)(?:-L([1-9][0-9]*))?$/u;\n\nfunction invalid(family: string, rest: string, reason: string): RefTarget {\n return { kind: 'invalid', family, rest, reason };\n}\n\n/** Split `<path>[#L<a>[-L<b>]]`, or return the reason it is malformed. */\nfunction codeLocation(text: string): { path: string; lines?: LineRange } | string {\n const hash = text.indexOf('#');\n const path = hash === -1 ? text : text.slice(0, hash);\n if (!path) {\n return 'missing path';\n }\n if (hash === -1) {\n return { path };\n }\n const match = LINES.exec(text.slice(hash + 1));\n const start = Number(match?.[1]);\n const end = match?.[2] === undefined ? undefined : Number(match[2]);\n if (!match || (end !== undefined && end < start)) {\n return 'line fragment must be #L<a> or #L<a>-L<b> with a <= b';\n }\n return { path, lines: end === undefined ? { start } : { start, end } };\n}\n\n/** Parse a `leo.ref` target into its family. Never throws. */\nexport function parseRefTarget(target: string): RefTarget {\n const slash = target.indexOf('/');\n if (slash === -1) {\n return target ? { kind: 'bare', id: target } : invalid('', '', 'empty target');\n }\n const family = target.slice(0, slash);\n const rest = target.slice(slash + 1);\n const segments = rest.split('/');\n const single = segments.length === 1 && segments[0] !== '';\n switch (family) {\n case 'decision':\n case 'failure':\n case 'fork':\n case 'adr':\n case 'artifact':\n return single ? { kind: family, id: rest } : invalid(family, rest, 'expected one id');\n case 'audit':\n return segments.length === 2 && segments[0] === 'question' && segments[1]\n ? { kind: 'audit-question', id: segments[1] }\n : invalid(family, rest, 'expected question/<ulid>');\n case 'path': {\n const location = codeLocation(rest);\n return typeof location === 'string'\n ? invalid(family, rest, location)\n : { kind: 'path', ...location };\n }\n case 'repo': {\n const split = rest.indexOf('/');\n const location =\n split > 0 ? codeLocation(rest.slice(split + 1)) : 'expected <repo-id>/<repo-path>';\n return typeof location === 'string'\n ? invalid(family, rest, location)\n : { kind: 'repo', repo: rest.slice(0, split), ...location };\n }\n case 'journey':\n case 'step':\n case 'tree':\n case 'node':\n return invalid(family, rest, 'only addressable as <slug>/' + family + '/…');\n }\n const exported = segments[0] ?? '';\n if (family && Object.hasOwn(SUITE_EXPORT_FAMILIES, exported)) {\n const ids = segments.slice(1);\n const expected = SUITE_EXPORT_FAMILIES[exported as SuiteExportFamily];\n return ids.length === expected && ids.every(Boolean)\n ? { kind: 'suite-export', suite: family, family: exported as SuiteExportFamily, ids }\n : invalid(family, rest, `expected ${expected} id segment(s) after ${exported}/`);\n }\n return { kind: 'unknown', family, rest };\n}\n\n/** The canonical string form of a parsed target; `formatRefTarget(parseRefTarget(t)) === t`. */\nexport function formatRefTarget(target: RefTarget): string {\n const lines = (range?: LineRange) =>\n range ? `#L${range.start}${range.end === undefined ? '' : `-L${range.end}`}` : '';\n switch (target.kind) {\n case 'bare':\n return target.id;\n case 'audit-question':\n return `audit/question/${target.id}`;\n case 'path':\n return `path/${target.path}${lines(target.lines)}`;\n case 'repo':\n return `repo/${target.repo}/${target.path}${lines(target.lines)}`;\n case 'suite-export':\n return [target.suite, target.family, ...target.ids].join('/');\n case 'unknown':\n case 'invalid':\n return target.family ? `${target.family}/${target.rest}` : target.rest;\n default:\n return `${target.kind}/${target.id}`;\n }\n}\n\n/** The data written to schema/vocabulary.json. */\nexport function buildVocabulary() {\n return {\n version: 1,\n relations: REF_RELATIONS.map((name) => ({ name, targets: RELATION_TARGETS[name] })),\n annotationRelations: ANNOTATION_RELATIONS,\n targetFamilies: Object.entries(TARGET_FAMILIES).map(([family, entry]) => ({\n family,\n ...entry,\n })),\n suiteExportFamilies: SUITE_EXPORT_FAMILIES,\n targetExamples: TARGET_EXAMPLES,\n productSpecComponents: Object.fromEntries(\n Object.entries(productSpecSchemas).map(([name, props]) => [\n name,\n {\n props,\n ...(name in productSpecChildren\n ? {\n children:\n productSpecChildren[name as keyof typeof productSpecChildren],\n }\n : {}),\n },\n ])\n ),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@leo-studio/leo-markup",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Pure-contract doc engine: shared leo.* vocabulary, island scanner, leo registry, prop schemas, PageContext type, and the parity test harness",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/leo-studio-ai/leo-markup.git",
9
+ "directory": "packages/leo-markup"
10
+ },
11
+ "homepage": "https://github.com/leo-studio-ai/leo-markup/tree/main/packages/leo-markup#readme",
12
+ "bugs": "https://github.com/leo-studio-ai/leo-markup/issues",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./schema/*.json": "./dist/schema/*.json"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "dependencies": {},
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "ajv": "^8.20.0",
32
+ "typescript": "7.0.2",
33
+ "vitest": "^4.1.11"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-schema.ts",
37
+ "lint": "biome check .",
38
+ "lint:fix": "biome check --write .",
39
+ "typecheck": "tsc --noEmit",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest",
42
+ "fixtures:generate": "pnpm run build && node scripts/generate-fixtures.ts",
43
+ "vocabulary:generate": "pnpm run build && node scripts/generate-vocabulary.ts",
44
+ "smoke:pack": "pnpm run build && node scripts/smoke-pack.ts"
45
+ }
6
46
  }