Skip to content

Commit 4bd84c2

Browse files
christsoclaude
andauthored
fix(marketplace): prevent repeated auto-registration on every plugin resolve (#66)
When a marketplace manifest defines a canonical name different from the repo name, getMarketplace() by repo name fails on every plugin resolve, triggering redundant auto-registration attempts with console spam and unnecessary I/O. Add findMarketplace() that checks both registry name and source.location in a single registry load, so already-registered marketplaces are found regardless of name mismatch. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1869e59 commit 4bd84c2

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/core/marketplace.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,28 @@ export async function getMarketplace(name: string): Promise<MarketplaceEntry | n
349349
return registry.marketplaces[name] || null;
350350
}
351351

352+
/**
353+
* Find a marketplace by name, falling back to source location lookup.
354+
* Single registry load for both checks.
355+
*/
356+
export async function findMarketplace(
357+
name: string,
358+
sourceLocation?: string,
359+
): Promise<MarketplaceEntry | null> {
360+
const registry = await loadRegistry();
361+
if (registry.marketplaces[name]) {
362+
return registry.marketplaces[name];
363+
}
364+
if (sourceLocation) {
365+
for (const entry of Object.values(registry.marketplaces)) {
366+
if (entry.source.location === sourceLocation) {
367+
return entry;
368+
}
369+
}
370+
}
371+
return null;
372+
}
373+
352374
/**
353375
* Update marketplace(s) by pulling latest changes
354376
* @param name - Optional marketplace name (updates all if not specified)
@@ -723,8 +745,9 @@ export async function resolvePluginSpecWithAutoRegister(
723745

724746
const { plugin: pluginName, marketplaceName, owner, repo, subpath } = parsed;
725747

726-
// Check if marketplace is already registered
727-
let marketplace = await getMarketplace(marketplaceName);
748+
// Check if marketplace is already registered (by name, then by source location)
749+
const sourceLocation = owner && repo ? `${owner}/${repo}` : undefined;
750+
let marketplace = await findMarketplace(marketplaceName, sourceLocation);
728751

729752
// If not registered, try auto-registration
730753
if (!marketplace) {

0 commit comments

Comments
 (0)