CherryHQ/cherry-studio · error · Error

[theme-contract] runtime input ${declaration.name} cannot de

Error message

[theme-contract] runtime input ${declaration.name} cannot depend on host-local ${reference}

What it means

Thrown by assertLayerDependencies when a runtime-input declaration (--cs-theme-*) in theme-input.css references a host-local variable (prefix --app-*). Runtime inputs must be self-contained values the host writes into --cs-theme-* directly; depending on host-local state would create a hidden coupling between the theme input layer and arbitrary host CSS variables.

Source

Thrown at packages/ui/scripts/validate-theme-contract.ts:267

          reference.startsWith('--color-') ||
          reference.startsWith('--app-')
        ) {
          throw new Error(`[theme-contract] foundation ${declaration.name} cannot depend on upper-layer ${reference}`)
        }
      }
    }
  }

  for (const declaration of extractDeclarations(sources.themeInput, 'theme-input.css')) {
    if (!runtimeVariables.has(declaration.name)) {
      throw new Error(`[theme-contract] theme-input.css declares unregistered runtime input ${declaration.name}`)
    }
    for (const reference of extractReferences(declaration.value, declaration.source)) {
      if (officialVariables.has(reference) || productVariables.has(reference) || reference.startsWith('--color-')) {
        throw new Error(`[theme-contract] runtime input ${declaration.name} cannot depend on upper-layer ${reference}`)
      }
      if (reference.startsWith('--app-')) {
        throw new Error(`[theme-contract] runtime input ${declaration.name} cannot depend on host-local ${reference}`)
      }
    }
  }

  for (const declaration of extractDeclarations(sources.shadcn, 'shadcn.css')) {
    if (declaration.name.startsWith(runtimeVariablePrefix)) {
      throw new Error(`[theme-contract] shadcn.css cannot own runtime input ${declaration.name}`)
    }
    for (const reference of extractReferences(declaration.value, declaration.source)) {
      if (productVariables.has(reference) || reference.startsWith('--color-') || reference.startsWith('--app-')) {
        throw new Error(`[theme-contract] Shadcn ${declaration.name} cannot depend on product/adapter ${reference}`)
      }
    }
  }

  for (const declaration of extractDeclarations(sources.product, 'product.css')) {
    for (const reference of extractReferences(declaration.value, declaration.source)) {
      const validNamespace =

View on GitHub (pinned to 726446b54c)

Solutions

  1. Have the host write the --cs-theme-* variable directly at runtime (that is the intended injection point), and remove the --app-* reference from theme-input.css.
  2. If an --app-* value must be consumed by product CSS, declare the dependency in product.css instead (the product layer is where host-local concerns are allowed to surface, subject to its own rules).
  3. Re-run `pnpm --filter @cherrystudio/ui theme:check`.

Example fix

// before (theme-input.css)
--cs-theme-primary: var(--app-accent);
// after — host writes --cs-theme-accent directly; theme-input stays foundation-only
--cs-theme-primary: var(--cs-primary);
Defensive patterns

Strategy: validation

Validate before calling

// Reject --app-* references inside theme-input.css.
const hostRefs = [...sources.themeInput.matchAll(/var\(\s*(--app-[a-z0-9-]+)/g)].map((m) => m[1])
if (hostRefs.length) throw new Error(`theme-input depends on host-local: ${hostRefs.join(', ')}`)

Try / catch

try {
  validateThemeContractSources(sources)
} catch (error) {
  if (error instanceof Error && /runtime input .* cannot depend on host-local/.test(error.message)) {
    console.error(error.message)
    process.exitCode = 1
    return
  }
  throw error
}

Prevention

When it happens

Trigger: Writing `--cs-theme-primary: var(--app-accent);` in theme-input.css; routing a host-injected color through theme-input via an --app-* reference.

Common situations: Migrating host-side theming into the contract and incorrectly wiring --app-* values into theme-input instead of having the host write --cs-theme-* directly.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/b27863a8f8a2b6b7. Report an issue: GitHub.