diff --git a/.github/workflows/gate.yml b/.github/workflows/gate.yml index 86a3326..fc2ebaa 100644 --- a/.github/workflows/gate.yml +++ b/.github/workflows/gate.yml @@ -14,6 +14,8 @@ jobs: node-version: 22 - name: Test the gate run: node --test gate/steerloop-gate.test.mjs + - name: Validate skills and stack.json + run: node scripts/validate-skills.mjs - name: Check the pull request body env: BODY: ${{ github.event.pull_request.body }} diff --git a/README.md b/README.md index 10ccce9..57d4783 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,20 @@ git config core.hooksPath .githooks # from a clone of this repo or copy `gate/steerloop-gate.mjs` into your own tooling and call it from a `commit-msg` hook or CI step. +## Profiles + +Not every project needs fourteen skills. `stack.json` is the machine-readable list; these are the same groups as commands: + +| Profile | What it covers | Install | +| --- | --- | --- | +| core | Gates, method, deepening | `npx skills add lukavtz/steerloop --skill steerloop --skill craftloop --skill be-ambitious` | +| web | Core plus performance and a landing page | `npx skills add lukavtz/steerloop --skill steerloop --skill craftloop --skill webperf --skill landing-page-design` | +| design | Page, Figma, anti-slop pass, figures, README | `npx skills add lukavtz/steerloop --skill landing-page-design --skill figma-designer --skill hallmark --skill anatomy --skill beautify-github-readme` | +| text | English and Russian prose | `npx skills add lukavtz/steerloop --skill stop-slop --skill ru-text --skill ru-check --skill ru-score --skill humanizer-ru` | +| full | All fourteen | `npx skills add lukavtz/steerloop` | + +`npm test` validates every `SKILL.md` frontmatter and checks that `stack.json` matches the tree, so a skill cannot be added without being listed. + ## The gate | Check | Rejects | @@ -141,7 +155,9 @@ skills/craftloop/SKILL.md the method skills/craftloop/references/ security rules, loaded on demand skills/webperf/SKILL.md web performance router skills/webperf/references/ 31 recipes, one per symptom -skills/* five original, five vendored +skills/* fourteen skills, five original +scripts/validate-skills.mjs frontmatter and stack.json check +stack.json skills, profiles, origins, licenses THIRD_PARTY_LICENSES/ MIT texts for the vendored skills gate/steerloop-gate.mjs the report validator gate/steerloop-gate.test.mjs 26 tests, run by npm test diff --git a/package.json b/package.json index 553de08..fe3a6c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steerloop", - "version": "0.2.0", + "version": "0.3.0", "description": "Two agent skills that keep a coding agent on one slice: ask before coding, red-first tests, stop gates, honest reports — plus a commit gate that enforces the report.", "license": "MIT", "repository": { @@ -22,14 +22,17 @@ "steerloop-gate": "./gate/steerloop-gate.mjs" }, "scripts": { - "test": "node --test gate/steerloop-gate.test.mjs", + "test": "node --test gate/steerloop-gate.test.mjs && node scripts/validate-skills.mjs", "gate:install": "git config core.hooksPath .githooks", - "gate:check": "node gate/steerloop-gate.mjs --body-file" + "gate:check": "node gate/steerloop-gate.mjs --body-file", + "validate": "node scripts/validate-skills.mjs" }, "files": [ "skills", "gate", + "scripts", ".githooks", + "stack.json", "THIRD_PARTY_NOTICE.md", "THIRD_PARTY_LICENSES", "README.md", diff --git a/scripts/validate-skills.mjs b/scripts/validate-skills.mjs new file mode 100644 index 0000000..c14ca7f --- /dev/null +++ b/scripts/validate-skills.mjs @@ -0,0 +1,91 @@ +#!/usr/bin/env node +// Validates every skills//SKILL.md against the Agent Skills frontmatter rules, +// and checks stack.json against the tree. +// Usage: node scripts/validate-skills.mjs + +import { existsSync, readFileSync, readdirSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); +const SKILLS = join(ROOT, "skills"); +const NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/; +const LIMITS = { name: 64, description: 1024, compatibility: 500 }; + +function frontmatter(raw) { + const lines = raw.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n").split("\n"); + if (lines[0]?.trim() !== "---") return null; + const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---"); + return end < 0 ? null : parseBlock(lines.slice(1, end)); +} + +function parseBlock(lines) { + const out = {}; + for (let i = 0; i < lines.length; i += 1) { + const match = lines[i].match(/^([a-z0-9-]+):\s*(.*)$/); + if (!match) continue; + const key = match[1]; + const rest = match[2]; + if (rest === ">" || rest === "|") { + const parts = []; + while (i + 1 < lines.length && /^\s+\S/.test(lines[i + 1])) parts.push(lines[++i].trim()); + out[key] = parts.join(" "); + } else { + out[key] = rest.replace(/^["']|["']$/g, "").trim(); + } + } + return out; +} + +function skillProblems(dir) { + const file = join(SKILLS, dir, "SKILL.md"); + if (!existsSync(file)) return [`${dir}: SKILL.md is missing`]; + const data = frontmatter(readFileSync(file, "utf8")); + if (!data) return [`${dir}: no frontmatter block`]; + const problems = []; + if (!data.name) problems.push(`${dir}: name is missing`); + else if (data.name !== dir) problems.push(`${dir}: name "${data.name}" does not match the folder`); + else if (!NAME.test(data.name)) problems.push(`${dir}: name must be lowercase words joined by single hyphens`); + if (!data.description) problems.push(`${dir}: description is missing`); + for (const [key, max] of Object.entries(LIMITS)) { + if (data[key] && data[key].length > max) problems.push(`${dir}: ${key} is ${data[key].length} chars, limit ${max}`); + } + return problems; +} + +function listingProblems(skills, stack) { + const listed = Object.keys(stack.skills ?? {}); + const missingFromStack = skills.filter((name) => !listed.includes(name)).map((n) => `stack.json: ${n} is not listed in skills`); + const missingFromTree = listed.filter((name) => !skills.includes(name)).map((n) => `stack.json: ${n} has no skills/${n}/SKILL.md`); + return [...missingFromStack, ...missingFromTree]; +} + +function profileProblems(skills, stack) { + return Object.entries(stack.profiles ?? {}).flatMap(([profile, names]) => + names.filter((name) => !skills.includes(name)).map((name) => `stack.json: profile ${profile} names unknown skill ${name}`), + ); +} + +function stackProblems(skills) { + const file = join(ROOT, "stack.json"); + if (!existsSync(file)) return ["stack.json is missing"]; + const stack = JSON.parse(readFileSync(file, "utf8")); + return [...listingProblems(skills, stack), ...profileProblems(skills, stack)]; +} + +function main() { + const skills = readdirSync(SKILLS, { withFileTypes: true }) + .filter((entry) => entry.isDirectory()) + .map((entry) => entry.name) + .sort(); + const problems = [...skills.flatMap(skillProblems), ...stackProblems(skills)]; + if (problems.length === 0) { + console.log(`skills: ${skills.length} valid, stack.json consistent`); + return 0; + } + for (const problem of problems) console.error(` - ${problem}`); + console.error(`\n${problems.length} problem(s)`); + return 1; +} + +process.exit(main()); \ No newline at end of file diff --git a/stack.json b/stack.json new file mode 100644 index 0000000..98a4f31 --- /dev/null +++ b/stack.json @@ -0,0 +1,45 @@ +{ + "name": "steerloop", + "version": "0.3.0", + "license": "MIT", + "install": "npx skills add lukavtz/steerloop", + "gate": "git config core.hooksPath .githooks", + "profiles": { + "core": ["steerloop", "craftloop", "be-ambitious"], + "web": ["steerloop", "craftloop", "webperf", "landing-page-design"], + "design": ["landing-page-design", "figma-designer", "hallmark", "anatomy", "beautify-github-readme"], + "text": ["stop-slop", "ru-text", "ru-check", "ru-score", "humanizer-ru"], + "full": [ + "steerloop", + "craftloop", + "be-ambitious", + "webperf", + "landing-page-design", + "figma-designer", + "hallmark", + "anatomy", + "beautify-github-readme", + "stop-slop", + "ru-text", + "ru-check", + "ru-score", + "humanizer-ru" + ] + }, + "skills": { + "steerloop": { "origin": "original", "license": "MIT" }, + "craftloop": { "origin": "original", "license": "MIT" }, + "webperf": { "origin": "original", "license": "MIT" }, + "landing-page-design": { "origin": "elayadesign/ai-design-skills@456d9e0", "license": "MIT" }, + "figma-designer": { "origin": "elayadesign/ai-design-skills@456d9e0", "license": "MIT" }, + "be-ambitious": { "origin": "DannyMac180/skills@7dc63b7", "license": "MIT" }, + "hallmark": { "origin": "nutlope/hallmark@407fa68", "license": "MIT" }, + "stop-slop": { "origin": "hardikpandya/stop-slop@8da1f03", "license": "MIT" }, + "anatomy": { "origin": "wheresryan22/anatomy@1482e84", "license": "MIT" }, + "beautify-github-readme": { "origin": "oil-oil/beautify-github-readme@d6562a5", "license": "MIT" }, + "ru-text": { "origin": "talkstream/ru-text@e398aec", "license": "MIT" }, + "ru-check": { "origin": "talkstream/ru-text@e398aec", "license": "MIT" }, + "ru-score": { "origin": "talkstream/ru-text@e398aec", "license": "MIT" }, + "humanizer-ru": { "origin": "ilyautov/humanizer-ru@b6df5d9", "license": "MIT" } + } +} \ No newline at end of file