Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(core,figma-skill): address PR feedback — regex key escaping, no-shell psnr probe
Vance Ingalls3d59dcc694bd
diff --git a/packages/core/src/figma/motionContextToDocs.ts b/packages/core/src/figma/motionContextToDocs.tsindex ba6a11a55b..7b07db9b49 100644--- a/packages/core/src/figma/motionContextToDocs.ts+++ b/packages/core/src/figma/motionContextToDocs.ts@@ -58,7 +58,15 @@ export interface MotionContextToDocsOptions {/** motion.dev property → GSAP property. */const PROPERTY_MAP: Record<string, string> = { rotate: "rotation" };-/** Extract the balanced `{...}` body following `marker` in `src`. */+/** Escape regex metacharacters — keys are `\w+` property names today, but a+ * future caller passing anything else must not silently misparse. */+function escapeRegExp(text: string): string {+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");+}++/** Extract the balanced `{...}` body following `marker` in `src`. Brace+ * counting does not skip string literals — sound for motion.dev output+ * (numeric arrays + named eases, never arbitrary strings containing `}`). */function balancedBlock(src: string, marker: string): string | null {const at = src.indexOf(marker);if (at === -1) return null;@@ -77,7 +85,7 @@ function balancedBlock(src: string, marker: string): string | null {/** Extract a balanced `[...]` immediately after `key:` inside `src`. */function arrayAfterKey(src: string, key: string): string | null {- const re = new RegExp(`${key}\\s*:\\s*\\[`);+ const re = new RegExp(`${escapeRegExp(key)}\\s*:\\s*\\[`);const m = re.exec(src);if (!m) return null;const start = m.index + m[0].length - 1;@@ -93,7 +101,7 @@ function arrayAfterKey(src: string, key: string): string | null {}function scalarAfterKey(src: string, key: string): string | null {- const m = new RegExp(`${key}\\s*:\\s*("[^"]*"|[\\w.]+)`).exec(src);+ const m = new RegExp(`${escapeRegExp(key)}\\s*:\\s*("[^"]*"|[\\w.]+)`).exec(src);return m?.[1] ?? null;}diff --git a/skills-manifest.json b/skills-manifest.jsonindex 1b48b1bf0c..c2a86bf30f 100644--- a/skills-manifest.json+++ b/skills-manifest.json@@ -10,7 +10,7 @@"files": 18},"figma": {- "hash": "e84abcb652194f57",+ "hash": "3172ad95070aaecc","files": 2},"general-video": {diff --git a/skills/figma/scripts/verify-motion.mjs b/skills/figma/scripts/verify-motion.mjsindex 0531a626b1..07d79be9cc 100644--- a/skills/figma/scripts/verify-motion.mjs+++ b/skills/figma/scripts/verify-motion.mjs@@ -21,7 +21,7 @@* frame. Measure it from the render (the card's left/top edge + scaled* size), don't guess: a wrong crop reads as motion divergence.*/-import { execFileSync, execSync } from "node:child_process";+import { execFileSync, spawnSync } from "node:child_process";import { mkdtempSync, rmSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";@@ -72,8 +72,9 @@ const frame = (src, t, vf, dst) => {const diff = (a, b, dst) =>execFileSync("ffmpeg", ["-y", "-v", "error", "-i", a, "-i", b, "-filter_complex", "blend=all_mode=difference", dst]);const psnr = (a, b) => {- const err = execSync(`ffmpeg -i ${JSON.stringify(a)} -i ${JSON.stringify(b)} -lavfi psnr -f null - 2>&1`).toString();- const m = err.match(/average:([\d.]+|inf)/);+ // spawnSync with array args (no shell): psnr stats land on stderr+ const r = spawnSync("ffmpeg", ["-i", a, "-i", b, "-lavfi", "psnr", "-f", "null", "-"], { encoding: "utf8" });+ const m = (r.stderr || "").match(/average:([\d.]+|inf)/);return m ? (m[1] === "inf" ? 99 : Number(m[1])) : NaN;};