diff --git a/README.md b/README.md index 7431fee..0dec5f0 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ In the VSCode settings, locate the "ai-commit" configuration options and configu | CLAUDE_API_KEY | string | None | No | Anthropic API key. Leave empty to use Claude CLI (authenticated via `claude setup-token`). Required when `AI_PROVIDER` is `claude` | | CLAUDE_MODEL | string | claude-sonnet-4-5-20250929 | No | Claude model to use | | CLAUDE_TEMPERATURE | number | 0.7 | No | Controls randomness. Range: 0–1 | -| AI_COMMIT_LANGUAGE | string | English | Yes | Supports 19 languages | +| AI_COMMIT_LANGUAGE | string | English | Yes | Supports 20 languages | | SYSTEM_PROMPT | string | None | No | Custom system prompt | ## ⌨️ Local Development diff --git a/README.zh_CN.md b/README.zh_CN.md index 9a76cf8..c9847f6 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -77,7 +77,7 @@ | CLAUDE_API_KEY | string | None | 否 | Anthropic API 密钥。留空可使用 Claude CLI(通过 `claude setup-token` 认证)。`AI_PROVIDER` 为 `claude` 时需配置 | | CLAUDE_MODEL | string | claude-sonnet-4-5-20250929 | 否 | Claude 使用的模型 | | CLAUDE_TEMPERATURE | number | 0.7 | 否 | 控制输出随机性。范围:0–1 | -| AI_COMMIT_LANGUAGE | string | English | 是 | 支持 19 种语言 | +| AI_COMMIT_LANGUAGE | string | English | 是 | 支持 20 种语言 | | SYSTEM_PROMPT | string | None | 否 | 自定义系统提示词 | ## ⌨️ 本地开发 diff --git a/package.json b/package.json index 0314328..9db80ad 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "Dutch", "Portuguese", "Vietnamese", + "Bangla (Bangladesh)", "English", "Spanish", "Swedish", @@ -85,6 +86,7 @@ "Nederlands", "português", "tiếng Việt", + "বাংলা (বাংলাদেশ)", "english", "español", "Svenska", diff --git a/src/prompts.ts b/src/prompts.ts index 59f80e3..1b6da47 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -1,16 +1,51 @@ import { ConfigKeys, ConfigurationManager } from './config'; +/** + * Optional language-specific style notes appended to the prompt. These steer + * the model toward natural, correct usage for a given locale. The language + * name itself is still used in the prompt's "Must be in " lines; + * these notes only add extra guidance, so they read grammatically regardless + * of how descriptive they are. + */ +const LANGUAGE_STYLE_NOTES: Record = { + 'Bangla (Bangladesh)': `## Bangla (Bangladesh) Language Rules + +- Write in Standard Formal Bangla (প্রমিত বাংলা), exactly as used in professional writing in Bangladesh. +- Use correct standard spelling. Do NOT use colloquial, spoken, or regional dialect spellings. +- Required word forms (use the left form, never the right): + - "থেকে" (NOT "থিকা") + - "করা হয়েছে" / "যোগ করা হয়েছে" / "সরানো হয়েছে" (NOT "হইল" / "করা হইল") + - "জন্য" (NOT "লাইগা" / "জইন্য") + - "পুরনো" / "পুরাতন" (NOT "পুরান") + - "এখান" / "এখানে" (NOT "এইখান" / "এইখানে") + - "হলো" (NOT "হইল") +- Prefer the perfect form "… করা হয়েছে" over the colloquial "… করা হইল". +- Use vocabulary common in Bangladesh — avoid West Bengal (India) specific words. +- Keep the tone neutral, professional, and concise, like a Bangladeshi software engineer writing a commit message. +- Keep technical terms (variable names, API names, file names, type/scope keywords) in English.` +}; + +const getLanguageStyleNote = (language: string): string => { + return LANGUAGE_STYLE_NOTES[language] ?? ''; +}; + /** * Initializes the main prompt for generating commit messages. * * @param {string} language - The language to be used in the prompt. * @returns {Object} - The main prompt object containing role and content. */ -const INIT_MAIN_PROMPT = (language: string) => ({ - role: 'system', - content: - ConfigurationManager.getInstance().getConfig(ConfigKeys.SYSTEM_PROMPT) || - `# Git Commit Message Guide +const INIT_MAIN_PROMPT = (language: string) => { + const styleNote = getLanguageStyleNote(language); + // Owns the spacing around the optional note so the surrounding template + // keeps consistent single blank lines whether or not a note is present. + const styleSection = styleNote ? `\n${styleNote}\n` : ''; + + return { + role: 'system', + content: + ConfigurationManager.getInstance().getConfig(ConfigKeys.SYSTEM_PROMPT) || + `# Git Commit Message Guide ## Role and Purpose @@ -70,7 +105,7 @@ You will act as a git commit message generator. When receiving a git diff, you w - Explain what and why - Must be in ${language} - Use【】for different types - +${styleSection} ## Critical Requirements 1. Output ONLY the commit message @@ -105,7 +140,8 @@ OUTPUT: - add environment variable port support for flexible deployment Remember: All output MUST be in ${language} language. You are to act as a pure commit message generator. Your response should contain NOTHING but the commit message itself.` -}); + }; +}; /** * Retrieves the main commit prompt.