@@ -32,15 +32,6 @@ pub enum AgentSubcommands {
32
32
/// List the available agents. Note that local agents are only discovered if the command is
33
33
/// invoked at a directory that contains them
34
34
List ,
35
- /// Renames a given agent to a new name
36
- Rename {
37
- /// Original name of the agent
38
- #[ arg( long, short) ]
39
- agent : String ,
40
- /// New name the agent shall be changed to
41
- #[ arg( long, short) ]
42
- new_name : String ,
43
- } ,
44
35
/// Create an agent config. If path is not provided, Q CLI shall create this config in the
45
36
/// global agent directory
46
37
Create {
@@ -140,11 +131,6 @@ impl AgentArgs {
140
131
path_with_file_name. display( )
141
132
) ?;
142
133
} ,
143
- Some ( AgentSubcommands :: Rename { agent, new_name } ) => {
144
- let mut agents = Agents :: load ( os, None , true , & mut stderr) . await . 0 ;
145
- rename_agent ( os, & mut agents, agent. clone ( ) , new_name. clone ( ) ) . await ?;
146
- writeln ! ( stderr, "\n ✓ Renamed agent '{}' to '{}'\n " , agent, new_name) ?;
147
- } ,
148
134
Some ( AgentSubcommands :: Validate { path } ) => {
149
135
let mut global_mcp_config = None :: < McpServerConfig > ;
150
136
let agent = Agent :: load ( os, path. as_str ( ) , & mut global_mcp_config) . await ;
@@ -354,43 +340,6 @@ pub async fn create_agent(
354
340
Ok ( path_with_file_name)
355
341
}
356
342
357
- pub async fn rename_agent ( os : & mut Os , agents : & mut Agents , agent : String , new_name : String ) -> Result < ( ) > {
358
- if agents. agents . iter ( ) . any ( |( name, _) | name == & new_name) {
359
- bail ! ( "New name {new_name} already exists in the current scope. Aborting" ) ;
360
- }
361
-
362
- match agents. switch ( agent. as_str ( ) ) {
363
- Ok ( target_agent) => {
364
- if let Some ( path) = target_agent. path . as_ref ( ) {
365
- let new_path = path
366
- . parent ( )
367
- . map ( |p| p. join ( format ! ( "{new_name}.json" ) ) )
368
- . ok_or ( eyre:: eyre!( "Failed to retrieve parent directory of target config" ) ) ?;
369
- os. fs . rename ( path, new_path) . await ?;
370
-
371
- if let Some ( default_agent) = os. database . settings . get_string ( Setting :: ChatDefaultAgent ) {
372
- let global_agent_path = directories:: chat_global_agent_path ( os) ?;
373
- if default_agent == agent
374
- && target_agent
375
- . path
376
- . as_ref ( )
377
- . is_some_and ( |p| p. parent ( ) . is_some_and ( |p| p == global_agent_path) )
378
- {
379
- os. database . settings . set ( Setting :: ChatDefaultAgent , new_name) . await ?;
380
- }
381
- }
382
- } else {
383
- bail ! ( "Target agent has no path associated. Aborting" ) ;
384
- }
385
- } ,
386
- Err ( e) => {
387
- bail ! ( e) ;
388
- } ,
389
- }
390
-
391
- Ok ( ( ) )
392
- }
393
-
394
343
#[ cfg( test) ]
395
344
mod tests {
396
345
use super :: * ;
@@ -420,17 +369,4 @@ mod tests {
420
369
} )
421
370
) ;
422
371
}
423
-
424
- #[ test]
425
- fn test_agent_subcommand_rename ( ) {
426
- assert_parse ! (
427
- [ "agent" , "rename" , "--agent" , "old_name" , "--new-name" , "new_name" ] ,
428
- RootSubcommand :: Agent ( AgentArgs {
429
- cmd: Some ( AgentSubcommands :: Rename {
430
- agent: "old_name" . to_string( ) ,
431
- new_name: "new_name" . to_string( ) ,
432
- } )
433
- } )
434
- ) ;
435
- }
436
372
}
0 commit comments