Skip to content

Write HTML. Render video. Built for agents.

fix(skills): preserve preset color roles in frame contrast checks (#5195)

Abdullah M. Nazif29b901dc60c4
diff --git a/skills-manifest.json b/skills-manifest.json
index e5aa8bf1d1..8d35dfe882 100644
--- a/skills-manifest.json
+++ b/skills-manifest.json
@@ -6,7 +6,7 @@
"files": 144
},
"faceless-explainer": {
- "hash": "3459707d807fdde5",
+ "hash": "1f10a69e0f879698",
"files": 28
},
"figma": {
@@ -66,12 +66,12 @@
"files": 169
},
"pr-to-video": {
- "hash": "b38d166d7328e4cb",
+ "hash": "88f4c68788eaba9e",
"files": 34
},
"product-launch-video": {
- "hash": "d78ebd2c45fa8bec",
- "files": 35
+ "hash": "76149a9f3514626e",
+ "files": 36
},
"remotion-to-hyperframes": {
"hash": "d02be65b7f3f4a63",
diff --git a/skills/faceless-explainer/scripts/build-frame.mjs b/skills/faceless-explainer/scripts/build-frame.mjs
index f84940bcab..54de674177 100644
--- a/skills/faceless-explainer/scripts/build-frame.mjs
+++ b/skills/faceless-explainer/scripts/build-frame.mjs
@@ -534,7 +534,12 @@ const outColors = parseColors(md);
if (outColors.length !== presetColors.length) {
die(`color keys changed (${presetColors.length}→${outColors.length}) — keys must be preserved`);
}
-const outRoles = semanticColors(outColors);
+// The preset's role keys stay fixed when a dark brand reverses their luminance order.
+const presetRoles = semanticColors(presetColors);
+const inkKey = presetColors.find(([, value]) => value === presetRoles.ink)?.[0];
+const canvasKey = presetColors.find(([, value]) => value === presetRoles.canvas)?.[0];
+const outByKey = new Map(outColors);
+const outRoles = { ink: outByKey.get(inkKey), canvas: outByKey.get(canvasKey) };
const li = lum(outRoles.ink),
lc = lum(outRoles.canvas);
// ink (type) and canvas (ground) must differ enough to READ — in EITHER direction. A
diff --git a/skills/pr-to-video/scripts/build-frame.mjs b/skills/pr-to-video/scripts/build-frame.mjs
index 617b1d3fa2..e93626d3c9 100644
--- a/skills/pr-to-video/scripts/build-frame.mjs
+++ b/skills/pr-to-video/scripts/build-frame.mjs
@@ -569,7 +569,12 @@ const outColors = parseColors(md);
if (outColors.length !== presetColors.length) {
die(`color keys changed (${presetColors.length}→${outColors.length}) — keys must be preserved`);
}
-const outRoles = semanticColors(outColors);
+// The preset's role keys stay fixed when a dark brand reverses their luminance order.
+const presetRoles = semanticColors(presetColors);
+const inkKey = presetColors.find(([, value]) => value === presetRoles.ink)?.[0];
+const canvasKey = presetColors.find(([, value]) => value === presetRoles.canvas)?.[0];
+const outByKey = new Map(outColors);
+const outRoles = { ink: outByKey.get(inkKey), canvas: outByKey.get(canvasKey) };
const li = lum(outRoles.ink),
lc = lum(outRoles.canvas);
// ink (type) and canvas (ground) must differ enough to READ — in EITHER direction. A
diff --git a/skills/product-launch-video/scripts/build-frame-colors.test.mjs b/skills/product-launch-video/scripts/build-frame-colors.test.mjs
new file mode 100644
index 0000000000..af84c40e5b
--- /dev/null
+++ b/skills/product-launch-video/scripts/build-frame-colors.test.mjs
@@ -0,0 +1,88 @@
+import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { fileURLToPath } from "node:url";
+import test from "node:test";
+import { parseColors } from "./lib/tokens.mjs";
+
+const workflows = ["product-launch-video", "faceless-explainer", "pr-to-video"];
+const presets = [
+ { name: "bold-poster", ink: "dark", canvas: "bg" },
+ { name: "cartesian", ink: "text-primary", canvas: "bg-primary" },
+ { name: "blue-professional", ink: "text", canvas: "bg" },
+];
+
+function brandTokens(ink, canvas) {
+ return {
+ colors: [canvas, ink, "#ff6b35"],
+ colorStats: [
+ { hex: canvas, count: 10, bgCount: 5, areaBg: 900000, maxArea: 900000 },
+ { hex: ink, count: 20, textCount: 20 },
+ { hex: "#ff6b35", count: 5, bgCount: 2, maxArea: 4000, textCount: 1, interactiveBg: 2 },
+ ],
+ };
+}
+
+function buildFrame(t, workflow, preset, tokens) {
+ const project = mkdtempSync(join(tmpdir(), "frame-colors-"));
+ t.after(() => rmSync(project, { recursive: true, force: true }));
+ if (tokens) {
+ mkdirSync(join(project, "capture/extracted"), { recursive: true });
+ writeFileSync(join(project, "capture/extracted/tokens.json"), JSON.stringify(tokens));
+ }
+ const result = spawnSync(
+ process.execPath,
+ [
+ fileURLToPath(new URL(`../../${workflow}/scripts/build-frame.mjs`, import.meta.url)),
+ "--preset",
+ preset,
+ "--hyperframes",
+ project,
+ ],
+ { encoding: "utf8", timeout: 10000 },
+ );
+ assert.ifError(result.error);
+ return { ...result, project };
+}
+
+for (const workflow of workflows) {
+ for (const preset of presets) {
+ for (const [polarity, ink, canvas] of [
+ ["dark", "#ffffff", "#0a1628"],
+ ["light", "#0a1628", "#ffffff"],
+ ]) {
+ test(`${workflow} validates ${preset.name} with a ${polarity} brand`, (t) => {
+ const result = buildFrame(t, workflow, preset.name, brandTokens(ink, canvas));
+ assert.equal(result.status, 0, result.stderr);
+ assert.match(result.stdout, /self-check: keys preserved, ink\/canvas contrast ok/);
+ const colors = new Map(parseColors(readFileSync(join(result.project, "frame.md"), "utf8")));
+ assert.equal(colors.get(preset.ink), ink);
+ assert.equal(colors.get(preset.canvas), canvas);
+ });
+ }
+
+ test(`${workflow} keeps ${preset.name}'s palette without brand tokens`, (t) => {
+ const result = buildFrame(t, workflow, preset.name);
+ assert.equal(result.status, 0, result.stderr);
+ const original = readFileSync(
+ new URL(
+ `../../hyperframes-creative/frame-presets/${preset.name}/FRAME.md`,
+ import.meta.url,
+ ),
+ "utf8",
+ );
+ const output = readFileSync(join(result.project, "frame.md"), "utf8");
+ assert.deepEqual(parseColors(output), parseColors(original));
+ });
+ }
+
+ test(`${workflow} still rejects a brand with insufficient ink/canvas contrast`, (t) => {
+ const result = buildFrame(t, workflow, "bold-poster", {
+ colors: ["#101010", "#202020", "#301020"],
+ });
+ assert.equal(result.status, 1);
+ assert.match(result.stderr, /ink .* and canvas .* lack contrast/);
+ });
+}
diff --git a/skills/product-launch-video/scripts/build-frame.mjs b/skills/product-launch-video/scripts/build-frame.mjs
index caaa587e92..174731bee5 100644
--- a/skills/product-launch-video/scripts/build-frame.mjs
+++ b/skills/product-launch-video/scripts/build-frame.mjs
@@ -532,7 +532,12 @@ const outColors = parseColors(md);
if (outColors.length !== presetColors.length) {
die(`color keys changed (${presetColors.length}→${outColors.length}) — keys must be preserved`);
}
-const outRoles = semanticColors(outColors);
+// The preset's role keys stay fixed when a dark brand reverses their luminance order.
+const presetRoles = semanticColors(presetColors);
+const inkKey = presetColors.find(([, value]) => value === presetRoles.ink)?.[0];
+const canvasKey = presetColors.find(([, value]) => value === presetRoles.canvas)?.[0];
+const outByKey = new Map(outColors);
+const outRoles = { ink: outByKey.get(inkKey), canvas: outByKey.get(canvasKey) };
const li = lum(outRoles.ink),
lc = lum(outRoles.canvas);
// ink (type) and canvas (ground) must differ enough to READ — in EITHER direction. A