Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
Resolve Windows audio decoders from absolute PATH entries
Alex Greenshpun297d3e49af9d
diff --git a/skills/anidoodle/engine/tools/sounds-unit.mjs b/skills/anidoodle/engine/tools/sounds-unit.mjsindex d66a521..61bc8ba 100644--- a/skills/anidoodle/engine/tools/sounds-unit.mjs+++ b/skills/anidoodle/engine/tools/sounds-unit.mjs@@ -41,7 +41,7 @@ M.clearBanks(); zone.sha256 = "0".repeat(64); writeFileSync(join(root, "manifestassert.throws(() => loadBanks(M, root, ["piano"]), /sha256 mismatch/); assert.equal(M.bankFor("piano"), undefined);console.log("PASS corrupt large FLAC hash: rejected before registration");let failures = 0;-const check = (label, fn) => { try { fn(); console.log(`PASS ${label}`); } catch (e) { failures++; console.error(`FAIL ${label}: ${e.message}`); } };+const check = (label, fn) => { if (process.env.ANIDOODLE_TEST_CASE && !label.includes(process.env.ANIDOODLE_TEST_CASE)) return; try { fn(); console.log(`PASS ${label}`); } catch (e) { failures++; console.error(`FAIL ${label}: ${e.message}`); } };zone.sha256 = originalRoom.sha256; manifest.rooms = {}; writeFileSync(join(root, 'manifest.json'), JSON.stringify(manifest));check('inherited constructor never becomes a sample-bank lookup', () => {M.clearBanks(); loadBanks(M, root, ['constructor']); assert.equal(M.bankFor('constructor'), undefined);@@ -86,5 +86,21 @@ check('film audio discovers and plays a default install with env unset', () => {const out = execFileSync(process.execPath, ['--require', preload, script], { env, encoding: 'utf8', maxBuffer: 1<<24 });assert.match(out, /DEFAULT FILM RECORDINGS PASS/);});+check('Windows decoder selection uses absolute PATH binaries, not implicit current-directory lookup', () => {+ const windowsPath = join(root, 'windows-path'); mkdirSync(windowsPath, { recursive: true });+ const marker = join(root, 'windows-decoder-marker');+ for (const command of ['ffprobe', 'ffmpeg']) {+ const real = execFileSync('which', [command], { encoding: 'utf8' }).trim();+ const shim = join(windowsPath, command + '.mjs');+ writeFileSync(shim, `import {readFileSync,writeFileSync} from 'node:fs'; import {execFileSync} from 'node:child_process'; writeFileSync(${JSON.stringify(marker)},'PATH binary'); process.stdout.write(execFileSync(${JSON.stringify(real)},process.argv.slice(2),{input:readFileSync(0),maxBuffer:1<<28}));`);+ const quote = s => "'" + s.replaceAll("'", "'\"'\"'") + "'";+ writeFileSync(join(windowsPath, command + '.exe'), `#!/bin/sh\nexec ${quote(process.execPath)} ${quote(shim)} \"$@\"\n`);+ chmodSync(join(windowsPath, command + '.exe'), 0o755);+ }+ const script = join(root, 'windows-loader.mjs');+ writeFileSync(script, `import {loadBanks} from ${JSON.stringify(new URL('./sounds.mjs', import.meta.url).href)}; const M=await import(${JSON.stringify('data:text/javascript;base64,'+Buffer.from(js).toString('base64'))}); Object.defineProperty(process,'platform',{value:'win32'}); loadBanks(M,${JSON.stringify(root)},['piano']);`);+ execFileSync(process.execPath, [script], { env: { ...process.env, PATH: windowsPath, PATHEXT: '.exe' }, maxBuffer: 1<<24 });+ assert.equal(readFileSync(marker, 'utf8'), 'PATH binary');+});if (failures) process.exitCode = 1;else console.log('SOUNDS LOADER REVIEW PASS');diff --git a/skills/anidoodle/engine/tools/sounds.mjs b/skills/anidoodle/engine/tools/sounds.mjsindex ec12244..1409d5b 100644--- a/skills/anidoodle/engine/tools/sounds.mjs+++ b/skills/anidoodle/engine/tools/sounds.mjs@@ -1,19 +1,32 @@// Host-side sound packs: verify the pinned FLAC bytes, decode once, then hand PCM to the engine.-import { readFileSync, realpathSync } from "node:fs";+import { readFileSync, realpathSync, existsSync } from "node:fs";import { resolve, sep, isAbsolute } from "node:path";import { createHash } from "node:crypto";import { execFileSync } from "node:child_process";export const soundIds = (piece) => piece.legacy ? [] : [...new Set(piece.parts.filter((p) => p.notes.length && p.opts?.sampled !== false).map((p) => typeof p.opts?.variant === "string" && p.opts.variant ? `${p.inst}.${p.opts.variant}` : p.inst))];+// Windows otherwise searches the current directory before PATH.+const decoderPath = (command) => {+ if (process.platform !== "win32") return command;+ const suffixes = (process.env.PATHEXT || ".EXE").split(";");+ for (const dir of (process.env.PATH || "").split(";")) {+ if (!isAbsolute(dir)) continue;+ for (const suffix of suffixes) {+ const file = resolve(dir, command + suffix);+ if (existsSync(file)) return file;+ }+ }+ throw new Error(`${command}: executable missing from absolute PATH directories`);+};const decodeFlac = (root, id, zone) => {if (typeof zone.file !== "string" || isAbsolute(zone.file) || !zone.file.endsWith(".flac")) throw new Error(`${id}: invalid FLAC path`);const file = realpathSync(resolve(root, zone.file)); if (!file.startsWith(root + sep)) throw new Error(`${id}: zone escapes pack: ${zone.file}`);const bytes = readFileSync(file), sha = createHash("sha256").update(bytes).digest("hex");if (typeof zone.sha256 !== "string" || sha !== zone.sha256.toLowerCase()) throw new Error(`${id}: sha256 mismatch: ${zone.file}`);// Count frames so ffprobe consumes the complete verified buffer rather than closing stdin early.- const info = JSON.parse(execFileSync("ffprobe", ["-v", "error", "-f", "flac", "-i", "pipe:0", "-count_frames", "-show_streams", "-of", "json"], { input: bytes, encoding: "utf8", maxBuffer: 1 << 20 })).streams;+ const info = JSON.parse(execFileSync(decoderPath("ffprobe"), ["-v", "error", "-f", "flac", "-i", "pipe:0", "-count_frames", "-show_streams", "-of", "json"], { input: bytes, encoding: "utf8", maxBuffer: 1 << 20 })).streams;if (info.length !== 1 || info[0].codec_name !== "flac" || Number(info[0].sample_rate) !== 48000 || Number(info[0].bits_per_raw_sample) !== 24 || info[0].channels !== zone.channels || ![1, 2].includes(zone.channels)) throw new Error(`${id}: expected 48 kHz 24-bit FLAC with ${zone.channels} channels: ${zone.file}`);- const pcm = execFileSync("ffmpeg", ["-v", "error", "-f", "flac", "-i", "pipe:0", "-vn", "-f", "f32le", "-acodec", "pcm_f32le", "-ar", "48000", "pipe:1"], { input: bytes, maxBuffer: 1 << 28 });+ const pcm = execFileSync(decoderPath("ffmpeg"), ["-v", "error", "-f", "flac", "-i", "pipe:0", "-vn", "-f", "f32le", "-acodec", "pcm_f32le", "-ar", "48000", "pipe:1"], { input: bytes, maxBuffer: 1 << 28 });if (!Number.isInteger(zone.frames) || zone.frames < 1 || pcm.length !== zone.frames * zone.channels * 4) throw new Error(`${id}: frame count mismatch: ${zone.file}`);const channels = Array.from({ length: zone.channels }, () => new Float32Array(zone.frames));for (let i = 0; i < zone.frames; i++) for (let c = 0; c < zone.channels; c++) { const v = pcm.readFloatLE((i * zone.channels + c) * 4); if (!Number.isFinite(v)) throw new Error(`${id}: non-finite PCM: ${zone.file}`); channels[c][i] = v; }