mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Add compatibility policies for skill catalog rendering (#34611)
## What changed - Parameterize skill catalog rendering with explicit core- and extension-compatible description policies. - Use full skill descriptions for core-compatible output, while extension-compatible output prefers `short_description` and falls back to the full description. - Keep extension prompt and world-state rendering on the extension-compatible policy. ## Testing - Add a renderer test covering description selection and fallback for both policies. GitOrigin-RevId: 5382075f88c25a49a715feb0702a9ab888ec0123
This commit is contained in:
1 parent
25d2dfcad0
commit
c7e3838987
4 files changed
+119
-11
No files matched your search
@@ -0,0 +1,67 @@
|
||||
use super::*;
|
||||
use crate::catalog::SkillAuthority;
|
||||
use crate::catalog::SkillPackageId;
|
||||
use crate::catalog::SkillResourceId;
|
||||
use codex_core_skills::render_available_skills_body;
|
||||
use codex_extension_api::ContextualUserFragment;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
fn entry(name: &str, description: &str, short_description: Option<&str>) -> SkillCatalogEntry {
|
||||
SkillCatalogEntry::new(
|
||||
SkillPackageId(name.to_string()),
|
||||
SkillAuthority::new(SkillSourceKind::Host, "host"),
|
||||
name,
|
||||
description,
|
||||
SkillResourceId::new(format!("/skills/{name}/SKILL.md")),
|
||||
)
|
||||
.with_short_description(short_description.map(str::to_string))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn description_selection_follows_render_policy() {
|
||||
let catalog = SkillCatalog {
|
||||
entries: vec![
|
||||
entry("shortened", "full description", Some("short description")),
|
||||
entry(
|
||||
"fallback",
|
||||
"fallback description",
|
||||
/*short_description*/ None,
|
||||
),
|
||||
],
|
||||
warnings: Vec::new(),
|
||||
};
|
||||
|
||||
let core = available_skills_fragment(
|
||||
&catalog,
|
||||
/*include_skills_usage_instructions*/ false,
|
||||
SkillCatalogRenderPolicy::CoreCompatible,
|
||||
)
|
||||
.expect("catalog should render");
|
||||
let extension = available_skills_fragment(
|
||||
&catalog,
|
||||
/*include_skills_usage_instructions*/ false,
|
||||
SkillCatalogRenderPolicy::ExtensionCompatible,
|
||||
)
|
||||
.expect("catalog should render");
|
||||
|
||||
assert_eq!(
|
||||
core.body(),
|
||||
render_available_skills_body(
|
||||
&[],
|
||||
&[
|
||||
"- shortened: full description (file: /skills/shortened/SKILL.md)".to_string(),
|
||||
"- fallback: fallback description (file: /skills/fallback/SKILL.md)".to_string(),
|
||||
],
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
extension.body(),
|
||||
render_available_skills_body(
|
||||
&[],
|
||||
&[
|
||||
"- shortened: short description (file: /skills/shortened/SKILL.md)".to_string(),
|
||||
"- fallback: fallback description (file: /skills/fallback/SKILL.md)".to_string(),
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user