Fix admin skills. (#8305)

We were assembling the skill roots in two different places, and the
admin root was missing in one of them. This change centralizes root
selection into a helper so both paths stay in sync.
This commit is contained in:
xl-openai 2025-12-18 20:10:19 -08:00 committed by GitHub
parent f4371d2f6c
commit 339b052d68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 13 deletions

View file

@ -148,17 +148,17 @@ pub(crate) fn repo_skills_root(cwd: &Path) -> Option<SkillRoot> {
})
}
fn skill_roots(config: &Config) -> Vec<SkillRoot> {
pub(crate) fn skill_roots_for_cwd(codex_home: &Path, cwd: &Path) -> Vec<SkillRoot> {
let mut roots = Vec::new();
if let Some(repo_root) = repo_skills_root(&config.cwd) {
if let Some(repo_root) = repo_skills_root(cwd) {
roots.push(repo_root);
}
// Load order matters: we dedupe by name, keeping the first occurrence.
// Priority order: repo, user, system, then admin.
roots.push(user_skills_root(&config.codex_home));
roots.push(system_skills_root(&config.codex_home));
roots.push(user_skills_root(codex_home));
roots.push(system_skills_root(codex_home));
if cfg!(unix) {
roots.push(admin_skills_root());
}
@ -166,6 +166,10 @@ fn skill_roots(config: &Config) -> Vec<SkillRoot> {
roots
}
fn skill_roots(config: &Config) -> Vec<SkillRoot> {
skill_roots_for_cwd(&config.codex_home, &config.cwd)
}
fn discover_skills_under_root(root: &Path, scope: SkillScope, outcome: &mut SkillLoadOutcome) {
let Ok(root) = normalize_path(root) else {
return;

View file

@ -5,9 +5,7 @@ use std::sync::RwLock;
use crate::skills::SkillLoadOutcome;
use crate::skills::loader::load_skills_from_roots;
use crate::skills::loader::repo_skills_root;
use crate::skills::loader::system_skills_root;
use crate::skills::loader::user_skills_root;
use crate::skills::loader::skill_roots_for_cwd;
use crate::skills::system::install_system_skills;
pub struct SkillsManager {
codex_home: PathBuf,
@ -39,12 +37,7 @@ impl SkillsManager {
return outcome;
}
let mut roots = Vec::new();
if let Some(repo_root) = repo_skills_root(cwd) {
roots.push(repo_root);
}
roots.push(user_skills_root(&self.codex_home));
roots.push(system_skills_root(&self.codex_home));
let roots = skill_roots_for_cwd(&self.codex_home, cwd);
let outcome = load_skills_from_roots(roots);
match self.cache_by_cwd.write() {
Ok(mut cache) => {