Skip to content

ognjenvujovic04/git-message-plugin

Repository files navigation

Commit Message Assistant

An IntelliJ-based IDE plugin that generates and improves Git commit messages using LLMs via the Groq API. It analyzes staged diffs, branch context, and recent commit history to produce commit messages that match the project's existing style.

Features

  • AI-powered commit message generation -- click a single button on the commit toolbar to generate a message from your staged changes, or improve an existing draft.
  • Three message styles -- Short (single line), Long (subject + detailed body), and Conventional Commits 1.0.0 format. Selectable from a dropdown on the commit toolbar.
  • Style memory -- reads the last 5 commit subjects from the repository and instructs the model to match the project's existing conventions (prefix patterns, scope names, capitalization, tone).
  • Diff-aware context -- collects git diff --stat, unified diff (with 3 lines of context), changed file paths, branch name, and optionally a ticket ID extracted from the branch name via regex.
  • Diff truncation -- large diffs are truncated at 40,000 characters to stay within model context limits.
  • Secure API key storage -- uses IntelliJ's Password Safe for credential storage, with fallback to the GROQ_API_KEY environment variable.
  • Configurable model -- defaults to llama-3.3-70b-versatile; includes presets for llama-3.1-8b-instant and llama-4-scout-17b-16e-instruct; accepts any Groq model ID.

How It Works

  1. The user opens the Commit tool window with at least one included change.
  2. Optionally selects a commit message style (Short / Long / Conventional) from the toolbar dropdown.
  3. Clicks AI Generate (if the message field is empty) or AI Improve (if there is existing text).
  4. The plugin collects context in the background:
    • Resolves the Git repository and relative paths for all included changes.
    • Runs git diff (prefers cached/staged; falls back to unstaged).
    • Retrieves git log -n 5 --pretty=%s for style memory.
    • Extracts a ticket ID from the branch name (pattern: [A-Z][A-Z0-9_]+-\d+).
  5. A prompt template is populated with the collected context and sent to the Groq Chat Completions API.
  6. The model response replaces the commit message in the editor.

Requirements

  • IntelliJ IDEA 2025.2 or later (build 252+)
  • Git plugin (bundled with IntelliJ)
  • A Groq API key (free tier available)

Installation

From source

git clone https://github.com/ognjenvujovic04/git-message-plugin.git
cd git-message-plugin
./gradlew runIde

This launches a sandboxed IDE instance with the plugin installed.

Building the plugin archive

./gradlew buildPlugin

The distributable .zip is generated in build/distributions/. It can be installed in any compatible JetBrains IDE via Settings > Plugins > Install Plugin from Disk.

Configuration

Navigate to Settings > Version Control > Commit Message Assistant.

Setting Description
API Key Your Groq API key. Stored in IntelliJ Password Safe. If left empty, falls back to GROQ_API_KEY environment variable.
Model The Groq model ID to use. Choose from presets or enter a custom model ID.

Project Structure

src/main/kotlin/io/github/ognjenvujovic04/gitmessage/
  ai/
    CommitContext.kt              Data class holding all collected context
    CommitContextCollector.kt     Gathers diffs, branch info, and commit history via Git4Idea
    GroqClient.kt                 HTTP client for the Groq Chat Completions API
    PromptRenderer.kt             Loads and populates prompt templates
  commit/
    CommitMessageStyle.kt         Enum: SHORT, LONG, CONVENTIONAL
    CommitMessageStyleGroup.kt    Toolbar dropdown for style selection
    CommitMessageStyleSettings.kt Persists the selected style
    SelectCommitMessageStyleAction.kt  Individual toggle actions per style
    ImproveCommitMessageAction.kt Main toolbar action (generate/improve)
  icons/
    GitMessageIcons.kt            Icon loader
  settings/
    GitMessageConfigurable.kt     Settings UI panel
    GitMessageCredentials.kt      API key resolution (Password Safe + env)
    GitMessageModelSettings.kt    Model ID persistence and presets
  GitMessageBundle.kt             i18n resource bundle

src/main/resources/
  META-INF/plugin.xml             Plugin descriptor
  icons/                          Toolbar icons (light + dark)
  messages/GitMessageBundle.properties  UI strings and error messages
  prompt_templates/               Prompt templates (short.txt, long.txt, conventional.txt)

Tech Stack

  • Language: Kotlin (2.3.20), JVM toolchain 21
  • Platform: IntelliJ Platform SDK (2025.2)
  • Build: Gradle 9.4.1 with Kotlin DSL, IntelliJ Platform Gradle Plugin 2.13.1
  • AI Provider: Groq API (OpenAI-compatible Chat Completions endpoint)
  • Dependencies: Git4Idea (bundled), Gson (bundled with IntelliJ Platform)

Design Decisions

  • Groq as the AI provider -- Groq offers a free tier with fast inference on open-weight models (Llama 3.3 70B, Llama 4 Scout), making it accessible without requiring paid API keys. The OpenAI-compatible endpoint keeps the integration straightforward and swappable.
  • Style memory via git log -- rather than asking the user to configure a commit style, the plugin reads the last 5 commit subjects and instructs the model to match the existing conventions. This makes the generated messages feel natural within the project without manual setup.
  • Prompt templates as resource files -- each commit style has its own .txt template with placeholders, making it easy to iterate on prompt engineering without touching Kotlin code.
  • No external dependencies -- the plugin uses only java.net.http.HttpClient (standard library) and Gson (bundled with the platform), avoiding dependency management complexity.
  • Single-repository constraint -- the plugin requires all included changes to belong to one Git repository, simplifying context collection and avoiding ambiguous diffs in multi-repo setups.

License

See CODE_OF_CONDUCT.md for the community code of conduct.

About

AI-powered IntelliJ plugin that generates and improves Git commit messages using Groq LLMs, with diff-aware context and automatic style matching from project history.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages