Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion scripts/dist/discover-components.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7984,12 +7984,31 @@ function generateMarketplace(plugins, config) {
category: plugin.category === "code" || plugin.category === "analysis" ? "development" : "productivity"
});
}
const marketplacePath = path.join(".claude-plugin", "marketplace.json");
let existingOrder = [];
try {
const existing = JSON.parse(fs.readFileSync(marketplacePath, "utf8"));
existingOrder = (existing.plugins || []).map((p) => p.source);
} catch {
}
const existingSet = new Set(existingOrder);
const pluginsBySource = new Map(marketplacePlugins.map((p) => [p.source, p]));
const ordered = [];
for (const source of existingOrder) {
if (pluginsBySource.has(source)) {
ordered.push(pluginsBySource.get(source));
pluginsBySource.delete(source);
}
}
const newPlugins = Array.from(pluginsBySource.values());
newPlugins.sort((a, b) => a.source.localeCompare(b.source));
ordered.push(...newPlugins);
return {
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
name,
description,
owner,
plugins: marketplacePlugins
plugins: ordered
};
}
function writePluginJsonFiles(plugins, config) {
Expand Down
30 changes: 29 additions & 1 deletion scripts/src/discover-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,12 +1296,40 @@ function generateMarketplace(plugins, config) {
});
}

// Stable ordering: preserve existing order, append new plugins at the end.
// This keeps diffs clean — only additions/removals, never reordering.
const marketplacePath = path.join('.claude-plugin', 'marketplace.json');
let existingOrder = [];
try {
const existing = JSON.parse(fs.readFileSync(marketplacePath, 'utf8'));
existingOrder = (existing.plugins || []).map(p => p.source);
} catch {
// No existing file or invalid JSON — all plugins are new
}

const existingSet = new Set(existingOrder);
const pluginsBySource = new Map(marketplacePlugins.map(p => [p.source, p]));

// Existing plugins in their original order (skip any that were removed)
const ordered = [];
for (const source of existingOrder) {
if (pluginsBySource.has(source)) {
ordered.push(pluginsBySource.get(source));
pluginsBySource.delete(source);
}
}

// New plugins appended at the end, sorted alphabetically among themselves
const newPlugins = Array.from(pluginsBySource.values());
newPlugins.sort((a, b) => a.source.localeCompare(b.source));
ordered.push(...newPlugins);

return {
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
name,
description,
owner,
plugins: marketplacePlugins
plugins: ordered
};
}

Expand Down