mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
fix: align marketplace display name with existing interface conventions (#14886)
1. camelCase for displayName; 2. move displayName under interface.
This commit is contained in:
@@ -3,6 +3,7 @@ use super::curated_plugins_repo_path;
|
||||
use super::load_plugin_manifest;
|
||||
use super::manifest::PluginManifestInterfaceSummary;
|
||||
use super::marketplace::MarketplaceError;
|
||||
use super::marketplace::MarketplaceInterfaceSummary;
|
||||
use super::marketplace::MarketplacePluginAuthPolicy;
|
||||
use super::marketplace::MarketplacePluginInstallPolicy;
|
||||
use super::marketplace::MarketplacePluginSourceSummary;
|
||||
@@ -121,7 +122,7 @@ pub struct PluginDetailSummary {
|
||||
pub struct ConfiguredMarketplaceSummary {
|
||||
pub name: String,
|
||||
pub path: AbsolutePathBuf,
|
||||
pub display_name: Option<String>,
|
||||
pub interface: Option<MarketplaceInterfaceSummary>,
|
||||
pub plugins: Vec<ConfiguredMarketplacePluginSummary>,
|
||||
}
|
||||
|
||||
@@ -846,7 +847,7 @@ impl PluginsManager {
|
||||
(!plugins.is_empty()).then_some(ConfiguredMarketplaceSummary {
|
||||
name: marketplace.name,
|
||||
path: marketplace.path,
|
||||
display_name: marketplace.display_name,
|
||||
interface: marketplace.interface,
|
||||
plugins,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -999,7 +999,7 @@ enabled = false
|
||||
tmp.path().join("repo/.agents/plugins/marketplace.json"),
|
||||
)
|
||||
.unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![
|
||||
ConfiguredMarketplacePluginSummary {
|
||||
id: "enabled-plugin@debug".to_string(),
|
||||
@@ -1044,7 +1044,9 @@ async fn list_marketplaces_includes_curated_repo_marketplace() {
|
||||
curated_root.join(".agents/plugins/marketplace.json"),
|
||||
r#"{
|
||||
"name": "openai-curated",
|
||||
"display_name": "ChatGPT Official",
|
||||
"interface": {
|
||||
"displayName": "ChatGPT Official"
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "linear",
|
||||
@@ -1079,7 +1081,9 @@ async fn list_marketplaces_includes_curated_repo_marketplace() {
|
||||
name: "openai-curated".to_string(),
|
||||
path: AbsolutePathBuf::try_from(curated_root.join(".agents/plugins/marketplace.json"))
|
||||
.unwrap(),
|
||||
display_name: Some("ChatGPT Official".to_string()),
|
||||
interface: Some(MarketplaceInterfaceSummary {
|
||||
display_name: Some("ChatGPT Official".to_string()),
|
||||
}),
|
||||
plugins: vec![ConfiguredMarketplacePluginSummary {
|
||||
id: "linear@openai-curated".to_string(),
|
||||
name: "linear".to_string(),
|
||||
@@ -1284,7 +1288,7 @@ enabled = true
|
||||
tmp.path().join("repo/.agents/plugins/marketplace.json"),
|
||||
)
|
||||
.unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![ConfiguredMarketplacePluginSummary {
|
||||
id: "sample-plugin@debug".to_string(),
|
||||
name: "sample-plugin".to_string(),
|
||||
|
||||
@@ -28,10 +28,15 @@ pub struct ResolvedMarketplacePlugin {
|
||||
pub struct MarketplaceSummary {
|
||||
pub name: String,
|
||||
pub path: AbsolutePathBuf,
|
||||
pub display_name: Option<String>,
|
||||
pub interface: Option<MarketplaceInterfaceSummary>,
|
||||
pub plugins: Vec<MarketplacePluginSummary>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MarketplaceInterfaceSummary {
|
||||
pub display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MarketplacePluginSummary {
|
||||
pub name: String,
|
||||
@@ -213,7 +218,7 @@ pub(crate) fn load_marketplace_summary(
|
||||
Ok(MarketplaceSummary {
|
||||
name: marketplace.name,
|
||||
path: path.clone(),
|
||||
display_name: marketplace.display_name,
|
||||
interface: marketplace_interface_summary(marketplace.interface),
|
||||
plugins,
|
||||
})
|
||||
}
|
||||
@@ -367,14 +372,21 @@ fn marketplace_root_dir(
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct MarketplaceFile {
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
#[serde(alias = "displayName")]
|
||||
display_name: Option<String>,
|
||||
interface: Option<MarketplaceInterface>,
|
||||
plugins: Vec<MarketplacePlugin>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct MarketplaceInterface {
|
||||
#[serde(default)]
|
||||
display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct MarketplacePlugin {
|
||||
@@ -394,6 +406,19 @@ enum MarketplacePluginSource {
|
||||
Local { path: String },
|
||||
}
|
||||
|
||||
fn marketplace_interface_summary(
|
||||
interface: Option<MarketplaceInterface>,
|
||||
) -> Option<MarketplaceInterfaceSummary> {
|
||||
let interface = interface?;
|
||||
if interface.display_name.is_some() {
|
||||
Some(MarketplaceInterfaceSummary {
|
||||
display_name: interface.display_name,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "marketplace_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -137,7 +137,7 @@ fn list_marketplaces_returns_home_and_repo_marketplaces() {
|
||||
path:
|
||||
AbsolutePathBuf::try_from(home_root.join(".agents/plugins/marketplace.json"),)
|
||||
.unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![
|
||||
MarketplacePluginSummary {
|
||||
name: "shared-plugin".to_string(),
|
||||
@@ -164,7 +164,7 @@ fn list_marketplaces_returns_home_and_repo_marketplaces() {
|
||||
path:
|
||||
AbsolutePathBuf::try_from(repo_root.join(".agents/plugins/marketplace.json"),)
|
||||
.unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![
|
||||
MarketplacePluginSummary {
|
||||
name: "shared-plugin".to_string(),
|
||||
@@ -247,7 +247,7 @@ fn list_marketplaces_keeps_distinct_entries_for_same_name() {
|
||||
MarketplaceSummary {
|
||||
name: "codex-curated".to_string(),
|
||||
path: AbsolutePathBuf::try_from(home_marketplace).unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![MarketplacePluginSummary {
|
||||
name: "local-plugin".to_string(),
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
@@ -261,7 +261,7 @@ fn list_marketplaces_keeps_distinct_entries_for_same_name() {
|
||||
MarketplaceSummary {
|
||||
name: "codex-curated".to_string(),
|
||||
path: AbsolutePathBuf::try_from(repo_marketplace.clone()).unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![MarketplacePluginSummary {
|
||||
name: "local-plugin".to_string(),
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
@@ -328,7 +328,7 @@ fn list_marketplaces_dedupes_multiple_roots_in_same_repo() {
|
||||
name: "codex-curated".to_string(),
|
||||
path: AbsolutePathBuf::try_from(repo_root.join(".agents/plugins/marketplace.json"))
|
||||
.unwrap(),
|
||||
display_name: None,
|
||||
interface: None,
|
||||
plugins: vec![MarketplacePluginSummary {
|
||||
name: "local-plugin".to_string(),
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
@@ -353,7 +353,9 @@ fn list_marketplaces_reads_marketplace_display_name() {
|
||||
repo_root.join(".agents/plugins/marketplace.json"),
|
||||
r#"{
|
||||
"name": "openai-curated",
|
||||
"display_name": "ChatGPT Official",
|
||||
"interface": {
|
||||
"displayName": "ChatGPT Official"
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "local-plugin",
|
||||
@@ -372,8 +374,10 @@ fn list_marketplaces_reads_marketplace_display_name() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
marketplaces[0].display_name,
|
||||
Some("ChatGPT Official".to_string())
|
||||
marketplaces[0].interface,
|
||||
Some(MarketplaceInterfaceSummary {
|
||||
display_name: Some("ChatGPT Official".to_string()),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user