Skip to main content

cmt/config/
defaults.rs

1//! Default values for configuration
2
3// General defaults
4pub const MESSAGE_ONLY: bool = false;
5pub const NO_DIFF_STATS: bool = false;
6pub const SHOW_RAW_DIFF: bool = false;
7pub const CONTEXT_LINES: u32 = 20; // Full function context - Gemini Flash supports 1M tokens
8pub const MAX_LINES_PER_FILE: usize = 2000; // Allow large files - we have token budget
9pub const MAX_LINE_WIDTH: usize = 500; // Allow wider lines for better context
10pub const MAX_FILE_LINES: usize = 5000; // Threshold for prompting to add to .cmtignore
11
12// Cmtignore defaults
13pub const CMTIGNORE_FILENAME: &str = ".cmtignore";
14
15// AI provider defaults
16pub const DEFAULT_PROVIDER: &str = "gemini";
17
18// Git defaults
19pub const INCLUDE_RECENT_COMMITS: bool = true;
20pub const RECENT_COMMITS_COUNT: usize = 10; // More history for better context
21
22// File paths
23pub const DEFAULT_CONFIG_FILENAME: &str = ".cmt.toml";
24pub const GLOBAL_CONFIG_DIRNAME: &str = ".config/cmt";
25pub const GLOBAL_CONFIG_FILENAME: &str = "config.toml";
26
27// Template defaults
28pub const DEFAULT_TEMPLATE: &str = "conventional";
29
30// Available providers
31pub const AVAILABLE_PROVIDERS: &[&str] = &["claude", "openai", "gemini"];
32
33// Last Verified: 2025-12-29 (use dated version - Anthropic API doesn't accept -latest aliases)
34pub const DEFAULT_CLAUDE_MODEL: &str = "claude-sonnet-4-5-20250929";
35// Last Verified: 2025-12-29
36pub const DEFAULT_OPENAI_MODEL: &str = "gpt-5.2";
37// Last Verified: 2025-12-29 (use -preview suffix for Gemini 3 models)
38pub const DEFAULT_GEMINI_MODEL: &str = "gemini-3-flash-preview";
39
40// Available templates
41pub const AVAILABLE_TEMPLATES: &[&str] = &["conventional", "simple", "detailed"];
42
43/// Example configuration for initialization
44pub fn example_config() -> String {
45    format!(
46        r#"# cmt configuration file
47
48# General options
49message_only = {}
50no_diff_stats = {}
51show_raw_diff = {}
52context_lines = {}
53max_lines_per_file = {}
54max_line_width = {}
55max_file_lines = {}
56
57# AI provider options
58provider = "{}"  # Options: {}
59# model = "{}"  # Uncomment to set a specific model
60# temperature = 0.3  # Uncomment to set a specific temperature
61
62# Git options
63include_recent_commits = {}
64recent_commits_count = {}
65
66# Template options
67# template = "{}"  # Uncomment to use a specific template
68
69# You can add a default hint that will be used for all commits
70# hint = "Focus on the technical details"
71"#,
72        MESSAGE_ONLY,
73        NO_DIFF_STATS,
74        SHOW_RAW_DIFF,
75        CONTEXT_LINES,
76        MAX_LINES_PER_FILE,
77        MAX_LINE_WIDTH,
78        MAX_FILE_LINES,
79        DEFAULT_PROVIDER,
80        AVAILABLE_PROVIDERS.join(", "),
81        DEFAULT_CLAUDE_MODEL,
82        INCLUDE_RECENT_COMMITS,
83        RECENT_COMMITS_COUNT,
84        DEFAULT_TEMPLATE,
85    )
86}
87
88/// Simple template
89pub fn simple_template() -> String {
90    r#"{{{subject}}}
91
92{{{details}}}"#
93        .to_string()
94}
95
96/// Conventional commits template (triple braces to avoid HTML escaping)
97pub fn conventional_template() -> String {
98    r#"{{type}}{{#if scope}}({{{scope}}}){{/if}}: {{{subject}}}
99
100{{#if details}}
101{{{details}}}
102{{/if}}"#
103        .to_string()
104}
105
106/// Detailed template (triple braces to avoid HTML escaping)
107pub fn detailed_template() -> String {
108    r#"{{type}}{{#if scope}}({{{scope}}}){{/if}}: {{{subject}}}
109
110{{#if details}}
111{{{details}}}
112{{/if}}
113
114{{#if issues}}
115Fixes: {{{issues}}}
116{{/if}}
117
118{{#if breaking}}
119BREAKING CHANGE: {{{breaking}}}
120{{/if}}"#
121        .to_string()
122}