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,
)
| 330 | /// First run clones the package; later runs reuse the cache so enable works |
| 331 | /// offline. `--force` discards the cache and re-clones. |
| 332 | fn sync_integration_package( |
| 333 | agent_name: &str, |
| 334 | spec: &atomic_agent::integrations::IntegrationSpec, |
| 335 | force: bool, |
| 336 | ) -> CliResult<std::path::PathBuf> { |
| 337 | let cache = atomic_agent::integrations::cache_repo_dir(agent_name) |
| 338 | .map_err(|e| crate::error::CliError::Internal(anyhow::anyhow!(e.to_string())))?; |
| 339 | |
| 340 | if force && cache.exists() { |
| 341 | std::fs::remove_dir_all(&cache).map_err(crate::error::CliError::Io)?; |
| 342 | } |
| 343 | |
| 344 | if cache.exists() { |
| 345 | println!( |
| 346 | "Using cached package at {} (use --force to refresh).", |
| 347 | cache.display() |
| 348 | ); |
| 349 | } else { |
| 350 | if let Some(ref tag) = spec.tag { |
| 351 | print_warning(&format!( |
| 352 | "Tag pinning ({tag}) is not yet implemented — installing the head of view '{}' instead.", |
| 353 | spec.view |
| 354 | )); |
| 355 | } |
| 356 | crate::commands::clone::Clone::new(spec.url.clone()) |
| 357 | .with_path(cache.display().to_string()) |
| 358 | .with_view(spec.view.clone()) |
| 359 | .run()?; |
| 360 | } |
| 361 | |
| 362 | Ok(cache) |
| 363 | } |
| 364 | |
| 365 | impl Enable { |
| 366 | /// Install an externally-packaged integration for an agent. |
no test coverage detected