Skip to content

Commit c40d857

Browse files
authored
fix(agent): removes agent rename (#2434)
1 parent f212b66 commit c40d857

File tree

2 files changed

+0
-99
lines changed

2 files changed

+0
-99
lines changed

crates/chat-cli/src/cli/agent/root_command_args.rs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ pub enum AgentSubcommands {
3232
/// List the available agents. Note that local agents are only discovered if the command is
3333
/// invoked at a directory that contains them
3434
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-
},
4435
/// Create an agent config. If path is not provided, Q CLI shall create this config in the
4536
/// global agent directory
4637
Create {
@@ -140,11 +131,6 @@ impl AgentArgs {
140131
path_with_file_name.display()
141132
)?;
142133
},
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-
},
148134
Some(AgentSubcommands::Validate { path }) => {
149135
let mut global_mcp_config = None::<McpServerConfig>;
150136
let agent = Agent::load(os, path.as_str(), &mut global_mcp_config).await;
@@ -354,43 +340,6 @@ pub async fn create_agent(
354340
Ok(path_with_file_name)
355341
}
356342

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-
394343
#[cfg(test)]
395344
mod tests {
396345
use super::*;
@@ -420,17 +369,4 @@ mod tests {
420369
})
421370
);
422371
}
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-
}
436372
}

crates/chat-cli/src/cli/chat/cli/profile.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::cli::agent::{
2626
Agent,
2727
Agents,
2828
create_agent,
29-
rename_agent,
3029
};
3130
use crate::cli::chat::{
3231
ChatError,
@@ -71,16 +70,6 @@ pub enum AgentSubcommand {
7170
/// Switch to the specified agent
7271
#[command(hide = true)]
7372
Set { name: String },
74-
/// Rename an agent. Should this be the current active agent, its changes will take effect upon
75-
/// next launch
76-
Rename {
77-
/// Original name of the agent
78-
#[arg(long, short)]
79-
agent: String,
80-
/// New name the agent shall be changed to
81-
#[arg(long, short)]
82-
new_name: String,
83-
},
8473
/// Show agent config schema
8574
Schema,
8675
/// Define a default agent to use when q chat launches
@@ -188,29 +177,6 @@ impl AgentSubcommand {
188177
style::SetForegroundColor(Color::Reset)
189178
)?;
190179
},
191-
Self::Rename { agent, new_name } => {
192-
let mut agents = Agents::load(os, None, true, &mut session.stderr).await.0;
193-
rename_agent(os, &mut agents, agent.clone(), new_name.clone())
194-
.await
195-
.map_err(|e| ChatError::Custom(Cow::Owned(e.to_string())))?;
196-
197-
execute!(
198-
session.stderr,
199-
style::SetForegroundColor(Color::Green),
200-
style::Print("Agent "),
201-
style::SetForegroundColor(Color::Cyan),
202-
style::Print(agent),
203-
style::SetForegroundColor(Color::Green),
204-
style::Print(" has been renamed to "),
205-
style::SetForegroundColor(Color::Cyan),
206-
style::Print(new_name),
207-
style::SetForegroundColor(Color::Reset),
208-
style::Print("\n"),
209-
style::SetForegroundColor(Color::Yellow),
210-
style::Print("Changes take effect on next launch"),
211-
style::SetForegroundColor(Color::Reset)
212-
)?;
213-
},
214180
Self::Set { .. } | Self::Delete { .. } => {
215181
// As part of the agent implementation, we are disabling the ability to
216182
// switch / create profile after a session has started.
@@ -271,7 +237,6 @@ impl AgentSubcommand {
271237
Self::Create { .. } => "create",
272238
Self::Delete { .. } => "delete",
273239
Self::Set { .. } => "set",
274-
Self::Rename { .. } => "rename",
275240
Self::Schema => "schema",
276241
Self::SetDefault { .. } => "set_default",
277242
}

0 commit comments

Comments
 (0)