@diegovelasquezweb/a11y-engine 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -26
- package/README.md +76 -215
- package/docs/api-reference.md +107 -0
- package/docs/architecture.md +83 -209
- package/docs/cli-handbook.md +4 -4
- package/docs/engine-manifest.md +58 -0
- package/docs/outputs.md +9 -11
- package/docs/testing.md +63 -0
- package/package.json +3 -6
- package/src/core/asset-loader.mjs +22 -14
- package/src/index.d.mts +29 -12
- package/src/index.mjs +49 -52
- package/src/pipeline/dom-scanner.mjs +4 -4
- package/src/reports/checklist.mjs +4 -4
- package/src/reports/html.mjs +5 -5
- package/src/reports/md.mjs +3 -3
- package/src/reports/pdf.mjs +3 -3
- package/src/reports/renderers/findings.mjs +32 -32
- package/src/reports/renderers/md.mjs +6 -4
- package/assets/source/discovery/crawler-config.json +0 -11
- package/assets/source/discovery/stack-detection.json +0 -235
- package/assets/source/engine/cdp-checks.json +0 -30
- package/assets/source/engine/pa11y-config.json +0 -53
- package/assets/source/remediation/axe-check-maps.json +0 -31
- package/assets/source/remediation/code-patterns.json +0 -109
- package/assets/source/remediation/guardrails.json +0 -24
- package/assets/source/remediation/intelligence.json +0 -4166
- package/assets/source/remediation/source-boundaries.json +0 -46
- package/assets/source/reporting/compliance-config.json +0 -173
- package/assets/source/reporting/manual-checks.json +0 -944
- package/assets/source/reporting/wcag-reference.json +0 -588
- package/src/sync-assets.mjs +0 -66
- /package/assets/{generated/discovery → discovery}/crawler-config.mjs +0 -0
- /package/assets/{generated/discovery → discovery}/stack-detection.mjs +0 -0
- /package/assets/{generated/remediation → remediation}/axe-check-maps.mjs +0 -0
- /package/assets/{generated/remediation → remediation}/code-patterns.mjs +0 -0
- /package/assets/{generated/remediation → remediation}/guardrails.mjs +0 -0
- /package/assets/{generated/remediation → remediation}/intelligence.mjs +0 -0
- /package/assets/{generated/remediation → remediation}/source-boundaries.mjs +0 -0
- /package/assets/{generated/reporting → reporting}/compliance-config.mjs +0 -0
- /package/assets/{generated/reporting → reporting}/manual-checks.mjs +0 -0
- /package/assets/{generated/reporting → reporting}/wcag-reference.mjs +0 -0
- /package/assets/{generated/engine → scanning}/cdp-checks.mjs +0 -0
- /package/assets/{generated/engine → scanning}/pa11y-config.mjs +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,38 +5,92 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.4.2] — 2026-03-15
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Broken relative imports in `src/reports/` after architecture migration — report builders were resolving `../../core/` and `../renderers/` instead of `../core/` and `./renderers/`
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## [0.4.1] — 2026-03-15
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Asset loader imports updated to match flattened `assets/` structure (removed `generated/` and `source/` subdirectories)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## [0.4.0] — 2026-03-15
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **Architecture migration**: all source code moved from `scripts/` to `src/` with domain-based modules:
|
|
29
|
+
- `src/cli/` — CLI adapter
|
|
30
|
+
- `src/core/` — utilities, asset loader, toolchain
|
|
31
|
+
- `src/pipeline/` — DOM scanner (axe + CDP + pa11y + merge)
|
|
32
|
+
- `src/enrichment/` — finding analyzer
|
|
33
|
+
- `src/reports/` — report builders and renderers
|
|
34
|
+
- `src/source-patterns/` — source code pattern scanner
|
|
35
|
+
- `src/index.mjs` — public API entry point
|
|
36
|
+
- `src/index.d.mts` — TypeScript declarations
|
|
37
|
+
- Assets simplified to single `.mjs` modules under `assets/` (no more `source/` + `generated/` duplication)
|
|
38
|
+
- `assets/engine/` renamed to `assets/scanning/` for semantic clarity
|
|
39
|
+
- Package entrypoints updated: `main`, `types`, `bin`, `exports` all point to `src/`
|
|
40
|
+
- CLI now invocable via `pnpm exec a11y-audit` (uses package `bin` field instead of internal paths)
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- Vitest regression suite: 8 test files, 26 tests covering asset loading, enrichment, summary, report APIs, source patterns, and `runAudit` integration with mocked modules
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## [0.3.1] — 2026-03-15
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- Assets converted to ESM modules with static imports — eliminates runtime `fs.readFileSync` and resolves Turbopack/Next.js chunk resolution failures
|
|
53
|
+
- `asset-loader.mjs` now uses `import` statements instead of filesystem reads
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## [0.3.0] — 2026-03-15
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- **DOM-based stack detection** — detects framework (Next.js, Nuxt, Gatsby, Angular, Svelte, Astro, Remix, Vue, React), CMS (WordPress, Shopify, Drupal, Wix, Squarespace, Webflow, Joomla, Magento), and UI libraries (Bootstrap, Material UI, jQuery, Foundation) from the live page using window globals, script sources, meta tags, and DOM selectors
|
|
62
|
+
- `runAudit()` — new programmatic API function that orchestrates the full scan pipeline with `onProgress` callback support
|
|
63
|
+
- `detectProjectContextFromDom(page)` — runtime stack detection via `page.evaluate()`
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
|
|
67
|
+
- Stack detection now merges repo-based detection (when `projectDir` is available) with DOM-based detection — repo takes priority, DOM fills gaps
|
|
68
|
+
- `detectProjectContext()` no longer falls back to `process.cwd()` without explicit `projectDir` — prevents false detection of the scanner/host app as the audited site
|
|
69
|
+
- `getAuditSummary` includes `cms` field in `detectedStack`
|
|
70
|
+
- UI library detection requires at least 2 signals or 1 strong signal (global/scriptSrc/meta) to avoid false positives
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## [0.2.0] — 2026-03-14
|
|
9
75
|
|
|
10
76
|
### Added
|
|
11
77
|
|
|
12
|
-
- **Programmatic API** —
|
|
13
|
-
- `
|
|
14
|
-
- `
|
|
15
|
-
- `
|
|
16
|
-
- `
|
|
17
|
-
- `getHTMLReport(payload, options?)` —
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
- `EnrichedFinding` — extends Finding with camelCase aliases and enriched fields
|
|
23
|
-
- `AuditSummary` — full audit summary including totals, score, personas, quick wins, detected stack
|
|
24
|
-
- `SeverityTotals`, `PersonaGroup`, `DetectedStack`, `ComplianceScore`
|
|
25
|
-
- `ScanPayload`, `EnrichmentOptions`, `ReportOptions`
|
|
26
|
-
- `PDFReport`, `HTMLReport`, `ChecklistReport`, `RemediationGuide`
|
|
27
|
-
- `SourcePatternFinding`, `SourcePatternResult`, `SourcePatternOptions`
|
|
28
|
-
- `exports` and `main` fields in `package.json` pointing to `scripts/index.mjs`
|
|
29
|
-
- `--axe-tags` CLI flag passthrough from `audit.mjs` to `dom-scanner.mjs`
|
|
30
|
-
- `resolveScanDirs` exported from `source-scanner.mjs` for programmatic use
|
|
78
|
+
- **Programmatic API** — 8 exported functions accessible via `import { ... } from "@diegovelasquezweb/a11y-engine"`:
|
|
79
|
+
- `runAudit(options)` — runs the full scan pipeline programmatically with progress callback
|
|
80
|
+
- `getEnrichedFindings(input, options?)` — normalizes, canonicalizes, enriches, and sorts findings
|
|
81
|
+
- `getAuditSummary(findings, payload?)` — computes totals, score, personas, quick wins, detected stack
|
|
82
|
+
- `getPDFReport(payload, options?)` — PDF compliance report
|
|
83
|
+
- `getHTMLReport(payload, options?)` — interactive HTML dashboard
|
|
84
|
+
- `getChecklist(options?)` — manual testing checklist
|
|
85
|
+
- `getRemediationGuide(payload, options?)` — Markdown remediation guide
|
|
86
|
+
- `getSourcePatterns(projectDir, options?)` — source code pattern analysis
|
|
87
|
+
- **TypeScript type declarations** shipped with the package (`src/index.d.mts`)
|
|
31
88
|
|
|
32
89
|
### Changed
|
|
33
90
|
|
|
34
|
-
- `getEnrichedFindings` always creates camelCase aliases
|
|
35
|
-
- `getEnrichedFindings` infers `effort`
|
|
36
|
-
- `
|
|
37
|
-
- `getEnrichedFindings` sorts findings by severity (Critical > Serious > Moderate > Minor) then by ID
|
|
38
|
-
- `getAuditSummary` now includes `quickWins` (top 3 Critical/Serious findings with fix code), `targetUrl` (extracted from metadata with fallbacks), and `detectedStack` (framework/CMS/libraries from project context)
|
|
39
|
-
- CLI (`audit.mjs`) continues to work standalone — the programmatic API is additive
|
|
91
|
+
- `getEnrichedFindings` always creates camelCase aliases regardless of existing fix data
|
|
92
|
+
- `getEnrichedFindings` infers `effort` after enrichment: findings with `fixCode` default to `"low"`, others to `"high"`
|
|
93
|
+
- `getAuditSummary` includes `quickWins`, `targetUrl`, and `detectedStack`
|
|
40
94
|
|
|
41
95
|
---
|
|
42
96
|
|
package/README.md
CHANGED
|
@@ -1,271 +1,132 @@
|
|
|
1
1
|
# @diegovelasquezweb/a11y-engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Accessibility automation engine for web applications. It orchestrates multi engine scanning, stack aware enrichment, and report generation for apps and services through a stable API.
|
|
4
4
|
|
|
5
|
-
## What it
|
|
5
|
+
## What it does
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
| Capability | Description |
|
|
8
|
+
| :--- | :--- |
|
|
9
|
+
| **Route discovery crawler** | Builds the scan route set using sitemap discovery first, then a same origin multi level crawl with robots filtering, depth control, and max route limits |
|
|
10
|
+
| **Multi engine scanning** | Runs axe-core, CDP accessibility tree checks, and pa11y HTML CodeSniffer against each page, then merges and deduplicates findings across all three engines |
|
|
11
|
+
| **Stack detection** | Detects framework and CMS from runtime signals and from project source signals such as package.json and file structure |
|
|
12
|
+
| **Fix intelligence** | Enriches each finding with WCAG mapping, fix code snippets, framework and CMS specific notes, UI library ownership hints, effort estimates, and persona impact |
|
|
13
|
+
| **Report generation** | Produces HTML dashboard, PDF compliance report, manual testing checklist, and Markdown remediation guide |
|
|
14
|
+
| **Source code scanning** | Static regex analysis of project source for accessibility patterns that runtime engines cannot detect |
|
|
11
15
|
|
|
12
|
-
##
|
|
16
|
+
## Installation
|
|
13
17
|
|
|
14
18
|
```bash
|
|
15
19
|
npm install @diegovelasquezweb/a11y-engine
|
|
20
|
+
|
|
21
|
+
# Required browsers
|
|
22
|
+
npx playwright install chromium # used by axe-core and CDP checks
|
|
23
|
+
npx puppeteer browsers install chrome # used by pa11y
|
|
16
24
|
```
|
|
17
25
|
|
|
26
|
+
## API Reference
|
|
27
|
+
|
|
28
|
+
### Core API
|
|
29
|
+
|
|
18
30
|
```ts
|
|
19
31
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
runAudit,
|
|
33
|
+
getFindings,
|
|
34
|
+
getOverview,
|
|
22
35
|
getPDFReport,
|
|
23
|
-
getChecklist,
|
|
24
36
|
getHTMLReport,
|
|
37
|
+
getChecklist,
|
|
25
38
|
getRemediationGuide,
|
|
26
39
|
getSourcePatterns,
|
|
27
40
|
} from "@diegovelasquezweb/a11y-engine";
|
|
28
41
|
```
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Normalizes raw scan findings, canonicalizes pa11y rules to axe equivalents, enriches with fix intelligence, infers effort, and sorts by severity.
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
const findings = getEnrichedFindings(scanPayload, {
|
|
36
|
-
screenshotUrlBuilder: (path) => `/api/screenshot?path=${encodeURIComponent(path)}`,
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
| Parameter | Type | Description |
|
|
41
|
-
| :--- | :--- | :--- |
|
|
42
|
-
| `input` | `ScanPayload \| Finding[] \| Record<string, unknown>[]` | Raw scan output or findings array |
|
|
43
|
-
| `options.screenshotUrlBuilder` | `(rawPath: string) => string` | Transforms screenshot file paths into consumer-specific URLs |
|
|
44
|
-
|
|
45
|
-
**Returns**: `EnrichedFinding[]` — normalized, enriched, sorted findings with both snake_case and camelCase fields.
|
|
46
|
-
|
|
47
|
-
### getAuditSummary
|
|
48
|
-
|
|
49
|
-
Computes a complete audit summary from enriched findings.
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
const summary = getAuditSummary(findings, scanPayload);
|
|
53
|
-
// summary.score → 72
|
|
54
|
-
// summary.label → "Good"
|
|
55
|
-
// summary.wcagStatus → "Fail"
|
|
56
|
-
// summary.totals → { Critical: 1, Serious: 3, Moderate: 5, Minor: 2 }
|
|
57
|
-
// summary.personaGroups → { screenReader: {...}, keyboard: {...}, ... }
|
|
58
|
-
// summary.quickWins → [top 3 fixable Critical/Serious findings]
|
|
59
|
-
// summary.targetUrl → "https://example.com"
|
|
60
|
-
// summary.detectedStack → { framework: "nextjs", cms: null, uiLibraries: [] }
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
| Parameter | Type | Description |
|
|
64
|
-
| :--- | :--- | :--- |
|
|
65
|
-
| `findings` | `EnrichedFinding[]` | Output from `getEnrichedFindings` |
|
|
66
|
-
| `payload` | `ScanPayload \| null` | Original scan payload for metadata extraction |
|
|
67
|
-
|
|
68
|
-
**Returns**: `AuditSummary`
|
|
69
|
-
|
|
70
|
-
### getPDFReport
|
|
43
|
+
#### runAudit
|
|
71
44
|
|
|
72
|
-
|
|
45
|
+
Runs the full scan pipeline: route discovery crawler, scan, merge, and analyze. Returns a payload ready for `getFindings`.
|
|
73
46
|
|
|
74
47
|
```ts
|
|
75
|
-
const
|
|
48
|
+
const payload = await runAudit({
|
|
76
49
|
baseUrl: "https://example.com",
|
|
50
|
+
maxRoutes: 5,
|
|
51
|
+
axeTags: ["wcag2a", "wcag2aa", "best-practice"],
|
|
52
|
+
onProgress: (step, status) => console.log(`${step}: ${status}`),
|
|
77
53
|
});
|
|
78
|
-
fs.writeFileSync("report.pdf", buffer);
|
|
79
54
|
```
|
|
80
55
|
|
|
81
|
-
|
|
56
|
+
Progress steps emitted: `page`, `axe`, `cdp`, `pa11y`, `merge`, `intelligence`.
|
|
82
57
|
|
|
83
|
-
|
|
58
|
+
**Common `runAudit` options**
|
|
84
59
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
60
|
+
| Option | Description |
|
|
61
|
+
| :--- | :--- |
|
|
62
|
+
| `baseUrl` | Target URL to scan |
|
|
63
|
+
| `maxRoutes` | Maximum routes to scan |
|
|
64
|
+
| `axeTags` | WCAG tag filters |
|
|
65
|
+
| `projectDir` | Project source path for source-aware detection and pattern scanning |
|
|
66
|
+
| `skipPatterns` | Disable source pattern scanning |
|
|
67
|
+
| `onProgress` | Progress callback for UI updates |
|
|
93
68
|
|
|
94
|
-
|
|
69
|
+
See [API Reference](docs/api-reference.md) for the full `RunAuditOptions` contract.
|
|
95
70
|
|
|
96
|
-
|
|
71
|
+
#### getFindings
|
|
97
72
|
|
|
98
|
-
|
|
73
|
+
Builds the enriched findings list from the `payload` returned by `runAudit`.
|
|
99
74
|
|
|
100
75
|
```ts
|
|
101
|
-
const
|
|
102
|
-
|
|
76
|
+
const findings = getFindings(payload, {
|
|
77
|
+
screenshotUrlBuilder: (path) => `/api/screenshot?path=${encodeURIComponent(path)}`,
|
|
103
78
|
});
|
|
104
79
|
```
|
|
105
80
|
|
|
106
|
-
|
|
81
|
+
Returns `EnrichedFinding[]` ready for UI rendering and report generation.
|
|
107
82
|
|
|
108
|
-
|
|
83
|
+
**Options (`EnrichmentOptions`)**
|
|
109
84
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const { markdown, contentType } = await getRemediationGuide(scanPayload, {
|
|
114
|
-
baseUrl: "https://example.com",
|
|
115
|
-
patternFindings: sourcePatternResult,
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**Returns**: `Promise<RemediationGuide>` — `{ markdown: string, contentType: "text/markdown" }`
|
|
85
|
+
| Option | Type | Description |
|
|
86
|
+
| :--- | :--- | :--- |
|
|
87
|
+
| `screenshotUrlBuilder` | `(rawPath: string) => string` | Rewrites internal screenshot paths into app URLs |
|
|
120
88
|
|
|
121
|
-
|
|
89
|
+
#### getOverview
|
|
122
90
|
|
|
123
|
-
|
|
91
|
+
Computes severity totals, compliance score, WCAG pass/fail status, persona impact groups, quick wins, and detected stack.
|
|
124
92
|
|
|
125
93
|
```ts
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// summary
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## CLI usage
|
|
135
|
-
|
|
136
|
-
The CLI runs the full scan pipeline: crawl, scan with 3 engines, merge, analyze, and generate reports.
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
# Minimal scan
|
|
140
|
-
npx a11y-audit --base-url https://example.com
|
|
141
|
-
|
|
142
|
-
# Full audit with all reports
|
|
143
|
-
npx a11y-audit --base-url https://example.com --with-reports --output ./audit/report.html
|
|
144
|
-
|
|
145
|
-
# Scan with source code intelligence
|
|
146
|
-
npx a11y-audit --base-url http://localhost:3000 --project-dir . --with-reports --output ./audit/report.html
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Targeting and scope
|
|
150
|
-
|
|
151
|
-
| Flag | Argument | Default | Description |
|
|
152
|
-
| :--- | :--- | :--- | :--- |
|
|
153
|
-
| `--base-url` | `<url>` | (Required) | Starting URL for the audit |
|
|
154
|
-
| `--max-routes` | `<num>` | `10` | Max routes to discover and scan |
|
|
155
|
-
| `--crawl-depth` | `<num>` | `2` | BFS link-follow depth during discovery (1-3) |
|
|
156
|
-
| `--routes` | `<csv>` | — | Explicit path list, bypasses auto-discovery |
|
|
157
|
-
| `--project-dir` | `<path>` | — | Path to project source for stack-aware fixes and source pattern scanning |
|
|
158
|
-
|
|
159
|
-
### Audit intelligence
|
|
160
|
-
|
|
161
|
-
| Flag | Argument | Default | Description |
|
|
162
|
-
| :--- | :--- | :--- | :--- |
|
|
163
|
-
| `--target` | `<text>` | `WCAG 2.2 AA` | Compliance target label in reports |
|
|
164
|
-
| `--axe-tags` | `<csv>` | `wcag2a,wcag2aa,wcag21a,wcag21aa,wcag22a,wcag22aa` | axe-core WCAG tag filter |
|
|
165
|
-
| `--only-rule` | `<id>` | — | Run a single axe rule (e.g. `color-contrast`) |
|
|
166
|
-
| `--ignore-findings` | `<csv>` | — | Rule IDs to exclude from output |
|
|
167
|
-
| `--exclude-selectors` | `<csv>` | — | CSS selectors to skip during DOM scan |
|
|
168
|
-
| `--framework` | `<name>` | — | Override auto-detected stack (`nextjs`, `react`, `vue`, `angular`, `svelte`, `shopify`, `wordpress`, etc.) |
|
|
169
|
-
|
|
170
|
-
### Execution and emulation
|
|
171
|
-
|
|
172
|
-
| Flag | Argument | Default | Description |
|
|
173
|
-
| :--- | :--- | :--- | :--- |
|
|
174
|
-
| `--color-scheme` | `light\|dark` | `light` | Emulate `prefers-color-scheme` |
|
|
175
|
-
| `--wait-until` | `domcontentloaded\|load\|networkidle` | `domcontentloaded` | Playwright page load strategy |
|
|
176
|
-
| `--viewport` | `<WxH>` | — | Viewport size (e.g. `375x812`) |
|
|
177
|
-
| `--wait-ms` | `<num>` | `2000` | Delay after page load before scanning (ms) |
|
|
178
|
-
| `--timeout-ms` | `<num>` | `30000` | Network timeout per page (ms) |
|
|
179
|
-
| `--headed` | — | `false` | Run browser in visible mode |
|
|
180
|
-
| `--affected-only` | — | `false` | Re-scan only routes with previous violations |
|
|
181
|
-
|
|
182
|
-
### Output generation
|
|
183
|
-
|
|
184
|
-
| Flag | Argument | Default | Description |
|
|
185
|
-
| :--- | :--- | :--- | :--- |
|
|
186
|
-
| `--with-reports` | — | `false` | Generate HTML + PDF + Checklist reports |
|
|
187
|
-
| `--output` | `<path>` | — | Output path for `report.html` |
|
|
188
|
-
| `--skip-patterns` | — | `false` | Disable source code pattern scanner |
|
|
189
|
-
|
|
190
|
-
## How the scan pipeline works
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
URL
|
|
194
|
-
|
|
|
195
|
-
v
|
|
196
|
-
[1. Crawl & Discover] sitemap.xml / BFS link crawl / explicit --routes
|
|
197
|
-
|
|
|
198
|
-
v
|
|
199
|
-
[2. Navigate] Playwright opens each route in Chromium
|
|
200
|
-
|
|
|
201
|
-
+---> [axe-core] Injects axe into the page, runs WCAG tag checks
|
|
202
|
-
|
|
|
203
|
-
+---> [CDP] Opens a CDP session, reads the full accessibility tree
|
|
204
|
-
|
|
|
205
|
-
+---> [pa11y] Launches HTML CodeSniffer via Puppeteer Chrome
|
|
206
|
-
|
|
|
207
|
-
v
|
|
208
|
-
[3. Merge & Dedup] Combines findings, removes cross-engine duplicates
|
|
209
|
-
|
|
|
210
|
-
v
|
|
211
|
-
[4. Analyze] Enriches with WCAG mapping, severity, fix code, framework hints
|
|
212
|
-
|
|
|
213
|
-
v
|
|
214
|
-
[5. Reports] HTML dashboard, PDF, checklist, Markdown remediation
|
|
94
|
+
const summary = getOverview(findings, payload);
|
|
95
|
+
// summary.score -> 72
|
|
96
|
+
// summary.label -> "Good"
|
|
97
|
+
// summary.wcagStatus -> "Fail"
|
|
98
|
+
// summary.totals -> { Critical: 1, Serious: 3, Moderate: 5, Minor: 2 }
|
|
99
|
+
// summary.personaGroups -> { screenReader: {...}, keyboard: {...}, ... }
|
|
100
|
+
// summary.quickWins -> [top 3 fixable Critical/Serious findings]
|
|
101
|
+
// summary.detectedStack -> { framework: "nextjs", cms: null, uiLibraries: [] }
|
|
215
102
|
```
|
|
216
103
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
### axe-core (via @axe-core/playwright)
|
|
220
|
-
|
|
221
|
-
The primary engine. Runs Deque's axe-core rule set against the live DOM inside Playwright's Chromium. Covers the majority of automatable WCAG 2.2 AA success criteria.
|
|
222
|
-
|
|
223
|
-
### CDP (Chrome DevTools Protocol)
|
|
224
|
-
|
|
225
|
-
Queries the browser's full accessibility tree via a CDP session. Catches issues axe may miss:
|
|
226
|
-
- Interactive elements with no accessible name
|
|
227
|
-
- Focusable elements hidden with `aria-hidden`
|
|
228
|
-
|
|
229
|
-
### pa11y (HTML CodeSniffer)
|
|
230
|
-
|
|
231
|
-
Runs Squiz's HTML CodeSniffer via Puppeteer Chrome. Catches WCAG violations around heading hierarchy, link purpose, and form label associations.
|
|
104
|
+
### Output API
|
|
232
105
|
|
|
233
|
-
|
|
106
|
+
These functions render final artifacts from scan payload data.
|
|
234
107
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
All artifacts are written to `.audit/` relative to the package root.
|
|
238
|
-
|
|
239
|
-
| File | Always generated | Description |
|
|
108
|
+
| Function | Returns | Description |
|
|
240
109
|
| :--- | :--- | :--- |
|
|
241
|
-
| `
|
|
242
|
-
| `
|
|
243
|
-
| `
|
|
244
|
-
| `
|
|
245
|
-
| `
|
|
246
|
-
| `report.pdf` | With `--with-reports` | Formal compliance PDF |
|
|
247
|
-
| `checklist.html` | With `--with-reports` | Manual WCAG testing checklist |
|
|
110
|
+
| `getPDFReport(payload, options?)` | `{ buffer, contentType }` | Formal A4 PDF compliance report |
|
|
111
|
+
| `getHTMLReport(payload, options?)` | `{ html, contentType }` | Interactive HTML audit dashboard |
|
|
112
|
+
| `getChecklist(options?)` | `{ html, contentType }` | Manual WCAG testing checklist |
|
|
113
|
+
| `getRemediationGuide(payload, options?)` | `{ markdown, contentType }` | Markdown remediation guide |
|
|
114
|
+
| `getSourcePatterns(projectDir, options?)` | `{ findings, summary }` | Source code pattern analysis |
|
|
248
115
|
|
|
249
|
-
|
|
116
|
+
See [API Reference](docs/api-reference.md) for exact options and return types.
|
|
250
117
|
|
|
251
|
-
|
|
252
|
-
npm install @diegovelasquezweb/a11y-engine
|
|
253
|
-
npx playwright install chromium
|
|
254
|
-
npx puppeteer browsers install chrome
|
|
255
|
-
```
|
|
118
|
+
## Optional CLI
|
|
256
119
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
> - **Puppeteer Chrome** — used by pa11y (HTML CodeSniffer)
|
|
120
|
+
If you need terminal execution, the package also exposes `a11y-audit`.
|
|
121
|
+
See the [CLI Handbook](docs/cli-handbook.md) for command flags and examples.
|
|
260
122
|
|
|
261
123
|
## Documentation
|
|
262
124
|
|
|
263
125
|
| Resource | Description |
|
|
264
126
|
| :--- | :--- |
|
|
265
|
-
| [Architecture](docs/architecture.md) |
|
|
266
|
-
| [
|
|
127
|
+
| [Architecture](docs/architecture.md) | Multi-engine pipeline, merge logic, and execution model |
|
|
128
|
+
| [API Reference](docs/api-reference.md) | Function signatures, options, and return contracts |
|
|
129
|
+
| [CLI Handbook](docs/cli-handbook.md) | Full flag reference and usage examples |
|
|
267
130
|
| [Output Artifacts](docs/outputs.md) | Schema and structure of every generated file |
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
MIT
|
|
131
|
+
| [Engine Manifest](docs/engine-manifest.md) | Current inventory of source modules, assets, and tests |
|
|
132
|
+
| [Testing](docs/testing.md) | Test categories, scope, and execution commands |
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
**Navigation**: [Home](../README.md) • [Architecture](architecture.md) • [API Reference](api-reference.md) • [CLI Handbook](cli-handbook.md) • [Output Artifacts](outputs.md) • [Engine Manifest](engine-manifest.md) • [Testing](testing.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Core API
|
|
8
|
+
|
|
9
|
+
### `runAudit(options)`
|
|
10
|
+
|
|
11
|
+
Runs route discovery, runtime scan, merge, and analyzer enrichment.
|
|
12
|
+
|
|
13
|
+
`options` (`RunAuditOptions`):
|
|
14
|
+
|
|
15
|
+
| Option | Type |
|
|
16
|
+
| :--- | :--- |
|
|
17
|
+
| `baseUrl` | `string` |
|
|
18
|
+
| `maxRoutes` | `number` |
|
|
19
|
+
| `crawlDepth` | `number` |
|
|
20
|
+
| `routes` | `string` |
|
|
21
|
+
| `waitMs` | `number` |
|
|
22
|
+
| `timeoutMs` | `number` |
|
|
23
|
+
| `headless` | `boolean` |
|
|
24
|
+
| `waitUntil` | `string` |
|
|
25
|
+
| `colorScheme` | `string` |
|
|
26
|
+
| `viewport` | `{ width: number; height: number }` |
|
|
27
|
+
| `axeTags` | `string[]` |
|
|
28
|
+
| `onlyRule` | `string` |
|
|
29
|
+
| `excludeSelectors` | `string[]` |
|
|
30
|
+
| `ignoreFindings` | `string[]` |
|
|
31
|
+
| `framework` | `string` |
|
|
32
|
+
| `projectDir` | `string` |
|
|
33
|
+
| `skipPatterns` | `boolean` |
|
|
34
|
+
| `screenshotsDir` | `string` |
|
|
35
|
+
| `onProgress` | `(step: string, status: string, extra?: Record<string, unknown>) => void` |
|
|
36
|
+
|
|
37
|
+
Returns: `Promise<ScanPayload>`
|
|
38
|
+
|
|
39
|
+
### `getFindings(input, options?)`
|
|
40
|
+
|
|
41
|
+
Normalizes and enriches findings and returns sorted enriched findings.
|
|
42
|
+
|
|
43
|
+
- `input`: `ScanPayload` from `runAudit`
|
|
44
|
+
- `options` (`EnrichmentOptions`):
|
|
45
|
+
- `screenshotUrlBuilder?: (rawPath: string) => string`
|
|
46
|
+
|
|
47
|
+
Returns: `EnrichedFinding[]`
|
|
48
|
+
|
|
49
|
+
### `getOverview(findings, payload?)`
|
|
50
|
+
|
|
51
|
+
Computes totals, score, WCAG status, persona groups, quick wins, target URL, and detected stack.
|
|
52
|
+
|
|
53
|
+
- `findings`: `EnrichedFinding[]`
|
|
54
|
+
- `payload`: `ScanPayload | null`
|
|
55
|
+
|
|
56
|
+
Returns: `AuditSummary`
|
|
57
|
+
|
|
58
|
+
## Output API
|
|
59
|
+
|
|
60
|
+
### `getPDFReport(payload, options?)`
|
|
61
|
+
|
|
62
|
+
- `payload`: `ScanPayload`
|
|
63
|
+
- `options`: `ReportOptions`
|
|
64
|
+
- `baseUrl?: string`
|
|
65
|
+
- `target?: string`
|
|
66
|
+
|
|
67
|
+
Returns: `Promise<PDFReport>` (`{ buffer, contentType }`)
|
|
68
|
+
|
|
69
|
+
### `getHTMLReport(payload, options?)`
|
|
70
|
+
|
|
71
|
+
- `payload`: `ScanPayload`
|
|
72
|
+
- `options`: `HTMLReportOptions`
|
|
73
|
+
- `baseUrl?: string`
|
|
74
|
+
- `target?: string`
|
|
75
|
+
- `screenshotsDir?: string`
|
|
76
|
+
|
|
77
|
+
Returns: `Promise<HTMLReport>` (`{ html, contentType }`)
|
|
78
|
+
|
|
79
|
+
### `getChecklist(options?)`
|
|
80
|
+
|
|
81
|
+
- `options`: `Pick<ReportOptions, "baseUrl">`
|
|
82
|
+
- `baseUrl?: string`
|
|
83
|
+
|
|
84
|
+
Returns: `Promise<ChecklistReport>` (`{ html, contentType }`)
|
|
85
|
+
|
|
86
|
+
### `getRemediationGuide(payload, options?)`
|
|
87
|
+
|
|
88
|
+
- `payload`: `ScanPayload & { incomplete_findings?: unknown[] }`
|
|
89
|
+
- `options`: `RemediationOptions`
|
|
90
|
+
- `baseUrl?: string`
|
|
91
|
+
- `target?: string`
|
|
92
|
+
- `patternFindings?: Record<string, unknown> | null`
|
|
93
|
+
|
|
94
|
+
Returns: `Promise<RemediationGuide>` (`{ markdown, contentType }`)
|
|
95
|
+
|
|
96
|
+
### `getSourcePatterns(projectDir, options?)`
|
|
97
|
+
|
|
98
|
+
- `projectDir`: `string`
|
|
99
|
+
- `options`: `SourcePatternOptions`
|
|
100
|
+
- `framework?: string`
|
|
101
|
+
- `onlyPattern?: string`
|
|
102
|
+
|
|
103
|
+
Returns: `Promise<SourcePatternResult>`
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
Canonical type source: `src/index.d.mts`
|