Infer the bundled Claude Code plugin marketplace (#34979)

## What changed

- Treat enabled plugins from `claude-code-plugins` as coming from
  `anthropics/claude-code` when no marketplace source is already known.
- Preserve an explicitly discovered source instead of replacing it with the
  inferred source.

## Testing

- Add a migration test covering inference from `enabledPlugins`.

GitOrigin-RevId: f061963356493027968e282a51538866d2bf31f4
This commit is contained in:
charlesgong-openai
2026-07-23 17:51:12 +00:00
committed by copyberry
parent ad65f016ed
commit 8d34c06672
2 changed files with 41 additions and 10 deletions
@@ -220,6 +220,30 @@ fn marketplace_import_sources_prefers_supported_declaration_over_materialization
);
}
#[test]
fn marketplace_import_sources_infers_bundled_claude_code_marketplace() {
let (_root, external_agent_home, _codex_home) = fixture_paths();
let settings = serde_json::json!({
"enabledPlugins": {
"code-review@claude-code-plugins": true,
}
});
let import_sources = source_cla::marketplace_import_sources(
&settings,
&external_agent_home,
&external_agent_home,
);
assert_eq!(
import_sources.get("claude-code-plugins"),
Some(&MarketplaceImportSource {
source: "anthropics/claude-code".to_string(),
ref_name: None,
})
);
}
#[tokio::test]
async fn detect_home_plugins_uses_local_settings_over_project_settings() {
let (_root, external_agent_home, codex_home) = fixture_paths();
@@ -21,6 +21,8 @@ use crate::model::PluginsMigration;
pub(super) const KNOWN_MARKETPLACES_PATH: &str = "plugins/known_marketplaces.json";
pub(super) const OFFICIAL_MARKETPLACE_NAME: &str = "claude-plugins-official";
pub(super) const OFFICIAL_MARKETPLACE_SOURCE: &str = "anthropics/claude-plugins-official";
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(
@@ -101,16 +103,21 @@ pub(super) fn marketplace_import_sources(
));
}
if has_enabled_plugin_for_marketplace(settings, OFFICIAL_MARKETPLACE_NAME)
&& !import_sources.contains_key(OFFICIAL_MARKETPLACE_NAME)
{
import_sources.insert(
OFFICIAL_MARKETPLACE_NAME.to_string(),
MarketplaceImportSource {
source: OFFICIAL_MARKETPLACE_SOURCE.to_string(),
ref_name: None,
},
);
for (marketplace_name, marketplace_source) in [
(OFFICIAL_MARKETPLACE_NAME, OFFICIAL_MARKETPLACE_SOURCE),
(CLAUDE_CODE_MARKETPLACE_NAME, CLAUDE_CODE_MARKETPLACE_SOURCE),
] {
if has_enabled_plugin_for_marketplace(settings, marketplace_name)
&& !import_sources.contains_key(marketplace_name)
{
import_sources.insert(
marketplace_name.to_string(),
MarketplaceImportSource {
source: marketplace_source.to_string(),
ref_name: None,
},
);
}
}
import_sources