summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Pocock <mattpocockvoice@gmail.com>2026-11-19 13:34:58 +0000
committerGitHub <noreply@github.com>2026-11-19 13:34:58 +0000
commitabeeaf95660ba9e8b7c753eb38f441ca707a8823 (patch)
treeb26c597d4a8dd96a70e4823ff9a3f0b9447d9bcf
parent3a05171775a49076900759e0dd1b3ef8e2671323 (diff)
parent37209058e45b7c60b36218b7392df0ebcceb247a (diff)
Merge pull request #1455 from mattpocock/ci-frontmatter-checkHEADmain
ci: check every SKILL.md's frontmatter parses with the installer's YAML parser
-rw-r--r--.github/workflows/check.yml28
-rw-r--r--package-lock.json23
-rw-r--r--package.json6
-rw-r--r--scripts/check-frontmatter.mjs46
4 files changed, 98 insertions, 5 deletions
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 0000000..6c19e6b
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,28 @@
+name: Check
+
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ frontmatter:
+ name: SKILL.md frontmatter
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 22
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Check frontmatter
+ run: npm run check-frontmatter
diff --git a/package-lock.json b/package-lock.json
index db12f08..2787482 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,16 +1,17 @@
{
"name": "mattpocock-skills",
- "version": "0.0.0",
+ "version": "1.3.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "mattpocock-skills",
- "version": "0.0.0",
+ "version": "1.3.2",
"license": "MIT",
"devDependencies": {
"@changesets/changelog-github": "^0.7.0",
- "@changesets/cli": "^2.30.0"
+ "@changesets/cli": "^2.30.0",
+ "yaml": "^2.9.1"
}
},
"node_modules/@babel/runtime": {
@@ -1380,6 +1381,22 @@
"engines": {
"node": ">= 8"
}
+ },
+ "node_modules/yaml": {
+ "version": "2.9.1",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
+ "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "yaml": "bin.mjs"
+ },
+ "engines": {
+ "node": ">= 14.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/eemeli"
+ }
}
}
}
diff --git a/package.json b/package.json
index c5b9804..56dcdcd 100644
--- a/package.json
+++ b/package.json
@@ -11,11 +11,13 @@
"scripts": {
"changeset": "changeset",
"version": "changeset version && node scripts/sync-plugin-version.mjs",
- "check-plugin-version": "node scripts/sync-plugin-version.mjs --check"
+ "check-plugin-version": "node scripts/sync-plugin-version.mjs --check",
+ "check-frontmatter": "node scripts/check-frontmatter.mjs"
},
"devDependencies": {
"@changesets/changelog-github": "^0.7.0",
- "@changesets/cli": "^2.30.0"
+ "@changesets/cli": "^2.30.0",
+ "yaml": "^2.9.1"
},
"packageManager": "npm@10.9.4"
}
diff --git a/scripts/check-frontmatter.mjs b/scripts/check-frontmatter.mjs
new file mode 100644
index 0000000..f06a876
--- /dev/null
+++ b/scripts/check-frontmatter.mjs
@@ -0,0 +1,46 @@
+// Parses every SKILL.md's frontmatter with `yaml`, the parser the `skills`
+// installer uses, so a skill that would be skipped on install fails here first.
+import { readFileSync, readdirSync } from "node:fs";
+import { join, relative } from "node:path";
+import { parseDocument } from "yaml";
+
+const root = new URL("..", import.meta.url).pathname;
+
+function* skillFiles(dir) {
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
+ const path = join(dir, entry.name);
+ if (entry.isDirectory()) yield* skillFiles(path);
+ else if (entry.name === "SKILL.md") yield path;
+ }
+}
+
+const failures = [];
+
+for (const file of skillFiles(join(root, "skills"))) {
+ const where = relative(root, file);
+ const match = readFileSync(file, "utf8").match(/^---\r?\n([\s\S]*?)\r?\n---/);
+ if (!match) {
+ failures.push(`${where}: no frontmatter block`);
+ continue;
+ }
+ const doc = parseDocument(match[1], { strict: true, uniqueKeys: true });
+ if (doc.errors.length > 0) {
+ failures.push(`${where}: ${doc.errors[0].message.split("\n")[0]}`);
+ continue;
+ }
+ const data = doc.toJS();
+ for (const key of ["name", "description"]) {
+ if (typeof data?.[key] !== "string" || data[key].trim() === "") {
+ failures.push(`${where}: missing \`${key}\``);
+ }
+ }
+}
+
+if (failures.length > 0) {
+ console.error(failures.join("\n"));
+ console.error(
+ `\n${failures.length} SKILL.md frontmatter error(s). Quote any value containing ": " or starting with a YAML indicator character.`,
+ );
+ process.exit(1);
+}
+console.log("All SKILL.md frontmatter parses.");