lean_ctx_cli/setup/
update_refresh.rs1use super::agent_selection as sel;
7
8pub struct UpdateRefresh;
10
11fn rewire_options(proxy_active: bool, skip_rules: bool, dry_run: bool) -> super::SetupOptions {
12 super::SetupOptions {
13 non_interactive: true,
14 yes: true,
15 fix: true,
16 skip_proxy: !proxy_active,
17 skip_rules,
18 refresh_only: true,
19 dry_run,
20 ..Default::default()
21 }
22}
23
24impl lean_ctx::core::updater::SetupRefresh for UpdateRefresh {
25 fn refresh(&self, proxy_active: bool, skip_rules: bool) -> Result<(), String> {
26 super::run_setup_with_options(&rewire_options(proxy_active, skip_rules, false)).map(|_| ())
27 }
28
29 fn print_plan(&self, proxy_active: bool, skip_rules: bool) {
30 match super::run_setup_with_options(&rewire_options(proxy_active, skip_rules, true)) {
31 Ok(report) => super::print_plan(&report),
32 Err(e) => eprintln!(" \x1b[31m✗\x1b[0m Cannot plan the setup refresh: {e}"),
33 }
34 }
35
36 fn print_unconnected_tools_hint(&self) {
39 let Some(home) = lean_ctx::core::home::resolve_home_dir() else {
40 return;
41 };
42 let targets = lean_ctx::core::editor_registry::build_targets(&home);
43 let scope = sel::scope_for_run(&home, &targets, None, true);
44 let skipped: Vec<String> = sel::detected_agents(&home, &targets)
45 .into_iter()
46 .filter(|a| !scope.allows(&a.key))
47 .map(|a| a.key)
48 .collect();
49 if !skipped.is_empty() {
50 eprintln!(
51 " \u{2139} Not connected (left untouched): {}",
52 skipped.join(", ")
53 );
54 eprintln!(" Connect one: lean-ctx init --agent <name> · choose: lean-ctx setup");
55 }
56 }
57}