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,
)
| 401 | /// First run clones the package; later runs reuse the cache so enable works |
| 402 | /// offline. `--force` discards the cache and re-clones. |
| 403 | fn sync_integration_package( |
| 404 | agent_name: &str, |
| 405 | spec: &atomic_agent::integrations::IntegrationSpec, |
| 406 | force: bool, |
| 407 | ) -> CliResult<std::path::PathBuf> { |
| 408 | let cache = atomic_agent::integrations::cache_repo_dir(agent_name) |
| 409 | .map_err(|e| crate::error::CliError::Internal(anyhow::anyhow!(e.to_string())))?; |
| 410 | |
| 411 | if force && cache.exists() { |
| 412 | std::fs::remove_dir_all(&cache).map_err(crate::error::CliError::Io)?; |
| 413 | } |
| 414 | |
| 415 | if cache.exists() { |
| 416 | println!( |
| 417 | "Using cached package at {} (use --force to refresh).", |
| 418 | cache.display() |
| 419 | ); |
| 420 | } else { |
| 421 | if let Some(ref tag) = spec.tag { |
| 422 | print_warning(&format!( |
| 423 | "Tag pinning ({tag}) is not yet implemented — installing the head of view '{}' instead.", |
| 424 | spec.view |
| 425 | )); |
| 426 | } |
| 427 | crate::commands::clone::Clone::new(spec.url.clone()) |
| 428 | .with_path(cache.display().to_string()) |
| 429 | .with_view(spec.view.clone()) |
| 430 | .run()?; |
| 431 | } |
| 432 | |
| 433 | Ok(cache) |
| 434 | } |
| 435 | |
| 436 | impl Enable { |
| 437 | /// Install an externally-packaged integration for an agent. |
no test coverage detected