mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Load host skill roots through the skills extension (#37162)
## What changed - Load ordinary recursive host skill roots with the skills extension's host loader. - Keep plugin-specific roots on the existing loader so plugin snapshot caching and namespacing continue to work. - Merge both kinds of root snapshots through the existing precedence and deduplication logic, including discovery paths and source filesystem mappings. - Move `HostSkillsSnapshot` into the skills extension as the owner of host skill loading. ## Testing - Cover merged host and plugin catalogs, precedence for symlinked roots, discovery paths, and end-to-end rendering and invocation of host, repository, and plugin skills. GitOrigin-RevId: c18080afb917c33c57bc17e36b40dd0f3c72d1d7
This commit is contained in:
1 parent
c38a60ded2
commit
bd36d69aae
21 files changed
+515
-162
No files matched your search
@@ -183,6 +183,104 @@ async fn skills_for_config_reuses_cache_for_same_effective_config() {
|
||||
assert_eq!(outcome2.skills, outcome1.skills);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn snapshot_for_config_merges_extension_host_and_legacy_plugin_roots() {
|
||||
let codex_home = tempfile::tempdir().expect("tempdir");
|
||||
let cwd = tempfile::tempdir().expect("tempdir");
|
||||
write_user_skill(&codex_home, "user", "user-skill", "from the host loader");
|
||||
let plugin_skill_path = write_plugin_skill(
|
||||
&codex_home,
|
||||
"test",
|
||||
"sample",
|
||||
"search",
|
||||
"search",
|
||||
"from the plugin loader",
|
||||
);
|
||||
let plugin_skill_root =
|
||||
plugin_skill_root_for_skill_path(&plugin_skill_path, "sample@test", "sample");
|
||||
let config_layer_stack = config_stack(&codex_home, "[skills.bundled]\nenabled = false\n");
|
||||
let input = HostSkillsLoadInput::new(
|
||||
cwd.path().abs(),
|
||||
vec![plugin_skill_root],
|
||||
config_layer_stack,
|
||||
/*bundled_skills_enabled*/ false,
|
||||
);
|
||||
let skills_service = HostSkillsService::new(
|
||||
codex_home.path().abs(),
|
||||
/*bundled_skills_enabled*/ false,
|
||||
);
|
||||
|
||||
let snapshot = skills_service
|
||||
.snapshot_for_config(&input, Some(Arc::clone(&LOCAL_FS)))
|
||||
.await;
|
||||
let skills = snapshot
|
||||
.outcome()
|
||||
.skills
|
||||
.iter()
|
||||
.map(|skill| (skill.name.as_str(), skill.plugin_id.as_deref()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
skills,
|
||||
vec![("sample:search", Some("sample@test")), ("user-skill", None)]
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
async fn snapshot_for_config_preserves_host_precedence_for_symlinked_plugin_root() {
|
||||
use std::os::unix::fs::symlink;
|
||||
|
||||
let codex_home = tempfile::tempdir().expect("tempdir");
|
||||
let cwd = tempfile::tempdir().expect("tempdir");
|
||||
let plugin_skill_path = write_plugin_skill(
|
||||
&codex_home,
|
||||
"test",
|
||||
"sample",
|
||||
"search",
|
||||
"search",
|
||||
"shared skill",
|
||||
);
|
||||
let plugin_skill_root =
|
||||
plugin_skill_root_for_skill_path(&plugin_skill_path, "sample@test", "sample");
|
||||
symlink(
|
||||
plugin_skill_root.path.as_path(),
|
||||
codex_home.path().join("skills"),
|
||||
)
|
||||
.expect("symlink user skills root to plugin skills root");
|
||||
let config_layer_stack = config_stack(&codex_home, "[skills.bundled]\nenabled = false\n");
|
||||
let skills_service = HostSkillsService::new(
|
||||
codex_home.path().abs(),
|
||||
/*bundled_skills_enabled*/ false,
|
||||
);
|
||||
|
||||
let outcome = skills_for_config_with_stack(
|
||||
&skills_service,
|
||||
&cwd,
|
||||
&config_layer_stack,
|
||||
&[plugin_skill_root],
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
outcome.skills,
|
||||
vec![codex_skills::SkillMetadata {
|
||||
name: "sample:search".to_string(),
|
||||
description: "shared skill".to_string(),
|
||||
short_description: None,
|
||||
interface: None,
|
||||
dependencies: None,
|
||||
policy: None,
|
||||
path_to_skills_md: dunce::canonicalize(plugin_skill_path)
|
||||
.expect("canonical plugin skill path")
|
||||
.abs(),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: None,
|
||||
remote_plugin_id: None,
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn skills_for_config_refreshes_cache_when_remote_plugin_id_changes() {
|
||||
let codex_home = tempfile::tempdir().expect("tempdir");
|
||||
|
||||
Reference in new issue
Block a user