a11y

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 12 Imported by: 0

README

Agent A11y (Agent Accessibility)

Go CI Go Lint Go SAST Go Report Card Docs Visualization License

Go accessibility auditing toolkit for WCAG 2.0, 2.1, and 2.2 compliance testing.

Features

  • WCAG Compliance Testing - Supports WCAG 2.0, 2.1, and 2.2 at levels A, AA, and AAA
  • 🔍 Multiple Audit Modes - Single page, site crawling, and user journey testing
  • 🪓 axe-core Integration - Industry-standard accessibility testing via axe-core
  • 🤖 LLM-as-a-Judge - Optional AI evaluation to reduce false positives
  • 📊 Report Formats - JSON, HTML, Markdown, VPAT 2.4, WCAG-EM, CSV
  • 🔌 MCP Server - Model Context Protocol integration for AI assistants
  • 🌐 HTTP API - REST API for programmatic access
  • 🤝 Multi-Agent Spec - Integration with multi-agent workflows

Installation

go install github.com/plexusone/agent-a11y/cmd/agent-a11y@latest
Prerequisites
  • Go 1.25+
  • Chrome/Chromium browser (for browser-based testing)

Quick Start

CLI Usage
# Audit a single page
agent-a11y audit https://example.com

# Audit with site crawling
agent-a11y audit https://example.com --crawl --depth 2

# Specify WCAG level and version
agent-a11y audit https://example.com --level AA --version 2.2

# Output to file with format
agent-a11y audit https://example.com -o report.html --format html

# Enable LLM evaluation (reduces false positives)
agent-a11y audit https://example.com --llm-provider anthropic --llm-model claude-sonnet-4-20250514
Go Library
package main

import (
    "context"
    "fmt"
    "log"

    a11y "github.com/plexusone/agent-a11y"
)

func main() {
    // Create auditor
    auditor, err := a11y.New(
        a11y.WithLevel(a11y.LevelAA),
        a11y.WithVersion(a11y.Version22),
    )
    if err != nil {
        log.Fatal(err)
    }
    defer auditor.Close()

    // Audit a page
    result, err := auditor.AuditPage(context.Background(), "https://example.com")
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(result.Summary())
    // WCAG 2.2 Level AA: Conformant (Score: 95/100, Issues: 0 critical, 0 serious, 1 moderate, 2 minor)
}

CLI Commands

Command Description
audit <url> Run accessibility audit on a URL
serve Start HTTP API server
mcp serve Start MCP server for AI assistants
compare <before> <after> Compare accessibility between two URLs
demo list List available demo sites
demo run [name] Run demo audit on sample sites
version Show version information

Output Formats

Format Flag Description
JSON --format json Machine-readable JSON output
HTML --format html Interactive HTML report
Markdown --format markdown Markdown report
VPAT --format vpat VPAT 2.4 accessibility conformance report
WCAG-EM --format wcag WCAG-EM evaluation report
CSV --format csv CSV export of findings

Configuration

Create a config file at ~/.agent-a11y.yaml or specify with --config:

wcag:
  level: AA
  version: "2.2"

browser:
  headless: true
  timeout: 30s

llm:
  enabled: true
  provider: anthropic
  model: claude-sonnet-4-20250514

crawl:
  depth: 2
  maxPages: 50
  delay: 500ms

LLM Providers

agent-a11y supports multiple LLM providers for AI-assisted evaluation:

Provider Environment Variable
Anthropic ANTHROPIC_API_KEY
OpenAI OPENAI_API_KEY
Google GOOGLE_API_KEY
xAI XAI_API_KEY
Ollama (local, no key required)

MCP Server

Run as an MCP server for integration with AI assistants:

agent-a11y mcp serve

Add to your Claude Desktop config:

{
  "mcpServers": {
    "a11y": {
      "command": "agent-a11y",
      "args": ["mcp", "serve"]
    }
  }
}

HTTP API

Start the API server:

agent-a11y serve --port 8080

Endpoints:

  • POST /audit - Run an accessibility audit
  • GET /health - Health check

Multi-Agent Integration

agent-a11y integrates with the multi-agent-spec for use in multi-agent workflows:

result, _ := auditor.AuditPage(ctx, url)

// Convert to AgentResult for multi-agent workflows
agentResult := result.AgentResult()

// Get narrative for reports
narrative := result.Narrative()

Examples

See the examples directory:

  • basic - Simple single-page audit
  • multi-agent - Multi-agent workflow integration

Development

# Run tests
go test -v ./...

# Run linter
golangci-lint run

# Build CLI
go build -o agent-a11y ./cmd/agent-a11y

License

MIT

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

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 New

func New(opts ...Option) (*Auditor, error)

New creates a new Auditor with the given options.

func (*Auditor) AuditJourney

func (a *Auditor) AuditJourney(ctx context.Context, url, journeyPath string) (*Result, error)

AuditJourney performs an accessibility audit using a journey definition file.

func (*Auditor) AuditPage

func (a *Auditor) AuditPage(ctx context.Context, url string) (*Result, error)

AuditPage performs an accessibility audit on a single page.

func (*Auditor) AuditSite

func (a *Auditor) AuditSite(ctx context.Context, url string, crawlOpts ...CrawlOption) (*Result, error)

AuditSite performs an accessibility audit on an entire website by crawling.

func (*Auditor) Close

func (a *Auditor) Close() error

Close releases resources used by the auditor.

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 CrawlDepth

func CrawlDepth(depth int) CrawlOption

CrawlDepth sets the maximum crawl depth.

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 Level

type Level string

Level represents WCAG conformance levels.

const (
	// LevelA is WCAG Level A (minimum conformance).
	LevelA Level = "A"
	// LevelAA is WCAG Level AA (standard conformance, most common target).
	LevelAA Level = "AA"
	// LevelAAA is WCAG Level AAA (enhanced conformance).
	LevelAAA Level = "AAA"
)

type Option

type Option func(*options)

Option configures an Auditor.

func WithHeadless

func WithHeadless(headless bool) Option

WithHeadless configures the browser to run in headless mode.

func WithLLM

func WithLLM(provider, model string) Option

WithLLM enables LLM-based evaluation of accessibility issues. Provider can be "anthropic", "openai", "gemini", "ollama", or "xai".

func WithLLMAPIKey

func WithLLMAPIKey(apiKey string) Option

WithLLMAPIKey sets the API key for LLM provider.

func WithLevel

func WithLevel(level Level) Option

WithLevel sets the target WCAG conformance level.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets a custom logger.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the maximum duration for audit operations.

func WithVersion

func WithVersion(version Version) Option

WithVersion sets the WCAG specification version.

type PageResult

type PageResult struct {
	URL          string
	Title        string
	FindingCount int
	Score        int
}

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

func (r *Result) Conformant() bool

Conformant returns true if the audit passed at the target level.

func (*Result) CriticalFindings

func (r *Result) CriticalFindings() []Finding

CriticalFindings returns only critical severity findings.

func (*Result) FindingsByCriterion

func (r *Result) FindingsByCriterion(criterion string) []Finding

FindingsByCriterion returns findings for a specific success criterion.

func (*Result) FindingsByLevel

func (r *Result) FindingsByLevel(level Level) []Finding

FindingsByLevel returns findings filtered by WCAG level.

func (*Result) HTML

func (r *Result) HTML() ([]byte, error)

HTML returns the result as an HTML report.

func (*Result) JSON

func (r *Result) JSON() ([]byte, error)

JSON returns the result as JSON bytes.

func (*Result) Markdown

func (r *Result) Markdown() ([]byte, error)

Markdown returns the result as a Markdown report.

func (*Result) Narrative

func (r *Result) Narrative() *mas.NarrativeSection

Narrative returns a NarrativeSection for prose reports.

func (*Result) SeriousFindings

func (r *Result) SeriousFindings() []Finding

SeriousFindings returns only serious severity findings.

func (*Result) Summary

func (r *Result) Summary() string

Summary returns a brief text summary of the audit.

func (*Result) TeamSection

func (r *Result) TeamSection() mas.TeamSection

TeamSection returns a TeamSection for inclusion in a TeamReport.

func (*Result) VPAT

func (r *Result) VPAT() ([]byte, error)

VPAT returns the result as a VPAT 2.4 report.

func (*Result) WCAG

func (r *Result) WCAG() ([]byte, error)

WCAG returns the result in WCAG-EM format.

type Stats

type Stats struct {
	TotalPages    int
	TotalFindings int
	Critical      int
	Serious       int
	Moderate      int
	Minor         int
	LevelA        int
	LevelAA       int
	LevelAAA      int
}

Stats contains summary statistics for the audit.

type Version

type Version string

Version represents WCAG specification versions.

const (
	// Version20 is WCAG 2.0.
	Version20 Version = "2.0"
	// Version21 is WCAG 2.1.
	Version21 Version = "2.1"
	// Version22 is WCAG 2.2.
	Version22 Version = "2.2"
)

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.
llm
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL