git_worktree_manager/operations/setup_claude/legacy.rs
1//! Removal of pre-marketplace install locations.
2//!
3//! Three layouts have shipped and need cleanup on `gw setup-claude` re-run:
4//! 1. `~/.claude/skills/gw/` — original single-skill install
5//! 2. `~/.claude/skills/gw-delegate/` — second single-skill iteration
6//! 3. `~/.claude/plugins/gw/` — broken plugin layout that Claude
7//! Code never recognized (manifest at the wrong path, no marketplace
8//! registration). This is the layout we are replacing in this change.
9//!
10//! All three are safe to remove because they were exclusively created by
11//! `gw setup-claude` — we know nothing else writes to those exact paths.
12
13use std::path::{Path, PathBuf};
14
15use crate::constants::home_dir_or_fallback;
16
17fn legacy_paths_under(home: &Path) -> Vec<PathBuf> {
18 let claude = home.join(".claude");
19 vec![
20 claude.join("skills").join("gw"),
21 claude.join("skills").join("gw-delegate"),
22 claude.join("plugins").join("gw"),
23 ]
24}
25
26pub fn any_legacy_present() -> bool {
27 any_legacy_present_under(&home_dir_or_fallback())
28}
29
30pub fn any_legacy_present_under(home: &Path) -> bool {
31 legacy_paths_under(home).iter().any(|p| p.exists())
32}
33
34pub fn remove_legacy_installs_under(home: &Path) {
35 for p in legacy_paths_under(home) {
36 if p.exists() {
37 let _ = std::fs::remove_dir_all(&p);
38 }
39 }
40}