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,
)
| 471 | /// First run clones the package; later runs reuse the cache so enable works |
| 472 | /// offline. `--force` discards the cache and re-clones. |
| 473 | fn 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 | |
| 506 | impl Enable { |
| 507 | /// Install an externally-packaged integration for an agent. |
no test coverage detected