From 6e38818088bf93fd6d694191ff920018c08bb989 Mon Sep 17 00:00:00 2001 From: starr-openai Date: Thu, 28 May 2026 16:29:15 -0700 Subject: [PATCH] Rename skill path refs to cwd and root paths --- codex-rs/app-server/src/skills_watcher.rs | 8 ++-- codex-rs/core-skills/src/loader.rs | 54 +++++++++++------------ codex-rs/core-skills/src/loader_tests.rs | 2 +- codex-rs/core-skills/src/manager.rs | 22 ++++----- codex-rs/core-skills/src/manager_tests.rs | 6 +-- codex-rs/core/src/session/session.rs | 10 ++--- codex-rs/core/src/session/turn_context.rs | 10 ++--- codex-rs/core/src/skills.rs | 8 ++-- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/codex-rs/app-server/src/skills_watcher.rs b/codex-rs/app-server/src/skills_watcher.rs index 7bf5bead31..b879b75227 100644 --- a/codex-rs/app-server/src/skills_watcher.rs +++ b/codex-rs/app-server/src/skills_watcher.rs @@ -81,19 +81,19 @@ impl SkillsWatcher { return WatchRegistration::default(); } - let skill_root_path_ref = EnvironmentPathRef::new( + let root_path_ref = EnvironmentPathRef::new( environment_selection.environment_id.clone(), environment.get_filesystem(), config.cwd.clone(), ); let plugins_input = config .plugins_config_input() - .with_skill_path_ref(Some(skill_root_path_ref.clone())); + .with_skill_path_ref(Some(root_path_ref.clone())); let plugins_manager = thread_manager.plugins_manager(); let plugin_outcome = plugins_manager.plugins_for_config(&plugins_input).await; let skills_input = SkillsLoadInput::new( - Some(skill_root_path_ref.clone()), - Some(skill_root_path_ref), + Some(root_path_ref.clone()), + Some(root_path_ref), plugin_outcome.effective_plugin_skill_roots(), config.config_layer_stack.clone(), config.bundled_skills_enabled(), diff --git a/codex-rs/core-skills/src/loader.rs b/codex-rs/core-skills/src/loader.rs index 74301692b9..19f19290ad 100644 --- a/codex-rs/core-skills/src/loader.rs +++ b/codex-rs/core-skills/src/loader.rs @@ -230,16 +230,16 @@ where } pub(crate) async fn skill_roots( - env_path_ref: Option<&EnvironmentPathRef>, - skill_root_path_ref: Option<&EnvironmentPathRef>, + cwd: Option<&EnvironmentPathRef>, + root_path_ref: Option<&EnvironmentPathRef>, config_layer_stack: &ConfigLayerStack, plugin_skill_roots: Vec, ) -> Vec { let home_dir = home_dir().and_then(|path| AbsolutePathBuf::from_absolute_path_checked(path).ok()); skill_roots_with_home_dir( - env_path_ref, - skill_root_path_ref, + cwd, + root_path_ref, config_layer_stack, home_dir.as_ref(), plugin_skill_roots, @@ -248,8 +248,8 @@ pub(crate) async fn skill_roots( } async fn skill_roots_with_home_dir( - env_path_ref: Option<&EnvironmentPathRef>, - skill_root_path_ref: Option<&EnvironmentPathRef>, + cwd: Option<&EnvironmentPathRef>, + root_path_ref: Option<&EnvironmentPathRef>, config_layer_stack: &ConfigLayerStack, home_dir: Option<&AbsolutePathBuf>, plugin_skill_roots: Vec, @@ -257,18 +257,18 @@ async fn skill_roots_with_home_dir( let mut roots = skill_roots_from_layer_stack_inner( config_layer_stack, home_dir, - env_path_ref, - skill_root_path_ref, + cwd, + root_path_ref, ); - if let Some(skill_root_path_ref) = skill_root_path_ref { + if let Some(root_path_ref) = root_path_ref { roots.extend(plugin_skill_roots.into_iter().map(|root| SkillRoot { - path: skill_root_path_ref.with_path(root.path), + path: root_path_ref.with_path(root.path), scope: SkillScope::User, plugin_id: Some(root.plugin_id), - plugin_root: Some(skill_root_path_ref.with_path(root.plugin_root)), + plugin_root: Some(root_path_ref.with_path(root.plugin_root)), })); } - roots.extend(repo_agents_skill_roots(env_path_ref, config_layer_stack).await); + roots.extend(repo_agents_skill_roots(cwd, config_layer_stack).await); dedupe_skill_roots_by_path(&mut roots); roots } @@ -276,8 +276,8 @@ async fn skill_roots_with_home_dir( fn skill_roots_from_layer_stack_inner( config_layer_stack: &ConfigLayerStack, home_dir: Option<&AbsolutePathBuf>, - env_path_ref: Option<&EnvironmentPathRef>, - skill_root_path_ref: Option<&EnvironmentPathRef>, + cwd: Option<&EnvironmentPathRef>, + root_path_ref: Option<&EnvironmentPathRef>, ) -> Vec { let mut roots = Vec::new(); @@ -291,9 +291,9 @@ fn skill_roots_from_layer_stack_inner( match &layer.name { ConfigLayerSource::Project { .. } => { - if let Some(env_path_ref) = env_path_ref { + if let Some(cwd) = cwd { roots.push(SkillRoot { - path: env_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)), + path: cwd.with_path(config_folder.join(SKILLS_DIR_NAME)), scope: SkillScope::Repo, plugin_id: None, plugin_root: None, @@ -301,13 +301,13 @@ fn skill_roots_from_layer_stack_inner( } } ConfigLayerSource::User { .. } => { - let Some(skill_root_path_ref) = skill_root_path_ref else { + let Some(root_path_ref) = root_path_ref else { continue; }; // Deprecated user skills location (`$CODEX_HOME/skills`), kept for backward // compatibility. roots.push(SkillRoot { - path: skill_root_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)), + path: root_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)), scope: SkillScope::User, plugin_id: None, plugin_root: None, @@ -316,7 +316,7 @@ fn skill_roots_from_layer_stack_inner( // `$HOME/.agents/skills` (user-installed skills). if let Some(home_dir) = home_dir { roots.push(SkillRoot { - path: skill_root_path_ref + path: root_path_ref .with_path(home_dir.join(AGENTS_DIR_NAME).join(SKILLS_DIR_NAME)), scope: SkillScope::User, plugin_id: None, @@ -327,20 +327,20 @@ fn skill_roots_from_layer_stack_inner( // Embedded system skills are cached under `$CODEX_HOME/skills/.system` and are a // special case (not a config layer). roots.push(SkillRoot { - path: skill_root_path_ref.with_path(system_cache_root_dir(&config_folder)), + path: root_path_ref.with_path(system_cache_root_dir(&config_folder)), scope: SkillScope::System, plugin_id: None, plugin_root: None, }); } ConfigLayerSource::System { .. } => { - let Some(skill_root_path_ref) = skill_root_path_ref else { + let Some(root_path_ref) = root_path_ref else { continue; }; // The system config layer lives under `/etc/codex/` on Unix, so treat // `/etc/codex/skills` as admin-scoped skills. roots.push(SkillRoot { - path: skill_root_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)), + path: root_path_ref.with_path(config_folder.join(SKILLS_DIR_NAME)), scope: SkillScope::Admin, plugin_id: None, plugin_root: None, @@ -357,18 +357,18 @@ fn skill_roots_from_layer_stack_inner( } async fn repo_agents_skill_roots( - env_path_ref: Option<&EnvironmentPathRef>, + cwd: Option<&EnvironmentPathRef>, config_layer_stack: &ConfigLayerStack, ) -> Vec { - let Some(env_path_ref) = env_path_ref else { + let Some(cwd) = cwd else { return Vec::new(); }; let project_root_markers = project_root_markers_from_stack(config_layer_stack); - 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 project_root = find_project_root(cwd, &project_root_markers).await; + let dirs = dirs_between_project_root_and_cwd(cwd.path(), project_root.path()); let mut roots = Vec::new(); for dir in dirs { - let agents_skills = env_path_ref.with_path(dir.join(AGENTS_DIR_NAME).join(SKILLS_DIR_NAME)); + let agents_skills = cwd.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: agents_skills, diff --git a/codex-rs/core-skills/src/loader_tests.rs b/codex-rs/core-skills/src/loader_tests.rs index 4f341a4b0c..1b58290004 100644 --- a/codex-rs/core-skills/src/loader_tests.rs +++ b/codex-rs/core-skills/src/loader_tests.rs @@ -1918,7 +1918,7 @@ async fn skill_roots_skip_local_roots_without_local_env_path_ref() { let local_env_path_ref = env_path_ref(cfg.cwd.clone()); let scopes: Vec = super::skill_roots( Some(&local_env_path_ref), - /*skill_root_path_ref*/ None, + /*root_path_ref*/ None, &cfg.config_layer_stack, Vec::new(), ) diff --git a/codex-rs/core-skills/src/manager.rs b/codex-rs/core-skills/src/manager.rs index c11d911a35..5adb62e694 100644 --- a/codex-rs/core-skills/src/manager.rs +++ b/codex-rs/core-skills/src/manager.rs @@ -26,8 +26,8 @@ use codex_exec_server::EnvironmentPathRef; #[derive(Debug, Clone)] pub struct SkillsLoadInput { - pub env_path_ref: Option, - pub skill_root_path_ref: Option, + pub cwd: Option, + pub root_path_ref: Option, pub effective_skill_roots: Vec, pub config_layer_stack: ConfigLayerStack, pub bundled_skills_enabled: bool, @@ -35,15 +35,15 @@ pub struct SkillsLoadInput { impl SkillsLoadInput { pub fn new( - env_path_ref: Option, - skill_root_path_ref: Option, + cwd: Option, + root_path_ref: Option, effective_skill_roots: Vec, config_layer_stack: ConfigLayerStack, bundled_skills_enabled: bool, ) -> Self { Self { - env_path_ref, - skill_root_path_ref, + cwd, + root_path_ref, effective_skill_roots, config_layer_stack, bundled_skills_enabled, @@ -109,8 +109,8 @@ impl SkillsManager { pub async fn skill_roots_for_config(&self, input: &SkillsLoadInput) -> Vec { let mut roots = skill_roots( - input.env_path_ref.as_ref(), - input.skill_root_path_ref.as_ref(), + input.cwd.as_ref(), + input.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.env_path_ref.clone(); + let cwd_cache_key = input.cwd.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,8 +135,8 @@ impl SkillsManager { } let mut roots = skill_roots( - input.env_path_ref.as_ref(), - input.skill_root_path_ref.as_ref(), + input.cwd.as_ref(), + input.root_path_ref.as_ref(), &input.config_layer_stack, input.effective_skill_roots.clone(), ) diff --git a/codex-rs/core-skills/src/manager_tests.rs b/codex-rs/core-skills/src/manager_tests.rs index ae6057e579..6648e3031d 100644 --- a/codex-rs/core-skills/src/manager_tests.rs +++ b/codex-rs/core-skills/src/manager_tests.rs @@ -374,10 +374,10 @@ async fn skills_for_cwd_without_fs_skips_repo_roots() { ConfigRequirementsToml::default(), ) .expect("valid config layer stack"); - let skill_root_path_ref = skill_root_path_ref(cwd.path().abs()); + let root_path_ref = skill_root_path_ref(cwd.path().abs()); let skills_input = SkillsLoadInput::new( - /*env_path_ref*/ None, - Some(skill_root_path_ref), + /*cwd*/ None, + Some(root_path_ref), Vec::new(), config_layer_stack.clone(), bundled_skills_enabled_from_stack(&config_layer_stack), diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs index 2084aa5c82..98af399462 100644 --- a/codex-rs/core/src/session/session.rs +++ b/codex-rs/core/src/session/session.rs @@ -453,7 +453,7 @@ async fn warm_plugins_and_skills_for_session_init( &environments, ) .ok(); - let env_path_ref = resolved_environments + let cwd = resolved_environments .as_ref() .and_then(crate::environment_selection::ResolvedTurnEnvironments::primary) .map(|environment| { @@ -463,16 +463,16 @@ async fn warm_plugins_and_skills_for_session_init( environment.cwd.clone(), ) }); - let skill_root_path_ref = env_path_ref.clone(); + let root_path_ref = cwd.clone(); let plugins_input = config .plugins_config_input() - .with_skill_path_ref(skill_root_path_ref.clone()); + .with_skill_path_ref(root_path_ref.clone()); let plugin_outcome = plugins_manager.plugins_for_config(&plugins_input).await; let effective_skill_roots = plugin_outcome.effective_plugin_skill_roots(); let skills_input = skills_load_input_from_config( config.as_ref(), - env_path_ref, - skill_root_path_ref, + cwd, + root_path_ref, effective_skill_roots, ); skills_manager.skills_for_config(&skills_input).await.errors diff --git a/codex-rs/core/src/session/turn_context.rs b/codex-rs/core/src/session/turn_context.rs index 07269633fb..f25f8f639a 100644 --- a/codex-rs/core/src/session/turn_context.rs +++ b/codex-rs/core/src/session/turn_context.rs @@ -677,17 +677,17 @@ impl Session { &per_turn_config.to_models_manager_config(), ) .await; - let env_path_ref = primary_turn_environment.map(|turn_environment| { + let cwd = 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 = env_path_ref.clone(); + let root_path_ref = cwd.clone(); let plugins_input = per_turn_config .plugins_config_input() - .with_skill_path_ref(skill_root_path_ref.clone()); + .with_skill_path_ref(root_path_ref.clone()); let plugin_outcome = self .services .plugins_manager @@ -696,8 +696,8 @@ impl Session { let effective_skill_roots = plugin_outcome.effective_plugin_skill_roots(); let skills_input = skills_load_input_from_config( &per_turn_config, - env_path_ref, - skill_root_path_ref, + cwd, + root_path_ref, effective_skill_roots, ); let skills_outcome = Arc::new( diff --git a/codex-rs/core/src/skills.rs b/codex-rs/core/src/skills.rs index 2fdcdfdc6a..a147e08c76 100644 --- a/codex-rs/core/src/skills.rs +++ b/codex-rs/core/src/skills.rs @@ -38,13 +38,13 @@ pub use codex_core_skills::system; pub(crate) fn skills_load_input_from_config( config: &Config, - env_path_ref: Option, - skill_root_path_ref: Option, + cwd: Option, + root_path_ref: Option, effective_skill_roots: Vec, ) -> SkillsLoadInput { SkillsLoadInput::new( - env_path_ref, - skill_root_path_ref, + cwd, + root_path_ref, effective_skill_roots, config.config_layer_stack.clone(), config.bundled_skills_enabled(),