@leo-studio/leo-markup 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +20 -0
  2. package/dist/fence.d.ts +6 -1
  3. package/dist/fence.d.ts.map +1 -1
  4. package/dist/fence.js +27 -4
  5. package/dist/fence.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/infra/index.d.ts +2 -0
  11. package/dist/infra/index.d.ts.map +1 -0
  12. package/dist/infra/index.js +2 -0
  13. package/dist/infra/index.js.map +1 -0
  14. package/dist/infra/infra-diagram.d.ts +150 -0
  15. package/dist/infra/infra-diagram.d.ts.map +1 -0
  16. package/dist/infra/infra-diagram.js +1373 -0
  17. package/dist/infra/infra-diagram.js.map +1 -0
  18. package/dist/infra/raster.d.ts +13 -0
  19. package/dist/infra/raster.d.ts.map +1 -0
  20. package/dist/infra/raster.js +46 -0
  21. package/dist/infra/raster.js.map +1 -0
  22. package/dist/infra/standalone-style.d.ts +5 -0
  23. package/dist/infra/standalone-style.d.ts.map +1 -0
  24. package/dist/infra/standalone-style.js +101 -0
  25. package/dist/infra/standalone-style.js.map +1 -0
  26. package/dist/product-spec.d.ts.map +1 -1
  27. package/dist/product-spec.js +8 -0
  28. package/dist/product-spec.js.map +1 -1
  29. package/dist/references.d.ts +74 -0
  30. package/dist/references.d.ts.map +1 -0
  31. package/dist/references.js +132 -0
  32. package/dist/references.js.map +1 -0
  33. package/dist/registry.d.ts.map +1 -1
  34. package/dist/registry.js +28 -3
  35. package/dist/registry.js.map +1 -1
  36. package/dist/scanner.d.ts.map +1 -1
  37. package/dist/scanner.js +4 -3
  38. package/dist/scanner.js.map +1 -1
  39. package/dist/schema/vocabulary.json +16 -5
  40. package/dist/vocabulary.d.ts +18 -4
  41. package/dist/vocabulary.d.ts.map +1 -1
  42. package/dist/vocabulary.js +78 -14
  43. package/dist/vocabulary.js.map +1 -1
  44. package/package.json +30 -5
package/dist/scanner.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * separately). The dot is a literal character in the name, not a namespace
24
24
  * lookup.
25
25
  */
26
- import { countRun, findFenceEnd, readFence } from './fence.js';
26
+ import { countRun, findFenceEnd, quotedLine, readFence } from './fence.js';
27
27
  /** The opener prefix the scanner claims. */
28
28
  const LEO_PREFIX = '<leo.';
29
29
  /**
@@ -110,9 +110,10 @@ function skipLiteral(source, at) {
110
110
  return end === -1 ? source.length : end + 3;
111
111
  }
112
112
  if (at === 0 || source[at - 1] === '\n') {
113
- const fence = readFence(source, at);
113
+ const quote = quotedLine(source, at);
114
+ const fence = readFence(source, quote.start);
114
115
  if (fence) {
115
- const end = findFenceEnd(source, fence.contentStart, fence.marker, fence.length);
116
+ const end = findFenceEnd(source, fence.contentStart, fence.marker, fence.length, quote.depth);
116
117
  return end === -1 ? source.length : end;
117
118
  }
118
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG/D,4CAA4C;AAC5C,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B;;;;GAIG;AACH,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,MAAc;IAC/B,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;YACZ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IAAI,CAAyB,CAAC;IAC9B,0EAA0E;IAC1E,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACrB,wDAAwD;YACxD,EAAE,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACb,CAAC;QACD,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,mEAAmE;QACnE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACjC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,+EAA+E;AAE/E,iFAAiF;AACjF,SAAS,SAAS,CAAC,KAAgB,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACzE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO;IACX,CAAC;IACD,MAAM,KAAK,GAAc,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC7D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC","sourcesContent":["/**\n * The `<leo.*>` island scanner (ADR-D-01KVQHTWH8MQ).\n *\n * A single-pass, quote-aware, balanced-nesting scanner that finds `<leo.*>`\n * islands in a source string and returns the document as an ordered list of\n * spans — prose passes through VERBATIM; each island is extracted with its raw\n * attrs and balanced body; a `<leo.` opener that cannot be parsed DEGRADES to a\n * malformed span (preserved as text) rather than stalling or dropping the rest.\n *\n * It is the SOLE resolution path on both surfaces (terminal + web), so the two\n * cannot diverge. It claims ONLY `<leo.*>` (the namespace allow-list); every\n * other angle bracket — `<div>`, `<Callout>`, autolinks, code spans, `a < b` —\n * passes through untouched.\n *\n * Fixes the three silent-mangle cases the PoC proved in the old regex/nextLeoTag\n * parser:\n * 1. `value=\"a > b\"` — quote-aware attr scan; `>` inside quotes is not the end.\n * 2. callout-in-callout — depth-counted body scan over the SAME tag name.\n * 3. unterminated opener — degrades to a malformed span; surrounding prose kept.\n *\n * Tag names are LOWERCASE-ONLY. `<leo.Callout>` (PascalCase) is NOT a\n * leo island — the scanner does not claim it (a lint rejects the authoring form\n * separately). The dot is a literal character in the name, not a namespace\n * lookup.\n */\n\nimport { countRun, findFenceEnd, readFence } from './fence.js';\nimport type { DocSpan, IslandSpan, MalformedSpan, ProseSpan } from './types.js';\n\n/** The opener prefix the scanner claims. */\nconst LEO_PREFIX = '<leo.';\n\n/**\n * A lowercase tag name: starts with a-z, then a-z/0-9/hyphen. This is what makes\n * the scanner lowercase-only — an uppercase first char fails the match, so the\n * prefix is treated as ordinary prose and passes through.\n */\nconst NAME_RE = /^[a-z][a-z0-9-]*/;\n\n/**\n * Scan a source string into ordered spans. Prose between islands is preserved\n * verbatim; islands carry raw (pre-coercion) attrs + balanced body; an\n * unparseable `<leo.` opener becomes a malformed span.\n */\nexport function scan(source: string): DocSpan[] {\n const spans: DocSpan[] = [];\n let cursor = 0;\n\n while (cursor < source.length) {\n const lt = findNextLeoPrefix(source, cursor);\n if (lt === -1) {\n // No more openers — the rest is prose.\n pushProse(spans, source.slice(cursor), cursor, source.length);\n break;\n }\n\n const nameMatch = NAME_RE.exec(source.slice(lt + LEO_PREFIX.length));\n if (!nameMatch) {\n // `<leo.` not followed by a lowercase name (e.g. `<leo.` then EOF, a\n // space, or an uppercase char). Not a claimable island: emit the\n // `<leo.` literal as prose and continue scanning AFTER it, so a real\n // island later in the source is still found.\n pushProse(\n spans,\n source.slice(cursor, lt + LEO_PREFIX.length),\n cursor,\n lt + LEO_PREFIX.length\n );\n cursor = lt + LEO_PREFIX.length;\n continue;\n }\n\n // Flush the prose before this opener.\n pushProse(spans, source.slice(cursor, lt), cursor, lt);\n\n const name = nameMatch[0];\n const island = parseIsland(source, lt, name);\n if (island === null) {\n // Unterminated/unclosed opener — degrade. Preserve the `<leo.NAME`\n // opener text and resume scanning just past it so the rest of the\n // document (including any well-formed islands) is never dropped.\n const openerEnd = lt + LEO_PREFIX.length + name.length;\n const malformed: MalformedSpan = {\n kind: 'malformed',\n text: source.slice(lt, openerEnd),\n reason: 'unterminated',\n start: lt,\n end: openerEnd,\n };\n spans.push(malformed);\n cursor = openerEnd;\n continue;\n }\n\n spans.push(island);\n cursor = island.end;\n }\n\n return spans;\n}\n\n/**\n * Find the next claimable opener outside Markdown code spans and fenced code.\n * This is lexical shielding, not a second Markdown parser: it recognizes only\n * CommonMark's literal-code delimiters, whose contents must pass through byte\n * for byte on every surface.\n */\nfunction findNextLeoPrefix(source: string, from: number): number {\n let i = from;\n\n while (i < source.length) {\n const literalEnd = skipLiteral(source, i);\n if (literalEnd !== i) {\n i = literalEnd;\n continue;\n }\n\n if (source.startsWith(LEO_PREFIX, i)) {\n return i;\n }\n i++;\n }\n\n return -1;\n}\n\n/** Skip Markdown literals and comments before recognizing either tag boundary. */\nfunction skipLiteral(source: string, at: number): number {\n if (source.startsWith('<!--', at)) {\n const end = source.indexOf('-->', at + 4);\n return end === -1 ? source.length : end + 3;\n }\n if (at === 0 || source[at - 1] === '\\n') {\n const fence = readFence(source, at);\n if (fence) {\n const end = findFenceEnd(source, fence.contentStart, fence.marker, fence.length);\n return end === -1 ? source.length : end;\n }\n }\n if (source[at] === '`') {\n const length = countRun(source, at, '`');\n const close = findMatchingBacktickRun(source, at + length, length);\n return close === -1 ? at + length : close + length;\n }\n return at;\n}\n\n/** Find a closing backtick run of exactly `length`, per CommonMark code spans. */\nfunction findMatchingBacktickRun(source: string, from: number, length: number): number {\n let at = source.indexOf('`', from);\n while (at !== -1) {\n const candidateLength = countRun(source, at, '`');\n if (candidateLength === length) {\n return at;\n }\n at = source.indexOf('`', at + candidateLength);\n }\n return -1;\n}\n\n/**\n * Parse a single island starting at `start` (the `<` of `<leo.NAME`). Returns\n * the island span, or `null` if it cannot be parsed as a balanced island\n * (caller degrades). Quote-aware throughout.\n */\nfunction parseIsland(source: string, start: number, name: string): IslandSpan | null {\n const attrsStart = start + LEO_PREFIX.length + name.length;\n\n // Find the end of the opening tag, skipping over quoted attribute values so\n // a `>` inside `value=\"a > b\"` does not terminate the tag (PoC bug #1).\n const openEnd = findOpenTagEnd(source, attrsStart);\n if (openEnd === null) {\n return null; // `<leo.NAME` with no closing `>` — unterminated opener.\n }\n\n const attrsRaw = source.slice(attrsStart, openEnd.attrsEnd);\n const attrs = parseAttrs(attrsRaw);\n\n if (openEnd.selfClosing) {\n return {\n kind: 'island',\n name,\n attrs,\n body: '',\n selfClosing: true,\n bodyStart: openEnd.tagEnd,\n start,\n end: openEnd.tagEnd,\n };\n }\n\n // Walk the body, depth-counting `<leo.NAME` openers vs `</leo.NAME>` closers\n // for THIS name (quote-aware), so a callout nested in a callout matches its\n // own close, not the inner one (PoC bug #2).\n const bodyStart = openEnd.tagEnd;\n const close = findMatchingClose(source, bodyStart, name);\n if (close === null) {\n return null; // No matching close — unclosed body; degrade.\n }\n\n return {\n kind: 'island',\n name,\n attrs,\n body: source.slice(bodyStart, close.bodyEnd),\n selfClosing: false,\n bodyStart,\n start,\n end: close.tagEnd,\n };\n}\n\ninterface OpenTagEnd {\n /** Offset just past the last attr char (before `/>` or `>`). */\n readonly attrsEnd: number;\n /** Offset just past the closing `>` of the opening tag. */\n readonly tagEnd: number;\n readonly selfClosing: boolean;\n}\n\n/**\n * Find the end of an opening tag's `>` (or `/>`), starting at the first attr\n * char. Skips over single- and double-quoted regions so a `>` inside a quoted\n * attribute value is ignored.\n */\nfunction findOpenTagEnd(source: string, from: number): OpenTagEnd | null {\n let i = from;\n let quote: '\"' | \"'\" | null = null;\n while (i < source.length) {\n const ch = source[i];\n if (quote !== null) {\n if (ch === quote) {\n quote = null;\n }\n i++;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n quote = ch;\n i++;\n continue;\n }\n if (ch === '>') {\n const selfClosing = source[i - 1] === '/';\n const attrsEnd = selfClosing ? i - 1 : i;\n return { attrsEnd, tagEnd: i + 1, selfClosing };\n }\n i++;\n }\n return null; // ran off the end without a `>` — unterminated.\n}\n\ninterface MatchingClose {\n /** Offset of the start of the matching `</leo.NAME>` (end of body). */\n readonly bodyEnd: number;\n /** Offset just past the matching close tag. */\n readonly tagEnd: number;\n}\n\n/**\n * From `bodyStart`, find the `</leo.NAME>` that closes the island, honoring\n * nesting of the SAME name and skipping quoted regions. Each well-formed\n * `<leo.NAME ...>` (non-self-closing) opener increments depth; each\n * `</leo.NAME>` decrements it; depth 0 is the match. A self-closing\n * `<leo.NAME .../>` does not change depth.\n */\nfunction findMatchingClose(source: string, bodyStart: number, name: string): MatchingClose | null {\n const closeTag = `</leo.${name}>`;\n let depth = 1;\n let i = bodyStart;\n while (i < source.length) {\n const literalEnd = skipLiteral(source, i);\n if (literalEnd !== i) {\n i = literalEnd;\n continue;\n }\n if (source.startsWith(closeTag, i)) {\n depth--;\n if (depth === 0) {\n return { bodyEnd: i, tagEnd: i + closeTag.length };\n }\n i += closeTag.length;\n continue;\n }\n if (source.startsWith(LEO_PREFIX, i)) {\n const match = NAME_RE.exec(source.slice(i + LEO_PREFIX.length));\n if (match) {\n const inner = findOpenTagEnd(source, i + LEO_PREFIX.length + match[0].length);\n if (!inner) {\n return null;\n }\n if (match[0] === name && !inner.selfClosing) {\n depth++;\n }\n i = inner.tagEnd;\n continue;\n }\n }\n i++;\n }\n return null;\n}\n\n/**\n * Parse `key=\"value\"` / `key='value'` (and bare `key`) attribute pairs from an\n * opening tag's attribute string. Quote-aware so a `>` inside a value is part of\n * the value (the scanner already kept it inside `attrsRaw`). A bare attribute\n * with no `=` becomes `key -> \"\"` (the schema coerces a boolean from presence).\n */\nexport function parseAttrs(attrsRaw: string): Record<string, string> {\n const attrs: Record<string, string> = {};\n const re = /([a-zA-Z_][\\w-]*)(?:\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))?/g;\n let m: RegExpExecArray | null;\n // biome-ignore lint/suspicious/noAssignInExpressions: idiomatic exec loop\n while ((m = re.exec(attrsRaw)) !== null) {\n if (m[0].trim() === '') {\n // Zero-width match — advance to avoid an infinite loop.\n re.lastIndex++;\n continue;\n }\n const key = m[1];\n // m[3] = double-quoted body, m[4] = single-quoted body, else bare.\n const value = m[3] ?? m[4] ?? '';\n attrs[key] = value;\n }\n return attrs;\n}\n\n// ── helpers ─────────────────────────────────────────────────────────────────\n\n/** Push a prose span iff non-empty (keeps the span list free of empty noise). */\nfunction pushProse(spans: DocSpan[], text: string, start: number, end: number): void {\n if (text.length === 0) {\n return;\n }\n const prose: ProseSpan = { kind: 'prose', text, start, end };\n spans.push(prose);\n}\n"]}
1
+ {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG3E,4CAA4C;AAC5C,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B;;;;GAIG;AACH,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,MAAc;IAC/B,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;YACZ,uCAAuC;YACvC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;Y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0EAA0E;IAC1E,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACrB,wDAAwD;YACxD,EAAE,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACb,CAAC;QACD,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,mEAAmE;QACnE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACjC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,+EAA+E;AAE/E,iFAAiF;AACjF,SAAS,SAAS,CAAC,KAAgB,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACzE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO;IACX,CAAC;IACD,MAAM,KAAK,GAAc,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC7D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC","sourcesContent":["/**\n * The `<leo.*>` island scanner (ADR-D-01KVQHTWH8MQ).\n *\n * A single-pass, quote-aware, balanced-nesting scanner that finds `<leo.*>`\n * islands in a source string and returns the document as an ordered list of\n * spans — prose passes through VERBATIM; each island is extracted with its raw\n * attrs and balanced body; a `<leo.` opener that cannot be parsed DEGRADES to a\n * malformed span (preserved as text) rather than stalling or dropping the rest.\n *\n * It is the SOLE resolution path on both surfaces (terminal + web), so the two\n * cannot diverge. It claims ONLY `<leo.*>` (the namespace allow-list); every\n * other angle bracket — `<div>`, `<Callout>`, autolinks, code spans, `a < b` —\n * passes through untouched.\n *\n * Fixes the three silent-mangle cases the PoC proved in the old regex/nextLeoTag\n * parser:\n * 1. `value=\"a > b\"` — quote-aware attr scan; `>` inside quotes is not the end.\n * 2. callout-in-callout — depth-counted body scan over the SAME tag name.\n * 3. unterminated opener — degrades to a malformed span; surrounding prose kept.\n *\n * Tag names are LOWERCASE-ONLY. `<leo.Callout>` (PascalCase) is NOT a\n * leo island — the scanner does not claim it (a lint rejects the authoring form\n * separately). The dot is a literal character in the name, not a namespace\n * lookup.\n */\n\nimport { countRun, findFenceEnd, quotedLine, readFence } from './fence.js';\nimport type { DocSpan, IslandSpan, MalformedSpan, ProseSpan } from './types.js';\n\n/** The opener prefix the scanner claims. */\nconst LEO_PREFIX = '<leo.';\n\n/**\n * A lowercase tag name: starts with a-z, then a-z/0-9/hyphen. This is what makes\n * the scanner lowercase-only — an uppercase first char fails the match, so the\n * prefix is treated as ordinary prose and passes through.\n */\nconst NAME_RE = /^[a-z][a-z0-9-]*/;\n\n/**\n * Scan a source string into ordered spans. Prose between islands is preserved\n * verbatim; islands carry raw (pre-coercion) attrs + balanced body; an\n * unparseable `<leo.` opener becomes a malformed span.\n */\nexport function scan(source: string): DocSpan[] {\n const spans: DocSpan[] = [];\n let cursor = 0;\n\n while (cursor < source.length) {\n const lt = findNextLeoPrefix(source, cursor);\n if (lt === -1) {\n // No more openers — the rest is prose.\n pushProse(spans, source.slice(cursor), cursor, source.length);\n break;\n }\n\n const nameMatch = NAME_RE.exec(source.slice(lt + LEO_PREFIX.length));\n if (!nameMatch) {\n // `<leo.` not followed by a lowercase name (e.g. `<leo.` then EOF, a\n // space, or an uppercase char). Not a claimable island: emit the\n // `<leo.` literal as prose and continue scanning AFTER it, so a real\n // island later in the source is still found.\n pushProse(\n spans,\n source.slice(cursor, lt + LEO_PREFIX.length),\n cursor,\n lt + LEO_PREFIX.length\n );\n cursor = lt + LEO_PREFIX.length;\n continue;\n }\n\n // Flush the prose before this opener.\n pushProse(spans, source.slice(cursor, lt), cursor, lt);\n\n const name = nameMatch[0];\n const island = parseIsland(source, lt, name);\n if (island === null) {\n // Unterminated/unclosed opener — degrade. Preserve the `<leo.NAME`\n // opener text and resume scanning just past it so the rest of the\n // document (including any well-formed islands) is never dropped.\n const openerEnd = lt + LEO_PREFIX.length + name.length;\n const malformed: MalformedSpan = {\n kind: 'malformed',\n text: source.slice(lt, openerEnd),\n reason: 'unterminated',\n start: lt,\n end: openerEnd,\n };\n spans.push(malformed);\n cursor = openerEnd;\n continue;\n }\n\n spans.push(island);\n cursor = island.end;\n }\n\n return spans;\n}\n\n/**\n * Find the next claimable opener outside Markdown code spans and fenced code.\n * This is lexical shielding, not a second Markdown parser: it recognizes only\n * CommonMark's literal-code delimiters, whose contents must pass through byte\n * for byte on every surface.\n */\nfunction findNextLeoPrefix(source: string, from: number): number {\n let i = from;\n\n while (i < source.length) {\n const literalEnd = skipLiteral(source, i);\n if (literalEnd !== i) {\n i = literalEnd;\n continue;\n }\n\n if (source.startsWith(LEO_PREFIX, i)) {\n return i;\n }\n i++;\n }\n\n return -1;\n}\n\n/** Skip Markdown literals and comments before recognizing either tag boundary. */\nfunction skipLiteral(source: string, at: number): number {\n if (source.startsWith('<!--', at)) {\n const end = source.indexOf('-->', at + 4);\n return end === -1 ? source.length : end + 3;\n }\n if (at === 0 || source[at - 1] === '\\n') {\n const quote = quotedLine(source, at);\n const fence = readFence(source, quote.start);\n if (fence) {\n const end = findFenceEnd(\n source,\n fence.contentStart,\n fence.marker,\n fence.length,\n quote.depth\n );\n return end === -1 ? source.length : end;\n }\n }\n if (source[at] === '`') {\n const length = countRun(source, at, '`');\n const close = findMatchingBacktickRun(source, at + length, length);\n return close === -1 ? at + length : close + length;\n }\n return at;\n}\n\n/** Find a closing backtick run of exactly `length`, per CommonMark code spans. */\nfunction findMatchingBacktickRun(source: string, from: number, length: number): number {\n let at = source.indexOf('`', from);\n while (at !== -1) {\n const candidateLength = countRun(source, at, '`');\n if (candidateLength === length) {\n return at;\n }\n at = source.indexOf('`', at + candidateLength);\n }\n return -1;\n}\n\n/**\n * Parse a single island starting at `start` (the `<` of `<leo.NAME`). Returns\n * the island span, or `null` if it cannot be parsed as a balanced island\n * (caller degrades). Quote-aware throughout.\n */\nfunction parseIsland(source: string, start: number, name: string): IslandSpan | null {\n const attrsStart = start + LEO_PREFIX.length + name.length;\n\n // Find the end of the opening tag, skipping over quoted attribute values so\n // a `>` inside `value=\"a > b\"` does not terminate the tag (PoC bug #1).\n const openEnd = findOpenTagEnd(source, attrsStart);\n if (openEnd === null) {\n return null; // `<leo.NAME` with no closing `>` — unterminated opener.\n }\n\n const attrsRaw = source.slice(attrsStart, openEnd.attrsEnd);\n const attrs = parseAttrs(attrsRaw);\n\n if (openEnd.selfClosing) {\n return {\n kind: 'island',\n name,\n attrs,\n body: '',\n selfClosing: true,\n bodyStart: openEnd.tagEnd,\n start,\n end: openEnd.tagEnd,\n };\n }\n\n // Walk the body, depth-counting `<leo.NAME` openers vs `</leo.NAME>` closers\n // for THIS name (quote-aware), so a callout nested in a callout matches its\n // own close, not the inner one (PoC bug #2).\n const bodyStart = openEnd.tagEnd;\n const close = findMatchingClose(source, bodyStart, name);\n if (close === null) {\n return null; // No matching close — unclosed body; degrade.\n }\n\n return {\n kind: 'island',\n name,\n attrs,\n body: source.slice(bodyStart, close.bodyEnd),\n selfClosing: false,\n bodyStart,\n start,\n end: close.tagEnd,\n };\n}\n\ninterface OpenTagEnd {\n /** Offset just past the last attr char (before `/>` or `>`). */\n readonly attrsEnd: number;\n /** Offset just past the closing `>` of the opening tag. */\n readonly tagEnd: number;\n readonly selfClosing: boolean;\n}\n\n/**\n * Find the end of an opening tag's `>` (or `/>`), starting at the first attr\n * char. Skips over single- and double-quoted regions so a `>` inside a quoted\n * attribute value is ignored.\n */\nfunction findOpenTagEnd(source: string, from: number): OpenTagEnd | null {\n let i = from;\n let quote: '\"' | \"'\" | null = null;\n while (i < source.length) {\n const ch = source[i];\n if (quote !== null) {\n if (ch === quote) {\n quote = null;\n }\n i++;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n quote = ch;\n i++;\n continue;\n }\n if (ch === '>') {\n const selfClosing = source[i - 1] === '/';\n const attrsEnd = selfClosing ? i - 1 : i;\n return { attrsEnd, tagEnd: i + 1, selfClosing };\n }\n i++;\n }\n return null; // ran off the end without a `>` — unterminated.\n}\n\ninterface MatchingClose {\n /** Offset of the start of the matching `</leo.NAME>` (end of body). */\n readonly bodyEnd: number;\n /** Offset just past the matching close tag. */\n readonly tagEnd: number;\n}\n\n/**\n * From `bodyStart`, find the `</leo.NAME>` that closes the island, honoring\n * nesting of the SAME name and skipping quoted regions. Each well-formed\n * `<leo.NAME ...>` (non-self-closing) opener increments depth; each\n * `</leo.NAME>` decrements it; depth 0 is the match. A self-closing\n * `<leo.NAME .../>` does not change depth.\n */\nfunction findMatchingClose(source: string, bodyStart: number, name: string): MatchingClose | null {\n const closeTag = `</leo.${name}>`;\n let depth = 1;\n let i = bodyStart;\n while (i < source.length) {\n const literalEnd = skipLiteral(source, i);\n if (literalEnd !== i) {\n i = literalEnd;\n continue;\n }\n if (source.startsWith(closeTag, i)) {\n depth--;\n if (depth === 0) {\n return { bodyEnd: i, tagEnd: i + closeTag.length };\n }\n i += closeTag.length;\n continue;\n }\n if (source.startsWith(LEO_PREFIX, i)) {\n const match = NAME_RE.exec(source.slice(i + LEO_PREFIX.length));\n if (match) {\n const inner = findOpenTagEnd(source, i + LEO_PREFIX.length + match[0].length);\n if (!inner) {\n return null;\n }\n if (match[0] === name && !inner.selfClosing) {\n depth++;\n }\n i = inner.tagEnd;\n continue;\n }\n }\n i++;\n }\n return null;\n}\n\n/**\n * Parse `key=\"value\"` / `key='value'` (and bare `key`) attribute pairs from an\n * opening tag's attribute string. Quote-aware so a `>` inside a value is part of\n * the value (the scanner already kept it inside `attrsRaw`). A bare attribute\n * with no `=` becomes `key -> \"\"` (the schema coerces a boolean from presence).\n */\nexport function parseAttrs(attrsRaw: string): Record<string, string> {\n const attrs: Record<string, string> = {};\n const re = /([a-zA-Z_][\\w-]*)(?:\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))?/g;\n let m: RegExpExecArray | null;\n // biome-ignore lint/suspicious/noAssignInExpressions: idiomatic exec loop\n while ((m = re.exec(attrsRaw)) !== null) {\n if (m[0].trim() === '') {\n // Zero-width match — advance to avoid an infinite loop.\n re.lastIndex++;\n continue;\n }\n const key = m[1];\n // m[3] = double-quoted body, m[4] = single-quoted body, else bare.\n const value = m[3] ?? m[4] ?? '';\n attrs[key] = value;\n }\n return attrs;\n}\n\n// ── helpers ─────────────────────────────────────────────────────────────────\n\n/** Push a prose span iff non-empty (keeps the span list free of empty noise). */\nfunction pushProse(spans: DocSpan[], text: string, start: number, end: number): void {\n if (text.length === 0) {\n return;\n }\n const prose: ProseSpan = { kind: 'prose', text, start, end };\n spans.push(prose);\n}\n"]}
@@ -128,12 +128,12 @@
128
128
  },
129
129
  {
130
130
  "family": "path",
131
- "form": "path/<repo-path>[#L<a>[-L<b>]]",
131
+ "form": "path/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]",
132
132
  "meaning": "File or directory in the document's own repository"
133
133
  },
134
134
  {
135
135
  "family": "repo",
136
- "form": "repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]",
136
+ "form": "repo/<repo-id>/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]",
137
137
  "meaning": "File or directory in the named repository"
138
138
  },
139
139
  {
@@ -183,11 +183,15 @@
183
183
  "path": [
184
184
  "path/packages/leo-markup",
185
185
  "path/src/scanner.ts#L12",
186
- "path/src/scanner.ts#L12-L40"
186
+ "path/src/scanner.ts#L12-L40",
187
+ "path/docs/prds/00061-conversation-reference-cards.prd.md#requirements",
188
+ "path/docs/plans/pty-markup-wiring.plan.md#phase/p1",
189
+ "path/docs/plans/pty-markup-wiring.plan.md#todo/p1-rename"
187
190
  ],
188
191
  "repo": [
189
192
  "repo/leo-mono/packages/leo-doc-core/src/scanner.ts",
190
- "repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#L3-L9"
193
+ "repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#L3-L9",
194
+ "repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#todo/p2-index"
191
195
  ],
192
196
  "suite-export": [
193
197
  "leo-studio/decision/D3",
@@ -206,7 +210,14 @@
206
210
  "repo/leo-mono",
207
211
  "path/a.ts#L9-L3",
208
212
  "audit/D1",
209
- "journey/onboarding"
213
+ "journey/onboarding",
214
+ "path/../secrets.md",
215
+ "path//etc/passwd",
216
+ "path/docs/./a.md",
217
+ "repo/leo-mono/~/notes.md",
218
+ "path/a.plan.md#todo/",
219
+ "path/a.plan.md#todo/x#L3",
220
+ "path/a.md#Not A Slug"
210
221
  ]
211
222
  },
212
223
  "productSpecComponents": {
@@ -57,11 +57,11 @@ export declare const TARGET_FAMILIES: {
57
57
  readonly meaning: 'ADR draft (D-<ulid>) or canonical ID';
58
58
  };
59
59
  readonly path: {
60
- readonly form: 'path/<repo-path>[#L<a>[-L<b>]]';
60
+ readonly form: 'path/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]';
61
61
  readonly meaning: "File or directory in the document's own repository";
62
62
  };
63
63
  readonly repo: {
64
- readonly form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]';
64
+ readonly form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]';
65
65
  readonly meaning: 'File or directory in the named repository';
66
66
  };
67
67
  readonly artifact: {
@@ -78,6 +78,18 @@ export interface LineRange {
78
78
  readonly start: number;
79
79
  readonly end?: number;
80
80
  }
81
+ /**
82
+ * A non-line fragment of a code target: a Markdown heading slug, or a phase or
83
+ * todo of a plan file. A target carries at most one fragment, so `lines` and
84
+ * `anchor` never appear together.
85
+ */
86
+ export type RefAnchor = {
87
+ readonly kind: 'heading';
88
+ readonly slug: string;
89
+ } | {
90
+ readonly kind: 'phase' | 'todo';
91
+ readonly id: string;
92
+ };
81
93
  /** A parsed `leo.ref` target. Unknown and malformed targets are reported as values, never dropped. */
82
94
  export type RefTarget =
83
95
  /** A single segment: a local ID (`D12`) or a suite slug; resolution decides which. comment-lint-ignore: literal target example */
@@ -94,11 +106,13 @@ export type RefTarget =
94
106
  readonly kind: 'path';
95
107
  readonly path: string;
96
108
  readonly lines?: LineRange;
109
+ readonly anchor?: RefAnchor;
97
110
  } | {
98
111
  readonly kind: 'repo';
99
112
  readonly repo: string;
100
113
  readonly path: string;
101
114
  readonly lines?: LineRange;
115
+ readonly anchor?: RefAnchor;
102
116
  } | {
103
117
  readonly kind: 'suite-export';
104
118
  readonly suite: string;
@@ -168,11 +182,11 @@ export declare function buildVocabulary(): {
168
182
  meaning: 'ADR draft (D-<ulid>) or canonical ID';
169
183
  family: string;
170
184
  } | {
171
- form: 'path/<repo-path>[#L<a>[-L<b>]]';
185
+ form: 'path/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]';
172
186
  meaning: "File or directory in the document's own repository";
173
187
  family: string;
174
188
  } | {
175
- form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]';
189
+ form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]';
176
190
  meaning: 'File or directory in the named repository';
177
191
  family: string;
178
192
  } | {
@@ -1 +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,MA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suite' },
54
54
  adr: { form: 'adr/<id>', meaning: 'ADR draft (D-<ulid>) or canonical ID' },
55
55
  path: {
56
- form: 'path/<repo-path>[#L<a>[-L<b>]]',
56
+ form: 'path/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]',
57
57
  meaning: "File or directory in the document's own repository",
58
58
  },
59
59
  repo: {
60
- form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]]',
60
+ form: 'repo/<repo-id>/<repo-path>[#L<a>[-L<b>]|#<heading>|#phase/<id>|#todo/<id>]',
61
61
  meaning: 'File or directory in the named repository',
62
62
  },
63
63
  artifact: { form: 'artifact/<key>', meaning: 'Logical implementation or evidence artifact' },
@@ -88,10 +88,18 @@ export const TARGET_EXAMPLES = {
88
88
  adr: ['adr/D-01KVQHTWH8MQ', 'adr/00042'],
89
89
  artifact: ['artifact/spec-matrix'],
90
90
  'audit-question': ['audit/question/01KVQHTWH8MQ'],
91
- path: ['path/packages/leo-markup', 'path/src/scanner.ts#L12', 'path/src/scanner.ts#L12-L40'],
91
+ path: [
92
+ 'path/packages/leo-markup',
93
+ 'path/src/scanner.ts#L12',
94
+ 'path/src/scanner.ts#L12-L40',
95
+ 'path/docs/prds/00061-conversation-reference-cards.prd.md#requirements',
96
+ 'path/docs/plans/pty-markup-wiring.plan.md#phase/p1',
97
+ 'path/docs/plans/pty-markup-wiring.plan.md#todo/p1-rename',
98
+ ],
92
99
  repo: [
93
100
  'repo/leo-mono/packages/leo-doc-core/src/scanner.ts',
94
101
  'repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#L3-L9',
102
+ 'repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#todo/p2-index',
95
103
  ],
96
104
  'suite-export': [
97
105
  'leo-studio/decision/D3',
@@ -103,29 +111,77 @@ export const TARGET_EXAMPLES = {
103
111
  'leo-studio/fork/review-1',
104
112
  ],
105
113
  unknown: ['ticket/LEO-12'],
106
- invalid: ['path/', 'repo/leo-mono', 'path/a.ts#L9-L3', 'audit/D1', 'journey/onboarding'],
114
+ invalid: [
115
+ 'path/',
116
+ 'repo/leo-mono',
117
+ 'path/a.ts#L9-L3',
118
+ 'audit/D1',
119
+ 'journey/onboarding',
120
+ 'path/../secrets.md',
121
+ 'path//etc/passwd',
122
+ 'path/docs/./a.md',
123
+ 'repo/leo-mono/~/notes.md',
124
+ 'path/a.plan.md#todo/',
125
+ 'path/a.plan.md#todo/x#L3',
126
+ 'path/a.md#Not A Slug',
127
+ ],
107
128
  };
108
129
  const LINES = /^L([1-9][0-9]*)(?:-L([1-9][0-9]*))?$/u;
130
+ const PLAN_ITEM = /^(phase|todo)\/([A-Za-z0-9][A-Za-z0-9._-]*)$/u;
131
+ const HEADING = /^[\p{Ll}\p{Lo}\p{N}][\p{Ll}\p{Lo}\p{N}_-]*$/u;
132
+ // Control characters and backslashes never belong in a repository-relative path.
133
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting them is the point
134
+ const UNSAFE_CHARACTERS = /[\u0000-\u001f\u007f\\]/u;
135
+ /** Why a repository-relative path cannot be addressed, or `undefined` when it is safe. */
136
+ function unsafePathReason(path) {
137
+ if (UNSAFE_CHARACTERS.test(path)) {
138
+ return 'unsafe path: control character or backslash';
139
+ }
140
+ const segments = path.split('/');
141
+ if (segments[0]?.startsWith('~')) {
142
+ return 'unsafe path: home-relative';
143
+ }
144
+ if (segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {
145
+ return 'unsafe path: must be repository-relative without empty, . or .. segments';
146
+ }
147
+ return undefined;
148
+ }
109
149
  function invalid(family, rest, reason) {
110
150
  return { kind: 'invalid', family, rest, reason };
111
151
  }
112
- /** Split `<path>[#L<a>[-L<b>]]`, or return the reason it is malformed. */
152
+ const FRAGMENT_FORMS = '#L<a>[-L<b>] with a <= b, #<heading-slug>, #phase/<id> or #todo/<id>';
153
+ /** Split `<path>[#<fragment>]`, or return the reason it is malformed. */
113
154
  function codeLocation(text) {
114
155
  const hash = text.indexOf('#');
115
156
  const path = hash === -1 ? text : text.slice(0, hash);
116
157
  if (!path) {
117
158
  return 'missing path';
118
159
  }
160
+ const unsafe = unsafePathReason(path);
161
+ if (unsafe) {
162
+ return unsafe;
163
+ }
119
164
  if (hash === -1) {
120
165
  return { path };
121
166
  }
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';
167
+ const fragment = text.slice(hash + 1);
168
+ const lines = LINES.exec(fragment);
169
+ if (lines) {
170
+ const start = Number(lines[1]);
171
+ const end = lines[2] === undefined ? undefined : Number(lines[2]);
172
+ if (end !== undefined && end < start) {
173
+ return `fragment must be ${FRAGMENT_FORMS}`;
174
+ }
175
+ return { path, lines: end === undefined ? { start } : { start, end } };
176
+ }
177
+ const item = PLAN_ITEM.exec(fragment);
178
+ if (item) {
179
+ return { path, anchor: { kind: item[1], id: item[2] } };
180
+ }
181
+ if (!/^L[0-9]/u.test(fragment) && !fragment.includes('/') && HEADING.test(fragment)) {
182
+ return { path, anchor: { kind: 'heading', slug: fragment } };
127
183
  }
128
- return { path, lines: end === undefined ? { start } : { start, end } };
184
+ return `fragment must be ${FRAGMENT_FORMS}`;
129
185
  }
130
186
  /** Parse a `leo.ref` target into its family. Never throws. */
131
187
  export function parseRefTarget(target) {
@@ -179,16 +235,24 @@ export function parseRefTarget(target) {
179
235
  }
180
236
  /** The canonical string form of a parsed target; `formatRefTarget(parseRefTarget(t)) === t`. */
181
237
  export function formatRefTarget(target) {
182
- const lines = (range) => range ? `#L${range.start}${range.end === undefined ? '' : `-L${range.end}`}` : '';
238
+ const lines = (range, anchor) => {
239
+ if (range) {
240
+ return `#L${range.start}${range.end === undefined ? '' : `-L${range.end}`}`;
241
+ }
242
+ if (!anchor) {
243
+ return '';
244
+ }
245
+ return anchor.kind === 'heading' ? `#${anchor.slug}` : `#${anchor.kind}/${anchor.id}`;
246
+ };
183
247
  switch (target.kind) {
184
248
  case 'bare':
185
249
  return target.id;
186
250
  case 'audit-question':
187
251
  return `audit/question/${target.id}`;
188
252
  case 'path':
189
- return `path/${target.path}${lines(target.lines)}`;
253
+ return `path/${target.path}${lines(target.lines, target.anchor)}`;
190
254
  case 'repo':
191
- return `repo/${target.repo}/${target.path}${lines(target.lines)}`;
255
+ return `repo/${target.repo}/${target.path}${lines(target.lines, target.anchor)}`;
192
256
  case 'suite-export':
193
257
  return [target.suite, target.family, ...target.ids].join('/');
194
258
  case 'unknown':
@@ -1 +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,EAA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C,IAAI,CAAC;QAC3E;YACI,OAAO,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;IAC7C,CAAC;AACL,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,eAAe;IAC3B,OAAO;QACH,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,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"]}
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,OAA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AAE,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>]|#<heading>|#phase/<id>|#todo/<id>]',\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>]|#<heading>|#phase/<id>|#todo/<id>]',\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/**\n * A non-line fragment of a code target: a Markdown heading slug, or a phase or\n * todo of a plan file. A target carries at most one fragment, so `lines` and\n * `anchor` never appear together.\n */\nexport type RefAnchor =\n | { readonly kind: 'heading'; readonly slug: string }\n | { readonly kind: 'phase' | 'todo'; readonly id: string };\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 | {\n readonly kind: 'path';\n readonly path: string;\n readonly lines?: LineRange;\n readonly anchor?: RefAnchor;\n }\n | {\n readonly kind: 'repo';\n readonly repo: string;\n readonly path: string;\n readonly lines?: LineRange;\n readonly anchor?: RefAnchor;\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: [\n 'path/packages/leo-markup',\n 'path/src/scanner.ts#L12',\n 'path/src/scanner.ts#L12-L40',\n 'path/docs/prds/00061-conversation-reference-cards.prd.md#requirements',\n 'path/docs/plans/pty-markup-wiring.plan.md#phase/p1',\n 'path/docs/plans/pty-markup-wiring.plan.md#todo/p1-rename',\n ],\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 'repo/pg-fs/docs/plans/leo-docs-hosting.plan.md#todo/p2-index',\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: [\n 'path/',\n 'repo/leo-mono',\n 'path/a.ts#L9-L3',\n 'audit/D1',\n 'journey/onboarding',\n 'path/../secrets.md',\n 'path//etc/passwd',\n 'path/docs/./a.md',\n 'repo/leo-mono/~/notes.md',\n 'path/a.plan.md#todo/',\n 'path/a.plan.md#todo/x#L3',\n 'path/a.md#Not A Slug',\n ],\n};\n\nconst LINES = /^L([1-9][0-9]*)(?:-L([1-9][0-9]*))?$/u;\nconst PLAN_ITEM = /^(phase|todo)\\/([A-Za-z0-9][A-Za-z0-9._-]*)$/u;\nconst HEADING = /^[\\p{Ll}\\p{Lo}\\p{N}][\\p{Ll}\\p{Lo}\\p{N}_-]*$/u;\n// Control characters and backslashes never belong in a repository-relative path.\n// biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting them is the point\nconst UNSAFE_CHARACTERS = /[\\u0000-\\u001f\\u007f\\\\]/u;\n\n/** Why a repository-relative path cannot be addressed, or `undefined` when it is safe. */\nfunction unsafePathReason(path: string): string | undefined {\n if (UNSAFE_CHARACTERS.test(path)) {\n return 'unsafe path: control character or backslash';\n }\n const segments = path.split('/');\n if (segments[0]?.startsWith('~')) {\n return 'unsafe path: home-relative';\n }\n if (segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {\n return 'unsafe path: must be repository-relative without empty, . or .. segments';\n }\n return undefined;\n}\n\nfunction invalid(family: string, rest: string, reason: string): RefTarget {\n return { kind: 'invalid', family, rest, reason };\n}\n\nconst FRAGMENT_FORMS = '#L<a>[-L<b>] with a <= b, #<heading-slug>, #phase/<id> or #todo/<id>';\n\n/** Split `<path>[#<fragment>]`, or return the reason it is malformed. */\nfunction codeLocation(\n text: string\n): { path: string; lines?: LineRange; anchor?: RefAnchor } | 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 const unsafe = unsafePathReason(path);\n if (unsafe) {\n return unsafe;\n }\n if (hash === -1) {\n return { path };\n }\n const fragment = text.slice(hash + 1);\n const lines = LINES.exec(fragment);\n if (lines) {\n const start = Number(lines[1]);\n const end = lines[2] === undefined ? undefined : Number(lines[2]);\n if (end !== undefined && end < start) {\n return `fragment must be ${FRAGMENT_FORMS}`;\n }\n return { path, lines: end === undefined ? { start } : { start, end } };\n }\n const item = PLAN_ITEM.exec(fragment);\n if (item) {\n return { path, anchor: { kind: item[1] as 'phase' | 'todo', id: item[2] as string } };\n }\n if (!/^L[0-9]/u.test(fragment) && !fragment.includes('/') && HEADING.test(fragment)) {\n return { path, anchor: { kind: 'heading', slug: fragment } };\n }\n return `fragment must be ${FRAGMENT_FORMS}`;\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, anchor?: RefAnchor) => {\n if (range) {\n return `#L${range.start}${range.end === undefined ? '' : `-L${range.end}`}`;\n }\n if (!anchor) {\n return '';\n }\n return anchor.kind === 'heading' ? `#${anchor.slug}` : `#${anchor.kind}/${anchor.id}`;\n };\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, target.anchor)}`;\n case 'repo':\n return `repo/${target.repo}/${target.path}${lines(target.lines, target.anchor)}`;\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,6 @@
1
1
  {
2
2
  "name": "@leo-studio/leo-markup",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Pure-contract doc engine: shared leo.* vocabulary, island scanner, leo registry, prop schemas, PageContext type, and the parity test harness",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -16,10 +16,20 @@
16
16
  "types": "./dist/index.d.ts",
17
17
  "default": "./dist/index.js"
18
18
  },
19
- "./schema/*.json": "./dist/schema/*.json"
19
+ "./schema/*.json": "./dist/schema/*.json",
20
+ "./infra": {
21
+ "types": "./dist/infra/index.d.ts",
22
+ "default": "./dist/infra/index.js"
23
+ },
24
+ "./infra/raster": {
25
+ "types": "./dist/infra/raster.d.ts",
26
+ "default": "./dist/infra/raster.js"
27
+ }
20
28
  },
21
29
  "files": [
22
- "dist"
30
+ "dist",
31
+ "!dist/browser",
32
+ "!dist/extension"
23
33
  ],
24
34
  "publishConfig": {
25
35
  "access": "public",
@@ -30,7 +40,18 @@
30
40
  "@types/node": "^22.0.0",
31
41
  "ajv": "^8.20.0",
32
42
  "typescript": "7.0.2",
33
- "vitest": "^4.1.11"
43
+ "vitest": "^4.1.11",
44
+ "@resvg/resvg-js": "^2.6.2",
45
+ "esbuild": "0.28.1",
46
+ "jsdom": "29.1.1"
47
+ },
48
+ "peerDependencies": {
49
+ "@resvg/resvg-js": "^2.6.2"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "@resvg/resvg-js": {
53
+ "optional": true
54
+ }
34
55
  },
35
56
  "scripts": {
36
57
  "build": "tsc -p tsconfig.build.json && node scripts/copy-schema.ts",
@@ -41,6 +62,10 @@
41
62
  "test:watch": "vitest",
42
63
  "fixtures:generate": "pnpm run build && node scripts/generate-fixtures.ts",
43
64
  "vocabulary:generate": "pnpm run build && node scripts/generate-vocabulary.ts",
44
- "smoke:pack": "pnpm run build && node scripts/smoke-pack.ts"
65
+ "smoke:pack": "pnpm run build && node scripts/smoke-pack.ts",
66
+ "infra:build-native": "node infra-scripts/build-native.mjs",
67
+ "infra:build-browser": "node infra-scripts/build-browser.mjs",
68
+ "infra:build-extension": "node infra-scripts/build-extension.mjs",
69
+ "infra:check-resources": "node infra-scripts/build-native.mjs --check"
45
70
  }
46
71
  }