mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Use PathUri for skill identity and path matching (#51482)
## Why Skill selection and disabled-path matching need to recognize equivalent Windows paths across case and separator differences while preserving literal spaces, `%`, and `#` in native filenames. ## What changed - Carry `PathUri` through skill metadata, discovery mappings, filesystem lookups, disabled-path sets, and invocation analytics. - Match linked skill mentions and TUI selections by parsed path identity. - Use `LegacyAppPathString` for app-server skill paths and regenerate schemas and SDK types, preserving native path strings on the wire. - Preserve native catalog display paths and ordering. Keep host filesystem probes and configuration writes restricted to host-compatible paths. ## Testing Add regression tests for Windows path identity and disabled-skill matching, literal filename characters, catalog resource reads, native path ordering, and foreign-path analytics normalization. GitOrigin-RevId: c212916dc9fef0e7616542726e107f0d6a313267
This commit is contained in:
committed by
copyberry
parent
e79c498b5e
commit
c9870d0157
@@ -48,6 +48,7 @@ use codex_skills::SkillRootLoadRequest;
|
||||
use codex_skills::SkillRootLoader;
|
||||
use codex_skills::SkillRootSnapshots;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use codex_utils_plugins::PluginIdentity;
|
||||
use codex_utils_plugins::PluginSkillRoot;
|
||||
use codex_utils_plugins::SkillDiscoveryMode;
|
||||
@@ -1022,7 +1023,7 @@ impl PluginSkillInventory {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResolvedPluginSkills {
|
||||
pub skills: Vec<SkillMetadata>,
|
||||
pub disabled_skill_paths: HashSet<AbsolutePathBuf>,
|
||||
pub disabled_skill_paths: HashSet<PathUri>,
|
||||
pub had_errors: bool,
|
||||
}
|
||||
|
||||
@@ -1034,7 +1035,7 @@ impl ResolvedPluginSkills {
|
||||
|
||||
fn contains_enabled_skill(
|
||||
skills: &[SkillMetadata],
|
||||
disabled_skill_paths: &HashSet<AbsolutePathBuf>,
|
||||
disabled_skill_paths: &HashSet<PathUri>,
|
||||
) -> bool {
|
||||
skills
|
||||
.iter()
|
||||
|
||||
@@ -122,6 +122,7 @@ use codex_tools::DiscoverablePluginInfo;
|
||||
use codex_tools::DiscoverableTool;
|
||||
use codex_tools::filter_request_plugin_install_discoverable_tools_for_client;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use codex_utils_plugins::PluginIdentity;
|
||||
use codex_utils_plugins::PluginSkillRoot;
|
||||
use std::collections::BTreeSet;
|
||||
@@ -469,7 +470,7 @@ pub struct PluginDetail {
|
||||
pub installed: bool,
|
||||
pub enabled: bool,
|
||||
pub skills: Vec<SkillMetadata>,
|
||||
pub disabled_skill_paths: HashSet<AbsolutePathBuf>,
|
||||
pub disabled_skill_paths: HashSet<PathUri>,
|
||||
/// Packaged onboarding path; callers apply visibility and enablement.
|
||||
pub onboarding_skill: Option<AbsolutePathBuf>,
|
||||
pub hooks: Vec<PluginHookSummary>,
|
||||
@@ -2729,10 +2730,11 @@ impl PluginsManager {
|
||||
if !path.as_path().starts_with(plugin_root.as_path()) {
|
||||
return None;
|
||||
}
|
||||
let path_uri = PathUri::from_abs_path(&path);
|
||||
resolved_skills
|
||||
.skills
|
||||
.iter()
|
||||
.any(|skill| skill.path_to_skills_md == path)
|
||||
.any(|skill| skill.path_to_skills_md == path_uri)
|
||||
.then_some(path)
|
||||
});
|
||||
let plugin_data_root = self.store.plugin_data_root(&plugin_id);
|
||||
|
||||
@@ -1844,7 +1844,7 @@ enabled = true
|
||||
|
||||
assert_eq!(
|
||||
outcome.plugins()[0].disabled_skill_paths,
|
||||
HashSet::from([skill_path])
|
||||
HashSet::from([PathUri::from_abs_path(&skill_path)])
|
||||
);
|
||||
assert!(!outcome.plugins()[0].has_enabled_skills);
|
||||
assert!(outcome.capability_summaries().is_empty());
|
||||
@@ -2295,7 +2295,10 @@ async fn install_plugin_materializes_default_command_skills() {
|
||||
resolved
|
||||
.skills
|
||||
.iter()
|
||||
.map(|skill| skill.path_to_skills_md.clone())
|
||||
.map(|skill| skill
|
||||
.path_to_skills_md
|
||||
.to_abs_path()
|
||||
.expect("host skill path"))
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
AbsolutePathBuf::from_absolute_path_checked(
|
||||
@@ -2421,7 +2424,12 @@ async fn load_plugin_skills_dedupes_overlapping_manifest_roots() {
|
||||
let skill_paths = resolved
|
||||
.skills
|
||||
.iter()
|
||||
.map(|skill| skill.path_to_skills_md.clone())
|
||||
.map(|skill| {
|
||||
skill
|
||||
.path_to_skills_md
|
||||
.to_abs_path()
|
||||
.expect("host skill path")
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let canonical_skill_path = |path| {
|
||||
AbsolutePathBuf::from_absolute_path_checked(
|
||||
|
||||
@@ -20,6 +20,7 @@ use codex_skills::LoadedSkills;
|
||||
use codex_skills::SkillMetadata;
|
||||
use codex_skills::SkillRootLoadRequest;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
|
||||
@@ -117,7 +118,9 @@ async fn curated_git_requirements_control_plugin_skills() -> Result<()> {
|
||||
interface: None,
|
||||
dependencies: None,
|
||||
policy: None,
|
||||
path_to_skills_md: AbsolutePathBuf::try_from(fs::canonicalize(skill_path)?)?,
|
||||
path_to_skills_md: PathUri::from_abs_path(&AbsolutePathBuf::try_from(
|
||||
fs::canonicalize(skill_path)?,
|
||||
)?),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: Some(plugin_id),
|
||||
remote_plugin_id: None,
|
||||
|
||||
@@ -42,6 +42,7 @@ use codex_skills::SkillRootLoadRequest;
|
||||
use codex_skills::SkillRootLoader;
|
||||
use codex_skills::parse_skill_frontmatter_metadata;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use codex_utils_plugins::PluginSkillRoot;
|
||||
use codex_utils_plugins::SkillDiscoveryMode;
|
||||
use codex_utils_plugins::migrated_command_skills_root;
|
||||
@@ -201,9 +202,17 @@ impl SkillRootLoader<PluginSkillRoot> for TestSkillRootLoader {
|
||||
outcome.errors.extend(snapshot.errors);
|
||||
}
|
||||
outcome.skills.sort_by(|left, right| {
|
||||
left.name
|
||||
.cmp(&right.name)
|
||||
.then_with(|| left.path_to_skills_md.cmp(&right.path_to_skills_md))
|
||||
left.name.cmp(&right.name).then_with(|| {
|
||||
left.path_to_skills_md
|
||||
.to_abs_path()
|
||||
.expect("host test skill path")
|
||||
.cmp(
|
||||
&right
|
||||
.path_to_skills_md
|
||||
.to_abs_path()
|
||||
.expect("host test skill path"),
|
||||
)
|
||||
})
|
||||
});
|
||||
outcome
|
||||
})
|
||||
@@ -261,7 +270,10 @@ fn load_test_skill_root(root: &PluginSkillRoot) -> LoadedSkillRoot {
|
||||
});
|
||||
match parsed {
|
||||
Ok(parsed) => {
|
||||
discovery_paths.insert(canonical_path.clone(), path);
|
||||
discovery_paths.insert(
|
||||
PathUri::from_abs_path(&canonical_path),
|
||||
PathUri::from_abs_path(&path),
|
||||
);
|
||||
skills.push(SkillMetadata {
|
||||
name: format!("{}:{}", root.plugin_namespace, parsed.name),
|
||||
description: parsed.description,
|
||||
@@ -269,7 +281,7 @@ fn load_test_skill_root(root: &PluginSkillRoot) -> LoadedSkillRoot {
|
||||
interface: None,
|
||||
dependencies: None,
|
||||
policy: None,
|
||||
path_to_skills_md: canonical_path,
|
||||
path_to_skills_md: PathUri::from_abs_path(&canonical_path),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: Some(root.plugin_identity.plugin_id.clone()),
|
||||
remote_plugin_id: root.plugin_identity.remote_plugin_id.clone(),
|
||||
|
||||
Reference in New Issue
Block a user