MonoCommit
MonoCommit 是一个面向 VS Code 的 AI 提交助手。
它会读取你选中的 Git 变更,自动提炼出符合 Conventional Commits 风格的 type、title 和 description,然后一键完成提交。
适合谁
- 想更快写出规范 commit message 的开发者
- 希望减少手动整理改动说明的人
- 习惯使用国内模型或本地模型的人
核心能力
- 根据已选文件的 Git Diff 自动生成提交信息
- 支持一键“自动提炼并提交”
- 支持查看最近提交记录和提交详情
- 默认兼容国内 OpenAI 风格接口
- 支持接入本地 Ollama 模型
快速开始
- 在 VS Code 安装并启用
MonoCommit
- 打开一个 Git 仓库目录
- 点击活动栏中的
MonoCommit
- 勾选要提交的文件
- 点击
🤖 自动提炼并提交
使用方式
MonoCommit 的基本流程很简单:
- 扩展读取当前工作区中的变更文件
- 你选择本次要纳入提交的文件
- 扩展根据这些文件的 staged / unstaged diff 生成提交信息
- 自动执行
git add 和 git commit
最终提交格式如下:
type: title
description
如果没有描述,则只提交第一行。
环境要求
- VS Code
1.85.0 或更高版本
- 当前打开的是文件夹工作区
- 该工作区是一个 Git 仓库根目录
默认模型配置
MonoCommit 默认使用国内可访问的 OpenAI 兼容接口:
{
"aiGitCommit.ai.endpoint": "https://api.siliconflow.cn/v1/chat/completions",
"aiGitCommit.ai.model": "Qwen/Qwen2.5-7B-Instruct"
}
如果你使用云端模型,只需要补充:
{
"aiGitCommit.ai.apiKey": "你的 API Key"
}
使用 Ollama
如果你想本地免费运行模型,可以使用 Ollama。
1. 安装并拉取模型
ollama pull qwen2.5:7b
2. 确认服务正常
ollama list
3. 在 VS Code 中配置
{
"aiGitCommit.ai.endpoint": "http://localhost:11434/v1/chat/completions",
"aiGitCommit.ai.apiKey": "",
"aiGitCommit.ai.model": "qwen2.5:7b",
"aiGitCommit.ai.maxDiffChars": 8000
}
配置项
在 VS Code 设置中搜索 MonoCommit,或直接在 settings.json 中配置:
| 配置项 |
类型 |
默认值 |
说明 |
aiGitCommit.ai.endpoint |
string |
https://api.siliconflow.cn/v1/chat/completions |
OpenAI 兼容接口地址 |
aiGitCommit.ai.apiKey |
string |
"" |
云端模型通常必填;本地 Ollama 可留空 |
aiGitCommit.ai.model |
string |
Qwen/Qwen2.5-7B-Instruct |
使用的模型名称 |
aiGitCommit.ai.maxDiffChars |
number |
12000 |
发给模型的最大 Diff 字符数 |
aiGitCommit.ui.openCommitDetailsAfterCommit |
boolean |
true |
提交成功后是否自动打开提交详情 |
aiGitCommit.ui.recentCommitsLimit |
number |
5 |
最近提交列表显示数量 |
常见问题
面板是空白的
通常是以下几种原因:
- 当前没有打开 Git 仓库目录
- Webview 资源未正确构建
- 使用的是旧版本扩展
遇到问题时可以尝试:
- 重新打开仓库根目录
- 执行
Developer: Reload Window
- 更新到最新版本
点击后没有生成内容
请检查:
endpoint 是否可访问
apiKey 是否正确
model 名称是否和服务端一致
- 本地 Ollama 是否正在运行
注意事项
- 扩展以当前工作区的第一个文件夹作为 Git 根目录
- 生成时会合并 staged 和 unstaged diff
- 请不要把真实 API Key 提交到公开仓库
开发者说明
展开查看本地开发与构建
在项目根目录执行:
npm install
npm run build
调试时可用:
| 命令 |
说明 |
npm run webview:build |
构建 Webview |
npm run webview:watch |
监听 Webview 构建 |
npm run compile |
编译扩展宿主代码 |
npm run watch |
监听扩展宿主编译 |
在 VS Code 中按 F5 启动扩展开发宿主。
License
This project is licensed under the MIT License.