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

View File

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