SPB Git

Repository Public

tpl-generate.mts 803 B 10 lines typescript

1// Génère un modèle par l'API d'Anthropic et l'écrit en JSON (importable par `cli template-import`).2// Usage : ANTHROPIC_API_KEY=… tsx scripts/dev/tpl-generate.mts <brief.json> <sortie.json>3import fs from "node:fs"4import { generateTemplate } from "../../server/src/templates-ai.js"5const [input, output] = process.argv.slice(2)6const brief = JSON.parse(fs.readFileSync(input, "utf8"))7const { template, usage } = await generateTemplate(brief)8fs.writeFileSync(output, JSON.stringify({ ...template, brand: brief.brand ?? {}, ai_model: usage.model }, null, 1))9console.log(JSON.stringify({ name: template.name, subject: template.subject, variables: template.variables.map((v) => `${v.name}${v.required ? "*" : ""}`), kb: +(template.html.length / 1024).toFixed(1), tokens: usage.output_tokens }))10
Files main
Menu

Theme