MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / pick_integrations_interactive

Function pick_integrations_interactive

src/agents/mod.rs:1350–1400  ·  view source on GitHub ↗

Interactively pick which agents to install/uninstall. - 0 detected agents → returns an error. - 1 detected and not already installed → returns it directly (no prompt). - Otherwise → asks a Y/n question for each detected agent. Returns `(to_install, to_uninstall)`.

(
    home: &Path,
    installed: &[String],
)

Source from the content-addressed store, hash-verified

1348///
1349/// Returns `(to_install, to_uninstall)`.
1350pub fn pick_integrations_interactive(
1351 home: &Path,
1352 installed: &[String],
1353) -> Result<(Vec<String>, Vec<String>)> {
1354 let detected: Vec<Box<dyn AgentIntegration>> = all_integrations()
1355 .into_iter()
1356 .filter(|ag| ag.is_detected(home))
1357 .collect();
1358
1359 if detected.is_empty() {
1360 return Err(TraceDecayError::Config {
1361 message: "No supported agents detected on this system".to_string(),
1362 });
1363 }
1364
1365 // Fast path: exactly one detected agent and it isn't installed yet.
1366 if detected.len() == 1 && !installed.contains(&detected[0].id().to_string()) {
1367 let id = detected[0].id().to_string();
1368 return Ok((vec![id], vec![]));
1369 }
1370
1371 let mut to_install = Vec::new();
1372 let mut to_uninstall = Vec::new();
1373
1374 for ag in &detected {
1375 let id = ag.id().to_string();
1376 let already = installed.contains(&id);
1377 if already {
1378 eprint!("Keep TraceDecay for {}? [Y/n] ", ag.name());
1379 } else {
1380 eprint!("Install TraceDecay for {}? [Y/n] ", ag.name());
1381 }
1382
1383 let mut input = String::new();
1384 std::io::stdin()
1385 .read_line(&mut input)
1386 .map_err(|e| TraceDecayError::Config {
1387 message: format!("failed to read input: {e}"),
1388 })?;
1389 let answer = input.trim().to_lowercase();
1390 let yes = answer.is_empty() || answer == "y" || answer == "yes";
1391
1392 if yes && !already {
1393 to_install.push(id);
1394 } else if !yes && already {
1395 to_uninstall.push(id);
1396 }
1397 }
1398
1399 Ok((to_install, to_uninstall))
1400}
1401
1402/// Load a TOML file as a document.
1403///

Calls 8

all_integrationsFunction · 0.85
collectMethod · 0.80
pushMethod · 0.80
is_detectedMethod · 0.45
is_emptyMethod · 0.45
containsMethod · 0.45
idMethod · 0.45
read_lineMethod · 0.45