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

Function sync_integration_package

atomic-cli/src/commands/agent/enable.rs:473–504  ·  view source on GitHub ↗

Sync an agent's integration package into the CLI-managed cache (`~/.atomic/integrations/ /repo`) using Atomic's own remote protocol, and return the package directory (the cache's working copy). First run clones the package; later runs reuse the cache so enable works offline. `--force` discards the cache and re-clones.

(
    agent_name: &str,
    spec: &atomic_agent::integrations::IntegrationSpec,
    force: bool,
)

Source from the content-addressed store, hash-verified

471/// First run clones the package; later runs reuse the cache so enable works
472/// offline. `--force` discards the cache and re-clones.
473fn sync_integration_package(
474 agent_name: &str,
475 spec: &atomic_agent::integrations::IntegrationSpec,
476 force: bool,
477) -> CliResult<std::path::PathBuf> {
478 let cache = atomic_agent::integrations::cache_repo_dir(agent_name)
479 .map_err(|e| crate::error::CliError::Internal(anyhow::anyhow!(e.to_string())))?;
480
481 if force && cache.exists() {
482 std::fs::remove_dir_all(&cache).map_err(crate::error::CliError::Io)?;
483 }
484
485 if cache.exists() {
486 println!(
487 "Using cached package at {} (use --force to refresh).",
488 cache.display()
489 );
490 } else {
491 if let Some(ref tag) = spec.tag {
492 print_warning(&format!(
493 "Tag pinning ({tag}) is not yet implemented — installing the head of view '{}' instead.",
494 spec.view
495 ));
496 }
497 crate::commands::clone::Clone::new(spec.url.clone())
498 .with_path(cache.display().to_string())
499 .with_view(spec.view.clone())
500 .run()?;
501 }
502
503 Ok(cache)
504}
505
506impl Enable {
507 /// Install an externally-packaged integration for an agent.

Callers 1

install_integrationMethod · 0.85

Calls 8

cache_repo_dirFunction · 0.85
print_warningFunction · 0.85
displayMethod · 0.80
existsMethod · 0.45
runMethod · 0.45
with_viewMethod · 0.45
with_pathMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected