Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
27248e9
feat: Add code-review-agent AgentKit
soumik15630m Mar 21, 2026
46b35e8
feat:small bug fixes and feature update
soumik15630m Mar 21, 2026
d3af5a5
feat: Add code-review-agent AgentKit
soumik15630m Mar 21, 2026
47c0756
Merge branch 'main' into main
amanintech Mar 27, 2026
1f11849
Update kits/agentic/code-review/.gitignore
soumik15630m Mar 28, 2026
cbc6304
Update kits/agentic/code-review/.env.example
soumik15630m Mar 28, 2026
47d8461
Update kits/agentic/code-review/config.json
soumik15630m Mar 28, 2026
2d7d9e0
Update kits/agentic/code-review/flows/code-review-agent/config.json
soumik15630m Mar 28, 2026
5239732
Update kits/agentic/code-review/README.md
soumik15630m Mar 28, 2026
fbe983c
Update kits/agentic/code-review/.env.example
soumik15630m Mar 28, 2026
a4669b0
Update kits/agentic/code-review/next.config.mjs
soumik15630m Mar 28, 2026
75e205c
Update kits/agentic/code-review/lib/lamatic-client.ts
soumik15630m Mar 28, 2026
ea33596
Update README.md
soumik15630m Mar 28, 2026
0e64dc4
Update next.config.mjs
soumik15630m Mar 28, 2026
fc14d66
Update next.config.mjs
soumik15630m Mar 28, 2026
95602c1
Enable TypeScript build error ignoring
soumik15630m Mar 28, 2026
98968cc
Update orchestrate.ts
soumik15630m Mar 28, 2026
2ed35e9
Disable check for AGENTIC_GENERATE_CONTENT
soumik15630m Mar 28, 2026
3236287
Remove steps for code review agent from config
soumik15630m Mar 28, 2026
0d99f37
Update kits/agentic/code-review/config.json
soumik15630m Mar 29, 2026
84e6aa9
Update kits/agentic/code-review/lib/lamatic-client.ts
soumik15630m Mar 29, 2026
82b8178
Update kits/agentic/code-review/config.json
soumik15630m Mar 29, 2026
382c7d7
Update orchestrate.ts
soumik15630m Mar 29, 2026
67c2733
Update kits/agentic/code-review/config.json
soumik15630m Mar 29, 2026
4be83ea
Update kits/agentic/code-review/actions/orchestrate.ts
soumik15630m Mar 29, 2026
6183b55
Fix formatting and content in README.md
soumik15630m Mar 29, 2026
10aba9a
Refactor workflow ID handling in generateContent function
soumik15630m Mar 29, 2026
8e9ba56
Update config.json
soumik15630m Mar 29, 2026
c893b2a
Merge branch 'main' into main
d-pamneja Mar 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kits/agentic/code-review/.env.example
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
30 changes: 30 additions & 0 deletions kits/agentic/code-review/.gitignore
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

Comment thread
soumik15630m marked this conversation as resolved.
# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
Empty file.
16 changes: 16 additions & 0 deletions kits/agentic/code-review/.next-dev-3001.log
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
185 changes: 185 additions & 0 deletions kits/agentic/code-review/README.md
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 |

Comment thread
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:

```text
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
```

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

```text
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

---

![alt text](image.png)

---

## Author

Built by [Soumik](https://github.com/soumik15630m) as a contribution to [Lamatic AgentKit](https://github.com/Lamatic/AgentKit).
70 changes: 70 additions & 0 deletions kits/agentic/code-review/actions/orchestrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"use server"

import { lamaticClient } from "@/lib/lamatic-client"
import config from "../config"

+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]
Comment thread
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);
Comment thread
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 workflowId = process.env[flow.workflowId]
if (!workflowId) {
throw new Error(`Missing environment variable for workflow ID key: ${flow.workflowId}`)
}
const resData = await lamaticClient.executeFlow(workflowId, inputs)
console.log("[v0] Raw response:", resData)

const answer = resData?.result?.answer

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,
}
}
}
Loading
Loading