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>
115 lines
3.8 KiB
Rust
115 lines
3.8 KiB
Rust
//! Plugin mutation errors and their stable telemetry classifications.
|
|
|
|
use crate::marketplace::MarketplaceError;
|
|
use crate::store::PluginStoreError;
|
|
use crate::store::error_context_sub_error_type;
|
|
use akode_plugin::PluginIdError;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum PluginInstallError {
|
|
#[error("{0}")]
|
|
Marketplace(#[from] MarketplaceError),
|
|
|
|
#[error("{0}")]
|
|
Store(#[from] PluginStoreError),
|
|
|
|
#[error("{0}")]
|
|
Config(#[from] anyhow::Error),
|
|
|
|
#[error("failed to join plugin install task: {0}")]
|
|
Join(#[from] tokio::task::JoinError),
|
|
}
|
|
|
|
impl PluginInstallError {
|
|
pub(super) fn join(source: tokio::task::JoinError) -> Self {
|
|
Self::Join(source)
|
|
}
|
|
|
|
pub fn is_invalid_request(&self) -> bool {
|
|
matches!(
|
|
self,
|
|
Self::Marketplace(
|
|
MarketplaceError::MarketplaceNotFound { .. }
|
|
| MarketplaceError::InvalidMarketplaceFile { .. }
|
|
| MarketplaceError::PluginNotFound { .. }
|
|
| MarketplaceError::PluginNotAvailable { .. }
|
|
| MarketplaceError::InvalidPlugin(_)
|
|
) | Self::Store(PluginStoreError::Invalid(_))
|
|
)
|
|
}
|
|
|
|
pub fn sub_error_type(&self) -> Option<String> {
|
|
match self {
|
|
Self::Marketplace(err) => marketplace_error_sub_error_type(err),
|
|
Self::Store(err) => err.sub_error_type(),
|
|
Self::Config(_) => Some("failed_to_enable_plugin".to_string()),
|
|
Self::Join(_) => Some("plugin_install_task_failed".to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(super) fn plugin_install_error_type(err: &PluginInstallError) -> &'static str {
|
|
match err {
|
|
PluginInstallError::Marketplace(err) => marketplace_error_type(err),
|
|
PluginInstallError::Store(err) => plugin_store_error_type(err),
|
|
PluginInstallError::Config(_) => "config",
|
|
PluginInstallError::Join(_) => "join",
|
|
}
|
|
}
|
|
|
|
pub(super) fn marketplace_error_type(err: &MarketplaceError) -> &'static str {
|
|
match err {
|
|
MarketplaceError::Io { .. } => "marketplace_io",
|
|
MarketplaceError::MarketplaceNotFound { .. } => "marketplace_not_found",
|
|
MarketplaceError::InvalidMarketplaceFile { .. } => "invalid_marketplace_file",
|
|
MarketplaceError::PluginNotFound { .. } => "plugin_not_found",
|
|
MarketplaceError::PluginNotAvailable { .. } => "plugin_not_available",
|
|
MarketplaceError::PluginsDisabled => "plugins_disabled",
|
|
MarketplaceError::InvalidPlugin(_) => "invalid_plugin",
|
|
}
|
|
}
|
|
|
|
pub(super) fn marketplace_error_sub_error_type(err: &MarketplaceError) -> Option<String> {
|
|
match err {
|
|
MarketplaceError::Io { context, .. } => Some(error_context_sub_error_type(context)),
|
|
MarketplaceError::MarketplaceNotFound { .. }
|
|
| MarketplaceError::InvalidMarketplaceFile { .. }
|
|
| MarketplaceError::PluginNotFound { .. }
|
|
| MarketplaceError::PluginNotAvailable { .. }
|
|
| MarketplaceError::PluginsDisabled
|
|
| MarketplaceError::InvalidPlugin(_) => None,
|
|
}
|
|
}
|
|
|
|
fn plugin_store_error_type(err: &PluginStoreError) -> &'static str {
|
|
match err {
|
|
PluginStoreError::Io { .. } => "store_io",
|
|
PluginStoreError::Invalid(_) => "store_invalid",
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum PluginUninstallError {
|
|
#[error("{0}")]
|
|
InvalidPluginId(#[from] PluginIdError),
|
|
|
|
#[error("{0}")]
|
|
Store(#[from] PluginStoreError),
|
|
|
|
#[error("{0}")]
|
|
Config(#[from] anyhow::Error),
|
|
|
|
#[error("failed to join plugin uninstall task: {0}")]
|
|
Join(#[from] tokio::task::JoinError),
|
|
}
|
|
|
|
impl PluginUninstallError {
|
|
pub(super) fn join(source: tokio::task::JoinError) -> Self {
|
|
Self::Join(source)
|
|
}
|
|
|
|
pub fn is_invalid_request(&self) -> bool {
|
|
matches!(self, Self::InvalidPluginId(_))
|
|
}
|
|
}
|