mirror of
https://github.com/github/awesome-copilot.git
synced 2026-03-12 12:15:12 +00:00
fix: copilot comments
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
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";
|
import { parseFrontmatter } from "./yaml-parser.mjs";
|
||||||
|
|
||||||
|
const PROMPTS_DIR = path.join(ROOT_FOLDER, "prompts");
|
||||||
/**
|
/**
|
||||||
* Convert a prompt file to a skill folder
|
* Convert a prompt file to a skill folder
|
||||||
* @param {string} promptFilePath - Full path to the prompt file
|
* @param {string} promptFilePath - Full path to the prompt file
|
||||||
@@ -13,7 +14,7 @@ import { parseFrontmatter } from "./yaml-parser.mjs";
|
|||||||
function convertPromptToSkill(promptFilePath) {
|
function convertPromptToSkill(promptFilePath) {
|
||||||
const filename = path.basename(promptFilePath);
|
const filename = path.basename(promptFilePath);
|
||||||
const baseName = filename.replace(".prompt.md", "");
|
const baseName = filename.replace(".prompt.md", "");
|
||||||
|
|
||||||
console.log(`\nConverting: ${baseName}`);
|
console.log(`\nConverting: ${baseName}`);
|
||||||
|
|
||||||
// Parse the prompt file frontmatter
|
// Parse the prompt file frontmatter
|
||||||
@@ -44,7 +45,7 @@ function convertPromptToSkill(promptFilePath) {
|
|||||||
// Build SKILL.md content
|
// Build SKILL.md content
|
||||||
const skillContent = `---
|
const skillContent = `---
|
||||||
name: ${skillFrontmatter.name}
|
name: ${skillFrontmatter.name}
|
||||||
description: '${skillFrontmatter.description.replace(/'/g, "'\\''")}'
|
description: '${skillFrontmatter.description.replace(/'/g, "'''")}'
|
||||||
---
|
---
|
||||||
|
|
||||||
${mainContent}
|
${mainContent}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { PLUGINS_DIR } from "./constants.mjs";
|
|||||||
function updatePluginManifest(pluginJsonPath) {
|
function updatePluginManifest(pluginJsonPath) {
|
||||||
const pluginDir = path.dirname(path.dirname(path.dirname(pluginJsonPath)));
|
const pluginDir = path.dirname(path.dirname(path.dirname(pluginJsonPath)));
|
||||||
const pluginName = path.basename(pluginDir);
|
const pluginName = path.basename(pluginDir);
|
||||||
|
|
||||||
console.log(`\nProcessing plugin: ${pluginName}`);
|
console.log(`\nProcessing plugin: ${pluginName}`);
|
||||||
|
|
||||||
// Read and parse plugin.json
|
// Read and parse plugin.json
|
||||||
@@ -34,20 +34,33 @@ function updatePluginManifest(pluginJsonPath) {
|
|||||||
const commandCount = plugin.commands.length;
|
const commandCount = plugin.commands.length;
|
||||||
console.log(` Found ${commandCount} command(s) to convert`);
|
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/"
|
// 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");
|
const basename = path.basename(cmd, ".md");
|
||||||
return `./skills/${basename}/`;
|
return `./skills/${basename}/`;
|
||||||
});
|
});
|
||||||
|
// Initialize skills array if it doesn't exist or is not an array
|
||||||
// Initialize skills array if it doesn't exist
|
if (!Array.isArray(plugin.skills)) {
|
||||||
if (!plugin.skills) {
|
|
||||||
plugin.skills = [];
|
plugin.skills = [];
|
||||||
}
|
}
|
||||||
|
// Add converted commands to skills array, de-duplicating entries
|
||||||
// Add converted commands to skills array
|
const allSkills = new Set(plugin.skills);
|
||||||
plugin.skills.push(...skills);
|
for (const skillPath of skills) {
|
||||||
|
allSkills.add(skillPath);
|
||||||
|
}
|
||||||
|
plugin.skills = Array.from(allSkills);
|
||||||
|
|
||||||
// Remove commands field
|
// Remove commands field
|
||||||
delete plugin.commands;
|
delete plugin.commands;
|
||||||
|
|||||||
Reference in New Issue
Block a user