@diegovelasquezweb/a11y-engine 0.11.34 → 0.11.36

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.34",
3
+ "version": "0.11.36",
4
4
  "description": "WCAG 2.2 accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -151,6 +151,21 @@ function getPatternCandidateFile(projectDir, finding) {
151
151
  }
152
152
 
153
153
  function buildPatternAiInput({ finding, candidate }) {
154
+ // Extract the exact line(s) containing the pattern match so Claude has an
155
+ // unambiguous search anchor instead of inferring it from the full file.
156
+ const fileLines = candidate.content.split("\n");
157
+ const lineNumber = typeof finding.line === "number" ? finding.line : null;
158
+ const matchLine = lineNumber !== null && lineNumber >= 1 && lineNumber <= fileLines.length
159
+ ? fileLines[lineNumber - 1]
160
+ : "";
161
+
162
+ // Widen context: include ±4 lines around the match line for multi-line elements.
163
+ const contextStart = lineNumber !== null ? Math.max(0, lineNumber - 5) : 0;
164
+ const contextEnd = lineNumber !== null ? Math.min(fileLines.length, lineNumber + 4) : 0;
165
+ const surroundingLines = contextStart < contextEnd
166
+ ? fileLines.slice(contextStart, contextEnd).join("\n")
167
+ : (finding.context || "");
168
+
154
169
  return {
155
170
  finding: {
156
171
  id: finding.id,
@@ -158,10 +173,12 @@ function buildPatternAiInput({ finding, candidate }) {
158
173
  severity: finding.severity,
159
174
  patternId: finding.pattern_id || finding.patternId || "",
160
175
  file: finding.file,
161
- line: finding.line ?? null,
176
+ line: lineNumber,
162
177
  match: finding.match || "",
163
- context: finding.context || "",
178
+ matchLine,
179
+ surroundingLines,
164
180
  fixDescription: finding.fix_description || "",
181
+ fixCode: finding.fix_code || "",
165
182
  },
166
183
  files: [{ filePath: candidate.rel, content: candidate.content.slice(0, 12000) }],
167
184
  };
@@ -379,6 +396,7 @@ async function callClaudeForPatch({ apiKey, model, aiInput }) {
379
396
  "CRITICAL — search accuracy: the 'search' value must be a verbatim copy of a substring from the file content. Do not paraphrase, reformat, or reconstruct it — copy it character-for-character.",
380
397
  "For insertions (new element not yet in the file), anchor the search on the nearest existing surrounding element and include it in both search and replace.",
381
398
  "Do not create new files. Only write changes for filePaths listed in the files array.",
399
+ "CSS files are never in the files array. Fix visual issues (touch targets, sizing) using inline style attributes or markup changes in the HTML file — never reference or create .css files.",
382
400
  "Schema:",
383
401
  "{\"changes\":[{\"filePath\":\"...\",\"search\":\"...\",\"replace\":\"...\"}],\"verifyRule\":\"...\",\"verifyRoute\":\"...\",\"notes\":\"...\"}",
384
402
  ].join("\n");