@kinti/a11y-toolkit 5.26.0 → 5.27.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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/a11y_toolkit/a11y.py +27 -4
  3. package/a11y_toolkit/a11yact.py +9 -1
  4. package/a11y_toolkit/a11yannotate.py +185 -0
  5. package/a11y_toolkit/a11yaudit.py +853 -193
  6. package/a11y_toolkit/a11ybadge.py +24 -17
  7. package/a11y_toolkit/a11ybudget.py +145 -1
  8. package/a11y_toolkit/a11ycorpus.py +58 -24
  9. package/a11y_toolkit/a11ycrit.py +110 -53
  10. package/a11y_toolkit/a11ydiff.py +104 -34
  11. package/a11y_toolkit/a11ydisprove.py +15 -8
  12. package/a11y_toolkit/a11ydocx.py +8 -6
  13. package/a11y_toolkit/a11ydom.py +425 -95
  14. package/a11y_toolkit/a11yen301549.py +53 -1
  15. package/a11y_toolkit/a11yengines.py +157 -0
  16. package/a11y_toolkit/a11yevidence.py +81 -33
  17. package/a11y_toolkit/a11yfix.py +131 -52
  18. package/a11y_toolkit/a11yinit.py +30 -5
  19. package/a11y_toolkit/a11yjourney.py +110 -4
  20. package/a11y_toolkit/a11yledger.py +119 -12
  21. package/a11y_toolkit/a11ylocate.py +247 -0
  22. package/a11y_toolkit/a11yopenacr.py +10 -3
  23. package/a11y_toolkit/a11ypatches.py +154 -0
  24. package/a11y_toolkit/a11ypatterns.py +344 -0
  25. package/a11y_toolkit/a11ypdf.py +109 -53
  26. package/a11y_toolkit/a11yrgaa.py +60 -0
  27. package/a11y_toolkit/a11yroute.py +34 -12
  28. package/a11y_toolkit/a11ysarif.py +45 -18
  29. package/a11y_toolkit/a11yscope.py +67 -15
  30. package/a11y_toolkit/a11yscroll.py +7 -5
  31. package/a11y_toolkit/a11ystatement.py +30 -6
  32. package/a11y_toolkit/a11ytrace.py +293 -0
  33. package/a11y_toolkit/a11yvalidate.py +21 -15
  34. package/a11y_toolkit/a11yvpat.py +34 -7
  35. package/a11y_toolkit/a11yvtt.py +22 -6
  36. package/a11y_toolkit/a11ywiz.py +121 -0
  37. package/a11y_toolkit/contrast.py +62 -24
  38. package/a11y_toolkit/locales/en.json +177 -20
  39. package/a11y_toolkit/locales/es.json +178 -21
  40. package/a11y_toolkit/rgaa.json +2661 -0
  41. package/a11y_toolkit/server.py +149 -50
  42. package/package.json +2 -2
  43. package/a11y_toolkit/a11yplan.py +0 -214
  44. package/a11y_toolkit/a11ywcagem.py +0 -237
@@ -13,6 +13,10 @@ Tools:
13
13
  - a11y_suggest_color(fg, bg, target?) nearest passing color
14
14
  - a11y_generate_declaration(...) legal statement RD 1112/2018 / EAA
15
15
  - a11y_snapshot(url) interactive elements + tab order
16
+ - a11y_locate(html, query, role?, multiple?) element by accessible name →
17
+ deterministic route, honest refusal
18
+ - a11y_patches(html, lang?) sealed patch-set of the
19
+ deterministic fixes (sha-keyed)
16
20
  - a11y_diff(a, b) regression diff between snapshots
17
21
  - a11y_diff_urls(url_a, url_b) staging vs production in one call
18
22
  - a11y_aria_live_snippet(lang?) injectable live-region monitor
@@ -26,6 +30,7 @@ Tools:
26
30
  - a11y_hover(url, …) tooltip Escape dismissibility (1.4.13)
27
31
  - a11y_sr_transcript(url, …) what a blind user hears, linearized
28
32
  - a11y_journey_verdict(task, steps, outcome) blindfold task verdict: friction log → scored evidence
33
+ (seal=true → the sha-sealed a11y-journey/1 record)
29
34
  - a11y_vtt_check(url, …) caption CONTENT quality (1.2.2)
30
35
  - a11y_audit_pdf(path) PDF structural screening — nobody automated it
31
36
  - a11y_docx_screen(path) DOCX structural screening (alt, fake headings, lang, table headers)
@@ -45,7 +50,7 @@ Tools:
45
50
  human confirms (EN 301 549 clauses)
46
51
 
47
52
  Prompts: audit-page, fix-contrast, pre-deploy-check, declaration-eaa,
48
- conformance-wcagem, blindfold-task.
53
+ blindfold-task.
49
54
 
50
55
  Register in an MCP client (no clone needed):
51
56
 
@@ -68,8 +73,10 @@ from .a11yscroll import audit_scroll # noqa: E402
68
73
  from .a11yvalidate import validate_url, validate_html # noqa: E402
69
74
  from .a11yevidence import build_pack as build_pack_fn # noqa: E402
70
75
  from .a11ydiff import snapshot as snapshot_fn, diff as diff_fn # noqa: E402
76
+ from .a11ylocate import locate as locate_fn # noqa: E402
77
+ from .a11ypatches import build as patches_build_fn, apply_patches as patches_apply_fn # noqa: E402
71
78
  from .a11ycrit import criterion as criterion_fn # noqa: E402
72
- from .a11yjourney import verdict as journey_verdict_fn # noqa: E402
79
+ from .a11yjourney import verdict as journey_verdict_fn, seal_record as journey_seal_fn, record_verify as journey_verify_fn # noqa: E402
73
80
  from .a11yvtt import vtt_check as vtt_check_fn # noqa: E402
74
81
  from .a11ypdf import pdf_screen as pdf_screen_fn # noqa: E402
75
82
  from .a11ydocx import docx_screen as docx_screen_fn # noqa: E402
@@ -90,7 +97,7 @@ try:
90
97
  except ImportError:
91
98
  ARIALIVE_JS = None # repo checkout: read the file
92
99
 
93
- VERSION = '5.26.0'
100
+ VERSION = '5.27.0'
94
101
 
95
102
  # Params renombrados a inglés en 5.11.0; se aceptan los nombres previos.
96
103
  PARAM_ALIASES = {
@@ -130,7 +137,7 @@ TOOLS = [
130
137
  {
131
138
  'name': 'a11y_audit_url',
132
139
  'description': ('Express WCAG 2.2 audit of a URL or an HTML string: 20+ automated '
133
- 'signals with a weighted 0-100 score — images without alt (1.1.1), '
140
+ 'signals with a weighted 0-100 score — images without alt (1.1.1), low-quality alt text (filenames, generics, placeholders; also 1.1.1), '
134
141
  'controls without accessible names (4.1.2), form fields without labels '
135
142
  '(3.3.2), missing autocomplete on user-data fields (1.3.5), click '
136
143
  'handlers on non-interactive elements (2.1.1), unknown ARIA roles and '
@@ -149,10 +156,46 @@ TOOLS = [
149
156
  'pages': {'type': 'integer', 'minimum': 1, 'maximum': 20, 'description': 'light same-domain crawl: audit up to N pages, aggregated by score and recurring signals (default 1, max 20)'},
150
157
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
151
158
  'timeout': {'type': 'number', 'description': 'fetch timeout seconds (30 default)'},
152
- 'standard': {'type': 'string', 'enum': ['en301549'], 'description': 'add the EN 301 549 V4.1.1 (2026) clause to every finding plus a standard block (EAA procurement, Canada ICT standard)'},
159
+ 'standard': {'type': 'string', 'enum': ['en301549', 'rgaa'], 'description': 'en301549: EN clause per finding (EAA procurement, Canada ICT) · rgaa: French RGAA criterion per finding'},
153
160
  'target': {'type': 'string', 'enum': ['web', 'documents', 'software'], 'description': 'EN 301 549 target: web=9.x clauses (default), documents=10.x, software=11.x'},
154
161
  }},
155
162
  },
163
+ {
164
+ 'name': 'a11y_locate',
165
+ 'description': ('Find an element by its accessible name and get its deterministic '
166
+ 'route selector (the same tag:nth-of-type identity annotate() uses): '
167
+ 'controls, headings, images with alt, iframes with title, fields '
168
+ 'with an explicit name. High confidence only on exact unique '
169
+ 'matches; when several elements share the name it refuses to pick '
170
+ 'one and returns the full candidate list (ambiguous) — a match is '
171
+ 'never invented. Feeds agents that edit code by selector and '
172
+ 'panel deep-links.'),
173
+ 'inputSchema': {'type': 'object', 'properties': {
174
+ 'html': {'type': 'string', 'description': 'raw HTML to search'},
175
+ 'query': {'type': 'string', 'description': 'accessible name to find (e.g. "Submit")'},
176
+ 'role': {'type': 'string', 'description': 'filter by role: button, link, textbox, checkbox, radio, combobox, heading, h1-h6, image…'},
177
+ 'multiple': {'type': 'boolean', 'description': 'list every exact match instead of refusing (default false)'},
178
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
179
+ }, 'required': ['html', 'query']},
180
+ },
181
+ {
182
+ 'name': 'a11y_patches',
183
+ 'description': ('Sealed patch-set of the deterministic safe fixes: build runs '
184
+ 'a11y_autofix once and records WHICH fixes were applied to WHICH '
185
+ 'page (SHA-256-keyed, format a11y-patches/1, engine version '
186
+ 'stamped); verify re-checks a set against a page — the same page '
187
+ 'must reproduce the same fixes, a different page is stale (sets '
188
+ 'never blind-apply). The artifact an agent or CI applies upstream: '
189
+ 'fixing the original web is the client job, the engine hands over '
190
+ 'the evidence.'),
191
+ 'inputSchema': {'type': 'object', 'properties': {
192
+ 'html': {'type': 'string', 'description': 'raw HTML'},
193
+ 'action': {'type': 'string', 'enum': ['build', 'verify'], 'description': 'build: run autofix and seal the record (default); verify: check patch_set against this html'},
194
+ 'patch_set': {'type': 'object', 'description': 'a11y-patches/1 artifact (verify only)'},
195
+ 'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
196
+ 'title': {'type': 'string', 'description': 'title for the fixed copy (build only)'},
197
+ }, 'required': ['html']},
198
+ },
156
199
  {
157
200
  'name': 'a11y_audit_dom',
158
201
  'description': ('Deep RENDERED WCAG audit via local Playwright/Chromium: real computed '
@@ -361,6 +404,7 @@ TOOLS = [
361
404
  'lang': {'type': 'string', 'enum': ['es', 'en']},
362
405
  'max_batches': {'type': 'integer', 'description': 'scroll batches (5 default)'},
363
406
  'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit an authenticated feed'},
407
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
364
408
  },
365
409
  'required': ['url']},
366
410
  },
@@ -385,6 +429,8 @@ TOOLS = [
385
429
  'scope': {'type': 'object', 'description': 'a11y_scope output: human-confirmed exclusions become not-applicable rows with their reason (machine proposals never exclude)'},
386
430
  'reviewer': {'type': 'object', 'description': '{"name":…, "credential":…, "review_date":…} to prefill the signature block'},
387
431
  'verified': {'type': 'array', 'items': {'type': 'string'}, 'description': 'Criterion codes an agent/human verified against this sample (manual checklist protocol) — they become agent-verified in the matrix; automated-fail stays fail'},
432
+ 'build': {'type': 'object', 'description': 'Build reference sealed into the pack sha — the claim→artifact chain: {"commit":…, "ci_url":…} or {"ref": "git:716d870"}'},
433
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'Pack language: matrix status labels and notes (en default)'},
388
434
  }, 'required': ['reports']},
389
435
  },
390
436
  {
@@ -408,9 +454,10 @@ TOOLS = [
408
454
  'inputSchema': {'type': 'object', 'properties': {
409
455
  'reports': {'type': 'array', 'items': {'type': 'object'},
410
456
  'description': 'audit report objects (any mode; reports carrying the features block power the machine proposals)'},
411
- 'standard': {'type': 'string', 'enum': ['wcag22', 'en301549'], 'description': 'wcag22 (default) or en301549: adds clause refs + EN families'},
457
+ 'standard': {'type': 'string', 'enum': ['wcag22', 'en301549', 'rgaa'], 'description': 'wcag22 (default), en301549 (clause refs + EN families) or rgaa (French 106-criterion checklist)'},
412
458
  'target': {'type': 'string', 'enum': ['web', 'documents', 'software'], 'description': 'ICT target: web=9.x clauses (default), documents=10.x, software=11.x'},
413
- 'answers': {'type': 'object', 'description': 'human confirmations keyed by criterion code: {"1.2.4": {"status": "excluded", "reason": "no live media"}} — status in-scope|proposed-excluded|excluded'},
459
+ 'targets': {'type': 'array', 'items': {'type': 'string', 'enum': ['web', 'documents', 'software']}, 'description': 'combined scope across ICT targets (like GSA ART multi-item); rows carry a clauses dict per target'},
460
+ 'answers': {'type': 'object', 'description': 'human confirmations keyed by criterion code: status in-scope|proposed-excluded|excluded'},
414
461
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
415
462
  }, 'required': ['reports']},
416
463
  },
@@ -429,6 +476,7 @@ TOOLS = [
429
476
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
430
477
  'timeout': {'type': 'number', 'description': 'Page load timeout seconds (45 default)'},
431
478
  'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON to test forms behind login'},
479
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
432
480
  },
433
481
  'required': ['url']},
434
482
  },
@@ -460,7 +508,8 @@ TOOLS = [
460
508
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
461
509
  'timeout': {'type': 'number', 'description': 'Page load timeout (45 default)'},
462
510
  'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit behind login — stays local'},
463
- }, 'required': ['url']},
511
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
512
+ }, 'required': ['url']},
464
513
  },
465
514
  {
466
515
  'name': 'a11y_sr_transcript',
@@ -508,6 +557,7 @@ TOOLS = [
508
557
  'url': {'type': 'string', 'description': 'URL (for record/gaps)'},
509
558
  'report': {'type': 'object', 'description': 'audit report object (for record)'},
510
559
  'ledger_path': {'type': 'string', 'description': 'ledger file path (default: a11y-ledger.json)'},
560
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'Notes language (en default)'},
511
561
  }, 'required': ['action']},
512
562
  },
513
563
  {
@@ -538,13 +588,15 @@ TOOLS = [
538
588
  'accessible name, log friction per step, then call this. Task usability '
539
589
  'evidence, never conformance.'),
540
590
  'inputSchema': {'type': 'object', 'properties': {
541
- 'task': {'type': 'object', 'description': '{"goal": what the agent attempted, "kind": sign-up|checkout|password-reset|search|custom}'},
591
+ 'task': {'type': 'object', 'description': '{"goal": what the agent attempted, "kind": sign-up|checkout|password-reset|search|onboarding|settings|data-export|custom}'},
542
592
  'steps': {'type': 'array', 'items': {'type': 'object'}, 'description': 'journey steps: {action, target (accessible name), perceived, friction?} — friction is {pattern: journey_* key} or {criterion, severity, issue, remediation?}'},
543
593
  'outcome': {'type': 'object', 'description': '{"completed": bool, "gave_up": bool, "workaround_used": bool, "notes"}'},
544
594
  'url': {'type': 'string', 'description': 'page(s) where the journey ran'},
545
595
  'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
546
596
  'output_path': {'type': 'string', 'description': 'write the full verdict JSON here instead of returning it inline'},
547
- }, 'required': ['task', 'steps', 'outcome']},
597
+ 'seal': {'type': 'boolean', 'description': 'return the sealed a11y-journey/1 record instead: the walk + judgment + steps, sha-sealed (record_verify re-derives the verdict from the steps)'},
598
+ 'verify_record': {'type': 'object', 'description': 'an a11y-journey/1 record to verify instead of judging: returns verified or tampered (sha + deterministic re-scoring)'},
599
+ }, 'required': []},
548
600
  },
549
601
  {
550
602
  'name': 'a11y_generate_vpat',
@@ -553,7 +605,8 @@ TOOLS = [
553
605
  'the full 55-criterion WCAG 2.2 A/AA table with Remarks auto-filled from '
554
606
  'the pack (status, measured values, examples, remaining human effort) and '
555
607
  'every Conformance Level starting at Not Evaluated — automated fails force '
556
- 'Does Not Support and a qualified human sets the final level via overrides '
608
+ 'Does Not Support, review-level signals stay Not Evaluated with the '
609
+ 'evidence in Remarks, and a qualified human sets the rest via overrides '
557
610
  '(supports, partially_supports, does_not_support, not_applicable, '
558
611
  'not_evaluated). The document is a DRAFT until the signature block, which '
559
612
  'must reference the pack sha256, is completed. VPAT is the US/ADA '
@@ -573,7 +626,8 @@ TOOLS = [
573
626
  'scope': {'type': 'object', 'description': 'a11y_scope output: human-confirmed exclusions become Not Applicable with their reason (machine proposals never); overrides still win'},
574
627
  'output_path': {'type': 'string', 'description': 'save the VPAT HTML here (optional)'},
575
628
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Document language (default en)'},
576
- }, 'required': ['product']},
629
+ },
630
+ 'required': ['product']},
577
631
  },
578
632
  {
579
633
  'name': 'a11y_generate_openacr',
@@ -582,8 +636,8 @@ TOOLS = [
582
636
  'a11y_evidence pack (or raw audit reports): the full 55-criterion '
583
637
  'WCAG 2.2 A/AA matrix as chapters with one web component per '
584
638
  'criterion, adherence levels starting at not-evaluated (automated '
585
- 'fails force does-not-support, review-level signals '
586
- 'partially-supports) and notes auto-filled from the pack (status, '
639
+ 'fails force does-not-support; review-level signals stay not-evaluated '
640
+ 'with the evidence in notes) and notes auto-filled from the pack (status, '
587
641
  'measured values, remaining human effort, sha256). Same honesty '
588
642
  'rule as a11y_generate_vpat: the machine fills notes, a qualified '
589
643
  'human sets levels via overrides (supports, partially_supports, …; '
@@ -605,7 +659,8 @@ TOOLS = [
605
659
  'scope': {'type': 'object', 'description': 'a11y_scope output: human-confirmed exclusions become not-applicable with their reason (machine proposals never); overrides still win'},
606
660
  'output_path': {'type': 'string', 'description': 'save the OpenACR YAML here (optional)'},
607
661
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Document language (default en)'},
608
- }, 'required': ['product']},
662
+ },
663
+ 'required': ['product']},
609
664
  },
610
665
  {
611
666
  'name': 'a11y_contrast_dom',
@@ -784,15 +839,6 @@ _PROMPTS = [
784
839
  {'name': 'status', 'description': 'plena | parcial | no_conforme', 'required': False},
785
840
  ],
786
841
  },
787
- {
788
- 'name': 'conformance-wcagem',
789
- 'description': 'Guided WCAG-EM conformance ladder for a site: express screening → agent-verified guided evaluation on a representative sample → conformance report inputs.',
790
- 'arguments': [
791
- {'name': 'url', 'description': 'site root to evaluate', 'required': True},
792
- {'name': 'tier', 'description': 'express | guided | conformance (default: express)', 'required': False},
793
- {'name': 'language', 'description': 'es or en', 'required': False},
794
- ],
795
- },
796
842
  {
797
843
  'name': 'blindfold-task',
798
844
  'description': ('Blindfold usability test — the agent attempts a real task perceiving '
@@ -803,7 +849,7 @@ _PROMPTS = [
803
849
  'arguments': [
804
850
  {'name': 'url', 'description': 'page where the task lives', 'required': True},
805
851
  {'name': 'goal', 'description': 'the task in user terms ("sign up for the newsletter")', 'required': True},
806
- {'name': 'kind', 'description': 'sign-up | checkout | password-reset | search | custom', 'required': False},
852
+ {'name': 'kind', 'description': 'sign-up | checkout | password-reset | search | onboarding | settings | data-export | custom', 'required': False},
807
853
  {'name': 'language', 'description': 'es or en', 'required': False},
808
854
  ],
809
855
  },
@@ -859,18 +905,6 @@ def _prompt(name, args):
859
905
  + "3. Informa: hallazgos nuevos (bloqueantes), hallazgos resueltos (buenas noticias), interactivos añadidos/eliminados/renombrados, cambios de orden de foco.\n"
860
906
  "4. Veredicto: GO (sin hallazgos altos nuevos ni regresiones de foco) / NO-GO (en caso contrario) con la evidencia.",
861
907
  },
862
- 'conformance-wcagem': {
863
- 'en': f"Run the WCAG-EM conformance ladder for {args.get('url','the site')} (tier: {args.get('tier','express')}):\n"
864
- "1. EXPRESS (always): a11y_audit_url on the root and the 4-5 key pages (use pages parameter / crawl). Report scores and findings by severity.\n"
865
- "2. GUIDED: pick a WCAG-EM sample — structured pages (home, contact, login, a content page, a form flow) plus a random pick from the crawl. On each sample page, run a11y_audit_dom if Playwright is available, then verify the manual checklist yourself (keyboard walk, focus visibility, zoom 200%, error announcement on one form). Mark each item verified-by-agent vs automated-only.\n"
866
- "3. CONFORMANCE: only with a human in the loop — compile the evidence (sample, pages, results, dates) into WCAG-EM report structure, state the scope honestly (sample-based evaluation, not a certification), and feed inaccessible_content into a11y_generate_declaration.\n"
867
- "Escalate one tier at a time; never present tier 1 or 2 as conformance.",
868
- 'es': f"Ejecuta la escalera de conformidad WCAG-EM para {args.get('url','el sitio')} (nivel: {args.get('tier','express')})\u003a\n"
869
- "1. EXPRESS (siempre): a11y_audit_url en la raíz y las 4-5 páginas clave (parámetro pages). Informa puntuaciones y hallazgos por severidad.\n"
870
- "2. GUIDED: elige una muestra WCAG-EM — páginas estructurales (inicio, contacto, login, una de contenido, un flujo de formulario) más una aleatoria del rastreo. En cada una, a11y_audit_dom si hay Playwright, y verifica tú el checklist manual (recorrido de teclado, foco visible, zoom 200%, anuncio de errores en un formulario). Marca cada punto como verificado-por-agente o solo-automático.\n"
871
- "3. CONFORMANCE: solo con humana en el bucle — recopila la evidencia (muestra, páginas, resultados, fechas) en la estructura del informe WCAG-EM, declara el alcance con honestidad (evaluación por muestreo, no certificación) y alimenta inaccessible_content en a11y_generate_declaration.\n"
872
- "Escala un nivel cada vez; nunca presentes el nivel 1 o 2 como conformidad.",
873
- },
874
908
  'declaration-eaa': {
875
909
  'en': f"Generate an accessibility statement for {args.get('entity','the entity')} ({args.get('url','URL')}):\n"
876
910
  "1. Establish the compliance state with a11y_audit_url (parcial is the honest default when findings exist).\n"
@@ -932,7 +966,7 @@ _PARAM_DOCS = {
932
966
  ('a11y_forms', 'browser'): 'Browser engine (auto = detect the first available)',
933
967
  ('a11y_sr_transcript', 'url'): 'Page URL to get the screen reader announcement transcript',
934
968
  ('a11y_sr_transcript', 'timeout'): 'Page load timeout in seconds (default 45)',
935
- ('a11y_journey_verdict', 'task'): 'Task the agent attempted blindfolded: {"goal": …, "kind": sign-up|checkout|password-reset|search|custom}',
969
+ ('a11y_journey_verdict', 'task'): 'Task the agent attempted blindfolded: {"goal": …, "kind": sign-up|checkout|password-reset|search|onboarding|settings|data-export|custom}',
936
970
  ('a11y_journey_verdict', 'steps'): 'Journey steps in order; each friction item is a journey_* pattern key or a raw {criterion, severity, issue}',
937
971
  ('a11y_journey_verdict', 'outcome'): 'How the journey ended: completed / gave_up / workaround_used + notes',
938
972
  ('a11y_journey_verdict', 'url'): 'Where the journey ran',
@@ -1011,6 +1045,7 @@ _PARAM_DOCS = {
1011
1045
  ('a11y_criterion', 'signal'): 'Signal id from any finding (e.g. img_no_alt): resolves its criterion and published ACT rules with w3.org links',
1012
1046
  ('a11y_criterion', 'lang'): 'Explanation language (default en)',
1013
1047
  ('a11y_evidence', 'reports'): 'Audit report objects to bundle (any mode: static, rendered, reflow, keyboard, scroll)',
1048
+ ('a11y_evidence', 'build'): 'Build reference sealed into the sha: {"commit":…, "ci_url":…} or {"ref": "git:sha"} — the claim→artifact chain',
1014
1049
  ('a11y_evidence', 'snapshot'): 'Optional a11y_snapshot output to include as an artifact',
1015
1050
  ('a11y_evidence', 'reviewer'): 'Optional prefill for the signature block: {"name":…, "credential":…, "review_date":…}',
1016
1051
  ('a11y_aria_live_snippet', 'lang'): 'Monitor panel language (default en)',
@@ -1103,6 +1138,8 @@ _ANN = {
1103
1138
  'a11y_forms': ('Form error testing', True, True),
1104
1139
  'a11y_scroll': ('Infinite-scroll audit', True, True),
1105
1140
  'a11y_snapshot': ('A11y snapshot + tab order', True, True),
1141
+ 'a11y_locate': ('Locate element by accessible name', True, True),
1142
+ 'a11y_patches': ('Sealed patch-set (sha-keyed)', True, False),
1106
1143
  'a11y_diff': ('Snapshot regression diff', True, False),
1107
1144
  'a11y_diff_urls': ('Staging vs production diff', True, True),
1108
1145
  'a11y_contrast_pair': ('Contrast ratio + verdicts', True, False),
@@ -1147,8 +1184,8 @@ _RETURNS = {
1147
1184
  'a11y_diff': 'Returns JSON: {ok, added, removed, renamed, focus_order_changed, first_differences} — ok:false means a regression to review.',
1148
1185
  'a11y_diff_urls': 'Returns the same diff shape as a11y_diff, for two live URLs.',
1149
1186
  'a11y_aria_live_snippet': 'Returns the injectable JavaScript as text (bookmarklet or page.evaluate).',
1150
- 'a11y_badge': 'Returns the honest SVG badge; writes a file only when output_path is given.',
1151
- 'a11y_autofix': 'Returns JSON: {fixed_html, applied [{fix, …}], not_applied [{issue, remediation}]} — writes a file only when output_path is given.',
1187
+ 'a11y_badge': 'Returns the honest SVG badge as text content (the agent writes the file).',
1188
+ 'a11y_autofix': 'Returns JSON: {fixed_html, applied [{fix, …}], not_applied [{issue, remediation}]} as text content (the agent writes the file).',
1152
1189
  'a11y_reflow': 'Returns JSON: {url, viewport, horizontal_scroll, offenders [{selector, width}]}.',
1153
1190
  'a11y_keyboard': 'Returns JSON: {tab_stops, trap_detected, escape_releases, findings}.',
1154
1191
  'a11y_scroll': 'Returns JSON: {mode, url, score, findings [{criterion, severity, signal, issue, remediation}], summary} — same shape as the audits.',
@@ -1159,7 +1196,7 @@ _RETURNS = {
1159
1196
  'a11y_disprove': 'Returns JSON: {confirmed, rejected, score} — a fresh score over confirmed findings only.',
1160
1197
  'a11y_ledger': 'record returns the stored entry; gaps returns criteria never checked; summary returns {entries, active_signals, resolved, mean_score}.',
1161
1198
  'a11y_criterion': 'Returns JSON: {criterion, level, understanding, toolkit_signals, requires, typical_failures, how_to_check} — signal mode adds {signal, act_rules [{id, name, status, url}]}; {error, …} for unknown codes.',
1162
- 'a11y_evidence': 'Returns the pack JSON (a11y-evidence-pack/2); writes a file only when output_path is given.',
1199
+ 'a11y_evidence': 'Returns the pack JSON (a11y-evidence-pack/2) as text content (the agent writes the file).',
1163
1200
  'a11y_journey_verdict': 'Returns JSON: {verdict pass|partial|fail|blocked, score 0-100, findings [{criterion, severity, signal, issue, remediation, step}], summary, rules} — writes a file only when output_path is given.',
1164
1201
  'a11y_generate_declaration': 'Returns {html, summary} — the accessible legal statement; writes a file only when output_path is given.',
1165
1202
  'a11y_generate_vpat': 'Returns {html, summary {level: count}, levels {code: level}, pack_sha256, draft} — the VPAT draft; writes a file only when output_path is given.',
@@ -1186,7 +1223,12 @@ for _t in TOOLS:
1186
1223
  _title_ro = _RO_OVERRIDE.get(_t['name'], _ro)
1187
1224
  _title_same = _IDEM_OVERRIDE.get(_t['name'], True)
1188
1225
  _t['title'] = 'a11y-toolkit: ' + _title
1189
- _t['annotations'] = {'readOnlyHint': _title_ro, 'destructiveHint': not _title_ro,
1226
+ # destructiveHint honrado (semántica MCP): «no-read-only» NO equivale a
1227
+ # destructivo. Escribir el fichero que te piden es un efecto normal; lo
1228
+ # genuinamente irreversible es a11y_forms (ENVÍA datos reales a la web
1229
+ # auditada) — el resto son cómputo + guardado dirigido por el usuario
1230
+ _t['annotations'] = {'readOnlyHint': _title_ro,
1231
+ 'destructiveHint': _t['name'] in ('a11y_forms',),
1190
1232
  'idempotentHint': _title_same, 'openWorldHint': _ow}
1191
1233
  if _t['name'] in _RETURNS:
1192
1234
  _t['description'] += ' ' + _RETURNS[_t['name']]
@@ -1293,6 +1335,17 @@ def invoke(name, args):
1293
1335
  'isError': True}
1294
1336
  except Exception as e: # noqa: BLE001
1295
1337
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1338
+ if name == 'a11y_locate':
1339
+ return _content(locate_fn(args['html'], args['query'],
1340
+ role=args.get('role'),
1341
+ multiple=bool(args.get('multiple', False)),
1342
+ lang=args.get('lang', 'en')))
1343
+ if name == 'a11y_patches':
1344
+ if args.get('action') == 'verify':
1345
+ return _content(patches_apply_fn(args['html'], args.get('patch_set'),
1346
+ lang=args.get('lang', 'en')))
1347
+ return _content(patches_build_fn(args['html'], lang=args.get('lang', 'en'),
1348
+ title=args.get('title')))
1296
1349
  if name == 'a11y_diff':
1297
1350
  def _load(v):
1298
1351
  v = v.strip()
@@ -1318,7 +1371,8 @@ def invoke(name, args):
1318
1371
  try:
1319
1372
  return _content(audit_scroll(args['url'], max_batches=args.get('max_batches', 5),
1320
1373
  lang=args.get('lang', 'en'),
1321
- auth_state=args.get('auth_state')))
1374
+ auth_state=args.get('auth_state'),
1375
+ browser=args.get('browser', 'auto')))
1322
1376
  except ImportError:
1323
1377
  return {'content': [{'type': 'text',
1324
1378
  'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
@@ -1339,7 +1393,7 @@ def invoke(name, args):
1339
1393
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1340
1394
  if name == 'a11y_forms':
1341
1395
  try:
1342
- return _content(audit_forms(args['url'], timeout=args.get('timeout', 45),
1396
+ return _content(audit_forms(args['url'], timeout=args.get('timeout', 45), browser=args.get('browser', 'auto'),
1343
1397
  lang=args.get('lang', 'en'),
1344
1398
  auth_state=args.get('auth_state')))
1345
1399
  except ImportError:
@@ -1353,7 +1407,9 @@ def invoke(name, args):
1353
1407
  return _content(build_pack_fn(args['reports'], snapshot=args.get('snapshot'),
1354
1408
  reviewer=args.get('reviewer'),
1355
1409
  verified=args.get('verified'),
1356
- scope=args.get('scope')))
1410
+ scope=args.get('scope'),
1411
+ build=args.get('build'),
1412
+ lang=args.get('lang', 'en')))
1357
1413
  except Exception as e: # noqa: BLE001
1358
1414
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1359
1415
  if name == 'a11y_scope':
@@ -1361,6 +1417,7 @@ def invoke(name, args):
1361
1417
  return _content(scope_fn(args['reports'], standard=args.get('standard', 'wcag22'),
1362
1418
  target=args.get('target', 'web'),
1363
1419
  answers=args.get('answers'),
1420
+ targets=args.get('targets'),
1364
1421
  lang=args.get('lang', 'en')))
1365
1422
  except Exception as e: # noqa: BLE001
1366
1423
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
@@ -1391,7 +1448,7 @@ def invoke(name, args):
1391
1448
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1392
1449
  if name == 'a11y_hover':
1393
1450
  try:
1394
- return _content(audit_hover(args['url'], timeout=args.get('timeout', 45),
1451
+ return _content(audit_hover(args['url'], timeout=args.get('timeout', 45), browser=args.get('browser', 'auto'),
1395
1452
  lang=args.get('lang', 'en'),
1396
1453
  auth_state=args.get('auth_state')))
1397
1454
  except ImportError:
@@ -1428,10 +1485,14 @@ def invoke(name, args):
1428
1485
  if not args.get('url'):
1429
1486
  return _content({'error': 'gaps requires url'})
1430
1487
  from .a11yledger import gaps as _gaps
1431
- return _content(_gaps(args['url'], path=path))
1488
+ return _content(_gaps(args['url'], path=path, lang=args.get('lang', 'en')))
1432
1489
  if action == 'summary':
1433
1490
  from .a11yledger import summary as _sum
1434
- return _content(_sum(path=path))
1491
+ return _content(_sum(path=path, lang=args.get('lang', 'en')))
1492
+ # enum inválido: error de tool-result nombrando la action y las
1493
+ # válidas — no caer al 'unknown tool' del dispatcher
1494
+ return _content({'error': f'invalid action: {action}',
1495
+ 'valid_actions': ['record', 'gaps', 'summary']})
1435
1496
  except Exception as e:
1436
1497
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1437
1498
  if name == 'a11y_criterion':
@@ -1440,6 +1501,27 @@ def invoke(name, args):
1440
1501
  return _content(criterion_fn(args.get('code'), lang=args.get('lang', 'en'),
1441
1502
  signal=args.get('signal')))
1442
1503
  if name == 'a11y_journey_verdict':
1504
+ if args.get('verify_record') is not None:
1505
+ return _content(journey_verify_fn(args['verify_record'],
1506
+ lang=args.get('lang', 'en')))
1507
+ # verify-only calls need just verify_record; the judge/seal path
1508
+ # (schema-optional since 5.26.1) still requires the walk itself
1509
+ _missing = [k for k in ('task', 'steps', 'outcome') if not args.get(k)]
1510
+ if _missing:
1511
+ return _content({'error': f'{", ".join(_missing)} required '
1512
+ '(only verify_record calls omit task/steps/outcome)'})
1513
+ if args.get('seal'):
1514
+ rec = journey_seal_fn(args['task'], args['steps'], args['outcome'],
1515
+ url=args.get('url', ''),
1516
+ lang=args.get('lang', 'en'))
1517
+ if args.get('output_path') and 'error' not in rec:
1518
+ with open(args['output_path'], 'w', encoding='utf-8') as f:
1519
+ f.write(json.dumps(rec, ensure_ascii=False, indent=1) + '\n')
1520
+ return _content({'out': args['output_path'],
1521
+ 'sha256': rec['sha256'],
1522
+ 'verdict': rec['verdict']['verdict'],
1523
+ 'score': rec['verdict']['score']})
1524
+ return _content(rec)
1443
1525
  res = journey_verdict_fn(args['task'], args['steps'], args['outcome'],
1444
1526
  url=args.get('url', ''), lang=args.get('lang', 'en'))
1445
1527
  if args.get('output_path') and 'error' not in res:
@@ -1558,13 +1640,27 @@ def invoke(name, args):
1558
1640
  else:
1559
1641
  with open(os.path.join(HERE, 'arialive.js'), encoding='utf-8') as f:
1560
1642
  js = f.read()
1561
- if args.get('lang') == 'en':
1643
+ if (args.get('lang') or 'en') != 'es':
1644
+ # the snippet's built-in labels are Spanish; the schema documents
1645
+ # en as the default, so only an explicit lang='es' keeps them
1562
1646
  js = "window.ALM_LANG='en';\n" + js
1563
1647
  return {'content': [{'type': 'text', 'text': js}]}
1564
1648
  raise ValueError(f'unknown tool: {name}')
1565
1649
 
1566
1650
 
1567
1651
  def main():
1652
+ # stdio MCP is UTF-8 by spec, but the process locale decides the pipe
1653
+ # encoding (cp1252 on Windows): one CJK/emoji finding would raise
1654
+ # UnicodeEncodeError OUTSIDE any try and kill the server mid-protocol.
1655
+ # stdin decodes with errors='replace' so a hostile line can never crash
1656
+ # the read either; stdout must encode everything we emit.
1657
+ for _stream, _kw in ((sys.stdin, {'encoding': 'utf-8', 'errors': 'replace'}),
1658
+ (sys.stdout, {'encoding': 'utf-8'})):
1659
+ if hasattr(_stream, 'reconfigure'):
1660
+ try:
1661
+ _stream.reconfigure(**_kw)
1662
+ except (ValueError, OSError, AttributeError):
1663
+ pass # exotic/closed streams: keep their default encoding
1568
1664
  for line in sys.stdin:
1569
1665
  line = line.strip()
1570
1666
  if not line:
@@ -1587,7 +1683,10 @@ def main():
1587
1683
  try:
1588
1684
  if method == 'initialize':
1589
1685
  resp = {'jsonrpc': '2.0', 'id': mid, 'result': {
1590
- 'protocolVersion': msg.get('params', {}).get('protocolVersion', '2024-11-05'),
1686
+ # MCP: answer with the LATEST version we actually support,
1687
+ # never echo the client's (batching is rejected below, so
1688
+ # echoing e.g. '2025-06-18' would be a partial lie)
1689
+ 'protocolVersion': '2024-11-05',
1591
1690
  'capabilities': {'tools': {}, 'prompts': {}},
1592
1691
  'serverInfo': {'name': 'a11y-toolkit', 'version': VERSION},
1593
1692
  'instructions': INSTRUCTIONS,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kinti/a11y-toolkit",
3
- "version": "5.26.0",
3
+ "version": "5.27.0",
4
4
  "mcpName": "io.github.kinti/a11y-toolkit",
5
- "description": "Zero-dependency WCAG 2.2 accessibility engine (35 MCP tools + CLI): audits, contrast fixing, SHA-256-sealed evidence packs, SARIF, EARL/ACT, CI ratchet. Self-contained: the pure-stdlib Python engine ships inside and runs via python3 \u2014 no downloads, no installs.",
5
+ "description": "Zero-dependency WCAG 2.2 accessibility engine (37 MCP tools + CLI): audits, contrast fixing, SHA-256-sealed evidence packs, SARIF, EARL/ACT, CI ratchet. Self-contained: the pure-stdlib Python engine ships inside and runs via python3 \u2014 no downloads, no installs.",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",