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(build-result): terminate Windows rename paths correctly
kashorin2fc3f134f04d
diff --git a/packages/build-result/src/replace-file-windows.ts b/packages/build-result/src/replace-file-windows.tsindex 1e64fc53..4c07b138 100644--- a/packages/build-result/src/replace-file-windows.ts+++ b/packages/build-result/src/replace-file-windows.ts@@ -37,7 +37,10 @@ function failure(syscall: string, from: string, to: string): Error {export function replaceWindowsFile(from: string, to: string): void {const filename = Buffer.from(toNamespacedPath(to), "utf16le");const nameOffset = koffi.offsetof(renameInfo, "FileName");- const info = Buffer.alloc(Math.max(koffi.sizeof(renameInfo), nameOffset + filename.length));+ // Win32 requires a NUL-terminated FileName even though FileNameLength excludes+ // that terminator. Buffer.alloc leaves the final WCHAR zero-initialized.+ // https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_rename_info+ const info = Buffer.alloc(Math.max(koffi.sizeof(renameInfo), nameOffset + filename.length + 2));info.writeUInt32LE(REPLACE_IF_EXISTS | POSIX_SEMANTICS, koffi.offsetof(renameInfo, "Flags"));info.writeUInt32LE(filename.length, koffi.offsetof(renameInfo, "FileNameLength"));filename.copy(info, nameOffset);diff --git a/packages/build-result/test/replace-file.test.ts b/packages/build-result/test/replace-file.test.tsnew file mode 100644index 00000000..93b00c51--- /dev/null+++ b/packages/build-result/test/replace-file.test.ts@@ -0,0 +1,33 @@+import assert from "node:assert/strict";+import { mkdtemp, open, readFile, readdir, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";++import { replaceFile } from "../src/replace-file.js";++test("file replacement publishes the exact destination name and preserves an open reader", async () => {+ const directory = await mkdtemp(join(tmpdir(), "hypit-replace-"));+ try {+ for (const name of ["result.json", ".writer.json", "素材 🎬.json"]) {+ const destination = join(directory, name);+ const temporary = join(directory, `${name}.part`);+ await writeFile(temporary, "first");+ await replaceFile(temporary, destination);+ assert.deepEqual(await readdir(directory), [name]);+ const reader = await open(destination, "r");+ try {+ await writeFile(temporary, "second");+ await replaceFile(temporary, destination);+ assert.equal(await readFile(destination, "utf8"), "second");+ assert.equal(await reader.readFile("utf8"), "first");+ assert.deepEqual(await readdir(directory), [name]);+ } finally {+ await reader.close();+ }+ await rm(destination);+ }+ } finally {+ await rm(directory, { recursive: true, force: true });+ }+});diff --git a/packages/runtime-local/test/local.test.ts b/packages/runtime-local/test/local.test.tsindex a567a8af..48af1da0 100644--- a/packages/runtime-local/test/local.test.ts+++ b/packages/runtime-local/test/local.test.ts@@ -281,8 +281,9 @@ test("project local Runtime advances, polls and cancels work with replaceable pa}],});+ let firstRuntime: Awaited<ReturnType<typeof createLocalRuntime>> | undefined;try {- const firstRuntime = await createLocalRuntime({+ firstRuntime = await createLocalRuntime({...projectRuntimeFixture(directory),components: [components],endpoints: [endpointPackage],@@ -339,8 +340,8 @@ test("project local Runtime advances, polls and cancels work with replaceable paconst cancelled = await finishClaimedBuild(firstRuntime);assert.equal(cancelled.outcome, "cancelled");assert.equal(cancels, 1);- await firstRuntime.close();} finally {+ await firstRuntime?.close();await rm(directory, { recursive: true, force: true });}});@@ -645,8 +646,9 @@ test("an immediate Command left in started state fails its Build without invokin},}],};+ let runtime: Awaited<ReturnType<typeof createLocalRuntime>> | undefined;try {- const runtime = await createLocalRuntime({+ runtime = await createLocalRuntime({...projectRuntimeFixture(directory),components: [components],});@@ -664,8 +666,8 @@ test("an immediate Command left in started state fails its Build without invokin.read("bld_20260902T120000008Z_0000000001");assert.equal(failed?.outcome, "failed");assert.match(failed?.failure ?? "", /stopped before its result was stored/u);- await runtime.close();} finally {+ await runtime?.close();await rm(directory, { recursive: true, force: true });}});