mirror of
https://github.com/openai/codex.git
synced 2026-05-16 01:02:48 +00:00
Add plugin default prompt alias
This commit is contained in:
@@ -12089,6 +12089,13 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"defaultPromptAlias": {
|
||||
"description": "Mention label used before starter prompts on plugin detail surfaces.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"developerName": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -8638,6 +8638,13 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"defaultPromptAlias": {
|
||||
"description": "Mention label used before starter prompts on plugin detail surfaces.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"developerName": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -111,6 +111,13 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"defaultPromptAlias": {
|
||||
"description": "Mention label used before starter prompts on plugin detail surfaces.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"developerName": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -204,6 +204,13 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"defaultPromptAlias": {
|
||||
"description": "Mention label used before starter prompts on plugin detail surfaces.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"developerName": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -85,6 +85,13 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"defaultPromptAlias": {
|
||||
"description": "Mention label used before starter prompts on plugin detail surfaces.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"developerName": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -8,7 +8,11 @@ export type PluginInterface = { displayName: string | null, shortDescription: st
|
||||
* Starter prompts for the plugin. Capped at 3 entries with a maximum of
|
||||
* 128 characters per entry.
|
||||
*/
|
||||
defaultPrompt: Array<string> | null, brandColor: string | null,
|
||||
defaultPrompt: Array<string> | null,
|
||||
/**
|
||||
* Mention label used before starter prompts on plugin detail surfaces.
|
||||
*/
|
||||
defaultPromptAlias: string | null, brandColor: string | null,
|
||||
/**
|
||||
* Local composer icon path, resolved from the installed plugin package.
|
||||
*/
|
||||
|
||||
@@ -644,6 +644,8 @@ pub struct PluginInterface {
|
||||
/// Starter prompts for the plugin. Capped at 3 entries with a maximum of
|
||||
/// 128 characters per entry.
|
||||
pub default_prompt: Option<Vec<String>>,
|
||||
/// Mention label used before starter prompts on plugin detail surfaces.
|
||||
pub default_prompt_alias: Option<String>,
|
||||
pub brand_color: Option<String>,
|
||||
/// Local composer icon path, resolved from the installed plugin package.
|
||||
pub composer_icon: Option<AbsolutePathBuf>,
|
||||
|
||||
@@ -2671,6 +2671,7 @@ fn plugin_interface_serializes_local_paths_and_remote_urls_separately() {
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: Some(composer_icon),
|
||||
composer_icon_url: Some("https://example.com/linear/icon.png".to_string()),
|
||||
@@ -2693,6 +2694,7 @@ fn plugin_interface_serializes_local_paths_and_remote_urls_separately() {
|
||||
"privacyPolicyUrl": null,
|
||||
"termsOfServiceUrl": null,
|
||||
"defaultPrompt": null,
|
||||
"defaultPromptAlias": null,
|
||||
"brandColor": null,
|
||||
"composerIcon": composer_icon_json,
|
||||
"composerIconUrl": "https://example.com/linear/icon.png",
|
||||
|
||||
@@ -61,6 +61,7 @@ fn local_plugin_interface_to_info(interface: PluginManifestInterface) -> PluginI
|
||||
privacy_policy_url: interface.privacy_policy_url,
|
||||
terms_of_service_url: interface.terms_of_service_url,
|
||||
default_prompt: interface.default_prompt,
|
||||
default_prompt_alias: interface.default_prompt_alias,
|
||||
brand_color: interface.brand_color,
|
||||
composer_icon: interface.composer_icon,
|
||||
composer_icon_url: None,
|
||||
|
||||
@@ -554,6 +554,7 @@ async fn plugin_list_uses_alternate_discoverable_manifest_and_keeps_undiscoverab
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
composer_icon_url: None,
|
||||
|
||||
@@ -1353,6 +1353,7 @@ fn expected_plugin_interface() -> PluginInterface {
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
composer_icon_url: None,
|
||||
|
||||
@@ -70,6 +70,7 @@ pub struct PluginManifestInterface {
|
||||
pub privacy_policy_url: Option<String>,
|
||||
pub terms_of_service_url: Option<String>,
|
||||
pub default_prompt: Option<Vec<String>>,
|
||||
pub default_prompt_alias: Option<String>,
|
||||
pub brand_color: Option<String>,
|
||||
pub composer_icon: Option<AbsolutePathBuf>,
|
||||
pub logo: Option<AbsolutePathBuf>,
|
||||
@@ -103,6 +104,8 @@ struct RawPluginManifestInterface {
|
||||
#[serde(default)]
|
||||
default_prompt: Option<RawPluginManifestDefaultPrompt>,
|
||||
#[serde(default)]
|
||||
default_prompt_alias: Option<String>,
|
||||
#[serde(default)]
|
||||
brand_color: Option<String>,
|
||||
#[serde(default)]
|
||||
composer_icon: Option<String>,
|
||||
@@ -175,6 +178,7 @@ pub fn load_plugin_manifest(plugin_root: &Path) -> Option<PluginManifest> {
|
||||
privacy_policy_url,
|
||||
terms_of_service_url,
|
||||
default_prompt,
|
||||
default_prompt_alias,
|
||||
brand_color,
|
||||
composer_icon,
|
||||
logo,
|
||||
@@ -192,6 +196,9 @@ pub fn load_plugin_manifest(plugin_root: &Path) -> Option<PluginManifest> {
|
||||
privacy_policy_url,
|
||||
terms_of_service_url,
|
||||
default_prompt: resolve_default_prompts(plugin_root, default_prompt.as_ref()),
|
||||
default_prompt_alias: non_empty_collapsed_string(
|
||||
default_prompt_alias.as_deref(),
|
||||
),
|
||||
brand_color,
|
||||
composer_icon: resolve_interface_asset_path(
|
||||
plugin_root,
|
||||
@@ -225,6 +232,7 @@ pub fn load_plugin_manifest(plugin_root: &Path) -> Option<PluginManifest> {
|
||||
|| interface.privacy_policy_url.is_some()
|
||||
|| interface.terms_of_service_url.is_some()
|
||||
|| interface.default_prompt.is_some()
|
||||
|| interface.default_prompt_alias.is_some()
|
||||
|| interface.brand_color.is_some()
|
||||
|| interface.composer_icon.is_some()
|
||||
|| interface.logo.is_some()
|
||||
@@ -372,6 +380,11 @@ fn resolve_default_prompt_str(plugin_root: &Path, field: &str, prompt: &str) ->
|
||||
Some(prompt)
|
||||
}
|
||||
|
||||
fn non_empty_collapsed_string(value: Option<&str>) -> Option<String> {
|
||||
let value = value?.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
(!value.is_empty()).then_some(value)
|
||||
}
|
||||
|
||||
fn warn_invalid_default_prompt(plugin_root: &Path, field: &str, message: &str) {
|
||||
if let Some(manifest_path) = find_plugin_manifest_path(plugin_root) {
|
||||
tracing::warn!(
|
||||
@@ -556,6 +569,28 @@ mod tests {
|
||||
assert_eq!(interface.default_prompt, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plugin_interface_normalizes_default_prompt_alias() {
|
||||
let tmp = tempdir().expect("tempdir");
|
||||
let plugin_root = tmp.path().join("demo-plugin");
|
||||
write_manifest(
|
||||
&plugin_root,
|
||||
/*version*/ None,
|
||||
r#"{
|
||||
"displayName": "Demo Plugin",
|
||||
"defaultPromptAlias": " Demo Alias "
|
||||
}"#,
|
||||
);
|
||||
|
||||
let manifest = load_manifest(&plugin_root);
|
||||
let interface = manifest.interface.expect("plugin interface");
|
||||
|
||||
assert_eq!(
|
||||
interface.default_prompt_alias,
|
||||
Some("Demo Alias".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plugin_manifest_reads_trimmed_version() {
|
||||
let tmp = tempdir().expect("tempdir");
|
||||
|
||||
@@ -409,6 +409,7 @@ fn list_marketplaces_supports_alternate_manifest_layout() {
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
logo: None,
|
||||
@@ -1232,6 +1233,7 @@ fn list_marketplaces_resolves_plugin_interface_paths_to_absolute() {
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: Some(
|
||||
AbsolutePathBuf::try_from(plugin_root.join("assets/icon.png")).unwrap(),
|
||||
@@ -1348,6 +1350,7 @@ fn list_marketplaces_ignores_plugin_interface_assets_without_dot_slash() {
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
logo: None,
|
||||
|
||||
@@ -1015,6 +1015,7 @@ fn remote_plugin_interface_to_info(plugin: &RemotePluginDirectoryItem) -> Option
|
||||
privacy_policy_url: interface.privacy_policy_url.clone(),
|
||||
terms_of_service_url: interface.terms_of_service_url.clone(),
|
||||
default_prompt,
|
||||
default_prompt_alias: None,
|
||||
brand_color: interface.brand_color.clone(),
|
||||
composer_icon: None,
|
||||
composer_icon_url: interface.composer_icon_url.clone(),
|
||||
@@ -1033,6 +1034,7 @@ fn remote_plugin_interface_to_info(plugin: &RemotePluginDirectoryItem) -> Option
|
||||
|| result.privacy_policy_url.is_some()
|
||||
|| result.terms_of_service_url.is_some()
|
||||
|| result.default_prompt.is_some()
|
||||
|| result.default_prompt_alias.is_some()
|
||||
|| result.brand_color.is_some()
|
||||
|| result.composer_icon_url.is_some()
|
||||
|| result.logo_url.is_some()
|
||||
|
||||
@@ -152,6 +152,7 @@ fn expected_plugin_interface() -> PluginInterface {
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
composer_icon_url: None,
|
||||
|
||||
@@ -1293,6 +1293,7 @@ pub(super) fn plugins_test_interface(
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
default_prompt_alias: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
composer_icon_url: None,
|
||||
|
||||
Reference in New Issue
Block a user