MCPcopy Create free account
hub / github.com/Railly/agentfiles / parseSkillFile

Function parseSkillFile

src/scanner.ts:164–207  ·  view source on GitHub ↗
(
	filePath: string,
	type: SkillType,
	toolId: string,
	_pattern: ScanPattern = "directory-with-skillmd",
	namingMode: NamingMode = "auto"
)

Source from the content-addressed store, hash-verified

162}
163
164function parseSkillFile(
165 filePath: string,
166 type: SkillType,
167 toolId: string,
168 _pattern: ScanPattern = "directory-with-skillmd",
169 namingMode: NamingMode = "auto"
170): SkillItem | null {
171 try {
172 const raw = readFileSync(filePath, "utf-8");
173 const stat = statSync(filePath);
174 const { frontmatter, content } = parseFrontmatter(raw);
175 const name = extractName(frontmatter, content, filePath, namingMode, type);
176 const description =
177 typeof frontmatter.description === "string"
178 ? frontmatter.description
179 : "";
180
181 let realPath: string;
182 try {
183 realPath = realpathSync(filePath);
184 } catch { /* empty */
185 realPath = filePath;
186 }
187
188 return {
189 id: hashPath(realPath),
190 name,
191 description,
192 type,
193 tools: [toolId],
194 filePath,
195 realPath,
196 dirPath: join(filePath, ".."),
197 content: raw,
198 frontmatter,
199 lastModified: stat.mtimeMs,
200 fileSize: stat.size,
201 isFavorite: false,
202 collections: [],
203 };
204 } catch { /* empty */
205 return null;
206 }
207}
208
209function scanPath(sp: SkillPath, toolId: string, namingMode: NamingMode = "auto"): SkillItem[] {
210 switch (sp.pattern) {

Callers 3

scanDirectoryWithSkillMdFunction · 0.85
scanFlatMdFunction · 0.85
scanMdcFunction · 0.85

Calls 3

parseFrontmatterFunction · 0.85
extractNameFunction · 0.85
hashPathFunction · 0.85

Tested by

no test coverage detected