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,
)
| 508 | /// First run clones the package; later runs reuse the cache so enable works |
| 509 | /// offline. `--force` discards the cache and re-clones. |
| 510 | fn sync_integration_package( |
| 511 | agent_name: &str, |
| 512 | spec: &atomic_agent::integrations::IntegrationSpec, |
| 513 | force: bool, |
| 514 | ) -> CliResult<std::path::PathBuf> { |
| 515 | let cache = atomic_agent::integrations::cache_repo_dir(agent_name) |
| 516 | .map_err(|e| crate::error::CliError::Internal(anyhow::anyhow!(e.to_string())))?; |
| 517 | |
| 518 | if force && cache.exists() { |
| 519 | std::fs::remove_dir_all(&cache).map_err(crate::error::CliError::Io)?; |
| 520 | } |
| 521 | |
| 522 | if cache.exists() { |
| 523 | println!( |
| 524 | "Using cached package at {} (use --force to refresh).", |
| 525 | cache.display() |
| 526 | ); |
| 527 | } else { |
| 528 | if let Some(ref tag) = spec.tag { |
| 529 | print_warning(&format!( |
| 530 | "Tag pinning ({tag}) is not yet implemented — installing the head of view '{}' instead.", |
| 531 | spec.view |
| 532 | )); |
| 533 | } |
| 534 | crate::commands::clone::Clone::new(spec.url.clone()) |
| 535 | .with_path(cache.display().to_string()) |
| 536 | .with_view(spec.view.clone()) |
| 537 | .run()?; |
| 538 | } |
| 539 | |
| 540 | Ok(cache) |
| 541 | } |
| 542 | |
| 543 | impl Enable { |
| 544 | /// Install an externally-packaged integration for an agent. |
no test coverage detected