mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Migrate Claude commands without frontmatter (#40643)
## What changed - Import supported Claude commands that lack a usable frontmatter description by deriving the skill description from the source command name. - Preserve commands with explicit descriptions when multiple source paths normalize to the same skill name, and skip ambiguous fallback-only collisions. - Apply the expanded detection and import behavior to both user-level and repository-level command directories. ## Testing - Add service tests for commands without frontmatter, normalized-name collisions, unsupported templates, and post-import detection. GitOrigin-RevId: 53691193128a6b1be192c4f83bdf563980a0e55d
This commit is contained in:
1 parent
da4cf1cdea
commit
a9e447a69d
2 files changed
+224
-12
No files matched your search
@@ -3,7 +3,6 @@ use crate::RewriteProfile;
|
||||
use codex_core_plugins::CommandDescriptionMode;
|
||||
use codex_core_plugins::CommandMigrationProfile;
|
||||
use codex_core_plugins::CommandRewriteProfile;
|
||||
use codex_core_plugins::count_missing_commands_with_profile;
|
||||
use codex_core_plugins::import_commands_with_profile;
|
||||
use codex_core_plugins::marketplace_add::is_local_marketplace_source;
|
||||
use codex_core_plugins::missing_command_names_with_profile;
|
||||
@@ -24,14 +23,23 @@ pub(super) const OFFICIAL_MARKETPLACE_SOURCE: &str = "anthropics/claude-plugins-
|
||||
pub(super) const CLAUDE_CODE_MARKETPLACE_NAME: &str = "claude-code-plugins";
|
||||
pub(super) const CLAUDE_CODE_MARKETPLACE_SOURCE: &str = "anthropics/claude-code";
|
||||
pub(super) const REWRITE_PROFILE: RewriteProfile = ClaSource::REWRITE_PROFILE;
|
||||
const COMMAND_MIGRATION_PROFILE: CommandMigrationProfile = CommandMigrationProfile::new(
|
||||
CommandRewriteProfile::new(
|
||||
REWRITE_PROFILE.doc_file_name(),
|
||||
REWRITE_PROFILE.term_variants(),
|
||||
)
|
||||
.with_case_sensitive_term_variants(REWRITE_PROFILE.case_sensitive_term_variants()),
|
||||
CommandDescriptionMode::RequireFrontmatter,
|
||||
);
|
||||
const COMMAND_REWRITE_PROFILE: CommandRewriteProfile = CommandRewriteProfile::new(
|
||||
REWRITE_PROFILE.doc_file_name(),
|
||||
REWRITE_PROFILE.term_variants(),
|
||||
)
|
||||
.with_case_sensitive_term_variants(REWRITE_PROFILE.case_sensitive_term_variants());
|
||||
|
||||
// Preserve described commands first. The fallback pass still checks all sources for collisions.
|
||||
const COMMAND_MIGRATION_PROFILES: [CommandMigrationProfile; 2] = [
|
||||
CommandMigrationProfile::new(
|
||||
COMMAND_REWRITE_PROFILE,
|
||||
CommandDescriptionMode::RequireFrontmatter,
|
||||
),
|
||||
CommandMigrationProfile::new(
|
||||
COMMAND_REWRITE_PROFILE,
|
||||
CommandDescriptionMode::UseSourceNameFallback,
|
||||
),
|
||||
];
|
||||
|
||||
pub(super) fn marketplace_import_sources(
|
||||
settings: &JsonValue,
|
||||
@@ -127,21 +135,41 @@ pub(super) fn import_source_commands(
|
||||
source_commands: &Path,
|
||||
target_skills: &Path,
|
||||
) -> io::Result<Vec<String>> {
|
||||
import_commands_with_profile(source_commands, target_skills, COMMAND_MIGRATION_PROFILE)
|
||||
let mut imported = Vec::new();
|
||||
for profile in COMMAND_MIGRATION_PROFILES {
|
||||
imported.extend(import_commands_with_profile(
|
||||
source_commands,
|
||||
target_skills,
|
||||
profile,
|
||||
)?);
|
||||
}
|
||||
imported.sort();
|
||||
imported.dedup();
|
||||
Ok(imported)
|
||||
}
|
||||
|
||||
pub(super) fn count_missing_source_commands(
|
||||
source_commands: &Path,
|
||||
target_skills: &Path,
|
||||
) -> io::Result<usize> {
|
||||
count_missing_commands_with_profile(source_commands, target_skills, COMMAND_MIGRATION_PROFILE)
|
||||
Ok(missing_source_command_names(source_commands, target_skills)?.len())
|
||||
}
|
||||
|
||||
pub(super) fn missing_source_command_names(
|
||||
source_commands: &Path,
|
||||
target_skills: &Path,
|
||||
) -> io::Result<Vec<String>> {
|
||||
missing_command_names_with_profile(source_commands, target_skills, COMMAND_MIGRATION_PROFILE)
|
||||
let mut names = Vec::new();
|
||||
for profile in COMMAND_MIGRATION_PROFILES {
|
||||
names.extend(missing_command_names_with_profile(
|
||||
source_commands,
|
||||
target_skills,
|
||||
profile,
|
||||
)?);
|
||||
}
|
||||
names.sort();
|
||||
names.dedup();
|
||||
Ok(names)
|
||||
}
|
||||
|
||||
pub(crate) fn extract_plugin_migration_details(
|
||||
|
||||
Reference in new issue
Block a user