Skip to content

A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.

Add skill description metadata validation (#184)

Priyanshu Agrawal9258fd9877a2
diff --git a/.github/workflows/validate-plugin-names.yml b/.github/workflows/validate-plugin-names.yml
deleted file mode 100644
index cfd76a41e..000000000
--- a/.github/workflows/validate-plugin-names.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-name: validate-plugin-names
-
-on:
- pull_request:
- branches:
- - main
- workflow_dispatch:
-
-jobs:
- validate-plugin-names:
- name: validate-plugin-names
- runs-on: ubuntu-latest
- steps:
- - name: checkout
- uses: actions/checkout@v4
-
- - name: validate-kebab-case-plugin-names
- shell: bash
- run: |
- python3 <<'PY'
- import json
- import re
- from pathlib import Path
-
- KEBAB_CASE_PATTERN = re.compile(r"^[a-z0-9]+(?:-[a-z0-9]+)*$")
-
-
- def validate_name(name, source):
- if KEBAB_CASE_PATTERN.fullmatch(name):
- return None
- return f"{source}: '{name}' is not kebab-case"
-
-
- errors = []
-
- marketplace_path = Path(".claude-plugin/marketplace.json")
- marketplace = json.loads(marketplace_path.read_text())
- for index, plugin in enumerate(marketplace.get("plugins", [])):
- error = validate_name(plugin["name"], f"{marketplace_path} plugins[{index}].name")
- if error:
- errors.append(error)
-
- for plugin_manifest_path in sorted(Path("plugins").glob("*/.claude-plugin/plugin.json")):
- plugin_manifest = json.loads(plugin_manifest_path.read_text())
- error = validate_name(plugin_manifest["name"], f"{plugin_manifest_path} name")
- if error:
- errors.append(error)
-
- if errors:
- print("Found plugin names that are not kebab-case:")
- for error in errors:
- print(f"- {error}")
- raise SystemExit(1)
-
- print("All plugin names are kebab-case.")
- PY
diff --git a/.github/workflows/validate-repository-metadata.yml b/.github/workflows/validate-repository-metadata.yml
new file mode 100644
index 000000000..cb72e74dc
--- /dev/null
+++ b/.github/workflows/validate-repository-metadata.yml
@@ -0,0 +1,26 @@
+name: validate-repository-metadata
+
+on:
+ pull_request:
+ branches:
+ - main
+ workflow_dispatch:
+
+jobs:
+ validate-repository-metadata:
+ name: validate-repository-metadata
+ runs-on: ubuntu-latest
+ steps:
+ - name: checkout
+ uses: actions/checkout@v4
+
+ - name: setup-node
+ uses: actions/setup-node@v4
+ with:
+ node-version: 20
+
+ - name: validate-kebab-case-plugin-names
+ run: node scripts/validate-plugin-names.js
+
+ - name: validate-skill-descriptions
+ run: node scripts/validate-skill-descriptions.js
diff --git a/scripts/validate-plugin-names.js b/scripts/validate-plugin-names.js
new file mode 100644
index 000000000..ad95f8349
--- /dev/null
+++ b/scripts/validate-plugin-names.js
@@ -0,0 +1,63 @@
+#!/usr/bin/env node
+
+/**
+ * Validates that plugin names use kebab-case in all plugin metadata files.
+ */
+
+const fs = require('fs');
+const path = require('path');
+
+const ROOT = path.resolve(__dirname, '..');
+const KEBAB_CASE_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
+
+function validateName(name, source) {
+ if (KEBAB_CASE_PATTERN.test(name)) return null;
+ return `${source}: '${name}' is not kebab-case`;
+}
+
+function readJson(filePath) {
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
+}
+
+function getPluginManifestPaths() {
+ const pluginsDirectory = path.join(ROOT, 'plugins');
+ if (!fs.existsSync(pluginsDirectory)) return [];
+
+ return fs
+ .readdirSync(pluginsDirectory, { withFileTypes: true })
+ .filter((entry) => entry.isDirectory())
+ .map((entry) => path.join(pluginsDirectory, entry.name, '.claude-plugin', 'plugin.json'))
+ .filter((filePath) => fs.existsSync(filePath))
+ .sort();
+}
+
+const errors = [];
+
+const marketplacePath = path.join(ROOT, '.claude-plugin', 'marketplace.json');
+const marketplace = readJson(marketplacePath);
+for (const [index, plugin] of (marketplace.plugins || []).entries()) {
+ const error = validateName(
+ plugin.name,
+ `${path.relative(ROOT, marketplacePath)} plugins[${index}].name`
+ );
+ if (error) errors.push(error);
+}
+
+for (const pluginManifestPath of getPluginManifestPaths()) {
+ const pluginManifest = readJson(pluginManifestPath);
+ const error = validateName(
+ pluginManifest.name,
+ `${path.relative(ROOT, pluginManifestPath)} name`
+ );
+ if (error) errors.push(error);
+}
+
+if (errors.length > 0) {
+ console.log('Found plugin names that are not kebab-case:');
+ for (const error of errors) {
+ console.log(`- ${error}`);
+ }
+ process.exit(1);
+}
+
+console.log('All plugin names are kebab-case.');
diff --git a/scripts/validate-skill-descriptions.js b/scripts/validate-skill-descriptions.js
new file mode 100644
index 000000000..164d70586
--- /dev/null
+++ b/scripts/validate-skill-descriptions.js
@@ -0,0 +1,200 @@
+#!/usr/bin/env node
+
+/**
+ * Validates that skill metadata descriptions are present and under the
+ * GitHub Copilot supported limit.
+ */
+
+const fs = require('fs');
+const path = require('path');
+
+const ROOT = path.resolve(__dirname, '..');
+const MAX_DESCRIPTION_LENGTH = 1024;
+
+function walkFiles(directory) {
+ if (!fs.existsSync(directory)) return [];
+
+ const entries = fs.readdirSync(directory, { withFileTypes: true });
+ const files = [];
+
+ for (const entry of entries) {
+ if (entry.name === '.git' || entry.name === 'node_modules') continue;
+
+ const entryPath = path.join(directory, entry.name);
+ if (entry.isDirectory()) {
+ files.push(...walkFiles(entryPath));
+ } else {
+ files.push(entryPath);
+ }
+ }
+
+ return files;
+}
+
+function isSkillMetadataFile(filePath) {
+ const normalized = path.relative(ROOT, filePath).split(path.sep).join('/');
+ return (
+ normalized.includes('/skills/') &&
+ (normalized.endsWith('/SKILL.md') || normalized.endsWith('/SKILL.template.md'))
+ );
+}
+
+function getFrontmatter(content) {
+ const match = content.match(/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/);
+ if (!match) return null;
+
+ const startLine = content.slice(0, match.index).split(/\r?\n/).length;
+ return {
+ body: match[1],
+ startLine,
+ };
+}
+
+function countIndent(line) {
+ const match = line.match(/^[ \t]*/);
+ return match ? match[0].length : 0;
+}
+
+function stripBlockIndent(lines) {
+ const indents = lines
+ .filter((line) => line.trim() !== '')
+ .map((line) => countIndent(line));
+ const indent = indents.length > 0 ? Math.min(...indents) : 0;
+
+ return lines.map((line) => {
+ if (line.trim() === '') return '';
+ return line.slice(Math.min(indent, countIndent(line)));
+ });
+}
+
+function foldBlockLines(lines) {
+ let value = '';
+
+ for (let index = 0; index < lines.length; index += 1) {
+ const line = lines[index];
+ if (index > 0) {
+ const previousLine = lines[index - 1];
+ value += previousLine === '' || line === '' ? '\n' : ' ';
+ }
+ value += line;
+ }
+
+ return value;
+}
+
+function unquoteInlineValue(value) {
+ const trimmed = value.trim();
+ if (trimmed.length < 2) return trimmed;
+
+ const quote = trimmed[0];
+ if ((quote !== '"' && quote !== "'") || trimmed[trimmed.length - 1] !== quote) {
+ return trimmed;
+ }
+
+ const unquoted = trimmed.slice(1, -1);
+ if (quote === "'") {
+ return unquoted.replace(/''/g, "'");
+ }
+
+ return unquoted
+ .replace(/\\"/g, '"')
+ .replace(/\\n/g, '\n')
+ .replace(/\\t/g, '\t')
+ .replace(/\\\\/g, '\\');
+}
+
+function parseDescription(frontmatter) {
+ const lines = frontmatter.body.split(/\r?\n/);
+
+ for (let index = 0; index < lines.length; index += 1) {
+ const line = lines[index];
+ const match = line.match(/^description\s*:\s*(.*)$/);
+ if (!match) continue;
+
+ const rawValue = match[1].trim();
+ const lineNumber = frontmatter.startLine + index + 1;
+ const blockMatch = rawValue.match(/^([>|])/);
+
+ if (!blockMatch) {
+ return {
+ value: unquoteInlineValue(rawValue),
+ lineNumber,
+ };
+ }
+
+ const blockLines = [];
+ const parentIndent = countIndent(line);
+ const explicitIndentMatch = rawValue.match(/^[>|]([1-9])/);
+ let blockIndent = explicitIndentMatch
+ ? parentIndent + Number(explicitIndentMatch[1])
+ : null;
+
+ for (let blockIndex = index + 1; blockIndex < lines.length; blockIndex += 1) {
+ const blockLine = lines[blockIndex];
+ if (blockLine.trim() !== '') {
+ const lineIndent = countIndent(blockLine);
+ if (blockIndent === null) {
+ if (lineIndent <= parentIndent) break;
+ blockIndent = lineIndent;
+ } else if (lineIndent < blockIndent) {
+ break;
+ }
+ }
+ blockLines.push(blockLine);
+ }
+
+ const strippedLines = stripBlockIndent(blockLines);
+ const value =
+ blockMatch[1] === '|'
+ ? strippedLines.join('\n').trimEnd()
+ : foldBlockLines(strippedLines).trimEnd();
+
+ return {
+ value,
+ lineNumber,
+ };
+ }
+
+ return null;
+}
+
+const skillFiles = walkFiles(ROOT).filter(isSkillMetadataFile).sort();
+const errors = [];
+
+for (const filePath of skillFiles) {
+ const relativePath = path.relative(ROOT, filePath);
+ const content = fs.readFileSync(filePath, 'utf8');
+ const frontmatter = getFrontmatter(content);
+
+ if (!frontmatter) {
+ errors.push(`${relativePath}: missing YAML frontmatter`);
+ continue;
+ }
+
+ const description = parseDescription(frontmatter);
+ if (!description) {
+ errors.push(`${relativePath}: missing description in YAML frontmatter`);
+ continue;
+ }
+
+ const descriptionLength = Array.from(description.value).length;
+ if (descriptionLength >= MAX_DESCRIPTION_LENGTH) {
+ errors.push(
+ `${relativePath}:${description.lineNumber}: description is ${descriptionLength} characters; ` +
+ `must be fewer than ${MAX_DESCRIPTION_LENGTH} characters because GitHub Copilot ` +
+ `does not support longer skill descriptions`
+ );
+ }
+}
+
+if (errors.length > 0) {
+ console.log('Found invalid skill descriptions:');
+ for (const error of errors) {
+ console.log(`- ${error}`);
+ }
+ process.exit(1);
+}
+
+console.log(
+ `Validated ${skillFiles.length} skill metadata file(s); all descriptions are under ${MAX_DESCRIPTION_LENGTH} characters.`
+);