@kinti/a11y-toolkit 5.26.0 → 5.28.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 (45) hide show
  1. package/README.md +1 -1
  2. package/a11y_toolkit/a11y.py +30 -4
  3. package/a11y_toolkit/a11yact.py +9 -1
  4. package/a11y_toolkit/a11yannotate.py +185 -0
  5. package/a11y_toolkit/a11yaudit.py +924 -196
  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 +114 -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 +567 -97
  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/a11ygate.py +225 -0
  19. package/a11y_toolkit/a11yinit.py +73 -7
  20. package/a11y_toolkit/a11yjourney.py +110 -4
  21. package/a11y_toolkit/a11yledger.py +119 -12
  22. package/a11y_toolkit/a11ylocate.py +247 -0
  23. package/a11y_toolkit/a11yopenacr.py +10 -3
  24. package/a11y_toolkit/a11ypatches.py +154 -0
  25. package/a11y_toolkit/a11ypatterns.py +344 -0
  26. package/a11y_toolkit/a11ypdf.py +109 -53
  27. package/a11y_toolkit/a11yrgaa.py +60 -0
  28. package/a11y_toolkit/a11yroute.py +34 -12
  29. package/a11y_toolkit/a11ysarif.py +45 -18
  30. package/a11y_toolkit/a11yscope.py +67 -15
  31. package/a11y_toolkit/a11yscroll.py +7 -5
  32. package/a11y_toolkit/a11ystatement.py +30 -6
  33. package/a11y_toolkit/a11ytrace.py +293 -0
  34. package/a11y_toolkit/a11yvalidate.py +21 -15
  35. package/a11y_toolkit/a11yvpat.py +34 -7
  36. package/a11y_toolkit/a11yvtt.py +22 -6
  37. package/a11y_toolkit/a11ywiz.py +121 -0
  38. package/a11y_toolkit/contrast.py +62 -24
  39. package/a11y_toolkit/locales/en.json +185 -20
  40. package/a11y_toolkit/locales/es.json +186 -21
  41. package/a11y_toolkit/rgaa.json +2661 -0
  42. package/a11y_toolkit/server.py +157 -54
  43. package/package.json +2 -2
  44. package/a11y_toolkit/a11yplan.py +0 -214
  45. 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.28.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 '
@@ -333,8 +376,12 @@ TOOLS = [
333
376
  'up to 60 real tab stops, cycle detection (the modal pattern), then '
334
377
  'the decisive test — does ESCAPE release the cycle? A modal that '
335
378
  'cycles and releases on Escape is correct and NOT reported; a cycle '
336
- 'Escape cannot leave is a trap (high severity). Returns the full tab '
337
- 'stop list too. Requires local Playwright.'),
379
+ 'Escape cannot leave is a trap (high severity). It also activates '
380
+ 'the first real skip link once and reports skip_target_hidden '
381
+ '(medium, 2.4.1) when the target is still not exposed after '
382
+ 'activation — focus landing on it is not required (browsers move '
383
+ 'the sequential-focus start regardless of tabindex). Returns the '
384
+ 'full tab stop list too. Requires local Playwright.'),
338
385
  'inputSchema': {'type': 'object', 'properties': {
339
386
  'url': {'type': 'string'},
340
387
  'lang': {'type': 'string', 'enum': ['es', 'en']},
@@ -361,6 +408,7 @@ TOOLS = [
361
408
  'lang': {'type': 'string', 'enum': ['es', 'en']},
362
409
  'max_batches': {'type': 'integer', 'description': 'scroll batches (5 default)'},
363
410
  'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit an authenticated feed'},
411
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
364
412
  },
365
413
  'required': ['url']},
366
414
  },
@@ -385,6 +433,8 @@ TOOLS = [
385
433
  'scope': {'type': 'object', 'description': 'a11y_scope output: human-confirmed exclusions become not-applicable rows with their reason (machine proposals never exclude)'},
386
434
  'reviewer': {'type': 'object', 'description': '{"name":…, "credential":…, "review_date":…} to prefill the signature block'},
387
435
  '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'},
436
+ 'build': {'type': 'object', 'description': 'Build reference sealed into the pack sha — the claim→artifact chain: {"commit":…, "ci_url":…} or {"ref": "git:716d870"}'},
437
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'Pack language: matrix status labels and notes (en default)'},
388
438
  }, 'required': ['reports']},
389
439
  },
390
440
  {
@@ -408,9 +458,10 @@ TOOLS = [
408
458
  'inputSchema': {'type': 'object', 'properties': {
409
459
  'reports': {'type': 'array', 'items': {'type': 'object'},
410
460
  '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'},
461
+ 'standard': {'type': 'string', 'enum': ['wcag22', 'en301549', 'rgaa'], 'description': 'wcag22 (default), en301549 (clause refs + EN families) or rgaa (French 106-criterion checklist)'},
412
462
  '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'},
463
+ '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'},
464
+ 'answers': {'type': 'object', 'description': 'human confirmations keyed by criterion code: status in-scope|proposed-excluded|excluded'},
414
465
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'output language (en default)'},
415
466
  }, 'required': ['reports']},
416
467
  },
@@ -429,6 +480,7 @@ TOOLS = [
429
480
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
430
481
  'timeout': {'type': 'number', 'description': 'Page load timeout seconds (45 default)'},
431
482
  'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON to test forms behind login'},
483
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
432
484
  },
433
485
  'required': ['url']},
434
486
  },
@@ -460,7 +512,8 @@ TOOLS = [
460
512
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Output language (en default)'},
461
513
  'timeout': {'type': 'number', 'description': 'Page load timeout (45 default)'},
462
514
  'auth_state': {'type': 'string', 'description': 'Path to a Playwright storage_state JSON (exported session) to audit behind login — stays local'},
463
- }, 'required': ['url']},
515
+ 'browser': {'type': 'string', 'enum': ['auto', 'chromium', 'firefox', 'webkit', 'chrome', 'msedge'], 'description': 'Browser engine (auto = detect the first available)'},
516
+ }, 'required': ['url']},
464
517
  },
465
518
  {
466
519
  'name': 'a11y_sr_transcript',
@@ -508,6 +561,7 @@ TOOLS = [
508
561
  'url': {'type': 'string', 'description': 'URL (for record/gaps)'},
509
562
  'report': {'type': 'object', 'description': 'audit report object (for record)'},
510
563
  'ledger_path': {'type': 'string', 'description': 'ledger file path (default: a11y-ledger.json)'},
564
+ 'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'Notes language (en default)'},
511
565
  }, 'required': ['action']},
512
566
  },
513
567
  {
@@ -538,13 +592,15 @@ TOOLS = [
538
592
  'accessible name, log friction per step, then call this. Task usability '
539
593
  'evidence, never conformance.'),
540
594
  'inputSchema': {'type': 'object', 'properties': {
541
- 'task': {'type': 'object', 'description': '{"goal": what the agent attempted, "kind": sign-up|checkout|password-reset|search|custom}'},
595
+ 'task': {'type': 'object', 'description': '{"goal": what the agent attempted, "kind": sign-up|checkout|password-reset|search|onboarding|settings|data-export|custom}'},
542
596
  '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
597
  'outcome': {'type': 'object', 'description': '{"completed": bool, "gave_up": bool, "workaround_used": bool, "notes"}'},
544
598
  'url': {'type': 'string', 'description': 'page(s) where the journey ran'},
545
599
  'lang': {'type': 'string', 'enum': ['en', 'es'], 'description': 'output language'},
546
600
  'output_path': {'type': 'string', 'description': 'write the full verdict JSON here instead of returning it inline'},
547
- }, 'required': ['task', 'steps', 'outcome']},
601
+ '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)'},
602
+ 'verify_record': {'type': 'object', 'description': 'an a11y-journey/1 record to verify instead of judging: returns verified or tampered (sha + deterministic re-scoring)'},
603
+ }, 'required': []},
548
604
  },
549
605
  {
550
606
  'name': 'a11y_generate_vpat',
@@ -553,7 +609,8 @@ TOOLS = [
553
609
  'the full 55-criterion WCAG 2.2 A/AA table with Remarks auto-filled from '
554
610
  'the pack (status, measured values, examples, remaining human effort) and '
555
611
  'every Conformance Level starting at Not Evaluated — automated fails force '
556
- 'Does Not Support and a qualified human sets the final level via overrides '
612
+ 'Does Not Support, review-level signals stay Not Evaluated with the '
613
+ 'evidence in Remarks, and a qualified human sets the rest via overrides '
557
614
  '(supports, partially_supports, does_not_support, not_applicable, '
558
615
  'not_evaluated). The document is a DRAFT until the signature block, which '
559
616
  'must reference the pack sha256, is completed. VPAT is the US/ADA '
@@ -573,7 +630,8 @@ TOOLS = [
573
630
  'scope': {'type': 'object', 'description': 'a11y_scope output: human-confirmed exclusions become Not Applicable with their reason (machine proposals never); overrides still win'},
574
631
  'output_path': {'type': 'string', 'description': 'save the VPAT HTML here (optional)'},
575
632
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Document language (default en)'},
576
- }, 'required': ['product']},
633
+ },
634
+ 'required': ['product']},
577
635
  },
578
636
  {
579
637
  'name': 'a11y_generate_openacr',
@@ -582,8 +640,8 @@ TOOLS = [
582
640
  'a11y_evidence pack (or raw audit reports): the full 55-criterion '
583
641
  'WCAG 2.2 A/AA matrix as chapters with one web component per '
584
642
  '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, '
643
+ 'fails force does-not-support; review-level signals stay not-evaluated '
644
+ 'with the evidence in notes) and notes auto-filled from the pack (status, '
587
645
  'measured values, remaining human effort, sha256). Same honesty '
588
646
  'rule as a11y_generate_vpat: the machine fills notes, a qualified '
589
647
  'human sets levels via overrides (supports, partially_supports, …; '
@@ -605,7 +663,8 @@ TOOLS = [
605
663
  'scope': {'type': 'object', 'description': 'a11y_scope output: human-confirmed exclusions become not-applicable with their reason (machine proposals never); overrides still win'},
606
664
  'output_path': {'type': 'string', 'description': 'save the OpenACR YAML here (optional)'},
607
665
  'lang': {'type': 'string', 'enum': ['es', 'en'], 'description': 'Document language (default en)'},
608
- }, 'required': ['product']},
666
+ },
667
+ 'required': ['product']},
609
668
  },
610
669
  {
611
670
  'name': 'a11y_contrast_dom',
@@ -784,15 +843,6 @@ _PROMPTS = [
784
843
  {'name': 'status', 'description': 'plena | parcial | no_conforme', 'required': False},
785
844
  ],
786
845
  },
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
846
  {
797
847
  'name': 'blindfold-task',
798
848
  'description': ('Blindfold usability test — the agent attempts a real task perceiving '
@@ -803,7 +853,7 @@ _PROMPTS = [
803
853
  'arguments': [
804
854
  {'name': 'url', 'description': 'page where the task lives', 'required': True},
805
855
  {'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},
856
+ {'name': 'kind', 'description': 'sign-up | checkout | password-reset | search | onboarding | settings | data-export | custom', 'required': False},
807
857
  {'name': 'language', 'description': 'es or en', 'required': False},
808
858
  ],
809
859
  },
@@ -859,18 +909,6 @@ def _prompt(name, args):
859
909
  + "3. Informa: hallazgos nuevos (bloqueantes), hallazgos resueltos (buenas noticias), interactivos añadidos/eliminados/renombrados, cambios de orden de foco.\n"
860
910
  "4. Veredicto: GO (sin hallazgos altos nuevos ni regresiones de foco) / NO-GO (en caso contrario) con la evidencia.",
861
911
  },
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
912
  'declaration-eaa': {
875
913
  'en': f"Generate an accessibility statement for {args.get('entity','the entity')} ({args.get('url','URL')}):\n"
876
914
  "1. Establish the compliance state with a11y_audit_url (parcial is the honest default when findings exist).\n"
@@ -932,7 +970,7 @@ _PARAM_DOCS = {
932
970
  ('a11y_forms', 'browser'): 'Browser engine (auto = detect the first available)',
933
971
  ('a11y_sr_transcript', 'url'): 'Page URL to get the screen reader announcement transcript',
934
972
  ('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}',
973
+ ('a11y_journey_verdict', 'task'): 'Task the agent attempted blindfolded: {"goal": …, "kind": sign-up|checkout|password-reset|search|onboarding|settings|data-export|custom}',
936
974
  ('a11y_journey_verdict', 'steps'): 'Journey steps in order; each friction item is a journey_* pattern key or a raw {criterion, severity, issue}',
937
975
  ('a11y_journey_verdict', 'outcome'): 'How the journey ended: completed / gave_up / workaround_used + notes',
938
976
  ('a11y_journey_verdict', 'url'): 'Where the journey ran',
@@ -1011,6 +1049,7 @@ _PARAM_DOCS = {
1011
1049
  ('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
1050
  ('a11y_criterion', 'lang'): 'Explanation language (default en)',
1013
1051
  ('a11y_evidence', 'reports'): 'Audit report objects to bundle (any mode: static, rendered, reflow, keyboard, scroll)',
1052
+ ('a11y_evidence', 'build'): 'Build reference sealed into the sha: {"commit":…, "ci_url":…} or {"ref": "git:sha"} — the claim→artifact chain',
1014
1053
  ('a11y_evidence', 'snapshot'): 'Optional a11y_snapshot output to include as an artifact',
1015
1054
  ('a11y_evidence', 'reviewer'): 'Optional prefill for the signature block: {"name":…, "credential":…, "review_date":…}',
1016
1055
  ('a11y_aria_live_snippet', 'lang'): 'Monitor panel language (default en)',
@@ -1064,7 +1103,7 @@ _ROUTING = {
1064
1103
  'a11y_audit_url': 'Prefer a11y_audit_dom when JS renders the content or contrast/2.5.8/focus matter; use pages for light multi-page sampling. Static CANNOT measure class/var() CSS contrast (1.4.3): the report\'s not_measured says so — a 100 is never \'contrast is fine\'.',
1065
1104
  'a11y_audit_dom': 'Use instead of a11y_audit_url on JS-heavy pages; needs local Playwright.',
1066
1105
  'a11y_reflow': 'Scope: 320px reflow only (1.4.10); for the full rendered pass use a11y_audit_dom.',
1067
- 'a11y_keyboard': 'Scope: keyboard traps (2.1.2); focus visibility is part of a11y_audit_dom.',
1106
+ 'a11y_keyboard': 'Scope: keyboard traps (2.1.2) + rendered bypass landing; focus visibility is part of a11y_audit_dom.',
1068
1107
  'a11y_scroll': 'For paginated feeds only; general page audit is a11y_audit_url/dom.',
1069
1108
  'a11y_contrast_pair': 'For flat pairs; text over images needs a11y_contrast_image.',
1070
1109
  'a11y_contrast_image': 'Use instead of a11y_contrast_pair whenever the background is a photo/gradient.',
@@ -1098,11 +1137,13 @@ _ANN = {
1098
1137
  'a11y_audit_url': ('Express WCAG audit', True, True),
1099
1138
  'a11y_audit_dom': ('Rendered WCAG audit', True, True),
1100
1139
  'a11y_reflow': ('320px reflow check', True, True),
1101
- 'a11y_keyboard': ('Keyboard-trap detector', True, True),
1140
+ 'a11y_keyboard': ('Keyboard-trap + skip-link landing detector', True, True),
1102
1141
  'a11y_html_validate': ('W3C Nu validation', True, True),
1103
1142
  'a11y_forms': ('Form error testing', True, True),
1104
1143
  'a11y_scroll': ('Infinite-scroll audit', True, True),
1105
1144
  'a11y_snapshot': ('A11y snapshot + tab order', True, True),
1145
+ 'a11y_locate': ('Locate element by accessible name', True, True),
1146
+ 'a11y_patches': ('Sealed patch-set (sha-keyed)', True, False),
1106
1147
  'a11y_diff': ('Snapshot regression diff', True, False),
1107
1148
  'a11y_diff_urls': ('Staging vs production diff', True, True),
1108
1149
  'a11y_contrast_pair': ('Contrast ratio + verdicts', True, False),
@@ -1147,8 +1188,8 @@ _RETURNS = {
1147
1188
  'a11y_diff': 'Returns JSON: {ok, added, removed, renamed, focus_order_changed, first_differences} — ok:false means a regression to review.',
1148
1189
  'a11y_diff_urls': 'Returns the same diff shape as a11y_diff, for two live URLs.',
1149
1190
  '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.',
1191
+ 'a11y_badge': 'Returns the honest SVG badge as text content (the agent writes the file).',
1192
+ 'a11y_autofix': 'Returns JSON: {fixed_html, applied [{fix, …}], not_applied [{issue, remediation}]} as text content (the agent writes the file).',
1152
1193
  'a11y_reflow': 'Returns JSON: {url, viewport, horizontal_scroll, offenders [{selector, width}]}.',
1153
1194
  'a11y_keyboard': 'Returns JSON: {tab_stops, trap_detected, escape_releases, findings}.',
1154
1195
  'a11y_scroll': 'Returns JSON: {mode, url, score, findings [{criterion, severity, signal, issue, remediation}], summary} — same shape as the audits.',
@@ -1159,7 +1200,7 @@ _RETURNS = {
1159
1200
  'a11y_disprove': 'Returns JSON: {confirmed, rejected, score} — a fresh score over confirmed findings only.',
1160
1201
  'a11y_ledger': 'record returns the stored entry; gaps returns criteria never checked; summary returns {entries, active_signals, resolved, mean_score}.',
1161
1202
  '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.',
1203
+ 'a11y_evidence': 'Returns the pack JSON (a11y-evidence-pack/2) as text content (the agent writes the file).',
1163
1204
  '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
1205
  'a11y_generate_declaration': 'Returns {html, summary} — the accessible legal statement; writes a file only when output_path is given.',
1165
1206
  '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 +1227,12 @@ for _t in TOOLS:
1186
1227
  _title_ro = _RO_OVERRIDE.get(_t['name'], _ro)
1187
1228
  _title_same = _IDEM_OVERRIDE.get(_t['name'], True)
1188
1229
  _t['title'] = 'a11y-toolkit: ' + _title
1189
- _t['annotations'] = {'readOnlyHint': _title_ro, 'destructiveHint': not _title_ro,
1230
+ # destructiveHint honrado (semántica MCP): «no-read-only» NO equivale a
1231
+ # destructivo. Escribir el fichero que te piden es un efecto normal; lo
1232
+ # genuinamente irreversible es a11y_forms (ENVÍA datos reales a la web
1233
+ # auditada) — el resto son cómputo + guardado dirigido por el usuario
1234
+ _t['annotations'] = {'readOnlyHint': _title_ro,
1235
+ 'destructiveHint': _t['name'] in ('a11y_forms',),
1190
1236
  'idempotentHint': _title_same, 'openWorldHint': _ow}
1191
1237
  if _t['name'] in _RETURNS:
1192
1238
  _t['description'] += ' ' + _RETURNS[_t['name']]
@@ -1293,6 +1339,17 @@ def invoke(name, args):
1293
1339
  'isError': True}
1294
1340
  except Exception as e: # noqa: BLE001
1295
1341
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1342
+ if name == 'a11y_locate':
1343
+ return _content(locate_fn(args['html'], args['query'],
1344
+ role=args.get('role'),
1345
+ multiple=bool(args.get('multiple', False)),
1346
+ lang=args.get('lang', 'en')))
1347
+ if name == 'a11y_patches':
1348
+ if args.get('action') == 'verify':
1349
+ return _content(patches_apply_fn(args['html'], args.get('patch_set'),
1350
+ lang=args.get('lang', 'en')))
1351
+ return _content(patches_build_fn(args['html'], lang=args.get('lang', 'en'),
1352
+ title=args.get('title')))
1296
1353
  if name == 'a11y_diff':
1297
1354
  def _load(v):
1298
1355
  v = v.strip()
@@ -1318,7 +1375,8 @@ def invoke(name, args):
1318
1375
  try:
1319
1376
  return _content(audit_scroll(args['url'], max_batches=args.get('max_batches', 5),
1320
1377
  lang=args.get('lang', 'en'),
1321
- auth_state=args.get('auth_state')))
1378
+ auth_state=args.get('auth_state'),
1379
+ browser=args.get('browser', 'auto')))
1322
1380
  except ImportError:
1323
1381
  return {'content': [{'type': 'text',
1324
1382
  'text': 'Playwright not installed: pip install playwright && playwright install chromium'}],
@@ -1339,7 +1397,7 @@ def invoke(name, args):
1339
1397
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1340
1398
  if name == 'a11y_forms':
1341
1399
  try:
1342
- return _content(audit_forms(args['url'], timeout=args.get('timeout', 45),
1400
+ return _content(audit_forms(args['url'], timeout=args.get('timeout', 45), browser=args.get('browser', 'auto'),
1343
1401
  lang=args.get('lang', 'en'),
1344
1402
  auth_state=args.get('auth_state')))
1345
1403
  except ImportError:
@@ -1353,7 +1411,9 @@ def invoke(name, args):
1353
1411
  return _content(build_pack_fn(args['reports'], snapshot=args.get('snapshot'),
1354
1412
  reviewer=args.get('reviewer'),
1355
1413
  verified=args.get('verified'),
1356
- scope=args.get('scope')))
1414
+ scope=args.get('scope'),
1415
+ build=args.get('build'),
1416
+ lang=args.get('lang', 'en')))
1357
1417
  except Exception as e: # noqa: BLE001
1358
1418
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1359
1419
  if name == 'a11y_scope':
@@ -1361,6 +1421,7 @@ def invoke(name, args):
1361
1421
  return _content(scope_fn(args['reports'], standard=args.get('standard', 'wcag22'),
1362
1422
  target=args.get('target', 'web'),
1363
1423
  answers=args.get('answers'),
1424
+ targets=args.get('targets'),
1364
1425
  lang=args.get('lang', 'en')))
1365
1426
  except Exception as e: # noqa: BLE001
1366
1427
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
@@ -1391,7 +1452,7 @@ def invoke(name, args):
1391
1452
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1392
1453
  if name == 'a11y_hover':
1393
1454
  try:
1394
- return _content(audit_hover(args['url'], timeout=args.get('timeout', 45),
1455
+ return _content(audit_hover(args['url'], timeout=args.get('timeout', 45), browser=args.get('browser', 'auto'),
1395
1456
  lang=args.get('lang', 'en'),
1396
1457
  auth_state=args.get('auth_state')))
1397
1458
  except ImportError:
@@ -1428,10 +1489,14 @@ def invoke(name, args):
1428
1489
  if not args.get('url'):
1429
1490
  return _content({'error': 'gaps requires url'})
1430
1491
  from .a11yledger import gaps as _gaps
1431
- return _content(_gaps(args['url'], path=path))
1492
+ return _content(_gaps(args['url'], path=path, lang=args.get('lang', 'en')))
1432
1493
  if action == 'summary':
1433
1494
  from .a11yledger import summary as _sum
1434
- return _content(_sum(path=path))
1495
+ return _content(_sum(path=path, lang=args.get('lang', 'en')))
1496
+ # enum inválido: error de tool-result nombrando la action y las
1497
+ # válidas — no caer al 'unknown tool' del dispatcher
1498
+ return _content({'error': f'invalid action: {action}',
1499
+ 'valid_actions': ['record', 'gaps', 'summary']})
1435
1500
  except Exception as e:
1436
1501
  return {'content': [{'type': 'text', 'text': f'error: {e}'}], 'isError': True}
1437
1502
  if name == 'a11y_criterion':
@@ -1440,6 +1505,27 @@ def invoke(name, args):
1440
1505
  return _content(criterion_fn(args.get('code'), lang=args.get('lang', 'en'),
1441
1506
  signal=args.get('signal')))
1442
1507
  if name == 'a11y_journey_verdict':
1508
+ if args.get('verify_record') is not None:
1509
+ return _content(journey_verify_fn(args['verify_record'],
1510
+ lang=args.get('lang', 'en')))
1511
+ # verify-only calls need just verify_record; the judge/seal path
1512
+ # (schema-optional since 5.26.1) still requires the walk itself
1513
+ _missing = [k for k in ('task', 'steps', 'outcome') if not args.get(k)]
1514
+ if _missing:
1515
+ return _content({'error': f'{", ".join(_missing)} required '
1516
+ '(only verify_record calls omit task/steps/outcome)'})
1517
+ if args.get('seal'):
1518
+ rec = journey_seal_fn(args['task'], args['steps'], args['outcome'],
1519
+ url=args.get('url', ''),
1520
+ lang=args.get('lang', 'en'))
1521
+ if args.get('output_path') and 'error' not in rec:
1522
+ with open(args['output_path'], 'w', encoding='utf-8') as f:
1523
+ f.write(json.dumps(rec, ensure_ascii=False, indent=1) + '\n')
1524
+ return _content({'out': args['output_path'],
1525
+ 'sha256': rec['sha256'],
1526
+ 'verdict': rec['verdict']['verdict'],
1527
+ 'score': rec['verdict']['score']})
1528
+ return _content(rec)
1443
1529
  res = journey_verdict_fn(args['task'], args['steps'], args['outcome'],
1444
1530
  url=args.get('url', ''), lang=args.get('lang', 'en'))
1445
1531
  if args.get('output_path') and 'error' not in res:
@@ -1558,13 +1644,27 @@ def invoke(name, args):
1558
1644
  else:
1559
1645
  with open(os.path.join(HERE, 'arialive.js'), encoding='utf-8') as f:
1560
1646
  js = f.read()
1561
- if args.get('lang') == 'en':
1647
+ if (args.get('lang') or 'en') != 'es':
1648
+ # the snippet's built-in labels are Spanish; the schema documents
1649
+ # en as the default, so only an explicit lang='es' keeps them
1562
1650
  js = "window.ALM_LANG='en';\n" + js
1563
1651
  return {'content': [{'type': 'text', 'text': js}]}
1564
1652
  raise ValueError(f'unknown tool: {name}')
1565
1653
 
1566
1654
 
1567
1655
  def main():
1656
+ # stdio MCP is UTF-8 by spec, but the process locale decides the pipe
1657
+ # encoding (cp1252 on Windows): one CJK/emoji finding would raise
1658
+ # UnicodeEncodeError OUTSIDE any try and kill the server mid-protocol.
1659
+ # stdin decodes with errors='replace' so a hostile line can never crash
1660
+ # the read either; stdout must encode everything we emit.
1661
+ for _stream, _kw in ((sys.stdin, {'encoding': 'utf-8', 'errors': 'replace'}),
1662
+ (sys.stdout, {'encoding': 'utf-8'})):
1663
+ if hasattr(_stream, 'reconfigure'):
1664
+ try:
1665
+ _stream.reconfigure(**_kw)
1666
+ except (ValueError, OSError, AttributeError):
1667
+ pass # exotic/closed streams: keep their default encoding
1568
1668
  for line in sys.stdin:
1569
1669
  line = line.strip()
1570
1670
  if not line:
@@ -1587,7 +1687,10 @@ def main():
1587
1687
  try:
1588
1688
  if method == 'initialize':
1589
1689
  resp = {'jsonrpc': '2.0', 'id': mid, 'result': {
1590
- 'protocolVersion': msg.get('params', {}).get('protocolVersion', '2024-11-05'),
1690
+ # MCP: answer with the LATEST version we actually support,
1691
+ # never echo the client's (batching is rejected below, so
1692
+ # echoing e.g. '2025-06-18' would be a partial lie)
1693
+ 'protocolVersion': '2024-11-05',
1591
1694
  'capabilities': {'tools': {}, 'prompts': {}},
1592
1695
  'serverInfo': {'name': 'a11y-toolkit', 'version': VERSION},
1593
1696
  '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.28.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",