重构配置模块以移除ini依赖,增强baseURL支持并汉化AI提示词
Some checks failed
Test / Test (ubuntu-latest) (push) Has been cancelled
Test / Test (windows-latest) (push) Has been cancelled

This commit is contained in:
史悦
2025-08-27 16:52:04 +08:00
parent e7f26efc71
commit d23dfecbcd
4 changed files with 67 additions and 37 deletions

View File

@@ -5,7 +5,7 @@ const commitTypeFormats: Record<CommitType, string> = {
conventional: '<type>(<optional scope>): <commit message>',
};
const specifyCommitFormat = (type: CommitType) =>
`The output response must be in format:\n${commitTypeFormats[type]}`;
`输出响应必须使用以下格式:\n${commitTypeFormats[type]}`;
const commitTypes: Record<CommitType, string> = {
'': '',
@@ -18,20 +18,20 @@ const commitTypes: Record<CommitType, string> = {
* Conventional Changelog:
* https://github.com/conventional-changelog/conventional-changelog/blob/d0e5d5926c8addba74bc962553dd8bcfba90e228/packages/conventional-changelog-conventionalcommits/writer-opts.js#L182-L193
*/
conventional: `Choose a type from the type-to-description JSON below that best describes the git diff:\n${JSON.stringify(
conventional: `从下面的类型到描述的JSON中选择最能描述git差异的类型\n${JSON.stringify(
{
docs: 'Documentation only changes',
docs: '仅文档更改',
style:
'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
refactor: 'A code change that neither fixes a bug nor adds a feature',
perf: 'A code change that improves performance',
test: 'Adding missing tests or correcting existing tests',
build: 'Changes that affect the build system or external dependencies',
ci: 'Changes to our CI configuration files and scripts',
chore: "Other changes that don't modify src or test files",
revert: 'Reverts a previous commit',
feat: 'A new feature',
fix: 'A bug fix',
'不影响代码含义的更改(空格、格式、缺少分号等)',
refactor: '既不修复错误也不添加功能的代码更改',
perf: '提高性能的代码更改',
test: '添加缺失的测试或更正现有测试',
build: '影响构建系统或外部依赖的更改',
ci: '对我们的CI配置文件和脚本的更改',
chore: '不修改src或测试文件的其他更改',
revert: '恢复之前的提交',
feat: '新功能',
fix: '错误修复',
},
null,
2
@@ -44,10 +44,13 @@ export const generatePrompt = (
type: CommitType
) =>
[
'Generate a concise git commit message written in present tense for the following code diff with the given specifications below:',
`Message language: ${locale}`,
`Commit message must be a maximum of ${maxLength} characters.`,
'Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit.',
'为以下代码差异生成一个简洁的、使用现在时态的中文git提交消息并遵循以下规范',
`提交消息使用中文编写。`,
`提交消息最多${maxLength}个字符。`,
'提交消息包含具体的类名、方法名或其他关键信息,不能过于笼统。',
'对于功能添加,应该指明具体的类或模块,如"在UserController中添加了用户权限验证功能"。',
'对于代码重构,应该指明重构的具体类或方法,如"重构了PaymentProcessor类的金额计算逻辑"。',
'排除任何不必要的内容如翻译。您的整个响应将直接传递到git提交中。',
commitTypes[type],
specifyCommitFormat(type),
]