Skip to content

Commit 8108847

Browse files
committed
copy global config files as part of migration
1 parent ef64ab8 commit 8108847

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

Cargo.lock

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ core-foundation-sys = "0.8.7"
5959
core-graphics = "0.24.0"
6060
crossterm = { version = "0.28.1", features = ["event-stream", "events"] }
6161
dashmap = "6.0.1"
62+
dircpy = "0.3.19"
6263
dirs = "5.0.0"
6364
eyre = "0.6.8"
6465
fig_api_client = { path = "crates/fig_api_client" }

crates/fig_install/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ bytes.workspace = true
1919
camino.workspace = true
2020
cfg-if.workspace = true
2121
cookie = "0.18.0"
22+
dircpy.workspace = true
2223
eyre.workspace = true
2324
fig_integrations.workspace = true
2425
fig_os_shim.workspace = true

crates/fig_install/src/migrate.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,55 @@ async fn copy_essential_files(src: &std::path::Path, dst: &std::path::Path) -> R
116116
}
117117
}
118118

119+
// Copy global files from home directory
120+
copy_global_config_files()?;
121+
122+
Ok(())
123+
}
124+
125+
fn copy_global_config_files() -> Result<()> {
126+
let home_dir = fig_util::directories::home_dir()?;
127+
let kiro_dir = home_dir.join(".kiro");
128+
let legacy_amazonq_dir = home_dir.join(".aws/amazonq");
129+
130+
let src_dir = if legacy_amazonq_dir.exists() {
131+
&legacy_amazonq_dir
132+
} else {
133+
return Ok(());
134+
};
135+
136+
// Use fig_data_dir for knowledge_bases and cli-checkouts
137+
let data_dir = fig_util::directories::fig_data_dir()?;
138+
139+
let files_to_copy = [
140+
// copy to home/.kiro
141+
("cli-agents", kiro_dir.join("agents")),
142+
("prompts", kiro_dir.join("prompts")),
143+
("mcp.json", kiro_dir.join("settings/mcp.json")),
144+
(".cli_bash_history", kiro_dir.join(".cli_bash_history")),
145+
// copy to data-dir
146+
("cli-checkouts", data_dir.join("cli-checkouts")),
147+
("knowledge_bases", data_dir.join("knowledge_bases")),
148+
];
149+
150+
for (src_subpath, dst_path) in files_to_copy {
151+
let src_path = src_dir.join(src_subpath);
152+
153+
if src_path.exists() {
154+
if let Some(parent) = dst_path.parent() {
155+
std::fs::create_dir_all(parent)?;
156+
}
157+
158+
if src_path.is_dir() {
159+
debug!("Copying directory {} to {}", src_path.display(), dst_path.display());
160+
dircpy::copy_dir(&src_path, &dst_path)?;
161+
} else {
162+
debug!("Copying file {} to {}", src_path.display(), dst_path.display());
163+
std::fs::copy(&src_path, &dst_path)?;
164+
}
165+
}
166+
}
167+
119168
Ok(())
120169
}
121170

0 commit comments

Comments
 (0)