Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
19 changes: 14 additions & 5 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 { .. }
Expand All @@ -264,7 +270,6 @@ impl Commands {
| Commands::Config(_)
| Commands::Version
| Commands::Completion { .. }
| Commands::Update
| Commands::Acp { .. }
| Commands::Auth(_)
| Commands::Autopilot(_)
Expand Down Expand Up @@ -516,6 +521,7 @@ impl Commands {
Commands::Ak(command) => {
command.run()?;
}
#[cfg(feature = "auto-update")]
Commands::Update => {
auto_update::run_auto_update(false).await?;
}
Expand All @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cli/src/utils/check_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -196,6 +197,7 @@ pub async fn get_latest_cli_version() -> Result<String, Box<dyn Error>> {
Ok(release.tag_name)
}

#[cfg(feature = "auto-update")]
pub async fn auto_update() -> Result<(), Box<dyn Error>> {
let release = get_latest_release().await?;
let current_version = format!("v{}", env!("CARGO_PKG_VERSION"));
Expand Down Expand Up @@ -245,6 +247,7 @@ pub async fn auto_update() -> Result<(), Box<dyn Error>> {

/// 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<bool, Box<dyn Error>> {
let release = get_latest_release().await?;
let current_version = format!("v{}", env!("CARGO_PKG_VERSION"));
Expand Down
Loading