mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Load managed cloud config for plugin add and list (#62837)
## Why `codex plugin add` and `codex plugin list` loaded configuration without the managed cloud configuration layer, so plugin discovery and installation could miss settings supplied by that layer. ## What changed Use the shared cloud-aware configuration builder for add and list, passing through CLI overrides. Keep `codex plugin remove` on the local configuration loader and use the loaded configuration's Codex home for all three commands. GitOrigin-RevId: 5ebe94de30e553c57ae6296a2ddb91792260a61f
This commit is contained in:
@@ -1274,26 +1274,17 @@ async fn dispatch_cli(
|
||||
prepend_config_flags(&mut config_overrides, root_config_overrides.clone());
|
||||
match subcommand {
|
||||
PluginSubcommand::Add(args) => {
|
||||
let overrides = config_overrides
|
||||
.parse_overrides()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
plugin_cmd::run_plugin_add(overrides, args).await?;
|
||||
plugin_cmd::run_plugin_add(&config_overrides, args).await?;
|
||||
}
|
||||
PluginSubcommand::List(args) => {
|
||||
let overrides = config_overrides
|
||||
.parse_overrides()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
plugin_cmd::run_plugin_list(overrides, args).await?;
|
||||
plugin_cmd::run_plugin_list(&config_overrides, args).await?;
|
||||
}
|
||||
PluginSubcommand::Marketplace(mut marketplace_cli) => {
|
||||
prepend_config_flags(&mut marketplace_cli.config_overrides, config_overrides);
|
||||
marketplace_cli.run().await?;
|
||||
}
|
||||
PluginSubcommand::Remove(args) => {
|
||||
let overrides = config_overrides
|
||||
.parse_overrides()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
plugin_cmd::run_plugin_remove(overrides, args).await?;
|
||||
plugin_cmd::run_plugin_remove(&config_overrides, args).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ use clap::Parser;
|
||||
use codex_app_server_protocol::PluginAuthPolicy;
|
||||
use codex_app_server_protocol::PluginInstallPolicy;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::find_codex_home;
|
||||
use codex_core::config::ConfigOverrides;
|
||||
use codex_core::config::LoaderOverrides;
|
||||
use codex_core::plugins_manager_for_config;
|
||||
use codex_core::plugins_manager_for_config_with_runtime;
|
||||
use codex_core_plugins::ConfiguredMarketplace;
|
||||
@@ -44,6 +45,7 @@ use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::cloud_config;
|
||||
use crate::marketplace_cmd::MarketplaceCli;
|
||||
|
||||
const OPENAI_BUNDLED_ALPHA_MARKETPLACE_NAME: &str = "openai-bundled-alpha";
|
||||
@@ -137,10 +139,7 @@ pub struct RemovePluginArgs {
|
||||
json: bool,
|
||||
}
|
||||
|
||||
pub async fn run_plugin_add(
|
||||
overrides: Vec<(String, toml::Value)>,
|
||||
args: AddPluginArgs,
|
||||
) -> Result<()> {
|
||||
pub async fn run_plugin_add(overrides: &CliConfigOverrides, args: AddPluginArgs) -> Result<()> {
|
||||
let AddPluginArgs {
|
||||
plugin,
|
||||
marketplace_name,
|
||||
@@ -244,10 +243,7 @@ impl JsonPluginAddOutput {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run_plugin_list(
|
||||
overrides: Vec<(String, toml::Value)>,
|
||||
args: ListPluginsArgs,
|
||||
) -> Result<()> {
|
||||
pub async fn run_plugin_list(overrides: &CliConfigOverrides, args: ListPluginsArgs) -> Result<()> {
|
||||
let context = load_plugin_command_context(overrides, args.marketplace_name.as_deref()).await?;
|
||||
let remote_listing = fetch_remote_marketplaces(
|
||||
&context,
|
||||
@@ -680,7 +676,7 @@ fn auth_policy_label(policy: MarketplacePluginAuthPolicy) -> &'static str {
|
||||
}
|
||||
|
||||
pub async fn run_plugin_remove(
|
||||
overrides: Vec<(String, toml::Value)>,
|
||||
overrides: &CliConfigOverrides,
|
||||
args: RemovePluginArgs,
|
||||
) -> Result<()> {
|
||||
let RemovePluginArgs {
|
||||
@@ -689,7 +685,12 @@ pub async fn run_plugin_remove(
|
||||
json,
|
||||
} = args;
|
||||
let selection = parse_plugin_selection(plugin, marketplace_name)?;
|
||||
let context = load_plugin_command_context(overrides, Some(&selection.marketplace_name)).await?;
|
||||
let overrides = overrides.parse_overrides().map_err(anyhow::Error::msg)?;
|
||||
let config = Config::load_with_cli_overrides(overrides)
|
||||
.await
|
||||
.context("failed to load configuration")?;
|
||||
let context =
|
||||
plugin_command_context_from_config(config, Some(&selection.marketplace_name)).await?;
|
||||
|
||||
if selection.marketplace_name == REMOTE_GLOBAL_MARKETPLACE_NAME {
|
||||
ensure!(
|
||||
@@ -766,13 +767,25 @@ struct PluginCommandContext {
|
||||
}
|
||||
|
||||
async fn load_plugin_command_context(
|
||||
overrides: Vec<(String, toml::Value)>,
|
||||
overrides: &CliConfigOverrides,
|
||||
marketplace_name: Option<&str>,
|
||||
) -> Result<PluginCommandContext> {
|
||||
let config = cloud_config::config_builder(
|
||||
overrides,
|
||||
LoaderOverrides::default(),
|
||||
ConfigOverrides::default(),
|
||||
)
|
||||
.await?
|
||||
.build()
|
||||
.await
|
||||
.context("failed to load configuration")?;
|
||||
plugin_command_context_from_config(config, marketplace_name).await
|
||||
}
|
||||
|
||||
async fn plugin_command_context_from_config(
|
||||
config: Config,
|
||||
marketplace_name: Option<&str>,
|
||||
) -> Result<PluginCommandContext> {
|
||||
let codex_home = find_codex_home().context("failed to resolve CODEX_HOME")?;
|
||||
let config = Config::load_with_cli_overrides(overrides)
|
||||
.await
|
||||
.context("failed to load configuration")?;
|
||||
let plugins_input = config.plugins_config_input();
|
||||
let auth_manager = load_cli_auth_manager(&config).await?;
|
||||
let auth = auth_manager.auth().await;
|
||||
@@ -785,7 +798,7 @@ async fn load_plugin_command_context(
|
||||
plugins_manager_for_config(&config, Arc::clone(&auth_manager))
|
||||
});
|
||||
Ok(PluginCommandContext {
|
||||
codex_home: codex_home.to_path_buf(),
|
||||
codex_home: config.codex_home.to_path_buf(),
|
||||
plugins_input,
|
||||
manager,
|
||||
auth,
|
||||
|
||||
Reference in New Issue
Block a user