A VS Code extension that adds a git icon to the top bar of the Source Control panel (next to Commit/Refresh). Click it to generate an AI commit message with the DeepSeek API and have it filled into the commit input box.
一个 VS Code 扩展:在源码管理面板标题栏(Commit/Refresh 旁边)添加 Git 图标按钮,点击即可调用 AI 大模型生成提交信息并自动填入提交输入框。
-
Git icon button on the Source Control panel header bar (always visible, next to Commit/Refresh)
源码管理面板标题栏常驻 Git 图标按钮(Commit/Refresh 旁边) -
Reads the full working tree diff (
git diff HEAD, staged + unstaged) plus branch name
读取完整工作区 diff(git diff HEAD,暂存 + 未暂存)与分支名 -
Generates a Conventional Commits message (English, summary line <= 72 chars)
按 Conventional Commits 规范生成提交信息(英文,摘要 ≤ 72 字符) -
Auto-stages all changes before generating (
gitai.autoStageAll, default on)
生成前自动暂存全部变更(gitai.autoStageAll,默认开启) -
Prefixes the summary with a type-matching emoji (
gitai.addEmoji, default on)
摘要开头自动添加类型匹配的 emoji(gitai.addEmoji,默认开启) -
Model and API endpoint are configurable — works with any OpenAI-compatible LLM
模型与接口地址可配置,兼容任意 OpenAI 兼容大模型 -
Writes the result into the git commit message input box for review
结果自动填入提交输入框供审阅 -
Auto-detects the real git repository — works when the repo is a nested subfolder of the workspace (e.g.
frontend-vue/,backend/) and with multiple open repos (uses the active editor's repo)
自动定位真实 git 仓库根目录——仓库位于工作区的嵌套子目录(如frontend-vue/、backend/)或多个仓库并存时均可使用(优先当前活动编辑器所在仓库) -
Errors are surfaced with clear messages (missing key, HTTP status, timeouts)
错误提示完善(缺 Key、HTTP 状态、超时等)
-
Install dependencies and package:
安装依赖并打包:npm install npm run package
Install the generated
gitai-0.0.4.vsixvia the Extensions view (Install from VSIX...).
在扩展视图选择Install from VSIX...安装生成的gitai-0.0.4.vsix。 -
For development, press
F5in VS Code to launch an Extension Development Host.
开发调试时按F5启动扩展开发宿主。
-
Make some changes in a git repository and open the Source Control panel.
在 git 仓库中做出修改,打开源码管理面板。 -
Click the git icon in the panel's top bar (next to the Commit/Refresh buttons).
点击标题栏中的 Git 图标按钮(Commit/Refresh 旁边)。 -
Review the generated message in the commit input box and commit.
审阅填入提交输入框的生成结果,然后提交。
-
Open VS Code Settings (
Ctrl + ,), or opensettings.jsonvia the Command Palette (Ctrl + Shift + P→Preferences: Open User Settings (JSON)).
打开 VS Code 设置(Ctrl + ,),或在命令面板(Ctrl + Shift + P)输入Preferences: Open User Settings (JSON)打开settings.json。 -
Add or modify any of the following settings (
gitai.*prefix):
添加/修改以下任意配置项(gitai.*前缀): -
Changes take effect immediately, no restart needed. Get an API key at https://platform.deepseek.com/api_keys.
保存后立即生效,无需重启。获取 API Key:https://platform.deepseek.com/api_keys
| Setting | Default | Description |
|---|---|---|
gitai.apiKey |
"" |
API key (required). Get a key at platform.deepseek.com/api_keys |
gitai.model |
deepseek-v4-flash |
Model to use (any OpenAI-compatible model) |
gitai.baseUrl |
https://api.deepseek.com |
API base URL, OpenAI-compatible mode |
gitai.maxDiffLength |
8000 |
Max diff characters sent to the API (roughly 1 token per 4 chars). Larger diffs are truncated; raise it if you need more context, lower it to save tokens |
gitai.autoStageAll |
true |
Automatically run git add -A before generating |
gitai.addEmoji |
true |
Prefix the summary with a type-matching emoji |
You can also search
gitaidirectly in the Settings UI to modify each setting individually (thegitai.apiKeyinput box supports pasting).
在设置界面中直接搜索gitai也可以逐个修改(gitai.apiKey输入框支持粘贴 API Key)。
- Fix:
No changes to commitin multi-repo workspaces when the repo with changes is not the first discovered one (e.g. changes inbackend/while the active editor is infrontend/or elsewhere). When several repositories exist under the workspace, GitAI now checks each one withgit status --porcelainand picks the repository that actually has changes — if only one has changes it is used directly; if several do, the active editor's repository wins, otherwise you are asked to choose via a quick pick.
修复多仓库工作区下"仓库有改动却提示No changes to commit"的问题(例如backend/有改动、而活动编辑器在frontend/或别处)。当工作区下存在多个仓库时,GitAI 现在用git status --porcelain逐一检查,优先选择真正有改动的仓库——仅有 1 个有改动时直接使用;多个有改动时优先活动编辑器所在仓库,否则弹出快速选择框让用户指定。
- Fix:
Failed to stage all changes: fatal: not a git repositorywhen the workspace root is not itself a git repository (e.g. repos live in nested subfolders likefrontend/,backend/, or monorepos). GitAI now resolves the actual repository root through the built-in git extension API — preferring the active editor's repository when several are open — and runs all git commands there, falling back togit rev-parse --show-toplevelwhen the API is unavailable.
修复当工作区根目录本身不是 git 仓库时报Failed to stage all changes: fatal: not a git repository的问题(如仓库位于工作区嵌套子目录frontend/、backend/,或多仓库 monorepo 场景)。GitAI 现在通过内置 git 扩展 API 定位真实仓库根目录——多仓库时优先当前活动编辑器所在仓库——并在该目录执行所有 git 命令;API 不可用时回退到git rev-parse --show-toplevel。
- Fix:
Failed to read git diff: stdout maxBuffer length exceeded— reads git output via streaming instead of a fixed buffer, no longer fails on very large diffs.
修复大 diff 时Failed to read git diff: stdout maxBuffer length exceeded报错(改为流式读取 git 输出,不再受缓冲区大小限制)。 - Change: default
gitai.maxDiffLengthlowered from 4,000,000 to 8,000 characters to avoid excessive token usage (roughly 2k tokens per request).
默认gitai.maxDiffLength由 4,000,000 调整为 8,000 字符,避免单次请求消耗过多 token(约 2k token)。
- Initial release.
首个版本。
MIT
{ // 1. API Key(必填 / required) "gitai.apiKey": "sk-xxxxxxxxxxxxxxxxxxxx", // 2. 模型(可选,默认 deepseek-v4-flash,可换任意 OpenAI 兼容模型) "gitai.model": "deepseek-v4-flash", // 3. 接口地址(可选,默认官方地址;自建代理/中转站时修改) "gitai.baseUrl": "https://api.deepseek.com", // 4. 发送给模型的 diff 最大长度(默认 8,000 字符,约 2k token; // 超出部分自动截断,按需调大可获取更多上下文) "gitai.maxDiffLength": 8000, // 5. 生成前自动暂存全部变更(默认开启) "gitai.autoStageAll": true, // 6. 摘要前添加类型匹配 emoji(默认开启) "gitai.addEmoji": true }