import { PrismaClient } from "@prisma/client";
import bcrypt from "bcryptjs";

const DEFAULT_SYSTEM_PROMPT =
  "You are a helpful, harmless, and honest AI assistant. You give thoughtful, accurate, and nuanced answers. When uncertain, you say so clearly rather than guessing. You write in clear, natural prose without unnecessary hedging or filler. For technical questions, you provide complete working examples. For complex topics, you break things down step by step. You match the user's language and tone. You don't moralize or add warnings unless genuinely relevant. You think carefully before answering difficult questions.";

const prisma = new PrismaClient();

async function main() {
  const existing = await prisma.user.findUnique({ where: { username: "admin" } });
  if (existing) {
    console.log("Admin user already exists, skipping seed.");
    return;
  }

  const passwordHash = await bcrypt.hash("Floppa.100", 12);
  await prisma.user.create({
    data: {
      username: "admin",
      passwordHash,
      role: "admin",
      defaultSystemPrompt: DEFAULT_SYSTEM_PROMPT,
    },
  });
  console.log("Seeded admin user (username: admin, password: Floppa.100)");
}

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
