MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / collect_from

Function collect_from

atomic-cli/src/commands/diagnostics/collect.rs:532–801  ·  view source on GitHub ↗

Collect the report from explicit sources: `probes` are the agent adapters, `packaged` the agents with an integration package.

(
    sources: &Sources,
    probes: &[AgentProbe],
    packaged: &[String],
)

Source from the content-addressed store, hash-verified

530/// Collect the report from explicit sources: `probes` are the agent
531/// adapters, `packaged` the agents with an integration package.
532pub(crate) fn collect_from(
533 sources: &Sources,
534 probes: &[AgentProbe],
535 packaged: &[String],
536) -> Report {
537 let home = sources.home.as_deref();
538 let display_name = |agent: &str| {
539 probes
540 .iter()
541 .find(|probe| probe.name == agent)
542 .map_or_else(|| agent.to_string(), |probe| probe.display_name.clone())
543 };
544
545 // Receipts, for every packaged agent plus any receipt on disk for an
546 // agent this binary no longer lists — that is exactly the
547 // version-skew case a support conversation needs to see.
548 let mut agents_with_packages: Vec<String> = packaged
549 .iter()
550 .filter(|name| *name != SKILLS_PACKAGE)
551 .cloned()
552 .collect();
553 if let Ok(root) = &sources.integrations_root {
554 for name in receipts_on_disk(root) {
555 if name != SKILLS_PACKAGE && !agents_with_packages.contains(&name) {
556 agents_with_packages.push(name);
557 }
558 }
559 }
560 agents_with_packages.sort();
561 let receipts: Vec<(String, ReceiptLookup)> = agents_with_packages
562 .into_iter()
563 .map(|agent| {
564 let lookup = match &sources.integrations_root {
565 Ok(root) => read_receipt(&root.join(&agent).join(RECEIPT_FILE)),
566 Err(_) => ReceiptLookup::Unreadable(ReceiptError::IntegrationsHome),
567 };
568 (agent, lookup)
569 })
570 .collect();
571 let receipt_for = |agent: &str| {
572 receipts
573 .iter()
574 .find(|(name, _)| name == agent)
575 .map(|(_, lookup)| lookup)
576 };
577
578 let package = match &sources.integrations_root {
579 Ok(root) => read_skills_package(&root.join(SKILLS_PACKAGE).join("repo")),
580 Err(reason) => SkillsPackage::Unreadable {
581 reason: format!("integrations directory unresolved: {reason}"),
582 },
583 };
584 let declared = match &package {
585 SkillsPackage::Available { skills, .. } => Some(skills.as_slice()),
586 _ => None,
587 };
588
589 let hook_activity = match &sources.workspace {

Calls 15

receipts_on_diskFunction · 0.85
read_receiptFunction · 0.85
read_skills_packageFunction · 0.85
read_hook_activityFunction · 0.85
file_stateFunction · 0.85
skill_nameFunction · 0.85
skill_metadataFunction · 0.85
describe_sourceFunction · 0.85
receipt_forFunction · 0.85
known_settings_locationFunction · 0.85
settings_hooksFunction · 0.85
classify_enabledFunction · 0.85