@@ -33,6 +33,17 @@ export const VALID_CONFIG_KEYS = [
3333
3434export type ConfigKey = typeof VALID_CONFIG_KEYS [ number ] ;
3535
36+ /**
37+ * Short aliases for config keys
38+ */
39+ export const CONFIG_ALIASES : Record < string , ConfigKey > = {
40+ lang : "default_language" ,
41+ scope : "default_scope" ,
42+ type : "default_type" ,
43+ url : "ollama_url" ,
44+ temp : "temperature" ,
45+ } ;
46+
3647export function getConfigPath ( ) : string {
3748 return join ( homedir ( ) , ".config" , "git-commit-ai" , "config.toml" ) ;
3849}
@@ -154,24 +165,33 @@ export function showConfig(config: Config): string {
154165 * Returns an object with success status and message
155166 */
156167export function updateConfig ( key : string , value : string ) : { success : boolean ; message : string } {
168+ // Resolve alias to full key name
169+ const resolvedKey = CONFIG_ALIASES [ key ] || key ;
170+
157171 // Validate key
158- if ( ! VALID_CONFIG_KEYS . includes ( key as ConfigKey ) ) {
172+ if ( ! VALID_CONFIG_KEYS . includes ( resolvedKey as ConfigKey ) ) {
173+ const aliasHelp = Object . entries ( CONFIG_ALIASES )
174+ . map ( ( [ alias , full ] ) => `${ alias } → ${ full } ` )
175+ . join ( ", " ) ;
159176 return {
160177 success : false ,
161- message : `Invalid config key: "${ key } ". Valid keys: ${ VALID_CONFIG_KEYS . join ( ", " ) } ` ,
178+ message : `Invalid config key: "${ key } ". Valid keys: ${ VALID_CONFIG_KEYS . join ( ", " ) } . Aliases: ${ aliasHelp } ` ,
162179 } ;
163180 }
181+
182+ // Use resolved key from here
183+ const configKey = resolvedKey as ConfigKey ;
164184
165185 // Validate backend value
166- if ( key === "backend" && ! VALID_BACKENDS . includes ( value as BackendType ) ) {
186+ if ( configKey === "backend" && ! VALID_BACKENDS . includes ( value as BackendType ) ) {
167187 return {
168188 success : false ,
169189 message : `Invalid backend: "${ value } ". Valid backends: ${ VALID_BACKENDS . join ( ", " ) } ` ,
170190 } ;
171191 }
172192
173193 // Validate temperature value
174- if ( key === "temperature" ) {
194+ if ( configKey === "temperature" ) {
175195 const temp = parseFloat ( value ) ;
176196 if ( isNaN ( temp ) || temp < 0 || temp > 1 ) {
177197 return {
@@ -184,7 +204,7 @@ export function updateConfig(key: string, value: string): { success: boolean; me
184204 // Load current config and update
185205 const config = loadConfig ( ) ;
186206
187- switch ( key ) {
207+ switch ( configKey ) {
188208 case "backend" :
189209 config . backend = value as BackendType ;
190210 break ;
@@ -212,8 +232,11 @@ export function updateConfig(key: string, value: string): { success: boolean; me
212232 }
213233
214234 saveConfig ( config ) ;
235+
236+ // Show alias resolution in message if applicable
237+ const keyDisplay = key !== configKey ? `${ key } (${ configKey } )` : configKey ;
215238 return {
216239 success : true ,
217- message : `Config updated: ${ key } = "${ value } "` ,
240+ message : `Config updated: ${ keyDisplay } = "${ value } "` ,
218241 } ;
219242}
0 commit comments