From 2b4f91025c4a294c605e90ca3d4a02715544aa30 Mon Sep 17 00:00:00 2001 From: Bortlesboat Date: Mon, 11 May 2026 14:35:13 -0400 Subject: [PATCH] fix: include agent config in uninstall purge --- src/cortex-cli/src/agent_cmd/tests.rs | 5 ++--- src/cortex-cli/src/uninstall_cmd.rs | 30 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/cortex-cli/src/agent_cmd/tests.rs b/src/cortex-cli/src/agent_cmd/tests.rs index e2ff07f9f..18f7ba753 100644 --- a/src/cortex-cli/src/agent_cmd/tests.rs +++ b/src/cortex-cli/src/agent_cmd/tests.rs @@ -3,10 +3,9 @@ #[cfg(test)] mod tests { use crate::agent_cmd::cli::{CopyArgs, ExportArgs}; - use crate::agent_cmd::loader::{ - load_builtin_agents, parse_frontmatter, read_file_with_encoding, - }; + use crate::agent_cmd::loader::{load_builtin_agents, parse_frontmatter}; use crate::agent_cmd::types::AgentMode; + use crate::utils::file::read_file_with_encoding; #[test] fn test_read_file_with_utf8() { diff --git a/src/cortex-cli/src/uninstall_cmd.rs b/src/cortex-cli/src/uninstall_cmd.rs index aa4db4306..fc87a3c03 100644 --- a/src/cortex-cli/src/uninstall_cmd.rs +++ b/src/cortex-cli/src/uninstall_cmd.rs @@ -398,6 +398,8 @@ fn collect_cortex_home_items(home_dir: &Path) -> Result> { // Configuration files let config_files = [ ("config.toml", "Main configuration file"), + ("agents.toml", "Agent configuration"), + ("aliases.toml", "Command aliases"), ("credentials.json", "Authentication credentials"), ("auth.json", "OAuth tokens"), ]; @@ -976,4 +978,32 @@ mod tests { | InstallMethod::Unknown => {} } } + + #[test] + fn test_collect_cortex_home_items_includes_agent_config_files() { + let temp_home = tempfile::tempdir().unwrap(); + let cortex_home = temp_home.path().join(".cortex"); + fs::create_dir_all(&cortex_home).unwrap(); + + for file_name in ["config.toml", "agents.toml", "aliases.toml"] { + fs::write(cortex_home.join(file_name), "test = true\n").unwrap(); + } + + let items = collect_cortex_home_items(temp_home.path()).unwrap(); + + assert!( + items + .iter() + .any(|item| item.path == cortex_home.join("config.toml")), + "control config.toml should be collected" + ); + + for file_name in ["agents.toml", "aliases.toml"] { + let item = items + .iter() + .find(|item| item.path == cortex_home.join(file_name)) + .unwrap_or_else(|| panic!("{file_name} should be collected")); + assert_eq!(item.category, RemovalCategory::Config); + } + } }