Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | 否 | 自定义系统提示词 |

## ⌨️ 本地开发
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"Dutch",
"Portuguese",
"Vietnamese",
"Bangla (Bangladesh)",
"English",
"Spanish",
"Swedish",
Expand All @@ -85,6 +86,7 @@
"Nederlands",
"português",
"tiếng Việt",
"বাংলা (বাংলাদেশ)",
"english",
"español",
"Svenska",
Expand Down
50 changes: 43 additions & 7 deletions src/prompts.ts
Original file line number Diff line number Diff line change
@@ -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 <language>" lines;
* these notes only add extra guidance, so they read grammatically regardless
* of how descriptive they are.
*/
const LANGUAGE_STYLE_NOTES: Record<string, string> = {
'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] ?? '';
};
Comment on lines +28 to +30

/**
* 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<string>(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<string>(ConfigKeys.SYSTEM_PROMPT) ||
`# Git Commit Message Guide

## Role and Purpose

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down