diff --git a/scripts/publish-skill.mjs b/scripts/publish-skill.mjs index e22bad7..07d43e3 100644 --- a/scripts/publish-skill.mjs +++ b/scripts/publish-skill.mjs @@ -220,7 +220,7 @@ async function publishSkill({ registry, token, skill, files, version, changelog, ); for (const file of files) { - form.append("files", new Blob([file.bytes], { type: "application/octet-stream" }), file.relPath); + form.append("files", new Blob([file.bytes], { type: mimeType(file.relPath) }), file.relPath); } const response = await fetch(`${registry}/api/v1/skills`, { @@ -281,6 +281,26 @@ function titleCase(value) { .replace(/\b\w/g, (char) => char.toUpperCase()); } +const MIME_MAP = { + ".md": "text/markdown", + ".ts": "text/plain", + ".js": "text/javascript", + ".mjs": "text/javascript", + ".json": "application/json", + ".yml": "text/yaml", + ".yaml": "text/yaml", + ".txt": "text/plain", + ".html": "text/html", + ".css": "text/css", + ".xml": "text/xml", + ".svg": "image/svg+xml", +}; + +function mimeType(relPath) { + const ext = path.extname(relPath).toLowerCase(); + return MIME_MAP[ext] || "text/plain"; +} + function parseBoolean(value) { return ["1", "true", "yes", "on"].includes(String(value).trim().toLowerCase()); }