fix: copilot comments

This commit is contained in:
Aaron Powell
2026-02-25 15:27:36 +11:00
parent 8553deab14
commit d144ab626a
2 changed files with 26 additions and 12 deletions

View File

@@ -2,9 +2,10 @@
import fs from "fs";
import path from "path";
import { ROOT_FOLDER, PROMPTS_DIR, SKILLS_DIR } from "./constants.mjs";
import { ROOT_FOLDER, SKILLS_DIR } from "./constants.mjs";
import { parseFrontmatter } from "./yaml-parser.mjs";
const PROMPTS_DIR = path.join(ROOT_FOLDER, "prompts");
/**
* Convert a prompt file to a skill folder
* @param {string} promptFilePath - Full path to the prompt file
@@ -13,7 +14,7 @@ import { parseFrontmatter } from "./yaml-parser.mjs";
function convertPromptToSkill(promptFilePath) {
const filename = path.basename(promptFilePath);
const baseName = filename.replace(".prompt.md", "");
console.log(`\nConverting: ${baseName}`);
// Parse the prompt file frontmatter
@@ -44,7 +45,7 @@ function convertPromptToSkill(promptFilePath) {
// Build SKILL.md content
const skillContent = `---
name: ${skillFrontmatter.name}
description: '${skillFrontmatter.description.replace(/'/g, "'\\''")}'
description: '${skillFrontmatter.description.replace(/'/g, "'''")}'
---
${mainContent}

View File

@@ -12,7 +12,7 @@ import { PLUGINS_DIR } from "./constants.mjs";
function updatePluginManifest(pluginJsonPath) {
const pluginDir = path.dirname(path.dirname(path.dirname(pluginJsonPath)));
const pluginName = path.basename(pluginDir);
console.log(`\nProcessing plugin: ${pluginName}`);
// Read and parse plugin.json
@@ -34,20 +34,33 @@ function updatePluginManifest(pluginJsonPath) {
const commandCount = plugin.commands.length;
console.log(` Found ${commandCount} command(s) to convert`);
// Convert commands to skills format
// Validate and convert commands to skills format
// Commands: "./commands/foo.md" → Skills: "./skills/foo/"
const skills = plugin.commands.map((cmd) => {
const validCommands = plugin.commands.filter((cmd) => {
if (typeof cmd !== "string") {
console.log(` ⚠ Skipping non-string command entry: ${JSON.stringify(cmd)}`);
return false;
}
if (!cmd.startsWith("./commands/") || !cmd.endsWith(".md")) {
console.log(` ⚠ Skipping command with unexpected format: ${cmd}`);
return false;
}
return true;
});
const skills = validCommands.map((cmd) => {
const basename = path.basename(cmd, ".md");
return `./skills/${basename}/`;
});
// Initialize skills array if it doesn't exist
if (!plugin.skills) {
// Initialize skills array if it doesn't exist or is not an array
if (!Array.isArray(plugin.skills)) {
plugin.skills = [];
}
// Add converted commands to skills array
plugin.skills.push(...skills);
// Add converted commands to skills array, de-duplicating entries
const allSkills = new Set(plugin.skills);
for (const skillPath of skills) {
allSkills.add(skillPath);
}
plugin.skills = Array.from(allSkills);
// Remove commands field
delete plugin.commands;