feat(generator): add language parameter to commit generation methods
This commit is contained in:
@@ -254,10 +254,12 @@ impl CommitCommand {
|
|||||||
|
|
||||||
println!("{}", messages.ai_analyzing());
|
println!("{}", messages.ai_analyzing());
|
||||||
|
|
||||||
|
let language = Language::from_str(&config.language.output_language).unwrap_or(Language::English);
|
||||||
|
|
||||||
let generated = if self.yes {
|
let generated = if self.yes {
|
||||||
generator.generate_commit_from_repo(repo, format).await?
|
generator.generate_commit_from_repo(repo, format, language).await?
|
||||||
} else {
|
} else {
|
||||||
generator.generate_commit_interactive(repo, format).await?
|
generator.generate_commit_interactive(repo, format, language).await?
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(generated.to_conventional())
|
Ok(generated.to_conventional())
|
||||||
|
|||||||
@@ -905,7 +905,7 @@ impl ConfigCommand {
|
|||||||
fn main() {
|
fn main() {
|
||||||
+ println!("Hello, World!");
|
+ println!("Hello, World!");
|
||||||
}"#;
|
}"#;
|
||||||
match client.generate_commit_message(sample_diff, crate::config::CommitFormat::Conventional).await {
|
match client.generate_commit_message(sample_diff, crate::config::CommitFormat::Conventional, crate::config::Language::English).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
println!("{} Generation test passed", "✓".green());
|
println!("{} Generation test passed", "✓".green());
|
||||||
println!("Response: {}", response.description.dimmed());
|
println!("Response: {}", response.description.dimmed());
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::config::{CommitFormat, LlmConfig};
|
use crate::config::{CommitFormat, LlmConfig, Language};
|
||||||
use crate::git::{CommitInfo, GitRepo};
|
use crate::git::{CommitInfo, GitRepo};
|
||||||
use crate::llm::{GeneratedCommit, LlmClient};
|
use crate::llm::{GeneratedCommit, LlmClient};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
@@ -27,6 +27,7 @@ impl ContentGenerator {
|
|||||||
&self,
|
&self,
|
||||||
diff: &str,
|
diff: &str,
|
||||||
format: CommitFormat,
|
format: CommitFormat,
|
||||||
|
language: Language,
|
||||||
) -> Result<GeneratedCommit> {
|
) -> Result<GeneratedCommit> {
|
||||||
// Truncate diff if too long
|
// Truncate diff if too long
|
||||||
let max_diff_len = 4000;
|
let max_diff_len = 4000;
|
||||||
@@ -36,7 +37,7 @@ impl ContentGenerator {
|
|||||||
diff.to_string()
|
diff.to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.llm_client.generate_commit_message(&truncated_diff, format).await
|
self.llm_client.generate_commit_message(&truncated_diff, format, language).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate commit message from repository changes
|
/// Generate commit message from repository changes
|
||||||
@@ -44,6 +45,7 @@ impl ContentGenerator {
|
|||||||
&self,
|
&self,
|
||||||
repo: &GitRepo,
|
repo: &GitRepo,
|
||||||
format: CommitFormat,
|
format: CommitFormat,
|
||||||
|
language: Language,
|
||||||
) -> Result<GeneratedCommit> {
|
) -> Result<GeneratedCommit> {
|
||||||
let diff = repo.get_staged_diff()
|
let diff = repo.get_staged_diff()
|
||||||
.context("Failed to get staged diff")?;
|
.context("Failed to get staged diff")?;
|
||||||
@@ -52,7 +54,7 @@ impl ContentGenerator {
|
|||||||
anyhow::bail!("No staged changes to generate commit from");
|
anyhow::bail!("No staged changes to generate commit from");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.generate_commit_message(&diff, format).await
|
self.generate_commit_message(&diff, format, language).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate tag message
|
/// Generate tag message
|
||||||
@@ -107,6 +109,7 @@ impl ContentGenerator {
|
|||||||
&self,
|
&self,
|
||||||
repo: &GitRepo,
|
repo: &GitRepo,
|
||||||
format: CommitFormat,
|
format: CommitFormat,
|
||||||
|
language: Language,
|
||||||
) -> Result<GeneratedCommit> {
|
) -> Result<GeneratedCommit> {
|
||||||
use dialoguer::{Confirm, Select};
|
use dialoguer::{Confirm, Select};
|
||||||
use console::Term;
|
use console::Term;
|
||||||
@@ -126,7 +129,7 @@ impl ContentGenerator {
|
|||||||
|
|
||||||
// Generate initial commit
|
// Generate initial commit
|
||||||
println!("\nGenerating commit message...");
|
println!("\nGenerating commit message...");
|
||||||
let mut generated = self.generate_commit_message(&diff, format).await?;
|
let mut generated = self.generate_commit_message(&diff, format, language).await?;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
println!("\n{}", "─".repeat(60));
|
println!("\n{}", "─".repeat(60));
|
||||||
@@ -153,7 +156,7 @@ impl ContentGenerator {
|
|||||||
0 => return Ok(generated),
|
0 => return Ok(generated),
|
||||||
1 => {
|
1 => {
|
||||||
println!("Regenerating...");
|
println!("Regenerating...");
|
||||||
generated = self.generate_commit_message(&diff, format).await?;
|
generated = self.generate_commit_message(&diff, format, language).await?;
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
let edited = crate::utils::editor::edit_content(&generated.to_conventional())?;
|
let edited = crate::utils::editor::edit_content(&generated.to_conventional())?;
|
||||||
|
|||||||
531
src/llm/mod.rs
531
src/llm/mod.rs
@@ -2,6 +2,7 @@ use anyhow::{bail, Context, Result};
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use crate::config::Language;
|
||||||
|
|
||||||
pub mod ollama;
|
pub mod ollama;
|
||||||
pub mod openai;
|
pub mod openai;
|
||||||
@@ -120,15 +121,9 @@ impl LlmClient {
|
|||||||
&self,
|
&self,
|
||||||
diff: &str,
|
diff: &str,
|
||||||
format: crate::config::CommitFormat,
|
format: crate::config::CommitFormat,
|
||||||
|
language: Language,
|
||||||
) -> Result<GeneratedCommit> {
|
) -> Result<GeneratedCommit> {
|
||||||
let system_prompt = match format {
|
let system_prompt = get_commit_system_prompt(format, language);
|
||||||
crate::config::CommitFormat::Conventional => {
|
|
||||||
CONVENTIONAL_COMMIT_SYSTEM_PROMPT
|
|
||||||
}
|
|
||||||
crate::config::CommitFormat::Commitlint => {
|
|
||||||
COMMITLINT_SYSTEM_PROMPT
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let prompt = format!("{}", diff);
|
let prompt = format!("{}", diff);
|
||||||
let response = self.provider.generate_with_system(system_prompt, &prompt).await?;
|
let response = self.provider.generate_with_system(system_prompt, &prompt).await?;
|
||||||
@@ -362,6 +357,34 @@ impl GeneratedCommit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// HTTP client helper
|
||||||
|
pub(crate) fn create_http_client(timeout: Duration) -> Result<reqwest::Client> {
|
||||||
|
reqwest::Client::builder()
|
||||||
|
.timeout(timeout)
|
||||||
|
.build()
|
||||||
|
.context("Failed to create HTTP client")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get commit system prompt based on format and language
|
||||||
|
fn get_commit_system_prompt(format: crate::config::CommitFormat, language: Language) -> &'static str {
|
||||||
|
match (format, language) {
|
||||||
|
(crate::config::CommitFormat::Conventional, Language::Chinese) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT_ZH,
|
||||||
|
(crate::config::CommitFormat::Conventional, Language::Japanese) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT_JA,
|
||||||
|
(crate::config::CommitFormat::Conventional, Language::Korean) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT_KO,
|
||||||
|
(crate::config::CommitFormat::Conventional, Language::Spanish) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT_ES,
|
||||||
|
(crate::config::CommitFormat::Conventional, Language::French) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT_FR,
|
||||||
|
(crate::config::CommitFormat::Conventional, Language::German) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT_DE,
|
||||||
|
(crate::config::CommitFormat::Conventional, _) => CONVENTIONAL_COMMIT_SYSTEM_PROMPT,
|
||||||
|
(crate::config::CommitFormat::Commitlint, Language::Chinese) => COMMITLINT_SYSTEM_PROMPT_ZH,
|
||||||
|
(crate::config::CommitFormat::Commitlint, Language::Japanese) => COMMITLINT_SYSTEM_PROMPT_JA,
|
||||||
|
(crate::config::CommitFormat::Commitlint, Language::Korean) => COMMITLINT_SYSTEM_PROMPT_KO,
|
||||||
|
(crate::config::CommitFormat::Commitlint, Language::Spanish) => COMMITLINT_SYSTEM_PROMPT_ES,
|
||||||
|
(crate::config::CommitFormat::Commitlint, Language::French) => COMMITLINT_SYSTEM_PROMPT_FR,
|
||||||
|
(crate::config::CommitFormat::Commitlint, Language::German) => COMMITLINT_SYSTEM_PROMPT_DE,
|
||||||
|
(crate::config::CommitFormat::Commitlint, _) => COMMITLINT_SYSTEM_PROMPT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// System prompts for LLM
|
// System prompts for LLM
|
||||||
|
|
||||||
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates conventional commit messages.
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates conventional commit messages.
|
||||||
@@ -394,6 +417,186 @@ Rules:
|
|||||||
Output ONLY the commit message, nothing else.
|
Output ONLY the commit message, nothing else.
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT_ZH: &str = r#"你是一个生成符合 Conventional Commits 规范的提交消息的助手。
|
||||||
|
|
||||||
|
分析提供的 git diff,并生成符合 Conventional Commits 规范的提交消息。
|
||||||
|
|
||||||
|
格式: <type>[可选作用域]: <描述>
|
||||||
|
|
||||||
|
类型:
|
||||||
|
- feat: 新功能
|
||||||
|
- fix: 修复错误
|
||||||
|
- docs: 仅文档更改
|
||||||
|
- style: 不影响代码含义的更改(格式化、分号等)
|
||||||
|
- refactor: 既不修复错误也不添加功能的代码更改
|
||||||
|
- perf: 提高性能的代码更改
|
||||||
|
- test: 添加或更正测试
|
||||||
|
- build: 更改构建系统或依赖项
|
||||||
|
- ci: 更改 CI 配置
|
||||||
|
- chore: 其他不修改 src 或测试文件的更改
|
||||||
|
- revert: 撤销之前的提交
|
||||||
|
|
||||||
|
规则:
|
||||||
|
1. 类型和小写使用小写
|
||||||
|
2. 描述保持在 100 个字符以内
|
||||||
|
3. 使用祈使语气("添加"而不是"已添加")
|
||||||
|
4. 不要大写首字母
|
||||||
|
5. 结尾不要句号
|
||||||
|
6. 如果更改特定于模块/组件,请包含作用域
|
||||||
|
|
||||||
|
仅输出提交消息,不要输出其他内容。
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT_JA: &str = r#"あなたはConventional Commits仕様に従ったコミットメッセージを生成するアシスタントです。
|
||||||
|
|
||||||
|
提供されたgit diffを分析し、Conventional Commits仕様に従ったコミットメッセージを生成してください。
|
||||||
|
|
||||||
|
形式: <type>[オプションのスコープ]: <説明>
|
||||||
|
|
||||||
|
タイプ:
|
||||||
|
- feat: 新機能
|
||||||
|
- fix: バグ修正
|
||||||
|
- docs: ドキュメントのみの変更
|
||||||
|
- style: コードの意味に影響しない変更(フォーマット、セミコロンなど)
|
||||||
|
- refactor: バグ修正や機能追加を伴わないコード変更
|
||||||
|
- perf: パフォーマンスを向上させるコード変更
|
||||||
|
- test: テストの追加または修正
|
||||||
|
- build: ビルドシステムまたは依存関係の変更
|
||||||
|
- ci: CI設定の変更
|
||||||
|
- chore: srcやテストファイルを変更しないその他の変更
|
||||||
|
- revert: 以前のコミットを取り消す
|
||||||
|
|
||||||
|
ルール:
|
||||||
|
1. タイプとスコープは小文字を使用
|
||||||
|
2. 説明は100文字以内にする
|
||||||
|
3. 命令形を使用する("追加"ではなく"追加する")
|
||||||
|
4. 先頭を大文字にしない
|
||||||
|
5. 最後にピリオドを付けない
|
||||||
|
6. 変更がモジュール/コンポーネントに固有の場合はスコープを含める
|
||||||
|
|
||||||
|
コミットメッセージのみを出力し、それ以外は出力しないでください。
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT_KO: &str = r#"당신은 Conventional Commits 사양에 따른 커밋 메시지를 생성하는 도우미입니다.
|
||||||
|
|
||||||
|
제공된 git diff를 분석하고 Conventional Commits 사양에 따른 커밋 메시지를 생성하세요.
|
||||||
|
|
||||||
|
형식: <type>[선택적 범위]: <설명>
|
||||||
|
|
||||||
|
유형:
|
||||||
|
- feat: 새 기능
|
||||||
|
- fix: 버그 수정
|
||||||
|
- docs: 문서 변경만
|
||||||
|
- style: 코드 의미에 영향을 주지 않는 변경(서식, 세미콜론 등)
|
||||||
|
- refactor: 버그를 수정하거나 기능을 추가하지 않는 코드 변경
|
||||||
|
- perf: 성능을 향상시키는 코드 변경
|
||||||
|
- test: 테스트 추가 또는 수정
|
||||||
|
- build: 빌드 시스템 또는 종속성 변경
|
||||||
|
- ci: CI 구성 변경
|
||||||
|
- chore: src 또는 테스트 파일을 수정하지 않는 기타 변경
|
||||||
|
- revert: 이전 커밋 되돌리기
|
||||||
|
|
||||||
|
규칙:
|
||||||
|
1. 유형과 범위는 소문자 사용
|
||||||
|
2. 설명은 100자 이내로 유지
|
||||||
|
3. 명령형 사용("추가"가 아닌 "추가하다")
|
||||||
|
4. 첫 글자 대문자화하지 않음
|
||||||
|
5. 끝에 마침표 사용하지 않음
|
||||||
|
6. 변경 사항이 모듈/구성 요소에 특정한 경우 범위 포함
|
||||||
|
|
||||||
|
커밋 메시지만 출력하고 다른 내용은 출력하지 마세요.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT_ES: &str = r#"Eres un asistente que genera mensajes de commit siguiendo la especificación Conventional Commits.
|
||||||
|
|
||||||
|
Analiza el diff de git proporcionado y genera un mensaje de commit siguiendo la especificación Conventional Commits.
|
||||||
|
|
||||||
|
Formato: <tipo>[alcance opcional]: <descripción>
|
||||||
|
|
||||||
|
Tipos:
|
||||||
|
- feat: Una nueva característica
|
||||||
|
- fix: Una corrección de error
|
||||||
|
- docs: Solo cambios en documentación
|
||||||
|
- style: Cambios que no afectan el significado del código (formato, punto y coma, etc.)
|
||||||
|
- refactor: Cambio de código que no corrige un error ni agrega una característica
|
||||||
|
- perf: Cambio de código que mejora el rendimiento
|
||||||
|
- test: Agregar o corregir pruebas
|
||||||
|
- build: Cambios en el sistema de construcción o dependencias
|
||||||
|
- ci: Cambios en la configuración de CI
|
||||||
|
- chore: Otros cambios que no modifican archivos src o de prueba
|
||||||
|
- revert: Revierte un commit anterior
|
||||||
|
|
||||||
|
Reglas:
|
||||||
|
1. Usa minúsculas para tipo y alcance
|
||||||
|
2. Mantén la descripción bajo 100 caracteres
|
||||||
|
3. Usa modo imperativo ("agregar" no "agregado")
|
||||||
|
4. No capitalices la primera letra
|
||||||
|
5. Sin punto al final
|
||||||
|
6. Incluye alcance si el cambio es específico de un módulo/componente
|
||||||
|
|
||||||
|
Genera SOLO el mensaje de commit, nada más.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT_FR: &str = r#"Vous êtes un assistant qui génère des messages de commit suivant la spécification Conventional Commits.
|
||||||
|
|
||||||
|
Analysez le diff git fourni et générez un message de commit suivant la spécification Conventional Commits.
|
||||||
|
|
||||||
|
Format: <type>[portée optionnelle]: <description>
|
||||||
|
|
||||||
|
Types:
|
||||||
|
- feat: Une nouvelle fonctionnalité
|
||||||
|
- fix: Une correction de bug
|
||||||
|
- docs: Changements de documentation uniquement
|
||||||
|
- style: Changements qui n'affectent pas la signification du code (formatage, points-virgules, etc.)
|
||||||
|
- refactor: Changement de code qui ne corrige pas un bug ni n'ajoute une fonctionnalité
|
||||||
|
- perf: Changement de code qui améliore les performances
|
||||||
|
- test: Ajout ou correction de tests
|
||||||
|
- build: Changements du système de build ou des dépendances
|
||||||
|
- ci: Changements de la configuration CI
|
||||||
|
- chore: Autres changements qui ne modifient pas les fichiers src ou de test
|
||||||
|
- revert: Révertit un commit précédent
|
||||||
|
|
||||||
|
Règles:
|
||||||
|
1. Utilisez des minuscules pour le type et la portée
|
||||||
|
2. Gardez la description sous 100 caractères
|
||||||
|
3. Utilisez le mode impératif ("ajouter" non "ajouté")
|
||||||
|
4. Ne capitalisez pas la première lettre
|
||||||
|
5. Pas de point à la fin
|
||||||
|
6. Incluez la portée si le changement est spécifique à un module/composant
|
||||||
|
|
||||||
|
Générez SEULEMENT le message de commit, rien d'autre.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CONVENTIONAL_COMMIT_SYSTEM_PROMPT_DE: &str = r#"Sie sind ein Assistent, der Commit-Nachrichten gemäß der Conventional Commits-Spezifikation generiert.
|
||||||
|
|
||||||
|
Analysieren Sie den bereitgestellten git diff und generieren Sie eine Commit-Nachricht gemäß der Conventional Commits-Spezifikation.
|
||||||
|
|
||||||
|
Format: <typ>[optionaler Bereich]: <beschreibung>
|
||||||
|
|
||||||
|
Typen:
|
||||||
|
- feat: Eine neue Funktion
|
||||||
|
- fix: Ein Bugfix
|
||||||
|
- docs: Nur Dokumentationsänderungen
|
||||||
|
- style: Änderungen, die die Code-Bedeutung nicht beeinflussen (Formatierung, Semikolons usw.)
|
||||||
|
- refactor: Code-Änderung, die weder einen Bug behebt noch eine Funktion hinzufügt
|
||||||
|
- perf: Code-Änderung, die die Leistung verbessert
|
||||||
|
- test: Hinzufügen oder Korrigieren von Tests
|
||||||
|
- build: Änderungen am Build-System oder Abhängigkeiten
|
||||||
|
- ci: Änderungen an der CI-Konfiguration
|
||||||
|
- chore: Andere Änderungen, die src- oder Testdateien nicht ändern
|
||||||
|
- revert: Setzt einen vorherigen Commit zurück
|
||||||
|
|
||||||
|
Regeln:
|
||||||
|
1. Verwenden Sie Kleinbuchstaben für Typ und Bereich
|
||||||
|
2. Halten Sie die Beschreibung unter 100 Zeichen
|
||||||
|
3. Verwenden Sie den Imperativ ("hinzufügen" nicht "hinzugefügt")
|
||||||
|
4. Großschreiben Sie den ersten Buchstaben nicht
|
||||||
|
5. Kein Punkt am Ende
|
||||||
|
6. Fügen Sie einen Bereich ein, wenn die Änderung spezifisch für ein Modul/Komponente ist
|
||||||
|
|
||||||
|
Geben Sie NUR die Commit-Nachricht aus, nichts anderes.
|
||||||
|
"#;
|
||||||
|
|
||||||
const COMMITLINT_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates commit messages following @commitlint/config-conventional.
|
const COMMITLINT_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates commit messages following @commitlint/config-conventional.
|
||||||
|
|
||||||
Analyze the git diff and generate a commit message.
|
Analyze the git diff and generate a commit message.
|
||||||
@@ -412,6 +615,114 @@ Rules:
|
|||||||
Output ONLY the commit message, nothing else.
|
Output ONLY the commit message, nothing else.
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
|
const COMMITLINT_SYSTEM_PROMPT_ZH: &str = r#"你是一个生成符合 @commitlint/config-conventional 规范的提交消息的助手。
|
||||||
|
|
||||||
|
分析 git diff 并生成提交消息。
|
||||||
|
|
||||||
|
格式: <type>[可选作用域]: <主题>
|
||||||
|
|
||||||
|
类型: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||||
|
|
||||||
|
规则:
|
||||||
|
1. 主题不应以大写字母开头
|
||||||
|
2. 主题不应以句号结尾
|
||||||
|
3. 主题应为 4-100 个字符
|
||||||
|
4. 使用祈使语气
|
||||||
|
5. 简洁但描述性强
|
||||||
|
|
||||||
|
仅输出提交消息,不要输出其他内容。
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const COMMITLINT_SYSTEM_PROMPT_JA: &str = r#"あなたは@commitlint/config-conventionalに従ったコミットメッセージを生成するアシスタントです。
|
||||||
|
|
||||||
|
git diffを分析し、コミットメッセージを生成してください。
|
||||||
|
|
||||||
|
形式: <type>[オプションのスコープ]: <件名>
|
||||||
|
|
||||||
|
タイプ: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||||
|
|
||||||
|
ルール:
|
||||||
|
1. 件名は大文字で始めないでください
|
||||||
|
2. 件名はピリオドで終わらないでください
|
||||||
|
3. 件名は4-100文字である必要があります
|
||||||
|
4. 命令形を使用してください
|
||||||
|
5. 簡潔ですが説明的であること
|
||||||
|
|
||||||
|
コミットメッセージのみを出力し、それ以外は出力しないでください。
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const COMMITLINT_SYSTEM_PROMPT_KO: &str = r#"당신은 @commitlint/config-conventional에 따른 커밋 메시지를 생성하는 도우미입니다.
|
||||||
|
|
||||||
|
git diff를 분석하고 커밋 메시지를 생성하세요.
|
||||||
|
|
||||||
|
형식: <type>[선택적 범위]: <제목>
|
||||||
|
|
||||||
|
유형: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||||
|
|
||||||
|
규칙:
|
||||||
|
1. 제목은 대문자로 시작하지 않아야 합니다
|
||||||
|
2. 제목은 마침표로 끝나지 않아야 합니다
|
||||||
|
3. 제목은 4-100자여야 합니다
|
||||||
|
4. 명령형을 사용하세요
|
||||||
|
5. 간결하지만 설명적이어야 합니다
|
||||||
|
|
||||||
|
커밋 메시지만 출력하고 다른 내용은 출력하지 마세요.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const COMMITLINT_SYSTEM_PROMPT_ES: &str = r#"Eres un asistente que genera mensajes de commit siguiendo @commitlint/config-conventional.
|
||||||
|
|
||||||
|
Analiza el diff de git y genera un mensaje de commit.
|
||||||
|
|
||||||
|
Formato: <tipo>[alcance opcional]: <asunto>
|
||||||
|
|
||||||
|
Tipos: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||||
|
|
||||||
|
Reglas:
|
||||||
|
1. El asunto no debe comenzar con mayúscula
|
||||||
|
2. El asunto no debe terminar con punto
|
||||||
|
3. El asunto debe tener 4-100 caracteres
|
||||||
|
4. Usa modo imperativo
|
||||||
|
5. Sé conciso pero descriptivo
|
||||||
|
|
||||||
|
Genera SOLO el mensaje de commit, nada más.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const COMMITLINT_SYSTEM_PROMPT_FR: &str = r#"Vous êtes un assistant qui génère des messages de commit suivant @commitlint/config-conventional.
|
||||||
|
|
||||||
|
Analysez le diff git et générez un message de commit.
|
||||||
|
|
||||||
|
Format: <type>[portée optionnelle]: <sujet>
|
||||||
|
|
||||||
|
Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||||
|
|
||||||
|
Règles:
|
||||||
|
1. Le sujet ne doit pas commencer par une majuscule
|
||||||
|
2. Le sujet ne doit pas se terminer par un point
|
||||||
|
3. Le sujet doit avoir 4-100 caractères
|
||||||
|
4. Utilisez le mode impératif
|
||||||
|
5. Soyez concis mais descriptif
|
||||||
|
|
||||||
|
Générez SEULEMENT le message de commit, rien d'autre.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const COMMITLINT_SYSTEM_PROMPT_DE: &str = r#"Sie sind ein Assistent, der Commit-Nachrichten gemäß @commitlint/config-conventional generiert.
|
||||||
|
|
||||||
|
Analysieren Sie den git diff und generieren Sie eine Commit-Nachricht.
|
||||||
|
|
||||||
|
Format: <typ>[optionaler Bereich]: <betreff>
|
||||||
|
|
||||||
|
Typen: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
|
||||||
|
|
||||||
|
Regeln:
|
||||||
|
1. Der Betreff sollte nicht mit einem Großbuchstaben beginnen
|
||||||
|
2. Der Betreff sollte nicht mit einem Punkt enden
|
||||||
|
3. Der Betreff sollte 4-100 Zeichen haben
|
||||||
|
4. Verwenden Sie den Imperativ
|
||||||
|
5. Seien Sie prägnant aber beschreibend
|
||||||
|
|
||||||
|
Geben Sie NUR die Commit-Nachricht aus, nichts anderes.
|
||||||
|
"#;
|
||||||
|
|
||||||
const TAG_MESSAGE_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates git tag annotation messages.
|
const TAG_MESSAGE_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates git tag annotation messages.
|
||||||
|
|
||||||
Given a version number and a list of commits, generate a concise but informative tag message.
|
Given a version number and a list of commits, generate a concise but informative tag message.
|
||||||
@@ -432,6 +743,126 @@ Changes:
|
|||||||
...
|
...
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
|
const TAG_MESSAGE_SYSTEM_PROMPT_ZH: &str = r#"你是一个生成 git 标签注释消息的助手。
|
||||||
|
|
||||||
|
给定版本号和提交列表,生成简洁但信息丰富的标签消息。
|
||||||
|
|
||||||
|
消息应该:
|
||||||
|
1. 以发布的简要摘要开始
|
||||||
|
2. 按类型分组更改(功能、修复等)
|
||||||
|
3. 适合 git 标注标签
|
||||||
|
|
||||||
|
格式:
|
||||||
|
<version> 发布
|
||||||
|
|
||||||
|
更改摘要...
|
||||||
|
|
||||||
|
更改:
|
||||||
|
- 功能:描述
|
||||||
|
- 修复:描述
|
||||||
|
...
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const TAG_MESSAGE_SYSTEM_PROMPT_JA: &str = r#"あなたはgitタグ注釈メッセージを生成するアシスタントです。
|
||||||
|
|
||||||
|
バージョン番号とコミットのリストを考慮して、簡潔ですが情報豊富なタグメッセージを生成してください。
|
||||||
|
|
||||||
|
メッセージは以下のようであるべきです:
|
||||||
|
1. リリースの簡単な要約から始める
|
||||||
|
2. タイプ別に変更をグループ化する(機能、修正など)
|
||||||
|
3. git注釈タグに適している
|
||||||
|
|
||||||
|
形式:
|
||||||
|
<version> リリース
|
||||||
|
|
||||||
|
変更の概要...
|
||||||
|
|
||||||
|
変更:
|
||||||
|
- 機能:説明
|
||||||
|
- 修正:説明
|
||||||
|
...
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const TAG_MESSAGE_SYSTEM_PROMPT_KO: &str = r#"당신은 git 태그 주석 메시지를 생성하는 도우미입니다.
|
||||||
|
|
||||||
|
버전 번호와 커밋 목록을 고려하여 간결하지만 정보가 풍부한 태그 메시지를 생성하세요.
|
||||||
|
|
||||||
|
메시지는 다음과 같아야 합니다:
|
||||||
|
1. 릴리스의 간단한 요약으로 시작
|
||||||
|
2. 유형별로 변경 사항 그룹화(기능, 수정 등)
|
||||||
|
3. git 주석 태그에 적합
|
||||||
|
|
||||||
|
형식:
|
||||||
|
<version> 릴리스
|
||||||
|
|
||||||
|
변경 사항 요약...
|
||||||
|
|
||||||
|
변경 사항:
|
||||||
|
- 기능: 설명
|
||||||
|
- 수정: 설명
|
||||||
|
...
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const TAG_MESSAGE_SYSTEM_PROMPT_ES: &str = r#"Eres un asistente que genera mensajes de anotación de etiquetas git.
|
||||||
|
|
||||||
|
Dado un número de versión y una lista de commits, genera un mensaje de etiqueta conciso pero informativo.
|
||||||
|
|
||||||
|
El mensaje debe:
|
||||||
|
1. Comenzar con un resumen breve de la versión
|
||||||
|
2. Agrupar cambios por tipo (características, correcciones, etc.)
|
||||||
|
3. Ser adecuado para una etiqueta git anotada
|
||||||
|
|
||||||
|
Formato:
|
||||||
|
<version> Versión
|
||||||
|
|
||||||
|
Resumen de cambios...
|
||||||
|
|
||||||
|
Cambios:
|
||||||
|
- Característica: descripción
|
||||||
|
- Corrección: descripción
|
||||||
|
...
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const TAG_MESSAGE_SYSTEM_PROMPT_FR: &str = r#"Vous êtes un assistant qui génère des messages d'annotation de balises git.
|
||||||
|
|
||||||
|
Étant donné un numéro de version et une liste de commits, générez un message de balise concis mais informatif.
|
||||||
|
|
||||||
|
Le message doit :
|
||||||
|
1. Commencer par un bref résumé de la version
|
||||||
|
2. Grouper les changements par type (fonctionnalités, corrections, etc.)
|
||||||
|
3. Être adapté à une balise git annotée
|
||||||
|
|
||||||
|
Format :
|
||||||
|
<version> Version
|
||||||
|
|
||||||
|
Résumé des changements...
|
||||||
|
|
||||||
|
Changements :
|
||||||
|
- Fonctionnalité : description
|
||||||
|
- Correction : description
|
||||||
|
...
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const TAG_MESSAGE_SYSTEM_PROMPT_DE: &str = r#"Sie sind ein Assistent, der git-Tag-Anmerkungsnachrichten generiert.
|
||||||
|
|
||||||
|
Gegeben eine Versionsnummer und eine Liste von Commits, generieren Sie eine prägnante aber informative Tag-Nachricht.
|
||||||
|
|
||||||
|
Die Nachricht sollte:
|
||||||
|
1. Mit einer kurzen Zusammenfassung der Version beginnen
|
||||||
|
2. Änderungen nach Typ gruppieren (Funktionen, Fixes, etc.)
|
||||||
|
3. Für ein git-annotiertes Tag geeignet sein
|
||||||
|
|
||||||
|
Format:
|
||||||
|
<version> Version
|
||||||
|
|
||||||
|
Zusammenfassung der Änderungen...
|
||||||
|
|
||||||
|
Änderungen:
|
||||||
|
- Funktion: Beschreibung
|
||||||
|
- Fix: Beschreibung
|
||||||
|
...
|
||||||
|
"#;
|
||||||
|
|
||||||
const CHANGELOG_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates changelog entries.
|
const CHANGELOG_SYSTEM_PROMPT: &str = r#"You are a helpful assistant that generates changelog entries.
|
||||||
|
|
||||||
Given a version and a list of commits, generate a well-formatted changelog section.
|
Given a version and a list of commits, generate a well-formatted changelog section.
|
||||||
@@ -445,10 +876,80 @@ Group commits by:
|
|||||||
Format in markdown with proper headings and bullet points.
|
Format in markdown with proper headings and bullet points.
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
/// HTTP client helper
|
const CHANGELOG_SYSTEM_PROMPT_ZH: &str = r#"你是一个生成变更日志条目的助手。
|
||||||
pub(crate) fn create_http_client(timeout: Duration) -> Result<reqwest::Client> {
|
|
||||||
reqwest::Client::builder()
|
给定版本和提交列表,生成格式良好的变更日志部分。
|
||||||
.timeout(timeout)
|
|
||||||
.build()
|
按以下方式分组提交:
|
||||||
.context("Failed to create HTTP client")
|
- 功能 (feat)
|
||||||
}
|
- 错误修复 (fix)
|
||||||
|
- 文档 (docs)
|
||||||
|
- 其他更改
|
||||||
|
|
||||||
|
使用适当的标题和项目符号以 markdown 格式输出。
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CHANGELOG_SYSTEM_PROMPT_JA: &str = r#"あなたは変更ログエントリを生成するアシスタントです。
|
||||||
|
|
||||||
|
バージョンとコミットのリストを考慮して、適切にフォーマットされた変更ログセクションを生成してください。
|
||||||
|
|
||||||
|
コミットを以下でグループ化してください:
|
||||||
|
- 機能 (feat)
|
||||||
|
- バグ修正 (fix)
|
||||||
|
- ドキュメント (docs)
|
||||||
|
- その他の変更
|
||||||
|
|
||||||
|
適切な見出しと箇条書きを使用してmarkdown形式でフォーマットしてください。
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CHANGELOG_SYSTEM_PROMPT_KO: &str = r#"당신은 변경 로그 항목을 생성하는 도우미입니다.
|
||||||
|
|
||||||
|
버전과 커밋 목록을 고려하여 잘 포맷된 변경 로그 섹션을 생성하세요.
|
||||||
|
|
||||||
|
다음으로 커밋을 그룹화하세요:
|
||||||
|
- 기능 (feat)
|
||||||
|
- 버그 수정 (fix)
|
||||||
|
- 문서 (docs)
|
||||||
|
- 기타 변경 사항
|
||||||
|
|
||||||
|
적절한 제목과 글머리 기호를 사용하여 markdown 형식으로 포맷하세요.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CHANGELOG_SYSTEM_PROMPT_ES: &str = r#"Eres un asistente que genera entradas de registro de cambios.
|
||||||
|
|
||||||
|
Dada una versión y una lista de commits, genera una sección de registro de cambios bien formateada.
|
||||||
|
|
||||||
|
Agrupa los commits por:
|
||||||
|
- Características (feat)
|
||||||
|
- Correcciones de errores (fix)
|
||||||
|
- Documentación (docs)
|
||||||
|
- Otros cambios
|
||||||
|
|
||||||
|
Formatea en markdown con encabezados y viñetas apropiados.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CHANGELOG_SYSTEM_PROMPT_FR: &str = r#"Vous êtes un assistant qui génère des entrées de journal des modifications.
|
||||||
|
|
||||||
|
Étant donné une version et une liste de commits, générez une section de journal des modifications bien formatée.
|
||||||
|
|
||||||
|
Groupez les commits par :
|
||||||
|
- Fonctionnalités (feat)
|
||||||
|
- Corrections de bugs (fix)
|
||||||
|
- Documentation (docs)
|
||||||
|
- Autres modifications
|
||||||
|
|
||||||
|
Formatez en markdown avec des en-têtes et des puces appropriés.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const CHANGELOG_SYSTEM_PROMPT_DE: &str = r#"Sie sind ein Assistent, der Changelog-Einträge generiert.
|
||||||
|
|
||||||
|
Gegeben eine Version und eine Liste von Commits, generieren Sie einen gut formatierten Changelog-Abschnitt.
|
||||||
|
|
||||||
|
Gruppieren Sie Commits nach:
|
||||||
|
- Funktionen (feat)
|
||||||
|
- Bugfixes (fix)
|
||||||
|
- Dokumentation (docs)
|
||||||
|
- Andere Änderungen
|
||||||
|
|
||||||
|
Formatieren Sie in Markdown mit geeigneten Überschriften und Aufzählungspunkten.
|
||||||
|
"#;
|
||||||
|
|||||||
Reference in New Issue
Block a user