Skip to content

Commit 078570c

Browse files
authored
Merge pull request #807 from github/fix/rewrite-plugin-json-on-publish
fix: rewrite plugin.json paths to folders during publish
2 parents b2404ea + 3145f77 commit 078570c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

eng/materialize-plugins.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,30 @@ function materializePlugins() {
145145
}
146146
}
147147

148+
// Rewrite plugin.json to use folder paths instead of individual file paths.
149+
// On staged, paths like ./agents/foo.md point to individual source files.
150+
// On main, after materialization, we only need the containing directory.
151+
const rewritten = { ...metadata };
152+
let changed = false;
153+
154+
for (const field of ["agents", "commands"]) {
155+
if (Array.isArray(rewritten[field]) && rewritten[field].length > 0) {
156+
const dirs = [...new Set(rewritten[field].map(p => path.dirname(p)))];
157+
rewritten[field] = dirs;
158+
changed = true;
159+
}
160+
}
161+
162+
if (Array.isArray(rewritten.skills) && rewritten.skills.length > 0) {
163+
// Skills are already folder refs (./skills/name/); strip trailing slash
164+
rewritten.skills = rewritten.skills.map(p => p.replace(/\/$/, ""));
165+
changed = true;
166+
}
167+
168+
if (changed) {
169+
fs.writeFileSync(pluginJsonPath, JSON.stringify(rewritten, null, 2) + "\n", "utf8");
170+
}
171+
148172
const counts = [];
149173
if (metadata.agents?.length) counts.push(`${metadata.agents.length} agents`);
150174
if (metadata.commands?.length) counts.push(`${metadata.commands.length} commands`);

0 commit comments

Comments
 (0)