Interactive wizard for initializing agentsync with file migration
(project_root: &Path, force: bool)
| 1581 | |
| 1582 | /// Interactive wizard for initializing agentsync with file migration |
| 1583 | pub fn init_wizard(project_root: &Path, force: bool) -> Result<()> { |
| 1584 | use colored::Colorize; |
| 1585 | use dialoguer::{Confirm, MultiSelect, Select, theme::ColorfulTheme}; |
| 1586 | |
| 1587 | struct DialoguerInitWizardRenderer; |
| 1588 | |
| 1589 | impl InitWizardRenderer for DialoguerInitWizardRenderer { |
| 1590 | fn confirm_migration(&mut self) -> Result<bool> { |
| 1591 | Ok(Confirm::with_theme(&ColorfulTheme::default()) |
| 1592 | .with_prompt("Would you like to migrate these files to the .agents/ directory?") |
| 1593 | .default(true) |
| 1594 | .interact()?) |
| 1595 | } |
| 1596 | |
| 1597 | fn select_files_to_migrate( |
| 1598 | &mut self, |
| 1599 | discovered_files: &[DiscoveredFile], |
| 1600 | ) -> Result<Vec<usize>> { |
| 1601 | Ok(MultiSelect::with_theme(&ColorfulTheme::default()) |
| 1602 | .with_prompt("Select files to migrate (use Space to select, Enter to confirm)") |
| 1603 | .items( |
| 1604 | discovered_files |
| 1605 | .iter() |
| 1606 | .map(|f| f.display_name.as_str()) |
| 1607 | .collect::<Vec<_>>(), |
| 1608 | ) |
| 1609 | .defaults(&discovered_files.iter().map(|_| true).collect::<Vec<_>>()) |
| 1610 | .interact()?) |
| 1611 | } |
| 1612 | |
| 1613 | fn select_skills_mode(&mut self, choice: &SkillsWizardChoice) -> Result<usize> { |
| 1614 | println!( |
| 1615 | "\n{}", |
| 1616 | format!( |
| 1617 | "🧠 Skills target for {} ({})", |
| 1618 | choice.agent_name, choice.destination |
| 1619 | ) |
| 1620 | .cyan() |
| 1621 | ); |
| 1622 | println!( |
| 1623 | " {} Recommended: {}{}", |
| 1624 | "ℹ".blue(), |
| 1625 | sync_type_label(choice.recommended_mode).bold(), |
| 1626 | choice |
| 1627 | .reason |
| 1628 | .as_ref() |
| 1629 | .map(|reason| format!(" — {reason}")) |
| 1630 | .unwrap_or_default() |
| 1631 | ); |
| 1632 | |
| 1633 | Ok(Select::with_theme(&ColorfulTheme::default()) |
| 1634 | .with_prompt("How should this skills target sync?") |
| 1635 | .items([ |
| 1636 | "symlink — link the whole directory to .agents/skills", |
| 1637 | "symlink-contents — keep a directory and link each item inside it", |
| 1638 | ]) |
| 1639 | .default(if choice.recommended_mode == SyncType::Symlink { |
| 1640 | 0 |
no test coverage detected