|
| 1 | +import { strict as assert } from "node:assert"; |
| 2 | +import { test } from "node:test"; |
| 3 | +import { existsSync } from "node:fs"; |
| 4 | +import { join, dirname } from "node:path"; |
| 5 | +import { fileURLToPath } from "node:url"; |
| 6 | +import { listTypes, getProviders } from "./registry.mjs"; |
| 7 | +import { CAPABILITIES, listModels } from "./local-models.mjs"; |
| 8 | + |
| 9 | +// Capstone: media-use must actually OWN each hyperframes media weakness. This |
| 10 | +// test enforces the weakness→owner matrix in SKILL.md so a claim can't rot — if |
| 11 | +// a capability's entrypoint disappears, this fails. |
| 12 | + |
| 13 | +const SKILL = join(dirname(fileURLToPath(import.meta.url)), "..", ".."); |
| 14 | + |
| 15 | +test("weakness: audio-only → media-use resolves image + icon", () => { |
| 16 | + for (const t of ["image", "icon"]) { |
| 17 | + assert.ok(getProviders(t).length > 0, `no provider for ${t}`); |
| 18 | + } |
| 19 | +}); |
| 20 | + |
| 21 | +test("weakness: no voice/audio gen → media-use exposes voice + the audio engine", () => { |
| 22 | + assert.ok(listTypes().includes("voice"), "voice type missing"); |
| 23 | + assert.ok(getProviders("voice").length > 0, "no enabled voice provider (Bin approved)"); |
| 24 | + assert.ok(existsSync(join(SKILL, "audio", "scripts", "audio.mjs")), "audio engine missing"); |
| 25 | +}); |
| 26 | + |
| 27 | +test("weakness: scattered audio engine → consolidated under media-use (hyperframes-media gone)", () => { |
| 28 | + assert.ok(existsSync(join(SKILL, "audio", "scripts", "lib", "tts.mjs")), "tts engine missing"); |
| 29 | + assert.ok( |
| 30 | + existsSync(join(SKILL, "audio", "assets", "sfx", "manifest.json")), |
| 31 | + "bundled SFX missing", |
| 32 | + ); |
| 33 | +}); |
| 34 | + |
| 35 | +test("weakness: no media-ops → ops guidance reference exists", () => { |
| 36 | + assert.ok(existsSync(join(SKILL, "references", "operations.md")), "operations.md missing"); |
| 37 | +}); |
| 38 | + |
| 39 | +test("weakness: no transcript-driven cutting → cut compiler entrypoints exist", async () => { |
| 40 | + assert.ok(existsSync(join(SKILL, "scripts", "transcript-cut.mjs")), "transcript-cut missing"); |
| 41 | + assert.ok(existsSync(join(SKILL, "scripts", "lib", "cutlist.mjs")), "cutlist lib missing"); |
| 42 | + const cutlist = await import("./cutlist.mjs"); |
| 43 | + assert.equal(typeof cutlist.compileCutList, "function"); |
| 44 | +}); |
| 45 | + |
| 46 | +test("weakness: whisper.cpp is weak → better local ASR (Parakeet) entrypoint exists", async () => { |
| 47 | + assert.ok(existsSync(join(SKILL, "scripts", "transcribe.mjs")), "transcribe.mjs missing"); |
| 48 | + const pw = await import("./parakeet-words.mjs"); |
| 49 | + assert.equal(typeof pw.mergeTokensToWords, "function", "token->word merge missing"); |
| 50 | + const lm = await import("./local-models.mjs"); |
| 51 | + const asr = lm.listModels("asr"); |
| 52 | + const parakeet = asr.find((m) => m.id === "parakeet-mlx"); |
| 53 | + assert.ok(parakeet && parakeet.rank === 0, "Parakeet must be the rank-0 preferred ASR"); |
| 54 | +}); |
| 55 | + |
| 56 | +test("weakness: no auto-duck/loudness → duck compiler and recipes exist", async () => { |
| 57 | + assert.ok(existsSync(join(SKILL, "scripts", "audio-duck.mjs")), "audio-duck missing"); |
| 58 | + assert.ok(existsSync(join(SKILL, "scripts", "lib", "duck.mjs")), "duck lib missing"); |
| 59 | + assert.ok(existsSync(join(SKILL, "references", "operations.md")), "operations.md missing"); |
| 60 | + const duck = await import("./duck.mjs"); |
| 61 | + assert.equal(typeof duck.speechSpans, "function"); |
| 62 | + assert.equal(typeof duck.duckKeyframes, "function"); |
| 63 | +}); |
| 64 | + |
| 65 | +test("weakness: no cross-project memory → global cache + ingest entrypoints exist", async () => { |
| 66 | + const cache = await import("./cache.mjs"); |
| 67 | + assert.equal(typeof cache.cachePut, "function"); |
| 68 | + assert.equal(typeof cache.promote, "function"); |
| 69 | + assert.equal(typeof cache.globalMediaDir, "function"); |
| 70 | + const freeze = await import("./freeze.mjs"); |
| 71 | + assert.equal(typeof freeze.isDirectMediaUrl, "function", "ingest URL guard missing"); |
| 72 | +}); |
| 73 | + |
| 74 | +// Wenbo (06-29): heygen free-usage is the default; local models are the opt-out |
| 75 | +// fallback ("if user no, then local"). We still assert the fallback table is |
| 76 | +// populated so the opt-out path stays real. |
| 77 | +test("weakness: weak local defaults → local models exist as the opt-out fallback (tts/asr/upscale)", () => { |
| 78 | + for (const cap of ["tts", "asr", "upscale"]) { |
| 79 | + assert.ok(CAPABILITIES.includes(cap), `capability ${cap} missing`); |
| 80 | + assert.ok(listModels(cap).length > 0, `no local models for ${cap}`); |
| 81 | + } |
| 82 | +}); |
| 83 | + |
| 84 | +test("weakness: no image generation → local mflux (RAM-graded) + codex upsell", async () => { |
| 85 | + const ps = getProviders("image"); |
| 86 | + assert.ok( |
| 87 | + ps.some((p) => p.name === "mflux.local" && typeof p.generate === "function"), |
| 88 | + "local image gen missing", |
| 89 | + ); |
| 90 | + assert.ok( |
| 91 | + ps.some((p) => p.name === "codex.image_gen" && typeof p.generate === "function"), |
| 92 | + "codex image upsell missing", |
| 93 | + ); |
| 94 | + const lm = await import("./local-models.mjs"); |
| 95 | + assert.ok(lm.CAPABILITIES.includes("imagegen"), "imagegen capability missing"); |
| 96 | + assert.ok(lm.listModels("imagegen").length >= 3, "imagegen RAM ladder too small"); |
| 97 | + assert.equal(typeof lm.describeModelLadder, "function", "agent-facing ladder missing"); |
| 98 | +}); |
| 99 | + |
| 100 | +test("weakness: no video generation → local videogen ladder + heygen avatar upsell", async () => { |
| 101 | + const lm = await import("./local-models.mjs"); |
| 102 | + assert.ok(lm.CAPABILITIES.includes("videogen"), "videogen capability missing"); |
| 103 | + assert.ok(lm.listModels("videogen").length >= 2, "videogen ladder too small"); |
| 104 | + const ops = existsSync(join(SKILL, "references", "operations.md")); |
| 105 | + assert.ok(ops, "operations.md (avatar-upsell recipe) missing"); |
| 106 | +}); |
| 107 | + |
| 108 | +test("every resolve type has at least one enabled provider", () => { |
| 109 | + for (const t of listTypes()) { |
| 110 | + assert.ok(getProviders(t).length > 0, `type ${t} has no enabled provider`); |
| 111 | + } |
| 112 | +}); |
0 commit comments