Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
85 lines
3.5 KiB
Rust
85 lines
3.5 KiB
Rust
//! Invocation overrides apply on fresh starts or explicitly confirmed managed restarts.
|
|
//! The lifecycle lock serializes persistence against other clients and updates.
|
|
|
|
use crate::Daemon;
|
|
use crate::LifecycleOutput;
|
|
use crate::ensure_supported_platform;
|
|
use crate::start_error::StartError;
|
|
use anyhow::Result;
|
|
use anyhow::ensure;
|
|
use std::collections::BTreeMap;
|
|
|
|
/// Start a missing daemon with these features, preserving other saved overrides,
|
|
/// or leave a running daemon unchanged.
|
|
/// Callers must check the running server's configuration before using it.
|
|
/// Startup diagnostics go to tracing, so a caller with a live TUI can keep rendering.
|
|
pub async fn start_with_features(features: &BTreeMap<String, bool>) -> Result<LifecycleOutput> {
|
|
start_with_features_classified(features)
|
|
.await
|
|
.map_err(|err| err.error)
|
|
}
|
|
|
|
/// Starts the daemon and classifies failures for the TUI startup counter.
|
|
pub async fn start_with_features_classified(
|
|
features: &BTreeMap<String, bool>,
|
|
) -> Result<LifecycleOutput, StartError> {
|
|
ensure_supported_platform()?;
|
|
#[cfg(windows)]
|
|
crate::backend::windows::ensure_not_elevated()?;
|
|
let mut daemon = Daemon::from_environment()?;
|
|
daemon.log_diagnostics = true;
|
|
let _operation_lock = daemon.acquire_operation_lock().await?;
|
|
let selected = daemon.current_installation()?;
|
|
let mut overrides = selected.load_settings().await?.feature_overrides;
|
|
overrides.extend(features.clone());
|
|
Box::pin(selected.start(&overrides)).await
|
|
}
|
|
|
|
/// Apply confirmed feature settings to an existing managed daemon and restart it.
|
|
/// Callers must obtain consent for changes to shared services and interrupted work,
|
|
/// then verify effective server compatibility after this operation completes.
|
|
pub async fn restart_with_features(features: &BTreeMap<String, bool>) -> Result<LifecycleOutput> {
|
|
ensure_supported_platform()?;
|
|
#[cfg(windows)]
|
|
crate::backend::windows::ensure_not_elevated()?;
|
|
let daemon = Daemon::from_environment()?;
|
|
let _operation_lock = daemon.acquire_operation_lock().await?;
|
|
let selected = daemon.current_installation()?;
|
|
Box::pin(selected.restart_with_features_locked(features)).await
|
|
}
|
|
|
|
impl Daemon {
|
|
pub(super) async fn restart(
|
|
&self,
|
|
features: &BTreeMap<String, bool>,
|
|
) -> Result<LifecycleOutput> {
|
|
let mut settings = self.load_settings().await?;
|
|
// Explicit requests replace saved aliases as well as canonical keys.
|
|
settings.feature_overrides.retain(|name, _| {
|
|
let canonical = akode_features::feature_for_key(name)
|
|
.map(akode_features::Feature::key)
|
|
.unwrap_or(name);
|
|
!features.contains_key(canonical)
|
|
});
|
|
settings.feature_overrides.extend(features.clone());
|
|
self.restart_with_settings(settings).await
|
|
}
|
|
|
|
pub(super) async fn restart_with_features_locked(
|
|
&self,
|
|
features: &BTreeMap<String, bool>,
|
|
) -> Result<LifecycleOutput> {
|
|
let mut settings = self.load_settings().await?;
|
|
ensure!(
|
|
self.running_backend_instance(&settings).await?.is_some(),
|
|
"no running managed daemon; rerun the command to check the current server"
|
|
);
|
|
let previous = settings.feature_overrides.clone();
|
|
settings.feature_overrides.extend(features.clone());
|
|
if settings.feature_overrides == previous {
|
|
return self.start(&previous).await.map_err(|err| err.error);
|
|
}
|
|
self.restart_with_settings(settings).await
|
|
}
|
|
}
|