Unify plugin skill loading with the host skill service (#37444)

## What changed

- Inject the host skill loader into `PluginsManager` so plugin discovery and agent turns use the same loading and product-policy behavior.
- Share plugin skill snapshots across those paths, preserving a consistent view of skills across workspaces.
- Apply migrated-command precedence after product filtering, allowing an eligible migrated command to replace a filtered native skill with the same name.

## Testing

- Add coverage for product-restricted plugin skills, native-versus-migrated command precedence, and the skills exposed to agent turns.

GitOrigin-RevId: f5ef0d0766ebeeb30d73ffaf044d003c2906ea4d
This commit is contained in:
felixxia-oai
2026-08-07 13:54:24 +00:00
committed by copyberry
parent e75a1888d7
commit e58d9ef447
30 changed files with 682 additions and 272 deletions
@@ -1,7 +1,7 @@
use crate::plugins::plugins_manager_for_config;
use crate::plugins::test_support::load_plugins_config;
use crate::plugins::test_support::write_file;
use crate::plugins::test_support::write_openai_curated_marketplace;
use codex_core_plugins::PluginsManager;
use codex_core_plugins::startup_sync::curated_plugins_repo_path;
use codex_tools::DiscoverablePluginInfo;
use pretty_assertions::assert_eq;
@@ -11,7 +11,7 @@ async fn list_discoverable_plugins(
config: &crate::config::Config,
loaded_plugin_app_connector_ids: &[String],
) -> anyhow::Result<Vec<DiscoverablePluginInfo>> {
let plugins_manager = PluginsManager::new(config.codex_home.to_path_buf());
let plugins_manager = plugins_manager_for_config(config);
super::list_tool_suggest_discoverable_plugins(
config,
&plugins_manager,
+16
View File
@@ -8,6 +8,11 @@ mod skill_snapshot_tests;
#[cfg(test)]
pub(crate) mod test_support;
use crate::config::Config;
use codex_core_plugins::PluginsManager;
use codex_skills_extension::HostSkillsService;
use std::sync::Arc;
pub(crate) use codex_plugin::PluginCapabilitySummary;
pub(crate) use discoverable::list_tool_suggest_discoverable_plugins;
@@ -19,3 +24,14 @@ pub(crate) use mentions::build_skill_name_counts;
pub(crate) use mentions::collect_explicit_app_ids;
pub(crate) use mentions::collect_explicit_plugin_mentions;
pub(crate) use mentions::collect_tool_mentions_from_messages;
/// Constructs a standalone plugin manager with extension-owned plugin skill loading.
///
/// Callers that already own a host skills service should inject that existing service instead.
pub fn plugins_manager_for_config(config: &Config) -> PluginsManager {
let skill_root_loader = Arc::new(HostSkillsService::new(
config.codex_home.clone(),
/*bundled_skills_enabled*/ false,
));
PluginsManager::new(config.codex_home.to_path_buf(), skill_root_loader)
}
@@ -5,7 +5,9 @@ use codex_protocol::auth::AuthMode;
use codex_protocol::protocol::Product;
use codex_skills_extension::HostSkillsLoadInput;
use codex_skills_extension::HostSkillsService;
use codex_utils_absolute_path::AbsolutePathBuf;
use pretty_assertions::assert_eq;
use std::sync::Arc;
use super::test_support::load_plugins_config;
use super::test_support::write_file;
@@ -43,44 +45,53 @@ enabled = true
.expect("persist remote plugin id");
let config = load_plugins_config(codex_home.path()).await;
let plugins_input = config.plugins_config_input();
let skills_service = Arc::new(HostSkillsService::new(
config.codex_home.clone(),
/*bundled_skills_enabled*/ false,
));
let plugins_manager = PluginsManager::new_with_options(
codex_home.path().to_path_buf(),
Some(Product::Codex),
Some(AuthMode::Chatgpt),
skills_service.clone(),
);
let plugin_outcome = plugins_manager.plugins_for_config(&plugins_input).await;
write_file(&skill_path, "---\nname: search\ndescription: second\n---\n");
let skills_input = HostSkillsLoadInput::new(
config.cwd.clone(),
plugin_outcome.effective_plugin_skill_roots(),
config.config_layer_stack.clone(),
/*bundled_skills_enabled*/ false,
)
.with_plugin_skill_snapshots(plugins_manager.plugin_skill_snapshots_for_config(&plugins_input));
let skills_service = HostSkillsService::new(
config.codex_home.clone(),
/*bundled_skills_enabled*/ false,
);
let snapshot = skills_service
.snapshot_for_config(&skills_input, /*fs*/ None)
.await;
let other_cwd = codex_home.path().join("other-workspace");
std::fs::create_dir_all(&other_cwd).expect("create second workspace");
let other_cwd = AbsolutePathBuf::from_absolute_path(other_cwd).expect("absolute workspace");
assert_eq!(
snapshot
.outcome()
.skills
.iter()
.filter(|skill| skill.plugin_id.as_deref() == Some(PLUGIN_CONFIG_NAME))
.map(|skill| {
(
skill.description.as_str(),
skill.plugin_id.as_deref(),
skill.remote_plugin_id.as_deref(),
)
})
.collect::<Vec<_>>(),
vec![("first", Some(PLUGIN_CONFIG_NAME), Some(REMOTE_PLUGIN_ID),)]
);
for cwd in [config.cwd.clone(), other_cwd] {
let skills_input = HostSkillsLoadInput::new(
cwd,
plugin_outcome.effective_plugin_skill_roots(),
config.config_layer_stack.clone(),
/*bundled_skills_enabled*/ false,
)
.with_plugin_skill_snapshots(
plugins_manager.plugin_skill_snapshots_for_config(&plugins_input),
);
let snapshot = skills_service
.snapshot_for_config(&skills_input, /*fs*/ None)
.await;
assert_eq!(
snapshot
.outcome()
.skills
.iter()
.filter(|skill| skill.plugin_id.as_deref() == Some(PLUGIN_CONFIG_NAME))
.map(|skill| {
(
skill.description.as_str(),
skill.plugin_id.as_deref(),
skill.remote_plugin_id.as_deref(),
)
})
.collect::<Vec<_>>(),
vec![("first", Some(PLUGIN_CONFIG_NAME), Some(REMOTE_PLUGIN_ID),)]
);
}
}