@kinti/a11y-toolkit 5.22.0 → 5.22.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/a11y_toolkit/__init__.py +5 -0
- package/a11y_toolkit/a11y.py +115 -0
- package/a11y_toolkit/a11yact.py +167 -0
- package/a11y_toolkit/a11yaudit.py +1951 -0
- package/a11y_toolkit/a11ybadge.py +102 -0
- package/a11y_toolkit/a11ybudget.py +122 -0
- package/a11y_toolkit/a11ycrit.py +1017 -0
- package/a11y_toolkit/a11ydiff.py +192 -0
- package/a11y_toolkit/a11ydisprove.py +175 -0
- package/a11y_toolkit/a11ydocx.py +132 -0
- package/a11y_toolkit/a11ydom.py +1831 -0
- package/a11y_toolkit/a11yevidence.py +272 -0
- package/a11y_toolkit/a11yfix.py +330 -0
- package/a11y_toolkit/a11yi18n.py +100 -0
- package/a11y_toolkit/a11yinit.py +113 -0
- package/a11y_toolkit/a11yjourney.py +284 -0
- package/a11y_toolkit/a11yledger.py +210 -0
- package/a11y_toolkit/a11ymutants.py +406 -0
- package/a11y_toolkit/a11yopenacr.py +207 -0
- package/a11y_toolkit/a11ypdf.py +273 -0
- package/a11y_toolkit/a11yroute.py +378 -0
- package/a11y_toolkit/a11ysarif.py +139 -0
- package/a11y_toolkit/a11yscroll.py +212 -0
- package/a11y_toolkit/a11ystatement.py +158 -0
- package/a11y_toolkit/a11yvalidate.py +127 -0
- package/a11y_toolkit/a11yvpat.py +238 -0
- package/a11y_toolkit/a11yvtt.py +136 -0
- package/a11y_toolkit/a11ywcag3.py +262 -0
- package/a11y_toolkit/arialive.js +107 -0
- package/a11y_toolkit/arialive_js.py +113 -0
- package/a11y_toolkit/contrast.py +536 -0
- package/a11y_toolkit/locales/_template.json +468 -0
- package/a11y_toolkit/locales/en.json +525 -0
- package/a11y_toolkit/locales/es.json +525 -0
- package/a11y_toolkit/server.py +1529 -0
- package/bin/a11y-toolkit-mcp.cjs +2 -2
- package/bin/a11y-toolkit.cjs +2 -2
- package/lib/runner.cjs +30 -22
- package/package.json +2 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""a11ytoolkit — one command for the whole toolkit.
|
|
3
|
+
|
|
4
|
+
a11ytoolkit pair "#text" "#background" [--lang es|en]
|
|
5
|
+
a11ytoolkit image path.jpg --text "#ffffff" [--region x,y,w,h] [--sample 4]
|
|
6
|
+
a11ytoolkit audit --url https://client.web | --file page.html
|
|
7
|
+
a11ytoolkit declaration --entity "Name" --url https://… --status partial [options]
|
|
8
|
+
a11ytoolkit snapshot https://mysite --out before.json # needs Playwright
|
|
9
|
+
a11ytoolkit diff before.json after.json
|
|
10
|
+
a11ytoolkit audit --url https://web --pages 5 # light same-domain crawl
|
|
11
|
+
a11ytoolkit sarif --url https://web -o a11y.sarif # GitHub code scanning
|
|
12
|
+
a11ytoolkit badge --score 92 --lang en --out badge.svg # honest SVG badge
|
|
13
|
+
a11ytoolkit budget --budget budget.json --audit today.json # only NEW findings block
|
|
14
|
+
a11ytoolkit fix --file page.html --lang es --title "T" -o fixed.html # safe autofix
|
|
15
|
+
a11ytoolkit reflow https://web # 320px reflow (1.4.10)
|
|
16
|
+
a11ytoolkit kbd https://web # keyboard traps? (2.1.2)
|
|
17
|
+
a11ytoolkit scroll https://medium/section # infinite-scroll audit
|
|
18
|
+
a11ytoolkit evidence audit.json -o pack.json # verifiable evidence pack
|
|
19
|
+
a11ytoolkit forms https://web/contact # form errors (3.3.1/3.3.3)
|
|
20
|
+
a11ytoolkit validate --url https://web # W3C Nu parser view
|
|
21
|
+
a11ytoolkit disprove --url https://web # re-verify findings
|
|
22
|
+
a11ytoolkit ledger record --url https://web --audit r.json # track coverage
|
|
23
|
+
a11ytoolkit contrast-dom https://web --selector ".hero h1" # auto-region pixel sampling
|
|
24
|
+
a11ytoolkit vpat pack.json --product "App" -o vpat.html # VPAT 2.5 (WCAG) draft
|
|
25
|
+
a11ytoolkit openacr pack.json --product "App" -o openacr.yaml # OpenACR YAML (GSA) draft
|
|
26
|
+
a11ytoolkit earl --from-audit audit.json -o earl.json # ACT Rules / EARL export
|
|
27
|
+
a11ytoolkit init [path] # agent hook: AGENTS.md + MCP config
|
|
28
|
+
a11ytoolkit wcag3 --from-audit audit.json # WCAG 3 draft preview (no score)
|
|
29
|
+
a11ytoolkit route --goal "gate my PR" # which tools for the task
|
|
30
|
+
a11ytoolkit route --file page.html # diagnosis: read the page, order the exams
|
|
31
|
+
a11ytoolkit mutants --seed 7 --n 12 # the engine's sealed self-exam
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
import sys
|
|
35
|
+
|
|
36
|
+
from . import a11yaudit
|
|
37
|
+
from . import a11ybadge
|
|
38
|
+
from . import a11yfix
|
|
39
|
+
from . import a11ydom
|
|
40
|
+
from . import a11yevidence
|
|
41
|
+
from . import a11yvalidate
|
|
42
|
+
from . import a11ydisprove
|
|
43
|
+
from . import a11yledger
|
|
44
|
+
from . import a11yscroll
|
|
45
|
+
from . import a11ybudget
|
|
46
|
+
from . import a11ycrit
|
|
47
|
+
from . import a11ydiff
|
|
48
|
+
from . import a11ysarif
|
|
49
|
+
from . import contrast
|
|
50
|
+
from . import a11ystatement
|
|
51
|
+
from . import a11yjourney
|
|
52
|
+
from . import a11yvtt
|
|
53
|
+
from . import a11ypdf
|
|
54
|
+
from . import a11yvpat
|
|
55
|
+
from . import a11yopenacr
|
|
56
|
+
from . import a11yact
|
|
57
|
+
from . import a11yinit
|
|
58
|
+
from . import a11ywcag3
|
|
59
|
+
from . import a11yroute
|
|
60
|
+
from . import a11ymutants
|
|
61
|
+
|
|
62
|
+
SUBCOMMANDS = {
|
|
63
|
+
'pair': (contrast, 'pair'),
|
|
64
|
+
'image': (contrast, 'image'),
|
|
65
|
+
'audit': (a11yaudit, None),
|
|
66
|
+
'declaration': (a11ystatement, None),
|
|
67
|
+
'snapshot': (a11ydiff, 'snapshot'),
|
|
68
|
+
'diff': (a11ydiff, 'diff'),
|
|
69
|
+
'criterion': (a11ycrit, None),
|
|
70
|
+
'sarif': (a11ysarif, None),
|
|
71
|
+
'fix': (a11yfix, None),
|
|
72
|
+
'kbd': (a11ydom, 'kbd_main'),
|
|
73
|
+
'scroll': (a11yscroll, None),
|
|
74
|
+
'forms': (a11ydom, 'forms_main'),
|
|
75
|
+
'validate': (a11yvalidate, None),
|
|
76
|
+
'disprove': (a11ydisprove, None),
|
|
77
|
+
'ledger': (a11yledger, None),
|
|
78
|
+
'evidence': (a11yevidence, None),
|
|
79
|
+
'reflow': (a11ydom, 'reflow_main'),
|
|
80
|
+
'badge': (a11ybadge, None),
|
|
81
|
+
'budget': (a11ybudget, None),
|
|
82
|
+
'journey': (a11yjourney, None),
|
|
83
|
+
'journey-budget': (a11yjourney, '_budget_main'),
|
|
84
|
+
'vtt': (a11yvtt, None),
|
|
85
|
+
'pdf': (a11ypdf, None),
|
|
86
|
+
'contrast-dom': (a11ydom, 'contrast_dom_main'),
|
|
87
|
+
'vpat': (a11yvpat, None),
|
|
88
|
+
'openacr': (a11yopenacr, None),
|
|
89
|
+
'earl': (a11yact, None),
|
|
90
|
+
'init': (a11yinit, 'init_main'),
|
|
91
|
+
'wcag3': (a11ywcag3, None),
|
|
92
|
+
'route': (a11yroute, None),
|
|
93
|
+
'mutants': (a11ymutants, None),
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def main(argv=None):
|
|
98
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
99
|
+
if not argv or argv[0] in ('-h', '--help'):
|
|
100
|
+
print(__doc__)
|
|
101
|
+
print('Available subcommands:', ', '.join(sorted(SUBCOMMANDS)))
|
|
102
|
+
return 0
|
|
103
|
+
if argv[0] not in SUBCOMMANDS:
|
|
104
|
+
print(__doc__)
|
|
105
|
+
print(f'Unknown subcommand: {argv[0]}. Available:', ', '.join(sorted(SUBCOMMANDS)))
|
|
106
|
+
return 2
|
|
107
|
+
modulo, sub = SUBCOMMANDS[argv[0]]
|
|
108
|
+
if sub and sub.endswith('_main'):
|
|
109
|
+
return getattr(modulo, sub)(argv[1:]) # función propia (reflow_main, kbd_main)
|
|
110
|
+
args = ([sub] + argv[1:]) if sub else argv[1:]
|
|
111
|
+
return modulo.main(args)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == '__main__':
|
|
115
|
+
sys.exit(main())
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""ACT Rules mapping + EARL export — interoperability with the W3C ecosystem.
|
|
3
|
+
|
|
4
|
+
- ACT_MAP: toolkit signal → published ACT rule(s) (act-rules.github.io), only
|
|
5
|
+
where a rule directly corresponds. Partial by design and documented: signals
|
|
6
|
+
without a published counterpart stay toolkit-specific (honest boundary,
|
|
7
|
+
never invented rules).
|
|
8
|
+
- earl(informe): EARL 1.0 JSON-LD assertions (earl:failed / earl:cantTell) for
|
|
9
|
+
findings whose signal has an ACT mapping. Automated findings only; the
|
|
10
|
+
absence of findings is NEVER asserted as pass (the pack's not-flagged rule).
|
|
11
|
+
|
|
12
|
+
CLI:
|
|
13
|
+
a11yact.py --url https://example.com -o earl.json # audits first
|
|
14
|
+
a11yact.py --from-audit audit.json -o earl.json # from a report
|
|
15
|
+
a11yact.py --list # print the map
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from .a11yaudit import normalize_signal # noqa: E402 (compat 5.10)
|
|
22
|
+
import sys
|
|
23
|
+
from datetime import datetime, timezone
|
|
24
|
+
|
|
25
|
+
# señal del toolkit → [(id ACT, nombre de la regla)] — curado, solo reglas
|
|
26
|
+
# publicadas en act-rules.github.io/rules/<id>/ que corresponden directamente.
|
|
27
|
+
ACT_MAP = {
|
|
28
|
+
'img_no_alt': [('23a2a8', 'Image has non-empty accessible name')],
|
|
29
|
+
'input_img_alt': [('59796f', 'Image button has non-empty accessible name')],
|
|
30
|
+
'ctrl_name': [('97a4e1', 'Button has non-empty accessible name'),
|
|
31
|
+
('c487ae', 'Link has non-empty accessible name')],
|
|
32
|
+
'field_label': [('e086e5', 'Form field has non-empty accessible name')],
|
|
33
|
+
'label_in_name': [('2ee8b8', 'Visible label is part of accessible name')],
|
|
34
|
+
'empty_heading': [('ffd0e9', 'Heading has non-empty accessible name')],
|
|
35
|
+
'iframe_title': [('cae760', 'Iframe element has non-empty accessible name')],
|
|
36
|
+
'aria_hidden_focusable': [('6cfa84', 'Element with aria-hidden has no content in sequential focus navigation')],
|
|
37
|
+
'aria_value_invalid': [('6a7281', 'ARIA state or property has valid value')],
|
|
38
|
+
'role_unknown': [('674b10', 'Role attribute has valid value')],
|
|
39
|
+
'lang_missing': [('b5c3f8', 'HTML page has lang attribute')],
|
|
40
|
+
'lang_invalid': [('bf051a', 'HTML page lang attribute has valid language tag')],
|
|
41
|
+
'element_lang_invalid': [('de46e4', 'Element with lang attribute has valid language tag')],
|
|
42
|
+
'title_missing': [('2779a5', 'HTML page has non-empty title')],
|
|
43
|
+
'meta_refresh': [('bc659a', 'Meta element has no refresh delay')],
|
|
44
|
+
'zoom_max': [('b4f0c3', 'Meta viewport allows for zoom')],
|
|
45
|
+
'zoom_no': [('b4f0c3', 'Meta viewport allows for zoom')],
|
|
46
|
+
'no_bypass': [('3e12e1', 'Block of repeated content is collapsible')],
|
|
47
|
+
'dup_ids': [('3ea0c8', 'Id attribute value is unique')],
|
|
48
|
+
'autocomplete_invalid': [('73f2c2', 'Autocomplete attribute has valid value')],
|
|
49
|
+
'contrast_fail': [('afw4f7', 'Text has minimum contrast')],
|
|
50
|
+
'contrast_image_fail': [('afw4f7', 'Text has minimum contrast')],
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Reglas con estado "proposed" (no aún publicadas por el AG WG) en el canónico
|
|
54
|
+
# w3c/wcag-act-rules — verificado 23/10/2026. Se citan con su estado, nunca como
|
|
55
|
+
# publicadas: la honestidad del toolkit incluye la del ecosistema que cita.
|
|
56
|
+
ACT_PROPOSED = {'2ee8b8', '3e12e1', '3ea0c8', 'cae760', 'ffd0e9'}
|
|
57
|
+
|
|
58
|
+
_ACT_URL = 'https://www.w3.org/WAI/standards-guidelines/act/rules/{rid}/'
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def act_rules_for(signal):
|
|
62
|
+
"""Señal → reglas ACT con id, título canónico, estado y URL oficial."""
|
|
63
|
+
signal = normalize_signal(signal)
|
|
64
|
+
return [{'id': rid, 'name': name,
|
|
65
|
+
'status': 'proposed' if rid in ACT_PROPOSED else 'published',
|
|
66
|
+
'url': _ACT_URL.format(rid=rid)}
|
|
67
|
+
for rid, name in ACT_MAP.get(signal, [])]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# Notas de honestidad por señal (solapes aproximados declarados)
|
|
71
|
+
ACT_NOTES = {
|
|
72
|
+
'ctrl_name': 'toolkit signal covers a/button/summary; the two ACT rules map by element role',
|
|
73
|
+
'dup_ids': 'ACT rule references WCAG 2.0/2.1 4.1.1 (removed in WCAG 2.2); kept as a parsing-quality signal',
|
|
74
|
+
'contrast_fail': ('ACT rule assumes solid backgrounds; the toolkit measurement '
|
|
75
|
+
'composes effective backgrounds with alpha — approximate overlap'),
|
|
76
|
+
'autocomplete_invalid': ('the ACT rule validates the attribute value; the toolkit '
|
|
77
|
+
'implements the WHATWG modifier grammar and flags invalid values'),
|
|
78
|
+
'no_bypass': 'toolkit signal is a bypass-mechanism heuristic (skip link/main); the ACT rule verifies the technique',
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_EARL_CTX = {
|
|
82
|
+
'earl': 'http://www.w3.org/ns/earl#',
|
|
83
|
+
'dct': 'http://purl.org/dc/terms/',
|
|
84
|
+
'url': 'dct:source',
|
|
85
|
+
'title': 'dct:title',
|
|
86
|
+
'date': 'dct:date',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_NOT_DEAD = {'rejected', 'not-rechecked'}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def act_ids(signal):
|
|
93
|
+
"""ACT rule ids para una señal (lista; vacía si no hay correspondencia publicada)."""
|
|
94
|
+
return [rid for rid, _n in ACT_MAP.get(signal, [])]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def earl(report, url=None):
|
|
98
|
+
"""Informe de auditoría → EARL 1.0 JSON-LD (solo hallazgos con mapeo ACT)."""
|
|
99
|
+
assertions = []
|
|
100
|
+
for h in report.get('findings', []):
|
|
101
|
+
if h.get('status') in _NOT_DEAD or h.get('disprover_status') in _NOT_DEAD:
|
|
102
|
+
continue
|
|
103
|
+
rules = ACT_MAP.get(normalize_signal(h.get('signal', '')))
|
|
104
|
+
if not rules:
|
|
105
|
+
continue
|
|
106
|
+
outcome = 'earl:failed' if h.get('severity') in ('high', 'medium') else 'earl:cantTell'
|
|
107
|
+
for rid, name in rules:
|
|
108
|
+
assertions.append({
|
|
109
|
+
'@type': 'earl:Assertion',
|
|
110
|
+
'earl:subject': {'@type': 'earl:TestSubject',
|
|
111
|
+
'url': url or report.get('url', '')},
|
|
112
|
+
'earl:test': {'@type': 'earl:TestCase',
|
|
113
|
+
'url': _ACT_URL.format(rid=rid),
|
|
114
|
+
'title': name},
|
|
115
|
+
'earl:result': {'@type': 'earl:TestResult',
|
|
116
|
+
'outcome': outcome,
|
|
117
|
+
'date': datetime.now(timezone.utc).isoformat(timespec='seconds'),
|
|
118
|
+
'description': (h.get('issue') or '')[:300]},
|
|
119
|
+
'earl:mode': 'earl:automatic',
|
|
120
|
+
'earl:assertedBy': {'@type': 'earl:Software', 'title': 'a11y-toolkit'},
|
|
121
|
+
})
|
|
122
|
+
return {
|
|
123
|
+
'@context': _EARL_CTX,
|
|
124
|
+
'@graph': assertions,
|
|
125
|
+
'meta': {
|
|
126
|
+
'tool': 'a11y-toolkit',
|
|
127
|
+
'url': url or report.get('url', ''),
|
|
128
|
+
'note': ('Only failed/cantTell findings are asserted; absence is never '
|
|
129
|
+
'asserted as pass. ACT coverage is partial by design — see ACT_MAP '
|
|
130
|
+
'and ACT_NOTES in a11yact.py.'),
|
|
131
|
+
'coverage': {'mapped_signals': len(ACT_MAP),
|
|
132
|
+
'assertions': len(assertions)},
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def main(argv):
|
|
138
|
+
ap = argparse.ArgumentParser(description='ACT Rules mapping + EARL export')
|
|
139
|
+
ap.add_argument('--url', help='URL to audit first (static pass)')
|
|
140
|
+
ap.add_argument('--from-audit', help='existing audit report JSON')
|
|
141
|
+
ap.add_argument('--list', action='store_true', help='print the signal → ACT rule map')
|
|
142
|
+
ap.add_argument('-o', '--out', help='write EARL JSON here (default: stdout)')
|
|
143
|
+
a = ap.parse_args(argv)
|
|
144
|
+
if a.list:
|
|
145
|
+
print(json.dumps({'act_map': ACT_MAP, 'act_notes': ACT_NOTES},
|
|
146
|
+
ensure_ascii=False, indent=1))
|
|
147
|
+
return 0
|
|
148
|
+
if a.from_audit:
|
|
149
|
+
report = json.load(open(a.from_audit, encoding='utf-8'))
|
|
150
|
+
elif a.url:
|
|
151
|
+
from .a11yaudit import audit_url
|
|
152
|
+
report = audit_url(a.url)
|
|
153
|
+
else:
|
|
154
|
+
ap.print_help()
|
|
155
|
+
return 2
|
|
156
|
+
res = earl(report, url=a.url)
|
|
157
|
+
if a.out:
|
|
158
|
+
with open(a.out, 'w', encoding='utf-8') as f:
|
|
159
|
+
json.dump(res, f, ensure_ascii=False, indent=1)
|
|
160
|
+
print(json.dumps({'earl': a.out, 'assertions': res['meta']['coverage']['assertions']}))
|
|
161
|
+
else:
|
|
162
|
+
print(json.dumps(res, ensure_ascii=False, indent=1))
|
|
163
|
+
return 0
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if __name__ == '__main__':
|
|
167
|
+
sys.exit(main(sys.argv[1:]))
|