Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ Each kit includes configuration instructions, environment variables/lamatic-conf
| **🧠 Agentic Kits** | Advanced self-directed, reasoning agents for goal-driven operations | | | [`/kits/agentic`](./kits/agentic) |
| **Deep Search Agent** | A Next.js starter kit for goal-driven reasoning agents using Lamatic Flows. | Available | [![Live Demo](https://img.shields.io/badge/Live%20Demo-black?style=for-the-badge)](https://agent-kit-reasoning.vercel.app) | [`/kits/agentic/deep-search`](./kits/agentic/deep-search) |
| **Generation Agent** | A Next.js starter kit for generating text/json/image content using Lamatic Flows. | Available | [![Live Demo](https://img.shields.io/badge/Live%20Demo-black?style=for-the-badge)](https://agent-kit-generation.vercel.app) | [`/kits/agentic/generation`](./kits/agentic/generation) |
| **Code Review Agent** | Reviews public GitHub PRs for bugs, security issues, and style risks using Lamatic flows. | Available | [![Live Demo](https://img.shields.io/badge/Live%20Demo-black?style=for-the-badge)](https://agent-kit-stk.vercel.app) | [`/kits/agentic/code-review`](./kits/agentic/code-review) |
||
| **🤖 Automation Kits** | Automate complex business processes with robust and flexible agent workflows | | | [`/kits/automation`](./kits/automation) |
| **Hiring Automation** | A Next.js starter kit for hiring automation using Lamatic Flows. | Available | [![Live Demo](https://img.shields.io/badge/Live%20Demo-black?style=for-the-badge)](https://agent-kit-hiring.vercel.app) | [`/kits/automation/hiring`](./kits/automation/hiring) |
| **Blog Writing Automation** | Generates, optimizes, and publishes blog posts from webhook or scheduler triggers. | Available | | [`/kits/automation/blog-automation`](./kits/automation/blog-automation) |
||
| **🧑‍💼 Assistant Kits** | Create context-aware helpers for users, customers, and team members | | | [`/kits/assistant`](./kits/assistant) |
| **Grammar Assistant** | A chrome extension to check grammar corrections across your selection. | Available | | [`/kits/assistant/grammar-extension`](./kits/assistant/grammar-extension) |
Expand Down
3 changes: 2 additions & 1 deletion kits/agentic/code-review/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.next-dev*.log

# env files
.env
Expand All @@ -27,4 +28,4 @@ yarn-error.log*

# typescript
*.tsbuildinfo
next-env.d.ts
next-env.d.ts
Empty file.
16 changes: 0 additions & 16 deletions kits/agentic/code-review/.next-dev-3001.log

This file was deleted.

14 changes: 10 additions & 4 deletions kits/agentic/code-review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ Results are returned as structured JSON and rendered in a premium dark-themed UI

Create a `.env` file in the kit root:

---
```bash
AGENTIC_GENERATE_CONTENT="your-deployed-flow-id"
LAMATIC_API_URL="https://your-org.lamatic.dev"
LAMATIC_PROJECT_ID="your-project-id"
LAMATIC_API_KEY="your-api-key"
```

## Lamatic Flow Setup

Expand All @@ -72,7 +77,7 @@ 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.
Import the exported flow from the `flows/` directory into your Lamatic project, deploy it, then copy the deployed flow id into `AGENTIC_GENERATE_CONTENT`.

---

Expand All @@ -85,7 +90,7 @@ npm install

# 2. Set up environment variables
cp .env.example .env
# Fill in your LAMATIC_API_KEY
# Fill in all Lamatic values from your project

# 3. Start the dev server
npm run dev
Expand Down Expand Up @@ -172,7 +177,8 @@ Deploy to Vercel in one click:
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
5. Add `LAMATIC_API_URL`, `LAMATIC_PROJECT_ID`, and `AGENTIC_GENERATE_CONTENT`
6. Deploy

---

Expand Down
74 changes: 31 additions & 43 deletions kits/agentic/code-review/actions/orchestrate.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,58 @@
"use server"

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

+export async function generateContent(
+ prUrl: string,
): Promise<{
type FlowConfig = {
name: string
workflowId: string
}

type GenerateContentResult = {
success: boolean
data?: any
data?: unknown
error?: string
}> {
try {
console.log("[v0] Generating content with:", { prUrl })
}

const flows = config.flows as Record<string, FlowConfig>

// Get the first workflow from the config
const flows = config.flows
const firstFlowKey = Object.keys(flows)[0]
export async function generateContent(
prUrl: string
): Promise<GenerateContentResult> {
try {
const [firstFlowKey] = Object.keys(flows)

if (!firstFlowKey) {
throw new Error("No workflows found in configuration")
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);

const inputs: Record<string, any> = { prUrl }
console.log("[v0] Sending inputs:", inputs)
const flow = flows[firstFlowKey]

if (!flow.workflowId) {
throw Error("Workflow not found in config.")
if (!flow?.workflowId) {
throw new 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
const workflowId = process.env[flow.workflowId]

if (!answer) {
throw new Error("No answer found in response")
if (!workflowId) {
throw new Error(
`Missing environment variable for workflow ID key: ${flow.workflowId}`
)
}

const response = await lamaticClient.executeFlow(workflowId, { prUrl })

return {
success: true,
data: answer,
data: response?.result ?? null,
}
} 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."
}
}
const message =
error instanceof Error ? error.message : "Unknown error occurred."

return {
success: false,
error: errorMessage,
error: message,
}
}
}
90 changes: 66 additions & 24 deletions kits/agentic/code-review/app/api/review/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ const query = `
}
`

type LamaticIssue = {
message?: string
}

type LamaticExecuteWorkflowResult = {
bugs?: unknown
security?: unknown
style?: unknown
summary?: unknown
}

type LamaticGraphqlResponse = {
data?: {
executeWorkflow?: {
result?: LamaticExecuteWorkflowResult
}
}
errors?: LamaticIssue[]
message?: string
}

function getGraphqlUrl(apiUrl: string) {
const trimmed = apiUrl.trim().replace(/\/+$/, "")
return trimmed.endsWith("/graphql") ? trimmed : `${trimmed}/graphql`
}

export async function POST(req: NextRequest) {
try {
const body = await req.json()
Expand All @@ -36,37 +62,50 @@ export async function POST(req: NextRequest) {
)
}

if (!process.env.LAMATIC_API_KEY) {
const lamaticApiKey = process.env.LAMATIC_API_KEY?.trim()
const lamaticApiUrl = process.env.LAMATIC_API_URL?.trim()
const lamaticProjectId = process.env.LAMATIC_PROJECT_ID?.trim()
const workflowId = process.env.AGENTIC_GENERATE_CONTENT?.trim()

const missingEnv = [
!lamaticApiKey && "LAMATIC_API_KEY",
!lamaticApiUrl && "LAMATIC_API_URL",
!lamaticProjectId && "LAMATIC_PROJECT_ID",
!workflowId && "AGENTIC_GENERATE_CONTENT",
].filter(Boolean)

if (missingEnv.length > 0) {
return NextResponse.json(
{ error: "LAMATIC_API_KEY is not configured on the server." },
{
error: `Missing required Lamatic environment variables: ${missingEnv.join(
", "
)}.`,
},
{ status: 500 }
)
}

const res = await fetch(
"https://soumiksorganization573-codereviewagent135.lamatic.dev/graphql",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LAMATIC_API_KEY}`,
"Content-Type": "application/json",
"x-project-id": "4da47f5c-f38d-4519-89b3-82feda6e81ab",
const res = await fetch(getGraphqlUrl(lamaticApiUrl), {
method: "POST",
headers: {
Authorization: `Bearer ${lamaticApiKey}`,
"Content-Type": "application/json",
"x-project-id": lamaticProjectId,
},
body: JSON.stringify({
query,
variables: {
workflowId,
owner,
repo,
pr_number,
},
body: JSON.stringify({
query,
variables: {
workflowId: "597871bb-6b0b-4cef-9771-05514dee60cd",
owner,
repo,
pr_number,
},
}),
}
)
}),
})

const raw = await res.text()
const trimmed = raw.trim()
let data: any = null
let data: LamaticGraphqlResponse | null = null

if (trimmed) {
try {
Expand All @@ -78,7 +117,10 @@ export async function POST(req: NextRequest) {

if (!res.ok) {
const upstreamMessage =
data?.errors?.map((error: any) => error?.message).filter(Boolean).join("; ") ||
data?.errors
?.map((error) => error.message)
.filter(Boolean)
.join("; ") ||
data?.message ||
(trimmed.startsWith("<")
? "Lamatic returned HTML instead of JSON."
Expand Down Expand Up @@ -108,7 +150,7 @@ export async function POST(req: NextRequest) {

if (Array.isArray(data.errors) && data.errors.length > 0) {
const message = data.errors
.map((error: any) => error?.message)
.map((error) => error.message)
.filter(Boolean)
.join("; ")

Expand Down
14 changes: 11 additions & 3 deletions kits/agentic/code-review/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ type ReviewResult = {
style: StyleItem[]
}

type ReviewApiResponse = {
error?: string
summary?: string
bugs?: Finding[]
security?: Finding[]
style?: StyleItem[]
}

export default function Home() {
const [owner, setOwner] = useState("")
const [repo, setRepo] = useState("")
Expand All @@ -33,7 +41,7 @@ export default function Home() {

const raw = await res.text()
const trimmed = raw.trim()
let data: any = null
let data: ReviewApiResponse | null = null

if (trimmed) {
try {
Expand Down Expand Up @@ -69,8 +77,8 @@ export default function Home() {
security: Array.isArray(data.security) ? data.security : [],
style: Array.isArray(data.style) ? data.style : [],
})
} catch (e: any) {
setError(e.message)
} catch (error: unknown) {
setError(error instanceof Error ? error.message : "The review request failed.")
} finally {
setLoading(false)
}
Expand Down
3 changes: 1 addition & 2 deletions kits/agentic/code-review/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
"type": "mandatory",
"envKey": "AGENTIC_GENERATE_CONTENT"
}
]
],
"integrations": ["GitHub", "Groq"],
"demoUrl": "https://agent-kit-stk.vercel.app/",
"githubUrl": "https://github.com/soumik15630m/AgentKit-stk/tree/main/kits/agentic/code-review"
}
}
14 changes: 14 additions & 0 deletions kits/agentic/code-review/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig, globalIgnores } from "eslint/config"
import nextVitals from "eslint-config-next/core-web-vitals"
import nextTs from "eslint-config-next/typescript"

export default defineConfig([
...nextVitals,
...nextTs,
globalIgnores([
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
])
Loading