Conversation
📝 WalkthroughWalkthroughThis PR introduces a complete "PR Review Agent" kit—a Next.js application that automates code review by accepting GitHub PR URLs and generating structured reviews via Lamatic.ai integration. The flow fetches PR diffs from GitHub and uses an LLM to produce verdict badges, summaries, issues, and suggestions. Changes
Sequence DiagramsequenceDiagram
actor User
participant React as React Component<br/>(PRReviewForm)
participant Server as Next.js Server<br/>(reviewPR Action)
participant Lamatic as Lamatic Flow<br/>(Executor)
participant GitHub as GitHub REST API
participant LLM as LLM Provider
User->>React: Paste PR URL & Submit
React->>Server: Call reviewPR(prUrl)
Server->>Lamatic: executeFlow({ pr_url })
Lamatic->>Lamatic: Extract owner/repo/pr_number<br/>via Regex Node
Lamatic->>GitHub: Fetch PR Diff<br/>(Accept: application/vnd.github.v3.diff)
GitHub-->>Lamatic: Unified Diff Content
Lamatic->>LLM: Generate Review<br/>(JSON Schema Constraint)
LLM-->>Lamatic: Verdict + Issues + Suggestions
Lamatic-->>Server: Flow Result (nested response)
Server->>Server: Normalize & Parse<br/>Multi-level Response
Server-->>React: PRReviewResult Object
React->>React: Update UI State<br/>(verdict, summary, issues, suggestions)
React-->>User: Display Review Badge,<br/>Summary & Diff Blocks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can disable the changed files summary in the walkthrough.Disable the |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
kits/automation/pr-review/lib/lamatic-client.ts (1)
3-7: Add validation for missing environment variables.The non-null assertions (
!) will cause cryptic runtime errors if any environment variable is missing. Consider adding validation with descriptive error messages to improve developer experience during setup.♻️ Proposed fix with environment validation
import { Lamatic } from "lamatic"; +const apiKey = process.env.LAMATIC_API_KEY; +const projectId = process.env.LAMATIC_PROJECT_ID; +const endpoint = process.env.LAMATIC_API_URL; + +if (!apiKey || !projectId || !endpoint) { + throw new Error( + `Missing required environment variables. Please check your .env file:\n` + + ` LAMATIC_API_KEY: ${apiKey ? "✓" : "✗ missing"}\n` + + ` LAMATIC_PROJECT_ID: ${projectId ? "✓" : "✗ missing"}\n` + + ` LAMATIC_API_URL: ${endpoint ? "✓" : "✗ missing"}` + ); +} + export const lamatic = new Lamatic({ - apiKey: process.env.LAMATIC_API_KEY!, - projectId: process.env.LAMATIC_PROJECT_ID!, - endpoint: process.env.LAMATIC_API_URL!, + apiKey, + projectId, + endpoint, });
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 446c70ca-8400-4a80-af25-8980d09711ee
⛔ Files ignored due to path filters (1)
kits/automation/pr-review/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
kits/automation/pr-review/.env.examplekits/automation/pr-review/.gitignorekits/automation/pr-review/README.mdkits/automation/pr-review/actions/orchestrate.tskits/automation/pr-review/app/layout.tsxkits/automation/pr-review/app/page.tsxkits/automation/pr-review/components/PRReviewForm.tsxkits/automation/pr-review/config.jsonkits/automation/pr-review/flows/pr-review-flow/README.mdkits/automation/pr-review/lib/lamatic-client.tskits/automation/pr-review/next-env.d.tskits/automation/pr-review/package.jsonkits/automation/pr-review/tsconfig.json
| if (typeof review === "string") { | ||
| try { | ||
| return JSON.parse(review) as PRReviewResult; | ||
| } catch { | ||
| throw new Error("Could not parse review: " + review); | ||
| } | ||
| } | ||
|
|
||
| if (review?.summary) { | ||
| return review as PRReviewResult; | ||
| } | ||
|
|
||
| throw new Error("Could not find review in response: " + JSON.stringify(response)); |
There was a problem hiding this comment.
Treat the flow output as untrusted input.
This branch casts model output straight to PRReviewResult and then echoes the raw payload in thrown errors. If the flow returns malformed JSON or drops a required field, PRReviewForm.tsx Line 322 can surface the full payload to the browser, and Lines 328-331 can still crash while rendering. Parse to unknown, validate summary/issues/suggestions/verdict plus item fields, and replace payload-echoing errors with generic client-safe messages.
| async function copyFix() { | ||
| try { | ||
| await navigator.clipboard.writeText(fix); | ||
| } catch { | ||
| // no-op | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| style={{ | ||
| border: "1px solid #27272a", | ||
| borderRadius: 6, | ||
| overflow: "hidden", | ||
| background: "#1a1a1a", | ||
| }} | ||
| > | ||
| <CodePane label="BEFORE" symbol="-" text={code} tone="#ff000015" onCopy={copyFix} /> | ||
| <CodePane label="AFTER" symbol="+" text={fix} tone="#00ff0015" borderTop onCopy={copyFix} /> |
There was a problem hiding this comment.
Wire each copy button to the pane it belongs to.
Both panes call copyFix, so clicking Copy in the BEFORE block still copies the replacement code instead of the original snippet.
Suggested fix
function CodeDiff({ code, fix }: { code: string; fix: string }) {
- async function copyFix() {
+ async function copyText(value: string) {
try {
- await navigator.clipboard.writeText(fix);
+ await navigator.clipboard.writeText(value);
} catch {
// no-op
}
}
@@
- <CodePane label="BEFORE" symbol="-" text={code} tone="#ff000015" onCopy={copyFix} />
- <CodePane label="AFTER" symbol="+" text={fix} tone="#00ff0015" borderTop onCopy={copyFix} />
+ <CodePane label="BEFORE" symbol="-" text={code} tone="#ff000015" onCopy={() => copyText(code)} />
+ <CodePane label="AFTER" symbol="+" text={fix} tone="#00ff0015" borderTop onCopy={() => copyText(fix)} />📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async function copyFix() { | |
| try { | |
| await navigator.clipboard.writeText(fix); | |
| } catch { | |
| // no-op | |
| } | |
| } | |
| return ( | |
| <div | |
| style={{ | |
| border: "1px solid #27272a", | |
| borderRadius: 6, | |
| overflow: "hidden", | |
| background: "#1a1a1a", | |
| }} | |
| > | |
| <CodePane label="BEFORE" symbol="-" text={code} tone="#ff000015" onCopy={copyFix} /> | |
| <CodePane label="AFTER" symbol="+" text={fix} tone="#00ff0015" borderTop onCopy={copyFix} /> | |
| async function copyText(value: string) { | |
| try { | |
| await navigator.clipboard.writeText(value); | |
| } catch { | |
| // no-op | |
| } | |
| } | |
| return ( | |
| <div | |
| style={{ | |
| border: "1px solid `#27272a`", | |
| borderRadius: 6, | |
| overflow: "hidden", | |
| background: "#1a1a1a", | |
| }} | |
| > | |
| <CodePane label="BEFORE" symbol="-" text={code} tone="#ff000015" onCopy={() => copyText(code)} /> | |
| <CodePane label="AFTER" symbol="+" text={fix} tone="#00ff0015" borderTop onCopy={() => copyText(fix)} /> |
| } catch (err: unknown) { | ||
| setError(err instanceof Error ? err.message : "Something went wrong."); |
There was a problem hiding this comment.
The error state is currently unreachable.
When reviewPR throws, result stays null, so the !result || !verdict branch wins and the message stored in error never renders. Bad URLs and flow failures will look like a silent reset instead of a failed review.
One minimal way to surface the error
- ) : !result || !verdict ? (
+ ) : error ? (
+ <div style={{ fontSize: 13, color: "#fca5a5" }}>{error}</div>
+ ) : !result || !verdict ? (
<EmptyLeftPanel />
) : (
@@
- {error && <div style={{ fontSize: 13, color: "#fca5a5" }}>{error}</div>}Also applies to: 565-567, 627-627
| ## Build in Lamatic Studio | ||
|
|
||
| This flow has 4 nodes: **API Request → Code → API → Generate JSON → API Response** | ||
|
|
There was a problem hiding this comment.
Correct the documented flow node count.
This README says the flow has 4 nodes, but the walkthrough later defines a fifth API Response node. That makes the setup look ambiguous even though the last node is required.
Suggested doc fix
-This flow has 4 nodes: **API Request → Code → API → Generate JSON → API Response**
+This flow has 5 nodes: **API Request → Code → API → Generate JSON → API Response**Also applies to: 140-142
| "dependencies": { | ||
| "next": "14.2.5", | ||
| "react": "^18", | ||
| "react-dom": "^18", | ||
| "lamatic": "^0.1.0" | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check latest versions and security advisories for key dependencies
echo "=== Checking Next.js ==="
curl -s https://registry.npmjs.org/next/latest | jq -r '.version'
echo "=== Checking lamatic ==="
curl -s https://registry.npmjs.org/lamatic/latest | jq -r '.version // "Package not found or no latest tag"'
echo "=== Security advisories for Next.js ==="
gh api graphql -f query='
{
securityVulnerabilities(first: 5, ecosystem: NPM, package: "next") {
nodes {
advisory {
summary
severity
publishedAt
}
vulnerableVersionRange
firstPatchedVersion {
identifier
}
}
}
}'Repository: Lamatic/AgentKit
Length of output: 323
Update Next.js to a current major version.
Next.js 14.2.5 is significantly outdated; version 16.2.0 is now available. Consider upgrading to the latest major version to receive security updates and new features. The lamatic@^0.1.0 dependency already permits updates (latest available is 0.3.2), though be mindful of breaking changes in early-stage dependencies.
| ## Demo | ||
|
|
||
| > | ||
|
|
There was a problem hiding this comment.
Populate or remove the empty demo section.
Right now this renders as a blank blockquote, so the README advertises a demo without giving readers anything to open or compare against.
|
closed as opened in #74 |
What This Kit Does
AI-powered GitHub pull request reviewer. Paste any public PR URL and get an instant structured code review, with file-level citations, before/after code diffs, and actionable fixes ready to copy-paste.
What it returns:
approve,needs_changes, ordiscussWhy this is useful: Teams using Lamatic can drop this into their dev workflow to get consistent, structured reviews on every PR, without waiting for a senior engineer to be available.
Providers & Prerequisites
GITHUB_TOKENto your env and pass it asAuthorization: Bearerin the API node header.How to Run Locally
cd kits/automation/pr-reviewnpm installcp .env.example .envand fill in valuesnpm run devOpen http://localhost:3000, paste a GitHub PR URL, hit Review PR.
Full flow setup instructions:
flows/pr-review-flow/README.mdLive Preview
Lamatic Flow
Flow ID:
a70ea776-386d-4474-953c-a7fe7bf54d41Built with: API Request → Code (URL parser) → API (GitHub diff fetch) → Generate JSON (LLM review) → API Response
Checklist
npm run dev.env.examplehas no secrets, only placeholdersREADME.mddocuments setup and usagekits/automation/pr-review/config.jsonis present and validflows/folderPR Review Agent Kit
kits/automation/pr-review- an AI-powered GitHub PR reviewer built with Lamatic.ai and Next.jsapprove,needs_changes, ordiscuss)GITHUB_TOKEN).env.example,package.jsonwith Next.js 14.2.5 and Lamatic SDK,tsconfig.json, and full documentationconfig.jsondefines agent metadata, GitHub integration, and feature descriptions