Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/cortex-cli/src/agent_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
53 changes: 53 additions & 0 deletions src/cortex-cli/src/uninstall_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,30 @@ fn collect_cortex_home_items(home_dir: &Path) -> Result<Vec<RemovalItem>> {
});
}

// Delegates directory
let delegates_dir = cortex_home.join("delegates");
if delegates_dir.exists() {
items.push(RemovalItem {
path: delegates_dir.clone(),
description: "Delegate data".to_string(),
size: get_dir_size(&delegates_dir),
requires_sudo: false,
category: RemovalCategory::Data,
});
}

// Snapshots directory
let snapshots_dir = cortex_home.join("snapshots");
if snapshots_dir.exists() {
items.push(RemovalItem {
path: snapshots_dir.clone(),
description: "Snapshot data".to_string(),
size: get_dir_size(&snapshots_dir),
requires_sudo: false,
category: RemovalCategory::Data,
});
}

// Plugins directory
let plugins_dir = cortex_home.join("plugins");
if plugins_dir.exists() {
Expand Down Expand Up @@ -976,4 +1000,33 @@ mod tests {
| InstallMethod::Unknown => {}
}
}

#[test]
fn test_collect_cortex_home_items_includes_delegate_and_snapshot_dirs() {
let temp_home = tempfile::tempdir().unwrap();
let cortex_home = temp_home.path().join(".cortex");

for dir_name in ["sessions", "delegates", "snapshots"] {
let dir = cortex_home.join(dir_name);
fs::create_dir_all(&dir).unwrap();
fs::write(dir.join("marker.txt"), "test\n").unwrap();
}

let items = collect_cortex_home_items(temp_home.path()).unwrap();

assert!(
items
.iter()
.any(|item| item.path == cortex_home.join("sessions")),
"control sessions directory should be collected"
);

for dir_name in ["delegates", "snapshots"] {
let item = items
.iter()
.find(|item| item.path == cortex_home.join(dir_name))
.unwrap_or_else(|| panic!("{dir_name} directory should be collected"));
assert_eq!(item.category, RemovalCategory::Data);
}
}
}