// 从本仓库存的预设包里把原始酒馆 JSON 抠出来,两边用同一个文件。 // 用法: node extract-preset.mjs [预设包路径] [输出名] import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; import os from "node:os"; import path from "node:path"; import { fileURLToPath } from "node:url"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const input = process.argv[2] ?? path.join(os.homedir(), ".writing-agent", "presets", "linux_1-3-9c636433.json"); const name = process.argv[3] ?? "linux_1-3"; const pkg = JSON.parse(readFileSync(input, "utf8")); const raw = pkg.raw ?? pkg; if (!raw.prompts || !raw.prompt_order) { throw new Error("这份预设里没有 prompts / prompt_order,不是酒馆格式"); } raw.name = name; const outDir = path.join(HERE, "presets"); mkdirSync(outDir, { recursive: true }); const file = path.join(outDir, name + ".json"); writeFileSync(file, JSON.stringify(raw, null, 2), "utf8"); console.log("写出 " + file + " (prompts=" + raw.prompts.length + ", prompt_order=" + raw.prompt_order.length + ")");