Skip to content

five00miles/commit-ai-lite

Repository files navigation

CommitAI Lite

简体中文

A minimal VS Code extension that turns Git diffs into clean AI-generated commit messages.

It reads the selected Git diff, calls an OpenAI-compatible /chat/completions API, and writes the generated message back to VS Code's commit input box. It never commits code automatically.

Usage Example

CommitAI Lite usage example

Features

  • Adds a generate action to the Source Control title menu
  • Defaults to staged changes so generated messages describe what will actually be committed
  • Can use staged-only, smart fallback, or full working tree diff modes
  • Adds diff stats, changed file status, recent commit subjects, and optional project style files to the model context
  • Uses file-aware diff summarization instead of simple character truncation for large changes
  • Supports OpenAI-compatible services such as OpenAI, DeepSeek, Qwen-compatible gateways, SiliconFlow, and OpenRouter
  • Configures provider, diff mode, language, format, body policy, and custom prompt directly in VS Code Settings
  • Defaults to Chinese Conventional Commits style messages

Configuration

Configure the extension in VS Code Settings JSON:

{
  "commitAILite.baseUrl": "https://api.openai.com/v1",
  "commitAILite.apiKey": "your-api-key",
  "commitAILite.model": "gpt-4o-mini",
  "commitAILite.diffMode": "staged",
  "commitAILite.language": "zh-CN",
  "commitAILite.format": "conventional",
  "commitAILite.includeBody": "auto",
  "commitAILite.customPrompt": "Please generate a Git commit message in Chinese that follows Conventional Commits.",
  "commitAILite.maxDiffChars": 12000
}

commitAILite.diffMode controls which changes are sent to the model:

  • staged: only staged changes; this is the default and recommended mode
  • smart: staged changes when present, otherwise unstaged and untracked changes
  • workingTree: staged, unstaged, and untracked changes together

To tune project-specific style, add .commitai.md or COMMITS.md at the repository root. CommitAI Lite will include the first matching file as extra style guidance.

DeepSeek example:

{
  "commitAILite.baseUrl": "https://api.deepseek.com/v1",
  "commitAILite.model": "deepseek-chat"
}

Local Development

Run checks:

npm test

Open this project in VS Code, press F5, and choose Run Extension to start an Extension Development Host.

For Marketplace compatibility, CommitAI Lite uses the stable scm/title menu contribution instead of the proposed scm/inputBox contribution.

Notes

  • commitAILite.apiKey is stored directly in VS Code Settings for simplicity. Treat your settings file as sensitive.
  • The extension only calls OpenAI-compatible /chat/completions; it does not include provider-specific adapters.
  • The extension only generates commit messages. It does not run git commit.
  • Before publishing, replace "publisher": "local" in package.json with your real Visual Studio Marketplace publisher ID.

License

MIT

About

Generate clean AI commit messages from Git diffs with your own OpenAI-compatible API key.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors