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,
)
| 444 | /// First run clones the package; later runs reuse the cache so enable works |
| 445 | /// offline. `--force` discards the cache and re-clones. |
| 446 | fn sync_integration_package( |
| 447 | agent_name: &str, |
| 448 | spec: &atomic_agent::integrations::IntegrationSpec, |
| 449 | force: bool, |
| 450 | ) -> CliResult<std::path::PathBuf> { |
| 451 | let cache = atomic_agent::integrations::cache_repo_dir(agent_name) |
| 452 | .map_err(|e| crate::error::CliError::Internal(anyhow::anyhow!(e.to_string())))?; |
| 453 | |
| 454 | if force && cache.exists() { |
| 455 | std::fs::remove_dir_all(&cache).map_err(crate::error::CliError::Io)?; |
| 456 | } |
| 457 | |
| 458 | if cache.exists() { |
| 459 | println!( |
| 460 | "Using cached package at {} (use --force to refresh).", |
| 461 | cache.display() |
| 462 | ); |
| 463 | } else { |
| 464 | if let Some(ref tag) = spec.tag { |
| 465 | print_warning(&format!( |
| 466 | "Tag pinning ({tag}) is not yet implemented — installing the head of view '{}' instead.", |
| 467 | spec.view |
| 468 | )); |
| 469 | } |
| 470 | crate::commands::clone::Clone::new(spec.url.clone()) |
| 471 | .with_path(cache.display().to_string()) |
| 472 | .with_view(spec.view.clone()) |
| 473 | .run()?; |
| 474 | } |
| 475 | |
| 476 | Ok(cache) |
| 477 | } |
| 478 | |
| 479 | impl Enable { |
| 480 | /// Install an externally-packaged integration for an agent. |
no test coverage detected