From 6f164018493b0a4c31f16085a0ef6502cdeb7bef Mon Sep 17 00:00:00 2001 From: mawkone Date: Wed, 3 Jun 2026 15:48:25 -0700 Subject: [PATCH] feat(frontend): automatically trigger prisma generate on schema.prisma write --- vibn-frontend/app/api/mcp/route.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vibn-frontend/app/api/mcp/route.ts b/vibn-frontend/app/api/mcp/route.ts index 559b941..1d269a3 100644 --- a/vibn-frontend/app/api/mcp/route.ts +++ b/vibn-frontend/app/api/mcp/route.ts @@ -4974,6 +4974,20 @@ async function toolFsWrite(principal: Principal, params: Record) { const { createHash } = require("crypto"); const bytes = Buffer.byteLength(content, "utf8"); const sha256 = createHash("sha256").update(content, "utf8").digest("hex"); + + // If we are writing to schema.prisma, automatically generate Prisma Client + if (path.endsWith("schema.prisma")) { + const prismaDir = path.replace(/\/prisma\/schema\.prisma$/, ""); + console.log( + `[Prisma Hook] Automatically generating prisma client in ${prismaDir}...`, + ); + runFsCmd( + principal, + project, + `cd ${shq(prismaDir)} && npx prisma generate`, + ).catch(() => {}); + } + return NextResponse.json({ result: { ok: true, path, bytes, sha256 }, });