diff --git a/server/src/chat/commands/setup.rs b/server/src/chat/commands/setup.rs index 99d28087..0fe29c89 100644 --- a/server/src/chat/commands/setup.rs +++ b/server/src/chat/commands/setup.rs @@ -59,12 +59,17 @@ fn wizard_generate_reply(ctx: &CommandContext) -> String { } /// Compose a status reply for the `setup` command (no args). +/// +/// If no wizard state exists, automatically initializes it so the user does +/// not need to run `huskies init` manually. fn wizard_status_reply(ctx: &CommandContext) -> String { + if WizardState::load(ctx.project_root).is_none() { + WizardState::init_if_missing(ctx.project_root); + } match WizardState::load(ctx.project_root) { Some(state) => format_wizard_state(&state), - None => { - "No setup wizard active. Run `huskies init` in the project root to begin.".to_string() - } + None => "Unable to initialize setup wizard. Ensure the `.huskies/` directory exists." + .to_string(), } } @@ -205,13 +210,18 @@ mod tests { } #[test] - fn setup_no_wizard_returns_helpful_message() { + fn setup_no_wizard_auto_initializes() { let dir = TempDir::new().unwrap(); + std::fs::create_dir_all(dir.path().join(".huskies")).unwrap(); let agents = Arc::new(crate::agents::AgentPool::new_test(4000)); let rooms = Arc::new(Mutex::new(HashSet::new())); let ctx = make_ctx("", dir.path(), &agents, &rooms); let result = handle_setup(&ctx).unwrap(); - assert!(result.contains("huskies init")); + // Bot should auto-initialize and return wizard status, not ask user to run huskies init. + assert!(result.contains("Setup wizard")); + assert!(!result.contains("huskies init")); + // Wizard state file should now exist. + assert!(WizardState::load(dir.path()).is_some()); } #[test]