MCPcopy Create free account
hub / github.com/clawshell/clawshell / apply_openclaw_onboarding_steps

Function apply_openclaw_onboarding_steps

src/main.rs:1152–1317  ·  view source on GitHub ↗

Steps 6, 7, 8 of the onboarding wizard when the user picked OpenClaw as the downstream agent target. Encapsulates the OpenClaw skill write, backup, credential cleanup preview, and `openclaw config set` apply.

(
    ob_config: &crate::onboard::OnboardConfig,
    openclaw_path: &Path,
    config_file: &Path,
)

Source from the content-addressed store, hash-verified

1150/// the downstream agent target. Encapsulates the OpenClaw skill write,
1151/// backup, credential cleanup preview, and `openclaw config set` apply.
1152fn apply_openclaw_onboarding_steps(
1153 ob_config: &crate::onboard::OnboardConfig,
1154 openclaw_path: &Path,
1155 config_file: &Path,
1156) -> Result<(), Box<dyn Error>> {
1157 const TOTAL_STEPS: usize = ONBOARD_TOTAL_STEPS;
1158
1159 // Step 6: Write OpenClaw skill files. The stats skill is always
1160 // installed; the email skill is added on top when email integration
1161 // is configured for this onboarding.
1162 tui::print_step(6, TOTAL_STEPS, "OpenClaw skill setup...");
1163 println!();
1164 let openclaw_skill_edit_approved = tui::prompt_confirm("Write OpenClaw skill files", true)?;
1165 let openclaw_skills: Vec<WrittenOpenclawSkill> = if openclaw_skill_edit_approved {
1166 let written = write_onboard_openclaw_skill(ob_config, openclaw_path)?;
1167 for skill in &written {
1168 onboard::upsert_managed_skill_manifest_entry(config_file, &skill.manifest_entry)?;
1169 tui::print_info("OpenClaw skill", &skill.path.display().to_string());
1170 }
1171 // Set up the weekly stats cron job, delivering to the first
1172 // configured messaging channel if one is detected.
1173 let mut openclaw_runner = openclaw_cli::RealOpenclawRunner;
1174 let channel = openclaw_cli::detect_openclaw_channel(&mut openclaw_runner);
1175 match openclaw_cli::setup_openclaw_stats_cron(&mut openclaw_runner, channel.as_deref()) {
1176 Ok(()) => {
1177 let dest = channel.as_deref().unwrap_or("log only");
1178 tui::print_info(
1179 "Cron job",
1180 &format!("clawshell-weekly-stats (Mon 09:00, deliver: {dest})"),
1181 );
1182 }
1183 Err(err) => {
1184 tui::print_warning(&format!("Failed to set up weekly stats cron job: {err}"))
1185 }
1186 }
1187 tui::print_step_done(6, TOTAL_STEPS, "OpenClaw skills written");
1188 written
1189 } else {
1190 tui::print_step_done(
1191 6,
1192 TOTAL_STEPS,
1193 "OpenClaw skills skipped (approval not granted)",
1194 );
1195 Vec::new()
1196 };
1197
1198 // Step 7: Backup OpenClaw configuration file if present.
1199 tui::print_step(7, TOTAL_STEPS, "Backing up OpenClaw configuration...");
1200 if openclaw_path.exists() {
1201 let backup = onboard::backup_openclaw_config(openclaw_path)?;
1202 tui::print_step_done(7, TOTAL_STEPS, "OpenClaw config backed up");
1203 tui::print_info("Backup", &backup.display().to_string());
1204 print_openclaw_recovery_notice(openclaw_path, &backup);
1205 } else {
1206 tui::print_step_done(7, TOTAL_STEPS, "OpenClaw config backup skipped");
1207 tui::print_warning(&format!(
1208 "OpenClaw config not found at: {}",
1209 openclaw_path.display()

Callers 1

cmd_onboardFunction · 0.85

Calls 15

print_stepFunction · 0.85
prompt_confirmFunction · 0.85
print_infoFunction · 0.85
detect_openclaw_channelFunction · 0.85
print_warningFunction · 0.85
print_step_doneFunction · 0.85
backup_openclaw_configFunction · 0.85
openclaw_config_rootFunction · 0.85

Tested by

no test coverage detected