@mew-lab/a11y-cli
v0.6.0
Published
WAI-ARIA APG パターンと WCAG 2.2 のアクセシビリティ観点を CLI/JSON で引けるツール(AI エージェント対応) | CLI/JSON tool for WAI-ARIA APG patterns & WCAG 2.2 accessibility guidelines (AI agent friendly)
Downloads
2,290
Maintainers
Readme
@mew-lab/a11y-cli
WAI-ARIA APG パターンと WCAG 2.2 のアクセシビリティ観点を、コマンドラインと JSON で引けるツールです。 a11y.mew-lab.com と同じ知識(日本語)を、エディタの手元や AI エージェントから参照できます。
📦 npm: https://www.npmjs.com/package/@mew-lab/a11y-cli
インストール
# 単発で使う(推奨)
npx @mew-lab/a11y-cli pattern dialog-modal
# グローバルに入れる
npm install -g @mew-lab/a11y-cli
a11y pattern dialog-modalNode.js 22.13 以上が必要です。
ローカルで試す(publish はしない):
pnpm --filter @mew-lab/a11y-cli build
pnpm --filter @mew-lab/a11y-cli pack # tarball を生成
npm install -g ./packages/cli/mew-lab-a11y-cli-<version>.tgzコマンド
| コマンド | 説明 |
|---|---|
| a11y pattern [slug] | APG パターンの観点(ARIA・キーボード・チェックリスト・アンチパターン・関連 WCAG)。無引数で一覧 |
| a11y wcag [slug] | WCAG 2.2 達成基準(レベル・原則・要約・参照 URL・関連パターン)。無引数で一覧 |
| a11y search <query> | パターン + WCAG を横断検索。--limit <n> で件数調整(デフォルト20件、--limit 0 で全件) |
| a11y checklist <slug> | パターンの実装チェックリストだけを表示(PR レビュー向け) |
| a11y manifest | 全コマンド/レスポンス型の構造化 manifest(AI エージェント向け) |
| a11y doctor | 実行環境を診断 |
グローバルオプション: --json(型付き JSON 出力)/ --detail <full|compact|brief> / --lang <en|ja>(出力言語。デフォルトは en)/ -v, --version。
--detail は pattern / wcag / technique(詳細・一覧)に適用されます(search / checklist には効きません)。間引く対象はコマンドごとに異なります: pattern の compact は要約とキーボード操作表のみ(ARIA 表・チェックリスト・アンチパターン・関連 WCAG は省略)、wcag の compact は関連パターン・関連 Techniques を省略、technique は元々小さいため compact は full と同じです。--detail brief はタイトル・slug のみの最小表示です。--json でも同じ間引きが data に効きます(--json --detail compact pattern dialog-modal のように併用)。
挙動変更(0.6.0〜):
searchはデフォルトで最大20件を返すようになりました。全件が必要なスクリプトは--limit 0を付けてください(以前のバージョンは常に全件を返していました)。
Exit Codes
| Code | 意味 |
|---|---|
| 0 | 正常終了 |
| 1 | 該当データなし(不明なパターン/達成基準/Technique など)・その他の内部エラー |
| 2 | 使い方の誤り(不明なコマンド・不正なオプション・空クエリなど) |
| 3 | 実行環境の問題(Node.js バージョン不足) |
旧バージョン(〜0.5.x)はすべてのエラーで exit code
1を返していました。スクリプトで exit code を分岐している場合はご注意ください。
使用例
# モーダルダイアログの観点を見る
a11y pattern dialog-modal
# パターン一覧
a11y pattern
# WCAG 達成基準を JSON で取得(スクリプト/AI 向け)
a11y wcag 1-1-1 --json
# 「フォーカス」に関する項目を横断検索
a11y search フォーカス
# タブの実装チェックリストだけ
a11y checklist tabsAI エージェント / スクリプトから使う
--json を付けると、機械可読な封筒で出力します。出力言語のデフォルトは en(--lang ja で日本語のメッセージになります)。
// 成功(--detail 未指定 or full。従来と完全互換のバイト列)
{ "apiVersion": 1, "type": "pattern.detail", "data": { /* ... */ } }
// --detail compact / brief のときだけ封筒に detail フィールドが付く(data も間引かれる)
{ "apiVersion": 1, "type": "pattern.detail", "detail": "compact", "data": { /* 要約とキーボード操作のみ */ } }
// エラー(type: "error" で成功時と機械的に判別でき、code で分岐できる。code は append-only の安定値)
// デフォルト(--lang 未指定 = en)の場合
{ "apiVersion": 1, "type": "error", "error": "Pattern 'dialg' not found",
"code": "ERR_UNKNOWN_PATTERN",
"suggestions": [{ "slug": "dialog-modal", "reason": "Modal dialog (similar name)" }] }
// --lang ja の場合
{ "apiVersion": 1, "type": "error", "error": "'dialg' というパターンはありません",
"code": "ERR_UNKNOWN_PATTERN",
"suggestions": [{ "slug": "dialog-modal", "reason": "モーダルダイアログ(似た名前)" }] }
// commander 自身が検出する不明コマンド・不正オプションも --json 指定時は同じ封筒になる
{ "apiVersion": 1, "type": "error", "error": "error: unknown command 'foo'",
"code": "ERR_INVALID_OPTION" }まず a11y manifest --json でコマンドとレスポンス型の一覧を取得すると、ヘルプをスクレイプせずに使えます。
プログラムから(API)
import { patternDetail, wcagDetail, search } from '@mew-lab/a11y-cli/api';
const { data } = patternDetail('dialog-modal'); // { type, data } を返す。CLI と同じロジックデータについて
掲載している観点は a11y.mew-lab.com と同じ内容です。 APG を参考にした非公式の日本語解説のため、正確な仕様は必ず原文をご確認ください。
English
A CLI/JSON tool for looking up WAI-ARIA APG pattern viewpoints and WCAG 2.2 accessibility guidelines. Access the same knowledge available on a11y.mew-lab.com (in Japanese) from your editor or AI agent.
📦 npm: https://www.npmjs.com/package/@mew-lab/a11y-cli
Installation
# One-off usage (recommended)
npx @mew-lab/a11y-cli pattern dialog-modal
# Install globally
npm install -g @mew-lab/a11y-cli
a11y pattern dialog-modalRequires Node.js 22.13 or later.
Try it locally (no publish):
pnpm --filter @mew-lab/a11y-cli build
pnpm --filter @mew-lab/a11y-cli pack # Generate tarball
npm install -g ./packages/cli/mew-lab-a11y-cli-<version>.tgzCommands
| Command | Description |
|---|---|
| a11y pattern [slug] | APG pattern viewpoints (ARIA, keyboard, checklist, anti-patterns, related WCAG). Lists all patterns when called without arguments |
| a11y wcag [slug] | WCAG 2.2 success criteria (level, principle, summary, reference URL, related patterns). Lists all criteria when called without arguments |
| a11y search <query> | Cross-search across patterns and WCAG. --limit <n> controls how many results are returned (default 20; --limit 0 for all) |
| a11y checklist <slug> | Show only the implementation checklist for a pattern (useful for PR reviews) |
| a11y manifest | Structured manifest of all commands and response types (for AI agents) |
| a11y doctor | Diagnose the runtime environment |
Global options: --json (typed JSON output) / --detail <full|compact|brief> / --lang <en|ja> (output language; defaults to en) / -v, --version.
--detail applies to pattern / wcag / technique (detail and list views); it has no effect on search / checklist. What gets trimmed differs per command: pattern compact prints only the summary and the keyboard interaction table (omits the ARIA table, checklist, anti-patterns, and related WCAG criteria), wcag compact omits related patterns and related techniques, and technique compact is the same as full because the payload is already small. --detail brief prints just the title and slug. --json applies the same trimming to data (e.g. --json --detail compact pattern dialog-modal).
Behavior change (0.6.0+):
searchnow returns at most 20 results by default. Add--limit 0if your scripts need every match (older versions always returned all matches).
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Not found (unknown pattern/criterion/technique, etc.) or other unexpected errors |
| 2 | Usage error (unknown command, invalid option, empty query, etc.) |
| 3 | Environment problem (unsupported Node.js version) |
Older versions (up to 0.5.x) returned exit code
1for every error. If your scripts branch on exit codes, please review this change.
Usage Examples
# View viewpoints for the modal dialog pattern
a11y pattern dialog-modal
# List all patterns
a11y pattern
# Get a WCAG success criterion as JSON (for scripts/AI)
a11y wcag 1-1-1 --json
# Cross-search for items related to "focus"
a11y search focus
# Show only the implementation checklist for tabs
a11y checklist tabsFor AI Agents / Scripts
Add --json to get machine-readable envelope output. The output language defaults to en (pass --lang ja for Japanese messages).
// Success (--detail unspecified or full — byte-identical to previous versions)
{ "apiVersion": 1, "type": "pattern.detail", "data": { /* ... */ } }
// With --detail compact / brief, the envelope gets a detail field (and data is trimmed)
{ "apiVersion": 1, "type": "pattern.detail", "detail": "compact", "data": { /* summary + keyboard interaction only */ } }
// Error (type: "error" lets you distinguish it from a success envelope; use code for branching — codes are append-only stable values)
{ "apiVersion": 1, "type": "error", "error": "Pattern 'dialg' not found",
"code": "ERR_UNKNOWN_PATTERN",
"suggestions": [{ "slug": "dialog-modal", "reason": "Modal dialog (similar name)" }] }
// Unknown commands / invalid options detected by commander itself use the same envelope when --json is set
{ "apiVersion": 1, "type": "error", "error": "error: unknown command 'foo'",
"code": "ERR_INVALID_OPTION" }Start by running a11y manifest --json to get a list of all commands and response types — no need to scrape help output.
Programmatic Usage (API)
import { patternDetail, wcagDetail, search } from '@mew-lab/a11y-cli/api';
const { data } = patternDetail('dialog-modal'); // Returns { type, data } — same logic as the CLIAbout the Data
The viewpoints are the same content as a11y.mew-lab.com. This is an unofficial Japanese guide based on APG — always refer to the original specification for authoritative information.
