MCPcopy Index your code
hub / github.com/Evobaso-J/ai-gitlab-code-review

github.com/Evobaso-J/ai-gitlab-code-review @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
32 symbols 81 edges 33 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

AI Code Reviewer

Gitlab AI Code Review is a JS script that leverages OpenAI's GPT-3.5-turbo to automatically review code changes in GitLab repositories. It listens for merge request and push events, fetches the associated code changes, and provides feedback on the changes in a Markdown format.

Features

  • Automatically reviews code changes in GitLab repositories
  • Provides feedback on code clarity, simplicity, bugs, and security issues
  • Generates Markdown-formatted responses for easy readability in GitLab

Prerequisites

Installation

  1. Clone the repository:
https://github.com/Evobaso-J/ai-gitlab-code-review
cd ai-code-reviewer
  1. Create a .env file by copying the .env.example file and set the required environment variables:
OPENAI_API_KEY=<your OpenAI API key>
GITLAB_TOKEN=<your GitLab API token>
GITLAB_URL=https://gitlab.com/api/v4
AI_MODEL=<an AI model from the ones supported by OpenAI>
  • OPEN_API_KEY is your ChatGPT account’s key
  • GITLAB_TOKEN is a personal gitlab account token. You can create it here and it can be either be your own personal token or a token from a gitlab account created ad hoc
  • GITLAB_URL it’s the latest gitlab’s api version url, currently https://gitlab.com/api/v4
  • AI_MODEL is the model you want to use from OpenAI. You can use gpt-3.5-turbo or any other model supported by OpenAI.

Docker

You can use Docker to run the application:

  1. Build the Docker image:
docker compose build
  1. Run the Docker container:
docker compose up -d

Usage

  1. Configure your GitLab repository to send webhook events to the AI Code Reviewer application by following GitLab's webhook documentation.

  2. The AI Code Reviewer application will automatically review code changes in your GitLab repository and provide feedback as comments on merge requests and commit diffs.

Available Scripts

In the project directory, you can run:

npm run dev

To start the app in dev mode.\ Open http://localhost:3000 to view it in the browser.

npm start

For production mode

npm run test

Run the test cases.

Learn More

To learn Fastify, check out the Fastify documentation.

Extension points exported contracts — how you extend this code

FastifyInstance (Interface)
(no doc)
fastify.d.ts
TestContext (Interface)
(no doc)
test/helper.ts
BuildPromptParameters (Interface)
(no doc)
src/prompt/index.ts
GitLabWebhookRequest (Interface)
(no doc)
src/routes/gitlab-webhook/index.ts
FastifyInstance (Interface)
(no doc)
src/routes/gitlab-webhook/index.ts
FetchBranchParams (Interface)
(no doc)
src/routes/gitlab-webhook/services.ts
FetchPreEditFilesParams (Interface)
(no doc)
src/routes/gitlab-webhook/services.ts
OldFileVersion (Interface)
(no doc)
src/routes/gitlab-webhook/services.ts

Core symbols most depended-on inside this repo

buildPrompt
called by 2
src/prompt/index.ts
config
called by 1
test/helper.ts
build
called by 1
test/helper.ts
buildAnswer
called by 1
src/prompt/index.ts
handleMergeRequestHook
called by 1
src/routes/gitlab-webhook/hookHandlers.ts
buildCommentPayload
called by 1
src/routes/gitlab-webhook/hookHandlers.ts
postAIReview
called by 1
src/routes/gitlab-webhook/postAIReview.ts
fetchBranchDiff
called by 1
src/routes/gitlab-webhook/services.ts

Shape

Function 14
Interface 11
Class 6
Method 1

Languages

TypeScript100%

Modules by API surface

src/routes/gitlab-webhook/services.ts8 symbols
src/routes/gitlab-webhook/types.ts6 symbols
test/helper.ts3 symbols
src/routes/gitlab-webhook/index.ts3 symbols
src/prompt/index.ts3 symbols
src/config/errors.ts3 symbols
src/routes/gitlab-webhook/hookHandlers.ts2 symbols
src/routes/root.ts1 symbols
src/routes/gitlab-webhook/postAIReview.ts1 symbols
src/app.ts1 symbols
fastify.d.ts1 symbols

For agents

$ claude mcp add ai-gitlab-code-review \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page