@decantr/essence-spec 1.0.0-beta.3 → 1.0.0-beta.4
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/dist/index.d.ts +17 -3
- package/dist/index.js +102 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/schema/essence.v2.json +18 -0
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,12 @@ interface Impression {
|
|
|
64
64
|
novel_elements: string[];
|
|
65
65
|
}
|
|
66
66
|
type GeneratorTarget = 'decantr' | 'react' | 'vue' | 'svelte' | string;
|
|
67
|
+
type WcagLevel = 'none' | 'A' | 'AA' | 'AAA';
|
|
68
|
+
type CvdPreference = 'none' | 'auto' | 'deuteranopia' | 'protanopia' | 'tritanopia' | 'achromatopsia';
|
|
69
|
+
interface Accessibility {
|
|
70
|
+
wcag_level?: WcagLevel;
|
|
71
|
+
cvd_preference?: CvdPreference;
|
|
72
|
+
}
|
|
67
73
|
interface Essence {
|
|
68
74
|
$schema?: string;
|
|
69
75
|
version: string;
|
|
@@ -76,6 +82,7 @@ interface Essence {
|
|
|
76
82
|
density: Density;
|
|
77
83
|
guard: Guard;
|
|
78
84
|
target: GeneratorTarget;
|
|
85
|
+
accessibility?: Accessibility;
|
|
79
86
|
_impression?: Impression;
|
|
80
87
|
}
|
|
81
88
|
interface EssenceSection {
|
|
@@ -96,6 +103,7 @@ interface SectionedEssence {
|
|
|
96
103
|
density: Density;
|
|
97
104
|
guard: Guard;
|
|
98
105
|
target: GeneratorTarget;
|
|
106
|
+
accessibility?: Accessibility;
|
|
99
107
|
_impression?: Impression;
|
|
100
108
|
}
|
|
101
109
|
type EssenceFile = Essence | SectionedEssence;
|
|
@@ -115,9 +123,10 @@ interface RecipeSpatialHints {
|
|
|
115
123
|
declare function computeDensity(personality: string[], recipeSpatial?: RecipeSpatialHints): Density;
|
|
116
124
|
|
|
117
125
|
interface GuardViolation {
|
|
118
|
-
rule: 'style' | 'structure' | 'layout' | 'recipe' | 'density';
|
|
126
|
+
rule: 'style' | 'structure' | 'layout' | 'recipe' | 'density' | 'theme-mode' | 'pattern-exists' | 'accessibility';
|
|
119
127
|
severity: 'error' | 'warning';
|
|
120
128
|
message: string;
|
|
129
|
+
suggestion?: string;
|
|
121
130
|
}
|
|
122
131
|
interface GuardContext {
|
|
123
132
|
pageId?: string;
|
|
@@ -125,9 +134,14 @@ interface GuardContext {
|
|
|
125
134
|
recipe?: string;
|
|
126
135
|
layout?: string[];
|
|
127
136
|
density_gap?: string;
|
|
137
|
+
themeRegistry?: Map<string, {
|
|
138
|
+
modes: string[];
|
|
139
|
+
}>;
|
|
140
|
+
patternRegistry?: Map<string, unknown>;
|
|
141
|
+
a11y_issues?: string[];
|
|
128
142
|
}
|
|
129
|
-
declare function evaluateGuard(essence: EssenceFile, context
|
|
143
|
+
declare function evaluateGuard(essence: EssenceFile, context?: GuardContext): GuardViolation[];
|
|
130
144
|
|
|
131
145
|
declare function normalizeEssence(input: Record<string, unknown>): EssenceFile;
|
|
132
146
|
|
|
133
|
-
export { type ColumnLayout, type Density, type DensityLevel, type Essence, type EssenceFile, type EssenceSection, type GeneratorTarget, type Guard, type GuardContext, type GuardMode, type GuardViolation, type Impression, type LayoutItem, type PatternRef, type Platform, type PlatformType, type RoutingStrategy, type SectionedEssence, type ShellType, type StructurePage, type Theme, type ThemeMode, type ThemeShape, type ThemeStyle, type ValidationResult, computeDensity, evaluateGuard, isSectioned, isSimple, normalizeEssence, validateEssence };
|
|
147
|
+
export { type Accessibility, type ColumnLayout, type CvdPreference, type Density, type DensityLevel, type Essence, type EssenceFile, type EssenceSection, type GeneratorTarget, type Guard, type GuardContext, type GuardMode, type GuardViolation, type Impression, type LayoutItem, type PatternRef, type Platform, type PlatformType, type RoutingStrategy, type SectionedEssence, type ShellType, type StructurePage, type Theme, type ThemeMode, type ThemeShape, type ThemeStyle, type ValidationResult, type WcagLevel, computeDensity, evaluateGuard, isSectioned, isSimple, normalizeEssence, validateEssence };
|
package/dist/index.js
CHANGED
|
@@ -74,7 +74,98 @@ function computeDensity(personality, recipeSpatial) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// src/guard.ts
|
|
77
|
-
function
|
|
77
|
+
function checkThemeModeCompatibility(essence, context) {
|
|
78
|
+
if (!context.themeRegistry) return null;
|
|
79
|
+
const themeId = isSimple(essence) ? essence.theme?.style : null;
|
|
80
|
+
const mode = isSimple(essence) ? essence.theme?.mode : null;
|
|
81
|
+
if (!themeId || !mode) return null;
|
|
82
|
+
const theme = context.themeRegistry.get(themeId);
|
|
83
|
+
if (!theme) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (!theme.modes.includes(mode) && mode !== "auto") {
|
|
87
|
+
const supportedModes = theme.modes.join(", ");
|
|
88
|
+
const suggestion = theme.modes.length > 0 ? `Use mode: "${theme.modes[0]}" instead, or choose a theme that supports ${mode} mode.` : void 0;
|
|
89
|
+
return {
|
|
90
|
+
rule: "theme-mode",
|
|
91
|
+
severity: "error",
|
|
92
|
+
message: `Theme "${themeId}" does not support "${mode}" mode. Supported modes: ${supportedModes}.`,
|
|
93
|
+
suggestion
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function collectPatternIds(item, ids) {
|
|
99
|
+
if (typeof item === "string") {
|
|
100
|
+
ids.add(item);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (typeof item === "object" && item !== null) {
|
|
104
|
+
if ("pattern" in item && typeof item.pattern === "string") {
|
|
105
|
+
ids.add(item.pattern);
|
|
106
|
+
}
|
|
107
|
+
if ("cols" in item && Array.isArray(item.cols)) {
|
|
108
|
+
for (const col of item.cols) {
|
|
109
|
+
if (typeof col === "string") {
|
|
110
|
+
ids.add(col);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function findSimilarPatterns(target, registry) {
|
|
117
|
+
const similar = [];
|
|
118
|
+
const targetLower = target.toLowerCase();
|
|
119
|
+
for (const id of registry.keys()) {
|
|
120
|
+
const idLower = id.toLowerCase();
|
|
121
|
+
if (idLower.includes(targetLower) || targetLower.includes(idLower)) {
|
|
122
|
+
similar.push(id);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return similar.slice(0, 3);
|
|
126
|
+
}
|
|
127
|
+
function checkPatternExistence(essence, context) {
|
|
128
|
+
if (!context.patternRegistry) return [];
|
|
129
|
+
const violations = [];
|
|
130
|
+
const referencedPatterns = /* @__PURE__ */ new Set();
|
|
131
|
+
const pages = getAllPages(essence);
|
|
132
|
+
for (const page of pages) {
|
|
133
|
+
for (const item of page.layout || []) {
|
|
134
|
+
collectPatternIds(item, referencedPatterns);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const patternId of referencedPatterns) {
|
|
138
|
+
if (!context.patternRegistry.has(patternId)) {
|
|
139
|
+
const similar = findSimilarPatterns(patternId, context.patternRegistry);
|
|
140
|
+
const suggestion = similar.length > 0 ? `Similar patterns: ${similar.join(", ")}` : `Run "decantr search ${patternId}" to find alternatives.`;
|
|
141
|
+
violations.push({
|
|
142
|
+
rule: "pattern-exists",
|
|
143
|
+
severity: "error",
|
|
144
|
+
message: `Pattern "${patternId}" is referenced but does not exist in the registry.`,
|
|
145
|
+
suggestion
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return violations;
|
|
150
|
+
}
|
|
151
|
+
function checkAccessibility(essence, context) {
|
|
152
|
+
const accessibility = "accessibility" in essence ? essence.accessibility : void 0;
|
|
153
|
+
if (!accessibility?.wcag_level || accessibility.wcag_level === "none") {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
if (context.a11y_issues && context.a11y_issues.length > 0) {
|
|
157
|
+
const issueList = context.a11y_issues.slice(0, 3).join(", ");
|
|
158
|
+
const moreCount = context.a11y_issues.length > 3 ? ` (+${context.a11y_issues.length - 3} more)` : "";
|
|
159
|
+
return {
|
|
160
|
+
rule: "accessibility",
|
|
161
|
+
severity: "error",
|
|
162
|
+
message: `WCAG ${accessibility.wcag_level} compliance required. Issues found: ${issueList}${moreCount}`,
|
|
163
|
+
suggestion: "Fix accessibility issues before proceeding. Run an accessibility audit for details."
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
function evaluateGuard(essence, context = {}) {
|
|
78
169
|
const guard = essence.guard;
|
|
79
170
|
if (guard.mode === "creative") {
|
|
80
171
|
return [];
|
|
@@ -139,6 +230,16 @@ function evaluateGuard(essence, context) {
|
|
|
139
230
|
});
|
|
140
231
|
}
|
|
141
232
|
}
|
|
233
|
+
const themeModeViolation = checkThemeModeCompatibility(essence, context);
|
|
234
|
+
if (themeModeViolation) {
|
|
235
|
+
violations.push(themeModeViolation);
|
|
236
|
+
}
|
|
237
|
+
const patternViolations = checkPatternExistence(essence, context);
|
|
238
|
+
violations.push(...patternViolations);
|
|
239
|
+
const accessibilityViolation = checkAccessibility(essence, context);
|
|
240
|
+
if (accessibilityViolation) {
|
|
241
|
+
violations.push(accessibilityViolation);
|
|
242
|
+
}
|
|
142
243
|
return violations;
|
|
143
244
|
}
|
|
144
245
|
function getAllPages(essence) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/validate.ts","../src/density.ts","../src/guard.ts","../src/normalize.ts"],"sourcesContent":["/**\n * Essence v2 schema types — normalized terminology.\n *\n * Terminology mapping (v1 wine terms → v2 normalized):\n * terroir → archetype, vintage → theme, tannins → features,\n * carafe → shell, cork → guard, blend → layout, clarity → density,\n * vessel → platform, character → personality,\n * decantation process → essence pipeline\n */\n\n// --- Theme ---\n\nexport type ThemeStyle =\n | 'auradecantism'\n | 'clean'\n | 'glassmorphism'\n | 'retro'\n | 'bioluminescent'\n | 'launchpad'\n | 'dopamine'\n | 'editorial'\n | 'liquid-glass'\n | 'prismatic';\n\nexport type ThemeMode = 'light' | 'dark' | 'auto';\nexport type ThemeShape = 'sharp' | 'rounded' | 'pill';\n\nexport interface Theme {\n style: ThemeStyle | string;\n mode: ThemeMode;\n recipe: string;\n shape?: ThemeShape;\n}\n\n// --- Platform ---\n\nexport type PlatformType = 'spa' | 'ssr' | 'static';\nexport type RoutingStrategy = 'hash' | 'history';\n\nexport interface Platform {\n type: PlatformType;\n routing: RoutingStrategy;\n}\n\n// --- Structure ---\n\nexport type ShellType =\n | 'sidebar-main'\n | 'top-nav-main'\n | 'full-bleed'\n | 'dashboard'\n | 'stacked'\n | string;\n\nexport type LayoutItem = string | PatternRef | ColumnLayout;\n\nexport interface PatternRef {\n pattern: string;\n preset?: string;\n as?: string;\n}\n\nexport interface ColumnLayout {\n cols: string[];\n at?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n span?: Record<string, number>;\n // AUTO: Multi-breakpoint grid — array of { at, cols } entries for cascading breakpoints\n breakpoints?: { at: string; cols: number }[];\n // AUTO: \"container\" uses container queries instead of viewport breakpoints\n responsive?: 'viewport' | 'container';\n}\n\nexport interface StructurePage {\n id: string;\n shell: ShellType;\n layout: LayoutItem[];\n surface?: string;\n}\n\n// --- Density ---\n\nexport type DensityLevel = 'compact' | 'comfortable' | 'spacious';\n\nexport interface Density {\n level: DensityLevel;\n content_gap: string;\n}\n\n// --- Guard ---\n\nexport type GuardMode = 'creative' | 'guided' | 'strict';\n\nexport interface Guard {\n enforce_style?: boolean;\n enforce_recipe?: boolean;\n mode: GuardMode;\n}\n\n// --- Impression ---\n\nexport interface Impression {\n vibe: string[];\n references: string[];\n density_intent: DensityLevel | string;\n layout_intent: ShellType | string;\n novel_elements: string[];\n}\n\n// --- Generator Target ---\n\nexport type GeneratorTarget = 'decantr' | 'react' | 'vue' | 'svelte' | string;\n\n// --- Essence (simple) ---\n\nexport interface Essence {\n $schema?: string;\n version: string;\n archetype: string;\n theme: Theme;\n personality: string[];\n platform: Platform;\n structure: StructurePage[];\n features: string[];\n density: Density;\n guard: Guard;\n target: GeneratorTarget;\n _impression?: Impression;\n}\n\n// --- Essence (sectioned) ---\n\nexport interface EssenceSection {\n id: string;\n path: string;\n archetype: string;\n theme: Theme;\n structure: StructurePage[];\n features?: string[];\n}\n\nexport interface SectionedEssence {\n $schema?: string;\n version: string;\n platform: Platform;\n personality: string[];\n sections: EssenceSection[];\n shared_features?: string[];\n density: Density;\n guard: Guard;\n target: GeneratorTarget;\n _impression?: Impression;\n}\n\nexport type EssenceFile = Essence | SectionedEssence;\n\nexport function isSectioned(essence: EssenceFile): essence is SectionedEssence {\n return 'sections' in essence && Array.isArray((essence as SectionedEssence).sections);\n}\n\nexport function isSimple(essence: EssenceFile): essence is Essence {\n return 'archetype' in essence && !('sections' in essence);\n}\n","import Ajv from 'ajv';\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst schemaPath = join(__dirname, '..', 'schema', 'essence.v2.json');\n\nlet cachedAjv: Ajv | null = null;\nlet cachedValidate: ReturnType<Ajv['compile']> | null = null;\n\nfunction getValidator() {\n if (cachedValidate) return cachedValidate;\n const schema = JSON.parse(readFileSync(schemaPath, 'utf-8'));\n cachedAjv = new Ajv({ allErrors: true, strict: false, validateSchema: false });\n cachedValidate = cachedAjv.compile(schema);\n return cachedValidate;\n}\n\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\nexport function validateEssence(data: unknown): ValidationResult {\n const validate = getValidator();\n const valid = validate(data);\n\n if (valid) {\n return { valid: true, errors: [] };\n }\n\n const errors = (validate.errors ?? []).map((err) => {\n const path = err.instancePath || '/';\n const msg = err.message ?? 'unknown error';\n return `${path}: ${msg}`;\n });\n\n return { valid: false, errors };\n}\n","import type { Density, DensityLevel } from './types.js';\n\ninterface RecipeSpatialHints {\n density_bias?: number;\n content_gap_shift?: number;\n}\n\ninterface DensityRule {\n traits: string[];\n level: DensityLevel;\n gap: number;\n}\n\nconst RULES: DensityRule[] = [\n { traits: ['tactical', 'dense', 'data-dense', 'utilitarian'], level: 'compact', gap: 3 },\n { traits: ['luxurious', 'premium', 'editorial'], level: 'spacious', gap: 8 },\n { traits: ['playful', 'bouncy', 'expressive'], level: 'comfortable', gap: 5 },\n { traits: ['minimal', 'clean', 'airy'], level: 'spacious', gap: 6 },\n { traits: ['professional', 'modern', 'balanced'], level: 'comfortable', gap: 4 },\n];\n\nconst MIN_GAP = 2;\nconst MAX_GAP = 10;\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\nexport function computeDensity(\n personality: string[],\n recipeSpatial?: RecipeSpatialHints,\n): Density {\n const lower = personality.map(c => c.toLowerCase());\n\n let level: DensityLevel = 'comfortable';\n let gap = 4;\n\n for (const rule of RULES) {\n if (rule.traits.some(t => lower.includes(t))) {\n level = rule.level;\n gap = rule.gap;\n break;\n }\n }\n\n if (recipeSpatial?.density_bias) {\n gap += recipeSpatial.density_bias;\n }\n if (recipeSpatial?.content_gap_shift) {\n gap += recipeSpatial.content_gap_shift;\n }\n\n gap = clamp(gap, MIN_GAP, MAX_GAP);\n\n if (gap <= 3) level = 'compact';\n else if (gap >= 6) level = 'spacious';\n else level = 'comfortable';\n\n return { level, content_gap: String(gap) };\n}\n","import type { EssenceFile, StructurePage } from './types.js';\nimport { isSimple, isSectioned } from './types.js';\n\nexport interface GuardViolation {\n rule: 'style' | 'structure' | 'layout' | 'recipe' | 'density';\n severity: 'error' | 'warning';\n message: string;\n}\n\nexport interface GuardContext {\n pageId?: string;\n style?: string;\n recipe?: string;\n layout?: string[];\n density_gap?: string;\n}\n\nexport function evaluateGuard(essence: EssenceFile, context: GuardContext): GuardViolation[] {\n const guard = essence.guard;\n\n if (guard.mode === 'creative') {\n return [];\n }\n\n const violations: GuardViolation[] = [];\n const isStrict = guard.mode === 'strict';\n\n // Rule 1: Style guard\n if (context.style) {\n const essenceStyle = isSimple(essence) ? essence.theme.style : null;\n if (essenceStyle && context.style !== essenceStyle && guard.enforce_style !== false) {\n violations.push({\n rule: 'style',\n severity: 'error',\n message: `Style \"${context.style}\" does not match essence theme \"${essenceStyle}\". Change the essence theme first.`,\n });\n }\n }\n\n // Rule 2: Structure guard (enforced in both guided and strict)\n if (context.pageId) {\n const pages = getAllPages(essence);\n const pageExists = pages.some(p => p.id === context.pageId);\n if (!pageExists) {\n violations.push({\n rule: 'structure',\n severity: 'error',\n message: `Page \"${context.pageId}\" does not exist in essence structure. Add it to the essence first.`,\n });\n }\n }\n\n // Rule 3: Layout guard (strict only)\n if (isStrict && context.pageId && context.layout) {\n const pages = getAllPages(essence);\n const page = pages.find(p => p.id === context.pageId);\n if (page) {\n const essenceLayout = page.layout.map(item =>\n typeof item === 'string' ? item : 'pattern' in item ? item.pattern : 'cols'\n );\n const proposedLayout = context.layout;\n const matches = essenceLayout.length === proposedLayout.length &&\n essenceLayout.every((item, i) => item === proposedLayout[i]);\n if (!matches) {\n violations.push({\n rule: 'layout',\n severity: 'error',\n message: `Layout for page \"${context.pageId}\" deviates from essence. Expected: [${essenceLayout.join(', ')}].`,\n });\n }\n }\n }\n\n // Rule 4: Recipe guard\n if (context.recipe && guard.enforce_recipe !== false) {\n const essenceRecipe = isSimple(essence) ? essence.theme.recipe : null;\n if (essenceRecipe && context.recipe !== essenceRecipe) {\n violations.push({\n rule: 'recipe',\n severity: 'error',\n message: `Recipe \"${context.recipe}\" does not match essence recipe \"${essenceRecipe}\".`,\n });\n }\n }\n\n // Rule 5: Density guard (strict only)\n if (isStrict && context.density_gap) {\n if (context.density_gap !== essence.density.content_gap) {\n violations.push({\n rule: 'density',\n severity: 'warning',\n message: `Content gap \"${context.density_gap}\" does not match essence density \"${essence.density.content_gap}\".`,\n });\n }\n }\n\n return violations;\n}\n\nfunction getAllPages(essence: EssenceFile): StructurePage[] {\n if (isSimple(essence)) return essence.structure;\n if (isSectioned(essence)) return essence.sections.flatMap(s => s.structure);\n return [];\n}\n","import type { Essence, SectionedEssence, EssenceFile, StructurePage, GuardMode } from './types.js';\n\nexport function normalizeEssence(input: Record<string, unknown>): EssenceFile {\n // Detect v2: has 'theme' and 'platform' (normalized terms)\n if (input.theme && input.platform) {\n return input as unknown as EssenceFile;\n }\n\n if (input.sections) {\n return normalizeSectioned(input);\n }\n\n return normalizeSimple(input);\n}\n\nfunction normalizeSimple(v1: Record<string, unknown>): Essence {\n // v1 field names (wine terms) → v2 normalized names:\n // vintage → theme, vessel → platform, clarity → density,\n // cork → guard, terroir/vignette → archetype, tannins → features,\n // carafe → shell, blend → layout, character → personality\n const vintage = v1.vintage as Record<string, string> | undefined;\n const vessel = v1.vessel as Record<string, string> | undefined;\n const clarity = v1.clarity as Record<string, string> | undefined;\n const cork = v1.cork as Record<string, unknown> | undefined;\n const structure = v1.structure as Array<Record<string, unknown>> | undefined;\n\n return {\n version: '2.0.0',\n archetype: (v1.terroir ?? v1.vignette ?? v1.archetype) as string,\n theme: {\n style: vintage?.style ?? '',\n mode: (vintage?.mode ?? 'dark') as 'light' | 'dark' | 'auto',\n recipe: vintage?.recipe ?? '',\n ...(vintage?.shape ? { shape: vintage.shape as 'sharp' | 'rounded' | 'pill' } : {}),\n },\n // Accept both old 'character' and new 'personality' field names\n personality: (v1.character ?? v1.personality) as string[],\n platform: {\n type: (vessel?.type ?? 'spa') as 'spa' | 'ssr' | 'static',\n routing: (vessel?.routing ?? 'hash') as 'hash' | 'history',\n },\n structure: (structure ?? []).map(normalizeStructurePage),\n features: (v1.tannins ?? v1.features ?? []) as string[],\n density: {\n level: (clarity?.density ?? 'comfortable') as 'compact' | 'comfortable' | 'spacious',\n content_gap: stripGapPrefix(clarity?.content_gap ?? '4'),\n },\n guard: normalizeGuard(cork),\n target: (v1.target as string) ?? 'decantr',\n ...(v1._impression ? { _impression: v1._impression as Essence['_impression'] } : {}),\n };\n}\n\nfunction normalizeSectioned(v1: Record<string, unknown>): SectionedEssence {\n // v1 field names (wine terms) → v2 normalized names:\n // vessel → platform, clarity → density, cork → guard,\n // terroir/vignette → archetype, tannins → features,\n // shared_tannins → shared_features, character → personality\n const vessel = v1.vessel as Record<string, string> | undefined;\n const clarity = v1.clarity as Record<string, string> | undefined;\n const cork = v1.cork as Record<string, unknown> | undefined;\n const sections = v1.sections as Array<Record<string, unknown>>;\n\n return {\n version: '2.0.0',\n platform: {\n type: (vessel?.type ?? 'spa') as 'spa' | 'ssr' | 'static',\n routing: (vessel?.routing ?? 'hash') as 'hash' | 'history',\n },\n // Accept both old 'character' and new 'personality' field names\n personality: (v1.character ?? v1.personality) as string[],\n sections: sections.map(section => ({\n id: section.id as string,\n path: section.path as string,\n archetype: (section.terroir ?? section.vignette ?? section.archetype) as string,\n theme: {\n style: (section.vintage as Record<string, string>)?.style ?? '',\n mode: ((section.vintage as Record<string, string>)?.mode ?? 'dark') as 'light' | 'dark' | 'auto',\n recipe: (section.vintage as Record<string, string>)?.recipe ?? '',\n },\n structure: ((section.structure as Array<Record<string, unknown>>) ?? []).map(normalizeStructurePage),\n ...(section.tannins ? { features: section.tannins as string[] } : {}),\n })),\n ...(v1.shared_tannins ? { shared_features: v1.shared_tannins as string[] } : {}),\n density: {\n level: (clarity?.density ?? 'comfortable') as 'compact' | 'comfortable' | 'spacious',\n content_gap: stripGapPrefix(clarity?.content_gap ?? '4'),\n },\n guard: normalizeGuard(cork),\n target: (v1.target as string) ?? 'decantr',\n };\n}\n\nfunction normalizeStructurePage(page: Record<string, unknown>): StructurePage {\n // Accept v1 wine terms (carafe → shell, blend → layout) for backward compatibility\n return {\n id: page.id as string,\n shell: (page.carafe ?? page.shell) as string,\n layout: (page.blend ?? page.layout) as StructurePage['layout'],\n ...(page.surface ? { surface: page.surface as string } : {}),\n };\n}\n\n// Accept v1 'cork' object and normalize to v2 'guard'\nfunction normalizeGuard(cork: Record<string, unknown> | undefined): Essence['guard'] {\n if (!cork) return { mode: 'creative' };\n\n const modeMap: Record<string, GuardMode> = {\n creative: 'creative',\n maintenance: 'strict',\n strict: 'strict',\n guided: 'guided',\n };\n\n return {\n ...(cork.enforce_style !== undefined ? { enforce_style: cork.enforce_style as boolean } : {}),\n ...(cork.enforce_recipe !== undefined ? { enforce_recipe: cork.enforce_recipe as boolean } : {}),\n mode: modeMap[(cork.mode as string) ?? 'creative'] ?? 'creative',\n };\n}\n\nfunction stripGapPrefix(gap: string): string {\n const match = gap.match(/^_gap(\\d+)$/);\n return match ? match[1] : gap;\n}\n"],"mappings":";AA2JO,SAAS,YAAY,SAAmD;AAC7E,SAAO,cAAc,WAAW,MAAM,QAAS,QAA6B,QAAQ;AACtF;AAEO,SAAS,SAAS,SAA0C;AACjE,SAAO,eAAe,WAAW,EAAE,cAAc;AACnD;;;ACjKA,OAAO,SAAS;AAChB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAE9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,IAAM,aAAa,KAAK,WAAW,MAAM,UAAU,iBAAiB;AAEpE,IAAI,YAAwB;AAC5B,IAAI,iBAAoD;AAExD,SAAS,eAAe;AACtB,MAAI,eAAgB,QAAO;AAC3B,QAAM,SAAS,KAAK,MAAM,aAAa,YAAY,OAAO,CAAC;AAC3D,cAAY,IAAI,IAAI,EAAE,WAAW,MAAM,QAAQ,OAAO,gBAAgB,MAAM,CAAC;AAC7E,mBAAiB,UAAU,QAAQ,MAAM;AACzC,SAAO;AACT;AAOO,SAAS,gBAAgB,MAAiC;AAC/D,QAAM,WAAW,aAAa;AAC9B,QAAM,QAAQ,SAAS,IAAI;AAE3B,MAAI,OAAO;AACT,WAAO,EAAE,OAAO,MAAM,QAAQ,CAAC,EAAE;AAAA,EACnC;AAEA,QAAM,UAAU,SAAS,UAAU,CAAC,GAAG,IAAI,CAAC,QAAQ;AAClD,UAAM,OAAO,IAAI,gBAAgB;AACjC,UAAM,MAAM,IAAI,WAAW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ts","../src/normalize.ts"],"sourcesContent":["/**\n * Essence v2 schema types — normalized terminology.\n *\n * Terminology mapping (v1 wine terms → v2 normalized):\n * terroir → archetype, vintage → theme, tannins → features,\n * carafe → shell, cork → guard, blend → layout, clarity → density,\n * vessel → platform, character → personality,\n * decantation process → essence pipeline\n */\n\n// --- Theme ---\n\nexport type ThemeStyle =\n | 'auradecantism'\n | 'clean'\n | 'glassmorphism'\n | 'retro'\n | 'bioluminescent'\n | 'launchpad'\n | 'dopamine'\n | 'editorial'\n | 'liquid-glass'\n | 'prismatic';\n\nexport type ThemeMode = 'light' | 'dark' | 'auto';\nexport type ThemeShape = 'sharp' | 'rounded' | 'pill';\n\nexport interface Theme {\n style: ThemeStyle | string;\n mode: ThemeMode;\n recipe: string;\n shape?: ThemeShape;\n}\n\n// --- Platform ---\n\nexport type PlatformType = 'spa' | 'ssr' | 'static';\nexport type RoutingStrategy = 'hash' | 'history';\n\nexport interface Platform {\n type: PlatformType;\n routing: RoutingStrategy;\n}\n\n// --- Structure ---\n\nexport type ShellType =\n | 'sidebar-main'\n | 'top-nav-main'\n | 'full-bleed'\n | 'dashboard'\n | 'stacked'\n | string;\n\nexport type LayoutItem = string | PatternRef | ColumnLayout;\n\nexport interface PatternRef {\n pattern: string;\n preset?: string;\n as?: string;\n}\n\nexport interface ColumnLayout {\n cols: string[];\n at?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n span?: Record<string, number>;\n // AUTO: Multi-breakpoint grid — array of { at, cols } entries for cascading breakpoints\n breakpoints?: { at: string; cols: number }[];\n // AUTO: \"container\" uses container queries instead of viewport breakpoints\n responsive?: 'viewport' | 'container';\n}\n\nexport interface StructurePage {\n id: string;\n shell: ShellType;\n layout: LayoutItem[];\n surface?: string;\n}\n\n// --- Density ---\n\nexport type DensityLevel = 'compact' | 'comfortable' | 'spacious';\n\nexport interface Density {\n level: DensityLevel;\n content_gap: string;\n}\n\n// --- Guard ---\n\nexport type GuardMode = 'creative' | 'guided' | 'strict';\n\nexport interface Guard {\n enforce_style?: boolean;\n enforce_recipe?: boolean;\n mode: GuardMode;\n}\n\n// --- Impression ---\n\nexport interface Impression {\n vibe: string[];\n references: string[];\n density_intent: DensityLevel | string;\n layout_intent: ShellType | string;\n novel_elements: string[];\n}\n\n// --- Generator Target ---\n\nexport type GeneratorTarget = 'decantr' | 'react' | 'vue' | 'svelte' | string;\n\n// --- Accessibility ---\n\nexport type WcagLevel = 'none' | 'A' | 'AA' | 'AAA';\n\nexport type CvdPreference =\n | 'none'\n | 'auto'\n | 'deuteranopia'\n | 'protanopia'\n | 'tritanopia'\n | 'achromatopsia';\n\nexport interface Accessibility {\n wcag_level?: WcagLevel;\n cvd_preference?: CvdPreference;\n}\n\n// --- Essence (simple) ---\n\nexport interface Essence {\n $schema?: string;\n version: string;\n archetype: string;\n theme: Theme;\n personality: string[];\n platform: Platform;\n structure: StructurePage[];\n features: string[];\n density: Density;\n guard: Guard;\n target: GeneratorTarget;\n accessibility?: Accessibility;\n _impression?: Impression;\n}\n\n// --- Essence (sectioned) ---\n\nexport interface EssenceSection {\n id: string;\n path: string;\n archetype: string;\n theme: Theme;\n structure: StructurePage[];\n features?: string[];\n}\n\nexport interface SectionedEssence {\n $schema?: string;\n version: string;\n platform: Platform;\n personality: string[];\n sections: EssenceSection[];\n shared_features?: string[];\n density: Density;\n guard: Guard;\n target: GeneratorTarget;\n accessibility?: Accessibility;\n _impression?: Impression;\n}\n\nexport type EssenceFile = Essence | SectionedEssence;\n\nexport function isSectioned(essence: EssenceFile): essence is SectionedEssence {\n return 'sections' in essence && Array.isArray((essence as SectionedEssence).sections);\n}\n\nexport function isSimple(essence: EssenceFile): essence is Essence {\n return 'archetype' in essence && !('sections' in essence);\n}\n","import Ajv from 'ajv';\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst schemaPath = join(__dirname, '..', 'schema', 'essence.v2.json');\n\nlet cachedAjv: Ajv | null = null;\nlet cachedValidate: ReturnType<Ajv['compile']> | null = null;\n\nfunction getValidator() {\n if (cachedValidate) return cachedValidate;\n const schema = JSON.parse(readFileSync(schemaPath, 'utf-8'));\n cachedAjv = new Ajv({ allErrors: true, strict: false, validateSchema: false });\n cachedValidate = cachedAjv.compile(schema);\n return cachedValidate;\n}\n\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\nexport function validateEssence(data: unknown): ValidationResult {\n const validate = getValidator();\n const valid = validate(data);\n\n if (valid) {\n return { valid: true, errors: [] };\n }\n\n const errors = (validate.errors ?? []).map((err) => {\n const path = err.instancePath || '/';\n const msg = err.message ?? 'unknown error';\n return `${path}: ${msg}`;\n });\n\n return { valid: false, errors };\n}\n","import type { Density, DensityLevel } from './types.js';\n\ninterface RecipeSpatialHints {\n density_bias?: number;\n content_gap_shift?: number;\n}\n\ninterface DensityRule {\n traits: string[];\n level: DensityLevel;\n gap: number;\n}\n\nconst RULES: DensityRule[] = [\n { traits: ['tactical', 'dense', 'data-dense', 'utilitarian'], level: 'compact', gap: 3 },\n { traits: ['luxurious', 'premium', 'editorial'], level: 'spacious', gap: 8 },\n { traits: ['playful', 'bouncy', 'expressive'], level: 'comfortable', gap: 5 },\n { traits: ['minimal', 'clean', 'airy'], level: 'spacious', gap: 6 },\n { traits: ['professional', 'modern', 'balanced'], level: 'comfortable', gap: 4 },\n];\n\nconst MIN_GAP = 2;\nconst MAX_GAP = 10;\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\nexport function computeDensity(\n personality: string[],\n recipeSpatial?: RecipeSpatialHints,\n): Density {\n const lower = personality.map(c => c.toLowerCase());\n\n let level: DensityLevel = 'comfortable';\n let gap = 4;\n\n for (const rule of RULES) {\n if (rule.traits.some(t => lower.includes(t))) {\n level = rule.level;\n gap = rule.gap;\n break;\n }\n }\n\n if (recipeSpatial?.density_bias) {\n gap += recipeSpatial.density_bias;\n }\n if (recipeSpatial?.content_gap_shift) {\n gap += recipeSpatial.content_gap_shift;\n }\n\n gap = clamp(gap, MIN_GAP, MAX_GAP);\n\n if (gap <= 3) level = 'compact';\n else if (gap >= 6) level = 'spacious';\n else level = 'comfortable';\n\n return { level, content_gap: String(gap) };\n}\n","import type { EssenceFile, StructurePage, LayoutItem } from './types.js';\nimport { isSimple, isSectioned } from './types.js';\n\nexport interface GuardViolation {\n rule: 'style' | 'structure' | 'layout' | 'recipe' | 'density' | 'theme-mode' | 'pattern-exists' | 'accessibility';\n severity: 'error' | 'warning';\n message: string;\n suggestion?: string;\n}\n\nexport interface GuardContext {\n pageId?: string;\n style?: string;\n recipe?: string;\n layout?: string[];\n density_gap?: string;\n themeRegistry?: Map<string, { modes: string[] }>;\n patternRegistry?: Map<string, unknown>;\n a11y_issues?: string[];\n}\n\n/**\n * Check if the theme supports the specified mode.\n */\nfunction checkThemeModeCompatibility(\n essence: EssenceFile,\n context: GuardContext\n): GuardViolation | null {\n if (!context.themeRegistry) return null;\n\n const themeId = isSimple(essence) ? essence.theme?.style : null;\n const mode = isSimple(essence) ? essence.theme?.mode : null;\n\n if (!themeId || !mode) return null;\n\n const theme = context.themeRegistry.get(themeId);\n if (!theme) {\n // Theme not found - separate validation\n return null;\n }\n\n if (!theme.modes.includes(mode) && mode !== 'auto') {\n const supportedModes = theme.modes.join(', ');\n const suggestion = theme.modes.length > 0\n ? `Use mode: \"${theme.modes[0]}\" instead, or choose a theme that supports ${mode} mode.`\n : undefined;\n\n return {\n rule: 'theme-mode',\n severity: 'error',\n message: `Theme \"${themeId}\" does not support \"${mode}\" mode. Supported modes: ${supportedModes}.`,\n suggestion,\n };\n }\n\n return null;\n}\n\n/**\n * Collect all pattern IDs from a layout item, recursively handling nested structures.\n */\nfunction collectPatternIds(item: LayoutItem, ids: Set<string>): void {\n if (typeof item === 'string') {\n ids.add(item);\n return;\n }\n if (typeof item === 'object' && item !== null) {\n if ('pattern' in item && typeof item.pattern === 'string') {\n ids.add(item.pattern);\n }\n if ('cols' in item && Array.isArray(item.cols)) {\n for (const col of item.cols) {\n // cols contains strings (pattern IDs)\n if (typeof col === 'string') {\n ids.add(col);\n }\n }\n }\n }\n}\n\n/**\n * Find similar pattern IDs in the registry for suggestion.\n */\nfunction findSimilarPatterns(target: string, registry: Map<string, unknown>): string[] {\n const similar: string[] = [];\n const targetLower = target.toLowerCase();\n\n for (const id of registry.keys()) {\n const idLower = id.toLowerCase();\n // Simple similarity: contains target or target contains id\n if (idLower.includes(targetLower) || targetLower.includes(idLower)) {\n similar.push(id);\n }\n }\n\n return similar.slice(0, 3); // Top 3 suggestions\n}\n\n/**\n * Check if all referenced patterns exist in the registry.\n */\nfunction checkPatternExistence(\n essence: EssenceFile,\n context: GuardContext\n): GuardViolation[] {\n if (!context.patternRegistry) return [];\n\n const violations: GuardViolation[] = [];\n const referencedPatterns = new Set<string>();\n\n // Collect all pattern references from structure\n const pages = getAllPages(essence);\n for (const page of pages) {\n for (const item of page.layout || []) {\n collectPatternIds(item, referencedPatterns);\n }\n }\n\n // Check each pattern exists\n for (const patternId of referencedPatterns) {\n if (!context.patternRegistry.has(patternId)) {\n // Find similar patterns for suggestion\n const similar = findSimilarPatterns(patternId, context.patternRegistry);\n const suggestion = similar.length > 0\n ? `Similar patterns: ${similar.join(', ')}`\n : `Run \"decantr search ${patternId}\" to find alternatives.`;\n\n violations.push({\n rule: 'pattern-exists',\n severity: 'error',\n message: `Pattern \"${patternId}\" is referenced but does not exist in the registry.`,\n suggestion,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Check accessibility compliance based on declared WCAG level.\n */\nfunction checkAccessibility(\n essence: EssenceFile,\n context: GuardContext\n): GuardViolation | null {\n const accessibility = 'accessibility' in essence ? essence.accessibility : undefined;\n\n if (!accessibility?.wcag_level || accessibility.wcag_level === 'none') {\n return null;\n }\n\n if (context.a11y_issues && context.a11y_issues.length > 0) {\n const issueList = context.a11y_issues.slice(0, 3).join(', ');\n const moreCount = context.a11y_issues.length > 3 ? ` (+${context.a11y_issues.length - 3} more)` : '';\n\n return {\n rule: 'accessibility',\n severity: 'error',\n message: `WCAG ${accessibility.wcag_level} compliance required. Issues found: ${issueList}${moreCount}`,\n suggestion: 'Fix accessibility issues before proceeding. Run an accessibility audit for details.',\n };\n }\n\n return null;\n}\n\nexport function evaluateGuard(essence: EssenceFile, context: GuardContext = {}): GuardViolation[] {\n const guard = essence.guard;\n\n if (guard.mode === 'creative') {\n return [];\n }\n\n const violations: GuardViolation[] = [];\n const isStrict = guard.mode === 'strict';\n\n // Rule 1: Style guard\n if (context.style) {\n const essenceStyle = isSimple(essence) ? essence.theme.style : null;\n if (essenceStyle && context.style !== essenceStyle && guard.enforce_style !== false) {\n violations.push({\n rule: 'style',\n severity: 'error',\n message: `Style \"${context.style}\" does not match essence theme \"${essenceStyle}\". Change the essence theme first.`,\n });\n }\n }\n\n // Rule 2: Structure guard (enforced in both guided and strict)\n if (context.pageId) {\n const pages = getAllPages(essence);\n const pageExists = pages.some(p => p.id === context.pageId);\n if (!pageExists) {\n violations.push({\n rule: 'structure',\n severity: 'error',\n message: `Page \"${context.pageId}\" does not exist in essence structure. Add it to the essence first.`,\n });\n }\n }\n\n // Rule 3: Layout guard (strict only)\n if (isStrict && context.pageId && context.layout) {\n const pages = getAllPages(essence);\n const page = pages.find(p => p.id === context.pageId);\n if (page) {\n const essenceLayout = page.layout.map(item =>\n typeof item === 'string' ? item : 'pattern' in item ? item.pattern : 'cols'\n );\n const proposedLayout = context.layout;\n const matches = essenceLayout.length === proposedLayout.length &&\n essenceLayout.every((item, i) => item === proposedLayout[i]);\n if (!matches) {\n violations.push({\n rule: 'layout',\n severity: 'error',\n message: `Layout for page \"${context.pageId}\" deviates from essence. Expected: [${essenceLayout.join(', ')}].`,\n });\n }\n }\n }\n\n // Rule 4: Recipe guard\n if (context.recipe && guard.enforce_recipe !== false) {\n const essenceRecipe = isSimple(essence) ? essence.theme.recipe : null;\n if (essenceRecipe && context.recipe !== essenceRecipe) {\n violations.push({\n rule: 'recipe',\n severity: 'error',\n message: `Recipe \"${context.recipe}\" does not match essence recipe \"${essenceRecipe}\".`,\n });\n }\n }\n\n // Rule 5: Density guard (strict only)\n if (isStrict && context.density_gap) {\n if (context.density_gap !== essence.density.content_gap) {\n violations.push({\n rule: 'density',\n severity: 'warning',\n message: `Content gap \"${context.density_gap}\" does not match essence density \"${essence.density.content_gap}\".`,\n });\n }\n }\n\n // Rule 6: Theme/mode compatibility (always checked when registry available)\n const themeModeViolation = checkThemeModeCompatibility(essence, context);\n if (themeModeViolation) {\n violations.push(themeModeViolation);\n }\n\n // Rule 7: Pattern existence (always checked when registry available)\n const patternViolations = checkPatternExistence(essence, context);\n violations.push(...patternViolations);\n\n // Rule 8: Accessibility (when wcag_level is set, guided and strict modes)\n const accessibilityViolation = checkAccessibility(essence, context);\n if (accessibilityViolation) {\n violations.push(accessibilityViolation);\n }\n\n return violations;\n}\n\nfunction getAllPages(essence: EssenceFile): StructurePage[] {\n if (isSimple(essence)) return essence.structure;\n if (isSectioned(essence)) return essence.sections.flatMap(s => s.structure);\n return [];\n}\n","import type { Essence, SectionedEssence, EssenceFile, StructurePage, GuardMode } from './types.js';\n\nexport function normalizeEssence(input: Record<string, unknown>): EssenceFile {\n // Detect v2: has 'theme' and 'platform' (normalized terms)\n if (input.theme && input.platform) {\n return input as unknown as EssenceFile;\n }\n\n if (input.sections) {\n return normalizeSectioned(input);\n }\n\n return normalizeSimple(input);\n}\n\nfunction normalizeSimple(v1: Record<string, unknown>): Essence {\n // v1 field names (wine terms) → v2 normalized names:\n // vintage → theme, vessel → platform, clarity → density,\n // cork → guard, terroir/vignette → archetype, tannins → features,\n // carafe → shell, blend → layout, character → personality\n const vintage = v1.vintage as Record<string, string> | undefined;\n const vessel = v1.vessel as Record<string, string> | undefined;\n const clarity = v1.clarity as Record<string, string> | undefined;\n const cork = v1.cork as Record<string, unknown> | undefined;\n const structure = v1.structure as Array<Record<string, unknown>> | undefined;\n\n return {\n version: '2.0.0',\n archetype: (v1.terroir ?? v1.vignette ?? v1.archetype) as string,\n theme: {\n style: vintage?.style ?? '',\n mode: (vintage?.mode ?? 'dark') as 'light' | 'dark' | 'auto',\n recipe: vintage?.recipe ?? '',\n ...(vintage?.shape ? { shape: vintage.shape as 'sharp' | 'rounded' | 'pill' } : {}),\n },\n // Accept both old 'character' and new 'personality' field names\n personality: (v1.character ?? v1.personality) as string[],\n platform: {\n type: (vessel?.type ?? 'spa') as 'spa' | 'ssr' | 'static',\n routing: (vessel?.routing ?? 'hash') as 'hash' | 'history',\n },\n structure: (structure ?? []).map(normalizeStructurePage),\n features: (v1.tannins ?? v1.features ?? []) as string[],\n density: {\n level: (clarity?.density ?? 'comfortable') as 'compact' | 'comfortable' | 'spacious',\n content_gap: stripGapPrefix(clarity?.content_gap ?? '4'),\n },\n guard: normalizeGuard(cork),\n target: (v1.target as string) ?? 'decantr',\n ...(v1._impression ? { _impression: v1._impression as Essence['_impression'] } : {}),\n };\n}\n\nfunction normalizeSectioned(v1: Record<string, unknown>): SectionedEssence {\n // v1 field names (wine terms) → v2 normalized names:\n // vessel → platform, clarity → density, cork → guard,\n // terroir/vignette → archetype, tannins → features,\n // shared_tannins → shared_features, character → personality\n const vessel = v1.vessel as Record<string, string> | undefined;\n const clarity = v1.clarity as Record<string, string> | undefined;\n const cork = v1.cork as Record<string, unknown> | undefined;\n const sections = v1.sections as Array<Record<string, unknown>>;\n\n return {\n version: '2.0.0',\n platform: {\n type: (vessel?.type ?? 'spa') as 'spa' | 'ssr' | 'static',\n routing: (vessel?.routing ?? 'hash') as 'hash' | 'history',\n },\n // Accept both old 'character' and new 'personality' field names\n personality: (v1.character ?? v1.personality) as string[],\n sections: sections.map(section => ({\n id: section.id as string,\n path: section.path as string,\n archetype: (section.terroir ?? section.vignette ?? section.archetype) as string,\n theme: {\n style: (section.vintage as Record<string, string>)?.style ?? '',\n mode: ((section.vintage as Record<string, string>)?.mode ?? 'dark') as 'light' | 'dark' | 'auto',\n recipe: (section.vintage as Record<string, string>)?.recipe ?? '',\n },\n structure: ((section.structure as Array<Record<string, unknown>>) ?? []).map(normalizeStructurePage),\n ...(section.tannins ? { features: section.tannins as string[] } : {}),\n })),\n ...(v1.shared_tannins ? { shared_features: v1.shared_tannins as string[] } : {}),\n density: {\n level: (clarity?.density ?? 'comfortable') as 'compact' | 'comfortable' | 'spacious',\n content_gap: stripGapPrefix(clarity?.content_gap ?? '4'),\n },\n guard: normalizeGuard(cork),\n target: (v1.target as string) ?? 'decantr',\n };\n}\n\nfunction normalizeStructurePage(page: Record<string, unknown>): StructurePage {\n // Accept v1 wine terms (carafe → shell, blend → layout) for backward compatibility\n return {\n id: page.id as string,\n shell: (page.carafe ?? page.shell) as string,\n layout: (page.blend ?? page.layout) as StructurePage['layout'],\n ...(page.surface ? { surface: page.surface as string } : {}),\n };\n}\n\n// Accept v1 'cork' object and normalize to v2 'guard'\nfunction normalizeGuard(cork: Record<string, unknown> | undefined): Essence['guard'] {\n if (!cork) return { mode: 'creative' };\n\n const modeMap: Record<string, GuardMode> = {\n creative: 'creative',\n maintenance: 'strict',\n strict: 'strict',\n guided: 'guided',\n };\n\n return {\n ...(cork.enforce_style !== undefined ? { enforce_style: cork.enforce_style as boolean } : {}),\n ...(cork.enforce_recipe !== undefined ? { enforce_recipe: cork.enforce_recipe as boolean } : {}),\n mode: modeMap[(cork.mode as string) ?? 'creative'] ?? 'creative',\n };\n}\n\nfunction stripGapPrefix(gap: string): string {\n const match = gap.match(/^_gap(\\d+)$/);\n return match ? match[1] : gap;\n}\n"],"mappings":";AA8KO,SAAS,YAAY,SAAmD;AAC7E,SAAO,cAAc,WAAW,MAAM,QAAS,QAA6B,QAAQ;AACtF;AAEO,SAAS,SAAS,SAA0C;AACjE,SAAO,eAAe,WAAW,EAAE,cAAc;AACnD;;;ACpLA,OAAO,SAAS;AAChB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAE9B,IAAM,YAAY,Q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,IACF,GAAI,GAAG,iBAAiB,EAAE,iBAAiB,GAAG,eAA2B,IAAI,CAAC;AAAA,IAC9E,SAAS;AAAA,MACP,OAAQ,SAAS,WAAW;AAAA,MAC5B,aAAa,eAAe,SAAS,eAAe,GAAG;AAAA,IACzD;AAAA,IACA,OAAO,eAAe,IAAI;AAAA,IAC1B,QAAS,GAAG,UAAqB;AAAA,EACnC;AACF;AAEA,SAAS,uBAAuB,MAA8C;AAE5E,SAAO;AAAA,IACL,IAAI,KAAK;AAAA,IACT,OAAQ,KAAK,UAAU,KAAK;AAAA,IAC5B,QAAS,KAAK,SAAS,KAAK;AAAA,IAC5B,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAkB,IAAI,CAAC;AAAA,EAC5D;AACF;AAGA,SAAS,eAAe,MAA6D;AACnF,MAAI,CAAC,KAAM,QAAO,EAAE,MAAM,WAAW;AAErC,QAAM,UAAqC;AAAA,IACzC,UAAU;AAAA,IACV,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAEA,SAAO;AAAA,IACL,GAAI,KAAK,kBAAkB,SAAY,EAAE,eAAe,KAAK,cAAyB,IAAI,CAAC;AAAA,IAC3F,GAAI,KAAK,mBAAmB,SAAY,EAAE,gBAAgB,KAAK,eAA0B,IAAI,CAAC;AAAA,IAC9F,MAAM,QAAS,KAAK,QAAmB,UAAU,KAAK;AAAA,EACxD;AACF;AAEA,SAAS,eAAe,KAAqB;AAC3C,QAAM,QAAQ,IAAI,MAAM,aAAa;AACrC,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decantr/essence-spec",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"description": "Essence schema, validator, and TypeScript types for Decantr",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,19 +21,16 @@
|
|
|
21
21
|
"import": "./schema/essence.v2.json"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"files": [
|
|
25
|
-
"dist",
|
|
26
|
-
"schema"
|
|
27
|
-
],
|
|
24
|
+
"files": ["dist", "schema"],
|
|
28
25
|
"publishConfig": {
|
|
29
26
|
"access": "public"
|
|
30
27
|
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"ajv": "^8.17.0"
|
|
33
|
-
},
|
|
34
28
|
"scripts": {
|
|
35
29
|
"build": "tsup",
|
|
36
30
|
"test": "vitest run",
|
|
37
31
|
"test:watch": "vitest"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"ajv": "^8.17.0"
|
|
38
35
|
}
|
|
39
|
-
}
|
|
36
|
+
}
|
package/schema/essence.v2.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"density": { "$ref": "#/$defs/Density" },
|
|
25
25
|
"guard": { "$ref": "#/$defs/Guard" },
|
|
26
26
|
"target": { "type": "string", "minLength": 1 },
|
|
27
|
+
"accessibility": { "$ref": "#/$defs/Accessibility" },
|
|
27
28
|
"_impression": { "$ref": "#/$defs/Impression" }
|
|
28
29
|
}
|
|
29
30
|
},
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"density": { "$ref": "#/$defs/Density" },
|
|
42
43
|
"guard": { "$ref": "#/$defs/Guard" },
|
|
43
44
|
"target": { "type": "string", "minLength": 1 },
|
|
45
|
+
"accessibility": { "$ref": "#/$defs/Accessibility" },
|
|
44
46
|
"_impression": { "$ref": "#/$defs/Impression" }
|
|
45
47
|
}
|
|
46
48
|
},
|
|
@@ -144,6 +146,22 @@
|
|
|
144
146
|
"structure": { "type": "array", "items": { "$ref": "#/$defs/StructurePage" }, "minItems": 1 },
|
|
145
147
|
"features": { "type": "array", "items": { "type": "string" } }
|
|
146
148
|
}
|
|
149
|
+
},
|
|
150
|
+
"Accessibility": {
|
|
151
|
+
"type": "object",
|
|
152
|
+
"additionalProperties": false,
|
|
153
|
+
"properties": {
|
|
154
|
+
"wcag_level": {
|
|
155
|
+
"type": "string",
|
|
156
|
+
"enum": ["none", "A", "AA", "AAA"],
|
|
157
|
+
"description": "WCAG compliance level requirement"
|
|
158
|
+
},
|
|
159
|
+
"cvd_preference": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"enum": ["none", "auto", "deuteranopia", "protanopia", "tritanopia", "achromatopsia"],
|
|
162
|
+
"description": "Color vision deficiency accommodation preference"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
147
165
|
}
|
|
148
166
|
}
|
|
149
167
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Decantr AI
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|