Skip to content

Commit ae2507b

Browse files
🔧 chore: 更新配置和项目结构
- 重命名配置项, AI_COMMIT_LANGUAGE 改为 commitLanguage - 重命名配置项, AI_COMMIT_SYSTEM_PROMPT 改为 systemPrompt - 添加 allowMergeCommits 配置项支持合并多个文件变更 - 添加 i18n 本地化支持和相应的英文、中文资源文件 - 完善配置参数类型定义并新增 AIModel 接口 - 优化 AI Provider 实现中的错误处理和提示信息 - 规范化 VSCode 配置文件和 settings.json 格式 - 优化差异内容处理相关工具类的实现 - 添加多语言提交信息生成方案的系统提示语模板
1 parent b2854e2 commit ae2507b

27 files changed

+1186
-3669
lines changed

.vscode-test.mjs

-5
This file was deleted.

.vscode-test.mts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from "@vscode/test-cli";
2+
3+
export default defineConfig({
4+
files: "out/test/**/*.test.js",
5+
});

.vscode/settings.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"files.exclude": {
4-
"out": false // set this to true to hide the "out" folder with the compiled JS files
5-
},
6-
"search.exclude": {
7-
"out": true // set this to false to include "out" folder in search results
8-
},
9-
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10-
"typescript.tsc.autoDetect": "off"
3+
"files.exclude": {
4+
"out": false // set this to true to hide the "out" folder with the compiled JS files
5+
},
6+
"search.exclude": {
7+
"out": true // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off",
11+
"i18n-ally.localesPaths": ["i18n", "out/i18n", "src/i18n"]
1112
}

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
A VSCode extension for generating standardized Git/SVN commit messages using AI
66

77
[Report Bug][github-issues-link] · [Request Feature][github-issues-link]
8+
89
<!-- SHIELD GROUP -->
910

1011
[![][github-contributors-shield]][github-contributors-link]
@@ -40,6 +41,7 @@ A VSCode extension for generating standardized Git/SVN commit messages using AI.
4041
### 🌍 Multi-language Commit Message Generation:
4142

4243
Supports 19 languages including:
44+
4345
- English
4446
- Simplified Chinese
4547
- Traditional Chinese
@@ -59,15 +61,15 @@ Supports 19 languages including:
5961

6062
### Configuration
6163

62-
| Configuration | Type | Default | Required |
63-
|--------------|------|---------|-----------|
64-
| dish-ai-commit.AI_COMMIT_LANGUAGE | string | Simplified Chinese | Yes |
65-
| dish-ai-commit.AI_COMMIT_SYSTEM_PROMPT | string | "" | No |
66-
| dish-ai-commit.provider | string | OpenAI | Yes |
67-
| dish-ai-commit.model | string | gpt-3.5-turbo | Yes |
68-
| dish-ai-commit.openai.apiKey | string | - | Yes |
69-
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | No |
70-
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | No |
64+
| Configuration | Type | Default | Required |
65+
| ----------------------------- | ------ | ------------------------- | -------- |
66+
| dish-ai-commit.commitLanguage | string | Simplified Chinese | Yes |
67+
| dish-ai-commit.systemPrompt | string | "" | No |
68+
| dish-ai-commit.provider | string | OpenAI | Yes |
69+
| dish-ai-commit.model | string | gpt-3.5-turbo | Yes |
70+
| dish-ai-commit.openai.apiKey | string | - | Yes |
71+
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | No |
72+
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | No |
7173

7274
### Commands
7375

README.zh-CN.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
用 AI 辅助生成规范的 Git/SVN 提交信息的 VSCode 扩展
66

77
[报告错误][github-issues-link] · [请求功能][github-issues-link]
8+
89
<!-- SHIELD GROUP -->
910

1011
[![][github-contributors-shield]][github-contributors-link]
@@ -52,15 +53,15 @@
5253

5354
### 配置项
5455

55-
| 配置项 | 类型 | 默认值 | 必填 |
56-
|--------|------|--------|------|
57-
| dish-ai-commit.AI_COMMIT_LANGUAGE | string | Simplified Chinese ||
58-
| dish-ai-commit.AI_COMMIT_SYSTEM_PROMPT | string | "" ||
59-
| dish-ai-commit.provider | string | OpenAI ||
60-
| dish-ai-commit.model | string | gpt-3.5-turbo ||
61-
| dish-ai-commit.openai.apiKey | string | - ||
62-
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 ||
63-
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 ||
56+
| 配置项 | 类型 | 默认值 | 必填 |
57+
| ----------------------------- | ------ | ------------------------- | ---- |
58+
| dish-ai-commit.commitLanguage | string | Simplified Chinese | |
59+
| dish-ai-commit.systemPrompt | string | "" | |
60+
| dish-ai-commit.provider | string | OpenAI | |
61+
| dish-ai-commit.model | string | gpt-3.5-turbo | |
62+
| dish-ai-commit.openai.apiKey | string | - | |
63+
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | |
64+
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | |
6465

6566
### 命令
6667

@@ -179,8 +180,6 @@
179180

180181
该项目是 [MIT](./LICENSE) 许可证。
181182

182-
183-
184183
<!-- LINK GROUP -->
185184

186185
[github-codespace-link]: https://codespaces.new/littleCareless/dish-ai-commit

i18n/en.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"openai.apikey.missing": "OpenAI API Key is not configured. Would you like to configure it now?",
3+
"ollama.baseurl.missing": "Ollama Base URL is not configured. Would you like to configure it now?",
4+
"diff.simplification.warning": "Diff simplification is enabled. This may affect the accuracy of AI-generated commit messages. For more accurate commit messages, consider disabling this feature.",
5+
"command.execution.failed": "Command execution failed",
6+
"scm.not.detected": "No supported version control system detected",
7+
"no.changes": "No changes to commit",
8+
"diff.too.long": "Changes content is too long, exceeding model limit. Please reduce the number of selected files or content length.\nCurrent length: {0} characters\nMaximum limit: {1} characters",
9+
"commit.message.generated": "Commit message has been filled in {0} commit box",
10+
"commit.message.write.failed": "Failed to write commit message: {0}",
11+
"commit.message.copied": "Commit message has been copied to clipboard",
12+
"commit.message.copy.failed": "Failed to copy commit message: {0}",
13+
"commit.message.manual.copy": "Commit message generated, please copy it manually to the commit box",
14+
"generate.commit.failed": "Failed to generate commit message: {0}",
15+
"get.models.failed": "Failed to get model list",
16+
"openai.config.required": "OpenAI API configuration is required to use this feature. Would you like to configure it now?",
17+
"openai.baseurl.prompt": "Enter OpenAI API URL",
18+
"openai.baseurl.placeholder": "e.g., https://api.openai.com/v1",
19+
"openai.apikey.prompt": "Enter OpenAI API Key",
20+
"ai.model.picker.title": "Select AI Model",
21+
"ai.model.picker.placeholder": "Select AI model for generating commit messages",
22+
"model.update.success": "AI model settings updated to: {0} - {1}",
23+
"model.list.failed": "Failed to get model list",
24+
"model.picker.title": "Select AI Model",
25+
"model.picker.placeholder": "Select AI model for generating commit messages",
26+
"progress.generating.commit": "Generating {0} commit message...",
27+
"progress.analyzing.changes": "Analyzing changes...",
28+
"progress.generation.complete": "Generation completed",
29+
"ollama.models.updated": "Ollama models list updated",
30+
"ollama.models.fetch.failed": "Failed to fetch Ollama models",
31+
"ollama.api.call.failed": "Ollama API call failed",
32+
"ollama.api.request.failed": "Ollama API request failed: {0}",
33+
"localization.manager.not.initialized": "LocalizationManager not initialized",
34+
"openai.config.invalid": "Invalid OpenAI configuration",
35+
"openai.models.update.success": "OpenAI models list updated",
36+
"openai.models.fetch.failed": "Failed to fetch OpenAI models",
37+
"provider.not.available": "AI Provider {0} is not available",
38+
"unexpected.error": "An unexpected error occurred: {0}",
39+
"vscode.no.models.available": "No VSCode language models available",
40+
"vscode.generation.failed": "VSCode AI generation failed: {0}",
41+
"vscode.models.fetch.failed": "Failed to fetch VSCode models",
42+
"provider.type.unknown": "Unknown AI provider type: {0}",
43+
"button.yes": "Yes",
44+
"button.no": "No",
45+
"workspace.not.found": "No workspace folder found",
46+
"git.diff.error": "Git diff error: {0}",
47+
"diff.noChanges": "No changes found",
48+
"git.diff.failed": "Git diff failed: {0}",
49+
"git.repository.not.found": "No Git repository found",
50+
"diff.noChangesFound": "No changes found",
51+
"svn.commit.failed": "SVN commit failed: {0}",
52+
"svn.no.changes": "No changes to commit in SVN",
53+
"svn.repository.not.found": "No SVN repository found",
54+
"openai.input.truncated": "Input content has been truncated, which may affect the quality of the generated result",
55+
"openai.generation.failed": "OpenAI generation failed: {0}",
56+
"ollama.input.truncated": "Input content has been truncated, which may affect the quality of the generated result",
57+
"ollama.generation.failed": "Ollama generation failed: {0}",
58+
"openai.models.empty": "No OpenAI models available",
59+
"openai.models.error": "Failed to fetch OpenAI models list",
60+
"model.not.found": "Selected model not found",
61+
"no.commit.message.generated": "No commit message was generated"
62+
}

i18n/zh-cn.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"openai.apikey.missing": "OpenAI API Key 未配置。是否现在配置?",
3+
"ollama.baseurl.missing": "Ollama Base URL 未配置。是否现在配置?",
4+
"diff.simplification.warning": "Diff 简化功能已启用。这可能会影响 AI 生成提交信息的准确性。如需获取更准确的提交信息,建议禁用此功能。",
5+
"command.execution.failed": "执行命令失败",
6+
"scm.not.detected": "未检测到支持的版本控制系统",
7+
"no.changes": "没有可提交的更改",
8+
"diff.too.long": "变更内容过长,超出模型最大限制。请减少选中的文件数量或内容长度。\n当前长度: {0} 字符\n最大限制: {1} 字符",
9+
"commit.message.generated": "已将提交信息填入 {0} 提交框",
10+
"commit.message.write.failed": "写入提交信息失败: {0}",
11+
"commit.message.copied": "提交信息已复制到剪贴板",
12+
"commit.message.copy.failed": "复制提交信息失败: {0}",
13+
"commit.message.manual.copy": "提交信息已生成,请手动复制到提交框",
14+
"generate.commit.failed": "生成提交信息失败: {0}",
15+
"get.models.failed": "获取模型列表失败",
16+
"openai.config.required": "需要配置 OpenAI API 信息才能使用该功能,是否现在配置?",
17+
"openai.baseurl.prompt": "请输入 OpenAI API 地址",
18+
"openai.baseurl.placeholder": "例如: https://api.openai.com/v1",
19+
"openai.apikey.prompt": "请输入 OpenAI API Key",
20+
"ai.model.picker.title": "选择 AI 模型",
21+
"ai.model.picker.placeholder": "选择用于生成提交信息的 AI 模型",
22+
"model.update.success": "已更新 AI 模型设置为: {0} - {1}",
23+
"model.list.failed": "获取模型列表失败",
24+
"model.picker.title": "选择 AI 模型",
25+
"model.picker.placeholder": "选择用于生成提交信息的 AI 模型",
26+
"progress.generating.commit": "正在生成 {0} 提交信息...",
27+
"progress.analyzing.changes": "正在分析变更内容...",
28+
"progress.generation.complete": "生成完成",
29+
"ollama.models.updated": "Ollama模型列表已更新",
30+
"ollama.models.fetch.failed": "获取Ollama模型列表失败",
31+
"ollama.api.call.failed": "Ollama API调用失败",
32+
"ollama.api.request.failed": "Ollama API请求失败: {0}",
33+
"localization.manager.not.initialized": "本地化管理器未初始化",
34+
"openai.config.invalid": "OpenAI 配置无效",
35+
"openai.models.update.success": "OpenAI模型列表已更新",
36+
"openai.models.fetch.failed": "获取OpenAI模型列表失败",
37+
"provider.not.available": "AI 提供商 {0} 不可用",
38+
"provider.type.unknown": "未知的 AI 提供商类型:{0}",
39+
"unexpected.error": "发生意外错误:{0}",
40+
"vscode.no.models.available": "未找到可用的VSCode语言模型",
41+
"vscode.generation.failed": "VSCode AI生成失败: {0}",
42+
"vscode.models.fetch.failed": "获取VSCode模型列表失败",
43+
"button.yes": "",
44+
"button.no": "",
45+
"workspace.not.found": "未找到工作区文件夹",
46+
"git.diff.error": "Git差异比较错误: {0}",
47+
"diff.noChanges": "没有发现任何更改",
48+
"git.diff.failed": "Git差异比较失败: {0}",
49+
"git.repository.not.found": "未找到Git仓库",
50+
"diff.noChangesFound": "未发现任何更改",
51+
"svn.commit.failed": "SVN提交失败: {0}",
52+
"svn.no.changes": "SVN没有要提交的更改",
53+
"svn.repository.not.found": "未找到SVN仓库",
54+
"openai.input.truncated": "输入内容过长已被截断,这可能会影响生成结果的质量",
55+
"openai.generation.failed": "OpenAI生成失败: {0}",
56+
"ollama.input.truncated": "输入内容过长已被截断,这可能会影响生成结果的质量",
57+
"ollama.generation.failed": "Ollama生成失败: {0}",
58+
"openai.models.empty": "未找到可用的OpenAI模型",
59+
"openai.models.error": "获取OpenAI模型列表失败",
60+
"model.not.found": "未找到选定的模型",
61+
"no.commit.message.generated": "未生成提交信息"
62+
}

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+24-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dish-ai-commit",
33
"displayName": "Dish AI Commit Gen",
44
"description": "",
5-
"version": "0.0.6",
5+
"version": "0.0.8",
66
"engines": {
77
"vscode": "^1.95.0"
88
},
@@ -60,7 +60,7 @@
6060
"configuration": {
6161
"title": "Dish AI Commit",
6262
"properties": {
63-
"dish-ai-commit.AI_COMMIT_LANGUAGE": {
63+
"dish-ai-commit.commitLanguage": {
6464
"default": "Simplified Chinese",
6565
"description": "Commit message language",
6666
"enum": [
@@ -107,7 +107,7 @@
107107
],
108108
"type": "string"
109109
},
110-
"dish-ai-commit.AI_COMMIT_SYSTEM_PROMPT": {
110+
"dish-ai-commit.systemPrompt": {
111111
"type": "string",
112112
"default": "",
113113
"description": "Custom system prompt for generating commit messages"
@@ -117,7 +117,7 @@
117117
"enum": [
118118
"OpenAI",
119119
"Ollama",
120-
"VS Code Provided "
120+
"VS Code Provided"
121121
],
122122
"default": "OpenAI",
123123
"description": "默认的 AI 提供商"
@@ -140,6 +140,26 @@
140140
"type": "string",
141141
"default": "http://localhost:11434",
142142
"description": "Ollama API 基础 URL"
143+
},
144+
"dish-ai-commit.enableDiffSimplification": {
145+
"type": "boolean",
146+
"default": false,
147+
"description": "启用 diff 内容简化功能(警告:启用此功能可能会导致生成的提交信息不够准确)"
148+
},
149+
"dish-ai-commit.diffSimplification.maxLineLength": {
150+
"type": "number",
151+
"default": 120,
152+
"description": "简化后每行的最大长度"
153+
},
154+
"dish-ai-commit.diffSimplification.contextLines": {
155+
"type": "number",
156+
"default": 3,
157+
"description": "保留的上下文行数"
158+
},
159+
"dish-ai-commit.allowMergeCommits": {
160+
"type": "boolean",
161+
"default": false,
162+
"description": "是否允许将多个文件的变更合并为一条提交信息"
143163
}
144164
}
145165
},

0 commit comments

Comments
 (0)