Skip to content

6pm/ai-local-code-review-tool

Repository files navigation

Code Review Tool

A tool for automated code reviews using local LLM models through Ollama. It fetches pull requests and performs code reviews file by file. You can customize the review process by modifying the guidelines in "guidelines/review-guidelines.md". The tool supports multiple models, allowing you to compare their review results. Review results will be saved in files named "temp/review-{MODEL_NAME}.txt".

Features

  • Fetches pull request diffs from Bitbucket and reviews files individually
  • Performs automated code reviews using local LLM models
  • Customizable review guidelines stored in "guidelines/review-guidelines.md"
  • Saves review results to separate files for each model
  • Configurable context length using MAX_CONTEXT_LENGTH environment variable (default: 20K tokens)

Prerequisites

Step 1: Setup Ollama

  1. Install Ollama

  2. Download the model you want to use, for example 'qwen2.5-coder':

ollama pull qwen2.5-coder:7b

The download might take a few minutes depending on the model size. Once completed, add the environment variable to the .env file in the root folder:

For a single model:

MODEL_NAME='qwen2.5-coder:7b'

For multiple models (comma-separated):

MODEL_NAME='qwen2.5-coder:14b,codellama:13b,mixtral:8x7b'

Step 2: Configure Bitbucket Access

Follow the instructions in the Bitbucket setup guide. After setup, add these variables to your .env file:

BITBUCKET_USERNAME='your-username'
BITBUCKET_APP_PASSWORD='your-app-password'

Step 3: Configure Pull Request and Optional Parameters

Add your Bitbucket pull request URL to the environment variables:

PULL_REQUEST_URL='https://bitbucket.org/your-repo/pull-requests/123/diff'

The context length is an optional parameter. The default value is 20K tokens. You can extend it by setting the environment variable:

MAX_CONTEXT_LENGTH=32768

Step 4: Customize Review Guidelines

Modify the guidelines file to match your project's requirements: guidelines/review-guidelines.md

Running the Application

pnpm i    # Install dependencies
pnpm start # Start the review process

Output

The review results will be saved in separate files under the temp directory, with filenames following the pattern review-${MODEL_NAME}.txt.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published