itismyskillmarket 1.3.32 → 1.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +29 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1608,7 +1608,7 @@ async function verifySkill(skillName) {
1608
1608
 
1609
1609
  // src/commands/ui.ts
1610
1610
  import { createServer } from "http";
1611
- import { readFileSync as readFileSync2, existsSync as existsSync3, mkdirSync, rmSync } from "fs";
1611
+ import { readFileSync as readFileSync2, existsSync as existsSync3, mkdirSync, rmSync, readdirSync, renameSync } from "fs";
1612
1612
  import { join as join3, extname, dirname, basename } from "path";
1613
1613
  import { fileURLToPath as fileURLToPath3 } from "url";
1614
1614
  import AdmZip from "adm-zip";
@@ -2607,10 +2607,8 @@ API_ROUTES.POST["/api/upload"] = async (req, res, _url) => {
2607
2607
  });
2608
2608
  let skillName = "";
2609
2609
  let pkgInfo = {};
2610
- let pkgEntryRelativePath = "";
2611
2610
  if (pkgEntry) {
2612
2611
  try {
2613
- pkgEntryRelativePath = normalizeEntryName(pkgEntry.entryName);
2614
2612
  pkgInfo = JSON.parse(pkgEntry.getData().toString("utf-8"));
2615
2613
  skillName = pkgInfo.skillmarket?.id || pkgInfo.name?.replace(/^@[^/]+\//, "") || "";
2616
2614
  } catch {
@@ -2631,14 +2629,20 @@ API_ROUTES.POST["/api/upload"] = async (req, res, _url) => {
2631
2629
  }
2632
2630
  mkdirSync(skillDir, { recursive: true });
2633
2631
  zip.extractAllTo(skillDir, true);
2634
- const skillMdExists = existsSync3(join3(skillDir, "SKILL.md")) || entries.some((e) => e.entryName.endsWith("SKILL.md"));
2635
- let pkgJsonPath = join3(skillDir, "package.json");
2636
- if (pkgEntryRelativePath) {
2637
- const extractedPkgPath = join3(skillDir, pkgEntryRelativePath);
2638
- if (existsSync3(extractedPkgPath)) {
2639
- pkgJsonPath = extractedPkgPath;
2632
+ const extractedItems = readdirSync(skillDir, { withFileTypes: true });
2633
+ const subDirs = extractedItems.filter((i) => i.isDirectory());
2634
+ const files = extractedItems.filter((i) => !i.isDirectory());
2635
+ if (subDirs.length === 1 && files.length === 0) {
2636
+ const subDirPath = join3(skillDir, subDirs[0].name);
2637
+ const subItems = readdirSync(subDirPath, { withFileTypes: true });
2638
+ for (const item of subItems) {
2639
+ renameSync(join3(subDirPath, item.name), join3(skillDir, item.name));
2640
2640
  }
2641
+ rmSync(subDirPath, { recursive: true, force: true });
2641
2642
  }
2643
+ const skillMdPath = findFileSync(skillDir, "SKILL.md");
2644
+ const skillMdExists = skillMdPath !== null;
2645
+ const pkgJsonPath = findFileSync(skillDir, "package.json") || join3(skillDir, "package.json");
2642
2646
  if (existsSync3(pkgJsonPath)) {
2643
2647
  try {
2644
2648
  pkgInfo = JSON.parse(readFileSync2(pkgJsonPath, "utf-8"));
@@ -2701,6 +2705,22 @@ API_ROUTES.POST["/api/upload/action"] = async (req, res, _url) => {
2701
2705
  jsonResponse(res, 500, { error: String(err) });
2702
2706
  }
2703
2707
  };
2708
+ function findFileSync(dir, filename) {
2709
+ try {
2710
+ const items = readdirSync(dir, { withFileTypes: true });
2711
+ for (const item of items) {
2712
+ const fullPath = join3(dir, item.name);
2713
+ if (item.isDirectory()) {
2714
+ const found = findFileSync(fullPath, filename);
2715
+ if (found) return found;
2716
+ } else if (item.name === filename) {
2717
+ return fullPath;
2718
+ }
2719
+ }
2720
+ } catch {
2721
+ }
2722
+ return null;
2723
+ }
2704
2724
  function serveStaticFile(res, filePath) {
2705
2725
  if (!existsSync3(filePath)) {
2706
2726
  res.writeHead(404, { "Content-Type": "text/plain" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itismyskillmarket",
3
- "version": "1.3.32",
3
+ "version": "1.3.34",
4
4
  "description": "Cross-platform skill manager for AI coding tools",
5
5
  "type": "module",
6
6
  "bin": {