-
Notifications
You must be signed in to change notification settings - Fork 136
feat: Add code-review-agent AgentKit #84
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
27248e9
feat: Add code-review-agent AgentKit
soumik15630m 46b35e8
feat:small bug fixes and feature update
soumik15630m d3af5a5
feat: Add code-review-agent AgentKit
soumik15630m 47c0756
Merge branch 'main' into main
amanintech 1f11849
Update kits/agentic/code-review/.gitignore
soumik15630m cbc6304
Update kits/agentic/code-review/.env.example
soumik15630m 47d8461
Update kits/agentic/code-review/config.json
soumik15630m 2d7d9e0
Update kits/agentic/code-review/flows/code-review-agent/config.json
soumik15630m 5239732
Update kits/agentic/code-review/README.md
soumik15630m fbe983c
Update kits/agentic/code-review/.env.example
soumik15630m a4669b0
Update kits/agentic/code-review/next.config.mjs
soumik15630m 75e205c
Update kits/agentic/code-review/lib/lamatic-client.ts
soumik15630m ea33596
Update README.md
soumik15630m 0e64dc4
Update next.config.mjs
soumik15630m fc14d66
Update next.config.mjs
soumik15630m 95602c1
Enable TypeScript build error ignoring
soumik15630m 98968cc
Update orchestrate.ts
soumik15630m 2ed35e9
Disable check for AGENTIC_GENERATE_CONTENT
soumik15630m 3236287
Remove steps for code review agent from config
soumik15630m 0d99f37
Update kits/agentic/code-review/config.json
soumik15630m 84e6aa9
Update kits/agentic/code-review/lib/lamatic-client.ts
soumik15630m 82b8178
Update kits/agentic/code-review/config.json
soumik15630m 382c7d7
Update orchestrate.ts
soumik15630m 67c2733
Update kits/agentic/code-review/config.json
soumik15630m 4be83ea
Update kits/agentic/code-review/actions/orchestrate.ts
soumik15630m 6183b55
Fix formatting and content in README.md
soumik15630m 10aba9a
Refactor workflow ID handling in generateContent function
soumik15630m 8e9ba56
Update config.json
soumik15630m c893b2a
Merge branch 'main' into main
d-pamneja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| AGENTIC_GENERATE_CONTENT=AGENTIC_GENERATE_CONTENT_FLOW_ID | ||
| LAMATIC_API_KEY=LAMATIC_API_KEY | ||
| LAMATIC_API_URL=LAMATIC_API_URL | ||
| LAMATIC_PROJECT_ID=LAMATIC_PROJECT_ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| /node_modules | ||
|
|
||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # env files | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
| !.env.example | ||
|
|
||
| # vercel | ||
| .vercel | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| > code-review-agent@0.1.0 dev | ||
| > next dev --port 3001 | ||
|
|
||
| ▲ Next.js 15.1.3 | ||
| - Local: http://localhost:3001 | ||
| - Network: http://10.72.173.67:3001 | ||
| - Environments: .env | ||
|
|
||
| ✓ Starting... | ||
| ✓ Ready in 3.5s | ||
| ○ Compiling / ... | ||
| ✓ Compiled / in 1390ms (571 modules) | ||
| GET / 200 in 1935ms | ||
| GET / 200 in 36ms | ||
| [?25h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| # Code Review Agent | ||
|
|
||
| An agentic Next.js starter kit that performs AI-powered code reviews on GitHub Pull Requests using Lamatic Flows. Enter any public GitHub PR and get a structured analysis of bugs, security vulnerabilities, and style issues in seconds. | ||
|
|
||
| ## Live Demo | ||
|
|
||
| [agent-kit-stk.vercel.app](https://agent-kit-stk.vercel.app) | ||
|
|
||
| --- | ||
|
|
||
| ## What It Does | ||
|
|
||
| The agent takes three inputs — GitHub owner, repository, and PR number — then runs a multi-step agentic flow: | ||
|
|
||
| 1. **Fetches** the PR diff from the GitHub REST API | ||
| 2. **Extracts** the raw patch content from all changed files | ||
| 3. **Analyzes bugs** — null pointer risks, logic errors, runtime failures | ||
| 4. **Analyzes security** — hardcoded secrets, injection risks, insecure dependencies | ||
| 5. **Analyzes style** — naming conventions, complexity, readability | ||
| 6. **Synthesizes** a concise overall summary of PR quality | ||
|
|
||
| Results are returned as structured JSON and rendered in a premium dark-themed UI with severity-aware triage cards. | ||
|
|
||
| --- | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| | Layer | Technology | | ||
| |---|---| | ||
| | Frontend | Next.js 16.2.1, React 19 | | ||
| | AI Flow | Lamatic Flows (GraphQL API) | | ||
| | LLM | Groq — `llama-3.3-70b-versatile` | | ||
| | GitHub Data | GitHub REST API | | ||
| | Deployment | Vercel | | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node.js 18+ | ||
| - A [Lamatic](https://lamatic.ai) account with the Code Review Agent flow deployed | ||
| - A [Groq](https://console.groq.com) API key (free) | ||
| - A [GitHub](https://github.com) account (for public PR access) | ||
|
|
||
| --- | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Create a `.env` file in the kit root: | ||
|
|
||
| --- | ||
|
|
||
| ## Lamatic Flow Setup | ||
|
|
||
| This kit requires a Lamatic flow with the following node structure: | ||
|
|
||
| ``` | ||
| API Request Trigger (owner, repo, pr_number) | ||
| ↓ | ||
| Code Node — extract diff from GitHub API response | ||
| ↓ | ||
| GitHub API Node — GET /repos/{owner}/{repo}/pulls/{pr_number}/files | ||
| ↓ | ||
| Generate JSON — Bug Analysis | ||
| ↓ | ||
| Generate JSON — Security Scan | ||
| ↓ | ||
| Generate JSON — Style Check | ||
| ↓ | ||
| Generate JSON — Final Merge (summary) | ||
| ↓ | ||
| API Response | ||
| ``` | ||
|
soumik15630m marked this conversation as resolved.
Outdated
|
||
|
|
||
| Import the exported flow from the `flows/` directory into your Lamatic project, then update the `workflowId` in `app/api/review/route.ts` with your deployed flow ID. | ||
|
|
||
| --- | ||
|
|
||
| ## Running Locally | ||
|
|
||
| ```bash | ||
| # 1. Install dependencies | ||
| cd kits/agentic/code-review | ||
| npm install | ||
|
|
||
| # 2. Set up environment variables | ||
| cp .env.example .env | ||
| # Fill in your LAMATIC_API_KEY | ||
|
|
||
| # 3. Start the dev server | ||
| npm run dev | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) in your browser. | ||
|
|
||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Enter the GitHub **owner** (e.g. `fmtlib`) | ||
| 2. Enter the **repository** name (e.g. `fmt`) | ||
| 3. Enter the **PR number** (e.g. `4660`) | ||
| 4. Click **Review PR** | ||
|
|
||
| The agent will fetch the diff and return: | ||
|
|
||
| - **Summary** — a concise 2-3 sentence overview of PR quality | ||
| - **Bugs** — logic errors and runtime risks with severity levels (High / Medium / Low) | ||
| - **Security** — vulnerability findings with severity levels | ||
| - **Style** — readability and code quality suggestions | ||
|
|
||
| --- | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| kits/agentic/code-review/ | ||
| ├── app/ | ||
| │ ├── api/ | ||
| │ │ └── review/ | ||
| │ │ └── route.ts # Calls Lamatic GraphQL API | ||
| │ ├── page.tsx # Main UI | ||
| │ ├── layout.tsx | ||
| │ └── globals.css | ||
| ├── flows/ | ||
| │ └── code-review-agent/ # Exported Lamatic flow | ||
| ├── .env.example | ||
| ├── config.json | ||
| ├── package.json | ||
| └── README.md | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### `POST /api/review` | ||
|
|
||
| **Request:** | ||
| ```json | ||
| { | ||
| "owner": "fmtlib", | ||
| "repo": "fmt", | ||
| "pr_number": "4660" | ||
| } | ||
| ``` | ||
|
|
||
| **Response:** | ||
| ```json | ||
| { | ||
| "summary": "The PR introduces a new is_container_adaptor trait...", | ||
| "bugs": [ | ||
| { "line": "776", "issue": "Potential null pointer risk", "severity": "High" } | ||
| ], | ||
| "security": [ | ||
| { "line": "765", "issue": "Insecure dependency", "severity": "Low" } | ||
| ], | ||
| "style": [ | ||
| "code style", | ||
| "readability issues" | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Deployment | ||
|
|
||
| Deploy to Vercel in one click: | ||
|
|
||
| 1. Fork this repository | ||
| 2. Import to [vercel.com](https://vercel.com) | ||
| 3. Set Root Directory to `kits/agentic/code-review` | ||
| 4. Add environment variable: `LAMATIC_API_KEY` | ||
| 5. Deploy | ||
|
|
||
| --- | ||
|
|
||
|  | ||
|
|
||
| --- | ||
|
|
||
| ## Author | ||
|
|
||
| Built by [Soumik](https://github.com/soumik15630m) as a contribution to [Lamatic AgentKit](https://github.com/Lamatic/AgentKit). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| "use server" | ||
|
|
||
| import { lamaticClient } from "@/lib/lamatic-client" | ||
|
|
||
| +export async function generateContent( | ||
| + prUrl: string, | ||
| ): Promise<{ | ||
| success: boolean | ||
| data?: any | ||
| error?: string | ||
| }> { | ||
| try { | ||
| console.log("[v0] Generating content with:", { prUrl }) | ||
|
|
||
| // Get the first workflow from the config | ||
| const flows = config.flows | ||
| const firstFlowKey = Object.keys(flows)[0] | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| if (!firstFlowKey) { | ||
| throw new Error("No workflows found in configuration") | ||
| } | ||
|
|
||
| // Fix: Add index signature to make TypeScript happy about accessing flows[firstFlowKey] | ||
| const flow = flows[firstFlowKey as keyof typeof flows] as (typeof flows)[keyof typeof flows]; | ||
| console.log("[v0] Using workflow:", flow.name, flow.workflowId); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| const inputs: Record<string, any> = { prUrl } | ||
| console.log("[v0] Sending inputs:", inputs) | ||
|
|
||
| if(!flow.workflowId){ | ||
| throw Error("Workflow not found in config.") | ||
| } | ||
| const resData = await lamaticClient.executeFlow(flow.workflowId, inputs) | ||
| console.log("[v0] Raw response:", resData) | ||
|
|
||
| const answer = data?.data?.executeWorkflow?.result | ||
|
soumik15630m marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (!answer) { | ||
| throw new Error("No answer found in response") | ||
| } | ||
|
|
||
| return { | ||
| success: true, | ||
| data: answer, | ||
| } | ||
| } catch (error) { | ||
| console.error("[v0] Generation error:", error) | ||
|
|
||
| let errorMessage = "Unknown error occurred" | ||
| if (error instanceof Error) { | ||
| errorMessage = error.message | ||
| if (error.message.includes("fetch failed")) { | ||
| errorMessage = | ||
| "Network error: Unable to connect to the service. Please check your internet connection and try again." | ||
| } else if (error.message.includes("API key")) { | ||
| errorMessage = "Authentication error: Please check your API configuration." | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| success: false, | ||
| error: errorMessage, | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.