High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
docs(a11y): document the axe engine and 'a11y audit' command (PIN-397)
Luigi Agostie508f795247c
diff --git a/docs/commands.md b/docs/commands.mdindex d4960068..e863c99c 100644--- a/docs/commands.md+++ b/docs/commands.md@@ -205,8 +205,19 @@ pinchtab find --threshold <0-1> # Minimum similarity scorepinchtab find --explain # Include score breakdownpinchtab find --ref-only # Print only the best refpinchtab eval <expression> # Evaluate JavaScript+pinchtab a11y audit # Accessibility score + findings (native engine)+pinchtab a11y audit --axe # Run axe-core in the page (industry rule ids)+pinchtab a11y audit --axe --tags wcag2a,wcag2aa # axe: filter by WCAG tags+pinchtab a11y audit --axe --rules image-alt,label # axe: run only these rule ids+pinchtab a11y audit --axe --json # Full JSON envelope with per-node refs```+`pinchtab a11y audit --axe` runs the vendored axe-core engine (see+[reference/a11y.md](reference/a11y.md)) in the page's isolated world, so page+script cannot tamper with the result. Each violation node that maps to a+snapshot ref carries it, so a failing element can be actioned directly with+`pinchtab action`.+`pinchtab eval` is intentionally not frame-scoped. Current `pinchtab frame`state affects selector-based commands such as `snap`, `click`, `fill`, and`type`, and it also affects `text` when `--frame` is not provided explicitly.diff --git a/docs/reference/a11y.md b/docs/reference/a11y.mdnew file mode 100644index 00000000..558d47c7--- /dev/null+++ b/docs/reference/a11y.md@@ -0,0 +1,94 @@+# Accessibility Audit++`/a11y/audit` scores a page for accessibility issues. It has two engines:++- **native** (default) — PinchTab's home-grown rule set over the accessibility+ snapshot. Fast, no page script.+- **axe** — vendored [axe-core](https://github.com/dequelabs/axe-core) run in+ the page, returning the industry rule ids, WCAG tags and help URLs humans+ already know, plus a snapshot `ref` for each failing element so an agent can+ act on it directly.++## Endpoints++- `GET /a11y/audit`+- `GET /tabs/{id}/a11y/audit`++## Query Parameters++| Parameter | Engine | Default | Description |+| --- | --- | --- | --- |+| `engine` | both | `native` | `native` or `axe`; any other value is a `400` |+| `tabId` | both | active tab | Tab ID when using `GET /a11y/audit` |+| `tags` | axe | WCAG tags without best-practice | Comma list of WCAG tags to run, e.g. `wcag2a,wcag2aa,best-practice` |+| `rules` | axe | all in-tag rules | Comma allowlist of rule ids; wins over `tags` |+| `includeIncomplete` | axe | `false` | Include rules axe could not decide (the `incomplete` set) |+| `selector` | axe | whole document | Scope the run to a CSS selector |++A `best-practice` rule appears only when `tags` includes `best-practice`; the+default tag set is WCAG conformance tags only.++## axe Response++```json+{+ "engine": "axe",+ "version": "4.13.0",+ "url": "https://example.com/",+ "violations": [+ {+ "id": "image-alt",+ "impact": "critical",+ "tags": ["wcag2a", "wcag111"],+ "help": "Images must have alternate text",+ "helpUrl": "https://dequeuniversity.com/rules/axe/4.13/image-alt",+ "nodes": [+ {+ "target": ["#no-alt"],+ "html": "<img id=\"no-alt\">",+ "ref": "e5",+ "failureSummary": "Fix any of the following: ..."+ }+ ]+ }+ ],+ "passes": 9,+ "incomplete": 0,+ "inapplicable": 51,+ "score": 70+}+```++- `version` echoes the vendored axe-core version (see `THIRD_PARTY_LICENSES.md`).+- `ref` is filled when the failing element maps to a snapshot ref, so an agent+ can fall straight to `/action` on it.+- `incompleteViolations` (details) is included only when `includeIncomplete=true`;+ the `incomplete` count is always present.+- `score` reuses the native 0–100 scale (`100` minus severity-weighted violation+ counts, floored at `0`) so axe and native scores stay comparable on a+ dashboard.++The script runs in PinchTab's **isolated world**, so a page that overrides+`window.axe` or a DOM prototype cannot alter the result.++## Examples++```bash+# axe engine, JSON+curl "http://localhost:9867/a11y/audit?engine=axe" -H "Authorization: Bearer $TOKEN"++# WCAG 2.0 A only (drops the AA-only color-contrast rule)+curl "http://localhost:9867/a11y/audit?engine=axe&tags=wcag2a" -H "Authorization: Bearer $TOKEN"++# CLI+pinchtab a11y audit --axe+pinchtab a11y audit --axe --tags wcag2a,wcag2aa --json+```++## Native Response++With `engine` omitted the response is the native report unchanged:++```json+{ "tabId": "...", "score": 88, "findings": [ { "rule": "missing-alt", "severity": "serious", "count": 1, "samples": ["image e5"] } ] }+```