@diegovelasquezweb/a11y-engine 0.11.0 → 0.11.2
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/docs/api-reference.md +20 -0
- package/docs/intelligence.md +13 -0
- package/docs/outputs.md +3 -0
- package/package.json +1 -1
- package/src/pipeline/dom-scanner.mjs +7 -2
package/docs/api-reference.md
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- [Constants](#constants)
|
|
25
25
|
- [VIEWPORT_PRESETS](#viewport_presets)
|
|
26
26
|
- [DEFAULT_AI_SYSTEM_PROMPT](#default_ai_system_prompt)
|
|
27
|
+
- [PM_AI_SYSTEM_PROMPT](#pm_ai_system_prompt)
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
@@ -52,6 +53,7 @@ import {
|
|
|
52
53
|
getKnowledge,
|
|
53
54
|
VIEWPORT_PRESETS,
|
|
54
55
|
DEFAULT_AI_SYSTEM_PROMPT,
|
|
56
|
+
PM_AI_SYSTEM_PROMPT,
|
|
55
57
|
} from "@diegovelasquezweb/a11y-engine";
|
|
56
58
|
```
|
|
57
59
|
|
|
@@ -121,6 +123,7 @@ Returns a `ScanPayload` object consumed by all other functions.
|
|
|
121
123
|
| `ai.githubToken` | `string` | — | GitHub PAT | Used to fetch source files from the repo for AI context |
|
|
122
124
|
| `ai.model` | `string` | `"claude-haiku-4-5-20251001"` | Anthropic model ID | Claude model to use |
|
|
123
125
|
| `ai.systemPrompt` | `string` | Built-in prompt | — | Overrides the default Claude system prompt for the entire scan |
|
|
126
|
+
| `ai.audience` | `string` | `"dev"` | `"dev"` \| `"pm"` | Controls the AI enrichment tone. `"dev"` generates code-level fixes; `"pm"` generates business impact summaries |
|
|
124
127
|
| `clearCache` | `boolean` | `false` | — | Clear browser cache before each page navigation via CDP `Network.clearBrowserCache`. Ensures fresh results on repeated scans of the same domain |
|
|
125
128
|
| `serverMode` | `boolean` | `false` | — | Enable server/EC2/Docker Chrome launch flags: `--no-sandbox`, `--disable-setuid-sandbox`, `--disable-dev-shm-usage`, `--disable-gpu`, `--no-zygote`, `--disable-accelerated-2d-canvas`. Use in CI, Docker, or EC2 environments |
|
|
126
129
|
| `onProgress` | `function` | — | — | Callback fired at each pipeline step |
|
|
@@ -328,6 +331,11 @@ Returns: `EnrichedFinding[]`
|
|
|
328
331
|
guardrails: object | null, // Guardrail metadata from the engine
|
|
329
332
|
checkData: object | null, // Raw check data from the engine
|
|
330
333
|
|
|
334
|
+
// PM audience fields (always present from intelligence DB)
|
|
335
|
+
pmSummary: string | null, // One-line business impact for PMs
|
|
336
|
+
pmImpact: string | null, // Business/legal/UX consequences
|
|
337
|
+
pmEffort: string | null, // "quick-win" | "medium" | "strategic"
|
|
338
|
+
|
|
331
339
|
// AI enrichment (only when ai.enabled ran)
|
|
332
340
|
aiEnhanced?: boolean, // true when AI enriched this finding
|
|
333
341
|
aiFixDescription?: string, // Claude-generated fix explanation
|
|
@@ -671,6 +679,18 @@ Type: `string`
|
|
|
671
679
|
|
|
672
680
|
---
|
|
673
681
|
|
|
682
|
+
### `PM_AI_SYSTEM_PROMPT`
|
|
683
|
+
|
|
684
|
+
The system prompt used for PM-audience AI enrichment. Instructs Claude to generate business-oriented summaries instead of developer-focused fixes. Used automatically when `ai.audience` is `"pm"`.
|
|
685
|
+
|
|
686
|
+
```ts
|
|
687
|
+
import { PM_AI_SYSTEM_PROMPT } from "@diegovelasquezweb/a11y-engine";
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
Type: `string`
|
|
691
|
+
|
|
692
|
+
---
|
|
693
|
+
|
|
674
694
|
> **Note on `ai_enriched_findings` fast path**: When `getFindings()` receives a payload that contains `ai_enriched_findings` and no `screenshotUrlBuilder` option is provided, it returns `ai_enriched_findings` directly without re-normalizing the raw `findings` array. If a `screenshotUrlBuilder` is provided, normalization always runs so paths can be rewritten.
|
|
675
695
|
|
|
676
696
|
---
|
package/docs/intelligence.md
CHANGED
|
@@ -68,6 +68,9 @@ Each rule entry can include:
|
|
|
68
68
|
| `cms_notes` | CMS-specific fix guidance |
|
|
69
69
|
| `preferred_relationship_checks` | axe check IDs to prioritize for relationship hints |
|
|
70
70
|
| `guardrails` / `guardrails_overrides` | Must/must-not/verify constraints for automated fixes |
|
|
71
|
+
| `pm.summary` | One-line business impact for PM audience (e.g. "Buttons without labels block screen reader users from key actions") |
|
|
72
|
+
| `pm.impact` | Business/legal/UX consequences for non-technical stakeholders |
|
|
73
|
+
| `pm.effort` | Effort classification: `quick-win`, `medium`, or `strategic` |
|
|
71
74
|
|
|
72
75
|
When a framework is detected (e.g. `nextjs`), only the relevant framework notes are included in the output. React-based frameworks (`nextjs`, `gatsby`) resolve to `react` notes.
|
|
73
76
|
|
|
@@ -250,6 +253,16 @@ AI enrichment runs automatically when `ANTHROPIC_API_KEY` is present in the envi
|
|
|
250
253
|
|
|
251
254
|
The default system prompt instructs Claude to go beyond the generic fix: explain why the issue matters for users, reference the specific selector and violation data, and provide a more complete code example than the engine's default. The prompt can be overridden per-scan via the `AI_SYSTEM_PROMPT` env var or `options.ai.systemPrompt` in the programmatic API.
|
|
252
255
|
|
|
256
|
+
### PM audience mode
|
|
257
|
+
|
|
258
|
+
When `ai.audience` is set to `"pm"`, the AI enrichment uses a PM-specific system prompt that generates business-oriented guidance instead of developer-focused fixes. The PM prompt instructs Claude to produce:
|
|
259
|
+
|
|
260
|
+
- `pmSummary` — one-line business impact in plain language
|
|
261
|
+
- `pmImpact` — 2-3 sentences on legal/compliance/UX consequences
|
|
262
|
+
- `pmEffort` — `quick-win`, `medium`, or `strategic` with time estimate
|
|
263
|
+
|
|
264
|
+
These AI-generated PM fields override the static PM fields from the intelligence database for Critical and Serious findings, similar to how `fixDescription` overrides the static fix for dev audience.
|
|
265
|
+
|
|
253
266
|
## Assets Reference
|
|
254
267
|
|
|
255
268
|
| Asset | Used by | Purpose |
|
package/docs/outputs.md
CHANGED
|
@@ -185,6 +185,9 @@ The primary enriched data artifact. Written by `src/enrichment/analyzer.mjs`. Th
|
|
|
185
185
|
| `verification_command_fallback` | `string\|null` | Fallback verify command |
|
|
186
186
|
| `pages_affected` | `number\|null` | Number of pages with this violation |
|
|
187
187
|
| `affected_urls` | `string[]\|null` | All URLs where this violation appears |
|
|
188
|
+
| `pm_summary` | `string\|null` | One-line business impact for PM audience. Populated from the intelligence database for all findings. |
|
|
189
|
+
| `pm_impact` | `string\|null` | Business/legal/UX consequences for non-technical stakeholders. |
|
|
190
|
+
| `pm_effort` | `string\|null` | Effort classification: `quick-win`, `medium`, or `strategic`. |
|
|
188
191
|
| `aiEnhanced` | `boolean` | `true` when Claude improved the fix for this finding. Only present on AI-enriched findings. |
|
|
189
192
|
| `ai_fix_description` | `string\|null` | Claude-generated fix description. More specific than `fix_description` — references the actual selector, colors, and violation data. Only present when `aiEnhanced` is `true`. |
|
|
190
193
|
| `ai_fix_code` | `string\|null` | Claude-generated code snippet in the correct framework syntax. Separate from the engine's `fix_code`. Only present when `aiEnhanced` is `true`. |
|
package/package.json
CHANGED
|
@@ -961,7 +961,7 @@ async function runCdpChecks(page) {
|
|
|
961
961
|
* The browser is NOT closed by this function — the caller is responsible for lifecycle.
|
|
962
962
|
* @returns {Promise<Object[]>} Array of pa11y-sourced violations in axe-compatible format.
|
|
963
963
|
*/
|
|
964
|
-
async function runPa11yChecks(routeUrl, axeTags, sharedBrowser = null) {
|
|
964
|
+
async function runPa11yChecks(routeUrl, axeTags, sharedBrowser = null, includeWarnings = false) {
|
|
965
965
|
const violations = [];
|
|
966
966
|
const equivalenceMap = PA11Y_CONFIG.equivalenceMap || {};
|
|
967
967
|
const impactMap = {};
|
|
@@ -985,6 +985,8 @@ async function runPa11yChecks(routeUrl, axeTags, sharedBrowser = null) {
|
|
|
985
985
|
timeout: 30000,
|
|
986
986
|
wait: 2000,
|
|
987
987
|
ignore: ignoreList,
|
|
988
|
+
includeWarnings: Boolean(includeWarnings),
|
|
989
|
+
includeNotices: false,
|
|
988
990
|
};
|
|
989
991
|
|
|
990
992
|
if (sharedBrowser) {
|
|
@@ -1126,6 +1128,8 @@ function mergeViolations(axeViolations, cdpViolations, pa11yViolations) {
|
|
|
1126
1128
|
/**
|
|
1127
1129
|
* Runs the DOM scanner programmatically.
|
|
1128
1130
|
* @param {Object} options - Scanner configuration (same shape as CLI args object).
|
|
1131
|
+
* @param {boolean} [options.includeWarnings] - Include pa11y WARNING-level issues (default: false). Automatically enabled when includeIncomplete is true.
|
|
1132
|
+
* @param {boolean} [options.includeIncomplete] - Include axe incomplete findings and activates includeWarnings (default: false).
|
|
1129
1133
|
* @param {{ onProgress?: (step: string, status: string, extra?: object) => void }} [callbacks={}]
|
|
1130
1134
|
* @returns {Promise<Object>} The scan payload { generated_at, base_url, onlyRule, projectContext, routes }.
|
|
1131
1135
|
*/
|
|
@@ -1153,6 +1157,7 @@ export async function runDomScanner(options = {}, callbacks = {}) {
|
|
|
1153
1157
|
cdp: options.engines?.cdp !== false,
|
|
1154
1158
|
pa11y: options.engines?.pa11y !== false,
|
|
1155
1159
|
},
|
|
1160
|
+
includeWarnings: options.includeWarnings ?? options.includeIncomplete ?? false,
|
|
1156
1161
|
clearCache: options.clearCache ?? false,
|
|
1157
1162
|
serverMode: options.serverMode ?? false,
|
|
1158
1163
|
};
|
|
@@ -1409,7 +1414,7 @@ async function _runDomScannerInternal(args) {
|
|
|
1409
1414
|
let pa11yPromise = Promise.resolve([]);
|
|
1410
1415
|
if (args.engines.pa11y) {
|
|
1411
1416
|
if (!emittedDone.has("pa11y")) writeProgress("pa11y", "running");
|
|
1412
|
-
pa11yPromise = runPa11yChecks(targetUrl, args.axeTags, pa11yBrowser)
|
|
1417
|
+
pa11yPromise = runPa11yChecks(targetUrl, args.axeTags, pa11yBrowser, args.includeWarnings)
|
|
1413
1418
|
.then((violations) => {
|
|
1414
1419
|
if (!emittedDone.has("pa11y")) {
|
|
1415
1420
|
writeProgress("pa11y", "done", { found: violations.length });
|