Skip to content

Write HTML. Render video. Built for agents.

fix(skill): address PR #1026 review — find $HOME, order-indep audioRegex, cached reads

ukimsanova5bc11632f4a
diff --git a/skills/website-to-hyperframes/references/step-3-storyboard.md b/skills/website-to-hyperframes/references/step-3-storyboard.md
index 00657dad21..aaebd640cf 100644
--- a/skills/website-to-hyperframes/references/step-3-storyboard.md
+++ b/skills/website-to-hyperframes/references/step-3-storyboard.md
@@ -192,7 +192,7 @@ When planning beats, decide which ones deserve an HTML-in-Canvas treatment vs. a
**Before writing beats,** read the SFX manifest. Locate it from your current directory:
```bash
-find / -path '*/website-to-hyperframes/assets/sfx/manifest.json' -maxdepth 12 2>/dev/null | head -1
+find "$HOME" -path '*/website-to-hyperframes/assets/sfx/manifest.json' -maxdepth 10 2>/dev/null | head -1
```
Or if you already copied SFX into the project (Step 5 does this), read your local `sfx/manifest.json`. Each entry has a filename, duration in seconds, and description. Assign **specific SFX files** to exact moments in the storyboard. Step 5 implements what you specify here — it makes no SFX decisions.
@@ -362,7 +362,7 @@ Write this section for THIS project's actual brand and the assets audited above
### Text Animations
-Every text element in this beat must name a specific effect from the catalog. The reference page is at [`../../hyperframes/references/text-effects.md`](../../hyperframes/references/text-effects.md) (or locate it with `find / -path '*/hyperframes/references/text-effects.md' -maxdepth 12 2>/dev/null | head -1`). It lists 24 effect IDs (from the separate `pixel-point/animate-text` skill); pick what fits the brand and this beat's mood — don't default to the same effect every beat.
+Every text element in this beat must name a specific effect from the catalog. The reference page is at [`../../hyperframes/references/text-effects.md`](../../hyperframes/references/text-effects.md) (or locate it with `find "$HOME" -path '*/hyperframes/references/text-effects.md' -maxdepth 10 2>/dev/null | head -1`). It lists 24 effect IDs (from the separate `pixel-point/animate-text` skill); pick what fits the brand and this beat's mood — don't default to the same effect every beat.
Format (FORMAT EXAMPLES of structure, not prescriptions — pick based on brand/mood/context):
diff --git a/skills/website-to-hyperframes/references/step-5-build.md b/skills/website-to-hyperframes/references/step-5-build.md
index 2b3d12524c..5bcb94a6a4 100644
--- a/skills/website-to-hyperframes/references/step-5-build.md
+++ b/skills/website-to-hyperframes/references/step-5-build.md
@@ -301,7 +301,7 @@ Build the composition for Beat N. Save to compositions/beat-N-name.html.
FIRST: Locate and read the beat-builder guide. Your CWD is the project directory, so
the skill lives outside it — run this to find it:
- find / -path '*/website-to-hyperframes/references/beat-builder-guide.md' -maxdepth 12 2>/dev/null | head -1
+ find "$HOME" -path '*/website-to-hyperframes/references/beat-builder-guide.md' -maxdepth 10 2>/dev/null | head -1
Read that file end to end. It has your full workflow, all rules, easing vocabulary,
and file references. Follow its workflow exactly:
diff --git a/skills/website-to-hyperframes/references/step-6-validate.md b/skills/website-to-hyperframes/references/step-6-validate.md
index 94d9f280ba..cb2f192a3d 100644
--- a/skills/website-to-hyperframes/references/step-6-validate.md
+++ b/skills/website-to-hyperframes/references/step-6-validate.md
@@ -42,7 +42,7 @@ Run it as the LAST gate in your DoD pass, after fixing everything else:
node <repo-root>/skills/website-to-hyperframes/scripts/w2h-verify.mjs <project-dir>
```
-(Locate the repo root from a project subdirectory: `find / -path '*/skills/website-to-hyperframes/scripts/w2h-verify.mjs' -maxdepth 12 2>/dev/null | head -1`.)
+(Locate the repo root from a project subdirectory: `find "$HOME" -path '*/skills/website-to-hyperframes/scripts/w2h-verify.mjs' -maxdepth 10 2>/dev/null | head -1`.)
**The script's output is the deliverable.** Paste the entire report — the table, the percentages, the FAIL lines — verbatim into your final user-facing summary, in the "What I verified" / "What I did NOT verify" section. The user will read it directly. You don't get to summarize, simplify, or omit rows.
diff --git a/skills/website-to-hyperframes/scripts/w2h-verify.mjs b/skills/website-to-hyperframes/scripts/w2h-verify.mjs
index 879f848f9f..26ce8eefdc 100644
--- a/skills/website-to-hyperframes/scripts/w2h-verify.mjs
+++ b/skills/website-to-hyperframes/scripts/w2h-verify.mjs
@@ -399,13 +399,23 @@ async function checkSfxTimestampConsistency() {
};
}
+ // Collect ALL audio tags per file (multi-timestamp SFX like click.mp3 have
+ // 3 tags). Use a two-step extraction so we don't depend on src= and
+ // data-start= attribute ordering — the documented canonical pattern in
+ // capabilities.md puts src= LAST in the tag, which an order-dependent
+ // regex would miss → false MISSING reports.
const indexSfx = new Map();
- const audioRegex =
- /<audio[^>]*src=["'](?:[^"']*\/)?sfx\/([\w-]+\.mp3)["'][^>]*?data-start=["']([0-9.]+)["']/g;
- let m;
- while ((m = audioRegex.exec(index)) !== null) {
- if (!indexSfx.has(m[1])) indexSfx.set(m[1], []);
- indexSfx.get(m[1]).push(parseFloat(m[2]));
+ const audioTagRegex = /<audio[^>]*?>/g;
+ let tagMatch;
+ while ((tagMatch = audioTagRegex.exec(index)) !== null) {
+ const tag = tagMatch[0];
+ const srcMatch = tag.match(/src=["'](?:[^"']*\/)?sfx\/([\w-]+\.mp3)["']/);
+ const dsMatch = tag.match(/data-start=["']([0-9.]+)["']/);
+ if (!srcMatch || !dsMatch) continue;
+ const file = srcMatch[1];
+ const t = parseFloat(dsMatch[1]);
+ if (!indexSfx.has(file)) indexSfx.set(file, []);
+ indexSfx.get(file).push(t);
}
const drifts = [];
@@ -593,9 +603,16 @@ async function checkMp4Exists() {
// ─── Helpers ─────────────────────────────────────────────────────────────────
+// Cached so multiple checks don't re-read the same files. The script is a
+// one-shot CLI so a process-scoped cache is fine; no invalidation needed.
+let _compositionsCache = null;
async function readBeatCompositions() {
+ if (_compositionsCache) return _compositionsCache;
const dir = join(PROJECT_DIR, "compositions");
- if (!existsSync(dir)) return [];
+ if (!existsSync(dir)) {
+ _compositionsCache = [];
+ return _compositionsCache;
+ }
const files = await readdir(dir);
const beats = files.filter((f) => /^beat-/i.test(f) && f.endsWith(".html"));
const out = [];
@@ -603,6 +620,7 @@ async function readBeatCompositions() {
const content = await readFile(join(dir, f), "utf-8");
out.push({ name: f, content });
}
+ _compositionsCache = out;
return out;
}
@@ -653,9 +671,15 @@ function extractTopLevelPositionArgs(content) {
}
// Returns a map of { "beat-1-name": durationInSeconds, ... } from index.html.
+// Cached per-process (one-shot CLI, no invalidation needed).
+let _beatDurationsCache = null;
async function readBeatDurationsFromIndex() {
+ if (_beatDurationsCache) return _beatDurationsCache;
const indexPath = join(PROJECT_DIR, "index.html");
- if (!existsSync(indexPath)) return {};
+ if (!existsSync(indexPath)) {
+ _beatDurationsCache = {};
+ return _beatDurationsCache;
+ }
const content = await readFile(indexPath, "utf-8");
const map = {};
@@ -673,6 +697,7 @@ async function readBeatDurationsFromIndex() {
if (idMatch) map[idMatch[1]] = dur;
if (srcMatch) map[srcMatch[1]] = dur;
}
+ _beatDurationsCache = map;
return map;
}