Replaced by an explicit list of forms only (ten exported names, runtime env names, project file names and marks, commands, skill names, the log prefix, the brand in prose). Package name, import paths, routes, CSS tokens, data attributes, custom keys, context flags, the cookie and kv keys are not touched. package.json keeps the five old bin names beside the five new ones. The old names stop working in this commit and come back as aliases in the next; docs follow. Co-Authored-By: Claude Fable 5.2 <[email protected]>
194 lines
9.6 KiB
JavaScript
194 lines
9.6 KiB
JavaScript
#!/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 — `iapl-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:
|
|
> IAPL features first (the \`iapl-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 IAPL 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. IAPL already provides users and roles,
|
|
> 2FA, SEO, forms, i18n, the site globals, revalidation and storage — check the \`iapl-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 (\`iapl-skills --external\`). Do not edit — regenerate with
|
|
\`scripts/vendor-external-skills.mjs\` in the IAPL 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 })
|
|
}
|