Skip to content

Commit 6614fc7

Browse files
test(skills): close review findings — package-loader pin, whisper win32 parity, quoted-none
Review follow-ups on #2476: - package-loader.mjs byte-identity pin (the elevated concern): the two copies now carry initializeSessionWithRetry + FALLBACK_TRANSIENT_PATTERNS, exactly the shared-logic shape a future fix could land in one copy and miss in the other — same enforcement as the audio.mjs pin. - whisper win32 call-site parity: runWhisper's npx resolution lifted into lib/npx-sync.mjs (resolveNpxInvocation, injectable params matching the localTtsGenerate idiom) with the same three-branch coverage as the Kokoro site — plus the hard-fail contract (throws actionably, since the whisper fallback has no next provider to fall through to). - quoted music: "none" pin: the vendored storyboard parser strips matching quotes at parse time (stripQuotes), so the silent marker already accepts the quoted spelling — pinned so that stays true. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent 1e195ca commit 6614fc7

6 files changed

Lines changed: 123 additions & 16 deletions

File tree

‎skills-manifest.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"files": 1
2323
},
2424
"hyperframes-animation": {
25-
"hash": "759f42c2e1e7eb7c",
25+
"hash": "82267d3ce0c4238b",
2626
"files": 102
2727
},
2828
"hyperframes-cli": {
@@ -46,8 +46,8 @@
4646
"files": 10
4747
},
4848
"media-use": {
49-
"hash": "6dc869b655caf834",
50-
"files": 125
49+
"hash": "20fbcf6f6f7b61ca",
50+
"files": 127
5151
},
5252
"motion-graphics": {
5353
"hash": "dafcdce07d221aa4",
@@ -62,7 +62,7 @@
6262
"files": 28
6363
},
6464
"product-launch-video": {
65-
"hash": "b344036156ff77ab",
65+
"hash": "3041af53ce770d2a",
6666
"files": 23
6767
},
6868
"remotion-to-hyperframes": {

‎skills/hyperframes-animation/scripts/animation-map.test.mjs‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from "node:assert/strict";
22
import { spawnSync } from "node:child_process";
3-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
44
import { tmpdir } from "node:os";
55
import { dirname, join, resolve } from "node:path";
66
import { fileURLToPath } from "node:url";
@@ -117,6 +117,25 @@ describe("HyperFrames skill helpers", () => {
117117
});
118118
});
119119

120+
// The two package-loader.mjs copies are intentionally byte-identical (each
121+
// skill ships standalone, so neither can import the other's) and now carry
122+
// shared logic (initializeSessionWithRetry + FALLBACK_TRANSIENT_PATTERNS)
123+
// that a future fix could land in one copy and silently miss in the other —
124+
// the exact drift class the audio.mjs identity pin was born to catch.
125+
describe("package-loader parity", () => {
126+
it("package-loader.mjs is byte-identical to hyperframes-creative's copy (the stated contract)", () => {
127+
const here = readFileSync(
128+
join(REPO_ROOT, "skills", "hyperframes-animation", "scripts", "package-loader.mjs"),
129+
"utf8",
130+
);
131+
const sibling = readFileSync(
132+
join(REPO_ROOT, "skills", "hyperframes-creative", "scripts", "package-loader.mjs"),
133+
"utf8",
134+
);
135+
assert.equal(here, sibling);
136+
});
137+
});
138+
120139
// ── Transient-init retry (the zero-duration false-fail fix) ─────────────────
121140
// A valid modular project's sub-composition timelines register asynchronously;
122141
// the first initializeSession can time out with the transient "zero duration /
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { existsSync } from "node:fs";
2+
import { resolveSpawnCommand } from "../../audio/scripts/lib/tts.mjs";
3+
4+
// Sync-spawn analog of the audio engine's spawnP, for execFileSync call sites
5+
// that must hard-fail (rather than fall through to another provider) when npx
6+
// cannot be resolved. On Windows a bare "npx" is npx.cmd, which
7+
// execFileSync/spawnSync cannot exec (spawnSync npx ENOENT) —
8+
// resolveSpawnCommand reroutes it through node + npx-cli.js, no shell:true.
9+
//
10+
// `platform`/`env`/`pathExists` params (defaulting to the real values) exist
11+
// so tests can exercise the win32 branch without mocking node:child_process
12+
// (its ESM exports are non-configurable) — same idiom as spawnP and
13+
// localTtsGenerate.
14+
export function resolveNpxInvocation(
15+
argv,
16+
opts,
17+
platform = process.platform,
18+
env = process.env,
19+
pathExists = existsSync,
20+
) {
21+
const resolved = resolveSpawnCommand("npx", argv, opts, platform, env, pathExists);
22+
if (!resolved) {
23+
// npx-on-win32 with no resolvable npx-cli.js — same terminal condition
24+
// spawnP warns about, surfaced as a throw for callers with no fallback.
25+
throw new Error(
26+
"cannot run npx on Windows: npm's npx-cli.js was not found " +
27+
"(install npm with Node, or run via npx/npm run so npm_execpath is set)",
28+
);
29+
}
30+
return resolved;
31+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { test } from "node:test";
2+
import assert from "node:assert/strict";
3+
import { resolveNpxInvocation } from "./npx-sync.mjs";
4+
5+
// Coverage parity with tts-local-provider.test.mjs, for the whisper.cpp
6+
// fallback's call-site shape (transcribe.mjs runWhisper): the same three
7+
// branches, but with the hard-fail contract — no fallback provider exists,
8+
// so an unresolvable npx must throw actionably instead of returning null.
9+
10+
const envWithNpxCli = {
11+
npm_execpath: "C:/Program Files/nodejs/node_modules/npm/bin/npm-cli.js",
12+
npm_node_execpath: "C:/Program Files/nodejs/node.exe",
13+
};
14+
const npxCliPath = "C:/Program Files/nodejs/node_modules/npm/bin/npx-cli.js";
15+
const pathExists = (path) => path === npxCliPath;
16+
17+
const WHISPER_ARGV = ["hyperframes", "transcribe", "C:\\media\\input.wav", "--dir", "C:\\work"];
18+
const WHISPER_OPTS = { stdio: ["ignore", "pipe", "pipe"], timeout: 1_800_000 };
19+
20+
test("win32: routes the whisper fallback through node + npx-cli, never bare npx", () => {
21+
const resolved = resolveNpxInvocation(
22+
WHISPER_ARGV,
23+
WHISPER_OPTS,
24+
"win32",
25+
envWithNpxCli,
26+
pathExists,
27+
);
28+
29+
assert.equal(resolved.cmd, envWithNpxCli.npm_node_execpath);
30+
assert.equal(resolved.args[0], npxCliPath);
31+
assert.deepEqual(resolved.args.slice(1, 3), ["hyperframes", "transcribe"]);
32+
// execFileSync options survive the rerouting (the timeout bounds the
33+
// whisper build/model download; the pipes surface its errors).
34+
assert.deepEqual(resolved.opts.stdio, ["ignore", "pipe", "pipe"]);
35+
assert.equal(resolved.opts.timeout, 1_800_000);
36+
});
37+
38+
test("win32 without a resolvable npx-cli: throws the actionable install hint", () => {
39+
assert.throws(
40+
() => resolveNpxInvocation(WHISPER_ARGV, WHISPER_OPTS, "win32", {}, () => false),
41+
/npx-cli\.js was not found/,
42+
);
43+
});
44+
45+
test("non-win32: spawns plain npx unchanged", () => {
46+
const resolved = resolveNpxInvocation(WHISPER_ARGV, WHISPER_OPTS, "darwin", {}, () => false);
47+
48+
assert.equal(resolved.cmd, "npx");
49+
assert.deepEqual(resolved.args, WHISPER_ARGV);
50+
});

‎skills/media-use/scripts/transcribe.mjs‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { basename, extname, join, resolve } from "node:path";
1515
import { parseArgs } from "node:util";
1616
import { mergeTokensToWords } from "./lib/parakeet-words.mjs";
1717
import { track } from "./lib/telemetry.mjs";
18-
import { resolveSpawnCommand } from "../audio/scripts/lib/tts.mjs";
18+
import { resolveNpxInvocation } from "./lib/npx-sync.mjs";
1919

2020
// The DEFAULT local transcription path. Prefers NVIDIA Parakeet-TDT via
2121
// parakeet-mlx, which beats whisper.cpp on the Open ASR Leaderboard (~6.05% vs
@@ -128,19 +128,13 @@ function runWhisper() {
128128
const workDir = mkdtempSync(join(tmpdir(), "media-use-whisper-"));
129129
try {
130130
// On Windows a bare "npx" is npx.cmd, which execFileSync cannot exec
131-
// (spawnSync npx ENOENT) — resolveSpawnCommand reroutes it through
132-
// node + npx-cli.js, same as the audio engine's TTS spawns.
133-
const resolved = resolveSpawnCommand(
134-
"npx",
131+
// (spawnSync npx ENOENT) — resolveNpxInvocation reroutes it through
132+
// node + npx-cli.js (and throws actionably when it can't), same
133+
// mechanism as the audio engine's TTS spawns.
134+
const resolved = resolveNpxInvocation(
135135
["hyperframes", "transcribe", inputPath, "--dir", workDir],
136136
{ stdio: ["ignore", "pipe", "pipe"], timeout: 1_800_000 },
137137
);
138-
if (!resolved) {
139-
throw new Error(
140-
"cannot run npx on Windows: npm's npx-cli.js was not found " +
141-
"(install npm with Node, or run via npx/npm run so npm_execpath is set)",
142-
);
143-
}
144138
execFileSync(resolved.cmd, resolved.args, resolved.opts);
145139
const produced = join(workDir, "transcript.json");
146140
if (!existsSync(produced)) throw new Error("whisper produced no transcript.json");

‎skills/product-launch-video/scripts/audio.test.mjs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ test("music: none with narration keeps TTS but turns BGM off (not fully silent)"
108108
assert.equal(request.lines.length, 1);
109109
});
110110

111+
test('a quoted music: "none" is still the silent marker (frontmatter stripQuotes)', () => {
112+
// YAML authors quote scalars freely; the vendored storyboard parser strips
113+
// matching quotes at parse time (storyboard.mjs stripQuotes), so the marker
114+
// must not depend on the unquoted spelling.
115+
const { dir, result } = runAudioRaw({
116+
storyboard: '---\nmessage: Test\nmusic: "none"\n---\n',
117+
});
118+
119+
assert.equal(result.status, 0, result.stderr);
120+
assert.match(result.stdout, /marked silent/);
121+
assert.equal(existsSync(join(dir, "audio_meta.json")), false);
122+
});
123+
111124
test("a storyboard music mood still retrieves BGM (marker is exact, not fuzzy)", () => {
112125
const { dir, result } = runAudioRaw({
113126
storyboard: "---\nmessage: Test\nmusic: upbeat synthwave with heavy drums\n---\n",

0 commit comments

Comments
 (0)