Initial commit

This commit is contained in:
2026-07-10 08:31:27 +08:00
commit 2b74c30d36
134 changed files with 21801 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { mkdirSync } from "node:fs";
import os from "node:os";
import path from "node:path";
/** 本地用户数据目录(不进 git、不同步 */
export function getUserDataDir(): string {
if (process.env.WRITING_AGENT_DATA_DIR) {
return path.resolve(process.env.WRITING_AGENT_DATA_DIR);
}
return path.join(os.homedir(), ".writing-agent");
}
export function getPresetsDir(): string {
return path.join(getUserDataDir(), "presets");
}
export function getBooksDir(): string {
return path.join(getUserDataDir(), "books");
}
export function ensureUserDataDirs(): void {
mkdirSync(getPresetsDir(), { recursive: true });
mkdirSync(getBooksDir(), { recursive: true });
mkdirSync(path.join(getUserDataDir(), "stats"), { recursive: true });
}