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

Method serveSkillFiles

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

Source from the content-addressed store, hash-verified

1140 }
1141
1142 private serveSkillFiles(res: http.ServerResponse, urlPath: string): void {
1143 const skillId = urlPath.replace("/api/skill/", "").replace("/files", "");
1144 const skill = this.store.getSkill(skillId);
1145 if (!skill) {
1146 res.writeHead(404, { "Content-Type": "application/json" });
1147 res.end(JSON.stringify({ error: "Skill not found" }));
1148 return;
1149 }
1150
1151 if (!fs.existsSync(skill.dirPath)) {
1152 this.jsonResponse(res, { files: [], error: "Skill directory not found" });
1153 return;
1154 }
1155
1156 const files = this.walkDir(skill.dirPath, skill.dirPath);
1157 this.jsonResponse(res, { files });
1158 }
1159
1160 private walkDir(dir: string, root: string): Array<{ path: string; type: string; size: number }> {
1161 const results: Array<{ path: string; type: string; size: number }> = [];

Callers 1

handleRequestMethod · 0.95

Calls 4

jsonResponseMethod · 0.95
walkDirMethod · 0.95
endMethod · 0.80
getSkillMethod · 0.65

Tested by

no test coverage detected