diff --git a/README.md b/README.md index 9898915..48edbc8 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,16 @@ have none) pointing the agent at the full guide: `AGENT.md`, the `ipal-reference (every option, env var, route and export) and the `ipal-setup` skill. Only the text between the markers is ever rewritten. `--no-pointer` skips that step. There is no `postinstall` script. +`pnpm exec ipal-skills --external` also adds a few well-known third-party skills as `ext-*` folders — Vercel's +React best practices and composition patterns, Addy Osmani's accessibility skill, Anthropic's frontend-design +skill and the official Payload 3 skill. They are vendored into the package at pinned commits (text only, each +with its licence and source), so nothing is downloaded, and each starts with a note that ipal-kit's rules win. +Pick some with `--external ext-accessibility,ext-payload`. + +*Updating the pins (plugin maintainers):* change the commit in `scripts/vendor-external-skills.mjs`, run +`node scripts/vendor-external-skills.mjs`, review `git diff docs/agent/external`, and run +`pnpm vitest run test/externalSkills.test.ts`. + From here, the guide takes over: **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** — from an empty project to a working site. diff --git a/bin/ipal-skills.mjs b/bin/ipal-skills.mjs index 1de4a65..8815b6a 100755 --- a/bin/ipal-skills.mjs +++ b/bin/ipal-skills.mjs @@ -4,22 +4,30 @@ // pnpm ipal-skills --dry-run → show what would change // pnpm ipal-skills --dest .claude/skills // pnpm ipal-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone +// pnpm ipal-skills --external → also the vendored third-party skills (ext-*, pinned, text only) +// pnpm ipal-skills --external ext-accessibility,ext-payload → only those // Only folders named ipal-* are touched; the project's own skills stay as they are. // ipal-* folders that no longer exist in the package are removed (renamed/retired skills). +// ext-* folders are touched only with --external, and only those carrying ipal-kit's SOURCE.md. // AGENTS.md (and CLAUDE.md) get a marked ipal-kit block pointing at the guide — only the // text between the markers is ever rewritten; the project's own content stays as it is. +import { createHash } from 'node:crypto' import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs' import { dirname, join, relative, resolve } from 'node:path' import { fileURLToPath } from 'node:url' const args = process.argv.slice(2) if (args.includes('--help') || args.includes('-h')) { - console.log('Usage: ipal-skills [--dest ] [--dry-run] [--no-pointer]\nDefault dest: .agents/skills') + console.log('Usage: ipal-skills [--dest ] [--dry-run] [--no-pointer] [--external [ext-a,ext-b]]\nDefault dest: .agents/skills') process.exit(0) } const dryRun = args.includes('--dry-run') const pointer = !args.includes('--no-pointer') +const externalArg = args.indexOf('--external') +const externalPick = externalArg >= 0 && args[externalArg + 1] && !args[externalArg + 1].startsWith('-') + ? args[externalArg + 1].split(',').map((n) => n.trim()).filter(Boolean) + : null const destArg = args.indexOf('--dest') const destValue = destArg >= 0 ? args[destArg + 1] : '.agents/skills' // A missing value would resolve to cwd and remove every ipal-* folder there. @@ -40,6 +48,16 @@ if (!existsSync(src)) { process.exit(1) } +// Validate --external before anything is copied. +const extSrc = join(pkgRoot, 'docs', 'agent', 'external') +const manifest = externalArg >= 0 ? JSON.parse(readFileSync(join(extSrc, 'manifest.json'), 'utf8')) : { skills: [] } +const known = manifest.skills.map((skill) => skill.name) +const unknown = (externalPick ?? []).filter((name) => !known.includes(name)) +if (unknown.length) { + console.error(`ipal-skills: unknown external skill(s): ${unknown.join(', ')} — available: ${known.join(', ')}`) + process.exit(1) +} + const isSkillDir = (base, name) => name.startsWith('ipal-') && statSync(join(base, name)).isDirectory() const shipped = readdirSync(src).filter((n) => isSkillDir(src, n)) const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : [] @@ -60,6 +78,41 @@ for (const name of retired) { } console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`) +// Third-party skills, vendored into the package at pinned commits (docs/agent/external, +// scripts/vendor-external-skills.mjs). Nothing is downloaded here: every file is checked +// against manifest.json before it is copied. +if (externalArg >= 0) { + const MARK = 'Vendored by @intecion/ipal-kit' + const ours = (name) => existsSync(join(dest, name, 'SOURCE.md')) && readFileSync(join(dest, name, 'SOURCE.md'), 'utf8').includes(MARK) + const filesOf = (dir) => readdirSync(dir).flatMap((n) => (statSync(join(dir, n)).isDirectory() ? filesOf(join(dir, n)).map((f) => `${n}/${f}`) : [n])) + for (const skill of manifest.skills.filter((s) => !externalPick || externalPick.includes(s.name))) { + const from = join(extSrc, skill.name) + const files = filesOf(from).sort() + const tampered = files.filter((f) => skill.files[f] !== createHash('sha256').update(readFileSync(join(from, f))).digest('hex')) + if (tampered.length || files.length !== Object.keys(skill.files).length) { + console.error(`ipal-skills: ${skill.name} does not match manifest.json (${tampered.join(', ') || 'file list'}) — skipped`) + process.exitCode = 1 + continue + } + if (existsSync(join(dest, skill.name)) && !ours(skill.name)) { + console.warn(`skip ${skill.name} (a folder of that name exists and is not from ipal-kit)`) + continue + } + console.log(`${existsSync(join(dest, skill.name)) ? 'update' : 'add '} ${skill.name} (${skill.publisher}, ${skill.license}, ${skill.commit.slice(0, 12)})`) + if (!dryRun) { + rmSync(join(dest, skill.name), { recursive: true, force: true }) + cpSync(from, join(dest, skill.name), { recursive: true }) + } + } + const retiredExt = existsSync(dest) + ? readdirSync(dest).filter((n) => n.startsWith('ext-') && !known.includes(n) && ours(n)) + : [] + for (const name of retiredExt) { + console.log(`remove ${name} (no longer in ipal-kit)`) + if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true }) + } +} + // Pointer block: an agent opening the project must find the guide without being told. // AGENTS.md is read by Codex/Cursor/Antigravity, CLAUDE.md by Claude Code (which also // follows `@AGENTS.md` imports, so a CLAUDE.md that imports AGENTS.md needs no copy). diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index abe0e9e..fa1f1bc 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -1343,6 +1343,27 @@ It copies only the `ipal-*` folders: adds new ones, replaces existing ones entir retired ones. Name the project's own skills **without** the `ipal-` prefix — they stay untouched. `--dest` must be a subdirectory of the project. Commit the copied `ipal-*` to the project repo. +**External skills (opt-in)** — well-known third-party skills, vendored into the package at pinned commits +(text only, licence + `SOURCE.md` in each folder). `ipal-skills` downloads nothing; it checks every file +against `docs/agent/external/manifest.json` before copying: +```bash +pnpm exec ipal-skills --external # all ext-* next to the ipal-* skills +pnpm exec ipal-skills --external ext-accessibility,ext-payload # only these +``` +| Skill | Publisher · licence | What it is for | Our override | +|---|---|---|---| +| `ext-react-best-practices` | Vercel · MIT | React/Next performance rules (waterfalls, bundles, RSC, re-renders) | no `swr` / client-fetch libraries — Server Components + Payload / `@/lib/content` | +| `ext-composition-patterns` | Vercel · MIT | compound components instead of boolean props, React 19 APIs | block schema and `RenderBlocks` follow §6 | +| `ext-accessibility` | Addy Osmani · MIT | WCAG 2.2 audit and fixes | Lighthouse / axe only as pinned devDependencies; ipal-kit components fixed via props or a plugin gap | +| `ext-frontend-design` | Anthropic · Apache-2.0 | distinctive visual direction, design quality floor | `DESIGN.md` tokens win; use it to write/extend `DESIGN.md`, never hex/fonts/text in components | +| `ext-payload` | Payload CMS · MIT | Payload 3 reference (v3.92.1) | reference only, never Payload 4 guidance; ipal-kit features first | + +**Our rules win.** Every `ext-*` SKILL.md starts with an override note; when an external skill conflicts with +this file, the project's `AGENTS.md` or `DESIGN.md`, those win — ipal-kit first, Payload data fetching over `swr`, +`DESIGN.md` tokens, Payload 3 not 4. `ext-*` folders are touched only with `--external`, and only those with +ipal-kit's `SOURCE.md`; do not name the project's own skills `ext-…`. Use them only after the owner chose them +("Project decisions"). + **`tsconfig.json` must exclude the skills directory** (it contains `.ts`/`.tsx` templates that break `tsc` and `next build`): `"exclude": ["node_modules", ".agents"]` (with `--dest .claude/skills` — `".claude"`). Without it `ipal-skills` prints a warning and exits with diff --git a/docs/agent/external/ext-accessibility/LICENSE b/docs/agent/external/ext-accessibility/LICENSE new file mode 100644 index 0000000..90715bb --- /dev/null +++ b/docs/agent/external/ext-accessibility/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Addy Osmani + +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. diff --git a/docs/agent/external/ext-accessibility/SKILL.md b/docs/agent/external/ext-accessibility/SKILL.md new file mode 100644 index 0000000..46e6f83 --- /dev/null +++ b/docs/agent/external/ext-accessibility/SKILL.md @@ -0,0 +1,475 @@ +--- +name: ext-accessibility +description: Audit and improve web accessibility following WCAG 2.2 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible". +license: MIT +metadata: + author: web-quality-skills + version: "2.0" +--- + +> **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. +> +> **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. + + +# Accessibility (a11y) + +Comprehensive accessibility guidelines based on WCAG 2.2 and Lighthouse accessibility audits. Goal: make content usable by everyone, including people with disabilities. + +## Evidence-led audit workflow + +When a rendered page is available: + +1. Run a live Lighthouse Accessibility audit when that capability is available; with Chrome DevTools MCP, use `lighthouse_audit`. Use mobile navigation mode for a general public page or snapshot mode when reloading would lose authenticated or user-created state. +2. Use failed audit nodes to localize the relevant component or template instead of searching the whole repository for generic patterns. +3. Inspect a rendered accessibility-tree snapshot for names, roles, states, landmarks, and heading structure; with Chrome DevTools MCP, use `take_snapshot`. Exercise the affected flow with the keyboard. +4. Fix the source, then re-run the same audit and manual interaction. + +If the live tools are unavailable, use Lighthouse CLI or axe for automated coverage and complete the same manual checks. Automated tools detect only a subset of accessibility barriers: a score of 100 is not WCAG conformance, and a low score does not replace issue-level evidence. + +## WCAG Principles: POUR + +| Principle | Description | +|-----------|-------------| +| **P**erceivable | Content can be perceived through different senses | +| **O**perable | Interface can be operated by all users | +| **U**nderstandable | Content and interface are understandable | +| **R**obust | Content works with assistive technologies | + +## Conformance levels + +| Level | Requirement | Target | +|-------|-------------|--------| +| **A** | Minimum accessibility | Must pass | +| **AA** | Standard compliance | Should pass (legal requirement in many jurisdictions) | +| **AAA** | Enhanced accessibility | Nice to have | + +--- + +## Perceivable + +### Text alternatives (1.1) + +**Images require alt text:** +```html + + + + +Bar chart showing 40% increase in Q3 sales + + + + + +
+ 2024 market trends infographic +
+ +
+
+``` + +**Icon buttons need accessible names:** +```html + + + + + + + + +``` + +**Visually hidden class:** +```css +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} +``` + +### Color contrast (1.4.3, 1.4.6) + +| Text Size | AA minimum | AAA enhanced | +|-----------|------------|--------------| +| Normal text (< 18px / < 14px bold) | 4.5:1 | 7:1 | +| Large text (≥ 18px / ≥ 14px bold) | 3:1 | 4.5:1 | +| UI components & graphics | 3:1 | 3:1 | + +```css +/* ❌ Low contrast (2.5:1) */ +.low-contrast { + color: #999; + background: #fff; +} + +/* ✅ Sufficient contrast (7:1) */ +.high-contrast { + color: #333; + background: #fff; +} + +/* ✅ Focus states need contrast too (3:1 against background, WCAG 1.4.11) */ +:focus-visible { + outline: 2px solid currentColor; + outline-offset: 2px; +} +``` + +**Don't rely on color alone:** +```html + + + + + +
+ + + + Please enter a valid email address + +
+``` + +### Media alternatives (1.2) + +```html + + + + + +
+ Transcript +

Full transcript text...

+
+``` + +--- + +## Operable + +### Keyboard accessible (2.1) + +**All functionality must be keyboard accessible.** Prefer native interactive elements — ` +``` + +```javascript +// ✅ When you MUST use a non-interactive element (e.g. div with role="button"), +// make it focusable AND handle keyboard activation. Do NOT add this to a native +// + +``` + +--- + +## Robust + +### ARIA usage (4.1.2) + +**Prefer native elements:** +```html + +
Click me
+ + + + + +
Option
+ + + +``` + +**When ARIA is needed,** use the correct roles and states. See the [ARIA tabs pattern](references/A11Y-PATTERNS.md#aria-tabs) for a complete tablist example. + +### Live regions (4.1.3) + +Use `aria-live` regions to announce dynamic content changes without moving focus. See the [live regions pattern](references/A11Y-PATTERNS.md#live-regions-and-notifications) for markup and a `showNotification()` helper. + +--- + +## Testing checklist + +### Automated testing + +Prefer a live Lighthouse audit that returns failing rendered nodes directly to the agent. With Chrome DevTools MCP, this is `lighthouse_audit`. Otherwise: + +```bash +# Lighthouse accessibility audit +npx lighthouse https://example.com --only-categories=accessibility + +# axe-core +npm install @axe-core/cli -g +axe https://example.com +``` + +### Manual testing + +- [ ] **Keyboard navigation:** Tab through entire page, use Enter/Space to activate +- [ ] **Screen reader:** Test with VoiceOver (Mac), NVDA (Windows), or TalkBack (Android) +- [ ] **Zoom:** Content usable at 200% zoom +- [ ] **High contrast:** Test with Windows High Contrast Mode +- [ ] **Reduced motion:** Test with `prefers-reduced-motion: reduce` +- [ ] **Focus order:** Logical and follows visual order +- [ ] **Target size:** Interactive elements meet 24×24px minimum + +See the [screen reader commands reference](references/A11Y-PATTERNS.md#screen-reader-commands) for VoiceOver and NVDA shortcuts. + +--- + +## Common issues by impact + +### Critical (fix immediately) +1. Missing form labels +2. Missing image alt text +3. Insufficient color contrast +4. Keyboard traps +5. No focus indicators + +### Serious (fix before launch) +1. Missing page language +2. Missing heading structure +3. Non-descriptive link text +4. Auto-playing media +5. Missing skip links + +### Moderate (fix soon) +1. Missing ARIA labels on icons +2. Inconsistent navigation +3. Missing error identification +4. Timing without controls +5. Missing landmark regions + +## References + +- [WCAG 2.2 Quick Reference](https://www.w3.org/WAI/WCAG22/quickref/) +- [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/) +- [Deque axe Rules](https://dequeuniversity.com/rules/axe/) +- [Web Quality Audit](../web-quality-audit/SKILL.md) +- [WCAG criteria reference](references/WCAG.md) +- [Accessibility code patterns](references/A11Y-PATTERNS.md) diff --git a/docs/agent/external/ext-accessibility/SOURCE.md b/docs/agent/external/ext-accessibility/SOURCE.md new file mode 100644 index 0000000..e752d96 --- /dev/null +++ b/docs/agent/external/ext-accessibility/SOURCE.md @@ -0,0 +1,14 @@ +# ext-accessibility + +Vendored by @intecion/ipal-kit (`ipal-skills --external`). Do not edit — regenerate with +`scripts/vendor-external-skills.mjs` in the ipal-kit repository. + +| | | +|---|---| +| Publisher | Addy Osmani | +| Source | https://github.com/addyosmani/web-quality-skills/tree/afa8da942115f2961fdbfa80807ea0b232ff6c00/skills/accessibility | +| Commit | `afa8da942115f2961fdbfa80807ea0b232ff6c00` | +| Licence | MIT (see the LICENSE file in this folder) | + +Changes from the upstream text: the `name` in the SKILL.md frontmatter is `ext-accessibility`, and an +override note (project rules win) is inserted after the frontmatter. Nothing else is changed. diff --git a/docs/agent/external/ext-accessibility/references/A11Y-PATTERNS.md b/docs/agent/external/ext-accessibility/references/A11Y-PATTERNS.md new file mode 100644 index 0000000..6d500ef --- /dev/null +++ b/docs/agent/external/ext-accessibility/references/A11Y-PATTERNS.md @@ -0,0 +1,233 @@ +# Accessibility Code Patterns + +Practical, copy-paste-ready patterns for common accessibility requirements. Each pattern is self-contained and linked from the main [SKILL.md](../SKILL.md). + +--- + +## Modal focus trap + +Trap keyboard focus inside a modal dialog so Tab/Shift+Tab cycle through its focusable elements and Escape closes it. + +```javascript +function openModal(modal) { + const focusableElements = modal.querySelectorAll( + 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' + ); + const firstElement = focusableElements[0]; + const lastElement = focusableElements[focusableElements.length - 1]; + + modal.addEventListener('keydown', (e) => { + if (e.key === 'Tab') { + if (e.shiftKey && document.activeElement === firstElement) { + e.preventDefault(); + lastElement.focus(); + } else if (!e.shiftKey && document.activeElement === lastElement) { + e.preventDefault(); + firstElement.focus(); + } + } + if (e.key === 'Escape') { + closeModal(); + } + }); + + firstElement.focus(); +} +``` + +The native `` element handles focus trapping automatically—prefer it when browser support allows. + +--- + +## Skip link + +Allows keyboard users to bypass repetitive navigation and jump straight to main content. + +```html + + +
+
+ +
+ +``` + +```css +.skip-link { + position: absolute; + top: -40px; + left: 0; + background: #000; + color: #fff; + padding: 8px 16px; + z-index: 100; +} + +.skip-link:focus { + top: 0; +} +``` + +--- + +## Error handling + +Announce errors to screen readers and focus the first invalid field on submit. + +```html +
+
+ + + +
+
+``` + +```javascript +form.addEventListener('submit', (e) => { + const firstError = form.querySelector('[aria-invalid="true"]'); + if (firstError) { + e.preventDefault(); + firstError.focus(); + + const errorSummary = document.getElementById('error-summary'); + errorSummary.textContent = + `${errors.length} errors found. Please fix them and try again.`; + errorSummary.focus(); + } +}); +``` + +--- + +## Form labels + +Every input needs an associated label—either explicit (`for`/`id`) or implicit (wrapping `