mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
refactor: migrate plugins to Claude Code spec format
- Move plugin manifests from .github/plugin/ to .claude-plugin/ - Convert items[] to Claude Code spec fields (agents, commands, skills) - Rename tags to keywords, drop display/featured/instructions from plugins - Delete all symlinks and materialized files from plugin directories - Add eng/materialize-plugins.mjs to copy source files into plugin dirs at publish time - Add .github/workflows/publish.yml for staged->main publishing - Update CI triggers to target staged branch - Update validation, creation, marketplace, and README generation scripts - Update CONTRIBUTING.md and AGENTS.md documentation - Include all new content from main (polyglot-test-agent, gem-browser-tester, fabric-lakehouse, fluentui-blazor, quasi-coder, transloadit-media-processing, make-repo-contribution hardening, website logo/gradient changes) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,7 @@ function prompt(question) {
|
||||
|
||||
function parseArgs() {
|
||||
const args = process.argv.slice(2);
|
||||
const out = { name: undefined, tags: undefined };
|
||||
const out = { name: undefined, keywords: undefined };
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const a = args[i];
|
||||
@@ -29,22 +29,22 @@ function parseArgs() {
|
||||
i++;
|
||||
} else if (a.startsWith("--name=")) {
|
||||
out.name = a.split("=")[1];
|
||||
} else if (a === "--tags" || a === "-t") {
|
||||
out.tags = args[i + 1];
|
||||
} else if (a === "--keywords" || a === "--tags" || a === "-t") {
|
||||
out.keywords = args[i + 1];
|
||||
i++;
|
||||
} else if (a.startsWith("--tags=")) {
|
||||
out.tags = a.split("=")[1];
|
||||
} else if (a.startsWith("--keywords=") || a.startsWith("--tags=")) {
|
||||
out.keywords = a.split("=")[1];
|
||||
} else if (!a.startsWith("-") && !out.name) {
|
||||
// first positional -> name
|
||||
out.name = a;
|
||||
} else if (!a.startsWith("-") && out.name && !out.tags) {
|
||||
// second positional -> tags
|
||||
out.tags = a;
|
||||
} else if (!a.startsWith("-") && out.name && !out.keywords) {
|
||||
// second positional -> keywords
|
||||
out.keywords = a;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(out.tags)) {
|
||||
out.tags = out.tags.join(",");
|
||||
if (Array.isArray(out.keywords)) {
|
||||
out.keywords = out.keywords.join(",");
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -108,23 +108,23 @@ async function createPlugin() {
|
||||
description = defaultDescription;
|
||||
}
|
||||
|
||||
// Get tags
|
||||
let tags = [];
|
||||
let tagInput = parsed.tags;
|
||||
if (!tagInput) {
|
||||
tagInput = await prompt(
|
||||
"Tags (comma-separated, or press Enter for defaults): "
|
||||
// Get keywords
|
||||
let keywords = [];
|
||||
let keywordInput = parsed.keywords;
|
||||
if (!keywordInput) {
|
||||
keywordInput = await prompt(
|
||||
"Keywords (comma-separated, or press Enter for defaults): "
|
||||
);
|
||||
}
|
||||
|
||||
if (tagInput && tagInput.toString().trim()) {
|
||||
tags = tagInput
|
||||
if (keywordInput && keywordInput.toString().trim()) {
|
||||
keywords = keywordInput
|
||||
.toString()
|
||||
.split(",")
|
||||
.map((tag) => tag.trim())
|
||||
.filter((tag) => tag);
|
||||
.map((kw) => kw.trim())
|
||||
.filter((kw) => kw);
|
||||
} else {
|
||||
tags = pluginId.split("-").slice(0, 3);
|
||||
keywords = pluginId.split("-").slice(0, 3);
|
||||
}
|
||||
|
||||
// Create directory structure
|
||||
@@ -136,11 +136,10 @@ async function createPlugin() {
|
||||
name: pluginId,
|
||||
description,
|
||||
version: "1.0.0",
|
||||
keywords,
|
||||
author: { name: "Awesome Copilot Community" },
|
||||
repository: "https://github.com/github/awesome-copilot",
|
||||
license: "MIT",
|
||||
tags,
|
||||
items: [],
|
||||
};
|
||||
|
||||
fs.writeFileSync(
|
||||
@@ -177,7 +176,7 @@ MIT
|
||||
console.log(`\n✅ Created plugin: ${pluginDir}`);
|
||||
console.log("\n📝 Next steps:");
|
||||
console.log(`1. Add agents, prompts, or instructions to plugins/${pluginId}/`);
|
||||
console.log(`2. Update plugins/${pluginId}/.github/plugin/plugin.json to list your items`);
|
||||
console.log(`2. Update plugins/${pluginId}/.github/plugin/plugin.json with your metadata`);
|
||||
console.log(`3. Edit plugins/${pluginId}/README.md to describe your plugin`);
|
||||
console.log("4. Run 'npm run build' to regenerate documentation");
|
||||
} catch (error) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import path from "path";
|
||||
import { ROOT_FOLDER } from "./constants.mjs";
|
||||
|
||||
const PLUGINS_DIR = path.join(ROOT_FOLDER, "plugins");
|
||||
const MARKETPLACE_FILE = path.join(ROOT_FOLDER, ".github", "plugin", "marketplace.json");
|
||||
const MARKETPLACE_FILE = path.join(ROOT_FOLDER, ".github/plugin", "marketplace.json");
|
||||
|
||||
/**
|
||||
* Read plugin metadata from plugin.json file
|
||||
@@ -13,7 +13,7 @@ const MARKETPLACE_FILE = path.join(ROOT_FOLDER, ".github", "plugin", "marketplac
|
||||
* @returns {object|null} - Plugin metadata or null if not found
|
||||
*/
|
||||
function readPluginMetadata(pluginDir) {
|
||||
const pluginJsonPath = path.join(pluginDir, ".github", "plugin", "plugin.json");
|
||||
const pluginJsonPath = path.join(pluginDir, ".github/plugin", "plugin.json");
|
||||
|
||||
if (!fs.existsSync(pluginJsonPath)) {
|
||||
console.warn(`Warning: No plugin.json found for ${path.basename(pluginDir)}`);
|
||||
|
||||
@@ -488,7 +488,7 @@ function generatePluginsData(gitDates) {
|
||||
const plugins = [];
|
||||
|
||||
if (!fs.existsSync(PLUGINS_DIR)) {
|
||||
return plugins;
|
||||
return { items: [], filters: { tags: [] } };
|
||||
}
|
||||
|
||||
const pluginDirs = fs.readdirSync(PLUGINS_DIR, { withFileTypes: true })
|
||||
@@ -496,7 +496,7 @@ function generatePluginsData(gitDates) {
|
||||
|
||||
for (const dir of pluginDirs) {
|
||||
const pluginDir = path.join(PLUGINS_DIR, dir.name);
|
||||
const jsonPath = path.join(pluginDir, ".github", "plugin", "plugin.json");
|
||||
const jsonPath = path.join(pluginDir, ".github/plugin", "plugin.json");
|
||||
|
||||
if (!fs.existsSync(jsonPath)) continue;
|
||||
|
||||
@@ -505,17 +505,25 @@ function generatePluginsData(gitDates) {
|
||||
const relPath = `plugins/${dir.name}`;
|
||||
const dates = gitDates[relPath] || gitDates[`${relPath}/`] || {};
|
||||
|
||||
// Build items list from spec fields (agents, commands, skills)
|
||||
const items = [
|
||||
...(data.agents || []).map(p => ({ kind: "agent", path: p })),
|
||||
...(data.commands || []).map(p => ({ kind: "prompt", path: p })),
|
||||
...(data.skills || []).map(p => ({ kind: "skill", path: p })),
|
||||
];
|
||||
|
||||
const tags = data.keywords || data.tags || [];
|
||||
|
||||
plugins.push({
|
||||
id: dir.name,
|
||||
name: data.name || dir.name,
|
||||
description: data.description || "",
|
||||
path: relPath,
|
||||
tags: data.tags || [],
|
||||
featured: data.featured || false,
|
||||
itemCount: data.items ? data.items.length : 0,
|
||||
items: data.items || [],
|
||||
tags: tags,
|
||||
itemCount: items.length,
|
||||
items: items,
|
||||
lastUpdated: dates.lastModified || null,
|
||||
searchText: `${data.name || dir.name} ${data.description || ""} ${(data.tags || []).join(" ")}`.toLowerCase(),
|
||||
searchText: `${data.name || dir.name} ${data.description || ""} ${tags.join(" ")}`.toLowerCase(),
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn(`Failed to parse plugin: ${dir.name}`, e.message);
|
||||
@@ -525,11 +533,7 @@ function generatePluginsData(gitDates) {
|
||||
// Collect all unique tags
|
||||
const allTags = [...new Set(plugins.flatMap(p => p.tags))].sort();
|
||||
|
||||
const sortedPlugins = plugins.sort((a, b) => {
|
||||
if (a.featured && !b.featured) return -1;
|
||||
if (!a.featured && b.featured) return 1;
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
const sortedPlugins = plugins.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
return {
|
||||
items: sortedPlugins,
|
||||
|
||||
167
eng/materialize-plugins.mjs
Normal file
167
eng/materialize-plugins.mjs
Normal file
@@ -0,0 +1,167 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { ROOT_FOLDER } from "./constants.mjs";
|
||||
|
||||
const PLUGINS_DIR = path.join(ROOT_FOLDER, "plugins");
|
||||
|
||||
/**
|
||||
* Recursively copy a directory.
|
||||
*/
|
||||
function copyDirRecursive(src, dest) {
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
copyDirRecursive(srcPath, destPath);
|
||||
} else {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a plugin-relative path to the repo-root source file.
|
||||
*
|
||||
* ./agents/foo.md → ROOT/agents/foo.agent.md
|
||||
* ./commands/bar.md → ROOT/prompts/bar.prompt.md
|
||||
* ./skills/baz/ → ROOT/skills/baz/
|
||||
*/
|
||||
function resolveSource(relPath) {
|
||||
const basename = path.basename(relPath, ".md");
|
||||
if (relPath.startsWith("./agents/")) {
|
||||
return path.join(ROOT_FOLDER, "agents", `${basename}.agent.md`);
|
||||
}
|
||||
if (relPath.startsWith("./commands/")) {
|
||||
return path.join(ROOT_FOLDER, "prompts", `${basename}.prompt.md`);
|
||||
}
|
||||
if (relPath.startsWith("./skills/")) {
|
||||
// Strip trailing slash and get the skill folder name
|
||||
const skillName = relPath.replace(/^\.\/skills\//, "").replace(/\/$/, "");
|
||||
return path.join(ROOT_FOLDER, "skills", skillName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function materializePlugins() {
|
||||
console.log("Materializing plugin files...\n");
|
||||
|
||||
if (!fs.existsSync(PLUGINS_DIR)) {
|
||||
console.error(`Error: Plugins directory not found at ${PLUGINS_DIR}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const pluginDirs = fs.readdirSync(PLUGINS_DIR, { withFileTypes: true })
|
||||
.filter(entry => entry.isDirectory())
|
||||
.map(entry => entry.name)
|
||||
.sort();
|
||||
|
||||
let totalAgents = 0;
|
||||
let totalCommands = 0;
|
||||
let totalSkills = 0;
|
||||
let warnings = 0;
|
||||
let errors = 0;
|
||||
|
||||
for (const dirName of pluginDirs) {
|
||||
const pluginPath = path.join(PLUGINS_DIR, dirName);
|
||||
const pluginJsonPath = path.join(pluginPath, ".github/plugin", "plugin.json");
|
||||
|
||||
if (!fs.existsSync(pluginJsonPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let metadata;
|
||||
try {
|
||||
metadata = JSON.parse(fs.readFileSync(pluginJsonPath, "utf8"));
|
||||
} catch (err) {
|
||||
console.error(`Error: Failed to parse ${pluginJsonPath}: ${err.message}`);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const pluginName = metadata.name || dirName;
|
||||
|
||||
// Process agents
|
||||
if (Array.isArray(metadata.agents)) {
|
||||
for (const relPath of metadata.agents) {
|
||||
const src = resolveSource(relPath);
|
||||
if (!src) {
|
||||
console.warn(` ⚠ ${pluginName}: Unknown path format: ${relPath}`);
|
||||
warnings++;
|
||||
continue;
|
||||
}
|
||||
if (!fs.existsSync(src)) {
|
||||
console.warn(` ⚠ ${pluginName}: Source not found: ${src}`);
|
||||
warnings++;
|
||||
continue;
|
||||
}
|
||||
const dest = path.join(pluginPath, relPath.replace(/^\.\//, ""));
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
totalAgents++;
|
||||
}
|
||||
}
|
||||
|
||||
// Process commands
|
||||
if (Array.isArray(metadata.commands)) {
|
||||
for (const relPath of metadata.commands) {
|
||||
const src = resolveSource(relPath);
|
||||
if (!src) {
|
||||
console.warn(` ⚠ ${pluginName}: Unknown path format: ${relPath}`);
|
||||
warnings++;
|
||||
continue;
|
||||
}
|
||||
if (!fs.existsSync(src)) {
|
||||
console.warn(` ⚠ ${pluginName}: Source not found: ${src}`);
|
||||
warnings++;
|
||||
continue;
|
||||
}
|
||||
const dest = path.join(pluginPath, relPath.replace(/^\.\//, ""));
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
totalCommands++;
|
||||
}
|
||||
}
|
||||
|
||||
// Process skills
|
||||
if (Array.isArray(metadata.skills)) {
|
||||
for (const relPath of metadata.skills) {
|
||||
const src = resolveSource(relPath);
|
||||
if (!src) {
|
||||
console.warn(` ⚠ ${pluginName}: Unknown path format: ${relPath}`);
|
||||
warnings++;
|
||||
continue;
|
||||
}
|
||||
if (!fs.existsSync(src) || !fs.statSync(src).isDirectory()) {
|
||||
console.warn(` ⚠ ${pluginName}: Source directory not found: ${src}`);
|
||||
warnings++;
|
||||
continue;
|
||||
}
|
||||
const dest = path.join(pluginPath, relPath.replace(/^\.\//, "").replace(/\/$/, ""));
|
||||
copyDirRecursive(src, dest);
|
||||
totalSkills++;
|
||||
}
|
||||
}
|
||||
|
||||
const counts = [];
|
||||
if (metadata.agents?.length) counts.push(`${metadata.agents.length} agents`);
|
||||
if (metadata.commands?.length) counts.push(`${metadata.commands.length} commands`);
|
||||
if (metadata.skills?.length) counts.push(`${metadata.skills.length} skills`);
|
||||
if (counts.length) {
|
||||
console.log(`✓ ${pluginName}: ${counts.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nDone. Copied ${totalAgents} agents, ${totalCommands} commands, ${totalSkills} skills.`);
|
||||
if (warnings > 0) {
|
||||
console.log(`${warnings} warning(s).`);
|
||||
}
|
||||
if (errors > 0) {
|
||||
console.error(`${errors} error(s).`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
materializePlugins();
|
||||
@@ -710,7 +710,7 @@ function generateUnifiedModeSection(cfg) {
|
||||
* Read and parse a plugin.json file from a plugin directory.
|
||||
*/
|
||||
function readPluginJson(pluginDir) {
|
||||
const jsonPath = path.join(pluginDir, ".github", "plugin", "plugin.json");
|
||||
const jsonPath = path.join(pluginDir, ".github/plugin", "plugin.json");
|
||||
if (!fs.existsSync(jsonPath)) return null;
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(jsonPath, "utf-8"));
|
||||
@@ -783,13 +783,13 @@ function generatePluginsSection(pluginsDir) {
|
||||
const description = formatTableCell(
|
||||
plugin.description || "No description"
|
||||
);
|
||||
const itemCount = plugin.items ? plugin.items.length : 0;
|
||||
const tags = plugin.tags ? plugin.tags.join(", ") : "";
|
||||
const itemCount = (plugin.agents || []).length + (plugin.commands || []).length + (plugin.skills || []).length;
|
||||
const keywords = plugin.keywords ? plugin.keywords.join(", ") : "";
|
||||
|
||||
const link = `../plugins/${dir}/README.md`;
|
||||
const displayName = isFeatured ? `⭐ ${name}` : name;
|
||||
|
||||
pluginsContent += `| [${displayName}](${link}) | ${description} | ${itemCount} items | ${tags} |\n`;
|
||||
pluginsContent += `| [${displayName}](${link}) | ${description} | ${itemCount} items | ${keywords} |\n`;
|
||||
}
|
||||
|
||||
return `${TEMPLATES.pluginsSection}\n${TEMPLATES.pluginsUsage}\n\n${pluginsContent}`;
|
||||
@@ -826,8 +826,8 @@ function generateFeaturedPluginsSection(pluginsDir) {
|
||||
const description = formatTableCell(
|
||||
plugin.description || "No description"
|
||||
);
|
||||
const tags = plugin.tags ? plugin.tags.join(", ") : "";
|
||||
const itemCount = plugin.items ? plugin.items.length : 0;
|
||||
const keywords = plugin.keywords ? plugin.keywords.join(", ") : "";
|
||||
const itemCount = (plugin.agents || []).length + (plugin.commands || []).length + (plugin.skills || []).length;
|
||||
|
||||
return {
|
||||
dir,
|
||||
@@ -835,7 +835,7 @@ function generateFeaturedPluginsSection(pluginsDir) {
|
||||
pluginId: name,
|
||||
name,
|
||||
description,
|
||||
tags,
|
||||
keywords,
|
||||
itemCount,
|
||||
};
|
||||
},
|
||||
@@ -861,10 +861,10 @@ function generateFeaturedPluginsSection(pluginsDir) {
|
||||
|
||||
// Generate table rows for each featured plugin
|
||||
for (const entry of featuredPlugins) {
|
||||
const { dir, name, description, tags, itemCount } = entry;
|
||||
const { dir, name, description, keywords, itemCount } = entry;
|
||||
const readmeLink = `plugins/${dir}/README.md`;
|
||||
|
||||
featuredContent += `| [${name}](${readmeLink}) | ${description} | ${itemCount} items | ${tags} |\n`;
|
||||
featuredContent += `| [${name}](${readmeLink}) | ${description} | ${itemCount} items | ${keywords} |\n`;
|
||||
}
|
||||
|
||||
return `${TEMPLATES.featuredPluginsSection}\n\n${featuredContent}`;
|
||||
|
||||
@@ -6,8 +6,6 @@ import { ROOT_FOLDER } from "./constants.mjs";
|
||||
|
||||
const PLUGINS_DIR = path.join(ROOT_FOLDER, "plugins");
|
||||
|
||||
const VALID_ITEM_KINDS = ["prompt", "agent", "instruction", "skill", "hook"];
|
||||
|
||||
// Validation functions
|
||||
function validateName(name, folderName) {
|
||||
const errors = [];
|
||||
@@ -44,82 +42,74 @@ function validateVersion(version) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateTags(tags) {
|
||||
if (tags === undefined) return null;
|
||||
if (!Array.isArray(tags)) {
|
||||
return "tags must be an array";
|
||||
function validateKeywords(keywords) {
|
||||
if (keywords === undefined) return null;
|
||||
if (!Array.isArray(keywords)) {
|
||||
return "keywords must be an array";
|
||||
}
|
||||
if (tags.length > 10) {
|
||||
return "maximum 10 tags allowed";
|
||||
if (keywords.length > 10) {
|
||||
return "maximum 10 keywords allowed";
|
||||
}
|
||||
for (const tag of tags) {
|
||||
if (typeof tag !== "string") {
|
||||
return "all tags must be strings";
|
||||
for (const keyword of keywords) {
|
||||
if (typeof keyword !== "string") {
|
||||
return "all keywords must be strings";
|
||||
}
|
||||
if (!/^[a-z0-9-]+$/.test(tag)) {
|
||||
return `tag "${tag}" must contain only lowercase letters, numbers, and hyphens`;
|
||||
if (!/^[a-z0-9-]+$/.test(keyword)) {
|
||||
return `keyword "${keyword}" must contain only lowercase letters, numbers, and hyphens`;
|
||||
}
|
||||
if (tag.length < 1 || tag.length > 30) {
|
||||
return `tag "${tag}" must be between 1 and 30 characters`;
|
||||
if (keyword.length < 1 || keyword.length > 30) {
|
||||
return `keyword "${keyword}" must be between 1 and 30 characters`;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateFeatured(featured) {
|
||||
if (featured === undefined) return null;
|
||||
if (typeof featured !== "boolean") {
|
||||
return "featured must be a boolean";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateDisplay(display) {
|
||||
if (display === undefined) return null;
|
||||
if (typeof display !== "object" || Array.isArray(display) || display === null) {
|
||||
return "display must be an object";
|
||||
}
|
||||
if (display.ordering !== undefined) {
|
||||
if (!["manual", "alpha"].includes(display.ordering)) {
|
||||
return "display.ordering must be 'manual' or 'alpha'";
|
||||
}
|
||||
}
|
||||
if (display.show_badge !== undefined) {
|
||||
if (typeof display.show_badge !== "boolean") {
|
||||
return "display.show_badge must be a boolean";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateItems(items) {
|
||||
if (items === undefined) return [];
|
||||
function validateSpecPaths(plugin) {
|
||||
const errors = [];
|
||||
if (!Array.isArray(items)) {
|
||||
errors.push("items must be an array");
|
||||
return errors;
|
||||
}
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (!item || typeof item !== "object") {
|
||||
errors.push(`items[${i}] must be an object`);
|
||||
const specs = {
|
||||
agents: { prefix: "./agents/", suffix: ".md", repoDir: "agents", repoSuffix: ".agent.md" },
|
||||
commands: { prefix: "./commands/", suffix: ".md", repoDir: "prompts", repoSuffix: ".prompt.md" },
|
||||
skills: { prefix: "./skills/", suffix: "/", repoDir: "skills", repoFile: "SKILL.md" },
|
||||
};
|
||||
|
||||
for (const [field, spec] of Object.entries(specs)) {
|
||||
const arr = plugin[field];
|
||||
if (arr === undefined) continue;
|
||||
if (!Array.isArray(arr)) {
|
||||
errors.push(`${field} must be an array`);
|
||||
continue;
|
||||
}
|
||||
if (!item.path || typeof item.path !== "string") {
|
||||
errors.push(`items[${i}] must have a path string`);
|
||||
}
|
||||
if (!item.kind || typeof item.kind !== "string") {
|
||||
errors.push(`items[${i}] must have a kind string`);
|
||||
} else if (!VALID_ITEM_KINDS.includes(item.kind)) {
|
||||
errors.push(
|
||||
`items[${i}] kind must be one of: ${VALID_ITEM_KINDS.join(", ")}`
|
||||
);
|
||||
}
|
||||
// Validate referenced path exists relative to repo root
|
||||
if (item.path && typeof item.path === "string") {
|
||||
const filePath = path.join(ROOT_FOLDER, item.path);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
errors.push(`items[${i}] file does not exist: ${item.path}`);
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const p = arr[i];
|
||||
if (typeof p !== "string") {
|
||||
errors.push(`${field}[${i}] must be a string`);
|
||||
continue;
|
||||
}
|
||||
if (!p.startsWith("./")) {
|
||||
errors.push(`${field}[${i}] must start with "./"`);
|
||||
continue;
|
||||
}
|
||||
if (!p.startsWith(spec.prefix)) {
|
||||
errors.push(`${field}[${i}] must start with "${spec.prefix}"`);
|
||||
continue;
|
||||
}
|
||||
if (!p.endsWith(spec.suffix)) {
|
||||
errors.push(`${field}[${i}] must end with "${spec.suffix}"`);
|
||||
continue;
|
||||
}
|
||||
// Validate the source file exists at repo root
|
||||
const basename = p.slice(spec.prefix.length, p.length - spec.suffix.length);
|
||||
if (field === "skills") {
|
||||
const skillDir = path.join(ROOT_FOLDER, spec.repoDir, basename);
|
||||
const skillFile = path.join(skillDir, spec.repoFile);
|
||||
if (!fs.existsSync(skillFile)) {
|
||||
errors.push(`${field}[${i}] source not found: ${spec.repoDir}/${basename}/SKILL.md`);
|
||||
}
|
||||
} else {
|
||||
const srcFile = path.join(ROOT_FOLDER, spec.repoDir, basename + spec.repoSuffix);
|
||||
if (!fs.existsSync(srcFile)) {
|
||||
errors.push(`${field}[${i}] source not found: ${spec.repoDir}/${basename}${spec.repoSuffix}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +121,7 @@ function validatePlugin(folderName) {
|
||||
const errors = [];
|
||||
|
||||
// Rule 1: Must have .github/plugin/plugin.json
|
||||
const pluginJsonPath = path.join(pluginDir, ".github", "plugin", "plugin.json");
|
||||
const pluginJsonPath = path.join(pluginDir, ".github/plugin", "plugin.json");
|
||||
if (!fs.existsSync(pluginJsonPath)) {
|
||||
errors.push("missing required file: .github/plugin/plugin.json");
|
||||
return errors;
|
||||
@@ -163,21 +153,13 @@ function validatePlugin(folderName) {
|
||||
const versionError = validateVersion(plugin.version);
|
||||
if (versionError) errors.push(versionError);
|
||||
|
||||
// Rule 5: tags
|
||||
const tagsError = validateTags(plugin.tags);
|
||||
if (tagsError) errors.push(tagsError);
|
||||
// Rule 5: keywords (or tags for backward compat)
|
||||
const keywordsError = validateKeywords(plugin.keywords ?? plugin.tags);
|
||||
if (keywordsError) errors.push(keywordsError);
|
||||
|
||||
// Rule 8: featured
|
||||
const featuredError = validateFeatured(plugin.featured);
|
||||
if (featuredError) errors.push(featuredError);
|
||||
|
||||
// Rule 9: display
|
||||
const displayError = validateDisplay(plugin.display);
|
||||
if (displayError) errors.push(displayError);
|
||||
|
||||
// Rule 6 & 7: items
|
||||
const itemErrors = validateItems(plugin.items);
|
||||
errors.push(...itemErrors);
|
||||
// Rule 6: agents, commands, skills paths
|
||||
const specErrors = validateSpecPaths(plugin);
|
||||
errors.push(...specErrors);
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user