ipal-skills --external: vendored third-party agent skills, pinned

- docs/agent/external: Vercel react-best-practices and composition-patterns
  (MIT), Addy Osmani accessibility (MIT), Anthropic frontend-design
  (Apache-2.0), official Payload skill at v3.92.1 (MIT) — text only, each
  with its licence, SOURCE.md (repo, commit) and an override note in front
  of the SKILL.md (ipal-kit first, Payload fetching over swr, DESIGN.md
  tokens, Payload 3 not 4); manifest.json with sha256 per file
- scripts/vendor-external-skills.mjs (maintainer, not shipped): fetches by
  full commit SHA only, rejects non-text or executable files, regenerates
  the manifest; --check verifies it
- ipal-skills --external [names]: copies ext-* after checking every file
  against the manifest, downloads nothing, never touches ext-* folders
  without ipal-kit's SOURCE.md, removes only retired ones it installed;
  an unknown name stops the run before anything is copied
- AGENT.md §14, ipal-setup stage 2 (optional step), README: usage,
  overrides, how to update the pins
- test/externalSkills.test.ts: pins are SHAs, no branch fetch, checksums,
  text only, licences, override note, installer leaves other folders alone

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 11:54:35 +01:00
co-authored by Claude Opus 5.5
parent 25719ae7ec
commit e1f82ce387
124 changed files with 18732 additions and 1 deletions
+193
View File
@@ -0,0 +1,193 @@
#!/usr/bin/env node
// Maintainer script (not shipped): vendors the third-party agent skills into docs/agent/external/
// at the commits pinned below. Projects never fetch anything — `ipal-skills --external` copies
// these vendored folders. To update a pin: change `commit`, run this script, review the diff
// (`git diff docs/agent/external`), run `pnpm vitest run test/externalSkills.test.ts`, commit.
//
// node scripts/vendor-external-skills.mjs → fetch, copy, write manifest.json
// node scripts/vendor-external-skills.mjs --check → only verify manifest checksums
//
// Only text files are copied (.md, .json, .txt); anything else fails the run.
import { createHash } from 'node:crypto'
import { execFileSync } from 'node:child_process'
import { cpSync, existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const outDir = join(root, 'docs', 'agent', 'external')
const COMMON = `> **Project rules win.** Vendored by @intecion/ipal-kit as guidance. When this skill conflicts with
> \`node_modules/@intecion/ipal-kit/docs/agent/AGENT.md\`, the project's \`AGENTS.md\` or \`DESIGN.md\`, those win:
> ipal-kit features first (the \`ipal-reference\` skill), Payload 3 + Next 16 App Router, data from Server Components
> through Payload / \`@/lib/content\`, every visible text from the CMS, design values from \`DESIGN.md\` tokens.
> Never add a dependency this skill suggests without the owner's decision.`
/** Pinned sources. `commit` must be a full 40-character SHA — never a branch. */
const SOURCES = [
{
name: 'ext-react-best-practices',
repo: 'https://github.com/vercel-labs/agent-skills',
commit: '1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62',
path: 'skills/react-best-practices',
publisher: 'Vercel',
license: 'MIT',
licenseFile: null, // the repo ships no LICENSE file; MIT is declared in SKILL.md and README
override: `> **Data fetching:** ignore \`client-swr-dedup\` and any advice to add \`swr\`, \`better-all\`, \`lru-cache\` or another
> client-fetch library. Fetch in Server Components with the Payload Local API / \`@/lib/content\` helpers (React \`cache()\`).`,
},
{
name: 'ext-composition-patterns',
repo: 'https://github.com/vercel-labs/agent-skills',
commit: '1a2c79d4e6c4a2283dc2c614b6538cbe1ed5ca62',
path: 'skills/composition-patterns',
publisher: 'Vercel',
license: 'MIT',
licenseFile: null,
override: `> **Blocks:** composition applies inside a block's own components; the block schema, shared fields and
> \`RenderBlocks\` follow AGENT.md §6.`,
},
{
name: 'ext-accessibility',
repo: 'https://github.com/addyosmani/web-quality-skills',
commit: 'afa8da942115f2961fdbfa80807ea0b232ff6c00',
path: 'skills/accessibility',
publisher: 'Addy Osmani',
license: 'MIT',
licenseFile: 'LICENSE',
override: `> **Tools:** never run \`npx lighthouse\` / \`npx @axe-core/cli\` unpinned — add them as devDependencies at fixed versions
> first. Use the ipal-kit components (CookieBanner, AccessibilityWidget, RenderForm…) and fix their markup through
> their props or a plugin gap report, not by copying them.`,
},
{
name: 'ext-frontend-design',
repo: 'https://github.com/anthropics/skills',
commit: 'ca45fc496a3436251f191354091d557da31c15b5',
path: 'skills/frontend-design',
publisher: 'Anthropic',
license: 'Apache-2.0',
licenseFile: 'skills/frontend-design/LICENSE.txt',
override: `> **Design tokens:** the project's \`DESIGN.md\` tokens win. Use this skill to write or extend \`DESIGN.md\` (with the
> owner's approval); components never contain hex colours, font names or text — only Tailwind tokens and CMS text.`,
},
{
name: 'ext-payload',
repo: 'https://github.com/payloadcms/payload',
commit: '9c396345dad3c831a34fd212299532e03dc4818f', // tag v3.92.1
path: 'tools/claude-plugin/skills/payload',
publisher: 'Payload CMS',
license: 'MIT',
licenseFile: 'LICENSE.md',
override: `> **Reference only — Payload 3 (v3.92.1).** Never apply Payload 4 guidance. ipal-kit already provides users and roles,
> 2FA, SEO, forms, i18n, the site globals, revalidation and storage — check the \`ipal-reference\` skill before you
> write Payload config, hooks or access rules by hand.`,
},
]
const MIT = `MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of
the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
`
const TEXT = /\.(?:json|md|txt)$/
const sha256 = (file) => createHash('sha256').update(readFileSync(file)).digest('hex')
const filesOf = (dir) =>
readdirSync(dir).flatMap((n) => (statSync(join(dir, n)).isDirectory() ? filesOf(join(dir, n)) : [join(dir, n)]))
function checksums(dir) {
return Object.fromEntries(filesOf(dir).map((f) => [relative(dir, f).split('\\').join('/'), sha256(f)]).sort())
}
if (process.argv.includes('--check')) {
const manifest = JSON.parse(readFileSync(join(outDir, 'manifest.json'), 'utf8'))
let bad = 0
for (const skill of manifest.skills) {
const actual = checksums(join(outDir, skill.name))
if (JSON.stringify(actual) !== JSON.stringify(skill.files)) {
console.error(`✗ ${skill.name}: files differ from manifest.json`)
bad++
}
}
console.log(bad ? `${bad} skill(s) changed` : 'all vendored skills match manifest.json')
process.exit(bad ? 1 : 0)
}
const work = mkdtempSync(join(tmpdir(), 'ipal-ext-'))
const git = (cwd, ...args) => execFileSync('git', args, { cwd, stdio: ['ignore', 'pipe', 'inherit'] }).toString().trim()
const checkouts = new Map()
function checkout(repo, commit) {
const key = `${repo}@${commit}`
if (checkouts.has(key)) {return checkouts.get(key)}
if (!/^[0-9a-f]{40}$/.test(commit)) {throw new Error(`${repo}: commit must be a full SHA, got "${commit}"`)}
const dir = join(work, String(checkouts.size))
execFileSync('git', ['init', '-q', dir])
git(dir, 'fetch', '-q', '--depth', '1', '--filter=blob:none', repo, commit)
git(dir, '-c', 'advice.detachedHead=false', 'checkout', '-q', 'FETCH_HEAD')
if (git(dir, 'rev-parse', 'HEAD') !== commit) {throw new Error(`${repo}: fetched commit differs from ${commit}`)}
checkouts.set(key, dir)
return dir
}
const manifest = { note: 'Generated by scripts/vendor-external-skills.mjs — do not edit by hand.', skills: [] }
try {
for (const src of SOURCES) {
const repoDir = checkout(src.repo, src.commit)
const from = join(repoDir, src.path)
const to = join(outDir, src.name)
const nonText = filesOf(from).filter((f) => !TEXT.test(f) || (statSync(f).mode & 0o111) !== 0)
if (nonText.length) {throw new Error(`${src.name}: not text-only: ${nonText.map((f) => relative(from, f)).join(', ')}`)}
rmSync(to, { force: true, recursive: true })
cpSync(from, to, { recursive: true })
// Our name and our overrides go in front of the upstream text.
const skillFile = join(to, 'SKILL.md')
const skill = readFileSync(skillFile, 'utf8')
const end = skill.indexOf('\n---', 3)
const frontmatter = skill.slice(0, end).replace(/^name: .+$/m, `name: ${src.name}`)
writeFileSync(skillFile, `${frontmatter}${skill.slice(end, end + 4)}\n\n${COMMON}\n>\n${src.override}\n${skill.slice(end + 4)}`)
if (src.licenseFile && !existsSync(join(to, src.licenseFile.split('/').pop()))) {
cpSync(join(repoDir, src.licenseFile), join(to, src.licenseFile.split('/').pop()))
}
if (!src.licenseFile) {
writeFileSync(join(to, 'LICENSE'), `${MIT}\nThe upstream repository (${src.repo}) declares the MIT licence in its README and in\nthe SKILL.md frontmatter; it ships no LICENSE file with a copyright line. Copyright: ${src.publisher}.\n`)
}
writeFileSync(join(to, 'SOURCE.md'), `# ${src.name}
Vendored by @intecion/ipal-kit (\`ipal-skills --external\`). Do not edit — regenerate with
\`scripts/vendor-external-skills.mjs\` in the ipal-kit repository.
| | |
|---|---|
| Publisher | ${src.publisher} |
| Source | ${src.repo}/tree/${src.commit}/${src.path} |
| Commit | \`${src.commit}\` |
| Licence | ${src.license} (see the LICENSE file in this folder) |
Changes from the upstream text: the \`name\` in the SKILL.md frontmatter is \`${src.name}\`, and an
override note (project rules win) is inserted after the frontmatter. Nothing else is changed.
`)
manifest.skills.push({
name: src.name, publisher: src.publisher, repo: src.repo, commit: src.commit, path: src.path, license: src.license,
files: checksums(to),
})
console.log(`vendored ${src.name} @ ${src.commit.slice(0, 12)}`)
}
writeFileSync(join(outDir, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`)
} finally {
rmSync(work, { force: true, recursive: true })
}