Inspiration

When we started experimenting with AI, the topic of code review came up really fast. We ourselves have sometimes had to spend quite some time explaining some code changes to less technical team members or to engineers less comfortable with certain frameworks. It also happens that we realize too late that some parts of our code could have been refactored. Therefore, we strongly believe a targeted use of AI for these use cases and more is a huge value added for reviewers within our team. We are excited to bring this to other developers!

What it does

It allows you to ask questions related to your Pull Request to an AI that knows all about its context (commits, code changes, etc). The key value is you do not need to provide context explicitly, it already knows! It is a great assistant to explain code changes, suggest better code and check for code issues & vulnerabilities.

How we built it

We do like Scala, therefore we tried to see if we can build our app in ScalaJS for Forge. All our source for the app is written in Scala, the backend as well as the CustomUI frontend. The source code then gets compiled to JavaScript which Forge will use.

We had these challenges:

  • Without type information, Scala is hard to write. Therefore, we used ScalablyTyped to translate the TypeScript type definitions to Scala type definitions. It works for most Forge APIs.
  • The time limits emposed by Forge are a challenge, as the AI processing can take a long time. We used a Forge Queue/Events to give us a higher limit. However, it sometimes still runs into timeouts.
  • For the CustomUI, we're also using ScalaJS with vite.js for quickly reloading code changes.

Challenges we ran into

The main challenge was to pass the context to the AI so it brings an actual value added in the context of a Pull Request. That challenge was 2-fold:

  • complying with the payload size limit accepted by the OpenAI API

  • providing the context in a format properly processed by the model

Accomplishments that we're proud of

A feature we are really proud about is the ability to use in-line comments in your code where the AI knows exactly where you are and what the line is about. It is very helpful when struggling with specific parts of the code.

What we learned

The AI is especially helpful in breaking down the purpose of complicated code and refactoring code snippets. We were actually surprise by the relevance of the answers we got during our early test phases and we are confident users will have the same experience.

In our experience, the quality of feedback is less consistent when it comes to security assessments of the code where the results, even though possibly helpful, need to be considered with extra caution and does not replace other static code analysis tools.

What's next for Mibex

We will be adding this feature to one of our existing apps - Code Review Assistant. Don’t hesitate to try it out for your Data Center repositories! And stay tuned for our new projects for PR automations.

Built With

Share this project:

Updates