Documentation
¶
Overview ¶
Package a11y provides comprehensive WCAG accessibility auditing for websites.
agent-a11y is a Go library and CLI tool for automated accessibility testing, supporting WCAG 2.0, 2.1, and 2.2 at levels A, AA, and AAA. It includes LLM-based evaluation, journey testing, site crawling, and multiple report formats.
Quick Start ¶
The simplest way to audit a page:
auditor := a11y.New()
result, err := auditor.AuditPage(ctx, "https://example.com")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Score: %d, Issues: %d\n", result.Score, len(result.Findings))
Configuration ¶
Use functional options to configure the auditor:
auditor := a11y.New(
a11y.WithLevel(a11y.LevelAA), // WCAG AA conformance
a11y.WithHeadless(true), // Run browser headlessly
a11y.WithTimeout(2 * time.Minute), // Set timeout
a11y.WithLLM("anthropic", "claude-sonnet-4-20250514"), // Enable LLM evaluation
)
Site Crawling ¶
Audit an entire website:
result, err := auditor.AuditSite(ctx, "https://example.com",
a11y.CrawlDepth(3),
a11y.CrawlMaxPages(100),
)
Journey Testing ¶
Test user flows with journey definitions:
result, err := auditor.AuditJourney(ctx, "https://example.com", "checkout.yaml")
Reports ¶
Generate reports in multiple formats:
// JSON report json, _ := result.JSON() // HTML report html, _ := result.HTML() // VPAT 2.4 report vpat, _ := result.VPAT()
Multi-Agent Integration ¶
Convert results to multi-agent-spec format for go/no-go decisions:
result, _ := auditor.AuditPage(ctx, "https://example.com")
// Get AgentResult for multi-agent workflows
agentResult := result.AgentResult()
fmt.Printf("Status: %s\n", agentResult.Status) // GO, WARN, NO-GO
// Get TeamSection for inclusion in a TeamReport
teamSection := result.TeamSection()
// Get narrative for prose reports
narrative := result.Narrative()
fmt.Println(narrative.Problem)
fmt.Println(narrative.Analysis)
fmt.Println(narrative.Recommendation)
MCP Server ¶
Start an MCP server for AI assistant integration:
server := a11y.NewMCPServer() server.Serve(ctx)
CLI Usage ¶
The agent-a11y command provides CLI access:
# Audit a page agent-a11y audit https://example.com # Audit with specific level agent-a11y audit https://example.com --level AA # Generate VPAT report agent-a11y vpat https://example.com -o vpat.html # Start MCP server agent-a11y mcp serve
Index ¶
- type Auditor
- func (a *Auditor) AuditJourney(ctx context.Context, url, journeyPath string) (*Result, error)
- func (a *Auditor) AuditPage(ctx context.Context, url string) (*Result, error)
- func (a *Auditor) AuditSite(ctx context.Context, url string, crawlOpts ...CrawlOption) (*Result, error)
- func (a *Auditor) Close() error
- type CrawlOption
- type Finding
- type Level
- type Option
- type PageResult
- type Result
- func (r *Result) AgentResult() *mas.AgentResult
- func (r *Result) Conformant() bool
- func (r *Result) CriticalFindings() []Finding
- func (r *Result) FindingsByCriterion(criterion string) []Finding
- func (r *Result) FindingsByLevel(level Level) []Finding
- func (r *Result) HTML() ([]byte, error)
- func (r *Result) JSON() ([]byte, error)
- func (r *Result) Markdown() ([]byte, error)
- func (r *Result) Narrative() *mas.NarrativeSection
- func (r *Result) SeriousFindings() []Finding
- func (r *Result) Summary() string
- func (r *Result) TeamSection() mas.TeamSection
- func (r *Result) VPAT() ([]byte, error)
- func (r *Result) WCAG() ([]byte, error)
- type Stats
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auditor ¶
type Auditor struct {
// contains filtered or unexported fields
}
Auditor performs WCAG accessibility audits.
func (*Auditor) AuditJourney ¶
AuditJourney performs an accessibility audit using a journey definition file.
type CrawlOption ¶
type CrawlOption func(*options)
CrawlOption configures site crawling behavior.
func CrawlDelay ¶
func CrawlDelay(delay time.Duration) CrawlOption
CrawlDelay sets the delay between page requests.
func CrawlMaxPages ¶
func CrawlMaxPages(maxPages int) CrawlOption
CrawlMaxPages sets the maximum number of pages to crawl.
type Finding ¶
type Finding struct {
// ID is the unique identifier for this finding.
ID string
// RuleID identifies the WCAG rule that was violated.
RuleID string
// Description explains the issue.
Description string
// Help provides guidance on how to fix the issue.
Help string
// SuccessCriteria lists the WCAG success criteria affected.
SuccessCriteria []string
// Level is the WCAG level (A, AA, AAA).
Level string
// Impact indicates the severity (critical, serious, moderate, minor).
Impact string
// Element is the HTML element type.
Element string
// Selector is the CSS selector to find the element.
Selector string
// HTML is a snippet of the problematic HTML.
HTML string
// PageURL is the URL where this issue was found.
PageURL string
// LLMConfirmed indicates if LLM evaluation confirmed the issue.
LLMConfirmed *bool
// LLMReasoning is the LLM's explanation.
LLMReasoning string
}
Finding represents a single accessibility issue.
type Option ¶
type Option func(*options)
Option configures an Auditor.
func WithHeadless ¶
WithHeadless configures the browser to run in headless mode.
func WithLLM ¶
WithLLM enables LLM-based evaluation of accessibility issues. Provider can be "anthropic", "openai", "gemini", "ollama", or "xai".
func WithLLMAPIKey ¶
WithLLMAPIKey sets the API key for LLM provider.
func WithTimeout ¶
WithTimeout sets the maximum duration for audit operations.
func WithVersion ¶
WithVersion sets the WCAG specification version.
type PageResult ¶
PageResult represents results for a single page.
type Result ¶
type Result struct {
// URL is the audited URL.
URL string
// Score is the overall conformance score (0-100).
Score int
// Level is the target WCAG level.
Level string
// Version is the WCAG version used.
Version string
// Findings contains all accessibility issues found.
Findings []Finding
// Pages contains per-page results (for site audits).
Pages []PageResult
// Stats contains summary statistics.
Stats Stats
// contains filtered or unexported fields
}
Result represents the outcome of an accessibility audit.
func (*Result) AgentResult ¶
func (r *Result) AgentResult() *mas.AgentResult
AgentResult converts the audit result to a multi-agent-spec AgentResult. This allows agent-a11y to be used as part of a multi-agent workflow, returning standardized go/no-go decisions and narrative reports.
func (*Result) Conformant ¶
Conformant returns true if the audit passed at the target level.
func (*Result) CriticalFindings ¶
CriticalFindings returns only critical severity findings.
func (*Result) FindingsByCriterion ¶
FindingsByCriterion returns findings for a specific success criterion.
func (*Result) FindingsByLevel ¶
FindingsByLevel returns findings filtered by WCAG level.
func (*Result) Narrative ¶
func (r *Result) Narrative() *mas.NarrativeSection
Narrative returns a NarrativeSection for prose reports.
func (*Result) SeriousFindings ¶
SeriousFindings returns only serious severity findings.
func (*Result) TeamSection ¶
func (r *Result) TeamSection() mas.TeamSection
TeamSection returns a TeamSection for inclusion in a TeamReport.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api provides the REST API server for the accessibility audit service.
|
Package api provides the REST API server for the accessibility audit service. |
|
Package audit provides the core accessibility audit engine.
|
Package audit provides the core accessibility audit engine. |
|
axe
Package axe provides accessibility testing using axe-core.
|
Package axe provides accessibility testing using axe-core. |
|
specialized
Package specialized provides specialized automated accessibility tests that go beyond what axe-core can detect.
|
Package specialized provides specialized automated accessibility tests that go beyond what axe-core can detect. |
|
Package auth provides authentication handling for accessibility audits.
|
Package auth provides authentication handling for accessibility audits. |
|
cmd
|
|
|
agent-a11y
command
Package main is the entry point for the agenta11y CLI.
|
Package main is the entry point for the agenta11y CLI. |
|
Package config provides configuration types for the accessibility audit service.
|
Package config provides configuration types for the accessibility audit service. |
|
Package crawler provides website crawling with SPA detection.
|
Package crawler provides website crawling with SPA detection. |
|
examples
|
|
|
basic
command
Example: Basic usage of agent-a11y as a Go library.
|
Example: Basic usage of agent-a11y as a Go library. |
|
multi-agent
command
Example: Multi-agent integration with agent-a11y.
|
Example: Multi-agent integration with agent-a11y. |
|
Package journey provides the compiler for converting prompts to deterministic steps.
|
Package journey provides the compiler for converting prompts to deterministic steps. |
|
Package llm provides LLM-as-a-Judge functionality for accessibility evaluation.
|
Package llm provides LLM-as-a-Judge functionality for accessibility evaluation. |
|
prompts
Package prompts contains LLM prompts for WCAG criterion evaluation.
|
Package prompts contains LLM prompts for WCAG criterion evaluation. |
|
Package mcp provides a Model Context Protocol server for agent-a11y.
|
Package mcp provides a Model Context Protocol server for agent-a11y. |
|
Package remediation provides constants and URL builders for accessibility remediation references, similar to how net/http provides HTTP status codes.
|
Package remediation provides constants and URL builders for accessibility remediation references, similar to how net/http provides HTTP status codes. |
|
Package report provides report generation for accessibility audits.
|
Package report provides report generation for accessibility audits. |
|
Package types provides shared types used across the accessibility audit service.
|
Package types provides shared types used across the accessibility audit service. |
|
Package wcag provides WCAG 2.2 criteria definitions and evaluation methods.
|
Package wcag provides WCAG 2.2 criteria definitions and evaluation methods. |