@@ -6,7 +6,8 @@ use clap::Parser;
66use codex_app_server_protocol:: PluginAuthPolicy ;
77use codex_app_server_protocol:: PluginInstallPolicy ;
88use codex_core:: config:: Config ;
9- use codex_core:: config:: find_codex_home;
9+ use codex_core:: config:: ConfigOverrides ;
10+ use codex_core:: config:: LoaderOverrides ;
1011use codex_core:: plugins_manager_for_config;
1112use codex_core:: plugins_manager_for_config_with_runtime;
1213use codex_core_plugins:: ConfiguredMarketplace ;
@@ -44,6 +45,7 @@ use std::path::Path;
4445use std:: path:: PathBuf ;
4546use std:: sync:: Arc ;
4647
48+ use crate :: cloud_config;
4749use crate :: marketplace_cmd:: MarketplaceCli ;
4850
4951const OPENAI_BUNDLED_ALPHA_MARKETPLACE_NAME : & str = "openai-bundled-alpha" ;
@@ -137,10 +139,7 @@ pub struct RemovePluginArgs {
137139 json : bool ,
138140}
139141
140- pub async fn run_plugin_add (
141- overrides : Vec < ( String , toml:: Value ) > ,
142- args : AddPluginArgs ,
143- ) -> Result < ( ) > {
142+ pub async fn run_plugin_add ( overrides : & CliConfigOverrides , args : AddPluginArgs ) -> Result < ( ) > {
144143 let AddPluginArgs {
145144 plugin,
146145 marketplace_name,
@@ -244,10 +243,7 @@ impl JsonPluginAddOutput {
244243 }
245244}
246245
247- pub async fn run_plugin_list (
248- overrides : Vec < ( String , toml:: Value ) > ,
249- args : ListPluginsArgs ,
250- ) -> Result < ( ) > {
246+ pub async fn run_plugin_list ( overrides : & CliConfigOverrides , args : ListPluginsArgs ) -> Result < ( ) > {
251247 let context = load_plugin_command_context ( overrides, args. marketplace_name . as_deref ( ) ) . await ?;
252248 let remote_listing = fetch_remote_marketplaces (
253249 & context,
@@ -680,7 +676,7 @@ fn auth_policy_label(policy: MarketplacePluginAuthPolicy) -> &'static str {
680676}
681677
682678pub async fn run_plugin_remove (
683- overrides : Vec < ( String , toml :: Value ) > ,
679+ overrides : & CliConfigOverrides ,
684680 args : RemovePluginArgs ,
685681) -> Result < ( ) > {
686682 let RemovePluginArgs {
@@ -689,7 +685,12 @@ pub async fn run_plugin_remove(
689685 json,
690686 } = args;
691687 let selection = parse_plugin_selection ( plugin, marketplace_name) ?;
692- let context = load_plugin_command_context ( overrides, Some ( & selection. marketplace_name ) ) . await ?;
688+ let overrides = overrides. parse_overrides ( ) . map_err ( anyhow:: Error :: msg) ?;
689+ let config = Config :: load_with_cli_overrides ( overrides)
690+ . await
691+ . context ( "failed to load configuration" ) ?;
692+ let context =
693+ plugin_command_context_from_config ( config, Some ( & selection. marketplace_name ) ) . await ?;
693694
694695 if selection. marketplace_name == REMOTE_GLOBAL_MARKETPLACE_NAME {
695696 ensure ! (
@@ -766,13 +767,25 @@ struct PluginCommandContext {
766767}
767768
768769async fn load_plugin_command_context (
769- overrides : Vec < ( String , toml:: Value ) > ,
770+ overrides : & CliConfigOverrides ,
771+ marketplace_name : Option < & str > ,
772+ ) -> Result < PluginCommandContext > {
773+ let config = cloud_config:: config_builder (
774+ overrides,
775+ LoaderOverrides :: default ( ) ,
776+ ConfigOverrides :: default ( ) ,
777+ )
778+ . await ?
779+ . build ( )
780+ . await
781+ . context ( "failed to load configuration" ) ?;
782+ plugin_command_context_from_config ( config, marketplace_name) . await
783+ }
784+
785+ async fn plugin_command_context_from_config (
786+ config : Config ,
770787 marketplace_name : Option < & str > ,
771788) -> Result < PluginCommandContext > {
772- let codex_home = find_codex_home ( ) . context ( "failed to resolve CODEX_HOME" ) ?;
773- let config = Config :: load_with_cli_overrides ( overrides)
774- . await
775- . context ( "failed to load configuration" ) ?;
776789 let plugins_input = config. plugins_config_input ( ) ;
777790 let auth_manager = load_cli_auth_manager ( & config) . await ?;
778791 let auth = auth_manager. auth ( ) . await ;
@@ -785,7 +798,7 @@ async fn load_plugin_command_context(
785798 plugins_manager_for_config ( & config, Arc :: clone ( & auth_manager) )
786799 } ) ;
787800 Ok ( PluginCommandContext {
788- codex_home : codex_home. to_path_buf ( ) ,
801+ codex_home : config . codex_home . to_path_buf ( ) ,
789802 plugins_input,
790803 manager,
791804 auth,
0 commit comments