-
Notifications
You must be signed in to change notification settings - Fork 0
update prompts #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update prompts #19
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds richer README generation logic to the existing POST endpoint: discovers repository root files, detects tech stack (Node/Python/Docker) and license, constructs a detailed, role-based prompt embedding verified project context, and restructures the README blueprint and setup guidance accordingly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/api/generate/route.ts (1)
119-124:⚠️ Potential issue | 🟡 MinorNo validation of the AI response; truncation risk with 4096 max tokens.
The prompt now requests significantly more content (tables, directory trees, badges, multiple detailed sections), but
maxOutputTokensingemini.tsis set to 4096. This may truncate the README mid-section. Additionally, if the response is blocked by safety filters,response.text()could return empty or throw.Consider:
- Increasing
maxOutputTokensingemini.tsto accommodate the richer prompt.- Adding a guard for empty/blocked responses before returning to the client.
const markdown = response.text(); if (!markdown) { return NextResponse.json( { error: "AI generation returned empty content. Please try again." }, { status: 502 } ); }
🤖 Fix all issues with AI agents
In `@src/app/api/generate/route.ts`:
- Around line 97-99: The prompt in generate/route.ts asks for a tree-style
directory structure despite getRepoContents only returning root entries; update
the prompt assembly (where you call getRepoContents and compose the "Technical
Architecture" section) to either remove or soften the tree instruction and
instead request a flat file list or explicitly state the limitation that only
root-level files are available; locate references to getRepoContents and the
prompt text (e.g., the "Technical Architecture" / "tree-style directory
structure" string) and change it to ask for a flat list or an explicit note
about limited depth so the AI won't hallucinate nested folders.
- Around line 77-78: The prompt assembly currently uses fabricated fallback
strings for repoInfo?.description and repoInfo?.language ("A high-performance
software solution." and "Multilingual/Polyglot") which injects false claims;
update the code that constructs the description and language lines (the template
using repoInfo?.description and repoInfo?.language in route.ts) to use neutral,
explicit fallbacks such as "No description provided." and "Language unknown" (or
similar phrasing that signals absence) so the prompt does not imply unverified
facts.
- Around line 108-110: The README generation currently hardcodes "MIT" in the
"Detailed License" line; update the prompt/template in
src/app/api/generate/route.ts to use repoInfo.license (e.g.,
repoInfo.license.name or repoInfo.license.spdx_id) instead of the literal "MIT",
and fall back to a neutral instruction requesting the model infer the license
from repo metadata if repoInfo.license is missing; locate the prompt/template
string that contains "Detailed \"License\" section (MIT)" and replace it with a
dynamic insertion of the repository license or a clear fallback instruction.
- Line 80: The Tech Stack Context line in route.ts currently interpolates flags
directly and yields extra spaces or blank output; fix it by building a small
array of labels from hasNode, hasPython, hasDocker (e.g. [hasNode && "Node.js
Environment", hasPython && "Python Environment", hasDocker &&
"Containerized"].filter(Boolean).join(", ")), then use that joined string in
place of the current interpolation (or show a default like "None" when the array
is empty) so the "**Tech Stack Context**" line only contains correctly formatted
entries without extra spaces.
🧹 Nitpick comments (1)
src/app/api/generate/route.ts (1)
62-64: Stack detection misses common project markers.
pyproject.tomlis the modern standard for Python projects (PEP 621) and is more common thansetup.pyin newer codebases. Similarly,docker-compose.yaml(.yamlextension) is equally valid as.yml.Proposed fix
const hasNode = files.includes("package.json"); -const hasPython = files.includes("requirements.txt") || files.includes("setup.py"); -const hasDocker = files.includes("Dockerfile") || files.includes("docker-compose.yml"); +const hasPython = files.includes("requirements.txt") || files.includes("setup.py") || files.includes("pyproject.toml"); +const hasDocker = files.includes("Dockerfile") || files.includes("docker-compose.yml") || files.includes("docker-compose.yaml");
Refactor README generation logic for improved accuracy and clarity. Enhance tech stack detection and update prompt structure with dynamic license information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/api/generate/route.ts (1)
120-124:⚠️ Potential issue | 🟡 MinorNo guard against empty or safety-blocked model output.
If the Gemini safety filters block the response,
response.text()can return an empty string (or throw, depending on the SDK version). The client would receive{ markdown: "" }with a 200 status, which is silently broken.Proposed fix
const result = await model.generateContent(prompt); const response = await result.response; const markdown = response.text(); + if (!markdown) { + return NextResponse.json( + { error: "The model returned an empty response. The content may have been blocked by safety filters." }, + { status: 502 } + ); + } + return NextResponse.json({ markdown });
🧹 Nitpick comments (1)
src/app/api/generate/route.ts (1)
95-96: "Minimum 5 features" may cause hallucinated content for small/trivial repos.For repositories with limited functionality, forcing a minimum of 5 features will push the model to fabricate. Consider phrasing it as "List key features (aim for 3–5 where supported by the project context)" to give the model room to be accurate.
🚀 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: @naheel0
Timestamp: {{ 10/2/2026 }}