1use lean_ctx::core::editor_registry::{WriteAction, WriteOptions};
3use lean_ctx::core::portable_binary::resolve_agent_binary;
4use lean_ctx_hooks::hooks::{HookMode, recommend_hook_mode};
5
6use super::first_run::{first_run_setup_level, persist_setup_choice};
7use super::helpers::{
8 configure_plan_mode_settings, configure_premium_features, configure_tool_profile, shorten_path,
9};
10use super::index_build::spawn_index_build_background;
11use super::options::SetupOptions;
12use super::with_options::run_setup_with_options;
13
14pub fn run_setup() {
15 run_setup_with_agents(None);
16}
17
18fn choose_agents(
22 home: &std::path::Path,
23 targets: &[lean_ctx::core::editor_registry::EditorTarget],
24 explicit: Option<std::collections::BTreeSet<String>>,
25) -> std::collections::BTreeSet<String> {
26 use super::agent_selection as sel;
27
28 let detected = sel::detected_agents(home, targets);
29 let selection = match explicit {
30 Some(keys) => keys,
31 None if detected.is_empty() => return std::collections::BTreeSet::new(),
32 None => {
33 let saved = lean_ctx::core::config::Config::load_global().setup.agents;
34 let default = sel::prompt_default(&detected, saved.as_deref());
35 sel::prompt_agent_selection(&detected, &default)
36 }
37 };
38 if let Err(e) = sel::save_selection(&selection) {
39 lean_ctx::terminal_ui::print_status_warn(&e);
40 }
41 selection
42}
43
44pub fn run_setup_with_agents(agents: Option<std::collections::BTreeSet<String>>) {
46 use lean_ctx::terminal_ui;
47
48 if lean_ctx::shell::is_non_interactive() {
49 eprintln!("Non-interactive terminal detected (no TTY on stdin).");
50 eprintln!(
51 "Running in non-interactive mode (equivalent to: lean-ctx setup --non-interactive --yes)"
52 );
53 if agents.is_none() {
54 eprintln!(
55 "Connecting all detected tools (or the recorded choice); use --agents to choose."
56 );
57 }
58 eprintln!();
59 let opts = SetupOptions {
60 non_interactive: true,
61 yes: true,
62 agents,
63 ..Default::default()
64 };
65 match run_setup_with_options(&opts) {
66 Ok(report) => {
67 for w in &report.warnings {
68 tracing::warn!("{w}");
69 }
70 }
71 Err(e) => tracing::error!("Setup error: {e}"),
72 }
73 return;
74 }
75
76 let Some(home) = lean_ctx::core::home::resolve_home_dir() else {
77 tracing::error!("Cannot determine home directory");
78 std::process::exit(1);
79 };
80
81 let binary = resolve_agent_binary();
82
83 let home_str = home.to_string_lossy().to_string();
84
85 terminal_ui::print_setup_header();
86
87 let (inject_rules, inject_skills) = first_run_setup_level();
88 persist_setup_choice(inject_rules, inject_skills);
89
90 let allow_rule_steering =
91 inject_rules && !lean_ctx::core::config::Config::load().declines_rule_steering();
92
93 terminal_ui::print_step_header(1, 14, "Shell Hook");
94 crate::cli::cmd_init(&["--global".to_string()]);
95 lean_ctx::shell_hook::install_all(false);
96
97 terminal_ui::print_step_header(2, 14, "Daemon");
98 if lean_ctx::daemon::is_daemon_running() {
99 terminal_ui::print_status_ok("Daemon running — restarting with current binary…");
100 let _ = lean_ctx::daemon::stop_daemon();
101 std::thread::sleep(std::time::Duration::from_millis(500));
102 if let Err(e) = lean_ctx::daemon::start_daemon(&[]) {
103 terminal_ui::print_status_warn(&format!("Daemon restart failed: {e}"));
104 }
105 } else if let Err(e) = lean_ctx::daemon::start_daemon(&[]) {
106 terminal_ui::print_status_warn(&format!("Daemon start failed: {e}"));
107 }
108
109 terminal_ui::print_step_header(3, 14, "AI Tool Detection");
110
111 let targets = lean_ctx::core::editor_registry::build_targets(&home);
112 let selection = choose_agents(&home, &targets, agents);
113 let allows = |key: &str| selection.contains(key);
114 let mut deselected: Vec<&str> = Vec::new();
115 let update_mcp = lean_ctx::core::config::Config::load()
119 .setup
120 .should_update_mcp();
121 let mut newly_configured: Vec<&str> = Vec::new();
122 let mut already_configured: Vec<&str> = Vec::new();
123 let mut not_installed: Vec<&str> = Vec::new();
124 let mut mcp_skipped: Vec<&str> = Vec::new();
125 let mut errors: Vec<&str> = Vec::new();
126 let mut configured_integration_ids = Vec::new();
127
128 lean_ctx_hooks::hooks::setup_writer::record();
132 for (host, outcome) in
133 lean_ctx_hooks::hooks::governor_default::apply_for_targets(&home, &targets, &allows)
134 {
135 if outcome.ran_steps() {
136 let _ = super::agent_selection::remember_connected_agent(host.key);
137 }
138 if let Some(notice) = outcome.notice(host) {
139 terminal_ui::print_status_new(¬ice);
140 }
141 }
142
143 for target in &targets {
144 let short_path = shorten_path(&target.config_path.to_string_lossy(), &home_str);
145
146 if !target.detect_path.exists() {
147 not_installed.push(target.name);
148 continue;
149 }
150
151 if !allows(&target.agent_key) {
152 if !deselected.contains(&target.name) {
153 deselected.push(target.name);
154 }
155 continue;
156 }
157
158 if !update_mcp {
159 terminal_ui::print_status_ok(&format!(
160 "{:<20} \x1b[2mMCP registration skipped (auto_update_mcp=false)\x1b[0m",
161 target.name
162 ));
163 mcp_skipped.push(target.name);
164 continue;
165 }
166
167 let mode = lean_ctx_hooks::hooks::governor_default::display_mode(
168 &target.agent_key,
169 &home,
170 if target.agent_key.is_empty() {
171 HookMode::Mcp
172 } else {
173 recommend_hook_mode(&target.agent_key)
174 },
175 );
176
177 match lean_ctx::core::editor_registry::write_config_with_options_and_rule_steering(
178 target,
179 &binary,
180 WriteOptions {
181 overwrite_invalid: false,
182 },
183 allow_rule_steering,
184 ) {
185 Ok(res) if res.action == WriteAction::Already => {
186 terminal_ui::print_status_ok(&format!(
187 "{:<20} \x1b[36m{mode}\x1b[0m \x1b[2m{short_path}\x1b[0m",
188 target.name
189 ));
190 already_configured.push(target.name);
191 configured_integration_ids.push(target.agent_key.clone());
192 }
193 Ok(_) => {
194 terminal_ui::print_status_new(&format!(
195 "{:<20} \x1b[36m{mode}\x1b[0m \x1b[2m{short_path}\x1b[0m",
196 target.name
197 ));
198 newly_configured.push(target.name);
199 configured_integration_ids.push(target.agent_key.clone());
200 }
201 Err(e) => {
202 terminal_ui::print_status_warn(&format!("{}: {e}", target.name));
203 errors.push(target.name);
204 }
205 }
206 }
207
208 let total_ok = newly_configured.len() + already_configured.len();
209 if total_ok == 0 && errors.is_empty() && mcp_skipped.is_empty() && deselected.is_empty() {
210 terminal_ui::print_status_warn(
211 "No AI tools detected. Install one and re-run: lean-ctx setup",
212 );
213 }
214
215 if !deselected.is_empty() {
216 println!(
217 " \x1b[2m○ {} left untouched (not selected): {}\x1b[0m",
218 deselected.len(),
219 deselected.join(", ")
220 );
221 }
222 if !not_installed.is_empty() {
223 println!(
224 " \x1b[2m○ {} not detected: {}\x1b[0m",
225 not_installed.len(),
226 not_installed.join(", ")
227 );
228 }
229
230 configure_plan_mode_settings(&newly_configured, &already_configured);
231
232 terminal_ui::print_step_header(4, 14, "Agent Rules");
233 let rules_result = if inject_rules {
234 let r = lean_ctx::rules_inject::inject_rules_where(&home, &allows);
235 for name in &r.injected {
236 terminal_ui::print_status_new(&format!("{name:<20} \x1b[2mrules injected\x1b[0m"));
237 }
238 for name in &r.updated {
239 terminal_ui::print_status_new(&format!("{name:<20} \x1b[2mrules updated\x1b[0m"));
240 }
241 for name in &r.already {
242 terminal_ui::print_status_ok(&format!("{name:<20} \x1b[2mrules up-to-date\x1b[0m"));
243 }
244 for err in &r.errors {
245 terminal_ui::print_status_warn(err);
246 }
247 if !r.backed_up.is_empty() {
248 for bak in &r.backed_up {
249 println!(" \x1b[2m ↳ backup: {bak}\x1b[0m");
250 }
251 }
252 if r.injected.is_empty()
253 && r.updated.is_empty()
254 && r.already.is_empty()
255 && r.errors.is_empty()
256 {
257 terminal_ui::print_status_skip("No agent rules needed");
258 }
259 r
260 } else {
261 terminal_ui::print_status_skip(
262 "Skipped (run `lean-ctx setup` or set auto_inject_rules = true in config)",
263 );
264 lean_ctx::rules_inject::InjectResult::default()
265 };
266
267 for target in &targets {
268 if !target.detect_path.exists() || target.agent_key.is_empty() || !allows(&target.agent_key)
269 {
270 continue;
271 }
272
273 let mode = recommend_hook_mode(&target.agent_key);
274
275 if allow_rule_steering {
276 lean_ctx_hooks::hooks::install_agent_hook_with_mode(&target.agent_key, true, mode);
277 } else {
278 lean_ctx_hooks::hooks::install_agent_runtime_hook_with_mode(
279 &target.agent_key,
280 true,
281 mode,
282 );
283 }
284 }
285
286 terminal_ui::print_step_header(5, 14, "API Proxy (optional)");
287 {
288 let cfg = lean_ctx::core::config::Config::load();
289 let proxy_port = crate::proxy_setup::default_port();
290
291 match cfg.proxy_enabled {
292 Some(true) => {
293 lean_ctx::proxy_autostart::install(proxy_port, false);
294 std::thread::sleep(std::time::Duration::from_millis(500));
295 crate::proxy_setup::install_proxy_env(&home, proxy_port, false);
296 terminal_ui::print_status_ok("Proxy active (opted in)");
297 }
298 Some(false) => {
299 terminal_ui::print_status_skip(
300 "Proxy disabled (run `lean-ctx proxy enable` to change)",
301 );
302 }
303 None => {
304 println!(
305 " \x1b[2mThe API proxy routes LLM requests through lean-ctx for additional\x1b[0m"
306 );
307 println!(
308 " \x1b[2mtool-result compression and precise token analytics in the dashboard.\x1b[0m"
309 );
310 println!();
311 println!(
312 " \x1b[2mWithout it: MCP tools, shell hooks, gain tracking, and memory\x1b[0m"
313 );
314 println!(
315 " \x1b[2mall work normally. The proxy compresses API traffic on top.\x1b[0m"
316 );
317 println!();
318 print!(" Enable the API proxy? [y/N] ");
319 let _ = std::io::Write::flush(&mut std::io::stdout());
320 let mut input = String::new();
321 let _ = std::io::stdin().read_line(&mut input);
322 let answer = matches!(input.trim().to_lowercase().as_str(), "y" | "yes");
323 if let Err(e) = lean_ctx::core::config::Config::update_global(|c| {
324 c.proxy_enabled = Some(answer);
325 }) {
326 tracing::warn!("could not persist proxy choice: {e}");
327 }
328 if answer {
329 lean_ctx::proxy_autostart::install(proxy_port, false);
330 std::thread::sleep(std::time::Duration::from_millis(500));
331 crate::proxy_setup::install_proxy_env(&home, proxy_port, false);
332 terminal_ui::print_status_new("Proxy enabled");
333 } else {
334 terminal_ui::print_status_skip(
335 "Proxy skipped (run `lean-ctx proxy enable` anytime)",
336 );
337 }
338 }
339 }
340 }
341
342 terminal_ui::print_step_header(6, 14, "IDE Config Access (optional)");
343 {
344 let cfg = lean_ctx::core::config::Config::load();
345 match cfg.allow_ide_config_dirs {
346 Some(true) => {
347 terminal_ui::print_status_ok(
348 "Enabled — the agent can read your editors' config dirs",
349 );
350 }
351 Some(false) => {
352 terminal_ui::print_status_skip(
353 "Off (enable: lean-ctx config set allow_ide_config_dirs true)",
354 );
355 }
356 None => {
357 println!(
358 " \x1b[2mlean-ctx tools are jailed to the current project. Enabling this lets\x1b[0m"
359 );
360 println!(
361 " \x1b[2mthe agent read every supported editor's config dir (~/.cursor, VS Code,\x1b[0m"
362 );
363 println!(
364 " \x1b[2mCline/Roo, JetBrains, …) to manage MCP setup across editors.\x1b[0m"
365 );
366 println!();
367 println!(
368 " \x1b[33mTrade-off:\x1b[0m \x1b[2mthose dirs can hold other agents' sessions & credentials.\x1b[0m"
369 );
370 println!();
371 print!(" Allow the agent to read IDE config dirs? [y/N] ");
372 let _ = std::io::Write::flush(&mut std::io::stdout());
373 let mut input = String::new();
374 let _ = std::io::stdin().read_line(&mut input);
375 let answer = matches!(input.trim().to_lowercase().as_str(), "y" | "yes");
376 if let Err(e) = lean_ctx::core::config::Config::update_global(|c| {
377 c.allow_ide_config_dirs = Some(answer);
378 }) {
379 tracing::warn!("could not persist IDE-config-access choice: {e}");
380 }
381 if answer {
382 terminal_ui::print_status_new("IDE config access enabled");
383 } else {
384 terminal_ui::print_status_skip(
385 "Skipped (enable later: lean-ctx config set allow_ide_config_dirs true)",
386 );
387 }
388 }
389 }
390 }
391
392 terminal_ui::print_step_header(7, 14, "Skill Files");
393 if inject_skills {
394 let skill_result = lean_ctx::rules_inject::install_skills_where(&home, &allows);
395 for (name, installed) in &skill_result {
396 if *installed {
397 terminal_ui::print_status_new(&format!(
398 "{name:<20} \x1b[2mSKILL.md installed\x1b[0m"
399 ));
400 } else {
401 terminal_ui::print_status_ok(&format!(
402 "{name:<20} \x1b[2mSKILL.md up-to-date\x1b[0m"
403 ));
404 }
405 }
406 if skill_result.is_empty() {
407 terminal_ui::print_status_skip("No skill directories to install");
408 }
409 } else {
410 terminal_ui::print_status_skip(
411 "Skipped (skill files install with the rules opt-in; choose Standard/Full in `lean-ctx setup`)",
412 );
413 }
414
415 terminal_ui::print_step_header(8, 14, "Environment Check");
416 let lean_dir = lean_ctx::core::data_dir::lean_ctx_data_dir()
417 .unwrap_or_else(|_| home.join(".config/lean-ctx"));
418 if lean_dir.exists() {
419 terminal_ui::print_status_ok(&format!("{} ready", lean_dir.display()));
420 } else {
421 let _ = std::fs::create_dir_all(&lean_dir);
422 terminal_ui::print_status_new(&format!("Created {}", lean_dir.display()));
423 }
424 if let Some(report) = lean_ctx::core::data_consolidate::consolidate()
425 && report.files_moved > 0
426 {
427 terminal_ui::print_status_new(&format!(
428 "Consolidated {} file(s) from a split data dir into {}",
429 report.files_moved,
430 report.canonical.display()
431 ));
432 }
433 if let Some(report) = lean_ctx::core::config_heal::heal() {
436 match report.action {
437 lean_ctx::core::config_heal::HealAction::Adopted => {
438 terminal_ui::print_status_new(&format!(
439 "Recovered your config into {}",
440 report.to.display()
441 ));
442 }
443 lean_ctx::core::config_heal::HealAction::Superseded => {
444 terminal_ui::print_status_ok("Unified config (archived a stale data-dir copy)");
445 }
446 }
447 }
448 crate::doctor::run_compact();
449
450 lean_ctx::core::layout_pin::heal();
453
454 terminal_ui::print_step_header(9, 14, "Help Improve lean-ctx");
455 if lean_ctx::core::telemetry_consent::telemetry_would_send() {
458 for line in lean_ctx::core::telemetry_consent::hint_lines() {
459 println!(" \x1b[2m{line}\x1b[0m");
460 }
461 } else {
462 terminal_ui::print_status_skip(
463 "Telemetry is off — nothing is sent. Turn on: lean-ctx telemetry on",
464 );
465 }
466 lean_ctx::core::telemetry_consent::mark_notice_seen();
467
468 terminal_ui::print_step_header(10, 14, "Auto-Updates");
469 println!(" Keep lean-ctx up to date automatically.");
470 println!(" \x1b[1mChecks GitHub every 6h, installs only when a new release exists.\x1b[0m");
471 println!(
472 " \x1b[2mNo restarts mid-session. Change anytime: lean-ctx update --schedule off\x1b[0m"
473 );
474 println!();
475 print!(" Enable automatic updates? \x1b[1m[y/N]\x1b[0m ");
476 use std::io::Write;
477 std::io::stdout().flush().ok();
478
479 let mut auto_input = String::new();
480 let auto_update = if std::io::stdin().read_line(&mut auto_input).is_ok() {
481 let answer = auto_input.trim().to_lowercase();
482 answer == "y" || answer == "yes"
483 } else {
484 false
485 };
486
487 if auto_update {
488 let cfg = lean_ctx::core::config::Config::load();
489 let hours = cfg.updates.check_interval_hours;
490 match lean_ctx::core::update_scheduler::install_schedule(hours) {
491 Ok(info) => {
492 lean_ctx::core::update_scheduler::set_auto_update(true, false, hours);
493 terminal_ui::print_status_ok(&format!("Enabled — {info}"));
494 }
495 Err(e) => {
496 terminal_ui::print_status_warn(&format!("Scheduler setup failed: {e}"));
497 terminal_ui::print_status_skip("Enable later: lean-ctx update --schedule");
498 }
499 }
500 } else {
501 lean_ctx::core::update_scheduler::set_auto_update(false, false, 6);
502 terminal_ui::print_status_skip("Skipped — enable later: lean-ctx update --schedule");
503 }
504
505 terminal_ui::print_step_header(11, 14, "Tool Profile");
506 configure_tool_profile();
507
508 terminal_ui::print_step_header(12, 14, "Advanced Tuning (optional)");
509 configure_premium_features(&home);
510
511 terminal_ui::print_step_header(13, 14, "Code Intelligence");
512 let cwd = std::env::current_dir().ok();
513 let cwd_is_home = cwd
514 .as_ref()
515 .is_some_and(|d| dirs::home_dir().is_some_and(|h| d.as_path() == h.as_path()));
516 if cwd_is_home {
517 terminal_ui::print_status_warn(
518 "Running from $HOME — graph build skipped to avoid scanning your entire home directory.",
519 );
520 println!();
521 println!(" \x1b[1mSet a default project root to avoid this:\x1b[0m");
522 println!(" \x1b[2mEnter your main project path (or press Enter to skip):\x1b[0m");
523 print!(" \x1b[1m>\x1b[0m ");
524 use std::io::Write;
525 std::io::stdout().flush().ok();
526 let mut root_input = String::new();
527 if std::io::stdin().read_line(&mut root_input).is_ok() {
528 let root_trimmed = root_input.trim();
529 if root_trimmed.is_empty() {
530 terminal_ui::print_status_skip(
531 "No project root set. Set later: lean-ctx config set project_root /path/to/project",
532 );
533 } else {
534 let root_path = std::path::Path::new(root_trimmed);
535 if root_path.exists() && root_path.is_dir() {
536 let config_path = lean_ctx::core::config::Config::path()
537 .unwrap_or_else(|| home.join(".config/lean-ctx").join("config.toml"));
538 let mut content = std::fs::read_to_string(&config_path).unwrap_or_default();
539 if content.contains("project_root") {
540 if let Ok(re) = regex::Regex::new(r#"(?m)^project_root\s*=\s*"[^"]*""#) {
541 content = re
542 .replace(&content, &format!("project_root = \"{root_trimmed}\""))
543 .to_string();
544 }
545 } else {
546 if !content.is_empty() && !content.ends_with('\n') {
547 content.push('\n');
548 }
549 content.push_str(&format!("project_root = \"{root_trimmed}\"\n"));
550 }
551 let _ = lean_ctx::config_io::write_atomic_with_backup(&config_path, &content);
552 terminal_ui::print_status_ok(&format!("Project root set: {root_trimmed}"));
553 if lean_ctx::core::pathutil::has_project_marker(root_path) {
554 spawn_index_build_background(root_path);
555 terminal_ui::print_status_ok("Graph build started (background)");
556 }
557 } else {
558 terminal_ui::print_status_warn(&format!(
559 "Path not found: {root_trimmed} — skipped"
560 ));
561 }
562 }
563 }
564 } else {
565 let is_project = cwd
566 .as_ref()
567 .is_some_and(|d| lean_ctx::core::pathutil::has_project_marker(d));
568 if is_project {
569 println!(" \x1b[2mBuilding code graph for graph-aware reads, impact analysis,\x1b[0m");
570 println!(" \x1b[2mand smart search fusion in the background...\x1b[0m");
571 if let Some(ref root) = cwd {
572 spawn_index_build_background(root);
573 }
574 terminal_ui::print_status_ok("Graph build started (background)");
575 } else {
576 println!(" \x1b[2mRun `lean-ctx graph build` inside any git project to enable\x1b[0m");
577 println!(
578 " \x1b[2mgraph-aware reads, impact analysis, and smart search fusion.\x1b[0m"
579 );
580 }
581 }
582 println!();
583
584 {
585 let tools = lean_ctx::core::editor_registry::writers::auto_approve_tools();
586 println!();
587 println!(
588 " \x1b[33m⚡ Auto-approved tools ({} total):\x1b[0m",
589 tools.len()
590 );
591 for chunk in tools.chunks(6) {
592 let names: Vec<_> = chunk.iter().map(|t| format!("\x1b[2m{t}\x1b[0m")).collect();
593 println!(" {}", names.join(", "));
594 }
595 }
596
597 terminal_ui::print_step_header(14, 14, "Intelligence Runtime (optional)");
598 super::intelligence::configure_runtime();
599
600 println!();
601 println!(
602 " \x1b[1;32m✓ Setup complete!\x1b[0m \x1b[1m{}\x1b[0m configured, \x1b[2m{} already set, {} skipped\x1b[0m",
603 newly_configured.len(),
604 already_configured.len(),
605 not_installed.len()
606 );
607
608 if !errors.is_empty() {
609 println!(
610 " \x1b[33m⚠ {} error{}: {}\x1b[0m",
611 errors.len(),
612 if errors.len() == 1 { "" } else { "s" },
613 errors.join(", ")
614 );
615 }
616
617 let source_cmd = lean_ctx::shell_hook::shell_source_command().unwrap_or("Restart your shell");
618
619 let dim = "\x1b[2m";
620 let bold = "\x1b[1m";
621 let cyan = "\x1b[36m";
622 let yellow = "\x1b[33m";
623 let rst = "\x1b[0m";
624
625 println!();
626 println!(" {bold}Next steps:{rst}");
627 println!();
628 println!(" {cyan}1.{rst} Reload your shell:");
629 println!(" {bold}{source_cmd}{rst}");
630 println!();
631
632 let mut tools_to_restart: Vec<String> = newly_configured
633 .iter()
634 .map(std::string::ToString::to_string)
635 .collect();
636 for name in rules_result
637 .injected
638 .iter()
639 .chain(rules_result.updated.iter())
640 {
641 if !tools_to_restart.contains(name) {
642 tools_to_restart.push(name.clone());
643 }
644 }
645
646 if !tools_to_restart.is_empty() {
647 println!(" {cyan}2.{rst} {yellow}{bold}Restart your IDE / AI tool:{rst}");
648 println!(" {bold}{}{rst}", tools_to_restart.join(", "));
649 println!(
650 " {dim}Changes take effect after a full restart (MCP may be enabled or disabled depending on mode).{rst}"
651 );
652 println!(" {dim}Close and re-open the application completely.{rst}");
653 } else if !already_configured.is_empty() {
654 println!(
655 " {cyan}2.{rst} {dim}Your tools are already configured — no restart needed.{rst}"
656 );
657 }
658
659 println!();
660 println!(
661 " {dim}After restart, lean-ctx will automatically optimize every AI interaction.{rst}"
662 );
663 println!(" {dim}Verify with:{rst} {bold}lean-ctx cockpit{rst}");
664
665 println!();
666 terminal_ui::print_logo_animated();
667 terminal_ui::print_command_box();
668
669 if errors.is_empty() {
670 if let Err(error) =
671 lean_ctx::core::telemetry_aggregate::record_setup_completion(configured_integration_ids)
672 {
673 tracing::debug!("telemetry setup aggregate unavailable: {error}");
674 }
675 }
676
677 crate::cli::show_first_run_wow();
678}