MCPcopy Index your code
hub / github.com/dallay/agentsync / sync

Method sync

src/linker.rs:362–444  ·  view source on GitHub ↗

Perform the sync operation

(&self, options: &SyncOptions)

Source from the content-addressed store, hash-verified

360
361 /// Perform the sync operation
362 pub fn sync(&self, options: &SyncOptions) -> Result<SyncResult> {
363 // Clear caches at the start of every sync run to prevent stale state.
364 self.compression_cache.borrow_mut().clear();
365 self.ensured_dirs.borrow_mut().clear();
366 self.ensured_compressed.borrow_mut().clear();
367 self.path_cache.borrow_mut().clear();
368 self.invalidate_discovery_caches();
369
370 let mut result = SyncResult::default();
371
372 if options.dry_run {
373 println!("{}", "Running in dry-run mode\n".cyan());
374 }
375
376 for (agent_name, agent_config) in &self.config.agents {
377 // Skip disabled agents
378 if !agent_config.enabled {
379 if options.verbose {
380 println!(" {} Skipping disabled agent: {}", "○".yellow(), agent_name);
381 }
382 continue;
383 }
384
385 // Filter by agent name if specified
386 // Priority: CLI --agents flag > default_agents config > all enabled agents
387 if let Some(ref filter) = options.agents {
388 if !filter
389 .iter()
390 .any(|f| crate::agent_ids::sync_filter_matches(agent_name, f))
391 {
392 if options.verbose {
393 println!(" {} Skipping filtered agent: {}", "○".yellow(), agent_name);
394 }
395 continue;
396 }
397 } else if !self.config.default_agents.is_empty()
398 && !self
399 .config
400 .default_agents
401 .iter()
402 .any(|f| crate::agent_ids::sync_filter_matches(agent_name, f))
403 {
404 if options.verbose {
405 println!(
406 " {} Skipping agent (not in default_agents): {}",
407 "○".yellow(),
408 agent_name
409 );
410 }
411 continue;
412 }
413 // If neither --agents nor default_agents, process all enabled agents
414
415 // Print agent header
416 let desc = if agent_config.description.is_empty() {
417 String::new()
418 } else {
419 format!(" - {}", agent_config.description)

Calls 3

sync_filter_matchesFunction · 0.85
process_targetMethod · 0.80