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.
- 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
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 modesmart: staged changes when present, otherwise unstaged and untracked changesworkingTree: 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"
}Run checks:
npm testOpen 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.
commitAILite.apiKeyis 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"inpackage.jsonwith your real Visual Studio Marketplace publisher ID.
