@leo-studio/leo-markup 0.2.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.
- package/README.md +20 -0
- package/dist/fence.d.ts +6 -1
- package/dist/fence.d.ts.map +1 -1
- package/dist/fence.js +27 -4
- package/dist/fence.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/infra/index.d.ts +2 -0
- package/dist/infra/index.d.ts.map +1 -0
- package/dist/infra/index.js +2 -0
- package/dist/infra/index.js.map +1 -0
- package/dist/infra/infra-diagram.d.ts +150 -0
- package/dist/infra/infra-diagram.d.ts.map +1 -0
- package/dist/infra/infra-diagram.js +1373 -0
- package/dist/infra/infra-diagram.js.map +1 -0
- package/dist/infra/raster.d.ts +13 -0
- package/dist/infra/raster.d.ts.map +1 -0
- package/dist/infra/raster.js +46 -0
- package/dist/infra/raster.js.map +1 -0
- package/dist/infra/standalone-style.d.ts +5 -0
- package/dist/infra/standalone-style.d.ts.map +1 -0
- package/dist/infra/standalone-style.js +101 -0
- package/dist/infra/standalone-style.js.map +1 -0
- package/dist/product-spec.d.ts.map +1 -1
- package/dist/product-spec.js +8 -0
- package/dist/product-spec.js.map +1 -1
- package/dist/references.d.ts +74 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +132 -0
- package/dist/references.js.map +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +28 -3
- package/dist/registry.js.map +1 -1
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +4 -3
- package/dist/scanner.js.map +1 -1
- package/dist/schema/vocabulary.json +16 -5
- package/dist/vocabulary.d.ts +18 -4
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +78 -14
- package/dist/vocabulary.js.map +1 -1
- package/package.json +30 -5
package/dist/product-spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|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AAM,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;AACvF,CAAC","sourcesContent":["import { composeMarkdownIslands } from './block-inline.js';\nimport { coerceProps, leoRegistry } from './registry.js';\nimport { scan } from './scanner.js';\nimport type { DocSpan, IslandSpan, LeoComponent, LeoRegistry, PropSchema } from './types.js';\n\nconst requiredString = { kind: 'string', required: true } as const;\nconst optionalString = { kind: 'string' } as const;\n\n/** The authored product-spec profile; display step/tree contracts remain independent. */\nexport const productSpecSchemas = {\n documents: {},\n document: {\n path: requiredString,\n title: requiredString,\n role: {\n kind: 'enum',\n required: true,\n values: ['index', 'decisions', 'detail', 'glossary', 'audit'],\n },\n },\n journey: { id: requiredString, title: requiredString },\n step: { id: requiredString },\n transition: { to: requiredString, when: requiredString },\n tree: { id: requiredString, title: optionalString },\n node: { label: requiredString, id: optionalString },\n scope: {\n increment: optionalString,\n deferred: { kind: 'boolean' },\n unassigned: { kind: 'boolean' },\n },\n ref: { relation: requiredString, target: requiredString },\n decisions: {},\n decision: {\n id: requiredString,\n title: requiredString,\n status: { kind: 'enum', required: true, values: ['accepted', 'superseded'] },\n architectural: { kind: 'boolean' },\n },\n statement: {},\n rationale: {},\n} as const satisfies Record<string, PropSchema>;\n\nexport type ProductSpecName = keyof typeof productSpecSchemas;\nexport type DeliveryScope =\n | { readonly kind: 'increment'; readonly increment: string }\n | { readonly kind: 'deferred' | 'unassigned' };\n\n/** Explicit capability profile: web consumers retain source until they implement these nodes. */\nexport const productSpecRegistry: LeoRegistry = Object.freeze({\n ...leoRegistry,\n ...Object.fromEntries(\n Object.entries(productSpecSchemas).map(([name, props]) => [\n name,\n {\n name,\n flow: name === 'ref' ? 'inline' : 'block',\n props,\n targets: 'terminal-only',\n degrade: {\n kind: 'note',\n text: 'Product-spec component: inspect source on this surface',\n },\n } satisfies LeoComponent,\n ])\n ),\n});\n\ninterface SourceNode {\n readonly start: number;\n readonly end: number;\n readonly source: string;\n readonly scope?: DeliveryScope;\n}\n\nexport interface ProductSpecComponent extends SourceNode {\n readonly kind: 'component';\n readonly name: ProductSpecName;\n readonly props: Readonly<Record<string, string | boolean>>;\n readonly bodyStart: number;\n readonly body: string;\n readonly children: readonly ProductSpecNode[];\n}\n\nexport type ProductSpecText = SourceNode &\n ({ readonly kind: 'prose' } | { readonly kind: 'fallback' });\n\nexport interface ProductSpecDisplay extends SourceNode {\n readonly kind: 'display';\n readonly island: IslandSpan;\n}\n\nexport type ProductSpecNode = ProductSpecComponent | ProductSpecText | ProductSpecDisplay;\nexport interface ProductSpecDiagnostic {\n readonly code:\n | 'invalid-component'\n | 'unknown-component'\n | 'malformed-component'\n | 'unsupported-version';\n readonly message: string;\n readonly start: number;\n readonly end: number;\n}\nexport interface ProductSpecParseResult {\n readonly nodes: readonly ProductSpecNode[];\n readonly diagnostics: readonly ProductSpecDiagnostic[];\n}\n\n/** The product-spec children each component accepts; a missing entry accepts any. */\nexport const productSpecChildren: Partial<Record<ProductSpecName, readonly ProductSpecName[]>> = {\n documents: ['document'],\n journey: ['step', 'scope'],\n tree: ['node', 'scope'],\n node: ['node', 'scope', 'ref'],\n step: ['transition', 'ref', 'scope'],\n decisions: ['decision'],\n decision: ['statement', 'rationale', 'ref'],\n ref: [],\n transition: [],\n};\n\nfunction sameScope(a: DeliveryScope, b: DeliveryScope): boolean {\n return (\n a.kind === b.kind &&\n (a.kind !== 'increment' || (b.kind === 'increment' && a.increment === b.increment))\n );\n}\n\nfunction readScope(props: Readonly<Record<string, string | boolean>>): DeliveryScope | undefined {\n if (typeof props.increment === 'string' && /^I[1-9][0-9]*$/.test(props.increment)) {\n return { kind: 'increment', increment: props.increment };\n }\n if (props.deferred === true) {\n return { kind: 'deferred' };\n }\n if (props.unassigned === true) {\n return { kind: 'unassigned' };\n }\n return undefined;\n}\n\n/** Identify the established display forms before selecting the spec profile. */\nfunction isDisplayForm(span: IslandSpan, parent?: ProductSpecName): boolean {\n if (span.name === 'step') {\n return !parent && !Object.hasOwn(span.attrs, 'id');\n }\n if (span.name === 'node') {\n return !parent && Object.hasOwn(span.attrs, 'name') && !Object.hasOwn(span.attrs, 'label');\n }\n if (span.name !== 'tree' || Object.hasOwn(span.attrs, 'id')) {\n return false;\n }\n const children = scan(span.body).filter((child) => child.kind === 'island');\n return (\n children.length > 0 &&\n children.every(\n (child) =>\n child.name === 'folder' ||\n child.name === 'file' ||\n (child.name === 'node' &&\n Object.hasOwn(child.attrs, 'name') &&\n !Object.hasOwn(child.attrs, 'label'))\n )\n );\n}\n\n/** Parse semantic components once, preserving source for every unsupported interpretation. */\nexport function parseProductSpec(\n source: string,\n options: { readonly schemaVersion?: unknown; readonly offset?: number } = {}\n): ProductSpecParseResult {\n const diagnostics: ProductSpecDiagnostic[] = [];\n const offset = options.offset ?? 0;\n if (options.schemaVersion !== undefined && options.schemaVersion !== 1) {\n const node = {\n kind: 'fallback',\n source,\n start: offset,\n end: offset + source.length,\n } as const;\n return {\n nodes: [node],\n diagnostics: [\n {\n code: 'unsupported-version',\n message: `Unsupported product-spec schema version: ${String(options.schemaVersion)}`,\n start: node.start,\n end: node.end,\n },\n ],\n };\n }\n\n const parse = (\n text: string,\n base: number,\n parent?: ProductSpecName,\n scope?: DeliveryScope\n ): ProductSpecNode[] =>\n scan(text).map((span): ProductSpecNode => {\n const raw = text.slice(span.start, span.end);\n const common = {\n source: raw,\n start: base + span.start,\n end: base + span.end,\n ...(scope ? { scope } : {}),\n };\n const fallback = (\n code: ProductSpecDiagnostic['code'],\n message: string\n ): ProductSpecText => {\n diagnostics.push({ code, message, start: common.start, end: common.end });\n return { ...common, kind: 'fallback' };\n };\n if (span.kind === 'prose') {\n return { ...common, kind: 'prose' };\n }\n if (span.kind === 'malformed') {\n return fallback('malformed-component', span.reason);\n }\n const name = span.name;\n const isSpec = Object.hasOwn(productSpecSchemas, name) && !isDisplayForm(span, parent);\n if (!isSpec) {\n if (Object.hasOwn(leoRegistry, name)) {\n return { ...common, kind: 'display', island: span };\n }\n return fallback('unknown-component', `Unknown component <leo.${name}>`);\n }\n // Only references participate in ordinary inline prose in the spec profile.\n const prefix = text.slice(text.lastIndexOf('\\n', span.start - 1) + 1, span.start);\n const followsComponent = /<\\/leo\\.[a-z]+>\\s*$/.test(prefix) || /\\/>\\s*$/.test(prefix);\n if (!parent && name !== 'ref' && prefix.trim() && !followsComponent) {\n return { ...common, kind: 'prose' };\n }\n const specName = name as ProductSpecName;\n if (\n parent &&\n productSpecChildren[parent] &&\n !productSpecChildren[parent]?.includes(specName)\n ) {\n return fallback(\n 'invalid-component',\n `<leo.${name}> is not valid inside <leo.${parent}>`\n );\n }\n const coerced = coerceProps(productSpecSchemas[specName], span.attrs);\n const errors = [...coerced.errors];\n for (const [key, value] of Object.entries(span.attrs)) {\n if (\n Object.hasOwn(productSpecSchemas[specName], key) &&\n value.trim() === '' &&\n (productSpecSchemas[specName] as PropSchema)[key]?.required\n ) {\n errors.push(`Empty required attribute ${key}`);\n }\n }\n const props = coerced.props as Record<string, string | boolean>;\n let effectiveScope = scope;\n if (specName === 'scope') {\n const next = readScope(props);\n if (!next || Object.keys(span.attrs).length !== 1) {\n errors.push('Scope requires exactly one valid disposition');\n } else if (scope && scope.kind !== 'unassigned' && !sameScope(scope, next)) {\n errors.push('Conflicting nested delivery scope');\n } else {\n effectiveScope = next;\n }\n }\n if (specName === 'transition' && span.body.trim()) {\n errors.push('Transition cannot contain a body');\n }\n if (errors.length) {\n return fallback('invalid-component', `<leo.${name}>: ${errors.join('; ')}`);\n }\n const bodyStart =\n base + (span.bodyStart ?? span.end - `</leo.${name}>`.length - span.body.length);\n const children = parse(\n span.body,\n bodyStart,\n specName === 'scope' ? parent : specName,\n effectiveScope\n );\n return {\n ...common,\n kind: 'component',\n name: specName,\n props,\n body: span.body,\n bodyStart,\n children,\n ...(effectiveScope ? { scope: effectiveScope } : {}),\n };\n });\n return { nodes: parse(source, offset), diagnostics };\n}\n\n/** Feed already interpreted nodes into the shared Markdown composition mechanism. */\nexport function composeProductSpecNodes(nodes: readonly ProductSpecNode[]) {\n const source = nodes.map((node) => node.source).join('');\n const byOffset = new Map<number, ProductSpecNode>();\n let offset = 0;\n const spans: DocSpan[] = nodes.map((node): DocSpan => {\n const start = offset;\n const end = start + node.source.length;\n offset = end;\n byOffset.set(start, node);\n if (node.kind === 'component') {\n return {\n kind: 'island',\n name: node.name,\n attrs: {},\n body: node.body,\n bodyStart: start + node.bodyStart - node.start,\n selfClosing: node.body === '',\n start,\n end,\n };\n }\n if (node.kind === 'display') {\n return { ...node.island, start, end };\n }\n if (node.kind === 'fallback') {\n return { kind: 'malformed', reason: 'unclosed-body', text: node.source, start, end };\n }\n return { kind: 'prose', text: node.source, start, end };\n });\n return { ...composeMarkdownIslands(source, productSpecRegistry, spans), byOffset };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"product-spec.js","sourceRoot":"","sources":["../src/product-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,MAAM,cAAc,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AACnE,MAAM,cAAc,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAW,CAAC;AAEnD,yFAAyF;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE;QACN,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE;YACF,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC;SAChE;KACJ;IACD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I,KAAK,WAAW,EAAE,CAAC;YAC5B,OAAO;gBACH,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK;gBAC9C,WAAW,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE;gBAC7B,KAAK;gBACL,GAAG;aACN,CAAC;QACN,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAC1C,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC3B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QACzF,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;AACvF,CAAC","sourcesContent":["import { composeMarkdownIslands } from './block-inline.js';\nimport { referenceDestination } from './references.js';\nimport { coerceProps, leoRegistry } from './registry.js';\nimport { scan } from './scanner.js';\nimport type { DocSpan, IslandSpan, LeoComponent, LeoRegistry, PropSchema } from './types.js';\n\nconst requiredString = { kind: 'string', required: true } as const;\nconst optionalString = { kind: 'string' } as const;\n\n/** The authored product-spec profile; display step/tree contracts remain independent. */\nexport const productSpecSchemas = {\n documents: {},\n document: {\n path: requiredString,\n title: requiredString,\n role: {\n kind: 'enum',\n required: true,\n values: ['index', 'decisions', 'detail', 'glossary', 'audit'],\n },\n },\n journey: { id: requiredString, title: requiredString },\n step: { id: requiredString },\n transition: { to: requiredString, when: requiredString },\n tree: { id: requiredString, title: optionalString },\n node: { label: requiredString, id: optionalString },\n scope: {\n increment: optionalString,\n deferred: { kind: 'boolean' },\n unassigned: { kind: 'boolean' },\n },\n ref: { relation: requiredString, target: requiredString },\n decisions: {},\n decision: {\n id: requiredString,\n title: requiredString,\n status: { kind: 'enum', required: true, values: ['accepted', 'superseded'] },\n architectural: { kind: 'boolean' },\n },\n statement: {},\n rationale: {},\n} as const satisfies Record<string, PropSchema>;\n\nexport type ProductSpecName = keyof typeof productSpecSchemas;\nexport type DeliveryScope =\n | { readonly kind: 'increment'; readonly increment: string }\n | { readonly kind: 'deferred' | 'unassigned' };\n\n/** Explicit capability profile: web consumers retain source until they implement these nodes. */\nexport const productSpecRegistry: LeoRegistry = Object.freeze({\n ...leoRegistry,\n ...Object.fromEntries(\n Object.entries(productSpecSchemas).map(([name, props]) => [\n name,\n {\n name,\n flow: name === 'ref' ? 'inline' : 'block',\n props,\n targets: 'terminal-only',\n degrade: {\n kind: 'note',\n text: 'Product-spec component: inspect source on this surface',\n },\n } satisfies LeoComponent,\n ])\n ),\n});\n\ninterface SourceNode {\n readonly start: number;\n readonly end: number;\n readonly source: string;\n readonly scope?: DeliveryScope;\n}\n\nexport interface ProductSpecComponent extends SourceNode {\n readonly kind: 'component';\n readonly name: ProductSpecName;\n readonly props: Readonly<Record<string, string | boolean>>;\n readonly bodyStart: number;\n readonly body: string;\n readonly children: readonly ProductSpecNode[];\n}\n\nexport type ProductSpecText = SourceNode &\n ({ readonly kind: 'prose' } | { readonly kind: 'fallback' });\n\nexport interface ProductSpecDisplay extends SourceNode {\n readonly kind: 'display';\n readonly island: IslandSpan;\n}\n\nexport type ProductSpecNode = ProductSpecComponent | ProductSpecText | ProductSpecDisplay;\nexport interface ProductSpecDiagnostic {\n readonly code:\n | 'invalid-component'\n | 'unknown-component'\n | 'malformed-component'\n | 'unsupported-version';\n readonly message: string;\n readonly start: number;\n readonly end: number;\n}\nexport interface ProductSpecParseResult {\n readonly nodes: readonly ProductSpecNode[];\n readonly diagnostics: readonly ProductSpecDiagnostic[];\n}\n\n/** The product-spec children each component accepts; a missing entry accepts any. */\nexport const productSpecChildren: Partial<Record<ProductSpecName, readonly ProductSpecName[]>> = {\n documents: ['document'],\n journey: ['step', 'scope'],\n tree: ['node', 'scope'],\n node: ['node', 'scope', 'ref'],\n step: ['transition', 'ref', 'scope'],\n decisions: ['decision'],\n decision: ['statement', 'rationale', 'ref'],\n ref: [],\n transition: [],\n};\n\nfunction sameScope(a: DeliveryScope, b: DeliveryScope): boolean {\n return (\n a.kind === b.kind &&\n (a.kind !== 'increment' || (b.kind === 'increment' && a.increment === b.increment))\n );\n}\n\nfunction readScope(props: Readonly<Record<string, string | boolean>>): DeliveryScope | undefined {\n if (typeof props.increment === 'string' && /^I[1-9][0-9]*$/.test(props.increment)) {\n return { kind: 'increment', increment: props.increment };\n }\n if (props.deferred === true) {\n return { kind: 'deferred' };\n }\n if (props.unassigned === true) {\n return { kind: 'unassigned' };\n }\n return undefined;\n}\n\n/** Identify the established display forms before selecting the spec profile. */\nfunction isDisplayForm(span: IslandSpan, parent?: ProductSpecName): boolean {\n if (span.name === 'ref') {\n const target = span.attrs.target;\n return (\n !parent &&\n Object.keys(span.attrs).length === 1 &&\n !!target &&\n referenceDestination(target).ok\n );\n }\n if (span.name === 'step') {\n return !parent && !Object.hasOwn(span.attrs, 'id');\n }\n if (span.name === 'node') {\n return !parent && Object.hasOwn(span.attrs, 'name') && !Object.hasOwn(span.attrs, 'label');\n }\n if (span.name !== 'tree' || Object.hasOwn(span.attrs, 'id')) {\n return false;\n }\n const children = scan(span.body).filter((child) => child.kind === 'island');\n return (\n children.length > 0 &&\n children.every(\n (child) =>\n child.name === 'folder' ||\n child.name === 'file' ||\n (child.name === 'node' &&\n Object.hasOwn(child.attrs, 'name') &&\n !Object.hasOwn(child.attrs, 'label'))\n )\n );\n}\n\n/** Parse semantic components once, preserving source for every unsupported interpretation. */\nexport function parseProductSpec(\n source: string,\n options: { readonly schemaVersion?: unknown; readonly offset?: number } = {}\n): ProductSpecParseResult {\n const diagnostics: ProductSpecDiagnostic[] = [];\n const offset = options.offset ?? 0;\n if (options.schemaVersion !== undefined && options.schemaVersion !== 1) {\n const node = {\n kind: 'fallback',\n source,\n start: offset,\n end: offset + source.length,\n } as const;\n return {\n nodes: [node],\n diagnostics: [\n {\n code: 'unsupported-version',\n message: `Unsupported product-spec schema version: ${String(options.schemaVersion)}`,\n start: node.start,\n end: node.end,\n },\n ],\n };\n }\n\n const parse = (\n text: string,\n base: number,\n parent?: ProductSpecName,\n scope?: DeliveryScope\n ): ProductSpecNode[] =>\n scan(text).map((span): ProductSpecNode => {\n const raw = text.slice(span.start, span.end);\n const common = {\n source: raw,\n start: base + span.start,\n end: base + span.end,\n ...(scope ? { scope } : {}),\n };\n const fallback = (\n code: ProductSpecDiagnostic['code'],\n message: string\n ): ProductSpecText => {\n diagnostics.push({ code, message, start: common.start, end: common.end });\n return { ...common, kind: 'fallback' };\n };\n if (span.kind === 'prose') {\n return { ...common, kind: 'prose' };\n }\n if (span.kind === 'malformed') {\n return fallback('malformed-component', span.reason);\n }\n const name = span.name;\n const isSpec = Object.hasOwn(productSpecSchemas, name) && !isDisplayForm(span, parent);\n if (!isSpec) {\n if (Object.hasOwn(leoRegistry, name)) {\n return { ...common, kind: 'display', island: span };\n }\n return fallback('unknown-component', `Unknown component <leo.${name}>`);\n }\n // Only references participate in ordinary inline prose in the spec profile.\n const prefix = text.slice(text.lastIndexOf('\\n', span.start - 1) + 1, span.start);\n const followsComponent = /<\\/leo\\.[a-z]+>\\s*$/.test(prefix) || /\\/>\\s*$/.test(prefix);\n if (!parent && name !== 'ref' && prefix.trim() && !followsComponent) {\n return { ...common, kind: 'prose' };\n }\n const specName = name as ProductSpecName;\n if (\n parent &&\n productSpecChildren[parent] &&\n !productSpecChildren[parent]?.includes(specName)\n ) {\n return fallback(\n 'invalid-component',\n `<leo.${name}> is not valid inside <leo.${parent}>`\n );\n }\n const coerced = coerceProps(productSpecSchemas[specName], span.attrs);\n const errors = [...coerced.errors];\n for (const [key, value] of Object.entries(span.attrs)) {\n if (\n Object.hasOwn(productSpecSchemas[specName], key) &&\n value.trim() === '' &&\n (productSpecSchemas[specName] as PropSchema)[key]?.required\n ) {\n errors.push(`Empty required attribute ${key}`);\n }\n }\n const props = coerced.props as Record<string, string | boolean>;\n let effectiveScope = scope;\n if (specName === 'scope') {\n const next = readScope(props);\n if (!next || Object.keys(span.attrs).length !== 1) {\n errors.push('Scope requires exactly one valid disposition');\n } else if (scope && scope.kind !== 'unassigned' && !sameScope(scope, next)) {\n errors.push('Conflicting nested delivery scope');\n } else {\n effectiveScope = next;\n }\n }\n if (specName === 'transition' && span.body.trim()) {\n errors.push('Transition cannot contain a body');\n }\n if (errors.length) {\n return fallback('invalid-component', `<leo.${name}>: ${errors.join('; ')}`);\n }\n const bodyStart =\n base + (span.bodyStart ?? span.end - `</leo.${name}>`.length - span.body.length);\n const children = parse(\n span.body,\n bodyStart,\n specName === 'scope' ? parent : specName,\n effectiveScope\n );\n return {\n ...common,\n kind: 'component',\n name: specName,\n props,\n body: span.body,\n bodyStart,\n children,\n ...(effectiveScope ? { scope: effectiveScope } : {}),\n };\n });\n return { nodes: parse(source, offset), diagnostics };\n}\n\n/** Feed already interpreted nodes into the shared Markdown composition mechanism. */\nexport function composeProductSpecNodes(nodes: readonly ProductSpecNode[]) {\n const source = nodes.map((node) => node.source).join('');\n const byOffset = new Map<number, ProductSpecNode>();\n let offset = 0;\n const spans: DocSpan[] = nodes.map((node): DocSpan => {\n const start = offset;\n const end = start + node.source.length;\n offset = end;\n byOffset.set(start, node);\n if (node.kind === 'component') {\n return {\n kind: 'island',\n name: node.name,\n attrs: {},\n body: node.body,\n bodyStart: start + node.bodyStart - node.start,\n selfClosing: node.body === '',\n start,\n end,\n };\n }\n if (node.kind === 'display') {\n return { ...node.island, start, end };\n }\n if (node.kind === 'fallback') {\n return { kind: 'malformed', reason: 'unclosed-body', text: node.source, start, end };\n }\n return { kind: 'prose', text: node.source, start, end };\n });\n return { ...composeMarkdownIslands(source, productSpecRegistry, spans), byOffset };\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation references: the `<leo.ref>` inline links and `<leo.card>` block
|
|
3
|
+
* cards an agent writes into a reply, and the destination each one names.
|
|
4
|
+
*
|
|
5
|
+
* Parsing and destination validation live here so every host reads the same
|
|
6
|
+
* contract. Hosts keep transcript placement, checkout resolution, status
|
|
7
|
+
* metadata and viewer selection. fixtures/conversation-references.json holds the
|
|
8
|
+
* cases both the TypeScript and Swift implementations must agree on.
|
|
9
|
+
*/
|
|
10
|
+
import { type LineRange, type RefAnchor } from './vocabulary.js';
|
|
11
|
+
/** The document families a reference destination can name. */
|
|
12
|
+
export declare const REFERENCE_DOCUMENT_KINDS: readonly ['spec', 'prd', 'adr', 'plan', 'issue', 'agent', 'skill', 'rule'];
|
|
13
|
+
export type ReferenceDocumentKind = (typeof REFERENCE_DOCUMENT_KINDS)[number];
|
|
14
|
+
/** Where inside the destination document to go. */
|
|
15
|
+
export type ReferenceAnchor = ({
|
|
16
|
+
readonly kind: 'lines';
|
|
17
|
+
} & LineRange) | RefAnchor;
|
|
18
|
+
/** A normalized destination: one document plus at most one anchor, kept separate. */
|
|
19
|
+
export interface ReferenceDestination {
|
|
20
|
+
/** Repository id for a `repo/` target; absent for the document's own repository. */
|
|
21
|
+
readonly repo?: string;
|
|
22
|
+
/** Repository-relative path with no fragment. */
|
|
23
|
+
readonly path: string;
|
|
24
|
+
/** Stable identity of the destination document: `[repo/<id>/|path/]<path>`, no anchor. */
|
|
25
|
+
readonly canonical: string;
|
|
26
|
+
readonly document?: ReferenceDocumentKind;
|
|
27
|
+
readonly anchor?: ReferenceAnchor;
|
|
28
|
+
}
|
|
29
|
+
export type ReferenceDestinationError = 'unsupported-target' | 'invalid-target';
|
|
30
|
+
export type ReferenceDestinationResult = {
|
|
31
|
+
readonly ok: true;
|
|
32
|
+
readonly destination: ReferenceDestination;
|
|
33
|
+
} | {
|
|
34
|
+
readonly ok: false;
|
|
35
|
+
readonly error: ReferenceDestinationError;
|
|
36
|
+
readonly reason: string;
|
|
37
|
+
};
|
|
38
|
+
/** Classify a repository-relative path by the Leo document family its name and location imply. */
|
|
39
|
+
export declare function referenceDocumentKind(path: string): ReferenceDocumentKind | undefined;
|
|
40
|
+
/** Resolve a `target` attribute into a normalized destination, or say why it has none. */
|
|
41
|
+
export declare function referenceDestination(target: string): ReferenceDestinationResult;
|
|
42
|
+
/** One complete `<leo.ref>` or `<leo.card>` in a message. Offsets are UTF-16 code units. */
|
|
43
|
+
export interface ConversationReference {
|
|
44
|
+
readonly component: 'ref' | 'card';
|
|
45
|
+
readonly start: number;
|
|
46
|
+
readonly end: number;
|
|
47
|
+
readonly target?: string;
|
|
48
|
+
/** The authored body text; empty when the author left the host to choose a label. */
|
|
49
|
+
readonly label: string;
|
|
50
|
+
/** An explicit spec relationship (`implements`, `depends-on`, …); absent for a neutral ref. */
|
|
51
|
+
readonly relation?: string;
|
|
52
|
+
/** True for a card that names its source with `type`/`ref`/`path`/`href` instead of `target`. */
|
|
53
|
+
readonly legacy: boolean;
|
|
54
|
+
readonly destination?: ReferenceDestination;
|
|
55
|
+
/** Why `target` has no destination; the reference still renders its label. */
|
|
56
|
+
readonly destinationError?: {
|
|
57
|
+
readonly error: ReferenceDestinationError;
|
|
58
|
+
readonly reason: string;
|
|
59
|
+
};
|
|
60
|
+
/** Authoring errors (unknown props, conflicting selectors, unknown relation). */
|
|
61
|
+
readonly errors: readonly string[];
|
|
62
|
+
}
|
|
63
|
+
export interface ConversationReferenceScan {
|
|
64
|
+
readonly references: readonly ConversationReference[];
|
|
65
|
+
/**
|
|
66
|
+
* Offset of an unfinished `<leo.ref` or `<leo.card` opener at the end of a
|
|
67
|
+
* streamed message. A streaming host holds back text from here until the tag
|
|
68
|
+
* completes; prose before it is unaffected.
|
|
69
|
+
*/
|
|
70
|
+
readonly pendingFrom?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Find the references in a message. Tags inside code spans, fences and comments stay text. */
|
|
73
|
+
export declare function scanConversationReferences(source: string): ConversationReferenceScan;
|
|
74
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,KAAK,SAAS,EAAiC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEhG,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,YACjC,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,CACA,CAAC;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,mDAAmD;AACnD,MAAM,MAAM,eAAe,GAAG,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AAEnF,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACjC,oFAAoF;IACpF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CACrC;AAED,MAAM,MAAM,yBAAyB,GAAG,oBAAoB,GAAG,gBAAgB,CA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B,EAAE,CAAC;IACtD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,+FAA+F;AAC/F,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,yBAAyB,CA8CpF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation references: the `<leo.ref>` inline links and `<leo.card>` block
|
|
3
|
+
* cards an agent writes into a reply, and the destination each one names.
|
|
4
|
+
*
|
|
5
|
+
* Parsing and destination validation live here so every host reads the same
|
|
6
|
+
* contract. Hosts keep transcript placement, checkout resolution, status
|
|
7
|
+
* metadata and viewer selection. fixtures/conversation-references.json holds the
|
|
8
|
+
* cases both the TypeScript and Swift implementations must agree on.
|
|
9
|
+
*/
|
|
10
|
+
import { coerceProps, leoRegistry } from './registry.js';
|
|
11
|
+
import { scan } from './scanner.js';
|
|
12
|
+
import { isIslandSpan, isMalformedSpan } from './types.js';
|
|
13
|
+
import { parseRefTarget, REF_RELATIONS } from './vocabulary.js';
|
|
14
|
+
/** The document families a reference destination can name. */
|
|
15
|
+
export const REFERENCE_DOCUMENT_KINDS = [
|
|
16
|
+
'spec',
|
|
17
|
+
'prd',
|
|
18
|
+
'adr',
|
|
19
|
+
'plan',
|
|
20
|
+
'issue',
|
|
21
|
+
'agent',
|
|
22
|
+
'skill',
|
|
23
|
+
'rule',
|
|
24
|
+
];
|
|
25
|
+
/** File-name suffixes that identify a Leo document family; checked in order. */
|
|
26
|
+
const DOCUMENT_SUFFIXES = [
|
|
27
|
+
['.prd.md', 'prd'],
|
|
28
|
+
['.adr.md', 'adr'],
|
|
29
|
+
['.plan.md', 'plan'],
|
|
30
|
+
['.issue.md', 'issue'],
|
|
31
|
+
['.agent.md', 'agent'],
|
|
32
|
+
['/SKILL.md', 'skill'],
|
|
33
|
+
['.mdc', 'rule'],
|
|
34
|
+
];
|
|
35
|
+
/** Classify a repository-relative path by the Leo document family its name and location imply. */
|
|
36
|
+
export function referenceDocumentKind(path) {
|
|
37
|
+
const named = DOCUMENT_SUFFIXES.find(([suffix]) => `/${path}`.endsWith(suffix));
|
|
38
|
+
if (named) {
|
|
39
|
+
return named[1];
|
|
40
|
+
}
|
|
41
|
+
const name = path.slice(path.lastIndexOf('/') + 1);
|
|
42
|
+
return /(^|\/)docs\/product\//u.test(path) && (name.endsWith('.md') || !name.includes('.'))
|
|
43
|
+
? 'spec'
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
46
|
+
/** Resolve a `target` attribute into a normalized destination, or say why it has none. */
|
|
47
|
+
export function referenceDestination(target) {
|
|
48
|
+
const parsed = parseRefTarget(target);
|
|
49
|
+
if (parsed.kind === 'invalid') {
|
|
50
|
+
return { ok: false, error: 'invalid-target', reason: parsed.reason };
|
|
51
|
+
}
|
|
52
|
+
if (parsed.kind !== 'path' && parsed.kind !== 'repo') {
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
error: 'unsupported-target',
|
|
56
|
+
reason: `${parsed.kind} targets have no document destination`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const anchor = parsed.lines
|
|
60
|
+
? { kind: 'lines', ...parsed.lines }
|
|
61
|
+
: parsed.anchor;
|
|
62
|
+
const document = referenceDocumentKind(parsed.path);
|
|
63
|
+
if ((anchor?.kind === 'phase' || anchor?.kind === 'todo') && document !== 'plan') {
|
|
64
|
+
return {
|
|
65
|
+
ok: false,
|
|
66
|
+
error: 'invalid-target',
|
|
67
|
+
reason: `a ${anchor.kind} anchor needs a plan document`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const repo = parsed.kind === 'repo' ? parsed.repo : undefined;
|
|
71
|
+
return {
|
|
72
|
+
ok: true,
|
|
73
|
+
destination: {
|
|
74
|
+
...(repo === undefined ? {} : { repo }),
|
|
75
|
+
path: parsed.path,
|
|
76
|
+
canonical: repo === undefined ? `path/${parsed.path}` : `repo/${repo}/${parsed.path}`,
|
|
77
|
+
...(document === undefined ? {} : { document }),
|
|
78
|
+
...(anchor === undefined ? {} : { anchor }),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Card attributes that select a legacy data source; a target-backed card uses none of them. */
|
|
83
|
+
const LEGACY_CARD_SELECTORS = ['type', 'ref', 'path', 'href'];
|
|
84
|
+
/** Find the references in a message. Tags inside code spans, fences and comments stay text. */
|
|
85
|
+
export function scanConversationReferences(source) {
|
|
86
|
+
const references = [];
|
|
87
|
+
let pendingFrom;
|
|
88
|
+
for (const span of scan(source)) {
|
|
89
|
+
if (isMalformedSpan(span)) {
|
|
90
|
+
if (pendingFrom === undefined && /^<leo\.(ref|card)\b/u.test(span.text)) {
|
|
91
|
+
pendingFrom = span.start;
|
|
92
|
+
}
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (!isIslandSpan(span) || (span.name !== 'ref' && span.name !== 'card')) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const component = span.name;
|
|
99
|
+
const schema = leoRegistry[component]?.props ?? {};
|
|
100
|
+
const errors = [...coerceProps(schema, span.attrs).errors];
|
|
101
|
+
const relation = span.attrs.relation;
|
|
102
|
+
if (relation !== undefined && !REF_RELATIONS.includes(relation)) {
|
|
103
|
+
errors.push(`unknown relation ${JSON.stringify(relation)}`);
|
|
104
|
+
}
|
|
105
|
+
const target = span.attrs.target;
|
|
106
|
+
const legacy = component === 'card' && target === undefined;
|
|
107
|
+
if (component === 'card' && target !== undefined) {
|
|
108
|
+
const conflicting = LEGACY_CARD_SELECTORS.filter((key) => key in span.attrs);
|
|
109
|
+
if (conflicting.length > 0) {
|
|
110
|
+
errors.push(`conflicting selectors: target with ${conflicting.join(', ')}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const result = target === undefined ? undefined : referenceDestination(target);
|
|
114
|
+
references.push({
|
|
115
|
+
component,
|
|
116
|
+
start: span.start,
|
|
117
|
+
end: span.end,
|
|
118
|
+
...(target === undefined ? {} : { target }),
|
|
119
|
+
label: span.body.trim(),
|
|
120
|
+
...(span.attrs.relation === undefined ? {} : { relation: span.attrs.relation }),
|
|
121
|
+
legacy,
|
|
122
|
+
...(result === undefined
|
|
123
|
+
? {}
|
|
124
|
+
: result.ok
|
|
125
|
+
? { destination: result.destination }
|
|
126
|
+
: { destinationError: { error: result.error, reason: result.reason } }),
|
|
127
|
+
errors,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return pendingFrom === undefined ? { references } : { references, pendingFrom };
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAkB,cAAc,EAAE,aAAa,EAAkB,MAAM,iBAAiB,CAAC;AAEhG,8DAA8D;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;CACA,CAAC;AAwBX,gFAAgF;AAChF,MAAM,iBAAiB,GAA0D;IAC7E,CAAC,SAAS,EAAE,KAAK,CAAC;IAClB,CAAC,SAAS,EAAE,KAAK,CAAC;IAClB,CAAC,UAAU,EAAE,MAAM,CAAC;IACpB,CAAC,WAAW,EAAE,OAAO,CAAC;IACtB,CAAC,WAAW,EAAE,OAAO,CAAC;IACtB,CAAC,WAAW,EAAE,OAAO,CAAC;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,kGAAkG;AAClG,MAAM,UAAU,qBAA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E,UAAU,EAAE,WAAW,EAAE,CAAC;AACpF,CAAC","sourcesContent":["/**\n * Conversation references: the `<leo.ref>` inline links and `<leo.card>` block\n * cards an agent writes into a reply, and the destination each one names.\n *\n * Parsing and destination validation live here so every host reads the same\n * contract. Hosts keep transcript placement, checkout resolution, status\n * metadata and viewer selection. fixtures/conversation-references.json holds the\n * cases both the TypeScript and Swift implementations must agree on.\n */\n\nimport { coerceProps, leoRegistry } from './registry.js';\nimport { scan } from './scanner.js';\nimport { isIslandSpan, isMalformedSpan } from './types.js';\nimport { type LineRange, parseRefTarget, REF_RELATIONS, type RefAnchor } from './vocabulary.js';\n\n/** The document families a reference destination can name. */\nexport const REFERENCE_DOCUMENT_KINDS = [\n 'spec',\n 'prd',\n 'adr',\n 'plan',\n 'issue',\n 'agent',\n 'skill',\n 'rule',\n] as const;\nexport type ReferenceDocumentKind = (typeof REFERENCE_DOCUMENT_KINDS)[number];\n\n/** Where inside the destination document to go. */\nexport type ReferenceAnchor = ({ readonly kind: 'lines' } & LineRange) | RefAnchor;\n\n/** A normalized destination: one document plus at most one anchor, kept separate. */\nexport interface ReferenceDestination {\n /** Repository id for a `repo/` target; absent for the document's own repository. */\n readonly repo?: string;\n /** Repository-relative path with no fragment. */\n readonly path: string;\n /** Stable identity of the destination document: `[repo/<id>/|path/]<path>`, no anchor. */\n readonly canonical: string;\n readonly document?: ReferenceDocumentKind;\n readonly anchor?: ReferenceAnchor;\n}\n\nexport type ReferenceDestinationError = 'unsupported-target' | 'invalid-target';\n\nexport type ReferenceDestinationResult =\n | { readonly ok: true; readonly destination: ReferenceDestination }\n | { readonly ok: false; readonly error: ReferenceDestinationError; readonly reason: string };\n\n/** File-name suffixes that identify a Leo document family; checked in order. */\nconst DOCUMENT_SUFFIXES: readonly (readonly [string, ReferenceDocumentKind])[] = [\n ['.prd.md', 'prd'],\n ['.adr.md', 'adr'],\n ['.plan.md', 'plan'],\n ['.issue.md', 'issue'],\n ['.agent.md', 'agent'],\n ['/SKILL.md', 'skill'],\n ['.mdc', 'rule'],\n];\n\n/** Classify a repository-relative path by the Leo document family its name and location imply. */\nexport function referenceDocumentKind(path: string): ReferenceDocumentKind | undefined {\n const named = DOCUMENT_SUFFIXES.find(([suffix]) => `/${path}`.endsWith(suffix));\n if (named) {\n return named[1];\n }\n const name = path.slice(path.lastIndexOf('/') + 1);\n return /(^|\\/)docs\\/product\\//u.test(path) && (name.endsWith('.md') || !name.includes('.'))\n ? 'spec'\n : undefined;\n}\n\n/** Resolve a `target` attribute into a normalized destination, or say why it has none. */\nexport function referenceDestination(target: string): ReferenceDestinationResult {\n const parsed = parseRefTarget(target);\n if (parsed.kind === 'invalid') {\n return { ok: false, error: 'invalid-target', reason: parsed.reason };\n }\n if (parsed.kind !== 'path' && parsed.kind !== 'repo') {\n return {\n ok: false,\n error: 'unsupported-target',\n reason: `${parsed.kind} targets have no document destination`,\n };\n }\n const anchor: ReferenceAnchor | undefined = parsed.lines\n ? { kind: 'lines', ...parsed.lines }\n : parsed.anchor;\n const document = referenceDocumentKind(parsed.path);\n if ((anchor?.kind === 'phase' || anchor?.kind === 'todo') && document !== 'plan') {\n return {\n ok: false,\n error: 'invalid-target',\n reason: `a ${anchor.kind} anchor needs a plan document`,\n };\n }\n const repo = parsed.kind === 'repo' ? parsed.repo : undefined;\n return {\n ok: true,\n destination: {\n ...(repo === undefined ? {} : { repo }),\n path: parsed.path,\n canonical: repo === undefined ? `path/${parsed.path}` : `repo/${repo}/${parsed.path}`,\n ...(document === undefined ? {} : { document }),\n ...(anchor === undefined ? {} : { anchor }),\n },\n };\n}\n\n/** Card attributes that select a legacy data source; a target-backed card uses none of them. */\nconst LEGACY_CARD_SELECTORS = ['type', 'ref', 'path', 'href'] as const;\n\n/** One complete `<leo.ref>` or `<leo.card>` in a message. Offsets are UTF-16 code units. */\nexport interface ConversationReference {\n readonly component: 'ref' | 'card';\n readonly start: number;\n readonly end: number;\n readonly target?: string;\n /** The authored body text; empty when the author left the host to choose a label. */\n readonly label: string;\n /** An explicit spec relationship (`implements`, `depends-on`, …); absent for a neutral ref. */\n readonly relation?: string;\n /** True for a card that names its source with `type`/`ref`/`path`/`href` instead of `target`. */\n readonly legacy: boolean;\n readonly destination?: ReferenceDestination;\n /** Why `target` has no destination; the reference still renders its label. */\n readonly destinationError?: {\n readonly error: ReferenceDestinationError;\n readonly reason: string;\n };\n /** Authoring errors (unknown props, conflicting selectors, unknown relation). */\n readonly errors: readonly string[];\n}\n\nexport interface ConversationReferenceScan {\n readonly references: readonly ConversationReference[];\n /**\n * Offset of an unfinished `<leo.ref` or `<leo.card` opener at the end of a\n * streamed message. A streaming host holds back text from here until the tag\n * completes; prose before it is unaffected.\n */\n readonly pendingFrom?: number;\n}\n\n/** Find the references in a message. Tags inside code spans, fences and comments stay text. */\nexport function scanConversationReferences(source: string): ConversationReferenceScan {\n const references: ConversationReference[] = [];\n let pendingFrom: number | undefined;\n for (const span of scan(source)) {\n if (isMalformedSpan(span)) {\n if (pendingFrom === undefined && /^<leo\\.(ref|card)\\b/u.test(span.text)) {\n pendingFrom = span.start;\n }\n continue;\n }\n if (!isIslandSpan(span) || (span.name !== 'ref' && span.name !== 'card')) {\n continue;\n }\n const component = span.name;\n const schema = leoRegistry[component]?.props ?? {};\n const errors = [...coerceProps(schema, span.attrs).errors];\n const relation = span.attrs.relation;\n if (relation !== undefined && !(REF_RELATIONS as readonly string[]).includes(relation)) {\n errors.push(`unknown relation ${JSON.stringify(relation)}`);\n }\n const target = span.attrs.target;\n const legacy = component === 'card' && target === undefined;\n if (component === 'card' && target !== undefined) {\n const conflicting = LEGACY_CARD_SELECTORS.filter((key) => key in span.attrs);\n if (conflicting.length > 0) {\n errors.push(`conflicting selectors: target with ${conflicting.join(', ')}`);\n }\n }\n const result = target === undefined ? undefined : referenceDestination(target);\n references.push({\n component,\n start: span.start,\n end: span.end,\n ...(target === undefined ? {} : { target }),\n label: span.body.trim(),\n ...(span.attrs.relation === undefined ? {} : { relation: span.attrs.relation }),\n legacy,\n ...(result === undefined\n ? {}\n : result.ok\n ? { destination: result.destination }\n : { destinationError: { error: result.error, reason: result.reason } }),\n errors,\n });\n }\n return pendingFrom === undefined ? { references } : { references, pendingFrom };\n}\n"]}
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,OAAO,KAAK,EAAc,YAAY,EAAE,WAAW,EAAY,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,OAAO,KAAK,EAAc,YAAY,EAAE,WAAW,EAAY,UAAU,EAAE,MAAM,YAAY,CAAC;AAwa9F;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAOxB,CAAC;AAIH;;;;;;GAMG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,WAAyB,GACpC,YAAY,GAAG,SAAS,CAI1B;AAED,4CAA4C;AAC5C,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,WAAyB,GAAG,OAAO,CAElF;AAID,MAAM,WAAW,YAAY;IACzB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACxC,YAAY,CA2Bd"}
|
package/dist/registry.js
CHANGED
|
@@ -81,6 +81,9 @@ const mermaidProps = {
|
|
|
81
81
|
// Body is full mermaid source (flowchart, state, class, ER, sequence,
|
|
82
82
|
// pie, mindmap, timeline, gitGraph); web target is a mermaid fence. No attrs.
|
|
83
83
|
};
|
|
84
|
+
const infraProps = {
|
|
85
|
+
// Body is the complete infra diagram source. No attributes.
|
|
86
|
+
};
|
|
84
87
|
const heatmapProps = {
|
|
85
88
|
// Body is a markdown table on terminal; the web chart reads the same cells.
|
|
86
89
|
// `data` may also arrive JSON-encoded as an attribute.
|
|
@@ -146,10 +149,23 @@ const cardProps = {
|
|
|
146
149
|
},
|
|
147
150
|
ref: { kind: 'string' },
|
|
148
151
|
path: { kind: 'string' },
|
|
152
|
+
target: {
|
|
153
|
+
kind: 'string',
|
|
154
|
+
note: 'A conversation reference target (see vocabulary.ts); excludes type/ref/path/href on the same card.',
|
|
155
|
+
},
|
|
149
156
|
title: { kind: 'string' },
|
|
150
157
|
description: { kind: 'string' },
|
|
151
158
|
href: { kind: 'string' },
|
|
152
159
|
};
|
|
160
|
+
// A neutral inline reference unless `relation` names a spec relationship. The
|
|
161
|
+
// body is the authored label; the destination comes from `target`.
|
|
162
|
+
const refProps = {
|
|
163
|
+
target: { kind: 'string', required: true },
|
|
164
|
+
relation: {
|
|
165
|
+
kind: 'string',
|
|
166
|
+
note: 'One of REF_RELATIONS (vocabulary.ts), checked by scanConversationReferences; kept a string here because vocabulary.ts imports this module.',
|
|
167
|
+
},
|
|
168
|
+
};
|
|
153
169
|
const metricProps = {
|
|
154
170
|
// web Metric (KPI) is the origin; the ANSI emitter renders label+value+trend.
|
|
155
171
|
label: { kind: 'string' },
|
|
@@ -214,6 +230,7 @@ const sharedBoth = {
|
|
|
214
230
|
props: comparisonTableProps,
|
|
215
231
|
}),
|
|
216
232
|
mermaid: entry({ name: 'mermaid', targets: 'both', props: mermaidProps }),
|
|
233
|
+
infra: entry({ name: 'infra', targets: 'both', props: infraProps }),
|
|
217
234
|
heatmap: entry({ name: 'heatmap', targets: 'both', props: heatmapProps }),
|
|
218
235
|
};
|
|
219
236
|
/**
|
|
@@ -256,11 +273,19 @@ const subComponents = {
|
|
|
256
273
|
}),
|
|
257
274
|
};
|
|
258
275
|
/**
|
|
259
|
-
* terminal-only (
|
|
260
|
-
*
|
|
261
|
-
*
|
|
276
|
+
* terminal-only (3): ref is a conversation reference the terminal and native
|
|
277
|
+
* hosts resolve (web degrades it to its label); git-status reads live git state;
|
|
278
|
+
* question is a chat/CLI question prompt (option/notes above are its nested
|
|
279
|
+
* sub-components). git-status and question degrade to a static note.
|
|
262
280
|
*/
|
|
263
281
|
const terminalOnly = {
|
|
282
|
+
ref: entry({
|
|
283
|
+
name: 'ref',
|
|
284
|
+
flow: 'inline',
|
|
285
|
+
targets: 'terminal-only',
|
|
286
|
+
props: refProps,
|
|
287
|
+
degrade: inlineDegrade,
|
|
288
|
+
}),
|
|
264
289
|
'git-status': entry({
|
|
265
290
|
name: 'git-status',
|
|
266
291
|
targets: 'terminal-only',
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,iFAAiF;AAEjF,MAAM,YAAY,GAAe;IAC7B,4EAA4E;IAC5E,kEAAkE;IAClE,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;QAChD,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,0FAA0F;KACnG;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC5B,CAAC;AAEF,MAAM,UAAU,GAAe;IAC3B,6EAA6E;IAC7E,0BAA0B;IAC1B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,E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AE,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,sBAAsB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACrE,OAAO,SAAS,CAAC;YACrB,CAAC;YACD,OAAO,CAAC,CAAC;QACb,CAAC;QACD,KAAK,SAAS;YACV,oEAAoE;YACpE,OAAO,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,MAAM,CAAC;QACxC,KAAK,MAAM,EAAE,CAAC;YACV,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,IAAI,CACP,SAAS,GAAG,oBAAoB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CACtF,CAAC;gBACF,OAAO,IAAI,CAAC,OAAO,CAAC;YACxB,CAAC;YACD,OAAO,GAAG,CAAC;QACf,CAAC;QACD,KAAK,MAAM,EAAE,CAAC;YACV,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,CAAC;gBAC/C,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QACD;YACI,OAAO,GAAG,CAAC;IACnB,CAAC;AACL,CAAC","sourcesContent":["/**\n * The `leo` registry — the allow-list.\n *\n * A single object keyed by the LOWERCASE authored name (`leo.callout` resolves\n * `registry['callout']`). Each entry declares its `targets`, its canonical\n * `PropSchema` (the one contract both the ANSI and web emitters adapt to), its\n * Markdown flow placement,\n * and a `degrade` strategy for any surface it does not target.\n *\n * EMITTERS ARE NOT WIRED HERE. This module declares the vocabulary, targets,\n * placement, and prop schemas; the concrete `ansi` emitters are attached by\n * leo-pty-renderer and the `web` emitters by leo-doc-web.\n * The parity harness (src/parity.ts) checks the contract against whatever\n * registry it is given; the FULLY-WIRED registry only satisfies the `both`\n * entries once those emitters are attached.\n *\n * Prop-schema conflicts: where leo's ANSI attrs and Glottodoc's web props\n * disagree, leo's ANSI attrs WIN (the smaller, stable subset). Each such\n * choice is recorded inline as a `note` on the prop so the canonical decision is\n * auditable.\n */\n\nimport {\n AGENT_SUPPORT_AGENTS,\n AGENT_SUPPORT_QUALIFIERS,\n AGENT_SUPPORT_STATES,\n} from './agent-support.js';\nimport type { IslandFlow, LeoComponent, LeoRegistry, PropDecl, PropSchema } from './types.js';\n\n// ── Canonical prop schemas (grounded in the leo-pty-renderer ANSI signatures) ─\n\nconst calloutProps: PropSchema = {\n // leo ANSI CalloutType is the canonical enum (info|warning|success|danger);\n // Glottodoc's web Callout adapts its richer type list onto these.\n type: {\n kind: 'enum',\n values: ['info', 'warning', 'success', 'danger'],\n default: 'info',\n note: 'ANSI-wins: canonical enum is leo CalloutType; web maps note/tip/error/danger onto these.',\n },\n title: { kind: 'string' },\n};\n\nconst badgeProps: PropSchema = {\n // ANSI renderBadge(value): the value may also come from the body; the schema\n // declares the attr form.\n value: { kind: 'string' },\n};\n\n// StatusBadge ↔ leo `capsule`/`status`. Canonical authored name is `statusbadge`\n// (lowercase of the vocabulary entry); the ANSI side is renderCapsule(value).\nconst statusBadgeProps: PropSchema = {\n value: {\n kind: 'string',\n note: 'ANSI-wins: leo capsule/status takes a single `value`; web StatusBadge label maps to it.',\n },\n};\n\nconst agentSupportProps: PropSchema = {\n agent: { kind: 'enum', values: AGENT_SUPPORT_AGENTS, required: true },\n support: { kind: 'enum', values: AGENT_SUPPORT_STATES, required: true },\n qualifier: { kind: 'enum', values: AGENT_SUPPORT_QUALIFIERS },\n};\n\nconst stepsProps: PropSchema = {\n // Container; steps are nested <leo.step> islands (auto-numbered both sides).\n};\n\nconst stepProps: PropSchema = {\n title: { kind: 'string' },\n};\n\nconst treeProps: PropSchema = {\n // Container; nodes are nested <leo.folder>/<leo.file> islands.\n};\n\nconst treeNodeProps: PropSchema = {\n name: { kind: 'string', required: true },\n comment: { kind: 'string' },\n highlight: { kind: 'boolean', default: false },\n plainIcon: { kind: 'string' },\n};\n\nconst comparisonTableProps: PropSchema = {\n // Body is a markdown table; these are ANSI-only presentation hints (web\n // ignores them) — ANSI-wins by definition.\n highlight: {\n kind: 'string',\n note: 'ANSI-only presentation hint (row label to highlight); web has no equivalent.',\n },\n wrap: {\n kind: 'number',\n note: 'ANSI-only column-wrap width; web has no equivalent.',\n },\n};\n\nconst mermaidProps: PropSchema = {\n // Body is full mermaid source (flowchart, state, class, ER, sequence,\n // pie, mindmap, timeline, gitGraph); web target is a mermaid fence. No attrs.\n};\n\nconst heatmapProps: PropSchema = {\n // Body is a markdown table on terminal; the web chart reads the same cells.\n // `data` may also arrive JSON-encoded as an attribute.\n data: {\n kind: 'json',\n note: 'Same data, different form: ANSI table ⟷ web chart. JSON-coerced when given as an attr.',\n },\n};\n\nconst gitStatusProps: PropSchema = {\n // terminal-only: reads live git state; no web equivalent.\n};\n\nconst questionProps: PropSchema = {\n // Container; options are nested <leo.option> islands, notes is a nested\n // <leo.notes> island. Terminal-only — a chat question has no web analogue.\n prompt: { kind: 'string', required: true },\n label: { kind: 'string' },\n type: {\n kind: 'enum',\n values: ['architecture'],\n note: 'Prefixes the headline with the resolved leo-adr glyph (patched font, 🏛️ emoji fallback) — flags a decision that would set precedent across surfaces (new package, third-party dep, cross-package contract), same signal as the 🏛 marker in the spec-author skill.',\n },\n urgency: { kind: 'enum', values: ['low', 'normal', 'blocker'], default: 'normal' },\n multiSelect: { kind: 'boolean', default: false },\n freeText: { kind: 'boolean', default: false },\n recommendation: { kind: 'string', note: 'the recommended <leo.option key=...> value' },\n hint: {\n kind: 'boolean',\n default: true,\n note: 'Shows the trailing \"how to answer\" callout once per batch/message; set false on any question in the batch to suppress it (e.g. once the user already knows the convention).',\n },\n};\n\nconst optionProps: PropSchema = {\n key: { kind: 'string', required: true },\n label: { kind: 'string', required: true },\n recommendation: { kind: 'enum', values: ['high', 'medium', 'low', 'not-recommended'] },\n freeText: { kind: 'boolean', default: false },\n};\n\nconst notesProps: PropSchema = {\n // Container; body is markdown (rendered via renderMarkdown, fence-aware).\n};\n\n// ── Port-backs (flipped to `both`) ───────────────────────────────────────────\n\nconst progressProps: PropSchema = {\n // ANSI renderProgress(value, total, label, width). `width` is an ANSI-only\n // bar-width hint; web derives its own width from layout (ANSI-wins).\n value: { kind: 'number', default: 0 },\n total: { kind: 'number', default: 100 },\n label: { kind: 'string' },\n width: {\n kind: 'number',\n default: 20,\n note: 'ANSI-only bar width; web sizes from layout.',\n },\n};\n\nconst cardProps: PropSchema = {\n // The card resolver dispatches on `type` (plan/issue/review-dash/doc) on the\n // live ANSI path; `ref`/`path` carry the data-source. The web side maps onto\n // RichLink/MdxCard. Title/description are the generic fallback both surfaces\n // can render without a data source.\n type: {\n kind: 'enum',\n values: ['plan', 'issue', 'review-dash', 'doc'],\n note: 'ANSI-wins: the leo card-resolver dispatches on these types; web maps them onto RichLink/MdxCard.',\n },\n ref: { kind: 'string' },\n path: { kind: 'string' },\n title: { kind: 'string' },\n description: { kind: 'string' },\n href: { kind: 'string' },\n};\n\nconst metricProps: PropSchema = {\n // web Metric (KPI) is the origin; the ANSI emitter renders label+value+trend.\n label: { kind: 'string' },\n value: { kind: 'string' },\n trend: {\n kind: 'enum',\n values: ['up', 'down', 'flat'],\n note: 'ANSI-wins: canonical trend enum (up|down|flat); the ANSI glyph + web arrow both map to it.',\n },\n change: { kind: 'string' },\n};\n\nconst iconProps: PropSchema = {\n // web Icon (lucide) is the origin; the ANSI emitter resolves a leo glyph/emoji.\n icon: { kind: 'string' },\n color: { kind: 'string' },\n size: {\n kind: 'string',\n note: 'web-only sizing hint (px); the ANSI glyph is single-cell.',\n },\n};\n\n// web-only props are intentionally permissive for now — the absorbed React\n// components carry their own prop handling; the canonical schema is\n// filled in as those components are absorbed. Empty schemas here keep the\n// allow-list complete without over-specifying ahead of the absorb.\nconst emptyProps: PropSchema = {};\n\n// ── degrade strategies ────────────────────────────────────────────────────────\n\nconst inlineDegrade = { kind: 'inline' } as const;\nconst stackDegrade = { kind: 'inline' } as const;\nconst flatListDegrade = { kind: 'inline' } as const;\nconst omitDegrade = { kind: 'omit' } as const;\nconst noteDegrade = { kind: 'note', text: 'see terminal' } as const;\n\n// ── entry helpers ─────────────────────────────────────────────────────────────\n\nfunction entry(c: Omit<LeoComponent, 'flow'> & { readonly flow?: IslandFlow }): LeoComponent {\n return { flow: 'block', ...c };\n}\n\n// ── The registry ──────────────────────────────────────────────────────────────\n//\n// Keys are the LOWERCASE authored names. Emitters (`ansi`/`web`) are attached by\n// leo-pty-renderer and leo-doc-web; here only `targets`, `props`, and\n// (off-surface) `degrade` are set.\n\n/** Shared `targets: both` entries (parity-enforced once emitters land). */\nconst sharedBoth: Record<string, LeoComponent> = {\n callout: entry({ name: 'callout', targets: 'both', props: calloutProps }),\n badge: entry({ name: 'badge', flow: 'inline', targets: 'both', props: badgeProps }),\n statusbadge: entry({\n name: 'statusbadge',\n flow: 'inline',\n targets: 'both',\n props: statusBadgeProps,\n }),\n agentsupport: entry({\n name: 'agentsupport',\n flow: 'inline',\n targets: 'both',\n props: agentSupportProps,\n }),\n steps: entry({ name: 'steps', targets: 'both', props: stepsProps }),\n tree: entry({ name: 'tree', targets: 'both', props: treeProps }),\n comparisontable: entry({\n name: 'comparisontable',\n targets: 'both',\n props: comparisonTableProps,\n }),\n mermaid: entry({ name: 'mermaid', targets: 'both', props: mermaidProps }),\n heatmap: entry({ name: 'heatmap', targets: 'both', props: heatmapProps }),\n};\n\n/**\n * Port-backs — now `targets: 'both'`. Each gained its second-surface\n * emitter (progress/card → web; metric/icon → terminal), so they\n * render to both surfaces and the parity harness enforces both emitters.\n */\nconst portBacks: Record<string, LeoComponent> = {\n progress: entry({ name: 'progress', targets: 'both', props: progressProps }),\n card: entry({ name: 'card', targets: 'both', props: cardProps }),\n metric: entry({ name: 'metric', targets: 'both', props: metricProps }),\n icon: entry({ name: 'icon', flow: 'inline', targets: 'both', props: iconProps }),\n};\n\n/**\n * Sub-components nested inside container `both` entries. `step`, `folder`, `file`\n * are resolved by the scanner within a parent body, not standalone — they ride\n * their parent's parity, so they are declared `both` with the parent and carry\n * no independent degrade.\n */\nconst subComponents: Record<string, LeoComponent> = {\n step: entry({ name: 'step', targets: 'both', props: stepProps }),\n folder: entry({ name: 'folder', targets: 'both', props: treeNodeProps }),\n file: entry({ name: 'file', targets: 'both', props: treeNodeProps }),\n // Abstract IA node (not a file/folder) — same tree container semantics as\n // folder (parseTreeNodeList treats folder/node identically as containers).\n node: entry({ name: 'node', targets: 'both', props: treeNodeProps }),\n // question/option/notes are terminal-only (see terminalOnly below), so\n // their sub-components ride THAT parity, not `both`.\n option: entry({\n name: 'option',\n targets: 'terminal-only',\n props: optionProps,\n degrade: noteDegrade,\n }),\n notes: entry({\n name: 'notes',\n targets: 'terminal-only',\n props: notesProps,\n degrade: noteDegrade,\n }),\n};\n\n/**\n * terminal-only (2): git-status reads live git state; question is a chat/CLI\n * question prompt (option/notes above are its nested sub-components). Neither\n * has a web equivalent — both degrade to a static note.\n */\nconst terminalOnly: Record<string, LeoComponent> = {\n 'git-status': entry({\n name: 'git-status',\n targets: 'terminal-only',\n props: gitStatusProps,\n degrade: noteDegrade,\n }),\n question: entry({\n name: 'question',\n targets: 'terminal-only',\n props: questionProps,\n degrade: noteDegrade,\n }),\n};\n\n/**\n * web-only entries that DEGRADE TO INLINE on terminal. Declared\n * so authored docs don't error on terminal — they degrade per strategy. The web\n * emitters are wired by leo-doc-web; here only targets + degrade are pinned.\n */\nconst webOnlyInline: Record<string, LeoComponent> = {\n accordion: entry({\n name: 'accordion',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n expandable: entry({\n name: 'expandable',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n tabs: entry({ name: 'tabs', targets: 'web-only', props: emptyProps, degrade: inlineDegrade }),\n tooltip: entry({\n name: 'tooltip',\n flow: 'inline',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n columns: entry({\n name: 'columns',\n targets: 'web-only',\n props: emptyProps,\n degrade: stackDegrade,\n }),\n tiles: entry({ name: 'tiles', targets: 'web-only', props: emptyProps, degrade: stackDegrade }),\n toc: entry({ name: 'toc', targets: 'web-only', props: emptyProps, degrade: flatListDegrade }),\n};\n\n/**\n * web-only entries with NO terminal meaning — they\n * omit on terminal. Charts/images/embeds/nav-context + ProfileCard/ReadingGuide.\n */\nconst webOnlyOmit: Record<string, LeoComponent> = {\n scoreradar: entry({\n name: 'scoreradar',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n starchart: entry({\n name: 'starchart',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n imagegallery: entry({\n name: 'imagegallery',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n imagelightbox: entry({\n name: 'imagelightbox',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n clickableimage: entry({\n name: 'clickableimage',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n frame: entry({ name: 'frame', targets: 'web-only', props: emptyProps, degrade: omitDegrade }),\n subpagelist: entry({\n name: 'subpagelist',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n subpagegrid: entry({\n name: 'subpagegrid',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n pagetable: entry({\n name: 'pagetable',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n pagecards: entry({\n name: 'pagecards',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n profilecard: entry({\n name: 'profilecard',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n readingguide: entry({\n name: 'readingguide',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n};\n\n/**\n * The canonical leo registry. Frozen so callers cannot mutate the allow-list at\n * runtime. The port-backs (progress, card, metric, icon) are now `both`\n * (their second-surface emitters have landed).\n */\nexport const leoRegistry: LeoRegistry = Object.freeze({\n ...sharedBoth,\n ...portBacks,\n ...subComponents,\n ...terminalOnly,\n ...webOnlyInline,\n ...webOnlyOmit,\n});\n\n// ── Resolution ────────────────────────────────────────────────────────────────\n\n/**\n * Resolve a lowercase authored name (`callout`) to its registry entry, against\n * the provided registry root (the renderer always provides one — a missing root\n * is a programmer error). Returns `undefined` for an unknown name; the\n * caller treats unknown `<leo.X>` as an authoring error (a lint surfaces it —\n * never silently rendered).\n */\nexport function resolve(\n name: string,\n registry: LeoRegistry = leoRegistry\n): LeoComponent | undefined {\n // Guard with hasOwn so an inherited member (`toString`, `constructor`) never\n // resolves as a fake island — `<leo.toString>` must be unknown, not a fn.\n return Object.hasOwn(registry, name) ? registry[name] : undefined;\n}\n\n/** True iff `name` is in the allow-list. */\nexport function isKnown(name: string, registry: LeoRegistry = leoRegistry): boolean {\n return Object.hasOwn(registry, name);\n}\n\n// ── Prop coercion ─────────────────────────────────────────────────────────────\n\nexport interface CoerceResult {\n /** Coerced props (defaults applied, types converted). */\n readonly props: Record<string, unknown>;\n /** Validation errors (unknown enum value, missing required, bad JSON). */\n readonly errors: readonly string[];\n}\n\n/**\n * Coerce/validate raw (string) scanned attrs against a component's PropSchema.\n * Attributes arrive as strings; per-prop the schema converts to the\n * declared kind, applies defaults, and validates enums / required / JSON. An\n * unknown attr (not in the schema) is dropped with a recorded error — the schema\n * is the contract.\n */\nexport function coerceProps(\n schema: PropSchema,\n attrs: Readonly<Record<string, string>>\n): CoerceResult {\n const props: Record<string, unknown> = {};\n const errors: string[] = [];\n\n for (const [key, decl] of Object.entries(schema)) {\n const raw = attrs[key];\n if (raw === undefined) {\n if (decl.required) {\n errors.push(`missing required prop \"${key}\"`);\n } else if (decl.default !== undefined) {\n props[key] = decl.default;\n }\n continue;\n }\n const coerced = coerceOne(key, decl, raw, errors);\n if (coerced !== undefined) {\n props[key] = coerced;\n }\n }\n\n for (const key of Object.keys(attrs)) {\n if (!Object.hasOwn(schema, key)) {\n errors.push(`unknown prop \"${key}\"`);\n }\n }\n\n return { props, errors };\n}\n\nfunction coerceOne(key: string, decl: PropDecl, raw: string, errors: string[]): unknown {\n switch (decl.kind) {\n case 'string':\n return raw;\n case 'number': {\n const n = Number(raw);\n if (Number.isNaN(n)) {\n errors.push(`prop \"${key}\" is not a number: ${JSON.stringify(raw)}`);\n return undefined;\n }\n return n;\n }\n case 'boolean':\n // Bare attr (`highlight`) arrives as \"\" → true; `=\"false\"` → false.\n return raw === '' || raw === 'true';\n case 'enum': {\n if (decl.values && !decl.values.includes(raw)) {\n errors.push(\n `prop \"${key}\" must be one of ${decl.values.join('|')}, got ${JSON.stringify(raw)}`\n );\n return decl.default;\n }\n return raw;\n }\n case 'json': {\n try {\n return JSON.parse(raw);\n } catch {\n errors.push(`prop \"${key}\" is not valid JSON`);\n return undefined;\n }\n }\n default:\n return raw;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,iFAAiF;AAEjF,MAAM,YAAY,GAAe;IAC7B,4EAA4E;IAC5E,kEAAkE;IAClE,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;QAChD,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,0FAA0F;KACnG;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC5B,CAAC;AAEF,MAAM,UAAU,GAAe;IAC3B,6EAA6E;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,EAAE,CACtF,CAAC;gBACF,OAAO,IAAI,CAAC,OAAO,CAAC;YACxB,CAAC;YACD,OAAO,GAAG,CAAC;QACf,CAAC;QACD,KAAK,MAAM,EAAE,CAAC;YACV,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,CAAC;gBAC/C,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QACD;YACI,OAAO,GAAG,CAAC;IACnB,CAAC;AACL,CAAC","sourcesContent":["/**\n * The `leo` registry — the allow-list.\n *\n * A single object keyed by the LOWERCASE authored name (`leo.callout` resolves\n * `registry['callout']`). Each entry declares its `targets`, its canonical\n * `PropSchema` (the one contract both the ANSI and web emitters adapt to), its\n * Markdown flow placement,\n * and a `degrade` strategy for any surface it does not target.\n *\n * EMITTERS ARE NOT WIRED HERE. This module declares the vocabulary, targets,\n * placement, and prop schemas; the concrete `ansi` emitters are attached by\n * leo-pty-renderer and the `web` emitters by leo-doc-web.\n * The parity harness (src/parity.ts) checks the contract against whatever\n * registry it is given; the FULLY-WIRED registry only satisfies the `both`\n * entries once those emitters are attached.\n *\n * Prop-schema conflicts: where leo's ANSI attrs and Glottodoc's web props\n * disagree, leo's ANSI attrs WIN (the smaller, stable subset). Each such\n * choice is recorded inline as a `note` on the prop so the canonical decision is\n * auditable.\n */\n\nimport {\n AGENT_SUPPORT_AGENTS,\n AGENT_SUPPORT_QUALIFIERS,\n AGENT_SUPPORT_STATES,\n} from './agent-support.js';\nimport type { IslandFlow, LeoComponent, LeoRegistry, PropDecl, PropSchema } from './types.js';\n\n// ── Canonical prop schemas (grounded in the leo-pty-renderer ANSI signatures) ─\n\nconst calloutProps: PropSchema = {\n // leo ANSI CalloutType is the canonical enum (info|warning|success|danger);\n // Glottodoc's web Callout adapts its richer type list onto these.\n type: {\n kind: 'enum',\n values: ['info', 'warning', 'success', 'danger'],\n default: 'info',\n note: 'ANSI-wins: canonical enum is leo CalloutType; web maps note/tip/error/danger onto these.',\n },\n title: { kind: 'string' },\n};\n\nconst badgeProps: PropSchema = {\n // ANSI renderBadge(value): the value may also come from the body; the schema\n // declares the attr form.\n value: { kind: 'string' },\n};\n\n// StatusBadge ↔ leo `capsule`/`status`. Canonical authored name is `statusbadge`\n// (lowercase of the vocabulary entry); the ANSI side is renderCapsule(value).\nconst statusBadgeProps: PropSchema = {\n value: {\n kind: 'string',\n note: 'ANSI-wins: leo capsule/status takes a single `value`; web StatusBadge label maps to it.',\n },\n};\n\nconst agentSupportProps: PropSchema = {\n agent: { kind: 'enum', values: AGENT_SUPPORT_AGENTS, required: true },\n support: { kind: 'enum', values: AGENT_SUPPORT_STATES, required: true },\n qualifier: { kind: 'enum', values: AGENT_SUPPORT_QUALIFIERS },\n};\n\nconst stepsProps: PropSchema = {\n // Container; steps are nested <leo.step> islands (auto-numbered both sides).\n};\n\nconst stepProps: PropSchema = {\n title: { kind: 'string' },\n};\n\nconst treeProps: PropSchema = {\n // Container; nodes are nested <leo.folder>/<leo.file> islands.\n};\n\nconst treeNodeProps: PropSchema = {\n name: { kind: 'string', required: true },\n comment: { kind: 'string' },\n highlight: { kind: 'boolean', default: false },\n plainIcon: { kind: 'string' },\n};\n\nconst comparisonTableProps: PropSchema = {\n // Body is a markdown table; these are ANSI-only presentation hints (web\n // ignores them) — ANSI-wins by definition.\n highlight: {\n kind: 'string',\n note: 'ANSI-only presentation hint (row label to highlight); web has no equivalent.',\n },\n wrap: {\n kind: 'number',\n note: 'ANSI-only column-wrap width; web has no equivalent.',\n },\n};\n\nconst mermaidProps: PropSchema = {\n // Body is full mermaid source (flowchart, state, class, ER, sequence,\n // pie, mindmap, timeline, gitGraph); web target is a mermaid fence. No attrs.\n};\n\nconst infraProps: PropSchema = {\n // Body is the complete infra diagram source. No attributes.\n};\n\nconst heatmapProps: PropSchema = {\n // Body is a markdown table on terminal; the web chart reads the same cells.\n // `data` may also arrive JSON-encoded as an attribute.\n data: {\n kind: 'json',\n note: 'Same data, different form: ANSI table ⟷ web chart. JSON-coerced when given as an attr.',\n },\n};\n\nconst gitStatusProps: PropSchema = {\n // terminal-only: reads live git state; no web equivalent.\n};\n\nconst questionProps: PropSchema = {\n // Container; options are nested <leo.option> islands, notes is a nested\n // <leo.notes> island. Terminal-only — a chat question has no web analogue.\n prompt: { kind: 'string', required: true },\n label: { kind: 'string' },\n type: {\n kind: 'enum',\n values: ['architecture'],\n note: 'Prefixes the headline with the resolved leo-adr glyph (patched font, 🏛️ emoji fallback) — flags a decision that would set precedent across surfaces (new package, third-party dep, cross-package contract), same signal as the 🏛 marker in the spec-author skill.',\n },\n urgency: { kind: 'enum', values: ['low', 'normal', 'blocker'], default: 'normal' },\n multiSelect: { kind: 'boolean', default: false },\n freeText: { kind: 'boolean', default: false },\n recommendation: { kind: 'string', note: 'the recommended <leo.option key=...> value' },\n hint: {\n kind: 'boolean',\n default: true,\n note: 'Shows the trailing \"how to answer\" callout once per batch/message; set false on any question in the batch to suppress it (e.g. once the user already knows the convention).',\n },\n};\n\nconst optionProps: PropSchema = {\n key: { kind: 'string', required: true },\n label: { kind: 'string', required: true },\n recommendation: { kind: 'enum', values: ['high', 'medium', 'low', 'not-recommended'] },\n freeText: { kind: 'boolean', default: false },\n};\n\nconst notesProps: PropSchema = {\n // Container; body is markdown (rendered via renderMarkdown, fence-aware).\n};\n\n// ── Port-backs (flipped to `both`) ───────────────────────────────────────────\n\nconst progressProps: PropSchema = {\n // ANSI renderProgress(value, total, label, width). `width` is an ANSI-only\n // bar-width hint; web derives its own width from layout (ANSI-wins).\n value: { kind: 'number', default: 0 },\n total: { kind: 'number', default: 100 },\n label: { kind: 'string' },\n width: {\n kind: 'number',\n default: 20,\n note: 'ANSI-only bar width; web sizes from layout.',\n },\n};\n\nconst cardProps: PropSchema = {\n // The card resolver dispatches on `type` (plan/issue/review-dash/doc) on the\n // live ANSI path; `ref`/`path` carry the data-source. The web side maps onto\n // RichLink/MdxCard. Title/description are the generic fallback both surfaces\n // can render without a data source.\n type: {\n kind: 'enum',\n values: ['plan', 'issue', 'review-dash', 'doc'],\n note: 'ANSI-wins: the leo card-resolver dispatches on these types; web maps them onto RichLink/MdxCard.',\n },\n ref: { kind: 'string' },\n path: { kind: 'string' },\n target: {\n kind: 'string',\n note: 'A conversation reference target (see vocabulary.ts); excludes type/ref/path/href on the same card.',\n },\n title: { kind: 'string' },\n description: { kind: 'string' },\n href: { kind: 'string' },\n};\n\n// A neutral inline reference unless `relation` names a spec relationship. The\n// body is the authored label; the destination comes from `target`.\nconst refProps: PropSchema = {\n target: { kind: 'string', required: true },\n relation: {\n kind: 'string',\n note: 'One of REF_RELATIONS (vocabulary.ts), checked by scanConversationReferences; kept a string here because vocabulary.ts imports this module.',\n },\n};\n\nconst metricProps: PropSchema = {\n // web Metric (KPI) is the origin; the ANSI emitter renders label+value+trend.\n label: { kind: 'string' },\n value: { kind: 'string' },\n trend: {\n kind: 'enum',\n values: ['up', 'down', 'flat'],\n note: 'ANSI-wins: canonical trend enum (up|down|flat); the ANSI glyph + web arrow both map to it.',\n },\n change: { kind: 'string' },\n};\n\nconst iconProps: PropSchema = {\n // web Icon (lucide) is the origin; the ANSI emitter resolves a leo glyph/emoji.\n icon: { kind: 'string' },\n color: { kind: 'string' },\n size: {\n kind: 'string',\n note: 'web-only sizing hint (px); the ANSI glyph is single-cell.',\n },\n};\n\n// web-only props are intentionally permissive for now — the absorbed React\n// components carry their own prop handling; the canonical schema is\n// filled in as those components are absorbed. Empty schemas here keep the\n// allow-list complete without over-specifying ahead of the absorb.\nconst emptyProps: PropSchema = {};\n\n// ── degrade strategies ────────────────────────────────────────────────────────\n\nconst inlineDegrade = { kind: 'inline' } as const;\nconst stackDegrade = { kind: 'inline' } as const;\nconst flatListDegrade = { kind: 'inline' } as const;\nconst omitDegrade = { kind: 'omit' } as const;\nconst noteDegrade = { kind: 'note', text: 'see terminal' } as const;\n\n// ── entry helpers ─────────────────────────────────────────────────────────────\n\nfunction entry(c: Omit<LeoComponent, 'flow'> & { readonly flow?: IslandFlow }): LeoComponent {\n return { flow: 'block', ...c };\n}\n\n// ── The registry ──────────────────────────────────────────────────────────────\n//\n// Keys are the LOWERCASE authored names. Emitters (`ansi`/`web`) are attached by\n// leo-pty-renderer and leo-doc-web; here only `targets`, `props`, and\n// (off-surface) `degrade` are set.\n\n/** Shared `targets: both` entries (parity-enforced once emitters land). */\nconst sharedBoth: Record<string, LeoComponent> = {\n callout: entry({ name: 'callout', targets: 'both', props: calloutProps }),\n badge: entry({ name: 'badge', flow: 'inline', targets: 'both', props: badgeProps }),\n statusbadge: entry({\n name: 'statusbadge',\n flow: 'inline',\n targets: 'both',\n props: statusBadgeProps,\n }),\n agentsupport: entry({\n name: 'agentsupport',\n flow: 'inline',\n targets: 'both',\n props: agentSupportProps,\n }),\n steps: entry({ name: 'steps', targets: 'both', props: stepsProps }),\n tree: entry({ name: 'tree', targets: 'both', props: treeProps }),\n comparisontable: entry({\n name: 'comparisontable',\n targets: 'both',\n props: comparisonTableProps,\n }),\n mermaid: entry({ name: 'mermaid', targets: 'both', props: mermaidProps }),\n infra: entry({ name: 'infra', targets: 'both', props: infraProps }),\n heatmap: entry({ name: 'heatmap', targets: 'both', props: heatmapProps }),\n};\n\n/**\n * Port-backs — now `targets: 'both'`. Each gained its second-surface\n * emitter (progress/card → web; metric/icon → terminal), so they\n * render to both surfaces and the parity harness enforces both emitters.\n */\nconst portBacks: Record<string, LeoComponent> = {\n progress: entry({ name: 'progress', targets: 'both', props: progressProps }),\n card: entry({ name: 'card', targets: 'both', props: cardProps }),\n metric: entry({ name: 'metric', targets: 'both', props: metricProps }),\n icon: entry({ name: 'icon', flow: 'inline', targets: 'both', props: iconProps }),\n};\n\n/**\n * Sub-components nested inside container `both` entries. `step`, `folder`, `file`\n * are resolved by the scanner within a parent body, not standalone — they ride\n * their parent's parity, so they are declared `both` with the parent and carry\n * no independent degrade.\n */\nconst subComponents: Record<string, LeoComponent> = {\n step: entry({ name: 'step', targets: 'both', props: stepProps }),\n folder: entry({ name: 'folder', targets: 'both', props: treeNodeProps }),\n file: entry({ name: 'file', targets: 'both', props: treeNodeProps }),\n // Abstract IA node (not a file/folder) — same tree container semantics as\n // folder (parseTreeNodeList treats folder/node identically as containers).\n node: entry({ name: 'node', targets: 'both', props: treeNodeProps }),\n // question/option/notes are terminal-only (see terminalOnly below), so\n // their sub-components ride THAT parity, not `both`.\n option: entry({\n name: 'option',\n targets: 'terminal-only',\n props: optionProps,\n degrade: noteDegrade,\n }),\n notes: entry({\n name: 'notes',\n targets: 'terminal-only',\n props: notesProps,\n degrade: noteDegrade,\n }),\n};\n\n/**\n * terminal-only (3): ref is a conversation reference the terminal and native\n * hosts resolve (web degrades it to its label); git-status reads live git state;\n * question is a chat/CLI question prompt (option/notes above are its nested\n * sub-components). git-status and question degrade to a static note.\n */\nconst terminalOnly: Record<string, LeoComponent> = {\n ref: entry({\n name: 'ref',\n flow: 'inline',\n targets: 'terminal-only',\n props: refProps,\n degrade: inlineDegrade,\n }),\n 'git-status': entry({\n name: 'git-status',\n targets: 'terminal-only',\n props: gitStatusProps,\n degrade: noteDegrade,\n }),\n question: entry({\n name: 'question',\n targets: 'terminal-only',\n props: questionProps,\n degrade: noteDegrade,\n }),\n};\n\n/**\n * web-only entries that DEGRADE TO INLINE on terminal. Declared\n * so authored docs don't error on terminal — they degrade per strategy. The web\n * emitters are wired by leo-doc-web; here only targets + degrade are pinned.\n */\nconst webOnlyInline: Record<string, LeoComponent> = {\n accordion: entry({\n name: 'accordion',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n expandable: entry({\n name: 'expandable',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n tabs: entry({ name: 'tabs', targets: 'web-only', props: emptyProps, degrade: inlineDegrade }),\n tooltip: entry({\n name: 'tooltip',\n flow: 'inline',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n columns: entry({\n name: 'columns',\n targets: 'web-only',\n props: emptyProps,\n degrade: stackDegrade,\n }),\n tiles: entry({ name: 'tiles', targets: 'web-only', props: emptyProps, degrade: stackDegrade }),\n toc: entry({ name: 'toc', targets: 'web-only', props: emptyProps, degrade: flatListDegrade }),\n};\n\n/**\n * web-only entries with NO terminal meaning — they\n * omit on terminal. Charts/images/embeds/nav-context + ProfileCard/ReadingGuide.\n */\nconst webOnlyOmit: Record<string, LeoComponent> = {\n scoreradar: entry({\n name: 'scoreradar',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n starchart: entry({\n name: 'starchart',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n imagegallery: entry({\n name: 'imagegallery',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n imagelightbox: entry({\n name: 'imagelightbox',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n clickableimage: entry({\n name: 'clickableimage',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n frame: entry({ name: 'frame', targets: 'web-only', props: emptyProps, degrade: omitDegrade }),\n subpagelist: entry({\n name: 'subpagelist',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n subpagegrid: entry({\n name: 'subpagegrid',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n pagetable: entry({\n name: 'pagetable',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n pagecards: entry({\n name: 'pagecards',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n profilecard: entry({\n name: 'profilecard',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n readingguide: entry({\n name: 'readingguide',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n};\n\n/**\n * The canonical leo registry. Frozen so callers cannot mutate the allow-list at\n * runtime. The port-backs (progress, card, metric, icon) are now `both`\n * (their second-surface emitters have landed).\n */\nexport const leoRegistry: LeoRegistry = Object.freeze({\n ...sharedBoth,\n ...portBacks,\n ...subComponents,\n ...terminalOnly,\n ...webOnlyInline,\n ...webOnlyOmit,\n});\n\n// ── Resolution ────────────────────────────────────────────────────────────────\n\n/**\n * Resolve a lowercase authored name (`callout`) to its registry entry, against\n * the provided registry root (the renderer always provides one — a missing root\n * is a programmer error). Returns `undefined` for an unknown name; the\n * caller treats unknown `<leo.X>` as an authoring error (a lint surfaces it —\n * never silently rendered).\n */\nexport function resolve(\n name: string,\n registry: LeoRegistry = leoRegistry\n): LeoComponent | undefined {\n // Guard with hasOwn so an inherited member (`toString`, `constructor`) never\n // resolves as a fake island — `<leo.toString>` must be unknown, not a fn.\n return Object.hasOwn(registry, name) ? registry[name] : undefined;\n}\n\n/** True iff `name` is in the allow-list. */\nexport function isKnown(name: string, registry: LeoRegistry = leoRegistry): boolean {\n return Object.hasOwn(registry, name);\n}\n\n// ── Prop coercion ─────────────────────────────────────────────────────────────\n\nexport interface CoerceResult {\n /** Coerced props (defaults applied, types converted). */\n readonly props: Record<string, unknown>;\n /** Validation errors (unknown enum value, missing required, bad JSON). */\n readonly errors: readonly string[];\n}\n\n/**\n * Coerce/validate raw (string) scanned attrs against a component's PropSchema.\n * Attributes arrive as strings; per-prop the schema converts to the\n * declared kind, applies defaults, and validates enums / required / JSON. An\n * unknown attr (not in the schema) is dropped with a recorded error — the schema\n * is the contract.\n */\nexport function coerceProps(\n schema: PropSchema,\n attrs: Readonly<Record<string, string>>\n): CoerceResult {\n const props: Record<string, unknown> = {};\n const errors: string[] = [];\n\n for (const [key, decl] of Object.entries(schema)) {\n const raw = attrs[key];\n if (raw === undefined) {\n if (decl.required) {\n errors.push(`missing required prop \"${key}\"`);\n } else if (decl.default !== undefined) {\n props[key] = decl.default;\n }\n continue;\n }\n const coerced = coerceOne(key, decl, raw, errors);\n if (coerced !== undefined) {\n props[key] = coerced;\n }\n }\n\n for (const key of Object.keys(attrs)) {\n if (!Object.hasOwn(schema, key)) {\n errors.push(`unknown prop \"${key}\"`);\n }\n }\n\n return { props, errors };\n}\n\nfunction coerceOne(key: string, decl: PropDecl, raw: string, errors: string[]): unknown {\n switch (decl.kind) {\n case 'string':\n return raw;\n case 'number': {\n const n = Number(raw);\n if (Number.isNaN(n)) {\n errors.push(`prop \"${key}\" is not a number: ${JSON.stringify(raw)}`);\n return undefined;\n }\n return n;\n }\n case 'boolean':\n // Bare attr (`highlight`) arrives as \"\" → true; `=\"false\"` → false.\n return raw === '' || raw === 'true';\n case 'enum': {\n if (decl.values && !decl.values.includes(raw)) {\n errors.push(\n `prop \"${key}\" must be one of ${decl.values.join('|')}, got ${JSON.stringify(raw)}`\n );\n return decl.default;\n }\n return raw;\n }\n case 'json': {\n try {\n return JSON.parse(raw);\n } catch {\n errors.push(`prop \"${key}\" is not valid JSON`);\n return undefined;\n }\n }\n default:\n return raw;\n }\n}\n"]}
|
package/dist/scanner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAwC,MAAM,YAAY,CAAC;AAYhF;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAuD9C;
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAwC,MAAM,YAAY,CAAC;AAYhF;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAuD9C;AAmND;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBnE"}
|