Initialize a new configuration in the given directory
(project_root: &Path, force: bool)
| 195 | |
| 196 | /// Initialize a new configuration in the given directory |
| 197 | pub fn init(project_root: &Path, force: bool) -> Result<()> { |
| 198 | use colored::Colorize; |
| 199 | |
| 200 | let agents_dir = project_root.join(".agents"); |
| 201 | let config_path = agents_dir.join("agentsync.toml"); |
| 202 | let agents_md_path = agents_dir.join("AGENTS.md"); |
| 203 | |
| 204 | // Create .agents directory |
| 205 | if !agents_dir.exists() { |
| 206 | fs::create_dir_all(&agents_dir)?; |
| 207 | println!( |
| 208 | " {} Created directory: {}", |
| 209 | "✔".green(), |
| 210 | agents_dir.display() |
| 211 | ); |
| 212 | } |
| 213 | |
| 214 | // Create skills directory |
| 215 | let skills_dir = agents_dir.join("skills"); |
| 216 | if !skills_dir.exists() { |
| 217 | fs::create_dir_all(&skills_dir)?; |
| 218 | println!( |
| 219 | " {} Created directory: {}", |
| 220 | "✔".green(), |
| 221 | skills_dir.display() |
| 222 | ); |
| 223 | } |
| 224 | |
| 225 | // Create commands directory |
| 226 | let commands_dir = agents_dir.join("commands"); |
| 227 | if !commands_dir.exists() { |
| 228 | fs::create_dir_all(&commands_dir)?; |
| 229 | println!( |
| 230 | " {} Created directory: {}", |
| 231 | "✔".green(), |
| 232 | commands_dir.display() |
| 233 | ); |
| 234 | } |
| 235 | |
| 236 | // Create config file |
| 237 | if config_path.exists() && !force { |
| 238 | println!( |
| 239 | " {} Config already exists: {} (use --force to overwrite)", |
| 240 | "!".yellow(), |
| 241 | config_path.display() |
| 242 | ); |
| 243 | } else { |
| 244 | fs::write(&config_path, DEFAULT_CONFIG)?; |
| 245 | println!(" {} Created: {}", "✔".green(), config_path.display()); |
| 246 | } |
| 247 | |
| 248 | // Create AGENTS.md |
| 249 | if agents_md_path.exists() && !force { |
| 250 | println!( |
| 251 | " {} AGENTS.md already exists: {} (use --force to overwrite)", |
| 252 | "!".yellow(), |
| 253 | agents_md_path.display() |
| 254 | ); |
no outgoing calls