@atlaskit/ads-mcp 0.2.4 → 0.3.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 (48) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +57 -1
  3. package/dist/cjs/index.js +9 -2
  4. package/dist/cjs/instructions.js +1 -1
  5. package/dist/cjs/tools/analyze-accessibility/index.js +483 -0
  6. package/dist/cjs/tools/get-accessibility-guidelines/index.js +204 -0
  7. package/dist/cjs/tools/suggest-accessibility-fixes/fixes.js +387 -0
  8. package/dist/cjs/tools/suggest-accessibility-fixes/index.js +185 -0
  9. package/dist/cjs/tools/suggest-accessibility-fixes/keywords.js +34 -0
  10. package/dist/es2019/index.js +9 -2
  11. package/dist/es2019/instructions.js +8 -1
  12. package/dist/es2019/tools/analyze-accessibility/index.js +457 -0
  13. package/dist/es2019/tools/get-accessibility-guidelines/index.js +312 -0
  14. package/dist/es2019/tools/suggest-accessibility-fixes/fixes.js +705 -0
  15. package/dist/es2019/tools/suggest-accessibility-fixes/index.js +143 -0
  16. package/dist/es2019/tools/suggest-accessibility-fixes/keywords.js +28 -0
  17. package/dist/esm/index.js +9 -2
  18. package/dist/esm/instructions.js +1 -1
  19. package/dist/esm/tools/analyze-accessibility/index.js +476 -0
  20. package/dist/esm/tools/get-accessibility-guidelines/index.js +197 -0
  21. package/dist/esm/tools/suggest-accessibility-fixes/fixes.js +381 -0
  22. package/dist/esm/tools/suggest-accessibility-fixes/index.js +178 -0
  23. package/dist/esm/tools/suggest-accessibility-fixes/keywords.js +28 -0
  24. package/dist/types/instructions.d.ts +1 -1
  25. package/dist/types/tools/analyze-accessibility/index.d.ts +56 -0
  26. package/dist/types/tools/get-accessibility-guidelines/index.d.ts +26 -0
  27. package/dist/types/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
  28. package/dist/types/tools/suggest-accessibility-fixes/index.d.ts +28 -0
  29. package/dist/types/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
  30. package/dist/types-ts4.5/instructions.d.ts +1 -1
  31. package/dist/types-ts4.5/tools/analyze-accessibility/index.d.ts +56 -0
  32. package/dist/types-ts4.5/tools/get-accessibility-guidelines/index.d.ts +26 -0
  33. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
  34. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/index.d.ts +28 -0
  35. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
  36. package/package.json +9 -3
  37. package/build/tsconfig.json +0 -22
  38. package/src/index.tsx +0 -70
  39. package/src/instructions.tsx +0 -5
  40. package/src/schema.tsx +0 -19
  41. package/src/tools/get-component-details/index.tsx +0 -64
  42. package/src/tools/get-components/components.tsx +0 -3579
  43. package/src/tools/get-components/index.tsx +0 -36
  44. package/src/tools/get-icons/index.tsx +0 -49
  45. package/src/tools/get-tokens/index.tsx +0 -43
  46. package/tsconfig.app.json +0 -41
  47. package/tsconfig.dev.json +0 -43
  48. package/tsconfig.json +0 -20
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/ads-mcp
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e4500e5351ce1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e4500e5351ce1) -
8
+ Added tooling to scan and fix a11y violations
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 0.2.5
15
+
16
+ ### Patch Changes
17
+
18
+ - [`098cfbb01dc36`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/098cfbb01dc36) -
19
+ Add missing npmignore files to remove unnecessary files from published package
20
+
3
21
  ## 0.2.4
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -5,7 +5,63 @@ Current state: Early Access
5
5
  The official Model Context Protocol (MCP) server for the Atlassian Design System. This server
6
6
  provides tools to access design tokens, icons, and components/primitives programmatically.
7
7
 
8
- This may expand to add accessibility, usage, and other guidance over time.
8
+ **New: Accessibility Analysis & Guidance** The server now includes comprehensive accessibility tools
9
+ to help ensure your interfaces are accessible to all users.
10
+
11
+ ## Available Tools
12
+
13
+ ### Design System Tools
14
+
15
+ - `get_tokens` - Get design tokens for colors, spacing, typography, etc.
16
+ - `get_components` - Get a list of available components
17
+ - `get_component_details` - Get detailed information about a specific component
18
+ - `get_icons` - Get a list of available icons
19
+
20
+ ### Accessibility Tools
21
+
22
+ - `analyze_accessibility` - Analyze React component code for accessibility violations using axe-core
23
+ and provide ADS-specific suggestions
24
+ - `analyze_localhost_accessibility` - Analyze whole web pages or specific elements (localhost or
25
+ deployed URLs) for accessibility violations
26
+ - `get_accessibility_guidelines` - Get specific accessibility guidelines and best practices for
27
+ different topics
28
+ - `suggest_accessibility_fixes` - Get specific fix suggestions for accessibility violations with
29
+ code examples
30
+
31
+ ## Accessibility Features
32
+
33
+ The ADS MCP server includes comprehensive accessibility analysis and guidance:
34
+
35
+ - **Axe-Core Analysis**: Industry-standard accessibility testing using axe-core
36
+ - **JSX to HTML Conversion**: Accurate analysis by converting React JSX to HTML
37
+ - **ADS-Specific Fixes**: Get suggestions that use Atlassian Design System components and patterns
38
+ - **WCAG 2.1 AA Compliance**: Test against WCAG 2.1 AA standards
39
+ - **Guidelines**: Access detailed accessibility guidelines for buttons, forms, images, colors, focus
40
+ management, and more
41
+ - **Best Practices**: Learn ADS-specific accessibility best practices and patterns
42
+ - **Fallback Analysis**: Pattern-based analysis if axe-core analysis fails
43
+
44
+ ### Example Usage
45
+
46
+ ```typescript
47
+ // Analyze a component for accessibility issues using axe-core
48
+ const analysis = await analyze_accessibility({
49
+ code: `<button onClick={handleClose}><CloseIcon /></button>`,
50
+ componentName: 'CloseButton',
51
+ includePatternAnalysis: true, // Also include pattern-based analysis
52
+ });
53
+
54
+ // Get specific accessibility guidelines
55
+ const guidelines = await get_accessibility_guidelines({
56
+ topic: 'buttons',
57
+ });
58
+
59
+ // Get fix suggestions for a violation
60
+ const fixes = await suggest_accessibility_fixes({
61
+ violation: 'Button missing accessible label',
62
+ code: `<button onClick={handleClose}><CloseIcon /></button>`,
63
+ });
64
+ ```
9
65
 
10
66
  ## Usage
11
67
 
package/dist/cjs/index.js CHANGED
@@ -7,10 +7,13 @@ var _index = require("@modelcontextprotocol/sdk/server/index.js");
7
7
  var _stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
8
8
  var _types = require("@modelcontextprotocol/sdk/types.js");
9
9
  var _instructions = require("./instructions");
10
+ var _analyzeAccessibility = require("./tools/analyze-accessibility");
11
+ var _getAccessibilityGuidelines = require("./tools/get-accessibility-guidelines");
10
12
  var _getComponentDetails = require("./tools/get-component-details");
11
13
  var _getComponents = require("./tools/get-components");
12
14
  var _getIcons = require("./tools/get-icons");
13
15
  var _getTokens = require("./tools/get-tokens");
16
+ var _suggestAccessibilityFixes = require("./tools/suggest-accessibility-fixes");
14
17
  /* eslint-disable import/extensions */
15
18
 
16
19
  // eslint-disable-next-line import/no-extraneous-dependencies -- this uses require because not all node versions this package supports use the same import assertions/attributes
@@ -30,7 +33,7 @@ server.setRequestHandler(_types.ListToolsRequestSchema, /*#__PURE__*/(0, _asyncT
30
33
  while (1) switch (_context.prev = _context.next) {
31
34
  case 0:
32
35
  return _context.abrupt("return", {
33
- tools: [_getTokens.listGetTokensTool, _getComponents.listGetComponentsTool, _getComponentDetails.listGetComponentDetailsTool, _getIcons.listGetIconsTool]
36
+ tools: [_getTokens.listGetTokensTool, _getComponents.listGetComponentsTool, _getComponentDetails.listGetComponentDetailsTool, _getIcons.listGetIconsTool, _analyzeAccessibility.listAnalyzeAccessibilityTool, _analyzeAccessibility.listAnalyzeLocalhostAccessibilityTool, _getAccessibilityGuidelines.listGetAccessibilityGuidelinesTool, _suggestAccessibilityFixes.listSuggestAccessibilityFixesTool]
34
37
  });
35
38
  case 1:
36
39
  case "end":
@@ -42,7 +45,11 @@ var callTools = {
42
45
  get_tokens: _getTokens.getTokensTool,
43
46
  get_components: _getComponents.getComponentsTool,
44
47
  get_component_details: _getComponentDetails.getComponentDetailsTool,
45
- get_icons: _getIcons.getIconsTool
48
+ get_icons: _getIcons.getIconsTool,
49
+ analyze_accessibility: _analyzeAccessibility.analyzeAccessibilityTool,
50
+ analyze_localhost_accessibility: _analyzeAccessibility.analyzeLocalhostAccessibilityTool,
51
+ get_accessibility_guidelines: _getAccessibilityGuidelines.getAccessibilityGuidelinesTool,
52
+ suggest_accessibility_fixes: _suggestAccessibilityFixes.suggestAccessibilityFixesTool
46
53
  };
47
54
 
48
55
  // Handle tool execution
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.instructions = void 0;
7
- var instructions = exports.instructions = "\nYou are an expert in the Atlassian Design System (aka ADS). You are able to answer questions about the design system and provide guidance on what offerings to use when building user interfaces.\n\nYou are able to use the provided tools to help answer your questions, but may also access https://atlassian.design/llms.txt or https://atlassian.design/ directly for deeper research and information.\n";
7
+ var instructions = exports.instructions = "\nYou are an expert in the Atlassian Design System (aka ADS). You are able to answer questions about the design system and provide guidance on what offerings to use when building user interfaces.\n\nYou have special expertise in accessibility and can help ensure that interfaces built with ADS components are accessible to all users. You can analyze code for accessibility violations, provide specific fix suggestions, and offer guidance on accessibility best practices.\n\nYou are able to use the provided tools to help answer your questions, but may also access https://atlassian.design/llms.txt, https://atlassian.design/llms-a11y.txt, or https://atlassian.design/ directly for deeper research and information.\n\nAccessibility Tools Available:\n- analyze_accessibility: Analyze React component code for accessibility violations\n- get_accessibility_guidelines: Get specific accessibility guidelines and best practices\n- suggest_accessibility_fixes: Get specific fix suggestions for accessibility violations\n";
@@ -0,0 +1,483 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.listAnalyzeLocalhostAccessibilityTool = exports.listAnalyzeAccessibilityTool = exports.analyzeLocalhostAccessibilityTool = exports.analyzeAccessibilityTool = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _puppeteer = require("@axe-core/puppeteer");
13
+ var _axeCore = _interopRequireDefault(require("axe-core"));
14
+ var _puppeteer2 = _interopRequireDefault(require("puppeteer"));
15
+ var _zod = require("zod");
16
+ var _zodToJsonSchema = require("zod-to-json-schema");
17
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ var inputSchema = _zod.z.object({
20
+ code: _zod.z.string().describe('React component code to analyze for accessibility'),
21
+ componentName: _zod.z.string().optional().describe('Name of the component being analyzed'),
22
+ context: _zod.z.string().optional().describe('Additional context about the component usage'),
23
+ includePatternAnalysis: _zod.z.boolean().optional().default(true).describe('Include pattern-based analysis in addition to axe-core')
24
+ });
25
+ var listAnalyzeAccessibilityTool = exports.listAnalyzeAccessibilityTool = {
26
+ name: 'analyze_accessibility',
27
+ description: "Analyze React component code for accessibility violations using axe-core and intelligently generate Atlassian Design System specific suggestions. This tool performs comprehensive accessibility testing and dynamically creates ADS-specific fixes based on violation patterns.\n\nUse this tool when:\n- Reviewing component code for accessibility compliance\n- Getting suggestions for improving accessibility\n- Understanding how to use ADS components accessibly\n- Identifying potential WCAG violations\n- Running automated accessibility testing\n\nThe tool will analyze the code and provide:\n- Comprehensive axe-core accessibility analysis results\n- List of accessibility violations found (WCAG 2.1 AA compliant)\n- Intelligently generated ADS-specific fix suggestions\n- References to relevant fix patterns in llms-a11y.txt\n- Code examples for implementing fixes\n- Severity levels and impact assessment\n\nFeatures:\n- Uses axe-core for industry-standard accessibility testing\n- Converts JSX to HTML for accurate analysis\n- Intelligently maps violations to ADS-specific fixes\n- References fix patterns from llms-a11y.txt documentation\n- Includes fallback pattern analysis if axe-core fails\n- Provides detailed violation descriptions and help text\n- Dynamically generates fix suggestions based on violation type",
28
+ annotations: {
29
+ title: 'Analyze Accessibility',
30
+ readOnlyHint: true,
31
+ destructiveHint: false,
32
+ idempotentHint: true,
33
+ openWorldHint: true
34
+ },
35
+ inputSchema: (0, _zodToJsonSchema.zodToJsonSchema)(inputSchema)
36
+ };
37
+ var urlInputSchema = _zod.z.object({
38
+ url: _zod.z.string().describe('The URL to analyze for accessibility (e.g. http://localhost:9000)'),
39
+ componentName: _zod.z.string().optional().describe('Name of the component being analyzed'),
40
+ context: _zod.z.string().optional().describe('Additional context about the component usage'),
41
+ selector: _zod.z.string().optional().describe('CSS selector to target a specific element for analysis (e.g. "#my-form", ".component-class")')
42
+ });
43
+ var listAnalyzeLocalhostAccessibilityTool = exports.listAnalyzeLocalhostAccessibilityTool = {
44
+ name: 'analyze_localhost_accessibility',
45
+ description: "Analyze a live web page (e.g. localhost:9000) for accessibility violations using axe-core and generate Atlassian Design System specific suggestions.\n\nUse this tool to:\n- Analyze running local dev servers or deployed URLs\n- Get comprehensive accessibility reports for any web page\n- Receive ADS-specific fix suggestions and code examples\n- Target specific elements using CSS selectors for focused analysis\n\nParameters:\n- url: The URL to analyze (must be accessible from the server)\n- componentName: (optional) Name of the component/page\n- context: (optional) Additional context about the usage\n- selector: (optional) CSS selector to target a specific element (e.g. \"#my-form\", \".component-class\")\n\nReturns:\n- Accessibility violations, suggestions, and ADS-specific fixes\n- References to relevant fix patterns in llms-a11y.txt\n- Code examples for implementing fixes\n- Severity levels and impact assessment\n",
46
+ annotations: {
47
+ title: 'Analyze Localhost Accessibility',
48
+ readOnlyHint: true,
49
+ destructiveHint: false,
50
+ idempotentHint: true,
51
+ openWorldHint: true
52
+ },
53
+ inputSchema: (0, _zodToJsonSchema.zodToJsonSchema)(urlInputSchema)
54
+ };
55
+
56
+ // Common accessibility patterns to detect in code
57
+ var accessibilityPatterns = [{
58
+ pattern: /<button[^>]*>(?!.*aria-label|.*>.*<\/button>)/g,
59
+ violation: 'Button without accessible text',
60
+ severity: 'error',
61
+ suggestion: 'Use the suggest-accessibility-fixes tool for ADS Button solutions. Describe the issue as "button missing label", "empty button", or "button needs text".'
62
+ }, {
63
+ pattern: /<img[^>]*>(?!.*alt=)/g,
64
+ violation: 'Image without alt text',
65
+ severity: 'error',
66
+ suggestion: 'Use the suggest-accessibility-fixes tool for ADS Image solutions. Describe the issue as "image missing alt", "missing alt text", or "image accessibility".'
67
+ }, {
68
+ pattern: /<div[^>]*onClick[^>]*>/g,
69
+ violation: 'Clickable div without accessibility',
70
+ severity: 'warning',
71
+ suggestion: 'Use the suggest-accessibility-fixes tool for ADS solutions. Describe the issue as "clickable div", "interactive div", or "div with click handler".'
72
+ }, {
73
+ pattern: /color:\s*['"]#[0-9a-fA-F]{3,6}['"]/g,
74
+ violation: 'Hardcoded color values',
75
+ severity: 'warning',
76
+ suggestion: 'Use the suggest-accessibility-fixes tool for design token solutions. Describe the issue as "hardcoded colors", "hex colors", or "design tokens".'
77
+ }, {
78
+ pattern: /<input[^>]*>(?!.*id=)/g,
79
+ violation: 'Input without associated label',
80
+ severity: 'error',
81
+ suggestion: 'Use the suggest-accessibility-fixes tool for ADS form solutions. Describe the issue as "input missing label", "form field without label", or "unlabeled input".'
82
+ }, {
83
+ pattern: /<div[^>]*role="button"[^>]*>/g,
84
+ violation: 'Custom button without full accessibility',
85
+ severity: 'warning',
86
+ suggestion: 'Use the suggest-accessibility-fixes tool for ADS Button/Focusable solutions. Describe the issue as "custom button", "div with button role", or "interactive element".'
87
+ }, {
88
+ pattern: /style=\{[^}]*color[^}]*\}/g,
89
+ violation: 'Inline color styles',
90
+ severity: 'warning',
91
+ suggestion: 'Use the suggest-accessibility-fixes tool for design token solutions. Describe the issue as "inline styles", "hardcoded colors", or "color tokens".'
92
+ }];
93
+
94
+ // ADS accessibility guidelines reference
95
+ var adsGuidelines = {
96
+ buttons: {
97
+ title: 'Button Accessibility',
98
+ guidelines: ['Always provide accessible labels for buttons', 'Use Button component for standard interactions', 'Use Focusable component for custom interactive elements', 'Avoid disabled buttons with tooltips', 'Ensure focus indicators are visible']
99
+ },
100
+ forms: {
101
+ title: 'Form Accessibility',
102
+ guidelines: ['Use TextField component for consistent labeling', 'Associate labels with inputs using id and htmlFor', 'Provide clear error messages with aria-describedby', 'Use MessageWrapper for form validation announcements']
103
+ },
104
+ images: {
105
+ title: 'Image Accessibility',
106
+ guidelines: ['Use Image component with proper alt text', 'Keep alt text under 125 characters', 'Leave alt="" for decorative images', 'Describe the purpose, not just the content']
107
+ },
108
+ colors: {
109
+ title: 'Color and Contrast',
110
+ guidelines: ['Use design tokens for consistent contrast ratios', 'Never rely on color alone for information', 'Use color.text tokens for proper contrast', 'Test with high contrast mode']
111
+ }
112
+ };
113
+
114
+ // Helper function to map axe-core violations to ADS-specific fixes
115
+ function mapAxeViolationsToADSFixes(violations) {
116
+ return violations.map(function (violation) {
117
+ var adsFix = generateADSFixForViolation(violation);
118
+ return _objectSpread(_objectSpread({}, violation), {}, {
119
+ type: adsFix.title,
120
+ // Use the specific fix key that matches fixes.ts
121
+ adsFix: adsFix,
122
+ severity: violation.impact === 'critical' || violation.impact === 'serious' ? 'error' : 'warning'
123
+ });
124
+ });
125
+ }
126
+
127
+ // Helper function to provide ADS-specific guidance for axe-core violations
128
+ function generateADSFixForViolation(violation) {
129
+ var id = violation.id,
130
+ description = violation.description,
131
+ help = violation.help,
132
+ tags = violation.tags;
133
+
134
+ // Provide general guidance without trying to map to specific fixes.ts keys
135
+ var adsFix = "Use the suggest-accessibility-fixes tool to get specific ADS component solutions. Describe the issue using the violation details: \"".concat(help, "\" or in your own words (e.g., \"button has no text\", \"missing alt text\", \"form field needs label\").");
136
+ return {
137
+ title: help,
138
+ // Use axe-core's human-readable description
139
+ description: description,
140
+ adsFix: adsFix,
141
+ example: 'The suggest-accessibility-fixes tool provides detailed code examples and ADS component solutions',
142
+ violationId: id,
143
+ axeHelp: help,
144
+ tags: tags,
145
+ wcagTags: tags.filter(function (tag) {
146
+ return tag.startsWith('wcag');
147
+ }),
148
+ // Extract WCAG compliance info
149
+ reference: "https://atlassian.design/llms-a11y.txt",
150
+ recommendations: ['Use ADS components for better accessibility out of the box', 'Reference the suggest-accessibility-fixes tool for specific solutions', 'Test with keyboard navigation and screen readers', 'Use automated accessibility testing tools']
151
+ };
152
+ }
153
+ var analyzeAccessibilityTool = exports.analyzeAccessibilityTool = /*#__PURE__*/function () {
154
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params) {
155
+ var code, componentName, context, _params$includePatter, includePatternAnalysis, violations, suggestions, axeResults, _axeResults$violation, _axeResults$passes, _axeResults$incomplet, results, adsViolations, relevantGuidelines, summary;
156
+ return _regenerator.default.wrap(function _callee$(_context) {
157
+ while (1) switch (_context.prev = _context.next) {
158
+ case 0:
159
+ code = params.code, componentName = params.componentName, context = params.context, _params$includePatter = params.includePatternAnalysis, includePatternAnalysis = _params$includePatter === void 0 ? true : _params$includePatter;
160
+ violations = [];
161
+ suggestions = [];
162
+ axeResults = {};
163
+ _context.prev = 4;
164
+ _context.next = 7;
165
+ return _axeCore.default.run({
166
+ fromFrames: ['iframe', 'html']
167
+ });
168
+ case 7:
169
+ results = _context.sent;
170
+ // Process axe-core results
171
+ if (results.violations && results.violations.length > 0) {
172
+ adsViolations = mapAxeViolationsToADSFixes(results.violations);
173
+ violations.push.apply(violations, (0, _toConsumableArray2.default)(adsViolations));
174
+ axeResults.violations = results.violations;
175
+ axeResults.passes = results.passes;
176
+ axeResults.incomplete = results.incomplete;
177
+ }
178
+
179
+ // Include pattern-based analysis if requested
180
+ if (includePatternAnalysis) {
181
+ accessibilityPatterns.forEach(function (pattern) {
182
+ var matches = code.match(pattern.pattern);
183
+ if (matches) {
184
+ violations.push({
185
+ type: pattern.violation,
186
+ severity: pattern.severity,
187
+ count: matches.length,
188
+ suggestion: pattern.suggestion,
189
+ adsFix: 'Use the suggest-accessibility-fixes tool for specific ADS component solutions',
190
+ example: 'The suggest-accessibility-fixes tool provides detailed code examples',
191
+ source: 'pattern-analysis'
192
+ });
193
+ }
194
+ });
195
+ }
196
+
197
+ // Generate ADS-specific suggestions
198
+ if (violations.length > 0) {
199
+ suggestions.push({
200
+ title: 'Accessibility Improvements Needed',
201
+ description: "Found ".concat(violations.length, " accessibility issues in your code."),
202
+ violations: violations,
203
+ nextSteps: ['Review each violation and apply the suggested fixes', 'Use ADS components instead of custom implementations', 'Test with screen readers and keyboard navigation', 'Run automated accessibility tests']
204
+ });
205
+ }
206
+
207
+ // Provide relevant ADS guidelines
208
+ relevantGuidelines = [];
209
+ if (code.includes('button') || code.includes('onClick')) {
210
+ relevantGuidelines.push(adsGuidelines.buttons);
211
+ }
212
+ if (code.includes('input') || code.includes('form')) {
213
+ relevantGuidelines.push(adsGuidelines.forms);
214
+ }
215
+ if (code.includes('img') || code.includes('image')) {
216
+ relevantGuidelines.push(adsGuidelines.images);
217
+ }
218
+ if (code.includes('color') || code.includes('style')) {
219
+ relevantGuidelines.push(adsGuidelines.colors);
220
+ }
221
+
222
+ // Generate summary
223
+ summary = {
224
+ componentName: componentName || 'Unknown component',
225
+ totalViolations: violations.length,
226
+ severityBreakdown: {
227
+ error: violations.filter(function (v) {
228
+ return v.severity === 'error';
229
+ }).length,
230
+ warning: violations.filter(function (v) {
231
+ return v.severity === 'warning';
232
+ }).length
233
+ },
234
+ context: context || 'No additional context provided',
235
+ axeResults: {
236
+ violations: ((_axeResults$violation = axeResults.violations) === null || _axeResults$violation === void 0 ? void 0 : _axeResults$violation.length) || 0,
237
+ passes: ((_axeResults$passes = axeResults.passes) === null || _axeResults$passes === void 0 ? void 0 : _axeResults$passes.length) || 0,
238
+ incomplete: ((_axeResults$incomplet = axeResults.incomplete) === null || _axeResults$incomplet === void 0 ? void 0 : _axeResults$incomplet.length) || 0
239
+ }
240
+ };
241
+ return _context.abrupt("return", {
242
+ content: [{
243
+ type: 'text',
244
+ text: JSON.stringify({
245
+ summary: summary,
246
+ violations: violations,
247
+ suggestions: suggestions,
248
+ relevantGuidelines: relevantGuidelines,
249
+ axeResults: axeResults,
250
+ recommendations: ['Use ADS components for better accessibility out of the box', 'Reference https://atlassian.design/llms-a11y.txt for detailed guidelines', 'Test with keyboard navigation and screen readers', 'Use automated accessibility testing tools']
251
+ }, null, 2)
252
+ }]
253
+ });
254
+ case 20:
255
+ _context.prev = 20;
256
+ _context.t0 = _context["catch"](4);
257
+ // Fallback to pattern-based analysis if axe-core fails
258
+ // console.warn('Axe-core analysis failed, falling back to pattern analysis:', error);
259
+
260
+ // Run pattern analysis as fallback
261
+ accessibilityPatterns.forEach(function (pattern) {
262
+ var matches = code.match(pattern.pattern);
263
+ if (matches) {
264
+ violations.push({
265
+ type: pattern.violation,
266
+ severity: pattern.severity,
267
+ count: matches.length,
268
+ suggestion: pattern.suggestion,
269
+ adsFix: 'Use the suggest-accessibility-fixes tool for specific ADS component solutions',
270
+ example: 'The suggest-accessibility-fixes tool provides detailed code examples',
271
+ source: 'pattern-analysis-fallback'
272
+ });
273
+ }
274
+ });
275
+ return _context.abrupt("return", {
276
+ content: [{
277
+ type: 'text',
278
+ text: JSON.stringify({
279
+ summary: {
280
+ componentName: componentName || 'Unknown component',
281
+ totalViolations: violations.length,
282
+ severityBreakdown: {
283
+ error: violations.filter(function (v) {
284
+ return v.severity === 'error';
285
+ }).length,
286
+ warning: violations.filter(function (v) {
287
+ return v.severity === 'warning';
288
+ }).length
289
+ },
290
+ context: context || 'No additional context provided',
291
+ note: 'Analysis completed using pattern matching (axe-core analysis failed)'
292
+ },
293
+ violations: violations,
294
+ suggestions: violations.length > 0 ? [{
295
+ title: 'Accessibility Improvements Needed',
296
+ description: "Found ".concat(violations.length, " accessibility issues in your code."),
297
+ violations: violations,
298
+ nextSteps: ['Review each violation and apply the suggested fixes', 'Use ADS components instead of custom implementations', 'Test with screen readers and keyboard navigation', 'Run automated accessibility tests']
299
+ }] : [],
300
+ error: 'Axe-core analysis failed, used pattern-based analysis as fallback',
301
+ recommendations: ['Use ADS components for better accessibility out of the box', 'Reference https://atlassian.design/llms-a11y.txt for detailed guidelines', 'Test with keyboard navigation and screen readers', 'Use automated accessibility testing tools']
302
+ }, null, 2)
303
+ }]
304
+ });
305
+ case 24:
306
+ case "end":
307
+ return _context.stop();
308
+ }
309
+ }, _callee, null, [[4, 20]]);
310
+ }));
311
+ return function analyzeAccessibilityTool(_x) {
312
+ return _ref.apply(this, arguments);
313
+ };
314
+ }();
315
+ var analyzeLocalhostAccessibilityTool = exports.analyzeLocalhostAccessibilityTool = /*#__PURE__*/function () {
316
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(params) {
317
+ var url, componentName, context, selector, violations, suggestions, axeResults, browser, page, _axeResults$violation2, _axeResults$passes2, _axeResults$incomplet2, elementExists, availableElements, axePuppeteer, results, adsViolations, relevantGuidelines, summary;
318
+ return _regenerator.default.wrap(function _callee2$(_context2) {
319
+ while (1) switch (_context2.prev = _context2.next) {
320
+ case 0:
321
+ url = params.url, componentName = params.componentName, context = params.context, selector = params.selector;
322
+ violations = [];
323
+ suggestions = [];
324
+ axeResults = {};
325
+ _context2.next = 6;
326
+ return _puppeteer2.default.launch();
327
+ case 6:
328
+ browser = _context2.sent;
329
+ _context2.next = 9;
330
+ return browser.newPage();
331
+ case 9:
332
+ page = _context2.sent;
333
+ _context2.prev = 10;
334
+ _context2.next = 13;
335
+ return page.goto(url, {
336
+ waitUntil: 'networkidle0'
337
+ });
338
+ case 13:
339
+ if (!selector) {
340
+ _context2.next = 22;
341
+ break;
342
+ }
343
+ _context2.next = 16;
344
+ return page.$(selector);
345
+ case 16:
346
+ elementExists = _context2.sent;
347
+ if (elementExists) {
348
+ _context2.next = 22;
349
+ break;
350
+ }
351
+ _context2.next = 20;
352
+ return page.evaluate(function () {
353
+ var elements = Array.from(document.querySelectorAll('[id]'));
354
+ return elements.map(function (el) {
355
+ return "#".concat(el.id);
356
+ });
357
+ });
358
+ case 20:
359
+ availableElements = _context2.sent;
360
+ throw new Error("Element with selector \"".concat(selector, "\" not found on the page after waiting. Available elements: ").concat(availableElements.join(', ')));
361
+ case 22:
362
+ // Run axe-core accessibility analysis
363
+ axePuppeteer = new _puppeteer.AxePuppeteer(page); // If selector is provided, analyze only that element
364
+ if (selector) {
365
+ axePuppeteer.include(selector);
366
+ }
367
+ _context2.next = 26;
368
+ return axePuppeteer.analyze();
369
+ case 26:
370
+ results = _context2.sent;
371
+ if (results.violations && results.violations.length > 0) {
372
+ adsViolations = mapAxeViolationsToADSFixes(results.violations);
373
+ violations.push.apply(violations, (0, _toConsumableArray2.default)(adsViolations));
374
+ axeResults.violations = results.violations;
375
+ axeResults.passes = results.passes;
376
+ axeResults.incomplete = results.incomplete;
377
+ }
378
+
379
+ // Generate ADS-specific suggestions
380
+ if (violations.length > 0) {
381
+ suggestions.push({
382
+ title: 'Accessibility Improvements Needed',
383
+ description: "Found ".concat(violations.length, " accessibility issues in your code."),
384
+ violations: violations,
385
+ nextSteps: ['Review each violation and apply the suggested fixes', 'Use ADS components instead of custom implementations', 'Test with screen readers and keyboard navigation', 'Run automated accessibility tests']
386
+ });
387
+ }
388
+
389
+ // Provide relevant ADS guidelines
390
+ relevantGuidelines = [];
391
+ if (url.includes('button') || url.includes('onClick')) {
392
+ relevantGuidelines.push(adsGuidelines.buttons);
393
+ }
394
+ if (url.includes('input') || url.includes('form')) {
395
+ relevantGuidelines.push(adsGuidelines.forms);
396
+ }
397
+ if (url.includes('img') || url.includes('image')) {
398
+ relevantGuidelines.push(adsGuidelines.images);
399
+ }
400
+ if (url.includes('color') || url.includes('style')) {
401
+ relevantGuidelines.push(adsGuidelines.colors);
402
+ }
403
+
404
+ // Generate summary
405
+ summary = {
406
+ url: url,
407
+ selector: selector || 'Entire page analyzed',
408
+ componentName: componentName || 'Unknown component',
409
+ totalViolations: violations.length,
410
+ severityBreakdown: {
411
+ error: violations.filter(function (v) {
412
+ return v.severity === 'error';
413
+ }).length,
414
+ warning: violations.filter(function (v) {
415
+ return v.severity === 'warning';
416
+ }).length
417
+ },
418
+ context: context || 'No additional context provided',
419
+ axeResults: {
420
+ violations: ((_axeResults$violation2 = axeResults.violations) === null || _axeResults$violation2 === void 0 ? void 0 : _axeResults$violation2.length) || 0,
421
+ passes: ((_axeResults$passes2 = axeResults.passes) === null || _axeResults$passes2 === void 0 ? void 0 : _axeResults$passes2.length) || 0,
422
+ incomplete: ((_axeResults$incomplet2 = axeResults.incomplete) === null || _axeResults$incomplet2 === void 0 ? void 0 : _axeResults$incomplet2.length) || 0
423
+ }
424
+ };
425
+ _context2.next = 37;
426
+ return browser.close();
427
+ case 37:
428
+ return _context2.abrupt("return", {
429
+ content: [{
430
+ type: 'text',
431
+ text: JSON.stringify({
432
+ summary: summary,
433
+ violations: violations,
434
+ suggestions: suggestions,
435
+ relevantGuidelines: relevantGuidelines,
436
+ axeResults: axeResults,
437
+ recommendations: ['Use ADS components for better accessibility out of the box', 'Reference https://atlassian.design/llms-a11y.txt for detailed guidelines', 'Test with keyboard navigation and screen readers', 'Use automated accessibility testing tools']
438
+ }, null, 2)
439
+ }]
440
+ });
441
+ case 40:
442
+ _context2.prev = 40;
443
+ _context2.t0 = _context2["catch"](10);
444
+ _context2.next = 44;
445
+ return browser.close();
446
+ case 44:
447
+ return _context2.abrupt("return", {
448
+ content: [{
449
+ type: 'text',
450
+ text: JSON.stringify({
451
+ summary: {
452
+ url: url,
453
+ selector: selector || 'Entire page analyzed',
454
+ componentName: componentName || 'Unknown component',
455
+ totalViolations: violations.length,
456
+ severityBreakdown: {
457
+ error: violations.filter(function (v) {
458
+ return v.severity === 'error';
459
+ }).length,
460
+ warning: violations.filter(function (v) {
461
+ return v.severity === 'warning';
462
+ }).length
463
+ },
464
+ context: context || 'No additional context provided',
465
+ note: 'Analysis failed to run on the provided URL'
466
+ },
467
+ violations: violations,
468
+ suggestions: [],
469
+ error: String(_context2.t0),
470
+ recommendations: ['Use ADS components for better accessibility out of the box', 'Reference https://atlassian.design/llms-a11y.txt for detailed guidelines', 'Test with keyboard navigation and screen readers', 'Use automated accessibility testing tools']
471
+ }, null, 2)
472
+ }]
473
+ });
474
+ case 45:
475
+ case "end":
476
+ return _context2.stop();
477
+ }
478
+ }, _callee2, null, [[10, 40]]);
479
+ }));
480
+ return function analyzeLocalhostAccessibilityTool(_x2) {
481
+ return _ref2.apply(this, arguments);
482
+ };
483
+ }();