From 20abd7f11d629647fb5b02910b1af29e8494e17c Mon Sep 17 00:00:00 2001 From: Harshit Gupta <153393197+Ashusf90@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:39:21 +0530 Subject: [PATCH 1/2] Update route.ts --- src/app/api/generate/route.ts | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/app/api/generate/route.ts b/src/app/api/generate/route.ts index 8eaaeee..760b57b 100644 --- a/src/app/api/generate/route.ts +++ b/src/app/api/generate/route.ts @@ -4,7 +4,47 @@ import { getRepoData, getRepoContents } from "@/lib/octokit"; import { SUPPORTED_LANGUAGES } from "@/constants/languages"; export const dynamic = "force-dynamic"; +// STEP 1: Generate structure +async function generateStructure(repoData: any) { + const prompt = ` + Create a list of README sections for this repository. + Return ONLY array of section names. + + Repo: + ${JSON.stringify(repoData)} + `; + + const res = await callAI(prompt); + return JSON.parse(res); // ["Introduction", "Features", ...] +} + + +// STEP 2: Generate each section +async function generateSection(section: string, repoData: any) { + const prompt = ` + Generate ONLY the "${section}" section of a README. + + Repo: + ${JSON.stringify(repoData)} + `; + + return await callAI(prompt); +} + +// STEP 3: Combine +export async function generateReadme(repoData: any) { + const sections = await generateStructure(repoData); + + let finalReadme = ""; + + for (const section of sections) { + const content = await generateSection(section, repoData); + finalReadme += `\n## ${section}\n${content}\n`; + } + + return finalReadme; +} /** * AI README Generation Endpoint * Optimized for data accuracy, clean prompt interpolation, and multi-language support. From 1b8b1c24494c193c6985055ebc7142395dcd837f Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:25:38 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- src/app/api/generate/route.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/api/generate/route.ts b/src/app/api/generate/route.ts index 760b57b..12fe591 100644 --- a/src/app/api/generate/route.ts +++ b/src/app/api/generate/route.ts @@ -18,7 +18,6 @@ async function generateStructure(repoData: any) { return JSON.parse(res); // ["Introduction", "Features", ...] } - // STEP 2: Generate each section async function generateSection(section: string, repoData: any) { const prompt = ` @@ -31,7 +30,6 @@ async function generateSection(section: string, repoData: any) { return await callAI(prompt); } - // STEP 3: Combine export async function generateReadme(repoData: any) { const sections = await generateStructure(repoData);