@diegovelasquezweb/a11y-engine 0.11.52 → 0.11.54

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegovelasquezweb/a11y-engine",
3
- "version": "0.11.52",
3
+ "version": "0.11.54",
4
4
  "description": "WCAG 2.2 accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,6 +32,9 @@
32
32
  "CHANGELOG.md",
33
33
  "LICENSE"
34
34
  ],
35
+ "scripts": {
36
+ "test": "vitest run"
37
+ },
35
38
  "dependencies": {
36
39
  "@axe-core/playwright": "^4.11.1",
37
40
  "axe-core": "^4.11.1",
@@ -41,7 +44,5 @@
41
44
  "devDependencies": {
42
45
  "vitest": "^4.0.18"
43
46
  },
44
- "scripts": {
45
- "test": "vitest run"
46
- }
47
- }
47
+ "packageManager": "pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c"
48
+ }
File without changes
@@ -150,7 +150,7 @@ function getPatternCandidateFile(projectDir, finding) {
150
150
  return { abs, rel: finding.file, content };
151
151
  }
152
152
 
153
- function buildPatternAiInput({ finding, candidate, projectHints }) {
153
+ function buildPatternAiInput({ finding, candidate, cssFiles = [], projectHints }) {
154
154
  // Extract the exact line(s) containing the pattern match so Claude has an
155
155
  // unambiguous search anchor instead of inferring it from the full file.
156
156
  const fileLines = candidate.content.split("\n");
@@ -224,7 +224,10 @@ function buildPatternAiInput({ finding, candidate, projectHints }) {
224
224
  fixDescription: finding.fix_description || "",
225
225
  fixCode: finding.fix_code || "",
226
226
  },
227
- files: [{ filePath: candidate.rel, content: candidate.content.slice(0, 12000) }],
227
+ files: [
228
+ { filePath: candidate.rel, content: candidate.content.slice(0, 12000) },
229
+ ...cssFiles.map((f) => ({ filePath: f.rel, content: f.content.slice(0, 12000) })),
230
+ ],
228
231
  ...(projectHints ? { projectContext: projectHints } : {}),
229
232
  };
230
233
  }
@@ -465,16 +468,32 @@ function detectStylingSystem(aiInput) {
465
468
  return "inline";
466
469
  }
467
470
 
471
+ export function buildStyleInstruction(stylingSystem) {
472
+ if (stylingSystem === "tailwind") {
473
+ return (
474
+ "This project uses Tailwind CSS. Apply style fixes as Tailwind utility classes in the HTML/JSX file — do not write raw CSS. " +
475
+ "For inline style attributes that suppress focus (e.g. style=\"outline: none\"): remove outline: none from the style attribute and add focus-visible: Tailwind utility classes (e.g. focus-visible:outline-2 focus-visible:outline-offset-2) directly on the element instead."
476
+ );
477
+ }
478
+ if (stylingSystem === "css") {
479
+ return (
480
+ "CSS/SCSS files are available in the files array. Prefer fixing visual issues (touch targets, color contrast) in the CSS/SCSS file using proper selectors. " +
481
+ "For violations in a CSS/SCSS file: add or update the rule there directly. " +
482
+ "For violations in an inline HTML style attribute (e.g. style=\"outline: none\"): make TWO changes — " +
483
+ "(1) remove outline: none / outline: 0 from the HTML style attribute, " +
484
+ "(2) add a :focus-visible rule in the CSS/SCSS file targeting the element."
485
+ );
486
+ }
487
+ return (
488
+ "No CSS file was provided. Remove outline: none or outline: 0 from the style attribute entirely and rely on the browser default focus indicator. " +
489
+ "Do not add new CSS files."
490
+ );
491
+ }
492
+
468
493
  async function callClaudeForPatch({ apiKey, model, aiInput, remediationPath }) {
469
494
  const remediationContext = extractRemediationContext(remediationPath);
470
495
  const stylingSystem = detectStylingSystem(aiInput);
471
-
472
- const styleInstruction =
473
- stylingSystem === "tailwind"
474
- ? "This project uses Tailwind CSS. Apply style fixes as Tailwind utility classes in the HTML/JSX file — do not write raw CSS."
475
- : stylingSystem === "css"
476
- ? "CSS/SCSS files are available in the files array. Prefer fixing visual issues (touch targets, color contrast, focus outlines) in the CSS/SCSS file using proper selectors rather than inline styles."
477
- : "No CSS file was provided. Apply style fixes using inline style attributes in the HTML file.";
496
+ const styleInstruction = buildStyleInstruction(stylingSystem);
478
497
 
479
498
  const system = [
480
499
  "You are an accessibility fix engine.",
@@ -666,8 +685,15 @@ export async function applyFindingFix(input) {
666
685
  });
667
686
  }
668
687
 
669
- const aiInput = buildPatternAiInput({ finding, candidate, projectHints });
670
- const candidateSet = new Set([candidate.rel]);
688
+ const allProjectFiles = listFilesRecursive(projectDir).map((abs) => ({
689
+ abs,
690
+ rel: path.relative(projectDir, abs),
691
+ content: fs.readFileSync(abs, "utf8"),
692
+ }));
693
+ const cssFiles = allProjectFiles.filter((f) => /\.(css|scss|sass)$/.test(f.rel));
694
+
695
+ const aiInput = buildPatternAiInput({ finding, candidate, cssFiles, projectHints });
696
+ const candidateSet = new Set([candidate.rel, ...cssFiles.map((f) => f.rel)]);
671
697
 
672
698
  let patchOutput = null;
673
699
  let claudeUsage = { input_tokens: 0, output_tokens: 0 };
File without changes
File without changes
package/assets/.DS_Store DELETED
Binary file