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
9 changes: 9 additions & 0 deletions .github/scripts/build-plugin-mirror.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const ALLOWED = /\.(md|txt|json|ya?ml|png|jpe?g|gif|webp|ico)$/i;
const ALLOWED_NAMES = new Set(["LICENSE", ".gitignore"]);
// Paths the directory edition leaves out: the server's launcher and every script.
const DIRECTORY_DROPS = [".mcp.json", "scripts"];
// Manifest fields the directory refuses from an unverified organization. Claude Code
// reads `network` (the hosts the plugin reaches), but the directory does not list it.
const DIRECTORY_MANIFEST_DROPS = ["network"];
// Words that would point Claude at something the directory edition does not ship.
const DANGLING = [/\.mjs\b/, /openscreenSetup/, /\/reload-plugins/, /\b(the|plugin.s) launcher\b/];

Expand Down Expand Up @@ -84,6 +87,12 @@ export function buildPluginMirror(pluginDir, outDir, { edition = "directory", li
if (edition === "full") return walk(outDir).sort();

for (const drop of DIRECTORY_DROPS) rmSync(join(outDir, drop), { recursive: true, force: true });
const manifest = join(outDir, ".claude-plugin", "plugin.json");
if (existsSync(manifest)) {
const json = JSON.parse(readFileSync(manifest, "utf8"));
for (const field of DIRECTORY_MANIFEST_DROPS) delete json[field];
writeFileSync(manifest, `${JSON.stringify(json, null, "\t")}\n`);
}
const skills = join(outDir, "skills");
if (existsSync(skills)) {
for (const skill of readdirSync(skills)) {
Expand Down
9 changes: 8 additions & 1 deletion .github/scripts/build-plugin-mirror.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ function write(rel, text) {

beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), "plugin-mirror-"));
write(".claude-plugin/plugin.json", '{ "name": "openscreen", "version": "2.4.0" }\n');
write(
".claude-plugin/plugin.json",
'{ "name": "openscreen", "version": "2.4.0", "network": { "hosts": ["github.com"] } }\n',
);
write(".mcp.json", '{ "mcpServers": {} }\n');
write("scripts/server.mjs", "#!/usr/bin/env node\n");
write("evals/README.md", "graders\n");
Expand All @@ -40,6 +43,10 @@ describe("buildPluginMirror", () => {
const out = join(dir, "out");
const files = buildPluginMirror(join(dir, "plugin"), out, { license: join(dir, "LICENSE") });
expect(files).toEqual([".claude-plugin/plugin.json", "LICENSE", "skills/demo/SKILL.md"]);
expect(JSON.parse(readFileSync(join(out, ".claude-plugin/plugin.json"), "utf8"))).toEqual({
name: "openscreen",
version: "2.4.0",
});
expect(readFileSync(join(out, "skills/demo/SKILL.md"), "utf8")).toBe(
"Setup. Register it by hand.\nEnd.\n",
);
Expand Down
Binary file modified plugin/.claude-plugin/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading