diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 84448e2f0..c1e7cdd48 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -9,7 +9,8 @@ homepage = { workspace = true } readme = "../README.md" [features] -default = ["bedrock"] +default = ["auto-update", "bedrock"] +auto-update = [] bedrock = ["stakpak-shared/bedrock", "stakai/bedrock"] jemalloc = ["dep:tikv-jemallocator"] libsql-test = [] diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 7a679c42b..f2dfba4b9 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -11,6 +11,7 @@ pub mod acp; pub mod agent; pub mod ak; pub mod auth; +#[cfg(feature = "auto-update")] pub mod auto_update; pub mod autopilot; pub mod board; @@ -192,6 +193,7 @@ pub enum Commands { )] Ak(ak::AkCommands), /// Update Stakpak Agent to the latest version + #[cfg(feature = "auto-update")] Update, /// Autonomous 24/7 lifecycle commands @@ -256,6 +258,10 @@ fn get_config_path_option(config: &AppConfig) -> Option<&Path> { impl Commands { pub fn requires_auth(&self) -> bool { + #[cfg(feature = "auto-update")] + if matches!(self, Commands::Update) { + return false; + } !matches!( self, Commands::Login { .. } @@ -264,7 +270,6 @@ impl Commands { | Commands::Config(_) | Commands::Version | Commands::Completion { .. } - | Commands::Update | Commands::Acp { .. } | Commands::Auth(_) | Commands::Autopilot(_) @@ -516,6 +521,7 @@ impl Commands { Commands::Ak(command) => { command.run()?; } + #[cfg(feature = "auto-update")] Commands::Update => { auto_update::run_auto_update(false).await?; } @@ -538,10 +544,13 @@ impl Commands { } Commands::Acp { system_prompt_file } => { // Force auto-update before starting ACP session (no prompt) - use crate::utils::check_update::force_auto_update; - if let Err(e) = force_auto_update().await { - // Log error but continue - don't block ACP if update check fails - eprintln!("Update check failed: {}", e); + #[cfg(feature = "auto-update")] + { + use crate::utils::check_update::force_auto_update; + if let Err(e) = force_auto_update().await { + // Log error but continue - don't block ACP if update check fails + eprintln!("Update check failed: {}", e); + } } let system_prompt = if let Some(system_prompt_file_path) = &system_prompt_file { diff --git a/cli/src/main.rs b/cli/src/main.rs index fbf312fc4..95e300bdb 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -54,7 +54,9 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use utils::agent_context::AgentContext; use utils::agents_md::discover_agents_md; use utils::apps_md::discover_apps_md; -use utils::check_update::{auto_update, check_update}; +#[cfg(feature = "auto-update")] +use utils::check_update::auto_update; +use utils::check_update::check_update; use utils::gitignore; use utils::local_context::analyze_local_context; @@ -238,6 +240,7 @@ async fn main() { }; // Only run auto-update in interactive mode (when no command is specified) + #[cfg(feature = "auto-update")] if cli.command.is_none() && !cli.r#async && !cli.print diff --git a/cli/src/utils/check_update.rs b/cli/src/utils/check_update.rs index 2b8f1a36a..86c4f9c82 100644 --- a/cli/src/utils/check_update.rs +++ b/cli/src/utils/check_update.rs @@ -4,6 +4,7 @@ use serde::Deserialize; use stakpak_shared::tls_client::{TlsClientConfig, create_tls_client}; use std::error::Error; +#[cfg(feature = "auto-update")] use crate::commands::auto_update::run_auto_update; use crate::utils::cli_colors::CliColors; @@ -196,6 +197,7 @@ pub async fn get_latest_cli_version() -> Result> { Ok(release.tag_name) } +#[cfg(feature = "auto-update")] pub async fn auto_update() -> Result<(), Box> { let release = get_latest_release().await?; let current_version = format!("v{}", env!("CARGO_PKG_VERSION")); @@ -245,6 +247,7 @@ pub async fn auto_update() -> Result<(), Box> { /// Force auto-update without prompting (for ACP mode). /// Returns true if an update was performed and the process should restart. +#[cfg(feature = "auto-update")] pub async fn force_auto_update() -> Result> { let release = get_latest_release().await?; let current_version = format!("v{}", env!("CARGO_PKG_VERSION"));