feat: Add skill creation command (#141)

Co-authored-by: cpacker <packercharles@gmail.com>
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
This commit is contained in:
Kevin Lin
2025-12-01 21:02:49 -08:00
committed by GitHub
parent 8ce6d32087
commit 57169c63e1
14 changed files with 1482 additions and 11 deletions

View File

@@ -89,11 +89,27 @@ export async function skill(args: SkillArgs): Promise<SkillResult> {
skillsDir = join(process.cwd(), SKILLS_DIR);
}
// Construct path to SKILL.md
const skillPath = join(skillsDir, skillId, "SKILL.md");
// Construct path to SKILL.md in the primary skills directory
let skillPath = join(skillsDir, skillId, "SKILL.md");
// Read the skill file directly
const skillContent = await readFile(skillPath, "utf-8");
// Read the skill file directly, with a fallback to bundled skills if not found
let skillContent: string;
try {
skillContent = await readFile(skillPath, "utf-8");
} catch (primaryError) {
// Fallback: check for bundled skills in a repo-level skills directory
try {
const bundledSkillsDir = join(process.cwd(), "skills", "skills");
const bundledSkillPath = join(bundledSkillsDir, skillId, "SKILL.md");
skillContent = await readFile(bundledSkillPath, "utf-8");
// Update path and directory to reflect bundled location for this invocation
skillsDir = bundledSkillsDir;
skillPath = bundledSkillPath;
} catch {
// If bundled fallback also fails, rethrow the original error
throw primaryError;
}
}
// Parse current loaded_skills block value
let currentValue = loadedSkillsBlock.value?.trim() || "";