Shorten env path naming in skills loading

This commit is contained in:
starr-openai
2026-05-28 16:22:40 -07:00
parent 1c0fda9d63
commit dfa0274dd8
7 changed files with 30 additions and 32 deletions

View File

@@ -232,7 +232,7 @@ where
}
pub(crate) async fn skill_roots(
repo_env_path_ref: Option<&EnvironmentPathRef>,
env_path_ref: Option<&EnvironmentPathRef>,
skill_root_path_ref: Option<&EnvironmentPathRef>,
config_layer_stack: &ConfigLayerStack,
plugin_skill_roots: Vec<PluginSkillRoot>,
@@ -240,7 +240,7 @@ pub(crate) async fn skill_roots(
let home_dir =
home_dir().and_then(|path| AbsolutePathBuf::from_absolute_path_checked(path).ok());
skill_roots_with_home_dir(
repo_env_path_ref,
env_path_ref,
skill_root_path_ref,
config_layer_stack,
home_dir.as_ref(),
@@ -250,7 +250,7 @@ pub(crate) async fn skill_roots(
}
async fn skill_roots_with_home_dir(
repo_env_path_ref: Option<&EnvironmentPathRef>,
env_path_ref: Option<&EnvironmentPathRef>,
skill_root_path_ref: Option<&EnvironmentPathRef>,
config_layer_stack: &ConfigLayerStack,
home_dir: Option<&AbsolutePathBuf>,
@@ -259,7 +259,7 @@ async fn skill_roots_with_home_dir(
let mut roots = skill_roots_from_layer_stack_inner(
config_layer_stack,
home_dir,
repo_env_path_ref,
env_path_ref,
skill_root_path_ref,
);
if let Some(skill_root_path_ref) = skill_root_path_ref {
@@ -270,7 +270,7 @@ async fn skill_roots_with_home_dir(
plugin_root: Some(skill_root_path_ref.with_path(root.plugin_root)),
}));
}
roots.extend(repo_agents_skill_roots(repo_env_path_ref, config_layer_stack).await);
roots.extend(repo_agents_skill_roots(env_path_ref, config_layer_stack).await);
dedupe_skill_roots_by_path(&mut roots);
roots
}
@@ -278,7 +278,7 @@ async fn skill_roots_with_home_dir(
fn skill_roots_from_layer_stack_inner(
config_layer_stack: &ConfigLayerStack,
home_dir: Option<&AbsolutePathBuf>,
repo_env_path_ref: Option<&EnvironmentPathRef>,
env_path_ref: Option<&EnvironmentPathRef>,
skill_root_path_ref: Option<&EnvironmentPathRef>,
) -> Vec<SkillRoot> {
let mut roots = Vec::new();
@@ -293,10 +293,10 @@ fn skill_roots_from_layer_stack_inner(
match &layer.name {
ConfigLayerSource::Project { .. } => {
if let Some(repo_env_path_ref) = repo_env_path_ref {
if let Some(env_path_ref) = env_path_ref {
roots.push(SkillRoot {
path: SkillRootPathRef::new(
repo_env_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)),
env_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)),
),
scope: SkillScope::Repo,
plugin_id: None,
@@ -369,20 +369,18 @@ fn skill_roots_from_layer_stack_inner(
}
async fn repo_agents_skill_roots(
repo_env_path_ref: Option<&EnvironmentPathRef>,
env_path_ref: Option<&EnvironmentPathRef>,
config_layer_stack: &ConfigLayerStack,
) -> Vec<SkillRoot> {
let Some(repo_env_path_ref) = repo_env_path_ref else {
let Some(env_path_ref) = env_path_ref else {
return Vec::new();
};
let project_root_markers = project_root_markers_from_stack(config_layer_stack);
let project_root = find_project_root(repo_env_path_ref, &project_root_markers).await;
let dirs =
dirs_between_project_root_and_cwd(repo_env_path_ref.path(), project_root.path());
let project_root = find_project_root(env_path_ref, &project_root_markers).await;
let dirs = dirs_between_project_root_and_cwd(env_path_ref.path(), project_root.path());
let mut roots = Vec::new();
for dir in dirs {
let agents_skills =
repo_env_path_ref.with_path(dir.join(AGENTS_DIR_NAME).join(SKILLS_DIR_NAME));
let agents_skills = env_path_ref.with_path(dir.join(AGENTS_DIR_NAME).join(SKILLS_DIR_NAME));
match agents_skills.metadata().await {
Ok(metadata) if metadata.is_directory => roots.push(SkillRoot {
path: SkillRootPathRef::new(agents_skills),

View File

@@ -1915,9 +1915,9 @@ async fn skill_roots_skip_local_roots_without_skill_root_path_ref() {
let codex_home = tempfile::tempdir().expect("tempdir");
let cfg = make_config(&codex_home).await;
let repo_env_path_ref = skill_root_path_ref(cfg.cwd.clone());
let env_path_ref = skill_root_path_ref(cfg.cwd.clone());
let scopes: Vec<SkillScope> = super::skill_roots(
Some(&repo_env_path_ref),
Some(&env_path_ref),
/*skill_root_path_ref*/ None,
&cfg.config_layer_stack,
Vec::new(),

View File

@@ -26,7 +26,7 @@ use codex_exec_server::EnvironmentPathRef;
#[derive(Debug, Clone)]
pub struct SkillsLoadInput {
pub repo_env_path_ref: Option<EnvironmentPathRef>,
pub env_path_ref: Option<EnvironmentPathRef>,
pub skill_root_path_ref: Option<EnvironmentPathRef>,
pub effective_skill_roots: Vec<PluginSkillRoot>,
pub config_layer_stack: ConfigLayerStack,
@@ -35,14 +35,14 @@ pub struct SkillsLoadInput {
impl SkillsLoadInput {
pub fn new(
repo_env_path_ref: Option<EnvironmentPathRef>,
env_path_ref: Option<EnvironmentPathRef>,
skill_root_path_ref: Option<EnvironmentPathRef>,
effective_skill_roots: Vec<PluginSkillRoot>,
config_layer_stack: ConfigLayerStack,
bundled_skills_enabled: bool,
) -> Self {
Self {
repo_env_path_ref,
env_path_ref,
skill_root_path_ref,
effective_skill_roots,
config_layer_stack,
@@ -109,7 +109,7 @@ impl SkillsManager {
pub async fn skill_roots_for_config(&self, input: &SkillsLoadInput) -> Vec<SkillRoot> {
let mut roots = skill_roots(
input.repo_env_path_ref.as_ref(),
input.env_path_ref.as_ref(),
input.skill_root_path_ref.as_ref(),
&input.config_layer_stack,
input.effective_skill_roots.clone(),
@@ -126,7 +126,7 @@ impl SkillsManager {
input: &SkillsLoadInput,
force_reload: bool,
) -> SkillLoadOutcome {
let cwd_cache_key = input.repo_env_path_ref.clone();
let cwd_cache_key = input.env_path_ref.clone();
if !force_reload
&& let Some(cwd_cache_key) = cwd_cache_key.as_ref()
&& let Some(outcome) = self.cached_outcome_for_cwd(cwd_cache_key)
@@ -135,7 +135,7 @@ impl SkillsManager {
}
let mut roots = skill_roots(
input.repo_env_path_ref.as_ref(),
input.env_path_ref.as_ref(),
input.skill_root_path_ref.as_ref(),
&input.config_layer_stack,
input.effective_skill_roots.clone(),

View File

@@ -376,7 +376,7 @@ async fn skills_for_cwd_without_fs_skips_repo_roots() {
.expect("valid config layer stack");
let skill_root_path_ref = skill_root_path_ref(cwd.path().abs());
let skills_input = SkillsLoadInput::new(
/*repo_env_path_ref*/ None,
/*env_path_ref*/ None,
Some(skill_root_path_ref),
Vec::new(),
config_layer_stack.clone(),

View File

@@ -453,7 +453,7 @@ async fn warm_plugins_and_skills_for_session_init(
&environments,
)
.ok();
let repo_env_path_ref = resolved_environments
let env_path_ref = resolved_environments
.as_ref()
.and_then(crate::environment_selection::ResolvedTurnEnvironments::primary)
.map(|environment| {
@@ -463,7 +463,7 @@ async fn warm_plugins_and_skills_for_session_init(
environment.cwd.clone(),
)
});
let skill_root_path_ref = repo_env_path_ref.clone();
let skill_root_path_ref = env_path_ref.clone();
let plugins_input = config
.plugins_config_input()
.with_skill_path_ref(skill_root_path_ref.clone());
@@ -471,7 +471,7 @@ async fn warm_plugins_and_skills_for_session_init(
let effective_skill_roots = plugin_outcome.effective_plugin_skill_roots();
let skills_input = skills_load_input_from_config(
config.as_ref(),
repo_env_path_ref,
env_path_ref,
skill_root_path_ref,
effective_skill_roots,
);

View File

@@ -677,14 +677,14 @@ impl Session {
&per_turn_config.to_models_manager_config(),
)
.await;
let repo_env_path_ref = primary_turn_environment.map(|turn_environment| {
let env_path_ref = primary_turn_environment.map(|turn_environment| {
environment_path_ref(
turn_environment.environment_id.clone(),
turn_environment.environment.get_filesystem(),
turn_environment.cwd.clone(),
)
});
let skill_root_path_ref = repo_env_path_ref.clone();
let skill_root_path_ref = env_path_ref.clone();
let plugins_input = per_turn_config
.plugins_config_input()
.with_skill_path_ref(skill_root_path_ref.clone());
@@ -696,7 +696,7 @@ impl Session {
let effective_skill_roots = plugin_outcome.effective_plugin_skill_roots();
let skills_input = skills_load_input_from_config(
&per_turn_config,
repo_env_path_ref,
env_path_ref,
skill_root_path_ref,
effective_skill_roots,
);

View File

@@ -38,12 +38,12 @@ pub use codex_core_skills::system;
pub(crate) fn skills_load_input_from_config(
config: &Config,
repo_env_path_ref: Option<EnvironmentPathRef>,
env_path_ref: Option<EnvironmentPathRef>,
skill_root_path_ref: Option<EnvironmentPathRef>,
effective_skill_roots: Vec<PluginSkillRoot>,
) -> SkillsLoadInput {
SkillsLoadInput::new(
repo_env_path_ref,
env_path_ref,
skill_root_path_ref,
effective_skill_roots,
config.config_layer_stack.clone(),