Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix: load project-local packages in the preview, and check it before delivery
rponeb341addbda29
diff --git a/.agents/skills/hypit/references/reference-video/final-sources.md b/.agents/skills/hypit/references/reference-video/final-sources.mdindex fd705b26..763f1b36 100644--- a/.agents/skills/hypit/references/reference-video/final-sources.md+++ b/.agents/skills/hypit/references/reference-video/final-sources.md@@ -35,6 +35,19 @@ pnpm hypit check path/to/studio.svspnpm hypit check path/to/build.svrun```+`hypit check` proves a Source is legal; it proves nothing about whether the tracks it declares can+actually be built. A track that fails the local preview fails the same way the moment the author+opens the Playground — a new package with a bad schedule, a media edge whose artifact is not an+image, a reference that does not resolve. Find that now, not on the author's screen:++```bash+node --import tsx .agents/skills/hypit/scripts/preview-check.mjs path/to/main.svml path/to/build.svrun+```++It reports every track that failed to build, and every track waiting on a Provider it cannot reach,+and exits non-zero when either exists. Repair until it passes or until what remains is waiting on a+capability the machine genuinely lacks — recorded as an accepted deviation, not left silent.+Fix package resolution and package implementation before repairing source use. Continue until allthree files are accepted. Do not create `check_svml_project` or another wrapper.diff --git a/.agents/skills/hypit/scripts/preview-check.mjs b/.agents/skills/hypit/scripts/preview-check.mjsnew file mode 100644index 00000000..a0b84917--- /dev/null+++ b/.agents/skills/hypit/scripts/preview-check.mjs@@ -0,0 +1,47 @@+#!/usr/bin/env node+/**+ * Preview-check a reconstruction before it is delivered.+ *+ * `pnpm hypit check` proves a Source is legal; it proves nothing about whether+ * the tracks it declares can actually be built by the local preview. A track+ * that fails here fails the same way when the author opens the playground, so+ * find out now.+ *+ * Usage: node --import tsx .agents/skills/hypit/scripts/preview-check.mjs <main.svml> [<build.svrun>]+ * Exit: 0 when every track built and nothing is waiting on an error.+ * 1 otherwise, listing the failing tracks and their errors.+ */+import { fileURLToPath } from "node:url";+// The script lives under `.agents/`; resolve the playground's preview pipeline from the repo root.+const repoRoot = fileURLToPath(new URL("../../../../", import.meta.url));+const { preview } = await import(`${repoRoot}packages/svml-playground/src/pipeline/preview.js`);++const source = process.argv[2];+if (source === undefined) {+ console.error("usage: preview-check.mjs <main.svml> [<build.svrun>]");+ process.exit(2);+}+const run = process.argv[3];++const built = await preview(source, run, undefined);+const problems = [];+for (const track of built.tracks ?? []) {+ const errors = track.errors ?? [];+ if (errors.length > 0) problems.push({ track: track.name, errors });+ else if ((track.waiting ?? []).length > 0) {+ // A track waiting on a capability is normal when a Provider is absent; it+ // is only a problem when it waits on an actual error rather than a Provider.+ const fatal = track.waiting.filter((w) => !/Provider|credential|capability/iu.test(String(w)));+ if (fatal.length > 0) problems.push({ track: track.name, waiting: fatal });+ }+}+const refused = (built.refused ?? []).map((r) => ({ refused: r }));+const unserved = (built.unserved ?? []).length > 0 ? { unserved: built.unserved } : undefined;++const all = [...problems, ...refused, ...(unserved === undefined ? [] : [unserved])];+if (all.length === 0) {+ console.log("preview-check: every track built.");+ process.exit(0);+}+for (const item of all) console.log(JSON.stringify(item, null, 2));+process.exit(1);diff --git a/examples/reference-reconstruction/packages/local-linerank/src/schedule.ts b/examples/reference-reconstruction/packages/local-linerank/src/schedule.tsindex 3283e06e..f1fd8cbc 100644--- a/examples/reference-reconstruction/packages/local-linerank/src/schedule.ts+++ b/examples/reference-reconstruction/packages/local-linerank/src/schedule.ts@@ -214,8 +214,11 @@ export function assertLinerankSchedule(value: LinerankSchedule, space?: ProgramS`LinerankSchedule.windows.${index} overlaps the previous one.`);}const lastWindow = value.windows.at(-1)!;- assert(value.terminalFrame >= lastWindow.startFrame && value.terminalFrame < lastWindow.endFrameExclusive,- "LinerankSchedule.terminalFrame is outside the final window.");+ // A `done` moment may sit at the very end of the board's last window — the reference marks the+ // list complete exactly as it finishes — so the terminal frame may coincide with the exclusive+ // end. The circle renderer clamps to the window, so this is safe.+ assert(value.terminalFrame >= lastWindow.startFrame && value.terminalFrame <= lastWindow.endFrameExclusive,+ `LinerankSchedule.terminalFrame ${value.terminalFrame} is outside the final window [${lastWindow.startFrame}, ${lastWindow.endFrameExclusive}].`);for (const [index, entry] of value.entries.entries()) {identity(entry.itemId, `LinerankSchedule.entries.${index}.itemId`);assert(!ids.has(entry.itemId), `LinerankSchedule repeats ${entry.itemId}.`);diff --git a/packages/svml-playground/src/official-video.ts b/packages/svml-playground/src/official-video.tsindex e64880a2..b1e63894 100644--- a/packages/svml-playground/src/official-video.ts+++ b/packages/svml-playground/src/official-video.ts@@ -72,7 +72,11 @@ let projectPackages: readonly string[] = [];let projectRoot: string | undefined;export function usePreviewPackages(packages: readonly string[], root: string): void {- if (loading !== undefined) throw new Error("Preview packages must be chosen before the first Source is compiled.");+ // The domain is built once, and the packages a Source imports are stable across its edits. Once+ // the domain is loading (or loaded), a later reading of the same Source must not re-specify them:+ // the first call wins, and later ones are ignored rather than throwing, because a watcher-driven+ // re-read is the normal path rather than an error.+ if (loading !== undefined) return;projectPackages = packages;projectRoot = root;}diff --git a/packages/svml-playground/src/pipeline/preview.ts b/packages/svml-playground/src/pipeline/preview.tsindex 813c1652..b1e92700 100644--- a/packages/svml-playground/src/pipeline/preview.ts+++ b/packages/svml-playground/src/pipeline/preview.ts@@ -8,10 +8,12 @@* them.*/import { createHash } from "node:crypto";+import { readFileSync } from "node:fs";+import { dirname } from "node:path";import { createProvidedCandidate } from "@hypit/run";-import { officialVideoDomain } from "../official-video.js";+import { importedPackages, officialVideoDomain, usePreviewPackages } from "../official-video.js";import { compileSource } from "./compile.js";import type { CompiledSource, ServedFile } from "./compile.js";import type { Placement } from "./observe.js";@@ -124,6 +126,11 @@ export async function preview(runPath?: string,archive?: Archive,): Promise<Preview> {+ // A Source may import a project-local package this application has never heard of; feed what it+ // names to the domain loader before the first compile, so `@hypit/local-*` resolves from the+ // project instead of being reported as uninstalled. (The session already does this, but preview+ // is also reached directly, and the domain is built once per process.)+ usePreviewPackages([...new Set(importedPackages(readFileSync(entryPath, "utf8")))], dirname(entryPath));const domain = await officialVideoDomain();const source = await compileSource(entryPath);diff --git a/packages/svml-playground/src/pipeline/session.ts b/packages/svml-playground/src/pipeline/session.tsindex dde45687..94cdfe79 100644--- a/packages/svml-playground/src/pipeline/session.ts+++ b/packages/svml-playground/src/pipeline/session.ts@@ -38,7 +38,7 @@ export async function readSource(input: {}async function read(- input: { readonly source: string; readonly run?: string; readonly revision: number },+ input: { readonly source: string; readonly run?: string; readonly revision: number; readonly packageRoot: string },archive: Archive | undefined,): Promise<Session> {const built = await preview(input.source, input.run, archive);