Skip to content

anugotta/lmstudio-code-review-gerrit-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Code Review Gerrit Plugin using LM Studio Server

Disclaimer: This project is not affiliated with LM Studio or its creators.

In this project I have modified the original Gerrit AI Code Review plugin to include native support for LM Studio Server, allowing use of locally-hosted language models for code reviews in Gerrit.

What's New

  • LM Studio Server Support
  • Local Model Support: Run code reviews entirely on your local system / server using LM Studio
  • Better Tool support: Compared to OLLAMA, LM Studio supports better tool call integration through tool choices enforcement

Limitations

Due to code changes for LM Studio, ChatGPT and OLLAMA integrations may not work in this version. Support for these services will get restored in a future release. If you need ChatGPT or OLLAMA, please use the original plugin. This plugin currently supports only stateless mode.


Features

After submitting a Patch Set, the AI service will provide review feedback in the form of comments and, optionally, a vote. You can continue to ask the AI Chat by @{gerritUserName} or @{gerritEmailAddress} (provided that gerritEmailAddress is in the form "gerritUserName@<any_email_domain>") in the comments to further guide it in generating more targeted review comments.

Reviews can be also triggered by directing a comment with the /review command which will be interpreted and sent on by the plugin.

Getting Started

  1. Build: Requires JDK 11 or higher, Maven 3.0 or higher.

    mvn -U clean package

    If the user needs to disable test just run

    mvn -U -DskipTests=true clean package
  2. Install: Upload the compiled jar file to the $gerrit_site/plugins directory.

    Important: If you're replacing the original ai-code-review plugin, make sure to remove the old JAR first:

    # Stop Gerrit (if running)
    rm $GERRIT_SITE/plugins/ai-code-review*.jar
    
    # Copy the new plugin
    cp target/ai-code-review-lmstudio-*.jar $GERRIT_SITE/plugins/
    
    # Start Gerrit
  3. Configure: First, you need to create an AI Code Review user in Gerrit. Then, set up the basic parameters in your $gerrit_site/etc/gerrit.config file under the section

    [plugin "ai-code-review-lmstudio"]

    If you're migrating from the original plugin, update your configuration section name from [plugin "ai-code-review"] to [plugin "ai-code-review-lmstudio"].

    Configuration parameters:

  • gerritUserName: Gerrit username of AI Code Review user.
  • globalEnable: Default value is false. The plugin will only review specified repositories. If set to true, the plugin will by default review all pull requests.
  1. Verify: After restarting Gerrit, you can see the following information in Gerrit's logs:

    INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin ai-code-review-lmstudio, version 1.0.0

    You can also check the status of the ai-code-review-lmstudio on Gerrit's plugin page as Enabled.

Setup of LM Studio

  1. Install LM Studio: Download and install from https://lmstudio.ai/
  2. Download a Model: Use LM Studio's interface to download a code-review capable model (e.g., CodeLlama, DeepSeek Coder, or similar). Make sure the model has tool support.
  3. Start the Local Server: In LM Studio, start the local server (typically runs on http://localhost:1234)
  4. Configure the Plugin: See the LM Studio configuration example below

Example Configuration for LM Studio

   [plugin "ai-code-review-lmstudio"]
      # Core AI settings
      isEnabled = true
      aiType = GENERIC
      aiDomain = http://10.50.200.55:1234/
      # aiChatEndpoint = /v1/chat/completions
      aiModel = qwen/qwen3-coder-30b
      # Note: aiToken might not be needed for local Ollama, but keep for compatibility
      aiToken = dummy-token-for-local
   	
      # Gerrit integration settings
      gerritUserName = ai-code-reviewer # Replace with your bot name and email
      gerritUserEmail = ai-reviewer@localhost
      globalEnable = true 
   	
      # Trigger configuration - THIS IS CRITICAL
      trigger = patchset-created
      aiReviewPatchSet = true
      aiReviewCommitMessages = true
      gptFullFileReview = true
      aiUsePositiveSeed = true
   	
      # Voting and scoring
      enabledVoting = true
      votingMinScore = -1
      votingMaxScore = 1
   	
      # AI behavior settings
      aiStreamOutput = false
      aiReviewTemperature = 0.2
   	
      # Content filtering and limits
      maxReviewLines = 5000
      maxReviewFileSize = 1048576
   	
      # Optional Custom prompt for better code reviews
      # aiSystemPrompt = Act like a Lead developer.

Usage Examples

Usage examples, configurations and params are same as AI Code Review Gerrit Plugin. Please be aware of this plugin's limitations cited under Limitations above

Contributing

Contributions are welcome! If you find bugs or have feature requests related to LM Studio Server support, please open an issue or submit a pull request.

License

Apache License 2.0