From 3145f777d22a949b0c1e9fe44ee3e6073566285f Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 25 Feb 2026 10:22:04 +1100 Subject: [PATCH] fix: rewrite plugin.json paths to folders during publish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the staged→main publish, after materializing files into plugin directories, rewrite each plugin.json to replace individual file paths with folder references so consumers on main get directory-level entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/materialize-plugins.mjs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/eng/materialize-plugins.mjs b/eng/materialize-plugins.mjs index 44b905108..0bd504466 100644 --- a/eng/materialize-plugins.mjs +++ b/eng/materialize-plugins.mjs @@ -145,6 +145,30 @@ function materializePlugins() { } } + // Rewrite plugin.json to use folder paths instead of individual file paths. + // On staged, paths like ./agents/foo.md point to individual source files. + // On main, after materialization, we only need the containing directory. + const rewritten = { ...metadata }; + let changed = false; + + for (const field of ["agents", "commands"]) { + if (Array.isArray(rewritten[field]) && rewritten[field].length > 0) { + const dirs = [...new Set(rewritten[field].map(p => path.dirname(p)))]; + rewritten[field] = dirs; + changed = true; + } + } + + if (Array.isArray(rewritten.skills) && rewritten.skills.length > 0) { + // Skills are already folder refs (./skills/name/); strip trailing slash + rewritten.skills = rewritten.skills.map(p => p.replace(/\/$/, "")); + changed = true; + } + + if (changed) { + fs.writeFileSync(pluginJsonPath, JSON.stringify(rewritten, null, 2) + "\n", "utf8"); + } + const counts = []; if (metadata.agents?.length) counts.push(`${metadata.agents.length} agents`); if (metadata.commands?.length) counts.push(`${metadata.commands.length} commands`);