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
merge: integrate origin main and keep Result replacement writes alive
kashorinc6cea518c992
diff --cc packages/build-result/src/store.tsindex aa195007,bcda029f..574a5c8c--- a/packages/build-result/src/store.ts+++ b/packages/build-result/src/store.ts@@@ -90,6 -90,30 +90,29 @@@ async function exists(path: string): Prreturn await stat(path).then((item) => item.isFile(), () => false);}+ /**- * Replace `to` with `from`, waiting out a reader.++ * Replace `to` with `from`, allowing brief filesystem contention to clear.+ *- * POSIX replaces atomically whatever else has the destination open. Windows resolves a replacing- * rename through `MoveFileEx`, which refuses with EPERM while any handle holds the destination, and- * reading a Build Result while its Build is still running is an ordinary thing to do: one `hypit- * inspect`, one Studio window or one poll landing inside the write is enough. The Build then carried- * a `complete` decision whose manifest was never written.++ * Windows CI observed EPERM when publishing result.json after execution completed. Sharing modes++ * and filesystem filters can temporarily prevent replacement; an open reader alone does not prove++ * the cause. Retry the same rename briefly, keeping the old file intact until replacement succeeds.++ * Persistent permission or sharing errors still fail this write with the original filesystem error.+ */+ async function replaceFile(from: string, to: string): Promise<void> {+ const deadline = Date.now() + 2_000;+ while (true) {+ try {+ await rename(from, to);+ return;+ } catch (error) {+ const code = error instanceof Error && "code" in error ? error.code : undefined;+ const contended = code === "EPERM" || code === "EACCES" || code === "EBUSY";+ if (!contended || Date.now() >= deadline) throw error;- await new Promise((settle) => { setTimeout(settle, 20).unref(); });++ await new Promise((settle) => { setTimeout(settle, 20); });+ }+ }+ }+async function writeJsonAtomic(path: string, value: unknown): Promise<void> {await mkdir(dirname(path), { recursive: true });const temporary = `${path}.part-${randomUUID()}`;diff --cc packages/build-result/test/result.test.tsindex e3302492,e3302492..248ae1b9--- a/packages/build-result/test/result.test.ts+++ b/packages/build-result/test/result.test.ts@@@ -1,8 -1,8 +1,10 @@@import assert from "node:assert/strict";++import { execFile } from "node:child_process";import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";import { join } from "node:path";import test from "node:test";++import { promisify } from "node:util";import { buildResultDirectory, FileBuildResult, FileBuildResultRepository } from "@hypit/build-result";import type { BlobRef, BuildState, TypeRef } from "@hypit/protocol";@@@ -16,6 -16,6 +18,39 @@@ const takeType: TypeRef =name: "SemanticTake",};++test("a short-lived writer stays alive through a transient file replacement failure", async () => {++ const root = await mkdtemp(join(tmpdir(), "hypit-result-replace-"));++ try {++ const script = `++ import fs from 'node:fs/promises';++ import { syncBuiltinESMExports } from 'node:module';++ const rename = fs.rename;++ let contended = false;++ fs.rename = async (from, to) => {++ if (!contended && String(to).endsWith('result.json')) {++ contended = true;++ throw Object.assign(new Error('temporary file contention'), { code: 'EBUSY' });++ }++ return rename(from, to);++ };++ syncBuiltinESMExports();++ const { FileBuildResult } = await import(${JSON.stringify(new URL("../src/store.ts", import.meta.url).href)});++ await FileBuildResult.create(process.argv[1], {++ id: 'bld_20260902T100000000Z_0000000001',++ source: { path: '/project/main.svml' }, targets: [], publishedOutputs: [],++ });++ if (!contended) throw new Error('replacement was not exercised');++ process.stdout.write('result saved');++ `;++ const { stdout } = await promisify(execFile)(process.execPath,++ ["--import", "tsx", "--input-type=module", "-e", script, root]);++ assert.equal(stdout, "result saved");++ assert.ok((await new FileBuildResultRepository(root).read("bld_20260902T100000000Z_0000000001")) !== undefined);++ } finally {++ await rm(root, { recursive: true, force: true });++ }++});++function state(input: {readonly status?: BuildState["status"];readonly records: BuildState["records"];