mdk-skills 2.2.23 → 2.2.24
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.
- package/package.json +1 -1
- package/scripts/web-ui/server.js +6 -15
package/package.json
CHANGED
package/scripts/web-ui/server.js
CHANGED
|
@@ -298,35 +298,26 @@ async function handleApi(req, res) {
|
|
|
298
298
|
const result = installSelectedSkills(selected);
|
|
299
299
|
return sendJSON(res, { ok: true, ...result });
|
|
300
300
|
}
|
|
301
|
-
// POST /api/skills/pull —
|
|
301
|
+
// POST /api/skills/pull — 从远程仓库拉取技能(使用 npx skills 自动发现)
|
|
302
302
|
if (method === "POST" && pathname === "/api/skills/pull") {
|
|
303
303
|
const body = await parseBody(req);
|
|
304
304
|
const url = (body.url || "").trim();
|
|
305
305
|
if (!url) return sendJSON(res, { error: "请输入仓库地址" }, 400);
|
|
306
306
|
const tmpDir = path.join(os.tmpdir(), "mdk-pull-" + Date.now());
|
|
307
|
+
fs.mkdirSync(path.join(tmpDir, ".claude", "skills"), { recursive: true });
|
|
307
308
|
try {
|
|
308
|
-
execSync("
|
|
309
|
+
execSync("npx --yes skills add \"" + url + "\" --copy -y -a claude-code", {
|
|
310
|
+
cwd: tmpDir,
|
|
309
311
|
stdio: "pipe",
|
|
310
312
|
timeout: 120000,
|
|
311
313
|
});
|
|
312
314
|
} catch {
|
|
313
|
-
if (fs.existsSync(tmpDir)) fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
314
|
-
return sendJSON(res, { error: "仓库克隆失败,请检查地址是否正确" }, 400);
|
|
315
|
-
}
|
|
316
|
-
let skillsDir = null;
|
|
317
|
-
const claudeSkills = path.join(tmpDir, ".claude", "skills");
|
|
318
|
-
const skills = path.join(tmpDir, "skills");
|
|
319
|
-
if (fs.existsSync(claudeSkills)) {
|
|
320
|
-
skillsDir = claudeSkills;
|
|
321
|
-
} else if (fs.existsSync(skills)) {
|
|
322
|
-
skillsDir = skills;
|
|
323
|
-
}
|
|
324
|
-
if (!skillsDir) {
|
|
325
315
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
326
|
-
return sendJSON(res, { error: "
|
|
316
|
+
return sendJSON(res, { error: "拉取失败,请检查地址或网络连接" }, 400);
|
|
327
317
|
}
|
|
328
318
|
const imported = [];
|
|
329
319
|
const skipped = [];
|
|
320
|
+
const skillsDir = path.join(tmpDir, ".claude", "skills");
|
|
330
321
|
const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
331
322
|
for (const entry of entries) {
|
|
332
323
|
if (!entry.isDirectory()) continue;
|