diff --git a/README.md b/README.md index b68be53..a63f58e 100644 --- a/README.md +++ b/README.md @@ -445,6 +445,8 @@ npx -y spacesheep@latest skills lint --json # for CI: exits 1 when the fold - **A repo holds one skill**, in a top-level folder named for it (`my-skill/SKILL.md`). The repo's own files (README, LICENSE, `.github/`) never enter a version. - **In a git repo** it checks what a commit would hold, so files git ignores are left out. +- **`docs/` is read as the skill page's Docs tab reads it**: a page `docs/SUMMARY.md` links that isn't there, + and a page it leaves out, are warnings, never a refusal. - **Well-formed isn't accepted.** What `spacesheep.yaml` declares the skill may ask for (scopes, triggers, tools, outside hosts), and a review of what the skill holds, are checked by Spacesheep when it takes the release. diff --git a/lib/skill-check.gen.js b/lib/skill-check.gen.js index 80ad1ce..caf6f17 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 -// bf95fdc515dc1970d0d713db4df87181233e3d99 (2026-11-27, the last commit to change these files): +// d657a28cb55409d363f4da068eeb7ce716bcc08a (2026-12-01, the last commit to change these files): // shared/skill-files.ts // shared/skill-format.ts // with yaml 2.9.0, whose licence follows: @@ -6434,6 +6434,61 @@ function changelogWarnings(text, tags = []) { } return out; } +function summaryEntries(text) { + const out = []; + let group, fence = null; + for (const line of text.replace(/\r\n?/g, "\n").split("\n")) { + const f = /^ {0,3}(`{3,}|~{3,})/.exec(line); + if (f) { + if (fence === null) fence = f[1]; + else if (f[1][0] === fence[0] && f[1].length >= fence.length && !line.trim().slice(f[1].length).trim()) fence = null; + continue; + } + if (fence !== null) continue; + const h = /^ {0,3}#{2,6}[ \t]+(.+?)[ \t#]*$/.exec(line); + if (h) { + group = h[1].replace(/[*_`]/g, "").trim().slice(0, 80) || void 0; + continue; + } + const m = /^([ \t]*)(?:[-*+][ \t]+)?\[([^\]]*)\]\(([^)\s]*)\)/.exec(line); + if (!m) continue; + const to = m[3].split("#")[0].replace(/^\.\//, ""); + if (!to) continue; + out.push({ to, title: m[2].replace(/[*_`]/g, "").trim().slice(0, 120), depth: m[1].replace(/\t/g, " ").length >= 2 ? 1 : 0, ...group ? { group } : {} }); + } + return out; +} +function underDocs(link) { + const parts = []; + for (const seg of link.replace(/^\.\//, "").split("#")[0].split("/")) { + if (seg === "..") { + if (!parts.pop()) return null; + } else if (seg && seg !== ".") parts.push(seg); + } + return parts.length ? parts.join("/") : null; +} +function summaryPage(to) { + const path = /^[a-z][a-z0-9+.-]*:/i.test(to) ? null : underDocs(to); + return path && /\.md$/i.test(path) && !/^summary\.md$/i.test(path) ? path : null; +} +function docsWarnings(paths, summary) { + const out = []; + const md = paths.filter((p) => /^docs\/.+\.md$/i.test(p) && !/^docs\/summary\.md$/i.test(p)); + let pages = md.filter((p) => !p.slice(5).includes("/")); + const linked = /* @__PURE__ */ new Set(); + for (const { to } of summaryEntries(summary ?? "")) { + const page = summaryPage(to); + if (!page) continue; + if (md.includes(`docs/${page}`)) linked.add(`docs/${page}`); + else out.push(`docs/SUMMARY.md links ${to}, which isn't in the folder: Docs skips it`); + } + if (linked.size) { + pages = [...linked]; + for (const p of md) if (!linked.has(p)) out.push(`${p} isn't in docs/SUMMARY.md, so Docs doesn't show it (it's still in Files)`); + } + if (pages.length > 50) out.push("docs/ has more than 50 pages: Docs shows the first 50"); + return out; +} function checkSkillFormat(files, opts, readDeclared) { const problems = []; const warnings = []; @@ -6447,6 +6502,8 @@ function checkSkillFormat(files, opts, readDeclared) { const extras = readSpacesheepYaml(byPath, readDeclared, problems, warnings); const log = byPath.get("CHANGELOG.md"); if (log) warnings.push(...changelogWarnings(new TextDecoder().decode(log.bytes))); + const summary = [...byPath.keys()].find((p) => /^docs\/summary\.md$/i.test(p)); + warnings.push(...docsWarnings([...byPath.keys()], summary ? new TextDecoder().decode(byPath.get(summary).bytes) : null)); const has_scripts = listed.some((f) => folded(f.path).startsWith("scripts/")); const result = { spec_valid: md.spec_problems.length === 0, @@ -7114,4 +7171,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":"bf95fdc515dc1970d0d713db4df87181233e3d99","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":"d657a28cb55409d363f4da068eeb7ce716bcc08a","date":"2026-12-01","files":["shared/skill-files.ts","shared/skill-format.ts"],"yaml":"2.9.0"}; diff --git a/package.json b/package.json index 9a05ae8..dd26be3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spacesheep", - "version": "1.42.0", + "version": "1.43.0", "description": "Publish web pages to spacesheep.dev from a terminal or CI: `npx spacesheep deploy ./dist`", "bin": { "spacesheep": "./bin/spacesheep.js" diff --git a/test/skill-lint.test.js b/test/skill-lint.test.js index 8fd5fae..6a6d822 100644 --- a/test/skill-lint.test.js +++ b/test/skill-lint.test.js @@ -111,6 +111,20 @@ test("the repo's CHANGELOG.md is held to Keep a Changelog 1.1, with its tags: wa ]); }); +test("docs/ is checked as the Docs tab reads it: SUMMARY.md's dead links and pages it leaves out are warnings", () => { + const root = write({ + ...skill(), + "my-skill/docs/index.md": "# Start\n", "my-skill/docs/extra.md": "# Extra\n", + "my-skill/docs/SUMMARY.md": "# Summary\n\n- [Start](index.md)\n- [Gone](gone.md)\n", + }); + const c = lint(root); + assert.strictEqual(c.ok, true, c.problems.join("; ")); + assert.deepStrictEqual(c.warnings.filter((w) => w.startsWith("docs/")), [ + "docs/SUMMARY.md links gone.md, which isn't in the folder: Docs skips it", + "docs/extra.md isn't in docs/SUMMARY.md, so Docs doesn't show it (it's still in Files)", + ]); +}); + 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]]);