Documentation
¶
Overview ¶
Package config provides configuration types for the accessibility audit service.
Package config provides configuration loading and management for agent-a11y.
Index ¶
- func A11yConfigDir() (string, error)
- func FixesConfigPath() (string, error)
- func PlexusOneDir() (string, error)
- func SaveFixesConfig(config *FixesConfig) error
- type AuditPoint
- type AuthConfig
- type AuthSelectors
- type BrowserConfig
- type ComponentFix
- type ComponentFixConfig
- type ComponentLibrary
- type Config
- type CrawlConfig
- type Duration
- type FixDefaults
- type FixResolver
- type FixesConfig
- type JourneyInline
- type JourneyRef
- type JourneyStep
- type LLMConfig
- type LanguageConfig
- type LanguageConventions
- type LanguagePattern
- type LibraryComponent
- type OutputConfig
- type ProjectConfig
- type ProjectContext
- type ResolvedFix
- type Viewport
- type WCAGConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func A11yConfigDir ¶ added in v0.4.0
A11yConfigDir returns the path to ~/.plexusone/a11y/
func FixesConfigPath ¶ added in v0.4.0
FixesConfigPath returns the path to ~/.plexusone/a11y/fixes.yaml
func PlexusOneDir ¶ added in v0.4.0
PlexusOneDir returns the path to ~/.plexusone/
func SaveFixesConfig ¶ added in v0.4.0
func SaveFixesConfig(config *FixesConfig) error
SaveFixesConfig saves the fixes configuration to ~/.plexusone/a11y/fixes.yaml
Types ¶
type AuditPoint ¶
type AuditPoint struct {
Description string `yaml:"description" json:"description"`
WaitFor string `yaml:"waitFor,omitempty" json:"waitFor,omitempty"`
Condition string `yaml:"condition,omitempty" json:"condition,omitempty"`
}
AuditPoint defines when to audit during a journey.
type AuthConfig ¶
type AuthConfig struct {
// Type is the authentication type: form, oauth, basic, bearer.
Type string `yaml:"type" json:"type"`
// LoginURL is the URL of the login page.
LoginURL string `yaml:"loginUrl,omitempty" json:"loginUrl,omitempty"`
// Credentials contains login credentials.
Credentials map[string]string `yaml:"credentials,omitempty" json:"credentials,omitempty"`
// Selectors contains CSS selectors for form elements.
Selectors *AuthSelectors `yaml:"selectors,omitempty" json:"selectors,omitempty"`
// Headers contains authentication headers (for bearer/basic).
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
// Cookies contains authentication cookies.
Cookies map[string]string `yaml:"cookies,omitempty" json:"cookies,omitempty"`
// SuccessIndicator is a selector that indicates successful login.
SuccessIndicator string `yaml:"successIndicator,omitempty" json:"successIndicator,omitempty"`
}
AuthConfig contains authentication settings.
type AuthSelectors ¶
type AuthSelectors struct {
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
Submit string `yaml:"submit" json:"submit"`
MFA string `yaml:"mfa,omitempty" json:"mfa,omitempty"`
}
AuthSelectors contains selectors for form-based authentication.
type BrowserConfig ¶
type BrowserConfig struct {
// Headless runs in headless mode.
Headless bool `yaml:"headless" json:"headless"`
// Timeout is the default page timeout.
Timeout Duration `yaml:"timeout" json:"timeout"`
// Viewport sets the viewport size.
Viewport *Viewport `yaml:"viewport,omitempty" json:"viewport,omitempty"`
// UserAgent overrides the user agent.
UserAgent string `yaml:"userAgent,omitempty" json:"userAgent,omitempty"`
}
BrowserConfig contains browser settings.
type ComponentFix ¶ added in v0.4.0
type ComponentFix struct {
Rule string `yaml:"rule" json:"rule"`
Pattern string `yaml:"pattern" json:"pattern"`
Priority int `yaml:"priority" json:"priority,omitempty"`
}
ComponentFix is a fix pattern for a component.
type ComponentFixConfig ¶ added in v0.4.0
type ComponentFixConfig struct {
Selectors []string `yaml:"selectors" json:"selectors"`
Fixes []ComponentFix `yaml:"fixes" json:"fixes"`
}
ComponentFixConfig contains fix patterns for a specific component.
type ComponentLibrary ¶ added in v0.4.0
type ComponentLibrary struct {
Components map[string]LibraryComponent `yaml:",inline"`
}
ComponentLibrary contains patterns for a UI component library.
type Config ¶
type Config struct {
// URL is the starting URL for the audit.
URL string `yaml:"url" json:"url"`
// Auth contains authentication configuration.
Auth *AuthConfig `yaml:"auth,omitempty" json:"auth,omitempty"`
// Crawl contains crawling configuration.
Crawl *CrawlConfig `yaml:"crawl,omitempty" json:"crawl,omitempty"`
// Journey specifies a user journey to execute.
Journey *JourneyRef `yaml:"journey,omitempty" json:"journey,omitempty"`
// WCAG contains WCAG testing configuration.
WCAG WCAGConfig `yaml:"wcag" json:"wcag"`
// LLM contains LLM-as-a-Judge configuration.
LLM *LLMConfig `yaml:"llm,omitempty" json:"llm,omitempty"`
// Output contains output configuration.
Output OutputConfig `yaml:"output" json:"output"`
// Browser contains browser configuration.
Browser BrowserConfig `yaml:"browser" json:"browser"`
}
Config represents the complete audit configuration.
func LoadConfig ¶
LoadConfig loads configuration from a YAML file.
type CrawlConfig ¶
type CrawlConfig struct {
// Depth is the maximum link depth to crawl.
Depth int `yaml:"depth" json:"depth"`
// MaxPages is the maximum number of pages to audit.
MaxPages int `yaml:"maxPages" json:"maxPages"`
// IncludePatterns are glob patterns for URLs to include.
IncludePatterns []string `yaml:"includePatterns,omitempty" json:"includePatterns,omitempty"`
// ExcludePatterns are glob patterns for URLs to exclude.
ExcludePatterns []string `yaml:"excludePatterns,omitempty" json:"excludePatterns,omitempty"`
// WaitForSPA enables waiting for SPA hydration.
WaitForSPA bool `yaml:"waitForSPA" json:"waitForSPA"`
// SPAIndicators are selectors that indicate SPA readiness.
SPAIndicators []string `yaml:"spaIndicators,omitempty" json:"spaIndicators,omitempty"`
// RespectRobots respects robots.txt rules.
RespectRobots bool `yaml:"respectRobots" json:"respectRobots"`
// UseSitemap uses sitemap.xml for discovery.
UseSitemap bool `yaml:"useSitemap" json:"useSitemap"`
// Delay between page requests.
Delay Duration `yaml:"delay,omitempty" json:"delay,omitempty"`
}
CrawlConfig contains crawling settings.
type FixDefaults ¶ added in v0.4.0
type FixDefaults struct {
Extends string `yaml:"extends" json:"extends"` // "builtin" or path to base config
Tokens map[string][]string `yaml:"tokens" json:"tokens"`
}
FixDefaults contains global default settings.
type FixResolver ¶ added in v0.4.0
type FixResolver struct {
// contains filtered or unexported fields
}
FixResolver resolves fix patterns from multiple sources.
func NewFixResolver ¶ added in v0.4.0
func NewFixResolver(fixesConfig *FixesConfig, projectCtx *ProjectContext) *FixResolver
NewFixResolver creates a new fix resolver.
func (*FixResolver) ResolveFixes ¶ added in v0.4.0
func (r *FixResolver) ResolveFixes(ruleID string, element *types.ElementContext) []ResolvedFix
ResolveFixes returns all applicable fix patterns for a rule. Resolution order: project > library > language > builtin
type FixesConfig ¶ added in v0.4.0
type FixesConfig struct {
Version string `yaml:"version" json:"version"`
Defaults FixDefaults `yaml:"defaults" json:"defaults"`
Languages map[string]LanguageConfig `yaml:"languages" json:"languages"`
Projects []ProjectConfig `yaml:"projects" json:"projects"`
Libraries map[string]ComponentLibrary `yaml:"component-libraries" json:"componentLibraries"`
}
FixesConfig is the root configuration for project-specific fixes. Loaded from ~/.plexusone/a11y/fixes.yaml
func LoadFixesConfig ¶ added in v0.4.0
func LoadFixesConfig() (*FixesConfig, error)
LoadFixesConfig loads the fixes configuration from ~/.plexusone/a11y/fixes.yaml
func (*FixesConfig) GetLanguageConfig ¶ added in v0.4.0
func (c *FixesConfig) GetLanguageConfig(language string) *LanguageConfig
GetLanguageConfig returns the language config for a given language.
func (*FixesConfig) GetLibrary ¶ added in v0.4.0
func (c *FixesConfig) GetLibrary(name string) *ComponentLibrary
GetLibrary returns a component library config by name.
func (*FixesConfig) MatchProject ¶ added in v0.4.0
func (c *FixesConfig) MatchProject(repoPath string) *ProjectConfig
MatchProject finds the best matching project config for a repo path.
type JourneyInline ¶
type JourneyInline struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Mode string `yaml:"mode" json:"mode"` // agentic, deterministic, hybrid
Steps []JourneyStep `yaml:"steps,omitempty" json:"steps,omitempty"`
Goal string `yaml:"goal,omitempty" json:"goal,omitempty"`
TestData map[string]any `yaml:"testData,omitempty" json:"testData,omitempty"`
AuditPoints []AuditPoint `yaml:"auditPoints,omitempty" json:"auditPoints,omitempty"`
}
JourneyInline contains an inline journey definition.
type JourneyRef ¶
type JourneyRef struct {
// ID is the journey ID (for stored journeys).
ID string `yaml:"id,omitempty" json:"id,omitempty"`
// Path is a file path to a journey definition.
Path string `yaml:"path,omitempty" json:"path,omitempty"`
// Inline contains an inline journey definition.
Inline *JourneyInline `yaml:"inline,omitempty" json:"inline,omitempty"`
}
JourneyRef references a journey definition.
type JourneyStep ¶
type JourneyStep struct {
// For deterministic mode
Action string `yaml:"action,omitempty" json:"action,omitempty"`
Selector string `yaml:"selector,omitempty" json:"selector,omitempty"`
Value string `yaml:"value,omitempty" json:"value,omitempty"`
URL string `yaml:"url,omitempty" json:"url,omitempty"`
WaitFor string `yaml:"waitFor,omitempty" json:"waitFor,omitempty"`
// For agentic/hybrid mode
Prompt string `yaml:"prompt,omitempty" json:"prompt,omitempty"`
Instructions string `yaml:"instructions,omitempty" json:"instructions,omitempty"`
Data map[string]any `yaml:"data,omitempty" json:"data,omitempty"`
File string `yaml:"file,omitempty" json:"file,omitempty"`
// Audit trigger
Audit bool `yaml:"audit,omitempty" json:"audit,omitempty"`
AuditName string `yaml:"auditName,omitempty" json:"auditName,omitempty"`
// Flow control
UseAuth bool `yaml:"auth,omitempty" json:"auth,omitempty"`
}
JourneyStep represents a step in a journey.
type LLMConfig ¶
type LLMConfig struct {
// Enabled enables LLM-based evaluation.
Enabled bool `yaml:"enabled" json:"enabled"`
// Provider is the LLM provider: anthropic, openai.
Provider string `yaml:"provider" json:"provider"`
// Model is the model ID.
Model string `yaml:"model" json:"model"`
// APIKey is the API key (or use env var).
APIKey string `yaml:"apiKey,omitempty" json:"apiKey,omitempty"`
// JudgeCategories are the categories to evaluate with LLM.
JudgeCategories []string `yaml:"judgeCategories,omitempty" json:"judgeCategories,omitempty"`
// CompileJourneys enables journey prompt compilation.
CompileJourneys bool `yaml:"compileJourneys,omitempty" json:"compileJourneys,omitempty"`
}
LLMConfig contains LLM-as-a-Judge settings.
type LanguageConfig ¶ added in v0.4.0
type LanguageConfig struct {
Patterns map[string]LanguagePattern `yaml:"patterns" json:"patterns"`
Conventions LanguageConventions `yaml:"conventions" json:"conventions"`
}
LanguageConfig contains language/framework-specific patterns.
type LanguageConventions ¶ added in v0.4.0
type LanguageConventions struct {
AriaAttributes string `yaml:"aria-attributes" json:"ariaAttributes"` // "camelCase" or "kebab-case"
EventHandlers string `yaml:"event-handlers" json:"eventHandlers"` // "onKeyDown" or "@keydown"
}
LanguageConventions describes language-specific conventions.
type LanguagePattern ¶ added in v0.4.0
type LanguagePattern struct {
Component string `yaml:"component" json:"component,omitempty"`
Import string `yaml:"import" json:"import,omitempty"`
Example string `yaml:"example" json:"example"`
}
LanguagePattern is a fix pattern for a specific language.
type LibraryComponent ¶ added in v0.4.0
type LibraryComponent struct {
Import string `yaml:"import" json:"import"`
Fixes []ComponentFix `yaml:"fixes" json:"fixes"`
}
LibraryComponent is a component from a UI library.
type OutputConfig ¶
type OutputConfig struct {
// Formats are the output formats to generate.
Formats []string `yaml:"formats" json:"formats"` // json, html, vpat, wcag, markdown
// Directory is the output directory.
Directory string `yaml:"directory" json:"directory"`
// Screenshots enables screenshot capture.
Screenshots bool `yaml:"screenshots" json:"screenshots"`
// WebhookURL for progress notifications.
WebhookURL string `yaml:"webhookUrl,omitempty" json:"webhookUrl,omitempty"`
}
OutputConfig contains output settings.
type ProjectConfig ¶ added in v0.4.0
type ProjectConfig struct {
Match string `yaml:"match" json:"match"` // Glob pattern for repo path
Language string `yaml:"language" json:"language"` // react, vue, svelte, go-templates
Framework string `yaml:"framework" json:"framework"` // next, nuxt, sveltekit
DesignSystem string `yaml:"design-system" json:"designSystem"` // Path to design system spec
AutoDetect bool `yaml:"auto-detect" json:"autoDetect"` // Auto-detect language
Components map[string]ComponentFixConfig `yaml:"components" json:"components"`
}
ProjectConfig contains project-specific overrides.
type ProjectContext ¶ added in v0.4.0
type ProjectContext struct {
// RepoPath is the absolute path to the project root
RepoPath string `json:"repoPath"`
// Language is the detected or configured language
Language string `json:"language"` // react, vue, svelte, go-templates, etc.
// Framework is the detected or configured framework
Framework string `json:"framework"` // next, nuxt, sveltekit, etc.
// ComponentLibrary is the detected UI library
ComponentLibrary string `json:"componentLibrary"` // mui, chakra, shadcn, etc.
// DesignSystem is the path to the design system spec
DesignSystem string `json:"designSystem,omitempty"`
// ProjectConfig is the matched project configuration
ProjectConfig *ProjectConfig `json:"projectConfig,omitempty"`
// LanguageConfig is the language-specific configuration
LanguageConfig *LanguageConfig `json:"languageConfig,omitempty"`
// LibraryConfig is the component library configuration
LibraryConfig *ComponentLibrary `json:"libraryConfig,omitempty"`
}
ProjectContext contains resolved project information.
func DetectProject ¶ added in v0.4.0
func DetectProject(dir string) (*ProjectContext, error)
DetectProject detects project context from a directory path.
func ResolveProject ¶ added in v0.4.0
func ResolveProject(dir string, fixesConfig *FixesConfig) (*ProjectContext, error)
ResolveProject resolves full project context including config.
type ResolvedFix ¶ added in v0.4.0
type ResolvedFix struct {
// Source indicates where this fix came from
Source string `json:"source"` // "project", "library", "language", "builtin"
// Component is the component name (for project/library fixes)
Component string `json:"component,omitempty"`
// Import is the import statement needed
Import string `json:"import,omitempty"`
// Rule is the accessibility rule this fixes
Rule string `json:"rule"`
// Pattern is the fix pattern/example
Pattern string `json:"pattern"`
// Priority for ordering (higher = more preferred)
Priority int `json:"priority,omitempty"`
}
ResolvedFix is a fix pattern with source information.
func MergeWithBuiltin ¶ added in v0.4.0
func MergeWithBuiltin(resolved []ResolvedFix, builtin []types.FixPattern) []ResolvedFix
MergeWithBuiltin merges resolved fixes with builtin fix patterns.
type Viewport ¶
type Viewport struct {
Width int `yaml:"width" json:"width"`
Height int `yaml:"height" json:"height"`
}
Viewport represents browser viewport dimensions.
type WCAGConfig ¶
type WCAGConfig struct {
// Level is the conformance level: A, AA, AAA.
Level string `yaml:"level" json:"level"`
// Version is the WCAG version: 2.0, 2.1, 2.2.
Version string `yaml:"version" json:"version"`
// Categories to test (empty = all).
Categories []string `yaml:"categories,omitempty" json:"categories,omitempty"`
// Rules to skip.
SkipRules []string `yaml:"skipRules,omitempty" json:"skipRules,omitempty"`
// Rules to include (empty = all applicable).
IncludeRules []string `yaml:"includeRules,omitempty" json:"includeRules,omitempty"`
}
WCAGConfig contains WCAG testing settings.