Conversation
|
@Ashusf90 is attempting to deploy a commit to the naheel0's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdded a multi-step README generation pipeline: Changes
Sequence DiagramsequenceDiagram
participant Client
participant generateReadme
participant generateStructure
participant generateSection
participant GeminiAPI
Client->>generateReadme: generateReadme(repoData)
generateReadme->>generateStructure: generateStructure(repoData)
generateStructure->>GeminiAPI: Prompt for section names
GeminiAPI-->>generateStructure: JSON array of section names
generateStructure-->>generateReadme: Section array
loop For each section
generateReadme->>generateSection: generateSection(section, repoData)
generateSection->>GeminiAPI: Prompt for section content
GeminiAPI-->>generateSection: Section content
generateSection-->>generateReadme: Section content
end
generateReadme->>generateReadme: Assemble Markdown with ## headers
generateReadme-->>Client: Final README Markdown
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/app/api/generate/route.ts (1)
8-8: Consider adding proper types instead ofany.All three functions use
repoData: any, losing type safety. If a type or interface for repository data exists (or can be created), using it would improve maintainability and catch errors at compile time.Also applies to: 23-23, 36-36
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/api/generate/route.ts` at line 8, Define a proper typed interface (e.g., RepositoryData) that lists the actual properties accessed on repoData and replace the repoData: any annotations with this interface in generateStructure and the other functions that accept repoData; to implement, inspect the bodies of generateStructure and the two other repoData-using functions to collect every property and nested shape they read/write, declare those fields in RepositoryData (or split into smaller interfaces for nested objects), export it if reused, and update the function signatures to use RepositoryData instead of any to restore type safety.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app/api/generate/route.ts`:
- Around line 22-32: The generateSection function calls a non-existent helper
callAI; replace that call with the project's established Gemini invocation or
implement a callAI wrapper that delegates to the existing Gemini-based request
flow. Locate the generateSection function and either (a) refactor the return
from "return await callAI(prompt);" to use the same Gemini call used elsewhere
(e.g., the function/method that sends prompts to the Gemini model), passing the
prompt and any required options, or (b) add a callAI helper that accepts a
prompt and internally invokes the Gemini request function/class used in the
codebase, then return its result; ensure you reference the exact symbol
generateSection when making the change so all callers keep working.
- Around line 7-19: The function generateStructure calls an undefined callAI and
blindly JSON.parse's the response; fix by replacing callAI with the existing
getGeminiModel()/appropriate AI call used elsewhere (or import/define callAI)
and wrap the JSON.parse in a try/catch that sanitizes/preprocesses the model
output before parsing (e.g., strip non-JSON preamble), validate the parsed value
is an array of strings, and return a safe fallback or throw a clear error;
reference generateStructure and callAI (or use getGeminiModel) when making the
change.
- Around line 35-47: The exported generateReadme function is unused and unsafe:
either remove/export it if unnecessary, or integrate it into the POST handler by
calling generateReadme from the request flow (replace the single-prompt path).
If you keep it, harden it by validating the result of generateStructure before
iterating (use Array.isArray on the value returned from
generateStructure/JSON.parse and handle non-array cases by throwing or returning
a safe default), and update the function signature/return type expectations
accordingly; ensure generateSection is only called for confirmed array entries.
---
Nitpick comments:
In `@src/app/api/generate/route.ts`:
- Line 8: Define a proper typed interface (e.g., RepositoryData) that lists the
actual properties accessed on repoData and replace the repoData: any annotations
with this interface in generateStructure and the other functions that accept
repoData; to implement, inspect the bodies of generateStructure and the two
other repoData-using functions to collect every property and nested shape they
read/write, declare those fields in RepositoryData (or split into smaller
interfaces for nested objects), export it if reused, and update the function
signatures to use RepositoryData instead of any to restore type safety.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3bf78f75-08cb-4469-b395-f6119f3d3e95
📒 Files selected for processing (1)
src/app/api/generate/route.ts
| // 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", ...] | ||
| } |
There was a problem hiding this comment.
callAI is undefined — code will fail at runtime.
The function callAI is called on line 17 but is never defined or imported in this file. This will throw a ReferenceError when executed.
Additionally, JSON.parse(res) on line 18 lacks error handling. If the AI returns malformed JSON or includes preamble text, this will throw an unhandled exception.
🐛 Proposed fix
Either define callAI or use the existing getGeminiModel() pattern:
+async function callAI(prompt: string): Promise<string> {
+ const model = getGeminiModel();
+ const result = await model.generateContent(prompt);
+ const response = await result.response;
+ return response.text();
+}
+
// 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", ...]
+ try {
+ return JSON.parse(res);
+ } catch {
+ throw new Error("Failed to parse section structure from AI response");
+ }
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/app/api/generate/route.ts` around lines 7 - 19, The function
generateStructure calls an undefined callAI and blindly JSON.parse's the
response; fix by replacing callAI with the existing getGeminiModel()/appropriate
AI call used elsewhere (or import/define callAI) and wrap the JSON.parse in a
try/catch that sanitizes/preprocesses the model output before parsing (e.g.,
strip non-JSON preamble), validate the parsed value is an array of strings, and
return a safe fallback or throw a clear error; reference generateStructure and
callAI (or use getGeminiModel) when making the change.
| // 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); | ||
| } |
There was a problem hiding this comment.
Same undefined callAI issue.
This function also calls callAI which doesn't exist. Same fix applies — either define the helper or refactor to use the existing Gemini model pattern.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/app/api/generate/route.ts` around lines 22 - 32, The generateSection
function calls a non-existent helper callAI; replace that call with the
project's established Gemini invocation or implement a callAI wrapper that
delegates to the existing Gemini-based request flow. Locate the generateSection
function and either (a) refactor the return from "return await callAI(prompt);"
to use the same Gemini call used elsewhere (e.g., the function/method that sends
prompts to the Gemini model), passing the prompt and any required options, or
(b) add a callAI helper that accepts a prompt and internally invokes the Gemini
request function/class used in the codebase, then return its result; ensure you
reference the exact symbol generateSection when making the change so all callers
keep working.
|
Hi @Ashusf90, Could you provide a brief description of the changes in this PR and how they address the linked issue #<issue_number>? Specifically, a short summary of what this update to route.ts does and the purpose of the new functions would help reviewers understand the context. Thanks! |
🚀 BΞYTΞFLʘW | Pull Request Protocol
PR Type: (Choose one:
feat|fix|refactor|docs|perf)Issue Link: Fixes #
📝 System Summary
Provide a concise brief of the changes introduced to the stream.
🛠️ Technical Changes
.........🧪 Quality Assurance (QA)
npm run buildexecuted without errors.🖼️ Visual Evidence
If this PR affects the UI, drop a screenshot or GIF below:
📡 Developer Authorization
Authorized by: @Yourusername
Timestamp: {{ date }}