@decantr/core 1.0.5 → 2.0.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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resolve.ts","../src/utils.ts","../src/ir.ts","../src/ir-helpers.ts","../src/packs.ts","../src/pipeline.ts"],"sourcesContent":["import type {\n BlueprintPage,\n ColumnLayout,\n Essence,\n EssenceFile,\n EssenceV3,\n LayoutItem,\n PatternRef,\n SectionedEssence,\n StructurePage,\n} from '@decantr/essence-spec';\nimport { computeDensity, isSectioned, isSimple, isV3 } from '@decantr/essence-spec';\nimport type {\n ContentResolver,\n Pattern,\n Theme as RegistryTheme,\n ResolvedPreset,\n} from '@decantr/registry';\nimport { detectWirings, resolvePatternPreset } from '@decantr/registry';\nimport type {\n IRNavItem,\n IRRoute,\n IRShellConfig,\n IRTheme,\n IRThemeDecoration,\n IRVisualEffect,\n IRWiring,\n IRWiringSignal,\n} from './types.js';\nimport { pascalCase } from './utils.js';\n\nexport interface ResolvedPage {\n page: ResolvedStructurePage;\n patterns: Map<string, { pattern: Pattern; preset: ResolvedPreset }>;\n wiring: IRWiring | null;\n}\n\ntype ResolvedStructurePage = StructurePage & {\n sectionId?: string;\n route?: string;\n};\n\nexport interface ResolvedEssence {\n essence: EssenceFile;\n pages: ResolvedPage[];\n registryTheme: RegistryTheme | null;\n density: { gap: string; level: string };\n theme: IRTheme;\n shell: IRShellConfig;\n routes: IRRoute[];\n features: string[];\n /** True when the source essence was v3 (DNA/Blueprint/Meta) */\n isV3Source: boolean;\n}\n\n// ─── Icon Mapping ─────────────────────────────────────────────\n\nconst NAV_ICONS: Record<string, string> = {\n overview: 'layout-dashboard',\n dashboard: 'layout-dashboard',\n home: 'home',\n analytics: 'bar-chart-3',\n settings: 'settings',\n users: 'users',\n billing: 'credit-card',\n reports: 'file-text',\n catalog: 'grid',\n products: 'package',\n orders: 'shopping-cart',\n messages: 'message-square',\n notifications: 'bell',\n activity: 'activity',\n search: 'search',\n profile: 'user',\n team: 'users',\n integrations: 'puzzle',\n api: 'code',\n docs: 'book-open',\n help: 'help-circle',\n projects: 'folder',\n workflows: 'git-branch',\n monitoring: 'monitor',\n security: 'shield',\n storage: 'database',\n deployments: 'rocket',\n logs: 'scroll-text',\n};\n\n// ─── Core styles that don't need explicit addon registration ──\n\nconst CORE_STYLES = new Set(['auradecantism']);\n\n// ─── Helpers ──────────────────────────────────────────────────\n\nfunction isPatternRef(item: LayoutItem): item is PatternRef {\n return typeof item === 'object' && 'pattern' in item;\n}\n\nfunction isColumnLayout(item: LayoutItem): item is ColumnLayout {\n return typeof item === 'object' && 'cols' in item;\n}\n\nfunction extractLayoutRefs(\n layout: LayoutItem[],\n): { id: string; explicitPreset?: string; alias?: string }[] {\n const refs: { id: string; explicitPreset?: string; alias?: string }[] = [];\n for (const item of layout) {\n if (typeof item === 'string') {\n refs.push({ id: item });\n } else if (isPatternRef(item)) {\n refs.push({ id: item.pattern, explicitPreset: item.preset, alias: item.as });\n } else if (isColumnLayout(item)) {\n // cols can mix string ids and PatternRef objects per the schema.\n // Normalize each entry so downstream resolvers always see a string id.\n for (const col of item.cols) {\n if (typeof col === 'string') {\n refs.push({ id: col });\n } else {\n refs.push({ id: col.pattern, explicitPreset: col.preset, alias: col.as });\n }\n }\n }\n }\n return refs;\n}\n\n/** Flatten a layout array so column children are promoted to top-level for wiring detection */\nfunction flattenLayoutForWiring(layout: LayoutItem[]): LayoutItem[] {\n const flat: LayoutItem[] = [];\n for (const item of layout) {\n if (typeof item === 'string') {\n flat.push(item);\n } else if (isPatternRef(item)) {\n flat.push(item);\n } else if (isColumnLayout(item)) {\n // Promote column children as string refs\n for (const col of item.cols) {\n flat.push(col);\n }\n }\n }\n return flat;\n}\n\nfunction routePath(pageId: string, index: number): string {\n if (index === 0) return '/';\n // AUTO: Pages ending in \"-detail\" get a dynamic :id route parameter\n if (pageId.endsWith('-detail')) {\n return `/${pageId}/:id`;\n }\n return `/${pageId}`;\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction buildNavItems(pages: ResolvedStructurePage[], routes?: IRRoute[]): IRNavItem[] {\n const routeLookup = new Map<string, string>(\n (routes ?? []).map((route) => [routeIdentity(route.pageId, route.sectionId), route.path]),\n );\n return pages.map((page, i) => ({\n href: routeLookup.get(routeIdentity(page.id, page.sectionId)) ?? routePath(page.id, i),\n icon: NAV_ICONS[page.id] || 'circle',\n label: capitalize(page.id.replace(/-/g, ' ')),\n }));\n}\n\nfunction buildThemeDecoration(theme: RegistryTheme): IRThemeDecoration | null {\n const shell = theme.shell;\n if (!shell) return null;\n // The JSON may have additional fields not in the strict type\n const shellAny = shell as unknown as Record<string, unknown>;\n return {\n root: shell.root || '',\n nav: shell.nav || '',\n header: shell.header || '',\n brand: (shellAny['brand'] as string) || '',\n navLabel: (shellAny['navLabel'] as string) || '',\n // AUTO: default nav style is 'pill' when the theme does not declare one\n navStyle: shell.nav_style || 'pill',\n defaultNavState: (shellAny['default_nav_state'] as string) || 'expanded',\n dimensions: shell.dimensions || null,\n };\n}\n\nfunction buildTheme(essence: Essence, isAddon: boolean): IRTheme {\n return {\n id: essence.theme.id,\n mode: essence.theme.mode,\n shape: essence.theme.shape || null,\n isAddon,\n };\n}\n\nfunction buildThemeFromV3(essence: EssenceV3, isAddon: boolean): IRTheme {\n const dna = essence.dna;\n return {\n id: dna.theme.id,\n mode: dna.theme.mode,\n shape: dna.radius.philosophy || dna.theme.shape || null,\n isAddon,\n };\n}\n\n/** Convert v3 BlueprintPage to the StructurePage shape used by the resolver pipeline */\nfunction blueprintPageToStructurePage(\n page: BlueprintPage,\n defaultShell: string,\n sectionId?: string,\n): ResolvedStructurePage {\n return {\n id: page.id,\n shell: page.shell_override ?? defaultShell,\n layout: page.layout,\n ...(sectionId ? { sectionId } : {}),\n ...(page.route ? { route: page.route } : {}),\n ...(page.surface ? { surface: page.surface } : {}),\n };\n}\n\nfunction routeIdentity(pageId: string, sectionId?: string): string {\n return sectionId ? `${sectionId}:${pageId}` : pageId;\n}\n\nfunction buildV3Routes(essence: EssenceV3, structurePages: ResolvedStructurePage[]): IRRoute[] {\n const explicitRoutes = new Map<string, string>();\n\n for (const [path, entry] of Object.entries(essence.blueprint.routes ?? {})) {\n if (!entry?.page) continue;\n const key = routeIdentity(entry.page, entry.section);\n if (!explicitRoutes.has(key)) {\n explicitRoutes.set(key, path);\n }\n }\n\n for (const page of structurePages) {\n const key = routeIdentity(page.id, page.sectionId);\n if (page.route && !explicitRoutes.has(key)) {\n explicitRoutes.set(key, page.route);\n }\n }\n\n if (explicitRoutes.size > 0) {\n return structurePages.flatMap((page) => {\n const path = explicitRoutes.get(routeIdentity(page.id, page.sectionId));\n return path\n ? [\n {\n path,\n pageId: page.id,\n shell: page.shell,\n ...(page.sectionId ? { sectionId: page.sectionId } : {}),\n },\n ]\n : [];\n });\n }\n\n return structurePages.map((page, i) => ({\n path: routePath(page.id, i),\n pageId: page.id,\n shell: page.shell,\n ...(page.sectionId ? { sectionId: page.sectionId } : {}),\n }));\n}\n\nfunction convertWiring(wiringResults: ReturnType<typeof detectWirings>): IRWiring | null {\n if (wiringResults.length === 0) return null;\n\n const signals: IRWiringSignal[] = [];\n const props: Record<string, Record<string, string>> = {};\n const hookProps: Record<string, Record<string, string>> = {};\n const hookSet = new Set<IRWiringSignal['hookType']>();\n\n for (const result of wiringResults) {\n for (const signal of result.signals) {\n // Avoid duplicate signals\n if (!signals.some((s) => s.name === signal.name)) {\n const setter = 'set' + signal.name.charAt(0).toUpperCase() + signal.name.slice(1);\n signals.push({\n name: signal.name,\n setter,\n init: signal.init,\n hookType: signal.hookType,\n });\n hookSet.add(signal.hookType);\n }\n }\n for (const [alias, aliasProps] of Object.entries(result.props)) {\n props[alias] = { ...props[alias], ...aliasProps };\n }\n // AUTO: Merge hook-based prop mappings\n for (const [alias, aliasHookProps] of Object.entries(result.hookProps)) {\n hookProps[alias] = { ...hookProps[alias], ...aliasHookProps };\n }\n }\n\n return { signals, props, hooks: [...hookSet], hookProps };\n}\n\n// ─── Visual Effects Resolution ────────────────────────────────\n\nexport function resolveVisualEffects(\n theme: RegistryTheme,\n pattern: Pattern,\n _slot?: string,\n): IRVisualEffect | null {\n const effects = theme.effects;\n if (!effects?.enabled) return null;\n\n const typeMapping = effects.type_mapping || {};\n const componentFallback = effects.component_fallback || {};\n const intensity = effects.intensity || 'medium';\n const intensityValues = effects.intensity_values || {};\n\n // Check pattern tags / components against type_mapping\n let decorators: string[] = [];\n\n // Check if any pattern components match the component_fallback\n for (const comp of pattern.components || []) {\n const effectType = componentFallback[comp];\n if (effectType && typeMapping[effectType]) {\n decorators = [...decorators, ...typeMapping[effectType]];\n }\n }\n\n if (decorators.length === 0) return null;\n\n // Deduplicate\n decorators = [...new Set(decorators)];\n\n return {\n decorators,\n intensity: intensityValues[intensity] || {},\n };\n}\n\n// ─── Main Resolution ─────────────────────────────────────────\n\n/** Resolve all external references in an Essence file */\nexport async function resolveEssence(\n essence: EssenceFile,\n resolver: ContentResolver,\n): Promise<ResolvedEssence> {\n // ─── V3 path: read from dna + blueprint layers ───────────\n if (isV3(essence)) {\n return resolveV3Essence(essence, resolver);\n }\n\n // ─── V2 path: simple or sectioned ────────────────────────\n let simpleEssence: Essence;\n if (isSimple(essence)) {\n simpleEssence = essence;\n } else if (isSectioned(essence)) {\n const sectioned = essence as SectionedEssence;\n if (sectioned.sections.length > 1) {\n throw new Error(\n `Sectioned essences with ${sectioned.sections.length} sections are not yet supported. ` +\n `Only single-section sectioned essences can be processed. ` +\n `Consider migrating to v3 format using migrateV2ToV3().`,\n );\n }\n const firstSection = sectioned.sections[0];\n simpleEssence = {\n version: sectioned.version,\n archetype: firstSection.archetype,\n theme: firstSection.theme,\n personality: sectioned.personality,\n platform: sectioned.platform,\n structure: firstSection.structure,\n features: firstSection.features || [],\n density: sectioned.density,\n guard: sectioned.guard,\n target: sectioned.target,\n };\n } else {\n throw new Error('Invalid essence format');\n }\n\n // 1. Theme resolution (replaces former recipe resolution)\n let registryTheme: RegistryTheme | null = null;\n const themeResult = await resolver.resolve('theme', simpleEssence.theme.id);\n if (themeResult) {\n registryTheme = themeResult.item;\n }\n\n // 2. Density computation\n const themeSpatial = registryTheme?.spatial;\n const density = computeDensity(\n simpleEssence.personality,\n themeSpatial\n ? {\n density_bias: themeSpatial.density_bias,\n content_gap_shift: themeSpatial.content_gap_shift,\n }\n : undefined,\n );\n\n // 3. Theme\n const themeId = simpleEssence.theme.id;\n const isAddon = themeId.startsWith('custom:') || !CORE_STYLES.has(themeId);\n const theme = buildTheme(simpleEssence, isAddon);\n\n // 4. Resolve each page\n const resolvedPages = await resolvePages(simpleEssence.structure, resolver, registryTheme);\n\n // 5. Shell config\n const shellType = simpleEssence.structure[0]?.shell || 'sidebar-main';\n const brand = pascalCase(simpleEssence.archetype);\n const nav = buildNavItems(simpleEssence.structure);\n const decoration = registryTheme ? buildThemeDecoration(registryTheme) : null;\n\n const shell: IRShellConfig = {\n type: shellType,\n brand,\n nav,\n inset: false,\n decoration,\n };\n\n // 6. Routes\n const routes: IRRoute[] = simpleEssence.structure.map((page, i) => ({\n path: routePath(page.id, i),\n pageId: page.id,\n shell: page.shell,\n }));\n\n return {\n essence,\n pages: resolvedPages,\n registryTheme,\n density: { gap: density.content_gap, level: density.level },\n theme,\n shell,\n routes,\n features: simpleEssence.features ?? [],\n isV3Source: false,\n };\n}\n\n// ─── V3 Resolution ──────────────────────────────────────────\n\nasync function resolveV3Essence(\n essence: EssenceV3,\n resolver: ContentResolver,\n): Promise<ResolvedEssence> {\n const { dna, blueprint, meta } = essence;\n\n // 1. Theme resolution (replaces former recipe resolution)\n let registryTheme: RegistryTheme | null = null;\n const themeResult = await resolver.resolve('theme', dna.theme.id);\n if (themeResult) {\n registryTheme = themeResult.item;\n }\n\n // 2. Density — v3 carries density directly in dna.spacing\n const themeSpatial = registryTheme?.spatial;\n const density = computeDensity(\n dna.personality,\n themeSpatial\n ? {\n density_bias: themeSpatial.density_bias,\n content_gap_shift: themeSpatial.content_gap_shift,\n }\n : undefined,\n );\n // V3 dna.spacing is authoritative; override computed density with DNA values\n const densityResult = {\n gap: dna.spacing.content_gap || density.content_gap,\n level: dna.spacing.density || density.level,\n };\n\n // 3. Theme from DNA layer\n const themeId = dna.theme.id;\n const isAddon = themeId.startsWith('custom:') || !CORE_STYLES.has(themeId);\n const theme = buildThemeFromV3(essence, isAddon);\n\n // 4. Convert blueprint pages to StructurePage and resolve\n // V3.1 essences may use sections instead of pages; flatten sections into pages\n const defaultShell = blueprint.shell ?? blueprint.sections?.[0]?.shell ?? 'sidebar-main';\n const structurePages: ResolvedStructurePage[] = blueprint.pages\n ? blueprint.pages.map((page) => blueprintPageToStructurePage(page, defaultShell))\n : blueprint.sections\n ? blueprint.sections.flatMap((section) =>\n section.pages.map((page) =>\n blueprintPageToStructurePage(page, section.shell ?? defaultShell, section.id),\n ),\n )\n : [\n blueprintPageToStructurePage(\n { id: 'home', layout: ['hero'] as LayoutItem[] },\n defaultShell,\n ),\n ];\n const resolvedPages = await resolvePages(structurePages, resolver, registryTheme);\n\n // 5. Shell config from blueprint\n const shellType = defaultShell;\n const brand = pascalCase(meta.archetype);\n const routes = buildV3Routes(essence, structurePages);\n const nav = buildNavItems(structurePages, routes);\n const decoration = registryTheme ? buildThemeDecoration(registryTheme) : null;\n\n const shell: IRShellConfig = {\n type: shellType,\n brand,\n nav,\n inset: false,\n decoration,\n };\n\n return {\n essence,\n pages: resolvedPages,\n registryTheme,\n density: densityResult,\n theme,\n shell,\n routes,\n features: blueprint.features ?? [],\n isV3Source: true,\n };\n}\n\n// ─── Shared page resolution ────────────────────────────────\n\nasync function resolvePages(\n pages: ResolvedStructurePage[],\n resolver: ContentResolver,\n registryTheme: RegistryTheme | null,\n): Promise<ResolvedPage[]> {\n const resolvedPages: ResolvedPage[] = [];\n for (const page of pages) {\n const refs = extractLayoutRefs(page.layout);\n const patterns = new Map<string, { pattern: Pattern; preset: ResolvedPreset }>();\n\n for (const ref of refs) {\n const patternResult = await resolver.resolve('pattern', ref.id);\n if (patternResult) {\n const preset = resolvePatternPreset(\n patternResult.item,\n ref.explicitPreset,\n registryTheme?.pattern_preferences?.default_presets,\n );\n const key = ref.alias || ref.id;\n patterns.set(key, { pattern: patternResult.item, preset });\n }\n }\n\n // Detect wiring (flatten cols so column children are visible)\n const wiringResults = detectWirings(flattenLayoutForWiring(page.layout));\n const wiring = convertWiring(wiringResults);\n\n resolvedPages.push({ page, patterns, wiring });\n }\n return resolvedPages;\n}\n","/** Convert a kebab-case or snake_case string to PascalCase */\nexport function pascalCase(str: string): string {\n return str\n .split(/[-_]/)\n .map((s) => s.charAt(0).toUpperCase() + s.slice(1))\n .join('');\n}\n","import type { ColumnLayout, LayoutItem, PatternRef, StructurePage } from '@decantr/essence-spec';\nimport type { Pattern, Theme as RegistryTheme, ResolvedPreset } from '@decantr/registry';\nimport { resolveVisualEffects } from './resolve.js';\nimport type {\n IRCardWrapping,\n IRGridNode,\n IRLayer,\n IRNode,\n IRPageNode,\n IRPatternMeta,\n IRPatternNode,\n IRVisualEffect,\n IRWiring,\n} from './types.js';\n\nexport interface ResolvedPatternEntry {\n pattern: Pattern;\n preset: ResolvedPreset;\n}\n\nfunction isPatternRef(item: LayoutItem): item is PatternRef {\n return typeof item === 'object' && 'pattern' in item;\n}\n\nfunction isColumnLayout(item: LayoutItem): item is ColumnLayout {\n return typeof item === 'object' && 'cols' in item;\n}\n\nfunction getPatternAlias(item: LayoutItem): string {\n if (typeof item === 'string') return item;\n if (isPatternRef(item)) return item.as || item.pattern;\n return '';\n}\n\nfunction getPatternId(item: LayoutItem): string {\n if (typeof item === 'string') return item;\n if (isPatternRef(item)) return item.pattern;\n return '';\n}\n\nfunction shouldWrapInCard(\n pattern: Pattern,\n preset: ResolvedPreset,\n theme: RegistryTheme | null,\n): boolean {\n // Hero/row/stack layouts are standalone\n const layout = preset.layout.layout;\n if (layout === 'hero' || layout === 'row') return false;\n\n // Pattern explicitly opts out\n if (pattern.contained === false) return false;\n\n // Theme spatial says no cards\n const cardWrapping = theme?.spatial?.card_wrapping;\n if (cardWrapping === 'none') return false;\n\n // Minimal: only wrap if pattern has presets (complex pattern)\n if (cardWrapping === 'minimal') {\n return Object.keys(pattern.presets).length > 0;\n }\n\n // Default: wrap\n return true;\n}\n\nfunction buildCardWrapping(pattern: Pattern, theme: RegistryTheme | null): IRCardWrapping {\n const mode = theme?.spatial?.card_wrapping || 'always';\n return {\n mode: mode as IRCardWrapping['mode'],\n headerLabel: pattern.name,\n };\n}\n\nfunction buildPatternNode(\n patternId: string,\n alias: string,\n resolved: ResolvedPatternEntry | undefined,\n wiring: IRWiring | null,\n theme: RegistryTheme | null,\n density: { gap: string },\n layer?: IRLayer,\n): IRPatternNode {\n const pattern = resolved?.pattern;\n const preset = resolved?.preset;\n\n const layout = preset?.layout.layout || 'column';\n const isStandalone = layout === 'hero' || layout === 'row';\n const contained = pattern && preset ? shouldWrapInCard(pattern, preset, theme) : false;\n const components = pattern?.components || [];\n\n const presetName = preset?.preset || 'default';\n const presetDescription = pattern?.presets?.[presetName]?.description;\n // v2.1 C1: thread interactions[] from the pattern through to PagePackPattern\n // so the page-pack renderer can surface them as a checkbox checklist.\n const interactions = Array.isArray((pattern as { interactions?: unknown })?.interactions)\n ? ((pattern as { interactions?: unknown }).interactions as string[])\n : undefined;\n\n const patternMeta: IRPatternMeta = {\n patternId,\n preset: presetName,\n alias,\n layout,\n contained,\n standalone: isStandalone,\n code: preset?.code ? { imports: preset.code.imports, example: preset.code.example } : null,\n components,\n ...(presetDescription ? { presetDescription } : {}),\n ...(interactions && interactions.length > 0 ? { interactions } : {}),\n };\n\n const card = contained && !isStandalone && pattern ? buildCardWrapping(pattern, theme) : null;\n\n const wireProps = wiring?.props[alias] || wiring?.props[patternId] || null;\n\n // Resolve visual effects from theme + pattern when available\n const visualEffects = theme && pattern ? resolveVisualEffects(theme, pattern) : null;\n\n return {\n type: 'pattern',\n id: alias,\n children: [],\n pattern: patternMeta,\n card,\n visualEffects,\n wireProps,\n spatial: { gap: density.gap },\n ...(layer ? { layer } : {}),\n };\n}\n\n/** Build IR tree for a single page from its resolved structure + patterns */\nexport function buildPageIR(\n page: StructurePage & { sectionId?: string },\n resolvedPatterns: Map<string, ResolvedPatternEntry>,\n wiring: IRWiring | null,\n theme: RegistryTheme | null,\n density: { gap: string },\n layer?: IRLayer,\n): IRPageNode {\n const children: IRNode[] = [];\n\n for (const item of page.layout) {\n if (typeof item === 'string') {\n // Simple string → full-width pattern\n const resolved = resolvedPatterns.get(item);\n children.push(buildPatternNode(item, item, resolved, wiring, theme, density, layer));\n } else if (isPatternRef(item)) {\n // PatternRef → pattern with optional preset/alias\n const alias = item.as || item.pattern;\n const resolved = resolvedPatterns.get(alias) || resolvedPatterns.get(item.pattern);\n children.push(buildPatternNode(item.pattern, alias, resolved, wiring, theme, density, layer));\n } else if (isColumnLayout(item)) {\n // ColumnLayout → grid with pattern children\n // cols can mix `string` ids and `PatternRef` objects per the schema.\n // Normalize FIRST so all downstream operations (Map keys, Record\n // keys, joined ids) see strings — otherwise PatternRef objects\n // serialize as `[object Object]` (cold-LLM harness flagged this\n // exact bug in cloud-platform's scaffold-pack).\n const colEntries = item.cols.map((col) => ({\n id: typeof col === 'string' ? col : col.pattern,\n alias:\n typeof col === 'string'\n ? col\n : (col.as ?? col.pattern),\n }));\n const breakpoint = item.at || null;\n const spans = item.span || null;\n\n // Normalize spans: fill in missing columns with weight 1.\n // Span keys reference column ids (the schema's span object uses\n // the column's effective id as the key).\n let normalizedSpans: Record<string, number> | null = null;\n if (spans) {\n normalizedSpans = {};\n for (const entry of colEntries) {\n normalizedSpans[entry.id] = spans[entry.id] || spans[entry.alias] || 1;\n }\n }\n\n const gridChildren: IRNode[] = [];\n for (const entry of colEntries) {\n const resolved =\n resolvedPatterns.get(entry.alias) || resolvedPatterns.get(entry.id);\n gridChildren.push(\n buildPatternNode(entry.id, entry.alias, resolved, wiring, theme, density, layer),\n );\n }\n\n const totalCols = normalizedSpans\n ? Object.values(normalizedSpans).reduce((a, b) => a + b, 0)\n : colEntries.length;\n\n // AUTO: Pass through multi-breakpoint and container query config from ColumnLayout\n const breakpoints = item.breakpoints?.map((bp) => ({ at: bp.at, cols: bp.cols })) || null;\n const responsive = item.responsive || null;\n\n const gridNode: IRGridNode = {\n type: 'grid',\n id: `grid-${colEntries.map((e) => e.id).join('-')}`,\n children: gridChildren,\n cols: totalCols,\n spans: normalizedSpans,\n breakpoint,\n breakpoints,\n responsive,\n spatial: { gap: density.gap },\n ...(layer ? { layer } : {}),\n };\n children.push(gridNode);\n }\n }\n\n const gapAtom = density.gap.startsWith('_')\n ? density.gap\n : density.gap.startsWith('gap')\n ? `_${density.gap}`\n : `_gap${density.gap}`;\n // Page surface declares layout direction + content gap ONLY. Padding, scroll\n // containment, and flex-grow belong to the shell per the \"Layout Rules\"\n // directive in DECANTR.md (\"One scroll container per region\", \"Let shells\n // own spacing, centering, and scroll containers\", \"Pages should not\n // duplicate shell responsibilities\"). Previous default (`_p4 _overauto\n // _flex1`) contradicted that directive and the v3 harness flagged it as\n // the single most expensive contract-ambiguity friction point. Pages that\n // genuinely need to claim scroll/padding can still declare it explicitly\n // via `page.surface` — the fallback just stops prescribing it.\n const surface = page.surface || `_flex _col ${gapAtom}`;\n\n return {\n type: 'page',\n id: page.sectionId ? `${page.sectionId}:${page.id}` : page.id,\n children,\n pageId: page.id,\n ...(page.sectionId ? { sectionId: page.sectionId } : {}),\n surface,\n wiring,\n ...(layer ? { layer } : {}),\n };\n}\n","import type { IRGridNode, IRNode, IRPatternNode } from './types.js';\n\n/** Depth-first walk of IR tree, calling visitor on each node */\nexport function walkIR(\n node: IRNode,\n visitor: (node: IRNode, parent: IRNode | null) => void,\n parent: IRNode | null = null,\n): void {\n visitor(node, parent);\n for (const child of node.children) {\n walkIR(child, visitor, node);\n }\n}\n\n/** Find all nodes of a specific type */\nexport function findNodes<T extends IRNode>(root: IRNode, type: string): T[] {\n const results: T[] = [];\n walkIR(root, (node) => {\n if (node.type === type) {\n results.push(node as T);\n }\n });\n return results;\n}\n\n/** Count total patterns in an IR tree */\nexport function countPatterns(root: IRNode): number {\n return findNodes(root, 'pattern').length;\n}\n\n/** Validate IR tree structure (no orphaned grids, patterns have meta, etc.) */\nexport function validateIR(root: IRNode): string[] {\n const errors: string[] = [];\n\n walkIR(root, (node, parent) => {\n if (node.type === 'grid') {\n const grid = node as IRGridNode;\n if (grid.children.length === 0) {\n errors.push(`Grid node \"${grid.id}\" has no children`);\n }\n }\n\n if (node.type === 'pattern') {\n const pattern = node as IRPatternNode;\n if (!pattern.pattern) {\n errors.push(`Pattern node \"${pattern.id}\" is missing pattern meta`);\n }\n if (!pattern.pattern.patternId) {\n errors.push(`Pattern node \"${pattern.id}\" has no patternId`);\n }\n }\n\n if (node.type === 'page') {\n if (!node.id) {\n errors.push('Page node is missing id');\n }\n }\n });\n\n return errors;\n}\n","import type { EssenceFile, EssenceV3 } from '@decantr/essence-spec';\nimport { isV3, migrateV2ToV3 } from '@decantr/essence-spec';\nimport type { ContentResolver } from '@decantr/registry';\nimport { walkIR } from './ir-helpers.js';\nimport { runPipeline } from './pipeline.js';\nimport type { IRAppNode, IRNode, IRPageNode, IRPatternNode } from './types.js';\n\nexport type ExecutionPackType = 'scaffold' | 'section' | 'page' | 'mutation' | 'review';\n\nexport const EXECUTION_PACK_SCHEMA_URLS = {\n scaffold: 'https://decantr.ai/schemas/scaffold-pack.v1.json',\n section: 'https://decantr.ai/schemas/section-pack.v1.json',\n page: 'https://decantr.ai/schemas/page-pack.v1.json',\n mutation: 'https://decantr.ai/schemas/mutation-pack.v1.json',\n review: 'https://decantr.ai/schemas/review-pack.v1.json',\n} as const;\n\nexport const PACK_MANIFEST_SCHEMA_URL = 'https://decantr.ai/schemas/pack-manifest.v1.json';\nexport const EXECUTION_PACK_BUNDLE_SCHEMA_URL =\n 'https://decantr.ai/schemas/execution-pack-bundle.v1.json';\nexport const SELECTED_EXECUTION_PACK_SCHEMA_URL =\n 'https://decantr.ai/schemas/selected-execution-pack.v1.json';\n\nexport interface ExecutionPackTarget {\n platform: 'web';\n framework: string | null;\n runtime: string | null;\n adapter: string;\n}\n\nexport interface ExecutionPackScope {\n appId: string;\n pageIds: string[];\n patternIds: string[];\n}\n\nexport interface ExecutionPackExample {\n id: string;\n label: string;\n language: string;\n snippet: string;\n}\n\nexport interface ExecutionPackAntiPattern {\n id: string;\n summary: string;\n guidance: string;\n}\n\nexport interface ExecutionPackSuccessCheck {\n id: string;\n label: string;\n severity: 'error' | 'warn' | 'info';\n}\n\nexport interface ExecutionPackTokenBudget {\n target: number;\n max: number;\n strategy: string[];\n}\n\nexport interface ExecutionPackBase<TData> {\n $schema: string;\n packVersion: '1.0.0';\n packType: ExecutionPackType;\n objective: string;\n target: ExecutionPackTarget;\n preset: string | null;\n scope: ExecutionPackScope;\n requiredSetup: string[];\n allowedVocabulary: string[];\n examples: ExecutionPackExample[];\n antiPatterns: ExecutionPackAntiPattern[];\n successChecks: ExecutionPackSuccessCheck[];\n tokenBudget: ExecutionPackTokenBudget;\n data: TData;\n renderedMarkdown: string;\n}\n\nexport interface PackManifestEntry {\n id: string;\n markdown: string;\n json: string;\n}\n\nexport interface PackManifestSectionEntry extends PackManifestEntry {\n pageIds: string[];\n}\n\nexport interface PackManifestPageEntry extends PackManifestEntry {\n sectionId: string | null;\n sectionRole: string | null;\n}\n\nexport interface PackManifestMutationEntry extends PackManifestEntry {\n mutationType: MutationPackKind;\n}\n\nexport interface ExecutionPackManifest {\n $schema: string;\n version: '1.0.0';\n generatedAt: string;\n scaffold: PackManifestEntry | null;\n review: PackManifestEntry | null;\n sections: PackManifestSectionEntry[];\n pages: PackManifestPageEntry[];\n mutations: PackManifestMutationEntry[];\n}\n\nexport interface ScaffoldPackRoute {\n pageId: string;\n sectionId?: string;\n path: string;\n patternIds: string[];\n shell?: string;\n}\n\nexport interface ScaffoldPackData {\n shell: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routing: 'hash' | 'history' | 'pathname';\n features: string[];\n navigation?: {\n /**\n * true = palette enabled with implicit defaults.\n * false = not enabled.\n * object = explicit structured contract (see CommandPaletteContract).\n */\n commandPalette: boolean | CommandPaletteContract;\n hotkeys: Array<{\n key: string;\n route?: string;\n label?: string;\n semantics?: HotkeySemantics;\n }>;\n /** Default hotkey semantics applied unless per-hotkey semantics override. */\n hotkeySemantics?: HotkeySemantics;\n };\n routes: ScaffoldPackRoute[];\n /**\n * Required theme decorator contract — surfaced ONCE at the project level\n * here, then referenced (not duplicated) in each section pack. Cold-LLM\n * runs reported the table was duplicated 7-10× across context files\n * (~270-540 redundant lines per scaffold) when each section pack carried\n * its own copy. Centralizing in scaffold-pack — which the cold prompt\n * tells AI to read first — keeps the contract authoritative without the\n * per-section repetition.\n */\n themeDecorators?: ThemeDecoratorEntry[];\n}\n\nexport interface CommandPaletteContract {\n trigger?: string;\n placeholder?: string;\n width?: string;\n styling?: 'modal' | 'sheet' | 'inline' | 'fullscreen';\n commands?: Array<{\n id: string;\n label: string;\n section?: string;\n hotkey?: string;\n action?: string;\n route?: string;\n }>;\n}\n\nexport interface HotkeySemantics {\n chord_window_ms?: number;\n input_guard?: boolean;\n modifier_suppression?: boolean;\n match_case?: boolean;\n}\n\nexport interface ScaffoldExecutionPack extends ExecutionPackBase<ScaffoldPackData> {\n packType: 'scaffold';\n}\n\nexport interface SectionPackInput {\n id: string;\n role: string;\n shell: string;\n description: string;\n features: string[];\n pageIds: string[];\n navigationItems?: SectionNavigationItemPack[];\n /** Execution-level directives — short imperative rules for this section. */\n directives?: string[];\n}\n\n/** Navigation item contract for a section's primary navigation. */\nexport interface SectionNavigationItemPack {\n label: string;\n route: string;\n icon?: string;\n hotkey?: string;\n active_match?: string;\n badge?: string;\n}\n\nexport interface SectionPackRoute {\n pageId: string;\n sectionId?: string;\n path: string;\n patternIds: string[];\n shell?: string;\n}\n\nexport interface SectionPackData {\n sectionId: string;\n role: string;\n shell: string;\n description: string;\n features: string[];\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routes: SectionPackRoute[];\n /** Contract for items rendered in this section's primary navigation. */\n navigationItems?: SectionNavigationItemPack[];\n /** Execution-level directives emitted into the section-pack rendering. */\n directives?: string[];\n /**\n * Required theme decorator contract surfaced into the compact pack.\n * Mirrors the long-form section-context \"Required Theme Decorators\" table.\n * Cold prompts instruct AI assistants to read packs first, so the strong\n * decorator contract has to live HERE, not just in the long-form file.\n */\n themeDecorators?: ThemeDecoratorEntry[];\n}\n\n/** Compact, render-ready decorator entry for pack contracts. */\nexport interface ThemeDecoratorEntry {\n /** Decorator class name without leading dot, e.g. \"lum-glass\". */\n class: string;\n /** Authored intent describing what the decorator does. */\n intent: string;\n /** Authored slot hints listing where to apply it (joined from usage[]). */\n applyTo: string;\n}\n\nexport interface SectionExecutionPack extends ExecutionPackBase<SectionPackData> {\n packType: 'section';\n}\n\nexport interface PagePackInput {\n pageId: string;\n shell: string;\n sectionId: string | null;\n sectionRole: string | null;\n features: string[];\n /** Execution-level directives — short imperative rules for this page. */\n directives?: string[];\n}\n\nexport interface PagePackPattern {\n id: string;\n alias: string;\n preset: string;\n layout: string;\n /**\n * Per-preset prose from the pattern's preset.description. When present,\n * the page-pack renderer emits it as a short description line so cold\n * LLMs read preset-specific guidance instead of having to look up the\n * pattern's root description.\n */\n presetDescription?: string;\n /**\n * v2.1 Tier C1. Declared interactions from the pattern JSON. Rendered\n * as a checkbox checklist so cold LLMs in generation mode see a\n * hard-edged list they can't categorize as \"philosophy\". Enforced by\n * decantr check --strict (C5 guard rule).\n */\n interactions?: string[];\n}\n\nexport interface PagePackData {\n pageId: string;\n path: string;\n shell: string;\n sectionId: string | null;\n sectionRole: string | null;\n features: string[];\n surface: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n wiringSignals: string[];\n patterns: PagePackPattern[];\n /** Execution-level directives emitted into the page-pack rendering. */\n directives?: string[];\n}\n\nexport interface PageExecutionPack extends ExecutionPackBase<PagePackData> {\n packType: 'page';\n}\n\nexport type MutationPackKind = 'add-page' | 'modify';\n\nexport interface MutationPackData {\n mutationType: MutationPackKind;\n shell: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routing: 'hash' | 'history' | 'pathname';\n features: string[];\n routes: ScaffoldPackRoute[];\n workflow: string[];\n}\n\nexport interface MutationExecutionPack extends ExecutionPackBase<MutationPackData> {\n packType: 'mutation';\n}\n\nexport type ReviewPackKind = 'app';\n\nexport interface ReviewPackData {\n reviewType: ReviewPackKind;\n shell: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routing: 'hash' | 'history' | 'pathname';\n features: string[];\n routes: ScaffoldPackRoute[];\n focusAreas: string[];\n workflow: string[];\n}\n\nexport interface ReviewExecutionPack extends ExecutionPackBase<ReviewPackData> {\n packType: 'review';\n}\n\nexport interface ExecutionPackBundle {\n $schema: string;\n generatedAt: string;\n sourceEssenceVersion: string;\n manifest: ExecutionPackManifest;\n scaffold: ScaffoldExecutionPack;\n review: ReviewExecutionPack;\n sections: SectionExecutionPack[];\n pages: PageExecutionPack[];\n mutations: MutationExecutionPack[];\n}\n\nexport type SelectedExecutionPack =\n | ScaffoldExecutionPack\n | ReviewExecutionPack\n | SectionExecutionPack\n | PageExecutionPack\n | MutationExecutionPack;\n\nexport interface ExecutionPackSelector {\n packType: ExecutionPackType;\n id?: string | null;\n}\n\nexport interface SelectedExecutionPackResponse {\n $schema: string;\n generatedAt: string;\n sourceEssenceVersion: string;\n manifest: ExecutionPackManifest;\n selector: {\n packType: ExecutionPackType;\n id: string | null;\n };\n pack: SelectedExecutionPack;\n}\n\nexport interface ScaffoldPackBuilderOptions {\n objective?: string;\n target?: Partial<ExecutionPackTarget>;\n preset?: string | null;\n requiredSetup?: string[];\n examples?: ExecutionPackExample[];\n antiPatterns?: ExecutionPackAntiPattern[];\n successChecks?: ExecutionPackSuccessCheck[];\n tokenBudget?: Partial<ExecutionPackTokenBudget>;\n navigation?: {\n commandPalette: boolean | CommandPaletteContract;\n hotkeys: Array<{\n key: string;\n route?: string;\n label?: string;\n semantics?: HotkeySemantics;\n }>;\n hotkeySemantics?: HotkeySemantics;\n };\n /**\n * Required theme decorator contract surfaced into the scaffold pack.\n * The scaffold pack is read first per cold-prompt rules, so the canonical\n * decorator contract belongs here. Section packs reference this without\n * duplicating to avoid the 7-10× repetition cold-LLM runs reported.\n */\n themeDecorators?: ThemeDecoratorEntry[];\n}\n\nexport interface SectionPackBuilderOptions extends ScaffoldPackBuilderOptions {\n // themeDecorators inherited from base — section packs render a pointer\n // to scaffold-pack rather than re-emitting the full table (1.7.22 dedup).\n}\nexport interface PagePackBuilderOptions extends ScaffoldPackBuilderOptions {}\nexport interface MutationPackBuilderOptions extends ScaffoldPackBuilderOptions {\n mutationType: MutationPackKind;\n workflow?: string[];\n}\nexport interface ReviewPackBuilderOptions extends ScaffoldPackBuilderOptions {\n reviewType?: ReviewPackKind;\n focusAreas?: string[];\n workflow?: string[];\n}\n\nexport interface CompileExecutionPackBundleOptions {\n contentRoot?: string;\n overridePaths?: string[];\n resolver?: ContentResolver;\n}\n\nconst DEFAULT_TARGET: ExecutionPackTarget = {\n platform: 'web',\n framework: null,\n runtime: null,\n adapter: 'generic-web',\n};\n\nconst DEFAULT_TOKEN_BUDGET: ExecutionPackTokenBudget = {\n target: 1400,\n max: 2200,\n strategy: [\n 'Prefer route summaries over repeated prose.',\n 'Use compact vocabulary lists instead of large reference tables.',\n 'Include only task-relevant examples and checks.',\n ],\n};\n\nconst DEFAULT_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'route-topology',\n label: 'Routes and page IDs match the compiled topology.',\n severity: 'error',\n },\n {\n id: 'shell-consistency',\n label: 'The declared shell contract is preserved unless the task explicitly mutates it.',\n severity: 'error',\n },\n {\n id: 'theme-consistency',\n label: 'Theme identity and mode remain consistent across scaffolded routes.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_SECTION_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'section-route-coherence',\n label: 'Section pages and routes remain coherent with the compiled topology.',\n severity: 'error',\n },\n {\n id: 'section-shell-consistency',\n label: 'The section shell contract stays consistent across its routes.',\n severity: 'error',\n },\n {\n id: 'section-pattern-coverage',\n label: 'Primary section patterns are represented without adding off-contract filler sections.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_PAGE_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'page-route-contract',\n label: 'The page keeps the compiled route, shell, and section contract intact.',\n severity: 'error',\n },\n {\n id: 'page-pattern-contract',\n label:\n 'The page preserves its primary compiled patterns instead of drifting into unrelated layouts.',\n severity: 'error',\n },\n {\n id: 'page-state-contract',\n label: 'Any declared wiring signals remain coherent with the rendered page structure.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_MUTATION_SUCCESS_CHECKS: Record<MutationPackKind, ExecutionPackSuccessCheck[]> = {\n 'add-page': [\n {\n id: 'mutation-essence-first',\n label: 'New pages are declared in the essence before any code generation begins.',\n severity: 'error',\n },\n {\n id: 'mutation-shell-contract',\n label:\n 'New routes inherit an existing shell and section contract unless the essence changes first.',\n severity: 'error',\n },\n {\n id: 'mutation-refresh',\n label: 'Refresh compiled packs after the mutation so downstream tasks read current topology.',\n severity: 'warn',\n },\n ],\n modify: [\n {\n id: 'mutation-existing-topology',\n label:\n 'Modified routes remain coherent with the compiled topology unless the essence changes first.',\n severity: 'error',\n },\n {\n id: 'mutation-theme-contract',\n label: 'Theme, shell, and page identity stay aligned with the current contract during edits.',\n severity: 'error',\n },\n {\n id: 'mutation-page-pack-first',\n label:\n 'Route-local edits should start from the compiled page pack rather than improvised structure.',\n severity: 'warn',\n },\n ],\n};\n\nconst DEFAULT_REVIEW_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'review-contract-baseline',\n label:\n 'Review findings should use the compiled route, shell, and theme contract as the baseline.',\n severity: 'error',\n },\n {\n id: 'review-evidence',\n label: 'Each critique finding should cite concrete evidence from the generated workspace.',\n severity: 'error',\n },\n {\n id: 'review-remediation',\n label:\n 'Suggested fixes should point back to code changes or essence updates when contract drift exists.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_REVIEW_ANTI_PATTERNS: ExecutionPackAntiPattern[] = [\n {\n id: 'inline-styles',\n summary: 'Avoid inline style literals as the primary styling path.',\n guidance:\n 'Move visual styling into tokens.css and treatments.css instead of component-local style objects.',\n },\n {\n id: 'hardcoded-colors',\n summary: 'Avoid hardcoded color literals.',\n guidance: 'Use CSS variables and theme decorators instead of hex, rgb, or hsl values.',\n },\n {\n id: 'utility-framework-leakage',\n summary: 'Avoid utility-framework leakage as the primary design language.',\n guidance:\n 'Prefer compiled Decantr treatments and contract vocabulary over ad hoc utility class stacks.',\n },\n];\n\nfunction collectPatternIds(page: IRPageNode): string[] {\n const patternIds: string[] = [];\n walkIR(page, (node: IRNode) => {\n if (node.type !== 'pattern') return;\n const patternNode = node as IRPatternNode;\n patternIds.push(patternNode.pattern.patternId);\n });\n return [...new Set(patternIds)];\n}\n\nfunction pageIdentity(pageId: string, sectionId?: string | null): string {\n return sectionId ? `${sectionId}/${pageId}` : pageId;\n}\n\nfunction pageFileId(pageId: string, sectionId?: string | null): string {\n return pageIdentity(pageId, sectionId).replace(/[^a-zA-Z0-9._-]+/g, '-');\n}\n\nfunction routePageLabel(route: Pick<ScaffoldPackRoute, 'pageId' | 'sectionId'>): string {\n return route.sectionId ? `${route.sectionId}/${route.pageId}` : route.pageId;\n}\n\nfunction summarizeRoutes(appNode: IRAppNode): ScaffoldPackRoute[] {\n return appNode.routes.flatMap((route) => {\n const pageNode = findPageNode(appNode, route.pageId, route.sectionId);\n if (!pageNode) return [];\n return [\n {\n pageId: pageNode.pageId,\n ...(route.sectionId ? { sectionId: route.sectionId } : {}),\n path: route.path,\n patternIds: collectPatternIds(pageNode),\n shell: route.shell,\n },\n ];\n });\n}\n\nfunction summarizeSectionRoutes(appNode: IRAppNode, input: SectionPackInput): SectionPackRoute[] {\n return summarizeRoutes(appNode).filter(\n (route) =>\n input.pageIds.includes(route.pageId) && (!route.sectionId || route.sectionId === input.id),\n );\n}\n\nfunction summarizePageRoute(\n appNode: IRAppNode,\n pageId: string,\n sectionId?: string | null,\n): ScaffoldPackRoute | null {\n return (\n summarizeRoutes(appNode).find(\n (route) =>\n route.pageId === pageId && (!sectionId || !route.sectionId || route.sectionId === sectionId),\n ) ?? null\n );\n}\n\nfunction findPageNode(\n appNode: IRAppNode,\n pageId: string,\n sectionId?: string | null,\n): IRPageNode | null {\n const page = appNode.children.find((node) => {\n const pageNode = node as IRPageNode;\n return (\n pageNode.pageId === pageId && (!sectionId || !pageNode.sectionId || pageNode.sectionId === sectionId)\n );\n });\n return page ? (page as IRPageNode) : null;\n}\n\nfunction collectPagePatterns(page: IRPageNode): PagePackPattern[] {\n const patterns: PagePackPattern[] = [];\n walkIR(page, (node: IRNode) => {\n if (node.type !== 'pattern') return;\n const patternNode = node as IRPatternNode;\n patterns.push({\n id: patternNode.pattern.patternId,\n alias: patternNode.pattern.alias,\n preset: patternNode.pattern.preset,\n layout: patternNode.pattern.layout,\n ...(patternNode.pattern.presetDescription\n ? { presetDescription: patternNode.pattern.presetDescription }\n : {}),\n ...(patternNode.pattern.interactions && patternNode.pattern.interactions.length > 0\n ? { interactions: patternNode.pattern.interactions }\n : {}),\n });\n });\n return patterns;\n}\n\nfunction mergeTokenBudget(overrides?: Partial<ExecutionPackTokenBudget>): ExecutionPackTokenBudget {\n return {\n target: overrides?.target ?? DEFAULT_TOKEN_BUDGET.target,\n max: overrides?.max ?? DEFAULT_TOKEN_BUDGET.max,\n strategy: overrides?.strategy ?? DEFAULT_TOKEN_BUDGET.strategy,\n };\n}\n\nfunction renderList(title: string, entries: string[]): string[] {\n if (entries.length === 0) return [];\n return [title, ...entries.map((entry) => `- ${entry}`), ''];\n}\n\n// Compact description of hotkey semantics for pack markdown. Returns empty\n// string when no semantics are declared so the line can be omitted entirely.\nfunction formatHotkeySemantics(semantics: HotkeySemantics | undefined): string {\n if (!semantics) return '';\n const parts: string[] = [];\n if (typeof semantics.chord_window_ms === 'number') {\n parts.push(`chord window ${semantics.chord_window_ms}ms`);\n }\n if (semantics.input_guard === true) parts.push('suppress during text-input focus');\n if (semantics.input_guard === false) parts.push('fire even while typing (explicit)');\n if (semantics.modifier_suppression === true) parts.push('ignore when modifier held');\n if (semantics.modifier_suppression === false) parts.push('allow modifier passthrough (explicit)');\n if (semantics.match_case === true) parts.push('case-sensitive');\n return parts.join('; ');\n}\n\n// Short, mechanical router-implementation hint so the LLM picks the right\n// imports without having to consult a separate narrative file. Keyed off the\n// same string enum as the schema.\nfunction routingImplementationHint(routing: 'hash' | 'history' | 'pathname'): string {\n switch (routing) {\n case 'hash':\n return 'HashRouter from react-router-dom; URLs prefixed with /# (e.g. /#/login). Only for static-only hosts without SPA fallback.';\n case 'history':\n return 'BrowserRouter from react-router-dom; regular URLs (e.g. /login). Works on Vite dev, Vercel, Netlify, Cloudflare Pages.';\n case 'pathname':\n return 'pathname-based routing (Next.js App Router file conventions).';\n default:\n return String(routing);\n }\n}\n\nexport function renderExecutionPackMarkdown(pack: ExecutionPackBase<unknown>): string {\n const lines: string[] = [];\n\n lines.push(`# ${pack.packType.charAt(0).toUpperCase()}${pack.packType.slice(1)} Pack`);\n lines.push('');\n lines.push(`**Objective:** ${pack.objective}`);\n lines.push(\n `**Target:** ${pack.target.adapter}${pack.target.framework ? ` (${pack.target.framework})` : ''}`,\n );\n lines.push(\n `**Scope:** pages=${pack.scope.pageIds.join(', ') || 'none'} | patterns=${pack.scope.patternIds.join(', ') || 'none'}`,\n );\n lines.push('');\n\n if (pack.packType === 'scaffold') {\n const scaffoldPack = pack as ScaffoldExecutionPack;\n const scaffoldShells = [\n ...new Set(scaffoldPack.data.routes.map((route) => route.shell).filter(Boolean)),\n ];\n lines.push('## Scaffold Contract');\n lines.push(`- Shell: ${scaffoldPack.data.shell}`);\n if (scaffoldShells.length > 1) {\n const secondaryShells = scaffoldShells.filter((shell) => shell !== scaffoldPack.data.shell);\n lines.push(\n `- Shells: ${[`${scaffoldPack.data.shell} (primary)`, ...secondaryShells].join(', ')}`,\n );\n }\n lines.push(`- Theme: ${scaffoldPack.data.theme.id} (${scaffoldPack.data.theme.mode})`);\n lines.push(\n `- Routing: ${scaffoldPack.data.routing} → ${routingImplementationHint(scaffoldPack.data.routing)}`,\n );\n if (scaffoldPack.data.features.length > 0) {\n lines.push(`- Features: ${scaffoldPack.data.features.join(', ')}`);\n }\n if (\n scaffoldPack.data.navigation?.commandPalette ||\n scaffoldPack.data.navigation?.hotkeys.length\n ) {\n lines.push('- Navigation:');\n const cp = scaffoldPack.data.navigation.commandPalette;\n if (cp) {\n if (typeof cp === 'object') {\n lines.push(' - Command palette:');\n if (cp.trigger) lines.push(` - Trigger: ${cp.trigger}`);\n if (cp.styling)\n lines.push(` - Styling: ${cp.styling}${cp.width ? ` (width ${cp.width})` : ''}`);\n else if (cp.width) lines.push(` - Width: ${cp.width}`);\n if (cp.placeholder) lines.push(` - Placeholder: \"${cp.placeholder}\"`);\n if (cp.commands && cp.commands.length > 0) {\n lines.push(` - Commands (${cp.commands.length}):`);\n for (const command of cp.commands) {\n const parts: string[] = [];\n if (command.section) parts.push(command.section);\n parts.push(command.label);\n if (command.hotkey) parts.push(`[${command.hotkey}]`);\n if (command.route) parts.push(`→ ${command.route}`);\n lines.push(` - ${command.id}: ${parts.join(' · ')}`);\n }\n }\n } else {\n lines.push(' - command palette required');\n }\n }\n const globalSemantics = scaffoldPack.data.navigation.hotkeySemantics;\n if (scaffoldPack.data.navigation.hotkeys.length > 0) {\n const semanticsSummary = formatHotkeySemantics(globalSemantics);\n lines.push(` - Hotkeys${semanticsSummary ? ` (${semanticsSummary})` : ''}:`);\n for (const hotkey of scaffoldPack.data.navigation.hotkeys) {\n const target = [hotkey.label, hotkey.route].filter(Boolean).join(' — ');\n const perKeySemantics = formatHotkeySemantics(hotkey.semantics);\n const suffix = perKeySemantics ? ` _(${perKeySemantics})_` : '';\n lines.push(` - ${hotkey.key}${target ? `: ${target}` : ''}${suffix}`);\n }\n }\n }\n lines.push('');\n\n lines.push('## Route Plan');\n for (const route of scaffoldPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n // Required Theme Decorators — canonical project-level decorator contract\n // (1.7.22). Lives ONCE here in scaffold-pack rather than duplicated across\n // section packs. Cold prompts read scaffold-pack first, so this is the\n // earliest authoritative read of the theme's visual identity contract.\n if (scaffoldPack.data.themeDecorators && scaffoldPack.data.themeDecorators.length > 0) {\n const escScaffoldCell = (s: string): string => s.replace(/\\|/g, '\\\\|');\n lines.push(`## Required Theme Decorators (${scaffoldPack.data.theme.id})`);\n lines.push('');\n lines.push(\n 'These classes carry the active theme\\'s visual identity. Tokens alone give bones; decorators give personality. Generated source MUST apply these across all sections — without them, every page reads as \"themed colors only\" with no theme character. Section packs reference this table; the contract is project-wide.',\n );\n lines.push('');\n lines.push('| Class | Intent | Apply to |');\n lines.push('|-------|--------|----------|');\n for (const entry of scaffoldPack.data.themeDecorators) {\n lines.push(\n `| \\`.${entry.class}\\` | ${escScaffoldCell(entry.intent)} | ${escScaffoldCell(entry.applyTo)} |`,\n );\n }\n lines.push('');\n }\n }\n\n if (pack.packType === 'section') {\n const sectionPack = pack as SectionExecutionPack;\n lines.push('## Section Contract');\n lines.push(`- Section: ${sectionPack.data.sectionId}`);\n lines.push(`- Role: ${sectionPack.data.role}`);\n lines.push(`- Shell: ${sectionPack.data.shell}`);\n lines.push(`- Theme: ${sectionPack.data.theme.id} (${sectionPack.data.theme.mode})`);\n if (sectionPack.data.features.length > 0) {\n lines.push(`- Features: ${sectionPack.data.features.join(', ')}`);\n }\n if (sectionPack.data.description) {\n lines.push(`- Description: ${sectionPack.data.description}`);\n }\n lines.push('');\n\n lines.push('## Section Routes');\n for (const route of sectionPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n if (sectionPack.data.navigationItems && sectionPack.data.navigationItems.length > 0) {\n lines.push('## Section Navigation');\n lines.push('');\n lines.push(\n \"Render these items in the shell's primary navigation. Exact match on label, route, and icon.\",\n );\n lines.push('');\n for (const item of sectionPack.data.navigationItems) {\n const parts: string[] = [`${item.label} → ${item.route}`];\n if (item.icon) parts.push(`icon: ${item.icon}`);\n if (item.hotkey) parts.push(`hotkey: ${item.hotkey}`);\n if (item.badge) parts.push(`badge: ${item.badge}`);\n if (item.active_match) parts.push(`active match: \\`${item.active_match}\\``);\n lines.push(`- ${parts.join(' · ')}`);\n }\n lines.push('');\n }\n\n if (sectionPack.data.directives && sectionPack.data.directives.length > 0) {\n lines.push('## Section Directives');\n lines.push('');\n lines.push(\n 'Execution-level rules every page in this section must obey. Follow exactly — these live in the pack contract, not narrative prose.',\n );\n lines.push('');\n for (const directive of sectionPack.data.directives) {\n lines.push(`- ${directive}`);\n }\n lines.push('');\n }\n\n // Theme decorators pointer — full table lives in scaffold-pack.md (1.7.22\n // dedup). F2 Phase 1 cold-LLM runs flagged 7-10× duplication of the same\n // table across section packs (~270-540 redundant lines per scaffold). The\n // canonical contract now lives ONCE in scaffold-pack; section packs cite\n // the theme id and point readers there. Section-pack data still carries\n // themeDecorators if explicitly set (legacy support), but the renderer\n // prefers the pointer form unless a section-specific override is needed.\n if (sectionPack.data.themeDecorators && sectionPack.data.themeDecorators.length > 0) {\n // Legacy/override path — render the full table. Kept for back-compat\n // with consumers that still pass themeDecorators directly.\n const escCell = (s: string): string => s.replace(/\\|/g, '\\\\|');\n lines.push(`## Required Theme Decorators (${sectionPack.data.theme.id})`);\n lines.push('');\n lines.push(\n 'These classes carry the active theme\\'s visual identity. Tokens alone give bones; decorators give personality. Generated source MUST apply these — without them, the page reads as \"themed colors only\" with no theme character.',\n );\n lines.push('');\n lines.push('| Class | Intent | Apply to |');\n lines.push('|-------|--------|----------|');\n for (const entry of sectionPack.data.themeDecorators) {\n lines.push(\n `| \\`.${entry.class}\\` | ${escCell(entry.intent)} | ${escCell(entry.applyTo)} |`,\n );\n }\n lines.push('');\n } else {\n // Default path (1.7.22+) — pointer to scaffold-pack's canonical table.\n lines.push('## Theme Decorators');\n lines.push('');\n lines.push(\n `Theme \\`${sectionPack.data.theme.id}\\` decorators are documented ONCE in \\`scaffold-pack.md\\` under \"Required Theme Decorators\". Apply them across this section's pages — the contract is the same project-wide. See also DECANTR.md \"Decorator Quick Reference\" for the same table.`,\n );\n lines.push('');\n }\n }\n\n if (pack.packType === 'page') {\n const pagePack = pack as PageExecutionPack;\n lines.push('## Page Contract');\n lines.push(`- Page: ${pagePack.data.pageId}`);\n lines.push(`- Path: ${pagePack.data.path}`);\n lines.push(`- Shell: ${pagePack.data.shell}`);\n if (pagePack.data.sectionId) {\n const role = pagePack.data.sectionRole ? ` (${pagePack.data.sectionRole})` : '';\n lines.push(`- Section: ${pagePack.data.sectionId}${role}`);\n }\n lines.push(`- Theme: ${pagePack.data.theme.id} (${pagePack.data.theme.mode})`);\n if (pagePack.data.features.length > 0) {\n lines.push(`- Features: ${pagePack.data.features.join(', ')}`);\n }\n if (pagePack.data.surface) {\n lines.push(`- Surface: ${pagePack.data.surface}`);\n }\n lines.push('');\n\n lines.push('## Page Patterns');\n for (const pattern of pagePack.data.patterns) {\n lines.push(\n `- ${pattern.alias} -> ${pattern.id} [${pattern.layout}${pattern.preset ? ` | ${pattern.preset}` : ''}]`,\n );\n // Emit preset-specific description on the next line (indented) when\n // the pattern's preset carries its own prose. This stops cold LLMs\n // from falling back to the blueprint-generic root description.\n if (pattern.presetDescription) {\n lines.push(` > ${pattern.presetDescription}`);\n }\n // v2.1 C1: surface declared interactions[] as a checkbox checklist.\n // Hard-edged format — LLMs in generation mode cannot categorize a\n // checkbox as philosophy. Enforced by decantr check --strict (C5).\n if (pattern.interactions && pattern.interactions.length > 0) {\n lines.push(` **Interactions (MUST implement each — see DECANTR.md \"Interaction Requirements\"):**`);\n for (const interaction of pattern.interactions) {\n lines.push(` - [ ] ${interaction}`);\n }\n }\n }\n lines.push('');\n\n if (pagePack.data.wiringSignals.length > 0) {\n lines.push('## Wiring Signals');\n for (const signal of pagePack.data.wiringSignals) {\n lines.push(`- ${signal}`);\n }\n lines.push('');\n }\n\n if (pagePack.data.directives && pagePack.data.directives.length > 0) {\n lines.push('## Page Directives');\n lines.push('');\n lines.push('Execution-level rules for this route. Follow exactly.');\n lines.push('');\n for (const directive of pagePack.data.directives) {\n lines.push(`- ${directive}`);\n }\n lines.push('');\n }\n }\n\n if (pack.packType === 'mutation') {\n const mutationPack = pack as MutationExecutionPack;\n lines.push('## Mutation Contract');\n lines.push(`- Operation: ${mutationPack.data.mutationType}`);\n lines.push(`- Shell: ${mutationPack.data.shell}`);\n lines.push(`- Theme: ${mutationPack.data.theme.id} (${mutationPack.data.theme.mode})`);\n lines.push(\n `- Routing: ${mutationPack.data.routing} → ${routingImplementationHint(mutationPack.data.routing)}`,\n );\n if (mutationPack.data.features.length > 0) {\n lines.push(`- Features: ${mutationPack.data.features.join(', ')}`);\n }\n lines.push('');\n\n lines.push('## Route Topology');\n for (const route of mutationPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n if (mutationPack.data.workflow.length > 0) {\n lines.push('## Workflow');\n for (const step of mutationPack.data.workflow) {\n lines.push(`- ${step}`);\n }\n lines.push('');\n }\n }\n\n if (pack.packType === 'review') {\n const reviewPack = pack as ReviewExecutionPack;\n lines.push('## Review Contract');\n lines.push(`- Review Type: ${reviewPack.data.reviewType}`);\n lines.push(`- Shell: ${reviewPack.data.shell}`);\n lines.push(`- Theme: ${reviewPack.data.theme.id} (${reviewPack.data.theme.mode})`);\n lines.push(`- Routing: ${reviewPack.data.routing}`);\n if (reviewPack.data.features.length > 0) {\n lines.push(`- Features: ${reviewPack.data.features.join(', ')}`);\n }\n lines.push('');\n\n lines.push('## Review Topology');\n for (const route of reviewPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n if (reviewPack.data.focusAreas.length > 0) {\n lines.push('## Focus Areas');\n for (const focusArea of reviewPack.data.focusAreas) {\n lines.push(`- ${focusArea}`);\n }\n lines.push('');\n }\n\n if (reviewPack.data.workflow.length > 0) {\n lines.push('## Review Workflow');\n for (const step of reviewPack.data.workflow) {\n lines.push(`- ${step}`);\n }\n lines.push('');\n }\n }\n\n // P1-1 — Page packs skip the universal footer (required setup, allowed\n // vocabulary, success checks, anti-patterns, examples, token budget).\n // These blocks are identical across every page in a 16-page scaffold\n // (~35 lines × N pages of pure boilerplate) and their JSON still carries\n // all fields for any consumer that needs the raw data. Non-page packs\n // keep the full footer — each one (scaffold, section, mutation, review)\n // is a singleton per scaffold so there's no duplication problem.\n if (pack.packType === 'page') {\n lines.push('## Shared Contract');\n lines.push(\n 'Required setup, allowed vocabulary, success checks, anti-patterns, and token budget are shared across every page pack. The full list lives in the pack JSON sidecar (`page-<id>-pack.json`) and in the pack-manifest. Refer there instead of re-reading the same boilerplate 16 times.',\n );\n lines.push('');\n return lines.join('\\n').trimEnd() + '\\n';\n }\n\n lines.push('## Required Setup');\n if (pack.requiredSetup.length === 0) {\n lines.push('- None declared.');\n } else {\n lines.push(...pack.requiredSetup.map((entry) => `- ${entry}`));\n }\n lines.push('');\n\n lines.push('## Allowed Vocabulary');\n if (pack.allowedVocabulary.length === 0) {\n lines.push('- None declared.');\n } else {\n lines.push(...pack.allowedVocabulary.map((entry) => `- ${entry}`));\n }\n lines.push('');\n\n lines.push(\n ...renderList(\n '## Success Checks',\n pack.successChecks.map((entry) => `${entry.label} [${entry.severity}]`),\n ),\n );\n lines.push(\n ...renderList(\n '## Anti-Patterns',\n pack.antiPatterns.map((entry) => `${entry.summary}: ${entry.guidance}`),\n ),\n );\n lines.push(\n ...renderList(\n '## Examples',\n pack.examples.map((entry) => `${entry.label} (${entry.language})`),\n ),\n );\n\n lines.push('## Token Budget');\n lines.push(`- Target: ${pack.tokenBudget.target}`);\n lines.push(`- Max: ${pack.tokenBudget.max}`);\n lines.push(...pack.tokenBudget.strategy.map((entry) => `- ${entry}`));\n lines.push('');\n\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\nexport function resolvePackAdapter(\n target: string | undefined,\n platformType: string | undefined,\n): string {\n if (target === 'react' && platformType === 'spa') return 'react-vite';\n if (target === 'react') return 'react-web';\n if (target === 'vue' && platformType === 'spa') return 'vue-vite';\n if (target === 'svelte' && platformType === 'spa') return 'sveltekit';\n if (target) return target;\n return 'generic-web';\n}\n\nexport function listPackSections(essence: EssenceV3): SectionPackInput[] {\n const declaredSections = essence.blueprint.sections;\n if (declaredSections && declaredSections.length > 0) {\n const routedSectionPages = new Set(\n Object.values(essence.blueprint.routes ?? {}).map(\n (entry) => `${entry.section}:${entry.page}`,\n ),\n );\n return declaredSections\n .map((section) => {\n const pageIds = section.pages\n .filter(\n (page) =>\n routedSectionPages.size === 0 || routedSectionPages.has(`${section.id}:${page.id}`),\n )\n .map((page) => page.id);\n\n return {\n id: section.id,\n role: section.role,\n shell: section.shell as string,\n description: section.description,\n features: section.features,\n pageIds,\n ...(Array.isArray(section.navigation_items) && section.navigation_items.length > 0\n ? { navigationItems: section.navigation_items as SectionNavigationItemPack[] }\n : {}),\n ...(Array.isArray(section.directives) && section.directives.length > 0\n ? { directives: section.directives }\n : {}),\n };\n })\n .filter((section) => section.pageIds.length > 0);\n }\n\n const pages = essence.blueprint.pages ?? [{ id: 'home', layout: ['hero'] }];\n return [\n {\n id: essence.meta.archetype || 'default',\n role: 'primary',\n shell: (essence.blueprint.shell ?? 'sidebar-main') as string,\n description: `${essence.meta.archetype || 'Application'} section`,\n features: essence.blueprint.features || [],\n pageIds: pages.map((page) => page.id),\n },\n ];\n}\n\nexport function listPackPages(essence: EssenceV3): PagePackInput[] {\n const declaredSections = essence.blueprint.sections;\n if (declaredSections && declaredSections.length > 0) {\n const routedSectionPages = new Set(\n Object.values(essence.blueprint.routes ?? {}).map(\n (entry) => `${entry.section}:${entry.page}`,\n ),\n );\n return declaredSections.flatMap((section) =>\n section.pages\n .map((page) => ({\n pageId: page.id,\n shell: (page.shell_override ?? section.shell) as string,\n sectionId: section.id,\n sectionRole: section.role,\n features: section.features,\n ...(Array.isArray(page.directives) && page.directives.length > 0\n ? { directives: page.directives }\n : {}),\n }))\n .filter(\n (page) =>\n routedSectionPages.size === 0 ||\n routedSectionPages.has(`${page.sectionId}:${page.pageId}`),\n ),\n );\n }\n\n const pages = essence.blueprint.pages ?? [{ id: 'home', layout: ['hero'] }];\n const defaultShell = (essence.blueprint.shell ?? 'sidebar-main') as string;\n return pages.map((page) => ({\n pageId: page.id,\n shell: (page.shell_override ?? defaultShell) as string,\n sectionId: essence.meta.archetype || 'default',\n sectionRole: 'primary',\n features: essence.blueprint.features || [],\n }));\n}\n\nfunction buildPageManifestEntries(pages: PagePackInput[]): PackManifestPageEntry[] {\n const counts = new Map<string, number>();\n for (const page of pages) {\n counts.set(page.pageId, (counts.get(page.pageId) ?? 0) + 1);\n }\n\n return pages.map((page) => {\n const hasDuplicatePageId = (counts.get(page.pageId) ?? 0) > 1;\n const id = hasDuplicatePageId ? pageIdentity(page.pageId, page.sectionId) : page.pageId;\n const fileId = hasDuplicatePageId ? pageFileId(page.pageId, page.sectionId) : page.pageId;\n return {\n id,\n markdown: `page-${fileId}-pack.md`,\n json: `page-${fileId}-pack.json`,\n sectionId: page.sectionId,\n sectionRole: page.sectionRole,\n };\n });\n}\n\nexport function buildScaffoldPack(\n appNode: IRAppNode,\n options: ScaffoldPackBuilderOptions = {},\n): ScaffoldExecutionPack {\n const routes = summarizeRoutes(appNode);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n\n const pack: ScaffoldExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.scaffold,\n packVersion: '1.0.0',\n packType: 'scaffold',\n objective:\n options.objective ?? `Scaffold the ${appNode.theme.id} app shell and declared routes.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Treat the declared routes as the topology source of truth.',\n 'Preserve the resolved theme and shell contract unless the task explicitly mutates them.',\n ],\n allowedVocabulary: [\n ...new Set([\n appNode.shell.config.type,\n appNode.theme.id,\n appNode.theme.mode,\n ...appNode.features,\n ...scopePatternIds,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n shell: appNode.shell.config.type,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routing: appNode.routing,\n features: appNode.features,\n navigation: options.navigation,\n routes,\n ...(options.themeDecorators && options.themeDecorators.length > 0\n ? { themeDecorators: options.themeDecorators }\n : {}),\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildSectionPack(\n appNode: IRAppNode,\n input: SectionPackInput,\n options: SectionPackBuilderOptions = {},\n): SectionExecutionPack {\n const routes = summarizeSectionRoutes(appNode, input);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n\n const pack: SectionExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.section,\n packVersion: '1.0.0',\n packType: 'section',\n objective:\n options.objective ??\n `Implement the ${input.id} section using the compiled ${input.shell} shell contract.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Use the declared section routes as the source of truth for this slice of the app.',\n 'Keep the section shell consistent unless the task explicitly changes the shell contract.',\n ],\n allowedVocabulary: [\n ...new Set([\n input.id,\n input.role,\n input.shell,\n appNode.theme.id,\n appNode.theme.mode,\n ...input.features,\n ...scopePatternIds,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_SECTION_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n sectionId: input.id,\n role: input.role,\n shell: input.shell,\n description: input.description,\n features: input.features,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routes,\n ...(input.navigationItems && input.navigationItems.length > 0\n ? { navigationItems: input.navigationItems }\n : {}),\n ...(input.directives && input.directives.length > 0 ? { directives: input.directives } : {}),\n ...(options.themeDecorators && options.themeDecorators.length > 0\n ? { themeDecorators: options.themeDecorators }\n : {}),\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildPagePack(\n appNode: IRAppNode,\n input: PagePackInput,\n options: PagePackBuilderOptions = {},\n): PageExecutionPack {\n const pageNode = findPageNode(appNode, input.pageId, input.sectionId);\n const route = summarizePageRoute(appNode, input.pageId, input.sectionId);\n\n if (!pageNode || !route) {\n throw new Error(`Unknown page for page pack: ${input.pageId}`);\n }\n\n const patterns = collectPagePatterns(pageNode);\n\n const pack: PageExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.page,\n packVersion: '1.0.0',\n packType: 'page',\n objective:\n options.objective ?? `Implement the ${input.pageId} route using the compiled page contract.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: [route.pageId],\n patternIds: [...new Set(patterns.map((pattern) => pattern.id))],\n },\n requiredSetup: options.requiredSetup ?? [\n 'Keep the compiled route and shell contract stable for this page.',\n 'Treat the listed page patterns as the primary structure for this route.',\n ],\n allowedVocabulary: [\n ...new Set(\n [\n input.pageId,\n input.shell,\n input.sectionId ?? '',\n input.sectionRole ?? '',\n appNode.theme.id,\n appNode.theme.mode,\n ...input.features,\n ...patterns.flatMap((pattern) => [pattern.id, pattern.alias, pattern.layout]),\n ].filter(Boolean),\n ),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_PAGE_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n pageId: route.pageId,\n path: route.path,\n shell: input.shell,\n sectionId: input.sectionId,\n sectionRole: input.sectionRole,\n features: input.features,\n surface: pageNode.surface,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n wiringSignals: pageNode.wiring?.signals.map((signal) => signal.name) ?? [],\n patterns,\n ...(input.directives && input.directives.length > 0 ? { directives: input.directives } : {}),\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildMutationPack(\n appNode: IRAppNode,\n options: MutationPackBuilderOptions,\n): MutationExecutionPack {\n const routes = summarizeRoutes(appNode);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n const defaultWorkflow =\n options.mutationType === 'add-page'\n ? [\n 'Declare the new page in the essence before generating code.',\n 'Refresh Decantr context so section and page packs include the new route.',\n 'Read the relevant section pack and new page pack before implementation.',\n ]\n : [\n 'Read the page pack for the route you are modifying first.',\n 'Stop and update the essence before changing route, shell, or pattern contracts.',\n 'Validate and check drift after code changes complete.',\n ];\n\n const pack: MutationExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.mutation,\n packVersion: '1.0.0',\n packType: 'mutation',\n objective:\n options.objective ??\n `Execute the ${options.mutationType} workflow against the compiled app contract.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Treat the compiled topology as the source of truth until the essence changes.',\n 'Refresh Decantr context after structural mutations so downstream tasks read current packs.',\n ],\n allowedVocabulary: [\n ...new Set([\n options.mutationType,\n appNode.shell.config.type,\n appNode.theme.id,\n appNode.theme.mode,\n ...appNode.features,\n ...scopePatternIds,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_MUTATION_SUCCESS_CHECKS[options.mutationType],\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n mutationType: options.mutationType,\n shell: appNode.shell.config.type,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routing: appNode.routing,\n features: appNode.features,\n routes,\n workflow: options.workflow ?? defaultWorkflow,\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildReviewPack(\n appNode: IRAppNode,\n options: ReviewPackBuilderOptions = {},\n): ReviewExecutionPack {\n const routes = summarizeRoutes(appNode);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n const reviewType = options.reviewType ?? 'app';\n const focusAreas = options.focusAreas ?? [\n 'route-topology',\n 'theme-consistency',\n 'treatment-usage',\n 'accessibility',\n 'responsive-design',\n ];\n const workflow = options.workflow ?? [\n 'Read the scaffold pack and page packs before evaluating generated code.',\n 'Compare findings against the compiled route, shell, and theme contract first.',\n 'Escalate contract drift into essence updates when the requested output intentionally changes topology or theme identity.',\n ];\n\n const pack: ReviewExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.review,\n packVersion: '1.0.0',\n packType: 'review',\n objective:\n options.objective ?? 'Review generated output against the compiled Decantr contract.',\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Read the compiled scaffold and route packs before reviewing code.',\n 'Use concrete evidence from the workspace instead of purely stylistic intuition.',\n ],\n allowedVocabulary: [\n ...new Set([\n reviewType,\n appNode.shell.config.type,\n appNode.theme.id,\n appNode.theme.mode,\n ...appNode.features,\n ...scopePatternIds,\n ...focusAreas,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? DEFAULT_REVIEW_ANTI_PATTERNS,\n successChecks: options.successChecks ?? DEFAULT_REVIEW_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n reviewType,\n shell: appNode.shell.config.type,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routing: appNode.routing,\n features: appNode.features,\n routes,\n focusAreas,\n workflow,\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport async function compileExecutionPackBundle(\n essence: EssenceFile,\n options: CompileExecutionPackBundleOptions = {},\n): Promise<ExecutionPackBundle> {\n const effectiveEssence = isV3(essence) ? essence : migrateV2ToV3(essence);\n const generatedAt = new Date().toISOString();\n const sharedTarget = {\n framework: effectiveEssence.meta.target || null,\n runtime: effectiveEssence.meta.platform.type || null,\n adapter: resolvePackAdapter(effectiveEssence.meta.target, effectiveEssence.meta.platform.type),\n };\n\n const pipeline = await runPipeline(essence, {\n contentRoot: options.contentRoot,\n overridePaths: options.overridePaths,\n resolver: options.resolver,\n });\n\n const navMeta = effectiveEssence.meta.navigation;\n // Preserve the full command_palette value when it's a structured contract;\n // coerce to boolean only when it's the legacy flag form.\n const commandPaletteValue: boolean | CommandPaletteContract =\n typeof navMeta?.command_palette === 'object' && navMeta.command_palette !== null\n ? (navMeta.command_palette as CommandPaletteContract)\n : Boolean(navMeta?.command_palette);\n\n // Compose theme decorator contract from registry data once and reuse for\n // both scaffold pack (canonical) and section packs (reference). Filter to\n // entries with the minimum data needed to render a useful row.\n const themeDecorators: ThemeDecoratorEntry[] | undefined = (() => {\n const defs = pipeline.registryTheme?.decorator_definitions;\n if (!defs) return undefined;\n const entries: ThemeDecoratorEntry[] = [];\n for (const [name, def] of Object.entries(defs)) {\n const intent = def.intent || def.description || '';\n const applyTo = (def.usage || []).join(', ');\n if (!intent && !applyTo) continue;\n entries.push({ class: name, intent, applyTo });\n }\n return entries.length > 0 ? entries : undefined;\n })();\n\n const scaffold = buildScaffoldPack(pipeline.ir, {\n target: sharedTarget,\n navigation: {\n commandPalette: commandPaletteValue,\n hotkeys: Array.isArray(navMeta?.hotkeys)\n ? navMeta.hotkeys\n .filter(\n (\n hotkey,\n ): hotkey is {\n key: string;\n route?: string;\n action?: string;\n label: string;\n semantics?: HotkeySemantics;\n } =>\n Boolean(\n hotkey && typeof hotkey.key === 'string' && typeof hotkey.label === 'string',\n ),\n )\n .map((hotkey) => ({\n key: hotkey.key,\n route: hotkey.route,\n label: hotkey.label,\n ...(hotkey.semantics ? { semantics: hotkey.semantics as HotkeySemantics } : {}),\n }))\n : [],\n ...(navMeta?.hotkey_semantics\n ? { hotkeySemantics: navMeta.hotkey_semantics as HotkeySemantics }\n : {}),\n },\n ...(themeDecorators ? { themeDecorators } : {}),\n });\n const review = buildReviewPack(pipeline.ir, {\n target: sharedTarget,\n });\n const sectionInputs = listPackSections(effectiveEssence);\n const pageInputs = listPackPages(effectiveEssence);\n\n const sections = sectionInputs.map((section) =>\n buildSectionPack(pipeline.ir, section, {\n target: sharedTarget,\n // themeDecorators intentionally NOT passed to section packs as of 1.7.22.\n // Section packs render a one-line pointer to scaffold-pack instead of\n // duplicating the full decorator table — F2 Phase 1 reports flagged\n // 7-10× duplication across context files. The decorators are still\n // available on each section pack as section-pack.theme.id allows the\n // renderer to compose the pointer with the correct theme name.\n }),\n );\n const pages = pageInputs.map((page) =>\n buildPagePack(pipeline.ir, page, {\n target: sharedTarget,\n }),\n );\n const mutations = (['add-page', 'modify'] as const).map((mutationType) =>\n buildMutationPack(pipeline.ir, {\n mutationType,\n target: sharedTarget,\n }),\n );\n\n const manifest: ExecutionPackManifest = {\n $schema: PACK_MANIFEST_SCHEMA_URL,\n version: '1.0.0',\n generatedAt,\n scaffold: {\n id: 'scaffold',\n markdown: 'scaffold-pack.md',\n json: 'scaffold-pack.json',\n },\n review: {\n id: 'review',\n markdown: 'review-pack.md',\n json: 'review-pack.json',\n },\n sections: sectionInputs.map((section) => ({\n id: section.id,\n markdown: `section-${section.id}-pack.md`,\n json: `section-${section.id}-pack.json`,\n pageIds: section.pageIds,\n })),\n pages: buildPageManifestEntries(pageInputs),\n mutations: (['add-page', 'modify'] as const).map((mutationType) => ({\n id: mutationType,\n markdown: `mutation-${mutationType}-pack.md`,\n json: `mutation-${mutationType}-pack.json`,\n mutationType,\n })),\n };\n\n return {\n $schema: EXECUTION_PACK_BUNDLE_SCHEMA_URL,\n generatedAt,\n sourceEssenceVersion: essence.version,\n manifest,\n scaffold,\n review,\n sections,\n pages,\n mutations,\n };\n}\n\nexport function selectExecutionPackFromBundle(\n bundle: ExecutionPackBundle,\n selector: ExecutionPackSelector,\n): SelectedExecutionPackResponse | null {\n const id = selector.id ?? null;\n let pack: SelectedExecutionPack | null = null;\n\n switch (selector.packType) {\n case 'scaffold':\n pack = bundle.scaffold;\n break;\n case 'review':\n pack = bundle.review;\n break;\n case 'section':\n pack = id ? (bundle.sections.find((entry) => entry.data.sectionId === id) ?? null) : null;\n break;\n case 'page':\n pack = id\n ? (bundle.pages.find(\n (entry) =>\n entry.data.pageId === id ||\n pageIdentity(entry.data.pageId, entry.data.sectionId) === id ||\n pageFileId(entry.data.pageId, entry.data.sectionId) === id,\n ) ?? null)\n : null;\n break;\n case 'mutation':\n pack = id ? (bundle.mutations.find((entry) => entry.data.mutationType === id) ?? null) : null;\n break;\n default:\n pack = null;\n break;\n }\n\n if (!pack) {\n return null;\n }\n\n return {\n $schema: SELECTED_EXECUTION_PACK_SCHEMA_URL,\n generatedAt: bundle.generatedAt,\n sourceEssenceVersion: bundle.sourceEssenceVersion,\n manifest: bundle.manifest,\n selector: {\n packType: selector.packType,\n id,\n },\n pack,\n };\n}\n\nexport async function compileSelectedExecutionPack(\n essence: EssenceFile,\n selector: ExecutionPackSelector,\n options: CompileExecutionPackBundleOptions = {},\n): Promise<SelectedExecutionPackResponse | null> {\n const bundle = await compileExecutionPackBundle(essence, options);\n return selectExecutionPackFromBundle(bundle, selector);\n}\n","import type { EssenceFile } from '@decantr/essence-spec';\nimport { isV3, migrateV2ToV3, validateEssence } from '@decantr/essence-spec';\nimport type { ContentResolver, Theme as RegistryTheme } from '@decantr/registry';\nimport { createResolver } from '@decantr/registry';\nimport { buildPageIR } from './ir.js';\nimport { resolveEssence } from './resolve.js';\nimport type { IRAppNode, IRLayer, IRPageNode, IRShellNode, IRStoreNode } from './types.js';\nimport { pascalCase } from './utils.js';\n\nfunction extractRouting(essence: EssenceFile): 'hash' | 'history' | 'pathname' {\n // Modern-SPA default. See packages/cli/src/scaffold.ts getPlatformMeta for rationale.\n if (isV3(essence)) {\n return essence.meta.platform.routing || 'history';\n }\n return (\n ((essence as { platform?: { routing?: string } }).platform?.routing as\n | 'hash'\n | 'history'\n | 'pathname') || 'history'\n );\n}\n\nexport interface PipelineOptions {\n /** Path to content directory (patterns, archetypes, themes) */\n contentRoot?: string;\n\n /** Override paths for local content resolution */\n overridePaths?: string[];\n\n /** Only resolve specific page(s) */\n pageFilter?: string;\n\n /** Optional custom resolver for hosted or in-memory execution */\n resolver?: ContentResolver;\n}\n\nexport interface PipelineResult {\n /** The framework-agnostic intermediate representation */\n ir: IRAppNode;\n /**\n * The fully-resolved registry theme record, including `decorator_definitions`\n * and other rich theme data not carried in the lite IR `theme` node.\n * Consumers (e.g. pack builders) need this to render decorator contracts\n * into compiled artifacts.\n */\n registryTheme: RegistryTheme | null;\n}\n\n/**\n * Run the Design Pipeline:\n * 1. Validate Essence against schema + guard rules\n * 2. Resolve all references (patterns, theme, wiring) from registry\n * 3. Build framework-agnostic IR tree\n * 4. Return IR (no code generation — that's the consumer's job)\n */\nexport async function runPipeline(\n essence: EssenceFile,\n options: PipelineOptions,\n): Promise<PipelineResult> {\n // 1. Validate\n const validation = validateEssence(essence);\n if (!validation.valid) {\n throw new Error(`Invalid essence: ${validation.errors.join(', ')}`);\n }\n\n // 2. Auto-migrate v2 → v3 before processing\n const effectiveEssence = isV3(essence) ? essence : migrateV2ToV3(essence);\n\n // 3. Create resolver and resolve\n const resolver =\n options.resolver ??\n (() => {\n if (!options.contentRoot) {\n throw new Error('Pipeline options must include either a contentRoot or a resolver.');\n }\n\n return createResolver({\n contentRoot: options.contentRoot,\n overridePaths: options.overridePaths,\n });\n })();\n\n const resolved = await resolveEssence(effectiveEssence, resolver);\n\n // 4. Build IR pages (v3 sources get layer metadata)\n const layer: IRLayer | undefined = resolved.isV3Source ? 'blueprint' : undefined;\n const pageNodes: IRPageNode[] = [];\n for (const rp of resolved.pages) {\n const pageIR = buildPageIR(\n rp.page,\n rp.patterns,\n rp.wiring,\n resolved.registryTheme,\n { gap: resolved.density.gap },\n layer,\n );\n pageNodes.push(pageIR);\n }\n\n // Apply page filter\n let filteredPages = pageNodes;\n if (options.pageFilter) {\n filteredPages = pageNodes.filter((p) => p.pageId === options.pageFilter);\n }\n\n // 4. Build shell node\n const shellNode: IRShellNode = {\n type: 'shell',\n id: 'shell',\n children: [],\n config: resolved.shell,\n };\n\n // 5. Build store node\n const storeNode: IRStoreNode = {\n type: 'store',\n id: 'store',\n children: [],\n pageSignals: pageNodes.map((p) => ({\n name: p.pageId,\n pascalName: pascalCase(p.pageId),\n })),\n };\n\n // 6. Assemble app node\n const appNode: IRAppNode = {\n type: 'app',\n id: 'app',\n children: filteredPages,\n theme: resolved.theme,\n routes: resolved.routes,\n routing: extractRouting(resolved.essence),\n shell: shellNode,\n store: storeNode,\n features: resolved.features,\n };\n\n return { ir: appNode, registryTheme: resolved.registryTheme };\n}\n"],"mappings":";AAWA,SAAS,gBAAgB,aAAa,UAAU,YAAY;AAO5D,SAAS,eAAe,4BAA4B;;;ACjB7C,SAAS,WAAW,KAAqB;AAC9C,SAAO,IACJ,MAAM,MAAM,EACZ,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC,CAAC,EACjD,KAAK,EAAE;AACZ;;;ADmDA,IAAM,YAAoC;AAAA,EACxC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,eAAe;AAAA,EACf,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,cAAc;AAAA,EACd,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AACR;AAIA,IAAM,cAAc,oBAAI,IAAI,CAAC,eAAe,CAAC;AAI7C,SAAS,aAAa,MAAsC;AAC1D,SAAO,OAAO,SAAS,YAAY,aAAa;AAClD;AAEA,SAAS,eAAe,MAAw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ACpB,sBAAsB,OAAO;AAAA,IAC7B,UAAU,OAAO;AAAA,IACjB,UAAU;AAAA,MACR,UAAU,SAAS;AAAA,MACnB;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,6BACpB,SACA,UACA,UAA6C,CAAC,GACC;AAC/C,QAAM,SAAS,MAAM,2BAA2B,SAAS,OAAO;AAChE,SAAO,8BAA8B,QAAQ,QAAQ;AACvD;","names":["isPatternRef","isColumnLayout","isPatternRef","isColumnLayout","isV3","migrateV2ToV3","isV3","isV3","isV3","migrateV2ToV3"]}
1
+ {"version":3,"sources":["../src/resolve.ts","../src/utils.ts","../src/ir.ts","../src/ir-helpers.ts","../src/packs.ts","../src/pipeline.ts","../src/realization.ts"],"sourcesContent":["import type {\n BlueprintPage,\n ColumnLayout,\n EssenceFile,\n EssenceV4,\n LayoutItem,\n PatternRef,\n StructurePage,\n} from '@decantr/essence-spec';\nimport { computeDensity, isV4 } from '@decantr/essence-spec';\nimport type {\n ContentResolver,\n Pattern,\n Theme as RegistryTheme,\n ResolvedPreset,\n} from '@decantr/registry';\nimport { detectWirings, resolvePatternPreset } from '@decantr/registry';\nimport type {\n IRNavItem,\n IRRoute,\n IRShellConfig,\n IRTheme,\n IRThemeDecoration,\n IRVisualEffect,\n IRWiring,\n IRWiringSignal,\n} from './types.js';\nimport { pascalCase } from './utils.js';\n\nexport interface ResolvedPage {\n page: ResolvedStructurePage;\n patterns: Map<string, { pattern: Pattern; preset: ResolvedPreset }>;\n wiring: IRWiring | null;\n}\n\ntype ResolvedStructurePage = StructurePage & {\n sectionId?: string;\n route?: string;\n};\n\nexport interface ResolvedEssence {\n essence: EssenceFile;\n pages: ResolvedPage[];\n registryTheme: RegistryTheme | null;\n density: { gap: string; level: string };\n theme: IRTheme;\n shell: IRShellConfig;\n routes: IRRoute[];\n features: string[];\n /** True when the source essence uses the active DNA/Blueprint/Meta contract. */\n isBlueprintSource: boolean;\n}\n\n// ─── Icon Mapping ─────────────────────────────────────────────\n\nconst NAV_ICONS: Record<string, string> = {\n overview: 'layout-dashboard',\n dashboard: 'layout-dashboard',\n home: 'home',\n analytics: 'bar-chart-3',\n settings: 'settings',\n users: 'users',\n billing: 'credit-card',\n reports: 'file-text',\n catalog: 'grid',\n products: 'package',\n orders: 'shopping-cart',\n messages: 'message-square',\n notifications: 'bell',\n activity: 'activity',\n search: 'search',\n profile: 'user',\n team: 'users',\n integrations: 'puzzle',\n api: 'code',\n docs: 'book-open',\n help: 'help-circle',\n projects: 'folder',\n workflows: 'git-branch',\n monitoring: 'monitor',\n security: 'shield',\n storage: 'database',\n deployments: 'rocket',\n logs: 'scroll-text',\n};\n\n// ─── Core styles that don't need explicit addon registration ──\n\nconst CORE_STYLES = new Set(['auradecantism']);\n\n// ─── Helpers ──────────────────────────────────────────────────\n\nfunction isPatternRef(item: LayoutItem): item is PatternRef {\n return typeof item === 'object' && 'pattern' in item;\n}\n\nfunction isColumnLayout(item: LayoutItem): item is ColumnLayout {\n return typeof item === 'object' && 'cols' in item;\n}\n\nfunction extractLayoutRefs(\n layout: LayoutItem[],\n): { id: string; explicitPreset?: string; alias?: string }[] {\n const refs: { id: string; explicitPreset?: string; alias?: string }[] = [];\n for (const item of layout) {\n if (typeof item === 'string') {\n refs.push({ id: item });\n } else if (isPatternRef(item)) {\n refs.push({ id: item.pattern, explicitPreset: item.preset, alias: item.as });\n } else if (isColumnLayout(item)) {\n // cols can mix string ids and PatternRef objects per the schema.\n // Normalize each entry so downstream resolvers always see a string id.\n for (const col of item.cols) {\n if (typeof col === 'string') {\n refs.push({ id: col });\n } else {\n refs.push({ id: col.pattern, explicitPreset: col.preset, alias: col.as });\n }\n }\n }\n }\n return refs;\n}\n\n/** Flatten a layout array so column children are promoted to top-level for wiring detection */\nfunction flattenLayoutForWiring(layout: LayoutItem[]): LayoutItem[] {\n const flat: LayoutItem[] = [];\n for (const item of layout) {\n if (typeof item === 'string') {\n flat.push(item);\n } else if (isPatternRef(item)) {\n flat.push(item);\n } else if (isColumnLayout(item)) {\n // Promote column children as string refs\n for (const col of item.cols) {\n flat.push(col);\n }\n }\n }\n return flat;\n}\n\nfunction routePath(pageId: string, index: number): string {\n if (index === 0) return '/';\n // AUTO: Pages ending in \"-detail\" get a dynamic :id route parameter\n if (pageId.endsWith('-detail')) {\n return `/${pageId}/:id`;\n }\n return `/${pageId}`;\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction buildNavItems(pages: ResolvedStructurePage[], routes?: IRRoute[]): IRNavItem[] {\n const routeLookup = new Map<string, string>(\n (routes ?? []).map((route) => [routeIdentity(route.pageId, route.sectionId), route.path]),\n );\n return pages.map((page, i) => ({\n href: routeLookup.get(routeIdentity(page.id, page.sectionId)) ?? routePath(page.id, i),\n icon: NAV_ICONS[page.id] || 'circle',\n label: capitalize(page.id.replace(/-/g, ' ')),\n }));\n}\n\nfunction buildThemeDecoration(theme: RegistryTheme): IRThemeDecoration | null {\n const shell = theme.shell;\n if (!shell) return null;\n // The JSON may have additional fields not in the strict type\n const shellAny = shell as unknown as Record<string, unknown>;\n return {\n root: shell.root || '',\n nav: shell.nav || '',\n header: shell.header || '',\n brand: (shellAny['brand'] as string) || '',\n navLabel: (shellAny['navLabel'] as string) || '',\n // AUTO: default nav style is 'pill' when the theme does not declare one\n navStyle: shell.nav_style || 'pill',\n defaultNavState: (shellAny['default_nav_state'] as string) || 'expanded',\n dimensions: shell.dimensions || null,\n };\n}\n\nfunction buildThemeFromV4(essence: EssenceV4, isAddon: boolean): IRTheme {\n const dna = essence.dna;\n return {\n id: dna.theme.id,\n mode: dna.theme.mode,\n shape: dna.radius.philosophy || dna.theme.shape || null,\n isAddon,\n };\n}\n\n/** Convert a BlueprintPage to the StructurePage shape used by the resolver pipeline */\nfunction blueprintPageToStructurePage(\n page: BlueprintPage,\n defaultShell: string,\n sectionId?: string,\n): ResolvedStructurePage {\n return {\n id: page.id,\n shell: page.shell_override ?? defaultShell,\n layout: page.layout,\n ...(sectionId ? { sectionId } : {}),\n ...(page.route ? { route: page.route } : {}),\n ...(page.surface ? { surface: page.surface } : {}),\n };\n}\n\nfunction routeIdentity(pageId: string, sectionId?: string): string {\n return sectionId ? `${sectionId}:${pageId}` : pageId;\n}\n\nfunction buildV4Routes(essence: EssenceV4, structurePages: ResolvedStructurePage[]): IRRoute[] {\n const explicitRoutes = new Map<string, string>();\n\n for (const [path, entry] of Object.entries(essence.blueprint.routes ?? {})) {\n if (!entry?.page) continue;\n const key = routeIdentity(entry.page, entry.section);\n if (!explicitRoutes.has(key)) {\n explicitRoutes.set(key, path);\n }\n }\n\n for (const page of structurePages) {\n const key = routeIdentity(page.id, page.sectionId);\n if (page.route && !explicitRoutes.has(key)) {\n explicitRoutes.set(key, page.route);\n }\n }\n\n if (explicitRoutes.size > 0) {\n return structurePages.flatMap((page) => {\n const path = explicitRoutes.get(routeIdentity(page.id, page.sectionId));\n return path\n ? [\n {\n path,\n pageId: page.id,\n shell: page.shell,\n ...(page.sectionId ? { sectionId: page.sectionId } : {}),\n },\n ]\n : [];\n });\n }\n\n return structurePages.map((page, i) => ({\n path: routePath(page.id, i),\n pageId: page.id,\n shell: page.shell,\n ...(page.sectionId ? { sectionId: page.sectionId } : {}),\n }));\n}\n\nfunction convertWiring(wiringResults: ReturnType<typeof detectWirings>): IRWiring | null {\n if (wiringResults.length === 0) return null;\n\n const signals: IRWiringSignal[] = [];\n const props: Record<string, Record<string, string>> = {};\n const hookProps: Record<string, Record<string, string>> = {};\n const hookSet = new Set<IRWiringSignal['hookType']>();\n\n for (const result of wiringResults) {\n for (const signal of result.signals) {\n // Avoid duplicate signals\n if (!signals.some((s) => s.name === signal.name)) {\n const setter = 'set' + signal.name.charAt(0).toUpperCase() + signal.name.slice(1);\n signals.push({\n name: signal.name,\n setter,\n init: signal.init,\n hookType: signal.hookType,\n });\n hookSet.add(signal.hookType);\n }\n }\n for (const [alias, aliasProps] of Object.entries(result.props)) {\n props[alias] = { ...props[alias], ...aliasProps };\n }\n // AUTO: Merge hook-based prop mappings\n for (const [alias, aliasHookProps] of Object.entries(result.hookProps)) {\n hookProps[alias] = { ...hookProps[alias], ...aliasHookProps };\n }\n }\n\n return { signals, props, hooks: [...hookSet], hookProps };\n}\n\n// ─── Visual Effects Resolution ────────────────────────────────\n\nexport function resolveVisualEffects(\n theme: RegistryTheme,\n pattern: Pattern,\n _slot?: string,\n): IRVisualEffect | null {\n const effects = theme.effects;\n if (!effects?.enabled) return null;\n\n const typeMapping = effects.type_mapping || {};\n const componentFallback = effects.component_fallback || {};\n const intensity = effects.intensity || 'medium';\n const intensityValues = effects.intensity_values || {};\n\n // Check pattern tags / components against type_mapping\n let decorators: string[] = [];\n\n // Check if any pattern components match the component_fallback\n for (const comp of pattern.components || []) {\n const effectType = componentFallback[comp];\n if (effectType && typeMapping[effectType]) {\n decorators = [...decorators, ...typeMapping[effectType]];\n }\n }\n\n if (decorators.length === 0) return null;\n\n // Deduplicate\n decorators = [...new Set(decorators)];\n\n return {\n decorators,\n intensity: intensityValues[intensity] || {},\n };\n}\n\n// ─── Main Resolution ─────────────────────────────────────────\n\n/** Resolve all external references in an Essence file */\nexport async function resolveEssence(\n essence: EssenceFile,\n resolver: ContentResolver,\n): Promise<ResolvedEssence> {\n if (!isV4(essence)) {\n throw new Error(\n 'Active Decantr V2 workflows require Essence v4.0.0. Run `decantr migrate --to v4` for older essence files.',\n );\n }\n\n return resolveV4Essence(essence, resolver);\n}\n\n// ─── V4 Resolution ──────────────────────────────────────────\n\nasync function resolveV4Essence(\n essence: EssenceV4,\n resolver: ContentResolver,\n): Promise<ResolvedEssence> {\n const { dna, blueprint, meta } = essence;\n\n // 1. Theme resolution (replaces former recipe resolution)\n let registryTheme: RegistryTheme | null = null;\n const themeResult = await resolver.resolve('theme', dna.theme.id);\n if (themeResult) {\n registryTheme = themeResult.item;\n }\n\n // 2. Density — v4 carries density directly in dna.spacing\n const themeSpatial = registryTheme?.spatial;\n const density = computeDensity(\n dna.personality,\n themeSpatial\n ? {\n density_bias: themeSpatial.density_bias,\n content_gap_shift: themeSpatial.content_gap_shift,\n }\n : undefined,\n );\n // V4 dna.spacing is authoritative; override computed density with DNA values\n const densityResult = {\n gap: dna.spacing.content_gap || density.content_gap,\n level: dna.spacing.density || density.level,\n };\n\n // 3. Theme from DNA layer\n const themeId = dna.theme.id;\n const isAddon = themeId.startsWith('custom:') || !CORE_STYLES.has(themeId);\n const theme = buildThemeFromV4(essence, isAddon);\n\n // 4. Convert sectioned blueprint pages to StructurePage and resolve\n const defaultShell = blueprint.shell ?? blueprint.sections[0]?.shell ?? 'sidebar-main';\n const structurePages: ResolvedStructurePage[] = blueprint.sections.flatMap((section) =>\n section.pages.map((page) =>\n blueprintPageToStructurePage(page, section.shell ?? defaultShell, section.id),\n ),\n );\n const resolvedPages = await resolvePages(structurePages, resolver, registryTheme);\n\n // 5. Shell config from blueprint\n const shellType = defaultShell;\n const brand = pascalCase(meta.archetype);\n const routes = buildV4Routes(essence, structurePages);\n const nav = buildNavItems(structurePages, routes);\n const decoration = registryTheme ? buildThemeDecoration(registryTheme) : null;\n\n const shell: IRShellConfig = {\n type: shellType,\n brand,\n nav,\n inset: false,\n decoration,\n };\n\n return {\n essence,\n pages: resolvedPages,\n registryTheme,\n density: densityResult,\n theme,\n shell,\n routes,\n features: blueprint.features ?? [],\n isBlueprintSource: true,\n };\n}\n\n// ─── Shared page resolution ────────────────────────────────\n\nasync function resolvePages(\n pages: ResolvedStructurePage[],\n resolver: ContentResolver,\n registryTheme: RegistryTheme | null,\n): Promise<ResolvedPage[]> {\n const resolvedPages: ResolvedPage[] = [];\n for (const page of pages) {\n const refs = extractLayoutRefs(page.layout);\n const patterns = new Map<string, { pattern: Pattern; preset: ResolvedPreset }>();\n\n for (const ref of refs) {\n const patternResult = await resolver.resolve('pattern', ref.id);\n if (patternResult) {\n const preset = resolvePatternPreset(\n patternResult.item,\n ref.explicitPreset,\n registryTheme?.pattern_preferences?.default_presets,\n );\n const key = ref.alias || ref.id;\n patterns.set(key, { pattern: patternResult.item, preset });\n }\n }\n\n // Detect wiring (flatten cols so column children are visible)\n const wiringResults = detectWirings(flattenLayoutForWiring(page.layout));\n const wiring = convertWiring(wiringResults);\n\n resolvedPages.push({ page, patterns, wiring });\n }\n return resolvedPages;\n}\n","/** Convert a kebab-case or snake_case string to PascalCase */\nexport function pascalCase(str: string): string {\n return str\n .split(/[-_]/)\n .map((s) => s.charAt(0).toUpperCase() + s.slice(1))\n .join('');\n}\n","import type { ColumnLayout, LayoutItem, PatternRef, StructurePage } from '@decantr/essence-spec';\nimport type { Pattern, Theme as RegistryTheme, ResolvedPreset } from '@decantr/registry';\nimport { resolveVisualEffects } from './resolve.js';\nimport type {\n IRCardWrapping,\n IRGridNode,\n IRLayer,\n IRNode,\n IRPageNode,\n IRPatternMeta,\n IRPatternNode,\n IRVisualEffect,\n IRWiring,\n} from './types.js';\n\nexport interface ResolvedPatternEntry {\n pattern: Pattern;\n preset: ResolvedPreset;\n}\n\nfunction isPatternRef(item: LayoutItem): item is PatternRef {\n return typeof item === 'object' && 'pattern' in item;\n}\n\nfunction isColumnLayout(item: LayoutItem): item is ColumnLayout {\n return typeof item === 'object' && 'cols' in item;\n}\n\nfunction getPatternAlias(item: LayoutItem): string {\n if (typeof item === 'string') return item;\n if (isPatternRef(item)) return item.as || item.pattern;\n return '';\n}\n\nfunction getPatternId(item: LayoutItem): string {\n if (typeof item === 'string') return item;\n if (isPatternRef(item)) return item.pattern;\n return '';\n}\n\nfunction shouldWrapInCard(\n pattern: Pattern,\n preset: ResolvedPreset,\n theme: RegistryTheme | null,\n): boolean {\n // Hero/row/stack layouts are standalone\n const layout = preset.layout.layout;\n if (layout === 'hero' || layout === 'row') return false;\n\n // Pattern explicitly opts out\n if (pattern.contained === false) return false;\n\n // Theme spatial says no cards\n const cardWrapping = theme?.spatial?.card_wrapping;\n if (cardWrapping === 'none') return false;\n\n // Minimal: only wrap if pattern has presets (complex pattern)\n if (cardWrapping === 'minimal') {\n return Object.keys(pattern.presets).length > 0;\n }\n\n // Default: wrap\n return true;\n}\n\nfunction buildCardWrapping(pattern: Pattern, theme: RegistryTheme | null): IRCardWrapping {\n const mode = theme?.spatial?.card_wrapping || 'always';\n return {\n mode: mode as IRCardWrapping['mode'],\n headerLabel: pattern.name,\n };\n}\n\nfunction buildPatternNode(\n patternId: string,\n alias: string,\n resolved: ResolvedPatternEntry | undefined,\n wiring: IRWiring | null,\n theme: RegistryTheme | null,\n density: { gap: string },\n layer?: IRLayer,\n): IRPatternNode {\n const pattern = resolved?.pattern;\n const preset = resolved?.preset;\n\n const layout = preset?.layout.layout || 'column';\n const isStandalone = layout === 'hero' || layout === 'row';\n const contained = pattern && preset ? shouldWrapInCard(pattern, preset, theme) : false;\n const components = pattern?.components || [];\n\n const presetName = preset?.preset || 'default';\n const presetDescription = pattern?.presets?.[presetName]?.description;\n // Thread declared interactions[] from the pattern through to PagePackPattern.\n // so the page-pack renderer can surface them as a checkbox checklist.\n const interactions = Array.isArray((pattern as { interactions?: unknown })?.interactions)\n ? ((pattern as { interactions?: unknown }).interactions as string[])\n : undefined;\n\n const patternMeta: IRPatternMeta = {\n patternId,\n preset: presetName,\n alias,\n layout,\n contained,\n standalone: isStandalone,\n code: preset?.code ? { imports: preset.code.imports, example: preset.code.example } : null,\n components,\n ...(presetDescription ? { presetDescription } : {}),\n ...(interactions && interactions.length > 0 ? { interactions } : {}),\n };\n\n const card = contained && !isStandalone && pattern ? buildCardWrapping(pattern, theme) : null;\n\n const wireProps = wiring?.props[alias] || wiring?.props[patternId] || null;\n\n // Resolve visual effects from theme + pattern when available\n const visualEffects = theme && pattern ? resolveVisualEffects(theme, pattern) : null;\n\n return {\n type: 'pattern',\n id: alias,\n children: [],\n pattern: patternMeta,\n card,\n visualEffects,\n wireProps,\n spatial: { gap: density.gap },\n ...(layer ? { layer } : {}),\n };\n}\n\n/** Build IR tree for a single page from its resolved structure + patterns */\nexport function buildPageIR(\n page: StructurePage & { sectionId?: string },\n resolvedPatterns: Map<string, ResolvedPatternEntry>,\n wiring: IRWiring | null,\n theme: RegistryTheme | null,\n density: { gap: string },\n layer?: IRLayer,\n): IRPageNode {\n const children: IRNode[] = [];\n\n for (const item of page.layout) {\n if (typeof item === 'string') {\n // Simple string → full-width pattern\n const resolved = resolvedPatterns.get(item);\n children.push(buildPatternNode(item, item, resolved, wiring, theme, density, layer));\n } else if (isPatternRef(item)) {\n // PatternRef → pattern with optional preset/alias\n const alias = item.as || item.pattern;\n const resolved = resolvedPatterns.get(alias) || resolvedPatterns.get(item.pattern);\n children.push(buildPatternNode(item.pattern, alias, resolved, wiring, theme, density, layer));\n } else if (isColumnLayout(item)) {\n // ColumnLayout → grid with pattern children\n // cols can mix `string` ids and `PatternRef` objects per the schema.\n // Normalize FIRST so all downstream operations (Map keys, Record\n // keys, joined ids) see strings — otherwise PatternRef objects\n // serialize as `[object Object]` (cold-LLM harness flagged this\n // exact bug in cloud-platform's scaffold-pack).\n const colEntries = item.cols.map((col) => ({\n id: typeof col === 'string' ? col : col.pattern,\n alias: typeof col === 'string' ? col : (col.as ?? col.pattern),\n }));\n const breakpoint = item.at || null;\n const spans = item.span || null;\n\n // Normalize spans: fill in missing columns with weight 1.\n // Span keys reference column ids (the schema's span object uses\n // the column's effective id as the key).\n let normalizedSpans: Record<string, number> | null = null;\n if (spans) {\n normalizedSpans = {};\n for (const entry of colEntries) {\n normalizedSpans[entry.id] = spans[entry.id] || spans[entry.alias] || 1;\n }\n }\n\n const gridChildren: IRNode[] = [];\n for (const entry of colEntries) {\n const resolved = resolvedPatterns.get(entry.alias) || resolvedPatterns.get(entry.id);\n gridChildren.push(\n buildPatternNode(entry.id, entry.alias, resolved, wiring, theme, density, layer),\n );\n }\n\n const totalCols = normalizedSpans\n ? Object.values(normalizedSpans).reduce((a, b) => a + b, 0)\n : colEntries.length;\n\n // AUTO: Pass through multi-breakpoint and container query config from ColumnLayout\n const breakpoints = item.breakpoints?.map((bp) => ({ at: bp.at, cols: bp.cols })) || null;\n const responsive = item.responsive || null;\n\n const gridNode: IRGridNode = {\n type: 'grid',\n id: `grid-${colEntries.map((e) => e.id).join('-')}`,\n children: gridChildren,\n cols: totalCols,\n spans: normalizedSpans,\n breakpoint,\n breakpoints,\n responsive,\n spatial: { gap: density.gap },\n ...(layer ? { layer } : {}),\n };\n children.push(gridNode);\n }\n }\n\n const gapAtom = density.gap.startsWith('_')\n ? density.gap\n : density.gap.startsWith('gap')\n ? `_${density.gap}`\n : `_gap${density.gap}`;\n // Page surface declares layout direction + content gap ONLY. Padding, scroll\n // containment, and flex-grow belong to the shell per the \"Layout Rules\"\n // directive in DECANTR.md (\"One scroll container per region\", \"Let shells\n // own spacing, centering, and scroll containers\", \"Pages should not\n // duplicate shell responsibilities\"). Previous default (`_p4 _overauto\n // _flex1`) contradicted that directive and the V4 harness flagged it as\n // the single most expensive contract-ambiguity friction point. Pages that\n // genuinely need to claim scroll/padding can still declare it explicitly\n // via `page.surface` — the fallback just stops prescribing it.\n const surface = page.surface || `_flex _col ${gapAtom}`;\n\n return {\n type: 'page',\n id: page.sectionId ? `${page.sectionId}:${page.id}` : page.id,\n children,\n pageId: page.id,\n ...(page.sectionId ? { sectionId: page.sectionId } : {}),\n surface,\n wiring,\n ...(layer ? { layer } : {}),\n };\n}\n","import type { IRGridNode, IRNode, IRPatternNode } from './types.js';\n\n/** Depth-first walk of IR tree, calling visitor on each node */\nexport function walkIR(\n node: IRNode,\n visitor: (node: IRNode, parent: IRNode | null) => void,\n parent: IRNode | null = null,\n): void {\n visitor(node, parent);\n for (const child of node.children) {\n walkIR(child, visitor, node);\n }\n}\n\n/** Find all nodes of a specific type */\nexport function findNodes<T extends IRNode>(root: IRNode, type: string): T[] {\n const results: T[] = [];\n walkIR(root, (node) => {\n if (node.type === type) {\n results.push(node as T);\n }\n });\n return results;\n}\n\n/** Count total patterns in an IR tree */\nexport function countPatterns(root: IRNode): number {\n return findNodes(root, 'pattern').length;\n}\n\n/** Validate IR tree structure (no orphaned grids, patterns have meta, etc.) */\nexport function validateIR(root: IRNode): string[] {\n const errors: string[] = [];\n\n walkIR(root, (node, parent) => {\n if (node.type === 'grid') {\n const grid = node as IRGridNode;\n if (grid.children.length === 0) {\n errors.push(`Grid node \"${grid.id}\" has no children`);\n }\n }\n\n if (node.type === 'pattern') {\n const pattern = node as IRPatternNode;\n if (!pattern.pattern) {\n errors.push(`Pattern node \"${pattern.id}\" is missing pattern meta`);\n }\n if (!pattern.pattern.patternId) {\n errors.push(`Pattern node \"${pattern.id}\" has no patternId`);\n }\n }\n\n if (node.type === 'page') {\n if (!node.id) {\n errors.push('Page node is missing id');\n }\n }\n });\n\n return errors;\n}\n","import type { EssenceFile, EssenceV4 } from '@decantr/essence-spec';\nimport { isV4 } from '@decantr/essence-spec';\nimport type { ContentResolver } from '@decantr/registry';\nimport { walkIR } from './ir-helpers.js';\nimport { runPipeline } from './pipeline.js';\nimport type { IRAppNode, IRNode, IRPageNode, IRPatternNode } from './types.js';\n\nexport type ExecutionPackType = 'scaffold' | 'section' | 'page' | 'mutation' | 'review';\n\nexport const EXECUTION_PACK_SCHEMA_URLS = {\n scaffold: 'https://decantr.ai/schemas/scaffold-pack.v1.json',\n section: 'https://decantr.ai/schemas/section-pack.v1.json',\n page: 'https://decantr.ai/schemas/page-pack.v1.json',\n mutation: 'https://decantr.ai/schemas/mutation-pack.v1.json',\n review: 'https://decantr.ai/schemas/review-pack.v1.json',\n} as const;\n\nexport const PACK_MANIFEST_SCHEMA_URL = 'https://decantr.ai/schemas/pack-manifest.v1.json';\nexport const EXECUTION_PACK_BUNDLE_SCHEMA_URL =\n 'https://decantr.ai/schemas/execution-pack-bundle.v1.json';\nexport const SELECTED_EXECUTION_PACK_SCHEMA_URL =\n 'https://decantr.ai/schemas/selected-execution-pack.v1.json';\n\nexport interface ExecutionPackTarget {\n platform: 'web';\n framework: string | null;\n runtime: string | null;\n adapter: string;\n}\n\nexport interface ExecutionPackScope {\n appId: string;\n pageIds: string[];\n patternIds: string[];\n}\n\nexport interface ExecutionPackExample {\n id: string;\n label: string;\n language: string;\n snippet: string;\n}\n\nexport interface ExecutionPackAntiPattern {\n id: string;\n summary: string;\n guidance: string;\n}\n\nexport interface ExecutionPackSuccessCheck {\n id: string;\n label: string;\n severity: 'error' | 'warn' | 'info';\n}\n\nexport interface ExecutionPackTokenBudget {\n target: number;\n max: number;\n strategy: string[];\n}\n\nexport interface ExecutionPackBase<TData> {\n $schema: string;\n packVersion: '1.0.0';\n packType: ExecutionPackType;\n objective: string;\n target: ExecutionPackTarget;\n preset: string | null;\n scope: ExecutionPackScope;\n requiredSetup: string[];\n allowedVocabulary: string[];\n examples: ExecutionPackExample[];\n antiPatterns: ExecutionPackAntiPattern[];\n successChecks: ExecutionPackSuccessCheck[];\n tokenBudget: ExecutionPackTokenBudget;\n data: TData;\n renderedMarkdown: string;\n}\n\nexport interface PackManifestEntry {\n id: string;\n markdown: string;\n json: string;\n}\n\nexport interface PackManifestSectionEntry extends PackManifestEntry {\n pageIds: string[];\n}\n\nexport interface PackManifestPageEntry extends PackManifestEntry {\n sectionId: string | null;\n sectionRole: string | null;\n}\n\nexport interface PackManifestMutationEntry extends PackManifestEntry {\n mutationType: MutationPackKind;\n}\n\nexport interface ExecutionPackManifest {\n $schema: string;\n version: '1.0.0';\n generatedAt: string;\n scaffold: PackManifestEntry | null;\n review: PackManifestEntry | null;\n sections: PackManifestSectionEntry[];\n pages: PackManifestPageEntry[];\n mutations: PackManifestMutationEntry[];\n}\n\nexport interface ScaffoldPackRoute {\n pageId: string;\n sectionId?: string;\n path: string;\n patternIds: string[];\n shell?: string;\n}\n\nexport interface ScaffoldPackData {\n shell: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routing: 'hash' | 'history' | 'pathname';\n features: string[];\n navigation?: {\n /**\n * true = palette enabled with implicit defaults.\n * false = not enabled.\n * object = explicit structured contract (see CommandPaletteContract).\n */\n commandPalette: boolean | CommandPaletteContract;\n hotkeys: Array<{\n key: string;\n route?: string;\n label?: string;\n semantics?: HotkeySemantics;\n }>;\n /** Default hotkey semantics applied unless per-hotkey semantics override. */\n hotkeySemantics?: HotkeySemantics;\n };\n routes: ScaffoldPackRoute[];\n /**\n * Required theme decorator contract — surfaced ONCE at the project level\n * here, then referenced (not duplicated) in each section pack. Cold-LLM\n * runs reported the table was duplicated 7-10× across context files\n * (~270-540 redundant lines per scaffold) when each section pack carried\n * its own copy. Centralizing in scaffold-pack — which the cold prompt\n * tells AI to read first — keeps the contract authoritative without the\n * per-section repetition.\n */\n themeDecorators?: ThemeDecoratorEntry[];\n}\n\nexport interface CommandPaletteContract {\n trigger?: string;\n placeholder?: string;\n width?: string;\n styling?: 'modal' | 'sheet' | 'inline' | 'fullscreen';\n commands?: Array<{\n id: string;\n label: string;\n section?: string;\n hotkey?: string;\n action?: string;\n route?: string;\n }>;\n}\n\nexport interface HotkeySemantics {\n chord_window_ms?: number;\n input_guard?: boolean;\n modifier_suppression?: boolean;\n match_case?: boolean;\n}\n\nexport interface ScaffoldExecutionPack extends ExecutionPackBase<ScaffoldPackData> {\n packType: 'scaffold';\n}\n\nexport interface SectionPackInput {\n id: string;\n role: string;\n shell: string;\n description: string;\n features: string[];\n pageIds: string[];\n navigationItems?: SectionNavigationItemPack[];\n /** Execution-level directives — short imperative rules for this section. */\n directives?: string[];\n}\n\n/** Navigation item contract for a section's primary navigation. */\nexport interface SectionNavigationItemPack {\n label: string;\n route: string;\n icon?: string;\n hotkey?: string;\n active_match?: string;\n badge?: string;\n}\n\nexport interface SectionPackRoute {\n pageId: string;\n sectionId?: string;\n path: string;\n patternIds: string[];\n shell?: string;\n}\n\nexport interface SectionPackData {\n sectionId: string;\n role: string;\n shell: string;\n description: string;\n features: string[];\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routes: SectionPackRoute[];\n /** Contract for items rendered in this section's primary navigation. */\n navigationItems?: SectionNavigationItemPack[];\n /** Execution-level directives emitted into the section-pack rendering. */\n directives?: string[];\n /**\n * Required theme decorator contract surfaced into the compact pack.\n * Mirrors the long-form section-context \"Required Theme Decorators\" table.\n * Cold prompts instruct AI assistants to read packs first, so the strong\n * decorator contract has to live HERE, not just in the long-form file.\n */\n themeDecorators?: ThemeDecoratorEntry[];\n}\n\n/** Compact, render-ready decorator entry for pack contracts. */\nexport interface ThemeDecoratorEntry {\n /** Decorator class name without leading dot, e.g. \"lum-glass\". */\n class: string;\n /** Authored intent describing what the decorator does. */\n intent: string;\n /** Authored slot hints listing where to apply it (joined from usage[]). */\n applyTo: string;\n}\n\nexport interface SectionExecutionPack extends ExecutionPackBase<SectionPackData> {\n packType: 'section';\n}\n\nexport interface PagePackInput {\n pageId: string;\n shell: string;\n sectionId: string | null;\n sectionRole: string | null;\n features: string[];\n /** Execution-level directives — short imperative rules for this page. */\n directives?: string[];\n}\n\nexport interface PagePackPattern {\n id: string;\n alias: string;\n preset: string;\n layout: string;\n /**\n * Per-preset prose from the pattern's preset.description. When present,\n * the page-pack renderer emits it as a short description line so cold\n * LLMs read preset-specific guidance instead of having to look up the\n * pattern's root description.\n */\n presetDescription?: string;\n /**\n * Declared interactions from the pattern JSON. Rendered\n * as a checkbox checklist so cold LLMs in generation mode see a\n * hard-edged list they can't categorize as \"philosophy\". Enforced by\n * decantr check --strict (C5 guard rule).\n */\n interactions?: string[];\n}\n\nexport interface PagePackData {\n pageId: string;\n path: string;\n shell: string;\n sectionId: string | null;\n sectionRole: string | null;\n features: string[];\n surface: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n wiringSignals: string[];\n patterns: PagePackPattern[];\n /** Execution-level directives emitted into the page-pack rendering. */\n directives?: string[];\n}\n\nexport interface PageExecutionPack extends ExecutionPackBase<PagePackData> {\n packType: 'page';\n}\n\nexport type MutationPackKind = 'add-page' | 'modify';\n\nexport interface MutationPackData {\n mutationType: MutationPackKind;\n shell: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routing: 'hash' | 'history' | 'pathname';\n features: string[];\n routes: ScaffoldPackRoute[];\n workflow: string[];\n}\n\nexport interface MutationExecutionPack extends ExecutionPackBase<MutationPackData> {\n packType: 'mutation';\n}\n\nexport type ReviewPackKind = 'app';\n\nexport interface ReviewPackData {\n reviewType: ReviewPackKind;\n shell: string;\n theme: {\n id: string;\n mode: string;\n shape: string | null;\n };\n routing: 'hash' | 'history' | 'pathname';\n features: string[];\n routes: ScaffoldPackRoute[];\n focusAreas: string[];\n workflow: string[];\n}\n\nexport interface ReviewExecutionPack extends ExecutionPackBase<ReviewPackData> {\n packType: 'review';\n}\n\nexport interface ExecutionPackBundle {\n $schema: string;\n generatedAt: string;\n sourceEssenceVersion: string;\n manifest: ExecutionPackManifest;\n scaffold: ScaffoldExecutionPack;\n review: ReviewExecutionPack;\n sections: SectionExecutionPack[];\n pages: PageExecutionPack[];\n mutations: MutationExecutionPack[];\n}\n\nexport type SelectedExecutionPack =\n | ScaffoldExecutionPack\n | ReviewExecutionPack\n | SectionExecutionPack\n | PageExecutionPack\n | MutationExecutionPack;\n\nexport interface ExecutionPackSelector {\n packType: ExecutionPackType;\n id?: string | null;\n}\n\nexport interface SelectedExecutionPackResponse {\n $schema: string;\n generatedAt: string;\n sourceEssenceVersion: string;\n manifest: ExecutionPackManifest;\n selector: {\n packType: ExecutionPackType;\n id: string | null;\n };\n pack: SelectedExecutionPack;\n}\n\nexport interface ScaffoldPackBuilderOptions {\n objective?: string;\n target?: Partial<ExecutionPackTarget>;\n preset?: string | null;\n requiredSetup?: string[];\n examples?: ExecutionPackExample[];\n antiPatterns?: ExecutionPackAntiPattern[];\n successChecks?: ExecutionPackSuccessCheck[];\n tokenBudget?: Partial<ExecutionPackTokenBudget>;\n navigation?: {\n commandPalette: boolean | CommandPaletteContract;\n hotkeys: Array<{\n key: string;\n route?: string;\n label?: string;\n semantics?: HotkeySemantics;\n }>;\n hotkeySemantics?: HotkeySemantics;\n };\n /**\n * Required theme decorator contract surfaced into the scaffold pack.\n * The scaffold pack is read first per cold-prompt rules, so the canonical\n * decorator contract belongs here. Section packs reference this without\n * duplicating to avoid the 7-10× repetition cold-LLM runs reported.\n */\n themeDecorators?: ThemeDecoratorEntry[];\n}\n\nexport interface SectionPackBuilderOptions extends ScaffoldPackBuilderOptions {\n // themeDecorators inherited from base — section packs render a pointer\n // to scaffold-pack rather than re-emitting the full table (1.7.22 dedup).\n}\nexport interface PagePackBuilderOptions extends ScaffoldPackBuilderOptions {}\nexport interface MutationPackBuilderOptions extends ScaffoldPackBuilderOptions {\n mutationType: MutationPackKind;\n workflow?: string[];\n}\nexport interface ReviewPackBuilderOptions extends ScaffoldPackBuilderOptions {\n reviewType?: ReviewPackKind;\n focusAreas?: string[];\n workflow?: string[];\n}\n\nexport interface CompileExecutionPackBundleOptions {\n contentRoot?: string;\n overridePaths?: string[];\n resolver?: ContentResolver;\n}\n\nconst DEFAULT_TARGET: ExecutionPackTarget = {\n platform: 'web',\n framework: null,\n runtime: null,\n adapter: 'generic-web',\n};\n\nconst DEFAULT_TOKEN_BUDGET: ExecutionPackTokenBudget = {\n target: 1400,\n max: 2200,\n strategy: [\n 'Prefer route summaries over repeated prose.',\n 'Use compact vocabulary lists instead of large reference tables.',\n 'Include only task-relevant examples and checks.',\n ],\n};\n\nconst DEFAULT_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'route-topology',\n label: 'Routes and page IDs match the compiled topology.',\n severity: 'error',\n },\n {\n id: 'shell-consistency',\n label: 'The declared shell contract is preserved unless the task explicitly mutates it.',\n severity: 'error',\n },\n {\n id: 'theme-consistency',\n label: 'Theme identity and mode remain consistent across scaffolded routes.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_SECTION_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'section-route-coherence',\n label: 'Section pages and routes remain coherent with the compiled topology.',\n severity: 'error',\n },\n {\n id: 'section-shell-consistency',\n label: 'The section shell contract stays consistent across its routes.',\n severity: 'error',\n },\n {\n id: 'section-pattern-coverage',\n label: 'Primary section patterns are represented without adding off-contract filler sections.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_PAGE_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'page-route-contract',\n label: 'The page keeps the compiled route, shell, and section contract intact.',\n severity: 'error',\n },\n {\n id: 'page-pattern-contract',\n label:\n 'The page preserves its primary compiled patterns instead of drifting into unrelated layouts.',\n severity: 'error',\n },\n {\n id: 'page-state-contract',\n label: 'Any declared wiring signals remain coherent with the rendered page structure.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_MUTATION_SUCCESS_CHECKS: Record<MutationPackKind, ExecutionPackSuccessCheck[]> = {\n 'add-page': [\n {\n id: 'mutation-essence-first',\n label: 'New pages are declared in the essence before any code generation begins.',\n severity: 'error',\n },\n {\n id: 'mutation-shell-contract',\n label:\n 'New routes inherit an existing shell and section contract unless the essence changes first.',\n severity: 'error',\n },\n {\n id: 'mutation-refresh',\n label: 'Refresh compiled packs after the mutation so downstream tasks read current topology.',\n severity: 'warn',\n },\n ],\n modify: [\n {\n id: 'mutation-existing-topology',\n label:\n 'Modified routes remain coherent with the compiled topology unless the essence changes first.',\n severity: 'error',\n },\n {\n id: 'mutation-theme-contract',\n label: 'Theme, shell, and page identity stay aligned with the current contract during edits.',\n severity: 'error',\n },\n {\n id: 'mutation-page-pack-first',\n label:\n 'Route-local edits should start from the compiled page pack rather than improvised structure.',\n severity: 'warn',\n },\n ],\n};\n\nconst DEFAULT_REVIEW_SUCCESS_CHECKS: ExecutionPackSuccessCheck[] = [\n {\n id: 'review-contract-baseline',\n label:\n 'Review findings should use the compiled route, shell, and theme contract as the baseline.',\n severity: 'error',\n },\n {\n id: 'review-evidence',\n label: 'Each critique finding should cite concrete evidence from the generated workspace.',\n severity: 'error',\n },\n {\n id: 'review-remediation',\n label:\n 'Suggested fixes should point back to code changes or essence updates when contract drift exists.',\n severity: 'warn',\n },\n];\n\nconst DEFAULT_REVIEW_ANTI_PATTERNS: ExecutionPackAntiPattern[] = [\n {\n id: 'inline-styles',\n summary: 'Avoid inline style literals as the primary styling path.',\n guidance:\n 'Move visual styling into tokens.css and treatments.css instead of component-local style objects.',\n },\n {\n id: 'hardcoded-colors',\n summary: 'Avoid hardcoded color literals.',\n guidance: 'Use CSS variables and theme decorators instead of hex, rgb, or hsl values.',\n },\n {\n id: 'utility-framework-leakage',\n summary: 'Avoid utility-framework leakage as the primary design language.',\n guidance:\n 'Prefer compiled Decantr treatments and contract vocabulary over ad hoc utility class stacks.',\n },\n];\n\nfunction collectPatternIds(page: IRPageNode): string[] {\n const patternIds: string[] = [];\n walkIR(page, (node: IRNode) => {\n if (node.type !== 'pattern') return;\n const patternNode = node as IRPatternNode;\n patternIds.push(patternNode.pattern.patternId);\n });\n return [...new Set(patternIds)];\n}\n\nfunction pageIdentity(pageId: string, sectionId?: string | null): string {\n return sectionId ? `${sectionId}/${pageId}` : pageId;\n}\n\nfunction pageFileId(pageId: string, sectionId?: string | null): string {\n return pageIdentity(pageId, sectionId).replace(/[^a-zA-Z0-9._-]+/g, '-');\n}\n\nfunction routePageLabel(route: Pick<ScaffoldPackRoute, 'pageId' | 'sectionId'>): string {\n return route.sectionId ? `${route.sectionId}/${route.pageId}` : route.pageId;\n}\n\nfunction summarizeRoutes(appNode: IRAppNode): ScaffoldPackRoute[] {\n return appNode.routes.flatMap((route) => {\n const pageNode = findPageNode(appNode, route.pageId, route.sectionId);\n if (!pageNode) return [];\n return [\n {\n pageId: pageNode.pageId,\n ...(route.sectionId ? { sectionId: route.sectionId } : {}),\n path: route.path,\n patternIds: collectPatternIds(pageNode),\n shell: route.shell,\n },\n ];\n });\n}\n\nfunction summarizeSectionRoutes(appNode: IRAppNode, input: SectionPackInput): SectionPackRoute[] {\n return summarizeRoutes(appNode).filter(\n (route) =>\n input.pageIds.includes(route.pageId) && (!route.sectionId || route.sectionId === input.id),\n );\n}\n\nfunction summarizePageRoute(\n appNode: IRAppNode,\n pageId: string,\n sectionId?: string | null,\n): ScaffoldPackRoute | null {\n return (\n summarizeRoutes(appNode).find(\n (route) =>\n route.pageId === pageId &&\n (!sectionId || !route.sectionId || route.sectionId === sectionId),\n ) ?? null\n );\n}\n\nfunction findPageNode(\n appNode: IRAppNode,\n pageId: string,\n sectionId?: string | null,\n): IRPageNode | null {\n const page = appNode.children.find((node) => {\n const pageNode = node as IRPageNode;\n return (\n pageNode.pageId === pageId &&\n (!sectionId || !pageNode.sectionId || pageNode.sectionId === sectionId)\n );\n });\n return page ? (page as IRPageNode) : null;\n}\n\nfunction collectPagePatterns(page: IRPageNode): PagePackPattern[] {\n const patterns: PagePackPattern[] = [];\n walkIR(page, (node: IRNode) => {\n if (node.type !== 'pattern') return;\n const patternNode = node as IRPatternNode;\n patterns.push({\n id: patternNode.pattern.patternId,\n alias: patternNode.pattern.alias,\n preset: patternNode.pattern.preset,\n layout: patternNode.pattern.layout,\n ...(patternNode.pattern.presetDescription\n ? { presetDescription: patternNode.pattern.presetDescription }\n : {}),\n ...(patternNode.pattern.interactions && patternNode.pattern.interactions.length > 0\n ? { interactions: patternNode.pattern.interactions }\n : {}),\n });\n });\n return patterns;\n}\n\nfunction mergeTokenBudget(overrides?: Partial<ExecutionPackTokenBudget>): ExecutionPackTokenBudget {\n return {\n target: overrides?.target ?? DEFAULT_TOKEN_BUDGET.target,\n max: overrides?.max ?? DEFAULT_TOKEN_BUDGET.max,\n strategy: overrides?.strategy ?? DEFAULT_TOKEN_BUDGET.strategy,\n };\n}\n\nfunction renderList(title: string, entries: string[]): string[] {\n if (entries.length === 0) return [];\n return [title, ...entries.map((entry) => `- ${entry}`), ''];\n}\n\n// Compact description of hotkey semantics for pack markdown. Returns empty\n// string when no semantics are declared so the line can be omitted entirely.\nfunction formatHotkeySemantics(semantics: HotkeySemantics | undefined): string {\n if (!semantics) return '';\n const parts: string[] = [];\n if (typeof semantics.chord_window_ms === 'number') {\n parts.push(`chord window ${semantics.chord_window_ms}ms`);\n }\n if (semantics.input_guard === true) parts.push('suppress during text-input focus');\n if (semantics.input_guard === false) parts.push('fire even while typing (explicit)');\n if (semantics.modifier_suppression === true) parts.push('ignore when modifier held');\n if (semantics.modifier_suppression === false) parts.push('allow modifier passthrough (explicit)');\n if (semantics.match_case === true) parts.push('case-sensitive');\n return parts.join('; ');\n}\n\n// Short, mechanical router-implementation hint so the LLM picks the right\n// imports without having to consult a separate narrative file. Keyed off the\n// same string enum as the schema.\nfunction routingImplementationHint(routing: 'hash' | 'history' | 'pathname'): string {\n switch (routing) {\n case 'hash':\n return 'HashRouter from react-router-dom; URLs prefixed with /# (e.g. /#/login). Only for static-only hosts without SPA fallback.';\n case 'history':\n return 'BrowserRouter from react-router-dom; regular URLs (e.g. /login). Works on Vite dev, Vercel, Netlify, Cloudflare Pages.';\n case 'pathname':\n return 'pathname-based routing (Next.js App Router file conventions).';\n default:\n return String(routing);\n }\n}\n\nexport function renderExecutionPackMarkdown(pack: ExecutionPackBase<unknown>): string {\n const lines: string[] = [];\n const escapeMarkdownCell = (value: string): string => {\n let escaped = '';\n for (const char of value) {\n if (char === '\\\\') escaped += '\\\\\\\\';\n else if (char === '|') escaped += '\\\\|';\n else if (char === '\\n' || char === '\\r') escaped += '<br>';\n else escaped += char;\n }\n return escaped;\n };\n\n lines.push(`# ${pack.packType.charAt(0).toUpperCase()}${pack.packType.slice(1)} Pack`);\n lines.push('');\n lines.push(`**Objective:** ${pack.objective}`);\n lines.push(\n `**Target:** ${pack.target.adapter}${pack.target.framework ? ` (${pack.target.framework})` : ''}`,\n );\n lines.push(\n `**Scope:** pages=${pack.scope.pageIds.join(', ') || 'none'} | patterns=${pack.scope.patternIds.join(', ') || 'none'}`,\n );\n lines.push('');\n\n if (pack.packType === 'scaffold') {\n const scaffoldPack = pack as ScaffoldExecutionPack;\n const scaffoldShells = [\n ...new Set(scaffoldPack.data.routes.map((route) => route.shell).filter(Boolean)),\n ];\n lines.push('## Scaffold Contract');\n lines.push(`- Shell: ${scaffoldPack.data.shell}`);\n if (scaffoldShells.length > 1) {\n const secondaryShells = scaffoldShells.filter((shell) => shell !== scaffoldPack.data.shell);\n lines.push(\n `- Shells: ${[`${scaffoldPack.data.shell} (primary)`, ...secondaryShells].join(', ')}`,\n );\n }\n lines.push(`- Theme: ${scaffoldPack.data.theme.id} (${scaffoldPack.data.theme.mode})`);\n lines.push(\n `- Routing: ${scaffoldPack.data.routing} → ${routingImplementationHint(scaffoldPack.data.routing)}`,\n );\n if (scaffoldPack.data.features.length > 0) {\n lines.push(`- Features: ${scaffoldPack.data.features.join(', ')}`);\n }\n if (\n scaffoldPack.data.navigation?.commandPalette ||\n scaffoldPack.data.navigation?.hotkeys.length\n ) {\n lines.push('- Navigation:');\n const cp = scaffoldPack.data.navigation.commandPalette;\n if (cp) {\n if (typeof cp === 'object') {\n lines.push(' - Command palette:');\n if (cp.trigger) lines.push(` - Trigger: ${cp.trigger}`);\n if (cp.styling)\n lines.push(` - Styling: ${cp.styling}${cp.width ? ` (width ${cp.width})` : ''}`);\n else if (cp.width) lines.push(` - Width: ${cp.width}`);\n if (cp.placeholder) lines.push(` - Placeholder: \"${cp.placeholder}\"`);\n if (cp.commands && cp.commands.length > 0) {\n lines.push(` - Commands (${cp.commands.length}):`);\n for (const command of cp.commands) {\n const parts: string[] = [];\n if (command.section) parts.push(command.section);\n parts.push(command.label);\n if (command.hotkey) parts.push(`[${command.hotkey}]`);\n if (command.route) parts.push(`→ ${command.route}`);\n lines.push(` - ${command.id}: ${parts.join(' · ')}`);\n }\n }\n } else {\n lines.push(' - command palette required');\n }\n }\n const globalSemantics = scaffoldPack.data.navigation.hotkeySemantics;\n if (scaffoldPack.data.navigation.hotkeys.length > 0) {\n const semanticsSummary = formatHotkeySemantics(globalSemantics);\n lines.push(` - Hotkeys${semanticsSummary ? ` (${semanticsSummary})` : ''}:`);\n for (const hotkey of scaffoldPack.data.navigation.hotkeys) {\n const target = [hotkey.label, hotkey.route].filter(Boolean).join(' — ');\n const perKeySemantics = formatHotkeySemantics(hotkey.semantics);\n const suffix = perKeySemantics ? ` _(${perKeySemantics})_` : '';\n lines.push(` - ${hotkey.key}${target ? `: ${target}` : ''}${suffix}`);\n }\n }\n }\n lines.push('');\n\n lines.push('## Route Plan');\n for (const route of scaffoldPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n // Required Theme Decorators — canonical project-level decorator contract\n // (1.7.22). Lives ONCE here in scaffold-pack rather than duplicated across\n // section packs. Cold prompts read scaffold-pack first, so this is the\n // earliest authoritative read of the theme's visual identity contract.\n if (scaffoldPack.data.themeDecorators && scaffoldPack.data.themeDecorators.length > 0) {\n lines.push(`## Required Theme Decorators (${scaffoldPack.data.theme.id})`);\n lines.push('');\n lines.push(\n 'These classes carry the active theme\\'s visual identity. Tokens alone give bones; decorators give personality. Generated source MUST apply these across all sections — without them, every page reads as \"themed colors only\" with no theme character. Section packs reference this table; the contract is project-wide.',\n );\n lines.push('');\n lines.push('| Class | Intent | Apply to |');\n lines.push('|-------|--------|----------|');\n for (const entry of scaffoldPack.data.themeDecorators) {\n lines.push(\n `| \\`.${entry.class}\\` | ${escapeMarkdownCell(entry.intent)} | ${escapeMarkdownCell(entry.applyTo)} |`,\n );\n }\n lines.push('');\n }\n }\n\n if (pack.packType === 'section') {\n const sectionPack = pack as SectionExecutionPack;\n lines.push('## Section Contract');\n lines.push(`- Section: ${sectionPack.data.sectionId}`);\n lines.push(`- Role: ${sectionPack.data.role}`);\n lines.push(`- Shell: ${sectionPack.data.shell}`);\n lines.push(`- Theme: ${sectionPack.data.theme.id} (${sectionPack.data.theme.mode})`);\n if (sectionPack.data.features.length > 0) {\n lines.push(`- Features: ${sectionPack.data.features.join(', ')}`);\n }\n if (sectionPack.data.description) {\n lines.push(`- Description: ${sectionPack.data.description}`);\n }\n lines.push('');\n\n lines.push('## Section Routes');\n for (const route of sectionPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n if (sectionPack.data.navigationItems && sectionPack.data.navigationItems.length > 0) {\n lines.push('## Section Navigation');\n lines.push('');\n lines.push(\n \"Render these items in the shell's primary navigation. Exact match on label, route, and icon.\",\n );\n lines.push('');\n for (const item of sectionPack.data.navigationItems) {\n const parts: string[] = [`${item.label} → ${item.route}`];\n if (item.icon) parts.push(`icon: ${item.icon}`);\n if (item.hotkey) parts.push(`hotkey: ${item.hotkey}`);\n if (item.badge) parts.push(`badge: ${item.badge}`);\n if (item.active_match) parts.push(`active match: \\`${item.active_match}\\``);\n lines.push(`- ${parts.join(' · ')}`);\n }\n lines.push('');\n }\n\n if (sectionPack.data.directives && sectionPack.data.directives.length > 0) {\n lines.push('## Section Directives');\n lines.push('');\n lines.push(\n 'Execution-level rules every page in this section must obey. Follow exactly — these live in the pack contract, not narrative prose.',\n );\n lines.push('');\n for (const directive of sectionPack.data.directives) {\n lines.push(`- ${directive}`);\n }\n lines.push('');\n }\n\n // Theme decorators pointer — full table lives in scaffold-pack.md (1.7.22\n // dedup). F2 Phase 1 cold-LLM runs flagged 7-10× duplication of the same\n // table across section packs (~270-540 redundant lines per scaffold). The\n // canonical contract now lives ONCE in scaffold-pack; section packs cite\n // the theme id and point readers there. Section-pack data still carries\n // themeDecorators if explicitly set (legacy support), but the renderer\n // prefers the pointer form unless a section-specific override is needed.\n if (sectionPack.data.themeDecorators && sectionPack.data.themeDecorators.length > 0) {\n // Legacy/override path — render the full table. Kept for back-compat\n // with consumers that still pass themeDecorators directly.\n lines.push(`## Required Theme Decorators (${sectionPack.data.theme.id})`);\n lines.push('');\n lines.push(\n 'These classes carry the active theme\\'s visual identity. Tokens alone give bones; decorators give personality. Generated source MUST apply these — without them, the page reads as \"themed colors only\" with no theme character.',\n );\n lines.push('');\n lines.push('| Class | Intent | Apply to |');\n lines.push('|-------|--------|----------|');\n for (const entry of sectionPack.data.themeDecorators) {\n lines.push(\n `| \\`.${entry.class}\\` | ${escapeMarkdownCell(entry.intent)} | ${escapeMarkdownCell(entry.applyTo)} |`,\n );\n }\n lines.push('');\n } else {\n // Default path (1.7.22+) — pointer to scaffold-pack's canonical table.\n lines.push('## Theme Decorators');\n lines.push('');\n lines.push(\n `Theme \\`${sectionPack.data.theme.id}\\` decorators are documented ONCE in \\`scaffold-pack.md\\` under \"Required Theme Decorators\". Apply them across this section's pages — the contract is the same project-wide. See also DECANTR.md \"Decorator Quick Reference\" for the same table.`,\n );\n lines.push('');\n }\n }\n\n if (pack.packType === 'page') {\n const pagePack = pack as PageExecutionPack;\n lines.push('## Page Contract');\n lines.push(`- Page: ${pagePack.data.pageId}`);\n lines.push(`- Path: ${pagePack.data.path}`);\n lines.push(`- Shell: ${pagePack.data.shell}`);\n if (pagePack.data.sectionId) {\n const role = pagePack.data.sectionRole ? ` (${pagePack.data.sectionRole})` : '';\n lines.push(`- Section: ${pagePack.data.sectionId}${role}`);\n }\n lines.push(`- Theme: ${pagePack.data.theme.id} (${pagePack.data.theme.mode})`);\n if (pagePack.data.features.length > 0) {\n lines.push(`- Features: ${pagePack.data.features.join(', ')}`);\n }\n if (pagePack.data.surface) {\n lines.push(`- Surface: ${pagePack.data.surface}`);\n }\n lines.push('');\n\n lines.push('## Page Patterns');\n for (const pattern of pagePack.data.patterns) {\n lines.push(\n `- ${pattern.alias} -> ${pattern.id} [${pattern.layout}${pattern.preset ? ` | ${pattern.preset}` : ''}]`,\n );\n // Emit preset-specific description on the next line (indented) when\n // the pattern's preset carries its own prose. This stops cold LLMs\n // from falling back to the blueprint-generic root description.\n if (pattern.presetDescription) {\n lines.push(` > ${pattern.presetDescription}`);\n }\n // Surface declared interactions[] as a checkbox checklist.\n // Hard-edged format — LLMs in generation mode cannot categorize a\n // checkbox as philosophy. Enforced by decantr check --strict (C5).\n if (pattern.interactions && pattern.interactions.length > 0) {\n lines.push(\n ` **Interactions (MUST implement each — see DECANTR.md \"Interaction Requirements\"):**`,\n );\n for (const interaction of pattern.interactions) {\n lines.push(` - [ ] ${interaction}`);\n }\n }\n }\n lines.push('');\n\n if (pagePack.data.wiringSignals.length > 0) {\n lines.push('## Wiring Signals');\n for (const signal of pagePack.data.wiringSignals) {\n lines.push(`- ${signal}`);\n }\n lines.push('');\n }\n\n if (pagePack.data.directives && pagePack.data.directives.length > 0) {\n lines.push('## Page Directives');\n lines.push('');\n lines.push('Execution-level rules for this route. Follow exactly.');\n lines.push('');\n for (const directive of pagePack.data.directives) {\n lines.push(`- ${directive}`);\n }\n lines.push('');\n }\n }\n\n if (pack.packType === 'mutation') {\n const mutationPack = pack as MutationExecutionPack;\n lines.push('## Mutation Contract');\n lines.push(`- Operation: ${mutationPack.data.mutationType}`);\n lines.push(`- Shell: ${mutationPack.data.shell}`);\n lines.push(`- Theme: ${mutationPack.data.theme.id} (${mutationPack.data.theme.mode})`);\n lines.push(\n `- Routing: ${mutationPack.data.routing} → ${routingImplementationHint(mutationPack.data.routing)}`,\n );\n if (mutationPack.data.features.length > 0) {\n lines.push(`- Features: ${mutationPack.data.features.join(', ')}`);\n }\n lines.push('');\n\n lines.push('## Route Topology');\n for (const route of mutationPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n if (mutationPack.data.workflow.length > 0) {\n lines.push('## Workflow');\n for (const step of mutationPack.data.workflow) {\n lines.push(`- ${step}`);\n }\n lines.push('');\n }\n }\n\n if (pack.packType === 'review') {\n const reviewPack = pack as ReviewExecutionPack;\n lines.push('## Review Contract');\n lines.push(`- Review Type: ${reviewPack.data.reviewType}`);\n lines.push(`- Shell: ${reviewPack.data.shell}`);\n lines.push(`- Theme: ${reviewPack.data.theme.id} (${reviewPack.data.theme.mode})`);\n lines.push(`- Routing: ${reviewPack.data.routing}`);\n if (reviewPack.data.features.length > 0) {\n lines.push(`- Features: ${reviewPack.data.features.join(', ')}`);\n }\n lines.push('');\n\n lines.push('## Review Topology');\n for (const route of reviewPack.data.routes) {\n const patterns = route.patternIds.length > 0 ? route.patternIds.join(', ') : 'none';\n lines.push(\n `- ${route.path} -> ${routePageLabel(route)}${route.shell ? ` @ ${route.shell}` : ''} [${patterns}]`,\n );\n }\n lines.push('');\n\n if (reviewPack.data.focusAreas.length > 0) {\n lines.push('## Focus Areas');\n for (const focusArea of reviewPack.data.focusAreas) {\n lines.push(`- ${focusArea}`);\n }\n lines.push('');\n }\n\n if (reviewPack.data.workflow.length > 0) {\n lines.push('## Review Workflow');\n for (const step of reviewPack.data.workflow) {\n lines.push(`- ${step}`);\n }\n lines.push('');\n }\n }\n\n // P1-1 — Page packs skip the universal footer (required setup, allowed\n // vocabulary, success checks, anti-patterns, examples, token budget).\n // These blocks are identical across every page in a 16-page scaffold\n // (~35 lines × N pages of pure boilerplate) and their JSON still carries\n // all fields for any consumer that needs the raw data. Non-page packs\n // keep the full footer — each one (scaffold, section, mutation, review)\n // is a singleton per scaffold so there's no duplication problem.\n if (pack.packType === 'page') {\n lines.push('## Shared Contract');\n lines.push(\n 'Required setup, allowed vocabulary, success checks, anti-patterns, and token budget are shared across every page pack. The full list lives in the pack JSON sidecar (`page-<id>-pack.json`) and in the pack-manifest. Refer there instead of re-reading the same boilerplate 16 times.',\n );\n lines.push('');\n return lines.join('\\n').trimEnd() + '\\n';\n }\n\n lines.push('## Required Setup');\n if (pack.requiredSetup.length === 0) {\n lines.push('- None declared.');\n } else {\n lines.push(...pack.requiredSetup.map((entry) => `- ${entry}`));\n }\n lines.push('');\n\n lines.push('## Allowed Vocabulary');\n if (pack.allowedVocabulary.length === 0) {\n lines.push('- None declared.');\n } else {\n lines.push(...pack.allowedVocabulary.map((entry) => `- ${entry}`));\n }\n lines.push('');\n\n lines.push(\n ...renderList(\n '## Success Checks',\n pack.successChecks.map((entry) => `${entry.label} [${entry.severity}]`),\n ),\n );\n lines.push(\n ...renderList(\n '## Anti-Patterns',\n pack.antiPatterns.map((entry) => `${entry.summary}: ${entry.guidance}`),\n ),\n );\n lines.push(\n ...renderList(\n '## Examples',\n pack.examples.map((entry) => `${entry.label} (${entry.language})`),\n ),\n );\n\n lines.push('## Token Budget');\n lines.push(`- Target: ${pack.tokenBudget.target}`);\n lines.push(`- Max: ${pack.tokenBudget.max}`);\n lines.push(...pack.tokenBudget.strategy.map((entry) => `- ${entry}`));\n lines.push('');\n\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\nexport function resolvePackAdapter(\n target: string | undefined,\n platformType: string | undefined,\n): string {\n if (target === 'react' && platformType === 'spa') return 'react-vite';\n if (target === 'react') return 'react-web';\n if (target === 'vue' && platformType === 'spa') return 'vue-vite';\n if (target === 'svelte' && platformType === 'spa') return 'sveltekit';\n if (target) return target;\n return 'generic-web';\n}\n\nexport function listPackSections(essence: EssenceV4): SectionPackInput[] {\n const declaredSections = essence.blueprint.sections;\n const routedSectionPages = new Set(\n Object.values(essence.blueprint.routes ?? {}).map((entry) => `${entry.section}:${entry.page}`),\n );\n return declaredSections\n .map((section) => {\n const pageIds = section.pages\n .filter(\n (page) =>\n routedSectionPages.size === 0 || routedSectionPages.has(`${section.id}:${page.id}`),\n )\n .map((page) => page.id);\n\n return {\n id: section.id,\n role: section.role,\n shell: section.shell as string,\n description: section.description,\n features: section.features,\n pageIds,\n ...(Array.isArray(section.navigation_items) && section.navigation_items.length > 0\n ? { navigationItems: section.navigation_items as SectionNavigationItemPack[] }\n : {}),\n ...(Array.isArray(section.directives) && section.directives.length > 0\n ? { directives: section.directives }\n : {}),\n };\n })\n .filter((section) => section.pageIds.length > 0);\n}\n\nexport function listPackPages(essence: EssenceV4): PagePackInput[] {\n const declaredSections = essence.blueprint.sections;\n const routedSectionPages = new Set(\n Object.values(essence.blueprint.routes ?? {}).map((entry) => `${entry.section}:${entry.page}`),\n );\n return declaredSections.flatMap((section) =>\n section.pages\n .map((page) => ({\n pageId: page.id,\n shell: (page.shell_override ?? section.shell) as string,\n sectionId: section.id,\n sectionRole: section.role,\n features: section.features,\n ...(Array.isArray(page.directives) && page.directives.length > 0\n ? { directives: page.directives }\n : {}),\n }))\n .filter(\n (page) =>\n routedSectionPages.size === 0 ||\n routedSectionPages.has(`${page.sectionId}:${page.pageId}`),\n ),\n );\n}\n\nfunction buildPageManifestEntries(pages: PagePackInput[]): PackManifestPageEntry[] {\n const counts = new Map<string, number>();\n for (const page of pages) {\n counts.set(page.pageId, (counts.get(page.pageId) ?? 0) + 1);\n }\n\n return pages.map((page) => {\n const hasDuplicatePageId = (counts.get(page.pageId) ?? 0) > 1;\n const id = hasDuplicatePageId ? pageIdentity(page.pageId, page.sectionId) : page.pageId;\n const fileId = hasDuplicatePageId ? pageFileId(page.pageId, page.sectionId) : page.pageId;\n return {\n id,\n markdown: `page-${fileId}-pack.md`,\n json: `page-${fileId}-pack.json`,\n sectionId: page.sectionId,\n sectionRole: page.sectionRole,\n };\n });\n}\n\nexport function buildScaffoldPack(\n appNode: IRAppNode,\n options: ScaffoldPackBuilderOptions = {},\n): ScaffoldExecutionPack {\n const routes = summarizeRoutes(appNode);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n\n const pack: ScaffoldExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.scaffold,\n packVersion: '1.0.0',\n packType: 'scaffold',\n objective:\n options.objective ?? `Scaffold the ${appNode.theme.id} app shell and declared routes.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Treat the declared routes as the topology source of truth.',\n 'Preserve the resolved theme and shell contract unless the task explicitly mutates them.',\n ],\n allowedVocabulary: [\n ...new Set([\n appNode.shell.config.type,\n appNode.theme.id,\n appNode.theme.mode,\n ...appNode.features,\n ...scopePatternIds,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n shell: appNode.shell.config.type,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routing: appNode.routing,\n features: appNode.features,\n navigation: options.navigation,\n routes,\n ...(options.themeDecorators && options.themeDecorators.length > 0\n ? { themeDecorators: options.themeDecorators }\n : {}),\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildSectionPack(\n appNode: IRAppNode,\n input: SectionPackInput,\n options: SectionPackBuilderOptions = {},\n): SectionExecutionPack {\n const routes = summarizeSectionRoutes(appNode, input);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n\n const pack: SectionExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.section,\n packVersion: '1.0.0',\n packType: 'section',\n objective:\n options.objective ??\n `Implement the ${input.id} section using the compiled ${input.shell} shell contract.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Use the declared section routes as the source of truth for this slice of the app.',\n 'Keep the section shell consistent unless the task explicitly changes the shell contract.',\n ],\n allowedVocabulary: [\n ...new Set([\n input.id,\n input.role,\n input.shell,\n appNode.theme.id,\n appNode.theme.mode,\n ...input.features,\n ...scopePatternIds,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_SECTION_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n sectionId: input.id,\n role: input.role,\n shell: input.shell,\n description: input.description,\n features: input.features,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routes,\n ...(input.navigationItems && input.navigationItems.length > 0\n ? { navigationItems: input.navigationItems }\n : {}),\n ...(input.directives && input.directives.length > 0 ? { directives: input.directives } : {}),\n ...(options.themeDecorators && options.themeDecorators.length > 0\n ? { themeDecorators: options.themeDecorators }\n : {}),\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildPagePack(\n appNode: IRAppNode,\n input: PagePackInput,\n options: PagePackBuilderOptions = {},\n): PageExecutionPack {\n const pageNode = findPageNode(appNode, input.pageId, input.sectionId);\n const route = summarizePageRoute(appNode, input.pageId, input.sectionId);\n\n if (!pageNode || !route) {\n throw new Error(`Unknown page for page pack: ${input.pageId}`);\n }\n\n const patterns = collectPagePatterns(pageNode);\n\n const pack: PageExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.page,\n packVersion: '1.0.0',\n packType: 'page',\n objective:\n options.objective ?? `Implement the ${input.pageId} route using the compiled page contract.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: [route.pageId],\n patternIds: [...new Set(patterns.map((pattern) => pattern.id))],\n },\n requiredSetup: options.requiredSetup ?? [\n 'Keep the compiled route and shell contract stable for this page.',\n 'Treat the listed page patterns as the primary structure for this route.',\n ],\n allowedVocabulary: [\n ...new Set(\n [\n input.pageId,\n input.shell,\n input.sectionId ?? '',\n input.sectionRole ?? '',\n appNode.theme.id,\n appNode.theme.mode,\n ...input.features,\n ...patterns.flatMap((pattern) => [pattern.id, pattern.alias, pattern.layout]),\n ].filter(Boolean),\n ),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_PAGE_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n pageId: route.pageId,\n path: route.path,\n shell: input.shell,\n sectionId: input.sectionId,\n sectionRole: input.sectionRole,\n features: input.features,\n surface: pageNode.surface,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n wiringSignals: pageNode.wiring?.signals.map((signal) => signal.name) ?? [],\n patterns,\n ...(input.directives && input.directives.length > 0 ? { directives: input.directives } : {}),\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildMutationPack(\n appNode: IRAppNode,\n options: MutationPackBuilderOptions,\n): MutationExecutionPack {\n const routes = summarizeRoutes(appNode);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n const defaultWorkflow =\n options.mutationType === 'add-page'\n ? [\n 'Declare the new page in the essence before generating code.',\n 'Refresh Decantr context so section and page packs include the new route.',\n 'Read the relevant section pack and new page pack before implementation.',\n ]\n : [\n 'Read the page pack for the route you are modifying first.',\n 'Stop and update the essence before changing route, shell, or pattern contracts.',\n 'Validate and check drift after code changes complete.',\n ];\n\n const pack: MutationExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.mutation,\n packVersion: '1.0.0',\n packType: 'mutation',\n objective:\n options.objective ??\n `Execute the ${options.mutationType} workflow against the compiled app contract.`,\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Treat the compiled topology as the source of truth until the essence changes.',\n 'Refresh Decantr context after structural mutations so downstream tasks read current packs.',\n ],\n allowedVocabulary: [\n ...new Set([\n options.mutationType,\n appNode.shell.config.type,\n appNode.theme.id,\n appNode.theme.mode,\n ...appNode.features,\n ...scopePatternIds,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? [],\n successChecks: options.successChecks ?? DEFAULT_MUTATION_SUCCESS_CHECKS[options.mutationType],\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n mutationType: options.mutationType,\n shell: appNode.shell.config.type,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routing: appNode.routing,\n features: appNode.features,\n routes,\n workflow: options.workflow ?? defaultWorkflow,\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport function buildReviewPack(\n appNode: IRAppNode,\n options: ReviewPackBuilderOptions = {},\n): ReviewExecutionPack {\n const routes = summarizeRoutes(appNode);\n const scopePatternIds = [...new Set(routes.flatMap((route) => route.patternIds))];\n const reviewType = options.reviewType ?? 'app';\n const focusAreas = options.focusAreas ?? [\n 'route-topology',\n 'theme-consistency',\n 'treatment-usage',\n 'accessibility',\n 'responsive-design',\n ];\n const workflow = options.workflow ?? [\n 'Read the scaffold pack and page packs before evaluating generated code.',\n 'Compare findings against the compiled route, shell, and theme contract first.',\n 'Escalate contract drift into essence updates when the requested output intentionally changes topology or theme identity.',\n ];\n\n const pack: ReviewExecutionPack = {\n $schema: EXECUTION_PACK_SCHEMA_URLS.review,\n packVersion: '1.0.0',\n packType: 'review',\n objective:\n options.objective ?? 'Review generated output against the compiled Decantr contract.',\n target: {\n ...DEFAULT_TARGET,\n ...options.target,\n },\n preset: options.preset ?? null,\n scope: {\n appId: appNode.id,\n pageIds: routes.map((route) => route.pageId),\n patternIds: scopePatternIds,\n },\n requiredSetup: options.requiredSetup ?? [\n 'Read the compiled scaffold and route packs before reviewing code.',\n 'Use concrete evidence from the workspace instead of purely stylistic intuition.',\n ],\n allowedVocabulary: [\n ...new Set([\n reviewType,\n appNode.shell.config.type,\n appNode.theme.id,\n appNode.theme.mode,\n ...appNode.features,\n ...scopePatternIds,\n ...focusAreas,\n ]),\n ],\n examples: options.examples ?? [],\n antiPatterns: options.antiPatterns ?? DEFAULT_REVIEW_ANTI_PATTERNS,\n successChecks: options.successChecks ?? DEFAULT_REVIEW_SUCCESS_CHECKS,\n tokenBudget: mergeTokenBudget(options.tokenBudget),\n data: {\n reviewType,\n shell: appNode.shell.config.type,\n theme: {\n id: appNode.theme.id,\n mode: appNode.theme.mode,\n shape: appNode.theme.shape,\n },\n routing: appNode.routing,\n features: appNode.features,\n routes,\n focusAreas,\n workflow,\n },\n renderedMarkdown: '',\n };\n\n pack.renderedMarkdown = renderExecutionPackMarkdown(pack);\n return pack;\n}\n\nexport async function compileExecutionPackBundle(\n essence: EssenceFile,\n options: CompileExecutionPackBundleOptions = {},\n): Promise<ExecutionPackBundle> {\n if (!isV4(essence)) {\n throw new Error(\n 'Active Decantr V2 workflows require Essence v4.0.0. Run `decantr migrate --to v4` for older essence files.',\n );\n }\n\n const generatedAt = new Date().toISOString();\n const sharedTarget = {\n framework: essence.meta.target || null,\n runtime: essence.meta.platform.type || null,\n adapter: resolvePackAdapter(essence.meta.target, essence.meta.platform.type),\n };\n\n const pipeline = await runPipeline(essence, {\n contentRoot: options.contentRoot,\n overridePaths: options.overridePaths,\n resolver: options.resolver,\n });\n\n const navMeta = essence.meta.navigation;\n // Preserve the full command_palette value when it's a structured contract;\n // coerce to boolean only when it's the legacy flag form.\n const commandPaletteValue: boolean | CommandPaletteContract =\n typeof navMeta?.command_palette === 'object' && navMeta.command_palette !== null\n ? (navMeta.command_palette as CommandPaletteContract)\n : Boolean(navMeta?.command_palette);\n\n // Compose theme decorator contract from registry data once and reuse for\n // both scaffold pack (canonical) and section packs (reference). Filter to\n // entries with the minimum data needed to render a useful row.\n const themeDecorators: ThemeDecoratorEntry[] | undefined = (() => {\n const defs = pipeline.registryTheme?.decorator_definitions;\n if (!defs) return undefined;\n const entries: ThemeDecoratorEntry[] = [];\n for (const [name, def] of Object.entries(defs)) {\n const intent = def.intent || def.description || '';\n const applyTo = (def.usage || []).join(', ');\n if (!intent && !applyTo) continue;\n entries.push({ class: name, intent, applyTo });\n }\n return entries.length > 0 ? entries : undefined;\n })();\n\n const scaffold = buildScaffoldPack(pipeline.ir, {\n target: sharedTarget,\n navigation: {\n commandPalette: commandPaletteValue,\n hotkeys: Array.isArray(navMeta?.hotkeys)\n ? navMeta.hotkeys\n .filter(\n (\n hotkey,\n ): hotkey is {\n key: string;\n route?: string;\n action?: string;\n label: string;\n semantics?: HotkeySemantics;\n } =>\n Boolean(\n hotkey && typeof hotkey.key === 'string' && typeof hotkey.label === 'string',\n ),\n )\n .map((hotkey) => ({\n key: hotkey.key,\n route: hotkey.route,\n label: hotkey.label,\n ...(hotkey.semantics ? { semantics: hotkey.semantics as HotkeySemantics } : {}),\n }))\n : [],\n ...(navMeta?.hotkey_semantics\n ? { hotkeySemantics: navMeta.hotkey_semantics as HotkeySemantics }\n : {}),\n },\n ...(themeDecorators ? { themeDecorators } : {}),\n });\n const review = buildReviewPack(pipeline.ir, {\n target: sharedTarget,\n });\n const sectionInputs = listPackSections(essence);\n const pageInputs = listPackPages(essence);\n\n const sections = sectionInputs.map((section) =>\n buildSectionPack(pipeline.ir, section, {\n target: sharedTarget,\n // themeDecorators intentionally NOT passed to section packs as of 1.7.22.\n // Section packs render a one-line pointer to scaffold-pack instead of\n // duplicating the full decorator table — F2 Phase 1 reports flagged\n // 7-10× duplication across context files. The decorators are still\n // available on each section pack as section-pack.theme.id allows the\n // renderer to compose the pointer with the correct theme name.\n }),\n );\n const pages = pageInputs.map((page) =>\n buildPagePack(pipeline.ir, page, {\n target: sharedTarget,\n }),\n );\n const mutations = (['add-page', 'modify'] as const).map((mutationType) =>\n buildMutationPack(pipeline.ir, {\n mutationType,\n target: sharedTarget,\n }),\n );\n\n const manifest: ExecutionPackManifest = {\n $schema: PACK_MANIFEST_SCHEMA_URL,\n version: '1.0.0',\n generatedAt,\n scaffold: {\n id: 'scaffold',\n markdown: 'scaffold-pack.md',\n json: 'scaffold-pack.json',\n },\n review: {\n id: 'review',\n markdown: 'review-pack.md',\n json: 'review-pack.json',\n },\n sections: sectionInputs.map((section) => ({\n id: section.id,\n markdown: `section-${section.id}-pack.md`,\n json: `section-${section.id}-pack.json`,\n pageIds: section.pageIds,\n })),\n pages: buildPageManifestEntries(pageInputs),\n mutations: (['add-page', 'modify'] as const).map((mutationType) => ({\n id: mutationType,\n markdown: `mutation-${mutationType}-pack.md`,\n json: `mutation-${mutationType}-pack.json`,\n mutationType,\n })),\n };\n\n return {\n $schema: EXECUTION_PACK_BUNDLE_SCHEMA_URL,\n generatedAt,\n sourceEssenceVersion: essence.version,\n manifest,\n scaffold,\n review,\n sections,\n pages,\n mutations,\n };\n}\n\nexport function selectExecutionPackFromBundle(\n bundle: ExecutionPackBundle,\n selector: ExecutionPackSelector,\n): SelectedExecutionPackResponse | null {\n const id = selector.id ?? null;\n let pack: SelectedExecutionPack | null = null;\n\n switch (selector.packType) {\n case 'scaffold':\n pack = bundle.scaffold;\n break;\n case 'review':\n pack = bundle.review;\n break;\n case 'section':\n pack = id ? (bundle.sections.find((entry) => entry.data.sectionId === id) ?? null) : null;\n break;\n case 'page':\n pack = id\n ? (bundle.pages.find(\n (entry) =>\n entry.data.pageId === id ||\n pageIdentity(entry.data.pageId, entry.data.sectionId) === id ||\n pageFileId(entry.data.pageId, entry.data.sectionId) === id,\n ) ?? null)\n : null;\n break;\n case 'mutation':\n pack = id ? (bundle.mutations.find((entry) => entry.data.mutationType === id) ?? null) : null;\n break;\n default:\n pack = null;\n break;\n }\n\n if (!pack) {\n return null;\n }\n\n return {\n $schema: SELECTED_EXECUTION_PACK_SCHEMA_URL,\n generatedAt: bundle.generatedAt,\n sourceEssenceVersion: bundle.sourceEssenceVersion,\n manifest: bundle.manifest,\n selector: {\n packType: selector.packType,\n id,\n },\n pack,\n };\n}\n\nexport async function compileSelectedExecutionPack(\n essence: EssenceFile,\n selector: ExecutionPackSelector,\n options: CompileExecutionPackBundleOptions = {},\n): Promise<SelectedExecutionPackResponse | null> {\n const bundle = await compileExecutionPackBundle(essence, options);\n return selectExecutionPackFromBundle(bundle, selector);\n}\n","import type { EssenceFile } from '@decantr/essence-spec';\nimport { validateEssence } from '@decantr/essence-spec';\nimport type { ContentResolver, Theme as RegistryTheme } from '@decantr/registry';\nimport { createResolver } from '@decantr/registry';\nimport { buildPageIR } from './ir.js';\nimport { resolveEssence } from './resolve.js';\nimport type { IRAppNode, IRLayer, IRPageNode, IRShellNode, IRStoreNode } from './types.js';\nimport { pascalCase } from './utils.js';\n\nfunction extractRouting(essence: EssenceFile): 'hash' | 'history' | 'pathname' {\n return essence.meta.platform.routing || 'history';\n}\n\nexport interface PipelineOptions {\n /** Path to content directory (patterns, archetypes, themes) */\n contentRoot?: string;\n\n /** Override paths for local content resolution */\n overridePaths?: string[];\n\n /** Only resolve specific page(s) */\n pageFilter?: string;\n\n /** Optional custom resolver for hosted or in-memory execution */\n resolver?: ContentResolver;\n}\n\nexport interface PipelineResult {\n /** The framework-agnostic intermediate representation */\n ir: IRAppNode;\n /**\n * The fully-resolved registry theme record, including `decorator_definitions`\n * and other rich theme data not carried in the lite IR `theme` node.\n * Consumers (e.g. pack builders) need this to render decorator contracts\n * into compiled artifacts.\n */\n registryTheme: RegistryTheme | null;\n}\n\n/**\n * Run the Design Pipeline:\n * 1. Validate Essence against schema + guard rules\n * 2. Resolve all references (patterns, theme, wiring) from registry\n * 3. Build framework-agnostic IR tree\n * 4. Return IR (no code generation — that's the consumer's job)\n */\nexport async function runPipeline(\n essence: EssenceFile,\n options: PipelineOptions,\n): Promise<PipelineResult> {\n // 1. Validate\n const validation = validateEssence(essence);\n if (!validation.valid) {\n throw new Error(`Invalid essence: ${validation.errors.join(', ')}`);\n }\n\n // 2. Create resolver and resolve\n const resolver =\n options.resolver ??\n (() => {\n if (!options.contentRoot) {\n throw new Error('Pipeline options must include either a contentRoot or a resolver.');\n }\n\n return createResolver({\n contentRoot: options.contentRoot,\n overridePaths: options.overridePaths,\n });\n })();\n\n const resolved = await resolveEssence(essence, resolver);\n\n // 3. Build IR pages\n const layer: IRLayer = 'blueprint';\n const pageNodes: IRPageNode[] = [];\n for (const rp of resolved.pages) {\n const pageIR = buildPageIR(\n rp.page,\n rp.patterns,\n rp.wiring,\n resolved.registryTheme,\n { gap: resolved.density.gap },\n layer,\n );\n pageNodes.push(pageIR);\n }\n\n // Apply page filter\n let filteredPages = pageNodes;\n if (options.pageFilter) {\n filteredPages = pageNodes.filter((p) => p.pageId === options.pageFilter);\n }\n\n // 4. Build shell node\n const shellNode: IRShellNode = {\n type: 'shell',\n id: 'shell',\n children: [],\n config: resolved.shell,\n };\n\n // 5. Build store node\n const storeNode: IRStoreNode = {\n type: 'store',\n id: 'store',\n children: [],\n pageSignals: pageNodes.map((p) => ({\n name: p.pageId,\n pascalName: pascalCase(p.pageId),\n })),\n };\n\n // 6. Assemble app node\n const appNode: IRAppNode = {\n type: 'app',\n id: 'app',\n children: filteredPages,\n theme: resolved.theme,\n routes: resolved.routes,\n routing: extractRouting(resolved.essence),\n shell: shellNode,\n store: storeNode,\n features: resolved.features,\n };\n\n return { ir: appNode, registryTheme: resolved.registryTheme };\n}\n","import type { BlueprintPage, EssenceV4, LayoutItem } from '@decantr/essence-spec';\nimport { isV4 } from '@decantr/essence-spec';\nimport { resolvePackAdapter } from './packs.js';\n\nexport type RealizationAdapter = 'react-vite' | 'next-app' | 'generic-web' | string;\n\nexport interface RealizationRoute {\n path: string;\n sectionId: string;\n sectionRole: string;\n pageId: string;\n shell: string;\n patterns: string[];\n states: Array<'empty' | 'loading' | 'error'>;\n}\n\nexport interface RealizationMockDataSeed {\n id: string;\n source: 'feature' | 'route';\n shape: Record<string, unknown>;\n}\n\nexport interface RealizationInteractionPlaceholder {\n id: string;\n kind: 'command-palette' | 'hotkey' | 'auth-mock' | 'route-action';\n route?: string;\n label: string;\n}\n\nexport interface RealizationPlan {\n version: '1.0.0';\n sourceEssenceVersion: '4.0.0';\n adapter: RealizationAdapter;\n canRealizeFrameworkCode: boolean;\n routes: RealizationRoute[];\n shell: {\n id: string;\n theme: string;\n mode: string;\n };\n mockData: RealizationMockDataSeed[];\n interactions: RealizationInteractionPlaceholder[];\n unsupportedReason?: string;\n}\n\nconst CERTIFIED_REALIZATION_ADAPTERS = new Set(['react-vite', 'next-app']);\n\nfunction routePath(page: BlueprintPage, fallbackIndex: number): string {\n if (page.route) return page.route;\n if (page.id === 'home' || fallbackIndex === 0) return '/';\n return `/${page.id}`;\n}\n\nfunction patternIds(layout: LayoutItem[]): string[] {\n const ids = new Set<string>();\n for (const item of layout) {\n if (typeof item === 'string') {\n ids.add(item);\n } else if ('pattern' in item) {\n ids.add(item.pattern);\n } else if ('cols' in item) {\n for (const col of item.cols) {\n ids.add(typeof col === 'string' ? col : col.pattern);\n }\n }\n }\n return [...ids];\n}\n\nexport function compileRealizationPlan(essence: EssenceV4): RealizationPlan {\n if (!isV4(essence)) {\n throw new Error(\n 'Active Decantr V2 workflows require Essence v4.0.0. Run `decantr migrate --to v4` for older essence files.',\n );\n }\n\n const packAdapter = resolvePackAdapter(essence.meta.target, essence.meta.platform.type);\n const adapter = essence.meta.target === 'nextjs' ? 'next-app' : packAdapter;\n const canRealizeFrameworkCode = CERTIFIED_REALIZATION_ADAPTERS.has(adapter);\n const routes: RealizationRoute[] = [];\n\n for (const section of essence.blueprint.sections) {\n section.pages.forEach((page, pageIndex) => {\n routes.push({\n path: routePath(page, routes.length + pageIndex),\n sectionId: section.id,\n sectionRole: section.role,\n pageId: page.id,\n shell: (page.shell_override ?? section.shell) as string,\n patterns: patternIds(page.layout),\n states: ['empty', 'loading', 'error'],\n });\n });\n }\n\n const mockData: RealizationMockDataSeed[] = [\n ...essence.blueprint.features.map((feature) => ({\n id: feature,\n source: 'feature' as const,\n shape: { enabled: true, status: 'mocked' },\n })),\n ...routes.map((route) => ({\n id: route.pageId,\n source: 'route' as const,\n shape: { title: route.pageId, items: [] },\n })),\n ];\n\n const navigation = essence.meta.navigation;\n const interactions: RealizationInteractionPlaceholder[] = [\n {\n id: 'auth-mock',\n kind: 'auth-mock',\n label: 'Authenticated user/session placeholder',\n },\n ];\n\n if (navigation?.command_palette) {\n interactions.push({\n id: 'command-palette',\n kind: 'command-palette',\n label: 'Command palette placeholder',\n });\n }\n\n for (const hotkey of navigation?.hotkeys ?? []) {\n interactions.push({\n id: `hotkey-${hotkey.key}`,\n kind: 'hotkey',\n route: hotkey.route,\n label: hotkey.label,\n });\n }\n\n return {\n version: '1.0.0',\n sourceEssenceVersion: '4.0.0',\n adapter,\n canRealizeFrameworkCode,\n routes,\n shell: {\n id: (essence.blueprint.shell ??\n essence.blueprint.sections[0]?.shell ??\n 'sidebar-main') as string,\n theme: essence.dna.theme.id,\n mode: essence.dna.theme.mode,\n },\n mockData,\n interactions,\n ...(canRealizeFrameworkCode\n ? {}\n : {\n unsupportedReason:\n 'No certified realization adapter is available for this target yet. Use the V4 contract, execution packs, prompts, and Project Health without generated framework code.',\n }),\n };\n}\n"],"mappings":";AASA,SAAS,gBAAgB,YAAY;AAOrC,SAAS,eAAe,4BAA4B;;;ACf7C,SAAS,WAAW,KAAqB;AAC9C,SAAO,IACJ,MAAM,MAAM,EACZ,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC,CAAC,EACjD,KAAK,EAAE;AACZ;;;ADiDA,IAAM,YAAoC;AAAA,EACxC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,eAAe;AAAA,EACf,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,cAAc;AAAA,EACd,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA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