mirror of
https://github.com/openai/codex.git
synced 2026-05-29 15:30:22 +00:00
Rename skill path refs to cwd and root paths
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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<PluginSkillRoot>,
|
||||
) -> Vec<SkillRoot> {
|
||||
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<PluginSkillRoot>,
|
||||
@@ -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<SkillRoot> {
|
||||
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<SkillRoot> {
|
||||
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,
|
||||
|
||||
@@ -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<SkillScope> = super::skill_roots(
|
||||
Some(&local_env_path_ref),
|
||||
/*skill_root_path_ref*/ None,
|
||||
/*root_path_ref*/ None,
|
||||
&cfg.config_layer_stack,
|
||||
Vec::new(),
|
||||
)
|
||||
|
||||
@@ -26,8 +26,8 @@ use codex_exec_server::EnvironmentPathRef;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SkillsLoadInput {
|
||||
pub env_path_ref: Option<EnvironmentPathRef>,
|
||||
pub skill_root_path_ref: Option<EnvironmentPathRef>,
|
||||
pub cwd: Option<EnvironmentPathRef>,
|
||||
pub root_path_ref: Option<EnvironmentPathRef>,
|
||||
pub effective_skill_roots: Vec<PluginSkillRoot>,
|
||||
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<EnvironmentPathRef>,
|
||||
skill_root_path_ref: Option<EnvironmentPathRef>,
|
||||
cwd: Option<EnvironmentPathRef>,
|
||||
root_path_ref: Option<EnvironmentPathRef>,
|
||||
effective_skill_roots: Vec<PluginSkillRoot>,
|
||||
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<SkillRoot> {
|
||||
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(),
|
||||
)
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -38,13 +38,13 @@ pub use codex_core_skills::system;
|
||||
|
||||
pub(crate) fn skills_load_input_from_config(
|
||||
config: &Config,
|
||||
env_path_ref: Option<EnvironmentPathRef>,
|
||||
skill_root_path_ref: Option<EnvironmentPathRef>,
|
||||
cwd: Option<EnvironmentPathRef>,
|
||||
root_path_ref: Option<EnvironmentPathRef>,
|
||||
effective_skill_roots: Vec<PluginSkillRoot>,
|
||||
) -> 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(),
|
||||
|
||||
Reference in New Issue
Block a user