Skip to content

Commit 2b4f910

Browse files
committed
fix: include agent config in uninstall purge
1 parent 7954d02 commit 2b4f910

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

src/cortex-cli/src/agent_cmd/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
#[cfg(test)]
44
mod tests {
55
use crate::agent_cmd::cli::{CopyArgs, ExportArgs};
6-
use crate::agent_cmd::loader::{
7-
load_builtin_agents, parse_frontmatter, read_file_with_encoding,
8-
};
6+
use crate::agent_cmd::loader::{load_builtin_agents, parse_frontmatter};
97
use crate::agent_cmd::types::AgentMode;
8+
use crate::utils::file::read_file_with_encoding;
109

1110
#[test]
1211
fn test_read_file_with_utf8() {

src/cortex-cli/src/uninstall_cmd.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ fn collect_cortex_home_items(home_dir: &Path) -> Result<Vec<RemovalItem>> {
398398
// Configuration files
399399
let config_files = [
400400
("config.toml", "Main configuration file"),
401+
("agents.toml", "Agent configuration"),
402+
("aliases.toml", "Command aliases"),
401403
("credentials.json", "Authentication credentials"),
402404
("auth.json", "OAuth tokens"),
403405
];
@@ -976,4 +978,32 @@ mod tests {
976978
| InstallMethod::Unknown => {}
977979
}
978980
}
981+
982+
#[test]
983+
fn test_collect_cortex_home_items_includes_agent_config_files() {
984+
let temp_home = tempfile::tempdir().unwrap();
985+
let cortex_home = temp_home.path().join(".cortex");
986+
fs::create_dir_all(&cortex_home).unwrap();
987+
988+
for file_name in ["config.toml", "agents.toml", "aliases.toml"] {
989+
fs::write(cortex_home.join(file_name), "test = true\n").unwrap();
990+
}
991+
992+
let items = collect_cortex_home_items(temp_home.path()).unwrap();
993+
994+
assert!(
995+
items
996+
.iter()
997+
.any(|item| item.path == cortex_home.join("config.toml")),
998+
"control config.toml should be collected"
999+
);
1000+
1001+
for file_name in ["agents.toml", "aliases.toml"] {
1002+
let item = items
1003+
.iter()
1004+
.find(|item| item.path == cortex_home.join(file_name))
1005+
.unwrap_or_else(|| panic!("{file_name} should be collected"));
1006+
assert_eq!(item.category, RemovalCategory::Config);
1007+
}
1008+
}
9791009
}

0 commit comments

Comments
 (0)