New awesome agent primitive

This commit is contained in:
Harald Kirschner
2025-12-17 15:27:05 -08:00
parent 8baf6d7223
commit 88956de414
11 changed files with 812 additions and 17 deletions

View File

@@ -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,
};