Skip to content

Agent skill for creative 3D visualization: turn an idea into a Three.js/Blender scene worth exploring. Claude Code + Codex plugin, 223 recipes, 440 knowledge records, 22 proved kits, 37 runnable studies.

6.2 KB
Raw Blame
// Generates site/src/generated/*.json and theme.css from the repository's own data.
// Every counter on the landing page comes from here; none is typed by hand.
import { mkdir, writeFile } from 'node:fs/promises';
import {
  countEvidenceEvents,
  countStudyDirectories,
  readCatalogSummary,
  readEvalScale,
  readShowcase,
  readSourceCount,
} from './build-data-sources.mjs';
import { CHAPTERS, readExamples, readInstall, readPalette } from './build-data-content.mjs';
import { readCatalog } from './build-data-catalog.mjs';
import { readCompatibility } from './build-data-design.mjs';

const outDir = new URL('../src/generated/', import.meta.url);

// The maintainer's Daylight design (Landing D — Daylight.dc.html) states these values inline on
// every element; they are authored art direction, so they live here as constants rather than being
// read out of a record. The record palette rides along below as --color-look-*.
const DESIGN_TOKENS = {
  cream: '#fffaf2', // page background
  ink: '#1c2a23', // headings, dark cards
  body: '#3a453f', // body prose
  mute: '#55605a', // section ledes, card blurbs, nav labels
  dim: '#69736d', // footer prose, figure captions
  'mono-dim': '#5c6a62', // mono kickers and study ids
  line: '#e2ede6', // hairline borders
  'line-strong': '#d7e7dd', // outline buttons
  wash: '#eef8f2', // outline-button hover
  tint: '#e8f5ee', // nav-link hover
  tile: '#f4faf6', // tiles inside the loop cards
  dash: '#b9cfc2', // dashed connector between loop steps
  'dash-line': '#cbe0d4', // dashed border of the loop box
  green: '#0b7553', // accent: links, primary button, figures
  'green-dark': '#085c41', // accent hover
  mint: '#e2f4ea', // mint chip fill
  'mint-line': '#cfe9dc', // mint chip border
  lime: '#c7ef7a', // LOOP badge fill
  'lime-ink': '#17452f', // LOOP badge text
  leaf: '#f3f9e2', // leaf chip fill
  'leaf-ink': '#4f7a14', // leaf chip text
  'leaf-line': '#e4efc9', // leaf chip border
  sky: '#e4f0fa', // sky chip fill
  'sky-ink': '#155273', // sky chip text
  'sky-line': '#d2e5f3', // sky chip border
  sand: '#fff3e0', // sand chip fill
  'sand-ink': '#8a5300', // sand chip text
  'sand-line': '#f3e2c8', // sand chip border
  rose: '#fdecec', // "still limited" chip fill
  'rose-ink': '#9b2c2c', // "still limited" chip text
  dark: '#1c2a23', // host-probe and install cards
  'dark-mute': '#c2d3ca', // prose on a dark card
  'dark-dim': '#9fb3a8', // mono kicker on a dark card
  'dark-mint': '#a7f3c8', // probe results, inline code on dark
  'dark-mint-2': '#9be6c4', // WORKS WITH status labels
  'panel-mint': '#e9f6ee', // numbers panel gradient, start
  'panel-leaf': '#f6fbe6', // numbers panel gradient, end
};

const DESIGN_FONTS = {
  display: 'Outfit, ui-sans-serif, system-ui, Helvetica, sans-serif',
  mono: '"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace',
};

/** Deterministic JSON: keys sorted at every level, two-space indent, trailing newline. */
function stableJson(value) {
  const sortKeys = (node) => {
    if (Array.isArray(node)) return node.map(sortKeys);
    if (node && typeof node === 'object') {
      return Object.fromEntries(
        Object.keys(node)
          .sort()
          .map((key) => [key, sortKeys(node[key])]),
      );
    }
    return node;
  };
  return `${JSON.stringify(sortKeys(value), null, 2)}\n`;
}

function themeCss(palette) {
  const line = (name, value) => `  --color-${name}: ${value};`;
  return [
    '/* Generated by site/scripts/build-data.mjs. Do not edit.',
    '   Colours and type: the maintainer\'s Daylight design, authored in build-data.mjs.',
    `   --color-look-*: the skill's own ${palette.record} record. */`,
    '@theme {',
    ...Object.entries(DESIGN_TOKENS).map(([name, hex]) => line(name, hex)),
    ...Object.entries(palette.colors).map(([name, hex]) => line(`look-${name}`, hex)),
    `  --font-display: ${DESIGN_FONTS.display};`,
    `  --font-mono: ${DESIGN_FONTS.mono};`,
    '}',
    '',
  ].join('\n');
}

function chapterCounts(examples) {
  const counts = Object.fromEntries(CHAPTERS.map((chapter) => [chapter, 0]));
  for (const study of examples) counts[study.chapter] += 1;
  return counts;
}

async function main() {
  const [
    summary,
    sources,
    evidenceEvents,
    evalScale,
    showcase,
    examples,
    palette,
    install,
    studyDirs,
    compatibility,
    catalog,
  ] = await Promise.all([
    readCatalogSummary(),
    readSourceCount(),
    countEvidenceEvents(),
    readEvalScale(),
    readShowcase(),
    readExamples(),
    readPalette(),
    readInstall(),
    countStudyDirectories(),
    readCompatibility(),
    readCatalog(),
  ]);

  if (examples.length !== studyDirs) {
    throw new Error(
      `build-data: examples/README.md lists ${examples.length} studies but examples/ ships ${studyDirs} runnable directories`,
    );
  }

  const stats = {
    recipes: summary.recipes,
    knowledge: summary.knowledge,
    blueprints: summary.blueprints,
    directions: summary.directions,
    sources,
    evidence_events: evidenceEvents,
    studies: examples.length,
    showcase_frames: showcase.length,
    eval_scale: evalScale,
  };

  await mkdir(outDir, { recursive: true });
  const files = {
    'stats.json': stableJson(stats),
    'examples.json': stableJson(examples),
    'catalog.json': stableJson(catalog),
    'showcase.json': stableJson(showcase),
    'palette.json': stableJson(palette),
    'install.json': stableJson(install),
    'compatibility.json': stableJson(compatibility),
    'theme.css': themeCss(palette),
  };
  for (const [name, contents] of Object.entries(files)) {
    await writeFile(new URL(name, outDir), contents);
  }

  const counts = chapterCounts(examples);
  const clips = examples.filter((study) => study.clip !== null).length;
  console.log(
    `build-data: ${stats.studies} studies (${CHAPTERS.map((c) => counts[c]).join(' / ')}), ` +
      `${clips} hover clips on disk, ${stats.showcase_frames} frames, ` +
      `${stats.evidence_events} evidence events, ${Object.keys(palette.colors).length} look tokens, ` +
      `${install.length} install tabs, ${compatibility.length} compatibility rows, ` +
      `catalog groups ${catalog.directions.length} directions / ${catalog.kinds.length} knowledge kinds / ` +
      `${catalog.blueprints.length} blueprints.`,
  );
}

await main();