MCPcopy Create free account
hub / github.com/MemTensor/MemOS / handleSkillDelete

Method handleSkillDelete

packages/memos-core/src/viewer/server.ts:1380–1404  ·  view source on GitHub ↗
(res: http.ServerResponse, urlPath: string)

Source from the content-addressed store, hash-verified

1378 }
1379
1380 private async handleSkillDelete(res: http.ServerResponse, urlPath: string): Promise<void> {
1381 const skillId = urlPath.replace("/api/skill/", "");
1382 const skill = this.store.getSkill(skillId);
1383 if (!skill) { res.writeHead(404, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Skill not found" })); return; }
1384 try {
1385 const hub = this.resolveHubConnection();
1386 if (hub) {
1387 await hubRequestJson(hub.hubUrl, hub.userToken, "/api/v1/hub/skills/unpublish", {
1388 method: "POST",
1389 body: JSON.stringify({ sourceSkillId: skillId }),
1390 }).catch(() => {});
1391 }
1392 const db = (this.store as any).db;
1393 db.prepare("DELETE FROM hub_skills WHERE source_skill_id = ?").run(skillId);
1394 } catch (_) {}
1395 try {
1396 if (skill.dirPath && fs.existsSync(skill.dirPath)) {
1397 fs.rmSync(skill.dirPath, { recursive: true, force: true });
1398 }
1399 } catch (err) {
1400 this.log.warn(`Failed to remove skill directory ${skill.dirPath}: ${err}`);
1401 }
1402 this.store.deleteSkill(skillId);
1403 this.jsonResponse(res, { ok: true, skillId });
1404 }
1405
1406 private handleSkillUpdate(req: http.IncomingMessage, res: http.ServerResponse, urlPath: string): void {
1407 const skillId = urlPath.replace("/api/skill/", "");

Callers 1

handleRequestMethod · 0.95

Calls 9

resolveHubConnectionMethod · 0.95
jsonResponseMethod · 0.95
hubRequestJsonFunction · 0.90
endMethod · 0.80
prepareMethod · 0.80
getSkillMethod · 0.65
runMethod · 0.65
warnMethod · 0.65
deleteSkillMethod · 0.65

Tested by

no test coverage detected