fix: use proper MIME types in skill publish to fix ClawhHub rejection

This commit is contained in:
Jim Liu 宝玉 2026-03-11 22:46:06 -05:00
parent 53c788eb3b
commit 42b8b1fc99
1 changed files with 21 additions and 1 deletions

View File

@ -220,7 +220,7 @@ async function publishSkill({ registry, token, skill, files, version, changelog,
); );
for (const file of files) { 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`, { const response = await fetch(`${registry}/api/v1/skills`, {
@ -281,6 +281,26 @@ function titleCase(value) {
.replace(/\b\w/g, (char) => char.toUpperCase()); .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) { function parseBoolean(value) {
return ["1", "true", "yes", "on"].includes(String(value).trim().toLowerCase()); return ["1", "true", "yes", "on"].includes(String(value).trim().toLowerCase());
} }