try deserialise old profile names in kebab case (#614)
This commit is contained in:
committed by
GitHub
parent
b5c565877d
commit
1c0564c979
@@ -8,7 +8,7 @@ utils = { path = "../utils" }
|
||||
tokio = { workspace = true }
|
||||
tokio-util = { version = "0.7", features = ["io"] }
|
||||
bytes = "1.0"
|
||||
serde = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
toml = "0.8"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{collections::HashMap, fs, sync::RwLock};
|
||||
use std::{collections::HashMap, fs, str::FromStr, sync::RwLock};
|
||||
|
||||
use convert_case::{Case, Casing};
|
||||
use lazy_static::lazy_static;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Deserializer, Serialize, de::Error as DeError};
|
||||
use thiserror::Error;
|
||||
use ts_rs::TS;
|
||||
|
||||
@@ -54,7 +54,7 @@ const DEFAULT_PROFILES_JSON: &str = include_str!("../default_profiles.json");
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, TS, Hash, Eq)]
|
||||
pub struct ExecutorProfileId {
|
||||
/// The executor type (e.g., "CLAUDE_CODE", "AMP")
|
||||
#[serde(alias = "profile")]
|
||||
#[serde(alias = "profile", deserialize_with = "de_base_coding_agent_kebab")]
|
||||
// Backwards compatability with ProfileVariantIds, esp stored in DB under ExecutorAction
|
||||
pub executor: BaseCodingAgent,
|
||||
/// Optional variant name (e.g., "PLAN", "ROUTER")
|
||||
@@ -62,6 +62,18 @@ pub struct ExecutorProfileId {
|
||||
pub variant: Option<String>,
|
||||
}
|
||||
|
||||
// Convert legacy profile/executor names from kebab-case to SCREAMING_SNAKE_CASE, can be deleted 14 days from 3/9/25
|
||||
fn de_base_coding_agent_kebab<'de, D>(de: D) -> Result<BaseCodingAgent, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let raw = String::deserialize(de)?;
|
||||
// kebab-case -> SCREAMING_SNAKE_CASE
|
||||
let norm = raw.replace('-', "_").to_ascii_uppercase();
|
||||
BaseCodingAgent::from_str(&norm)
|
||||
.map_err(|_| D::Error::custom(format!("unknown executor '{raw}' (normalized to '{norm}')")))
|
||||
}
|
||||
|
||||
impl ExecutorProfileId {
|
||||
/// Create a new executor profile ID with default variant
|
||||
pub fn new(executor: BaseCodingAgent) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user