// Load presets from disk. Each preset is a JSON file; index.json is the manifest // used to render the picker cards. The store is created with the resolved presets // directory so it works from repo root (dev) and /app (Docker) alike. import { readFileSync } from 'node:fs'; import type { Preset, PresetMeta } from '../shared/types'; export interface PresetStore { listMeta(): PresetMeta[]; get(id: string): Preset | null; } export function createPresetStore(dir: string): PresetStore { const manifest = JSON.parse(readFileSync(`${dir}/index.json`, 'utf8')) as PresetMeta[]; return { listMeta() { return manifest; }, get(id: string) { try { return JSON.parse(readFileSync(`${dir}/${id}.json`, 'utf8')) as Preset; } catch { return null; } }, }; }