From 172f576a5b2cc059454f8fa2aa8df507f34c5a80 Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Fri, 27 Nov 2026 13:31:30 +0800 Subject: [PATCH 1/2] skills lint: check the repo's CHANGELOG.md against Keep a Changelog 1.1 The CHANGELOG.md beside the skill (in its folder, else at the repo's top) is checked by the format's changelogWarnings, with the repo's v* tags, so a release heading that isn't ## [X.Y.Z] - YYYY-MM-DD, more than 6 bullets, an unknown group or a tag with no section is a warning. It never fails the lint. Co-authored-by: Pointman Co-authored-by: Claude --- lib/skill-check.gen.js | 66 ++++++++++++++++++++++++++++++++-- lib/skill-lint.js | 17 +++++++-- scripts/skill-check-bundle.mjs | 2 +- test/skill-lint.test.js | 19 ++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/lib/skill-check.gen.js b/lib/skill-check.gen.js index 8c976af..b7df17a 100644 --- a/lib/skill-check.gen.js +++ b/lib/skill-check.gen.js @@ -1,7 +1,7 @@ // Generated by scripts/skill-check-bundle.mjs: don't edit, run it again. // The published half of Spacesheep's skill checker (the format: SKILL.md, spacesheep.yaml's // shape, the folder's bytes and the hash), built from spacesheep-dev/spacesheep at -// 01a2df10810250b6516613ec1bc8b7f5d1683bc1 (2026-11-17, the last commit to change these files): +// 9405d37eaf1c10942b3f4fae3f56f9be33fecee4 (2026-11-27, the last commit to change these files): // shared/skill-files.ts // shared/skill-format.ts // with yaml 2.9.0, whose licence follows: @@ -43,6 +43,7 @@ __export(skill_check_entry_exports, { DECLARED_KEYS: () => DECLARED_KEYS, SKILL_FILE_NAMES: () => SKILL_FILE_NAMES, SKILL_FORMAT_LIMITS: () => SKILL_FORMAT_LIMITS, + changelogWarnings: () => changelogWarnings, checkSkillFormat: () => checkSkillFormat }); module.exports = __toCommonJS(skill_check_entry_exports); @@ -6374,6 +6375,65 @@ var SKILL_MD = "SKILL.md"; var SKILL_FILE_NAMES = [SKILL_MD, "skill.md"]; var SPACESHEEP_YAML = "spacesheep.yaml"; var DECLARED_KEYS = ["scopes", "triggers", "tools", "sends_to"]; +var RELEASE_NOTE_GROUPS = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]; +var RELEASE_NOTE_LINES = 6; +var semverKey = (v) => v.split(".").map(Number); +var semverAfter = (a, b) => { + const [x, y] = [semverKey(a), semverKey(b)]; + for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] > y[i]; + return false; +}; +function changelogWarnings(text, tags = []) { + const out = []; + const say = (w) => out.push(`CHANGELOG.md: ${w}`); + const groups = RELEASE_NOTE_GROUPS.join(", "); + const seen = []; + let section = null; + let bullets = 0; + let first = true; + const close = () => { + if (section && section !== "Unreleased" && bullets > RELEASE_NOTE_LINES) say(`[${section}] has ${bullets} bullets; a release holds at most ${RELEASE_NOTE_LINES}`); + }; + for (const raw of text.replace(/\r\n?/g, "\n").split("\n")) { + const line = raw.trim(); + if (/^##\s/.test(line) && !/^###/.test(line)) { + close(); + bullets = 0; + const head = line.slice(3).trim(); + if (/^\[unreleased\]$/i.test(head)) { + section = "Unreleased"; + if (!first) say("## [Unreleased] goes at the top, above every release"); + } else { + const m = /^\[(\d+\.\d+\.\d+)\] - \d{4}-\d{2}-\d{2}$/.exec(head); + if (first) say("start with an ## [Unreleased] section, above every release"); + if (!m) { + say(`"${line.slice(0, 60)}" isn't a release heading: write ## [X.Y.Z] - YYYY-MM-DD`); + section = null; + } else { + if (seen.length && !semverAfter(seen[seen.length - 1], m[1])) say(`[${m[1]}] is below [${seen[seen.length - 1]}]: releases go newest first`); + seen.push(m[1]); + section = m[1]; + } + } + first = false; + continue; + } + if (section === null || !line || /^\[[^\]]+\]:\s/.test(line)) continue; + const g = /^###\s+(.*)$/.exec(line); + if (g) { + if (!RELEASE_NOTE_GROUPS.includes(g[1].trim())) say(`[${section}]: "### ${g[1].trim().slice(0, 30)}" isn't a group: use ${groups}`); + continue; + } + if (/^[-*]\s/.test(line)) bullets++; + else say(`[${section}]: "${line.slice(0, 50)}" should be a bullet under a ### group`); + } + close(); + for (const t of tags) { + const m = /^v(\d+\.\d+\.\d+)$/.exec(t); + if (m && !seen.includes(m[1])) say(`the tag ${t} has no ## [${m[1]}] section`); + } + return out; +} function checkSkillFormat(files, opts, readDeclared) { const problems = []; const warnings = []; @@ -6385,6 +6445,8 @@ function checkSkillFormat(files, opts, readDeclared) { problems.push(...md.problems); warnings.push(...md.warnings); const extras = readSpacesheepYaml(byPath, readDeclared, problems, warnings); + const log = byPath.get("CHANGELOG.md"); + if (log) warnings.push(...changelogWarnings(new TextDecoder().decode(log.bytes))); const has_scripts = listed.some((f) => folded(f.path).startsWith("scripts/")); const result = { spec_valid: md.spec_problems.length === 0, @@ -7052,4 +7114,4 @@ function sha256Hex(data) { for (const word of H) hex += word.toString(16).padStart(8, "0"); return hex; } -module.exports.BUILT_FROM = {"repo":"spacesheep-dev/spacesheep","commit":"01a2df10810250b6516613ec1bc8b7f5d1683bc1","date":"2026-11-17","files":["shared/skill-files.ts","shared/skill-format.ts"],"yaml":"2.9.0"}; +module.exports.BUILT_FROM = {"repo":"spacesheep-dev/spacesheep","commit":"9405d37eaf1c10942b3f4fae3f56f9be33fecee4","date":"2026-11-27","files":["shared/skill-files.ts","shared/skill-format.ts"],"yaml":"2.9.0"}; diff --git a/lib/skill-lint.js b/lib/skill-lint.js index 5635eb2..158a65d 100644 --- a/lib/skill-lint.js +++ b/lib/skill-lint.js @@ -20,7 +20,7 @@ const fs = require("fs"); const path = require("path"); const { execFileSync } = require("child_process"); -const { checkSkillFormat, SKILL_FILE_NAMES, BUILT_FROM } = require("./skill-check.gen"); +const { changelogWarnings, checkSkillFormat, SKILL_FILE_NAMES, BUILT_FROM } = require("./skill-check.gen"); const SAID = { none: "No skill here: the repo needs one top-level folder with a SKILL.md.", @@ -81,6 +81,18 @@ function findSkill(dir, entries) { return { dir: path.join(dir, folder), folder, entries: inside }; } +/** The release-notes format's warnings for the CHANGELOG.md beside the skill: in its folder, else at the repo's + * top, with the repo's v.. tags so a tag with no section is named. None when there's no file. */ +function changelog(top, dir) { + const file = [path.join(dir, "CHANGELOG.md"), path.join(top, "CHANGELOG.md")].find((p) => kindOf(p) === "file"); + if (!file) return []; + let tags = []; + try { + tags = execFileSync("git", ["-C", top, "tag", "--list", "v*"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).split("\n").filter(Boolean); + } catch (_) { /* not a git repo: no tags to check */ } + return changelogWarnings(fs.readFileSync(file, "utf8"), tags); +} + /** The check, as data: what `--json` prints. */ function lint(target) { if (!isDir(target)) throw new Error(`${target} isn't a folder`); @@ -98,6 +110,7 @@ function lint(target) { const mismatch = `SKILL.md: Directory name '${where.folder}' must match skill name '`; const problems = r.problems.map((p) => (p.startsWith(mismatch) && p.endsWith("'") ? SAID.differ(where.folder, p.slice(mismatch.length, -1)) : p)); const f = r.facts; + const warnings = [...r.warnings.filter((w) => !w.startsWith("CHANGELOG.md")), ...changelog(target, where.dir)]; return { ok: problems.length === 0, folder: shown, @@ -106,7 +119,7 @@ function lint(target) { files: f ? f.files.length : files.length, bytes: files.reduce((n, x) => n + x.bytes.length, 0), problems, - warnings: r.warnings, + warnings, spec_valid: r.spec_valid, spec_problems: r.spec_problems, declares: r.declares, diff --git a/scripts/skill-check-bundle.mjs b/scripts/skill-check-bundle.mjs index 99d5a05..d19e560 100644 --- a/scripts/skill-check-bundle.mjs +++ b/scripts/skill-check-bundle.mjs @@ -29,7 +29,7 @@ const here = dirname(fileURLToPath(import.meta.url)); export const OUT = join(here, "..", "lib", "skill-check.gen.js"); /** The only files of the app's repo the bundle may hold. */ export const SOURCES = ["shared/skill-format.ts", "shared/skill-files.ts"]; -const ENTRY = `export { checkSkillFormat, DECLARED_KEYS, SKILL_FILE_NAMES, SKILL_FORMAT_LIMITS } from "./shared/skill-format"; +const ENTRY = `export { changelogWarnings, checkSkillFormat, DECLARED_KEYS, SKILL_FILE_NAMES, SKILL_FORMAT_LIMITS } from "./shared/skill-format"; `; /** Where the app's repo is: --core, $SPACESHEEP_CORE, or ../spacesheep beside this repo. */ diff --git a/test/skill-lint.test.js b/test/skill-lint.test.js index b058053..8fd5fae 100644 --- a/test/skill-lint.test.js +++ b/test/skill-lint.test.js @@ -92,6 +92,25 @@ test("a repo: the one top-level skill folder is checked, and the repo's own file assert.strictEqual(c.hash, lint(path.join(root, "my-skill")).hash); }); +test("the repo's CHANGELOG.md is held to Keep a Changelog 1.1, with its tags: warnings, never a refusal", () => { + const good = "# Changelog\n\n## [Unreleased]\n\n## [1.0.0] - 2026-11-27\n\n### Added\n\n- The first release.\n\n[1.0.0]: https://example.com\n"; + const root = write({ ...skill(), "CHANGELOG.md": good }); + const git = (...a) => execFileSync("git", ["-C", root, ...a], { stdio: "ignore" }); + execFileSync("git", ["init", "-q", root]); + git("add", "-A"); + git("-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-qm", "one"); + git("tag", "v1.0.0"); + assert.deepStrictEqual(lint(root).warnings.filter((w) => w.startsWith("CHANGELOG.md")), []); + git("tag", "v1.1.0"); + fs.appendFileSync(path.join(root, "CHANGELOG.md"), "\n## v2.0.0\n- x\n"); + const c = lint(root); + assert.strictEqual(c.ok, true); + assert.deepStrictEqual(c.warnings.filter((w) => w.startsWith("CHANGELOG.md")), [ + 'CHANGELOG.md: "## v2.0.0" isn\'t a release heading: write ## [X.Y.Z] - YYYY-MM-DD', + "CHANGELOG.md: the tag v1.1.0 has no ## [1.1.0] section", + ]); +}); + test("the three refusals are the import's words, and refuse", () => { const none = lint(write({ "README.md": "# Nothing\n", "docs/a.md": "a\n" })); assert.deepStrictEqual([none.ok, none.problems], [false, [SAID.none]]); From 097a152332c472dd7d04eb762a1bdb112ead7456 Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Fri, 27 Nov 2026 13:37:19 +0800 Subject: [PATCH 2/2] skill-check.gen.js: built from spacesheep main bf95fdc51 (changelogWarnings) Co-authored-by: Pointman Co-authored-by: Claude --- lib/skill-check.gen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/skill-check.gen.js b/lib/skill-check.gen.js index b7df17a..80ad1ce 100644 --- a/lib/skill-check.gen.js +++ b/lib/skill-check.gen.js @@ -1,7 +1,7 @@ // Generated by scripts/skill-check-bundle.mjs: don't edit, run it again. // The published half of Spacesheep's skill checker (the format: SKILL.md, spacesheep.yaml's // shape, the folder's bytes and the hash), built from spacesheep-dev/spacesheep at -// 9405d37eaf1c10942b3f4fae3f56f9be33fecee4 (2026-11-27, the last commit to change these files): +// bf95fdc515dc1970d0d713db4df87181233e3d99 (2026-11-27, the last commit to change these files): // shared/skill-files.ts // shared/skill-format.ts // with yaml 2.9.0, whose licence follows: @@ -7114,4 +7114,4 @@ function sha256Hex(data) { for (const word of H) hex += word.toString(16).padStart(8, "0"); return hex; } -module.exports.BUILT_FROM = {"repo":"spacesheep-dev/spacesheep","commit":"9405d37eaf1c10942b3f4fae3f56f9be33fecee4","date":"2026-11-27","files":["shared/skill-files.ts","shared/skill-format.ts"],"yaml":"2.9.0"}; +module.exports.BUILT_FROM = {"repo":"spacesheep-dev/spacesheep","commit":"bf95fdc515dc1970d0d713db4df87181233e3d99","date":"2026-11-27","files":["shared/skill-files.ts","shared/skill-format.ts"],"yaml":"2.9.0"};