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 authored and copyberry committed 2026-07-23 17:51:12 +00:00
1 parent ad65f016ed
commit 8d34c06672
2 files changed
+41 -10

No files matched your search

@@ -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] #[tokio::test]
async fn detect_home_plugins_uses_local_settings_over_project_settings() { async fn detect_home_plugins_uses_local_settings_over_project_settings() {
let (_root, external_agent_home, codex_home) = fixture_paths(); 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 KNOWN_MARKETPLACES_PATH: &str = "plugins/known_marketplaces.json";
pub(super) const OFFICIAL_MARKETPLACE_NAME: &str = "claude-plugins-official"; pub(super) const OFFICIAL_MARKETPLACE_NAME: &str = "claude-plugins-official";
pub(super) const OFFICIAL_MARKETPLACE_SOURCE: &str = "anthropics/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; pub(super) const REWRITE_PROFILE: RewriteProfile = ClaSource::REWRITE_PROFILE;
const COMMAND_MIGRATION_PROFILE: CommandMigrationProfile = CommandMigrationProfile::new( const COMMAND_MIGRATION_PROFILE: CommandMigrationProfile = CommandMigrationProfile::new(
CommandRewriteProfile::new( CommandRewriteProfile::new(
@@ -101,16 +103,21 @@ pub(super) fn marketplace_import_sources(
)); ));
} }
if has_enabled_plugin_for_marketplace(settings, OFFICIAL_MARKETPLACE_NAME) for (marketplace_name, marketplace_source) in [
&& !import_sources.contains_key(OFFICIAL_MARKETPLACE_NAME) (OFFICIAL_MARKETPLACE_NAME, OFFICIAL_MARKETPLACE_SOURCE),
{ (CLAUDE_CODE_MARKETPLACE_NAME, CLAUDE_CODE_MARKETPLACE_SOURCE),
import_sources.insert( ] {
OFFICIAL_MARKETPLACE_NAME.to_string(), if has_enabled_plugin_for_marketplace(settings, marketplace_name)
MarketplaceImportSource { && !import_sources.contains_key(marketplace_name)
source: OFFICIAL_MARKETPLACE_SOURCE.to_string(), {
ref_name: None, import_sources.insert(
}, marketplace_name.to_string(),
); MarketplaceImportSource {
source: marketplace_source.to_string(),
ref_name: None,
},
);
}
} }
import_sources import_sources