diff --git a/kits/ai-pr-reviewer/README.md b/kits/ai-pr-reviewer/README.md new file mode 100644 index 000000000..3c7fcef7d --- /dev/null +++ b/kits/ai-pr-reviewer/README.md @@ -0,0 +1,19 @@ +# AI PR Code Reviewer & Security Auditor + +An agentic workflow built on **Lamatic.ai AgentKit** designed to automate Pull Request reviews. This agent acts as a first line of defense in CI/CD pipelines by analyzing code snippets or git diffs for security vulnerabilities and performance improvements. + +## The Problem +Manual code reviews are time-consuming, and senior engineers often waste hours pointing out basic linting errors or missing security checks. + +## The Solution (This Agent) +By integrating this AgentKit flow into a webhook or CI pipeline, development teams get instant, structured feedback on their code before a human ever looks at it. + +## Features +- **Security Audit:** Flags OWASP top 10 vulnerabilities (e.g., SQL injection, hardcoded secrets). +- **Code Optimization:** Suggests specific refactors for time/space complexity. +- **Structured JSON Output:** Returns actionable data that can be parsed directly into GitHub PR comments. + +## Workflow Structure +1. **Trigger:** Receives raw code or a git diff. +2. **Review Node (LLM):** A highly constrained prompt evaluates the code against strict engineering standards. +3. **Formatting Node:** Outputs a structured JSON payload with `vulnerabilities`, `refactor_suggestions`, and a `pass_fail` boolean. diff --git a/kits/ai-pr-reviewer/agent.md b/kits/ai-pr-reviewer/agent.md new file mode 100644 index 000000000..bedb65ee2 --- /dev/null +++ b/kits/ai-pr-reviewer/agent.md @@ -0,0 +1,2 @@ +# AI PR Code Reviewer +This agent automatically reviews code for security vulnerabilities and performance bottlenecks, acting as a first line of defense in your CI/CD pipeline. diff --git a/kits/ai-pr-reviewer/constitutions/default.md b/kits/ai-pr-reviewer/constitutions/default.md new file mode 100644 index 000000000..11994e322 --- /dev/null +++ b/kits/ai-pr-reviewer/constitutions/default.md @@ -0,0 +1,4 @@ +# Default Constitution +1. Always prioritize identifying security vulnerabilities. +2. Provide specific, actionable refactoring suggestions. +3. Be polite and concise in GitHub PR comments. diff --git a/kits/ai-pr-reviewer/flows/code-review.ts b/kits/ai-pr-reviewer/flows/code-review.ts new file mode 100644 index 000000000..f8a9e0888 --- /dev/null +++ b/kits/ai-pr-reviewer/flows/code-review.ts @@ -0,0 +1,37 @@ +export default { + "name": "Automated Code Review Flow", + "description": "Analyzes input code snippets for security vulnerabilities and optimization opportunities.", + "nodes": [ + { + "id": "input_code", + "type": "trigger", + "label": "Code Snippet Input", + "config": { + "inputType": "text", + "placeholder": "Paste your code snippet or git diff here..." + } + }, + { + "id": "llm_auditor", + "type": "llm", + "label": "DevSecOps LLM", + "config": { + "model": "gpt-4o", + "temperature": 0.1, + "systemPrompt": "You are a Principal Security Engineer and strict code reviewer. Analyze the provided code. Output a JSON object containing: 1) 'pass_fail' (boolean), 2) 'vulnerabilities' (array of strings, empty if none), 3) 'optimizations' (array of specific refactoring suggestions), and 4) 'pr_comment' (a polite markdown summary of your review ready for GitHub)." + } + }, + { + "id": "output_report", + "type": "response", + "label": "CI/CD JSON Response", + "config": { + "format": "json" + } + } + ], + "edges": [ + { "source": "input_code", "target": "llm_auditor" }, + { "source": "llm_auditor", "target": "output_report" } + ] +}; diff --git a/kits/ai-pr-reviewer/lamatic.config.ts b/kits/ai-pr-reviewer/lamatic.config.ts new file mode 100644 index 000000000..be14d8133 --- /dev/null +++ b/kits/ai-pr-reviewer/lamatic.config.ts @@ -0,0 +1,12 @@ +export default { + id: "ai-pr-reviewer", + name: "AI PR Code Reviewer & Security Auditor", + description: "An automated agent that analyzes git diffs or code snippets for security vulnerabilities, performance bottlenecks, and clean-code refactoring.", + type: "template", + author: "Sushobhita Majhi", + category: "Developer Tools / CI-CD", + tags: ["LLM", "Code Review", "DevSecOps", "Agentic Workflow"], + links: { + github: "kits/ai-pr-reviewer" + } +};