mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
New awesome agent primitive
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// YAML parser for collection files and frontmatter parsing using vfile-matter
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import yaml from "js-yaml";
|
||||
import { VFile } from "vfile";
|
||||
import { matter } from "vfile-matter";
|
||||
@@ -137,11 +138,56 @@ function extractMcpServerConfigs(filePath) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse SKILL.md frontmatter and list bundled assets in a skill folder
|
||||
* @param {string} skillPath - Path to skill folder
|
||||
* @returns {object|null} Skill metadata with name, description, and assets array
|
||||
*/
|
||||
function parseSkillMetadata(skillPath) {
|
||||
return safeFileOperation(
|
||||
() => {
|
||||
const skillFile = path.join(skillPath, "SKILL.md");
|
||||
if (!fs.existsSync(skillFile)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const frontmatter = parseFrontmatter(skillFile);
|
||||
|
||||
// Validate required fields
|
||||
if (!frontmatter?.name || !frontmatter?.description) {
|
||||
console.warn(
|
||||
`Invalid skill at ${skillPath}: missing name or description in frontmatter`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
// List bundled assets (all files except SKILL.md)
|
||||
const assets = fs
|
||||
.readdirSync(skillPath)
|
||||
.filter((file) => {
|
||||
const filePath = path.join(skillPath, file);
|
||||
return file !== "SKILL.md" && fs.statSync(filePath).isFile();
|
||||
})
|
||||
.sort();
|
||||
|
||||
return {
|
||||
name: frontmatter.name,
|
||||
description: frontmatter.description,
|
||||
assets,
|
||||
path: skillPath,
|
||||
};
|
||||
},
|
||||
skillPath,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
parseCollectionYaml,
|
||||
parseFrontmatter,
|
||||
extractAgentMetadata,
|
||||
extractMcpServers,
|
||||
extractMcpServerConfigs,
|
||||
parseSkillMetadata,
|
||||
safeFileOperation,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user