feat: Add github-auto-fix-agent AgentKit#87
Conversation
WalkthroughAdds a new "GitHub Auto Fix Agent" kit: a Next.js frontend, Lamatic flow and client, server-side orchestration to run flows and create PRs, API routes, UI components/pages, and project/tooling/config files. Changes
Suggested reviewers
🚥 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)
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 |
There was a problem hiding this comment.
Actionable comments posted: 13
🧹 Nitpick comments (4)
kits/agentic/github-auto-fix-agent/flows/github-issue-solver/meta.json (1)
3-8: Populate flow metadata fields for discoverability and maintainability.Leaving
description,testInput, and URLs empty reduces clarity for users consuming this flow package.Suggested improvement
{ "name": "github-issue-solver", - "description": "", - "tags": [], - "testInput": "", - "githubUrl": "", - "documentationUrl": "", - "deployUrl": "" + "description": "Analyzes a GitHub issue, generates a minimal code-fix proposal, and prepares pull request metadata.", + "tags": ["github", "automation", "issue-triage", "code-fix"], + "testInput": "{\"issueUrl\":\"https://github.com/owner/repo/issues/123\"}", + "githubUrl": "https://github.com/Lamatic/AgentKit/tree/main/kits/agentic/github-auto-fix-agent", + "documentationUrl": "https://docs.lamatic.ai", + "deployUrl": "https://agent-kit-beta.vercel.app/" }kits/agentic/github-auto-fix-agent/lib/lamatic-client.ts (1)
3-9: Improve env validation error specificity.The fail-fast check is good, but the current message doesn’t say which variables are missing. Returning exact missing keys will reduce setup/debug time.
♻️ Proposed refinement
-if ( - !process.env.LAMATIC_API_URL || - !process.env.LAMATIC_PROJECT_ID || - !process.env.LAMATIC_API_KEY -) { - throw new Error("Missing Lamatic environment variables"); -} +const requiredLamaticEnv = [ + "LAMATIC_API_URL", + "LAMATIC_PROJECT_ID", + "LAMATIC_API_KEY", +] as const; + +const missingLamaticEnv = requiredLamaticEnv.filter( + (key) => !process.env[key], +); + +if (missingLamaticEnv.length > 0) { + throw new Error( + `Missing Lamatic environment variables: ${missingLamaticEnv.join(", ")}`, + ); +}kits/agentic/github-auto-fix-agent/app/page.tsx (2)
36-49: Error details are discarded, making debugging harder.The API error text is logged but then replaced with a generic "API failed" error. The actual error message from the server is lost when displayed to the user. Consider preserving the server error message for better UX.
♻️ Proposed fix to preserve error details
if (!res.ok) { const text = await res.text(); console.error("API ERROR:", text); - throw new Error("API failed"); + let errorMessage = "API request failed"; + try { + const errorJson = JSON.parse(text); + errorMessage = errorJson.error || errorMessage; + } catch { + errorMessage = text || errorMessage; + } + throw new Error(errorMessage); } const data = await res.json(); setResult(data); } catch (err) { console.error(err); setResult({ success: false, - error: "An unexpected error occurred while processing the request.", + error: err instanceof Error ? err.message : "An unexpected error occurred.", }); }
16-16: Consider adding proper typing forresultstate.Using
anytype loses TypeScript benefits. Define an interface matching the expected API response structure.♻️ Proposed type definition
+interface FixResult { + success: boolean; + pr_url?: string; + analysis?: { summary?: string; root_cause?: string }; + fix?: { explanation?: string; diff?: string }; + error?: string; +} + export default function Home() { const [issueUrl, setIssueUrl] = useState(""); const [filePath, setFilePath] = useState(""); const [loading, setLoading] = useState(false); - const [result, setResult] = useState<any>(null); + const [result, setResult] = useState<FixResult | null>(null);
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a9f20308-5534-48be-b087-c8578c48ef9a
⛔ Files ignored due to path filters (8)
kits/agentic/github-auto-fix-agent/app/favicon.icois excluded by!**/*.icokits/agentic/github-auto-fix-agent/package-lock.jsonis excluded by!**/package-lock.jsonkits/agentic/github-auto-fix-agent/public/file.svgis excluded by!**/*.svgkits/agentic/github-auto-fix-agent/public/flows.pngis excluded by!**/*.pngkits/agentic/github-auto-fix-agent/public/globe.svgis excluded by!**/*.svgkits/agentic/github-auto-fix-agent/public/next.svgis excluded by!**/*.svgkits/agentic/github-auto-fix-agent/public/vercel.svgis excluded by!**/*.svgkits/agentic/github-auto-fix-agent/public/window.svgis excluded by!**/*.svg
📒 Files selected for processing (24)
kits/agentic/github-auto-fix-agent/.env.examplekits/agentic/github-auto-fix-agent/.gitignorekits/agentic/github-auto-fix-agent/README.mdkits/agentic/github-auto-fix-agent/actions/orchestrate.tskits/agentic/github-auto-fix-agent/app/api/fix/route.tskits/agentic/github-auto-fix-agent/app/globals.csskits/agentic/github-auto-fix-agent/app/layout.tsxkits/agentic/github-auto-fix-agent/app/page.tsxkits/agentic/github-auto-fix-agent/components/BackgroundDecoration.tsxkits/agentic/github-auto-fix-agent/components/ErrorResult.tsxkits/agentic/github-auto-fix-agent/components/Footer.tsxkits/agentic/github-auto-fix-agent/components/Header.tsxkits/agentic/github-auto-fix-agent/components/IssueForm.tsxkits/agentic/github-auto-fix-agent/components/SuccessResult.tsxkits/agentic/github-auto-fix-agent/eslint.config.mjskits/agentic/github-auto-fix-agent/flows/github-issue-solver/README.mdkits/agentic/github-auto-fix-agent/flows/github-issue-solver/config.jsonkits/agentic/github-auto-fix-agent/flows/github-issue-solver/inputs.jsonkits/agentic/github-auto-fix-agent/flows/github-issue-solver/meta.jsonkits/agentic/github-auto-fix-agent/lib/lamatic-client.tskits/agentic/github-auto-fix-agent/next.config.tskits/agentic/github-auto-fix-agent/package.jsonkits/agentic/github-auto-fix-agent/postcss.config.mjskits/agentic/github-auto-fix-agent/tsconfig.json
kits/agentic/github-auto-fix-agent/flows/github-issue-solver/config.json
Show resolved
Hide resolved
kits/agentic/github-auto-fix-agent/flows/github-issue-solver/config.json
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (4)
kits/agentic/github-auto-fix-agent/actions/orchestrate.ts (3)
76-140:⚠️ Potential issue | 🟠 MajorValidate GitHub API responses before consuming JSON.
Line 76 onward assumes success for repo/ref/file/update calls. A 401/404/422 currently propagates as malformed data instead of a clear failure at the source.
🔧 Proposed fix (centralized GitHub fetch with status checks)
+ async function githubFetch(url: string, options?: RequestInit) { + const res = await fetch(url, { + ...options, + headers: { + Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, + "Content-Type": "application/json", + ...(options?.headers || {}), + }, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) { + throw new Error( + `GitHub API error (${res.status}): ${ + (data as { message?: string })?.message || "Unknown error" + }` + ); + } + return data; + }Then replace direct
fetch(...).then(res => res.json())/uncheckedfetch(...)calls withgithubFetch(...).
100-110:⚠️ Potential issue | 🟠 MajorHandle existing-branch (422) as an idempotent path.
Line 100 creates the branch but does not handle “Reference already exists”. Re-running the flow for the same issue should continue safely.
160-165:⚠️ Potential issue | 🟠 MajorConfirm PR creation succeeded before returning success.
Line 162 returns success even when GitHub rejects PR creation (e.g., validation/permission errors), which can produce
pr_url: undefined.🔧 Proposed fix
const prData = await prRes.json(); + if (!prRes.ok || !prData?.html_url) { + throw new Error( + `Failed to create PR: ${prData?.message || "Unknown GitHub error"}` + ); + } + return { success: true, pr_url: prData.html_url, };kits/agentic/github-auto-fix-agent/components/SuccessResult.tsx (1)
195-209:⚠️ Potential issue | 🔴 CriticalSanitize diff content before
dangerouslySetInnerHTMLto prevent XSS.Lines 195-209 inject raw LLM output into HTML. Prompt-injected
<script>/event handlers can execute in-browser.🔧 Proposed fix
+function escapeHtml(text: string): string { + return text + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); +} + +function formatDiff(diff: string): string { + return diff + .split("\n") + .map((line) => { + const safe = escapeHtml(line); + if (line.startsWith("+")) + return `<span class="text-[`#3FB950`] bg-[`#2EA04326`] block w-full px-3 -mx-3 rounded">${safe}</span>`; + if (line.startsWith("-")) + return `<span class="text-[`#F85149`] bg-[`#F8514926`] block w-full px-3 -mx-3 rounded">${safe}</span>`; + return `<span class="text-slate-400 block px-3 -mx-3">${safe}</span>`; + }) + .join("\n"); +} ... - __html: result.fix?.diff - ? result.fix.diff.replace( - /^(.*?)$/gm, - (line: string) => { - if (line.startsWith("+")) - return `<span class="text-[`#3FB950`] bg-[`#2EA04326`] block w-full px-3 -mx-3 rounded">${line}</span>`; - if (line.startsWith("-")) - return `<span class="text-[`#F85149`] bg-[`#F8514926`] block w-full px-3 -mx-3 rounded">${line}</span>`; - return `<span class="text-slate-400 block px-3 -mx-3">${line}</span>`; - } - ) + __html: result.fix?.diff + ? formatDiff(result.fix.diff) : "No diff available.",
🧹 Nitpick comments (2)
kits/agentic/github-auto-fix-agent/app/api/create-pr/route.ts (1)
20-20: Consider mapping handler failures to non-200 HTTP status codes.Line 20 always returns 200 even when
result.successis false. Returning 4xx/5xx here simplifies client-side error handling and observability.kits/agentic/github-auto-fix-agent/components/SuccessResult.tsx (1)
42-47: Pre-validate required PR fields before enabling submit.Line 42 checks only
result.probject presence; missingbranch_name/pr_title/etc. still sends a request that will fail downstream. Validate nested fields and disable the button when incomplete.Also applies to: 116-119
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 368e84fc-9763-4963-9880-29dbac2f768e
📒 Files selected for processing (6)
kits/agentic/github-auto-fix-agent/actions/orchestrate.tskits/agentic/github-auto-fix-agent/app/api/create-pr/route.tskits/agentic/github-auto-fix-agent/app/page.tsxkits/agentic/github-auto-fix-agent/components/Header.tsxkits/agentic/github-auto-fix-agent/components/IssueForm.tsxkits/agentic/github-auto-fix-agent/components/SuccessResult.tsx
✅ Files skipped from review due to trivial changes (1)
- kits/agentic/github-auto-fix-agent/components/Header.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- kits/agentic/github-auto-fix-agent/components/IssueForm.tsx
- kits/agentic/github-auto-fix-agent/app/page.tsx
|
Please Resolve all the comments before proceeding. |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
kits/agentic/github-auto-fix-agent/actions/orchestrate.ts (1)
79-169:⚠️ Potential issue | 🟠 MajorMission-critical: abort on GitHub API failures instead of marching on.
Lines 80-164 still parse every GitHub response as JSON and continue. A 401/404/422 here turns into
undefinedbranch/SHA state, and Line 166 can still returnsuccess: truewith no realpr_url. Centralize these calls behind a helper that checksres.ok, and only special-case422 Reference already existsif branch reuse is intentional.Suggested fix
+ async function githubFetch(url: string, init?: RequestInit) { + const res = await fetch(url, { + ...init, + headers: { + Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, + "Content-Type": "application/json", + ...init?.headers, + }, + }); + + const data = await res.json(); + + if (!res.ok) { + throw new Error( + `GitHub API error (${res.status}): ${data?.message ?? "Unknown error"}`, + ); + } + + return data; + }Use this helper for the repo, ref, file, branch-creation, and PR-creation calls. If branch reuse is expected, wrap just the ref-creation call with an explicit
422 Reference already existsexception.Run this to inspect the current call sites and confirm there are no status checks in
handleCreatePR:#!/bin/bash rg -n -C2 'fetch\(|\.then\(\(res\) => res\.json\(\)\)|await prRes\.json\(\)|\.ok|status' \ kits/agentic/github-auto-fix-agent/actions/orchestrate.ts🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@kits/agentic/github-auto-fix-agent/actions/orchestrate.ts` around lines 79 - 169, The GitHub API fetches (producing repoData, refData, fileData, the branch-creation POST, the file PUT, and prRes/prData) must validate HTTP status before parsing JSON and proceeding; add a shared helper (e.g., checkAndParseResponse) that checks res.ok and throws an informative error including status/text when false, use it for the repo/ref/file/PUT/PR calls, and special-case the ref-creation call to catch and ignore a 422 "Reference already exists" only if branch reuse is intended; also ensure the final return only reports success when prData.html_url is present (otherwise throw/return failure).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@kits/agentic/github-auto-fix-agent/config.json`:
- Around line 24-26: The deployUrl in config.json is pointing to a personal fork
(RitoG09/AgentKit); update the "deployUrl" value to reference the canonical
repository (Lamatic/AgentKit) so deployments clone the official source (i.e.,
replace any occurrence of "https://github.com/RitoG09/AgentKit" with
"https://github.com/Lamatic/AgentKit" in the "deployUrl" field).
---
Duplicate comments:
In `@kits/agentic/github-auto-fix-agent/actions/orchestrate.ts`:
- Around line 79-169: The GitHub API fetches (producing repoData, refData,
fileData, the branch-creation POST, the file PUT, and prRes/prData) must
validate HTTP status before parsing JSON and proceeding; add a shared helper
(e.g., checkAndParseResponse) that checks res.ok and throws an informative error
including status/text when false, use it for the repo/ref/file/PUT/PR calls, and
special-case the ref-creation call to catch and ignore a 422 "Reference already
exists" only if branch reuse is intended; also ensure the final return only
reports success when prData.html_url is present (otherwise throw/return
failure).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 9451aa97-e843-45d1-bc24-de42081095a9
📒 Files selected for processing (3)
kits/agentic/github-auto-fix-agent/.env.examplekits/agentic/github-auto-fix-agent/actions/orchestrate.tskits/agentic/github-auto-fix-agent/config.json
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@kits/agentic/github-auto-fix-agent/config.json`:
- Line 27: The config.json is missing a usable documentation URL (the
documentationUrl field is empty); update the documentationUrl value in
kits/agentic/github-auto-fix-agent/config.json to a valid, reachable
documentation link (e.g., the kit's README or docs page) so the kit metadata
includes a non-empty documentationUrl; ensure the string is a full URL and
follows the same format as other kits' documentationUrl fields to satisfy the
required metadata fields (name, description, tags, author, steps,
documentationUrl).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8875a0f0-764f-4928-97ce-767be2fc544d
📒 Files selected for processing (1)
kits/agentic/github-auto-fix-agent/config.json
@amanintech Done, can you please check once and give feedback accordingly? |
What This Kit Does
This kit automatically analyzes GitHub issues and generates intelligent code fixes along with ready-to-use pull request metadata.
It solves the problem of manually debugging issues by:
Instead of spending time manually fixing minimal bugs, developers can review AI-suggested changes and create PRs in seconds.
Providers & Prerequisites
Providers
Prerequisites
repopermissionsRequired Environment Variables
How to Run Locally
cd kits/agentic/github-auto-fix-agentnpm installcp .env.example .envand fill in valuesnpm run devLive Preview
https://agent-kit-beta.vercel.app/
Lamatic Flow
Flow ID: b232a0d5-1bbd-44dd-96a1-33a3b98615b8
Checklist
npm run dev.env.examplehas no secrets, only placeholdersREADME.mddocuments setup and usagekits/<category>/<kit-name>/config.jsonis present and validflows/folderOverview
Files added (paths)
Flow (flows/github-issue-solver/config.json) — node types and behavior
High-level flow summary
Orchestration & integrations