@@ -78,6 +78,11 @@ def config_group():
7878 type = int ,
7979 help = "Maximum tokens per leaf module (default: 16000)"
8080)
81+ @click .option (
82+ "--max-depth" ,
83+ type = int ,
84+ help = "Maximum depth for hierarchical decomposition (default: 2)"
85+ )
8186def config_set (
8287 api_key : Optional [str ],
8388 base_url : Optional [str ],
@@ -86,7 +91,8 @@ def config_set(
8691 fallback_model : Optional [str ],
8792 max_tokens : Optional [int ],
8893 max_token_per_module : Optional [int ],
89- max_token_per_leaf_module : Optional [int ]
94+ max_token_per_leaf_module : Optional [int ],
95+ max_depth : Optional [int ]
9096):
9197 """
9298 Set configuration values for CodeWiki.
@@ -114,10 +120,14 @@ def config_set(
114120 \b
115121 # Set all max token settings
116122 $ codewiki config set --max-tokens 32768 --max-token-per-module 40000 --max-token-per-leaf-module 20000
123+
124+ \b
125+ # Set max depth for hierarchical decomposition
126+ $ codewiki config set --max-depth 3
117127 """
118128 try :
119129 # Check if at least one option is provided
120- if not any ([api_key , base_url , main_model , cluster_model , fallback_model , max_tokens , max_token_per_module , max_token_per_leaf_module ]):
130+ if not any ([api_key , base_url , main_model , cluster_model , fallback_model , max_tokens , max_token_per_module , max_token_per_leaf_module , max_depth ]):
121131 click .echo ("No options provided. Use --help for usage information." )
122132 sys .exit (EXIT_CONFIG_ERROR )
123133
@@ -154,6 +164,11 @@ def config_set(
154164 raise ConfigurationError ("max_token_per_leaf_module must be a positive integer" )
155165 validated_data ['max_token_per_leaf_module' ] = max_token_per_leaf_module
156166
167+ if max_depth is not None :
168+ if max_depth < 1 :
169+ raise ConfigurationError ("max_depth must be a positive integer" )
170+ validated_data ['max_depth' ] = max_depth
171+
157172 # Create config manager and save
158173 manager = ConfigManager ()
159174 manager .load () # Load existing config if present
@@ -166,7 +181,8 @@ def config_set(
166181 fallback_model = validated_data .get ('fallback_model' ),
167182 max_tokens = validated_data .get ('max_tokens' ),
168183 max_token_per_module = validated_data .get ('max_token_per_module' ),
169- max_token_per_leaf_module = validated_data .get ('max_token_per_leaf_module' )
184+ max_token_per_leaf_module = validated_data .get ('max_token_per_leaf_module' ),
185+ max_depth = validated_data .get ('max_depth' )
170186 )
171187
172188 # Display success messages
@@ -212,6 +228,9 @@ def config_set(
212228 if max_token_per_leaf_module :
213229 click .secho (f"✓ Max token per leaf module: { max_token_per_leaf_module } " , fg = "green" )
214230
231+ if max_depth :
232+ click .secho (f"✓ Max depth: { max_depth } " , fg = "green" )
233+
215234 click .echo ("\n " + click .style ("Configuration updated successfully." , fg = "green" , bold = True ))
216235
217236 except ConfigurationError as e :
@@ -271,6 +290,7 @@ def config_show(output_json: bool):
271290 "max_tokens" : config .max_tokens if config else 32768 ,
272291 "max_token_per_module" : config .max_token_per_module if config else 36369 ,
273292 "max_token_per_leaf_module" : config .max_token_per_leaf_module if config else 16000 ,
293+ "max_depth" : config .max_depth if config else 2 ,
274294 "agent_instructions" : config .agent_instructions .to_dict () if config and config .agent_instructions else {},
275295 "config_file" : str (manager .config_file_path )
276296 }
@@ -311,6 +331,11 @@ def config_show(output_json: bool):
311331 click .echo (f" Max Token/Module: { config .max_token_per_module } " )
312332 click .echo (f" Max Token/Leaf Module: { config .max_token_per_leaf_module } " )
313333
334+ click .echo ()
335+ click .secho ("Decomposition Settings" , fg = "cyan" , bold = True )
336+ if config :
337+ click .echo (f" Max Depth: { config .max_depth } " )
338+
314339 click .echo ()
315340 click .secho ("Agent Instructions" , fg = "cyan" , bold = True )
316341 if config and config .agent_instructions and not config .agent_instructions .is_empty ():
0 commit comments