Skip to content

Write HTML. Render video. Built for agents.

fix(cli): init writes the project into a folder with a non-ASCII name on Windows (#5833)

Miguel Ángeld58d3edd39b0
diff --git a/packages/cli/src/commands/init.nonAsciiPath.test.ts b/packages/cli/src/commands/init.nonAsciiPath.test.ts
new file mode 100644
index 0000000000..86ca10ec0f
--- /dev/null
+++ b/packages/cli/src/commands/init.nonAsciiPath.test.ts
@@ -0,0 +1,28 @@
+import { afterEach, expect, it, vi } from "vitest";
+import { existsSync, mkdtempSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { runCommand } from "citty";
+import init from "./init.js";
+
+vi.mock("../telemetry/events.js", () => ({ trackInitTemplate: vi.fn() }));
+
+afterEach(() => {
+ vi.restoreAllMocks();
+ vi.unstubAllEnvs();
+});
+
+// Node 22's native directory copy wrote nothing to such a path on Windows, without an error.
+it("scaffolds the template into a folder with a Cyrillic name", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "hf-init-cyrillic-"));
+ const project = join(dir, "Проект");
+ vi.stubEnv("HYPERFRAMES_SKIP_SKILLS", "1");
+ vi.spyOn(console, "log").mockImplementation(() => {});
+ try {
+ await runCommand(init, { rawArgs: [project, "--example", "blank", "--non-interactive"] });
+ expect(existsSync(join(project, "index.html"))).toBe(true);
+ expect(existsSync(join(project, "hyperframes.json"))).toBe(true);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index b3bf347f1b..e7fb6440f7 100644
--- a/packages/cli/src/commands/init.ts
+++ b/packages/cli/src/commands/init.ts
@@ -27,11 +27,11 @@ import {
existsSync,
mkdirSync,
copyFileSync,
- cpSync,
writeFileSync,
readFileSync,
readdirSync,
} from "node:fs";
+import { copyDirSync } from "../utils/copyDir.js";
import { resolve, basename, join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { execFileSync, spawn } from "node:child_process";
@@ -575,7 +575,7 @@ async function scaffoldProject(
// build toolchain should not prevent the remote fetch fallback.
const templateDir = getStaticTemplateDir(templateId);
if (existsSync(join(templateDir, "index.html"))) {
- cpSync(templateDir, destDir, { recursive: true });
+ copyDirSync(templateDir, destDir);
} else {
await fetchRemoteTemplate(templateId, destDir);
}
diff --git a/packages/cli/src/media-use/lib/recipe-store.mjs b/packages/cli/src/media-use/lib/recipe-store.mjs
index 2b710e049e..131f29d7c0 100644
--- a/packages/cli/src/media-use/lib/recipe-store.mjs
+++ b/packages/cli/src/media-use/lib/recipe-store.mjs
@@ -14,6 +14,9 @@ import { appendRecord, mediaDir, nextId } from "./manifest.mjs";
import { regenerateIndex } from "./index-gen.mjs";
import { mergedPreferences } from "./prefs-store.mjs";
+// A filter keeps Node 22 off its native copy, which writes nothing under a non-ASCII path on Windows.
+const NON_ASCII_SAFE_DIR_COPY = { recursive: true, force: true, filter: () => true };
+
/**
* Recipes — the heavyweight tier of HyperFrames user memory.
*
@@ -279,7 +282,7 @@ export function freezeRecipe({ projectDir, name, workflow, blocks }) {
try {
const userDir = join(userRecipesDir(), slug);
mkdirSync(userDir, { recursive: true });
- cpSync(dir, userDir, { recursive: true, force: true });
+ cpSync(dir, userDir, NON_ASCII_SAFE_DIR_COPY);
} catch {
// The project-tier freeze already landed.
}
@@ -339,7 +342,7 @@ export function useRecipe({ projectDir, name }) {
);
}
mkdirSync(dir, { recursive: true });
- cpSync(userDir, dir, { recursive: true, force: true });
+ cpSync(userDir, dir, NON_ASCII_SAFE_DIR_COPY);
const imported = readRecipeJson(dir);
appendRecord(root, {
id: nextId(root, "recipe"),
diff --git a/packages/cli/src/utils/copyDir.ts b/packages/cli/src/utils/copyDir.ts
new file mode 100644
index 0000000000..47f890e4e8
--- /dev/null
+++ b/packages/cli/src/utils/copyDir.ts
@@ -0,0 +1,10 @@
+import { cpSync, type CopySyncOptions } from "node:fs";
+
+export function copyDirSync(
+ src: string,
+ dest: string,
+ options: Omit<CopySyncOptions, "recursive" | "filter"> = {},
+): void {
+ // Any filter keeps Node 22 off its native copy, which writes nothing under a non-ASCII path on Windows.
+ cpSync(src, dest, { ...options, recursive: true, filter: () => true });
+}
diff --git a/packages/cli/src/utils/skillsMirror.ts b/packages/cli/src/utils/skillsMirror.ts
index ba32db2c9a..74e06ea414 100644
--- a/packages/cli/src/utils/skillsMirror.ts
+++ b/packages/cli/src/utils/skillsMirror.ts
@@ -23,7 +23,6 @@
// those set mirrors into the exact dir the agent reads.
import {
- cpSync,
existsSync,
lstatSync,
mkdirSync,
@@ -34,6 +33,7 @@ import {
symlinkSync,
unlinkSync,
} from "node:fs";
+import { copyDirSync } from "./copyDir.js";
import { homedir } from "node:os";
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
import { AGENT_GLOBAL_DIRS, type AgentDirBase } from "./agentDirs.generated.js";
@@ -195,7 +195,7 @@ function linkOrCopy(
if (unsafe) return unsafe;
rmSync(targetSkill, { recursive: true, force: true });
if (platform === "win32") {
- cpSync(sourceSkill, targetSkill, { recursive: true });
+ copyDirSync(sourceSkill, targetSkill);
} else {
symlinkSync(relative(dirname(targetSkill), sourceSkill), targetSkill);
}
diff --git a/skills-manifest.json b/skills-manifest.json
index 07a59ad5e5..fe32020a25 100644
--- a/skills-manifest.json
+++ b/skills-manifest.json
@@ -54,7 +54,7 @@
"files": 1
},
"media-use": {
- "hash": "2816313a2f72e636",
+ "hash": "1a2c3f1c16ab3ef7",
"files": 113
},
"motion-graphics": {
diff --git a/skills/media-use/scripts/lib/recipe-store.mjs b/skills/media-use/scripts/lib/recipe-store.mjs
index 2b710e049e..131f29d7c0 100644
--- a/skills/media-use/scripts/lib/recipe-store.mjs
+++ b/skills/media-use/scripts/lib/recipe-store.mjs
@@ -14,6 +14,9 @@ import { appendRecord, mediaDir, nextId } from "./manifest.mjs";
import { regenerateIndex } from "./index-gen.mjs";
import { mergedPreferences } from "./prefs-store.mjs";
+// A filter keeps Node 22 off its native copy, which writes nothing under a non-ASCII path on Windows.
+const NON_ASCII_SAFE_DIR_COPY = { recursive: true, force: true, filter: () => true };
+
/**
* Recipes — the heavyweight tier of HyperFrames user memory.
*
@@ -279,7 +282,7 @@ export function freezeRecipe({ projectDir, name, workflow, blocks }) {
try {
const userDir = join(userRecipesDir(), slug);
mkdirSync(userDir, { recursive: true });
- cpSync(dir, userDir, { recursive: true, force: true });
+ cpSync(dir, userDir, NON_ASCII_SAFE_DIR_COPY);
} catch {
// The project-tier freeze already landed.
}
@@ -339,7 +342,7 @@ export function useRecipe({ projectDir, name }) {
);
}
mkdirSync(dir, { recursive: true });
- cpSync(userDir, dir, { recursive: true, force: true });
+ cpSync(userDir, dir, NON_ASCII_SAFE_DIR_COPY);
const imported = readRecipeJson(dir);
appendRecord(root, {
id: nextId(root, "recipe"),