Skip to content

Commit

Permalink
🔧 chore: 更新配置和项目结构
Browse files Browse the repository at this point in the history
- 重命名配置项, AI_COMMIT_LANGUAGE 改为 commitLanguage
- 重命名配置项, AI_COMMIT_SYSTEM_PROMPT 改为 systemPrompt
- 添加 allowMergeCommits 配置项支持合并多个文件变更
- 添加 i18n 本地化支持和相应的英文、中文资源文件
- 完善配置参数类型定义并新增 AIModel 接口
- 优化 AI Provider 实现中的错误处理和提示信息
- 规范化 VSCode 配置文件和 settings.json 格式
- 优化差异内容处理相关工具类的实现
- 添加多语言提交信息生成方案的系统提示语模板
  • Loading branch information
littleCareless committed Dec 9, 2024
1 parent b2854e2 commit ae2507b
Show file tree
Hide file tree
Showing 27 changed files with 1,186 additions and 3,669 deletions.
5 changes: 0 additions & 5 deletions .vscode-test.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions .vscode-test.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
files: "out/test/**/*.test.js",
});
17 changes: 9 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"i18n-ally.localesPaths": ["i18n", "out/i18n", "src/i18n"]
}
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
A VSCode extension for generating standardized Git/SVN commit messages using AI

[Report Bug][github-issues-link] · [Request Feature][github-issues-link]

<!-- SHIELD GROUP -->

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

Supports 19 languages including:

- English
- Simplified Chinese
- Traditional Chinese
Expand All @@ -59,15 +61,15 @@ Supports 19 languages including:

### Configuration

| Configuration | Type | Default | Required |
|--------------|------|---------|-----------|
| dish-ai-commit.AI_COMMIT_LANGUAGE | string | Simplified Chinese | Yes |
| dish-ai-commit.AI_COMMIT_SYSTEM_PROMPT | string | "" | No |
| dish-ai-commit.provider | string | OpenAI | Yes |
| dish-ai-commit.model | string | gpt-3.5-turbo | Yes |
| dish-ai-commit.openai.apiKey | string | - | Yes |
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | No |
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | No |
| Configuration | Type | Default | Required |
| ----------------------------- | ------ | ------------------------- | -------- |
| dish-ai-commit.commitLanguage | string | Simplified Chinese | Yes |
| dish-ai-commit.systemPrompt | string | "" | No |
| dish-ai-commit.provider | string | OpenAI | Yes |
| dish-ai-commit.model | string | gpt-3.5-turbo | Yes |
| dish-ai-commit.openai.apiKey | string | - | Yes |
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | No |
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | No |

### Commands

Expand Down
21 changes: 10 additions & 11 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
用 AI 辅助生成规范的 Git/SVN 提交信息的 VSCode 扩展

[报告错误][github-issues-link] · [请求功能][github-issues-link]

<!-- SHIELD GROUP -->

[![][github-contributors-shield]][github-contributors-link]
Expand Down Expand Up @@ -52,15 +53,15 @@

### 配置项

| 配置项 | 类型 | 默认值 | 必填 |
|--------|------|--------|------|
| dish-ai-commit.AI_COMMIT_LANGUAGE | string | Simplified Chinese ||
| dish-ai-commit.AI_COMMIT_SYSTEM_PROMPT | string | "" ||
| dish-ai-commit.provider | string | OpenAI ||
| dish-ai-commit.model | string | gpt-3.5-turbo ||
| dish-ai-commit.openai.apiKey | string | - ||
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 ||
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 ||
| 配置项 | 类型 | 默认值 | 必填 |
| ----------------------------- | ------ | ------------------------- | ---- |
| dish-ai-commit.commitLanguage | string | Simplified Chinese | |
| dish-ai-commit.systemPrompt | string | "" | |
| dish-ai-commit.provider | string | OpenAI | |
| dish-ai-commit.model | string | gpt-3.5-turbo | |
| dish-ai-commit.openai.apiKey | string | - | |
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | |
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | |

### 命令

Expand Down Expand Up @@ -179,8 +180,6 @@

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



<!-- LINK GROUP -->

[github-codespace-link]: https://codespaces.new/littleCareless/dish-ai-commit
Expand Down
62 changes: 62 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"openai.apikey.missing": "OpenAI API Key is not configured. Would you like to configure it now?",
"ollama.baseurl.missing": "Ollama Base URL is not configured. Would you like to configure it now?",
"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.",
"command.execution.failed": "Command execution failed",
"scm.not.detected": "No supported version control system detected",
"no.changes": "No changes to commit",
"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",
"commit.message.generated": "Commit message has been filled in {0} commit box",
"commit.message.write.failed": "Failed to write commit message: {0}",
"commit.message.copied": "Commit message has been copied to clipboard",
"commit.message.copy.failed": "Failed to copy commit message: {0}",
"commit.message.manual.copy": "Commit message generated, please copy it manually to the commit box",
"generate.commit.failed": "Failed to generate commit message: {0}",
"get.models.failed": "Failed to get model list",
"openai.config.required": "OpenAI API configuration is required to use this feature. Would you like to configure it now?",
"openai.baseurl.prompt": "Enter OpenAI API URL",
"openai.baseurl.placeholder": "e.g., https://api.openai.com/v1",
"openai.apikey.prompt": "Enter OpenAI API Key",
"ai.model.picker.title": "Select AI Model",
"ai.model.picker.placeholder": "Select AI model for generating commit messages",
"model.update.success": "AI model settings updated to: {0} - {1}",
"model.list.failed": "Failed to get model list",
"model.picker.title": "Select AI Model",
"model.picker.placeholder": "Select AI model for generating commit messages",
"progress.generating.commit": "Generating {0} commit message...",
"progress.analyzing.changes": "Analyzing changes...",
"progress.generation.complete": "Generation completed",
"ollama.models.updated": "Ollama models list updated",
"ollama.models.fetch.failed": "Failed to fetch Ollama models",
"ollama.api.call.failed": "Ollama API call failed",
"ollama.api.request.failed": "Ollama API request failed: {0}",
"localization.manager.not.initialized": "LocalizationManager not initialized",
"openai.config.invalid": "Invalid OpenAI configuration",
"openai.models.update.success": "OpenAI models list updated",
"openai.models.fetch.failed": "Failed to fetch OpenAI models",
"provider.not.available": "AI Provider {0} is not available",
"unexpected.error": "An unexpected error occurred: {0}",
"vscode.no.models.available": "No VSCode language models available",
"vscode.generation.failed": "VSCode AI generation failed: {0}",
"vscode.models.fetch.failed": "Failed to fetch VSCode models",
"provider.type.unknown": "Unknown AI provider type: {0}",
"button.yes": "Yes",
"button.no": "No",
"workspace.not.found": "No workspace folder found",
"git.diff.error": "Git diff error: {0}",
"diff.noChanges": "No changes found",
"git.diff.failed": "Git diff failed: {0}",
"git.repository.not.found": "No Git repository found",
"diff.noChangesFound": "No changes found",
"svn.commit.failed": "SVN commit failed: {0}",
"svn.no.changes": "No changes to commit in SVN",
"svn.repository.not.found": "No SVN repository found",
"openai.input.truncated": "Input content has been truncated, which may affect the quality of the generated result",
"openai.generation.failed": "OpenAI generation failed: {0}",
"ollama.input.truncated": "Input content has been truncated, which may affect the quality of the generated result",
"ollama.generation.failed": "Ollama generation failed: {0}",
"openai.models.empty": "No OpenAI models available",
"openai.models.error": "Failed to fetch OpenAI models list",
"model.not.found": "Selected model not found",
"no.commit.message.generated": "No commit message was generated"
}
62 changes: 62 additions & 0 deletions i18n/zh-cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"openai.apikey.missing": "OpenAI API Key 未配置。是否现在配置?",
"ollama.baseurl.missing": "Ollama Base URL 未配置。是否现在配置?",
"diff.simplification.warning": "Diff 简化功能已启用。这可能会影响 AI 生成提交信息的准确性。如需获取更准确的提交信息,建议禁用此功能。",
"command.execution.failed": "执行命令失败",
"scm.not.detected": "未检测到支持的版本控制系统",
"no.changes": "没有可提交的更改",
"diff.too.long": "变更内容过长,超出模型最大限制。请减少选中的文件数量或内容长度。\n当前长度: {0} 字符\n最大限制: {1} 字符",
"commit.message.generated": "已将提交信息填入 {0} 提交框",
"commit.message.write.failed": "写入提交信息失败: {0}",
"commit.message.copied": "提交信息已复制到剪贴板",
"commit.message.copy.failed": "复制提交信息失败: {0}",
"commit.message.manual.copy": "提交信息已生成,请手动复制到提交框",
"generate.commit.failed": "生成提交信息失败: {0}",
"get.models.failed": "获取模型列表失败",
"openai.config.required": "需要配置 OpenAI API 信息才能使用该功能,是否现在配置?",
"openai.baseurl.prompt": "请输入 OpenAI API 地址",
"openai.baseurl.placeholder": "例如: https://api.openai.com/v1",
"openai.apikey.prompt": "请输入 OpenAI API Key",
"ai.model.picker.title": "选择 AI 模型",
"ai.model.picker.placeholder": "选择用于生成提交信息的 AI 模型",
"model.update.success": "已更新 AI 模型设置为: {0} - {1}",
"model.list.failed": "获取模型列表失败",
"model.picker.title": "选择 AI 模型",
"model.picker.placeholder": "选择用于生成提交信息的 AI 模型",
"progress.generating.commit": "正在生成 {0} 提交信息...",
"progress.analyzing.changes": "正在分析变更内容...",
"progress.generation.complete": "生成完成",
"ollama.models.updated": "Ollama模型列表已更新",
"ollama.models.fetch.failed": "获取Ollama模型列表失败",
"ollama.api.call.failed": "Ollama API调用失败",
"ollama.api.request.failed": "Ollama API请求失败: {0}",
"localization.manager.not.initialized": "本地化管理器未初始化",
"openai.config.invalid": "OpenAI 配置无效",
"openai.models.update.success": "OpenAI模型列表已更新",
"openai.models.fetch.failed": "获取OpenAI模型列表失败",
"provider.not.available": "AI 提供商 {0} 不可用",
"provider.type.unknown": "未知的 AI 提供商类型:{0}",
"unexpected.error": "发生意外错误:{0}",
"vscode.no.models.available": "未找到可用的VSCode语言模型",
"vscode.generation.failed": "VSCode AI生成失败: {0}",
"vscode.models.fetch.failed": "获取VSCode模型列表失败",
"button.yes": "",
"button.no": "",
"workspace.not.found": "未找到工作区文件夹",
"git.diff.error": "Git差异比较错误: {0}",
"diff.noChanges": "没有发现任何更改",
"git.diff.failed": "Git差异比较失败: {0}",
"git.repository.not.found": "未找到Git仓库",
"diff.noChangesFound": "未发现任何更改",
"svn.commit.failed": "SVN提交失败: {0}",
"svn.no.changes": "SVN没有要提交的更改",
"svn.repository.not.found": "未找到SVN仓库",
"openai.input.truncated": "输入内容过长已被截断,这可能会影响生成结果的质量",
"openai.generation.failed": "OpenAI生成失败: {0}",
"ollama.input.truncated": "输入内容过长已被截断,这可能会影响生成结果的质量",
"ollama.generation.failed": "Ollama生成失败: {0}",
"openai.models.empty": "未找到可用的OpenAI模型",
"openai.models.error": "获取OpenAI模型列表失败",
"model.not.found": "未找到选定的模型",
"no.commit.message.generated": "未生成提交信息"
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 24 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dish-ai-commit",
"displayName": "Dish AI Commit Gen",
"description": "",
"version": "0.0.6",
"version": "0.0.8",
"engines": {
"vscode": "^1.95.0"
},
Expand Down Expand Up @@ -60,7 +60,7 @@
"configuration": {
"title": "Dish AI Commit",
"properties": {
"dish-ai-commit.AI_COMMIT_LANGUAGE": {
"dish-ai-commit.commitLanguage": {
"default": "Simplified Chinese",
"description": "Commit message language",
"enum": [
Expand Down Expand Up @@ -107,7 +107,7 @@
],
"type": "string"
},
"dish-ai-commit.AI_COMMIT_SYSTEM_PROMPT": {
"dish-ai-commit.systemPrompt": {
"type": "string",
"default": "",
"description": "Custom system prompt for generating commit messages"
Expand All @@ -117,7 +117,7 @@
"enum": [
"OpenAI",
"Ollama",
"VS Code Provided "
"VS Code Provided"
],
"default": "OpenAI",
"description": "默认的 AI 提供商"
Expand All @@ -140,6 +140,26 @@
"type": "string",
"default": "http://localhost:11434",
"description": "Ollama API 基础 URL"
},
"dish-ai-commit.enableDiffSimplification": {
"type": "boolean",
"default": false,
"description": "启用 diff 内容简化功能(警告:启用此功能可能会导致生成的提交信息不够准确)"
},
"dish-ai-commit.diffSimplification.maxLineLength": {
"type": "number",
"default": 120,
"description": "简化后每行的最大长度"
},
"dish-ai-commit.diffSimplification.contextLines": {
"type": "number",
"default": 3,
"description": "保留的上下文行数"
},
"dish-ai-commit.allowMergeCommits": {
"type": "boolean",
"default": false,
"description": "是否允许将多个文件的变更合并为一条提交信息"
}
}
},
Expand Down
Loading

0 comments on commit ae2507b

Please sign in to comment.