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>
65 lines
2.3 KiB
Rust
65 lines
2.3 KiB
Rust
//! Conservative authentication checks that run before the provisional composer appears.
|
|
//!
|
|
//! Existing configuration, daemon, or authentication state keeps the composer visible.
|
|
|
|
use std::io;
|
|
use std::path::Path;
|
|
|
|
use akode_utils_absolute_path::AbsolutePathBuf;
|
|
|
|
/// Recognize the single configuration override synthesized by the legacy `--search` flag.
|
|
pub(super) fn has_only_search_config_override(cli_kv_overrides: &[(String, toml::Value)]) -> bool {
|
|
matches!(
|
|
cli_kv_overrides,
|
|
[(key, toml::Value::String(value))] if key == "web_search" && value == "live"
|
|
)
|
|
}
|
|
|
|
/// Hide the composer when the default file-backed account cannot already be authenticated.
|
|
pub(super) fn should_delay_startup_composer_for_first_login(
|
|
codex_home: &Path,
|
|
system_config_path: io::Result<AbsolutePathBuf>,
|
|
managed_configuration: impl FnOnce() -> io::Result<bool>,
|
|
) -> bool {
|
|
let Ok(system_config_path) = system_config_path else {
|
|
return false;
|
|
};
|
|
if !matches!(system_config_path.as_path().try_exists(), Ok(false)) {
|
|
return false;
|
|
}
|
|
|
|
match std::fs::metadata(codex_home) {
|
|
Ok(metadata) if !metadata.is_dir() => return false,
|
|
Ok(_) => {
|
|
// With file auth as the default, auth.json is a hint of existing credentials.
|
|
// An existing config.toml may select keyring storage, which need not create
|
|
// auth.json. Keep the composer visible when any of these files exists;
|
|
// the normal account lookup decides whether sign-in is required.
|
|
for state_file in ["auth.json", "config.toml", "environments.toml"] {
|
|
if !matches!(codex_home.join(state_file).try_exists(), Ok(false)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
let Ok(daemon_socket) =
|
|
akode_app_server_client::app_server_control_socket_path(codex_home)
|
|
else {
|
|
return false;
|
|
};
|
|
if !matches!(daemon_socket.as_path().try_exists(), Ok(false)) {
|
|
return false;
|
|
}
|
|
}
|
|
Err(error)
|
|
if error.kind() == io::ErrorKind::NotFound
|
|
&& matches!(codex_home.try_exists(), Ok(false)) => {}
|
|
Err(_) => return false,
|
|
}
|
|
|
|
matches!(managed_configuration(), Ok(false))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "startup_preflight_tests.rs"]
|
|
mod tests;
|