@diegovelasquezweb/a11y-engine 0.11.43 → 0.11.45

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.43",
3
+ "version": "0.11.45",
4
4
  "description": "WCAG 2.2 accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -165,6 +165,10 @@ function buildPatternAiInput({ finding, candidate, projectHints }) {
165
165
  ? finding.context.split("\n").map((l) => l.trim()).filter(Boolean)
166
166
  : [];
167
167
  const matchPrefix = rawMatch.slice(0, 30);
168
+
169
+ // Declare effectiveLineIndex first so it can be used when computing currentAtOriginal.
170
+ let effectiveLineIndex = originalLine !== null ? originalLine - 1 : -1;
171
+
168
172
  // The current content at the original line position — use this to pin the anchor
169
173
  // to THIS specific element rather than a sibling with a similar match prefix.
170
174
  const currentAtOriginal = effectiveLineIndex >= 0
@@ -186,7 +190,6 @@ function buildPatternAiInput({ finding, candidate, projectHints }) {
186
190
  // The file may have been modified by a previous sequential fix (lines shifted).
187
191
  // Search for the actual current line containing the anchor instead of
188
192
  // relying solely on the original line number from the scan.
189
- let effectiveLineIndex = originalLine !== null ? originalLine - 1 : -1;
190
193
  if (anchor && effectiveLineIndex >= 0) {
191
194
  const lineAtOriginal = (fileLines[effectiveLineIndex] || "").trim();
192
195
  if (!lineAtOriginal.includes(anchor)) {
@@ -668,6 +671,39 @@ export async function applyFindingFix(input) {
668
671
 
669
672
  const validation = validateAiPatchOutput(patchOutput, projectDir, candidateSet);
670
673
  if (!validation.ok) {
674
+ // When Claude returns no changes, it may be because a prior fix (e.g. the DOM
675
+ // batch) already resolved this issue. Verify by checking if the pattern's
676
+ // context_reject_regex now matches the surroundingLines of the target element.
677
+ // If it does, the element is already accessible — count as resolved.
678
+ if (validation.reason === "AI patch output has no changes") {
679
+ const patternId = finding.pattern_id || finding.patternId || "";
680
+ const patternDef = (ASSETS.remediation.codePatterns?.patterns || [])
681
+ .find((p) => p.id === patternId);
682
+ const rejectRegex = patternDef?.context_reject_regex;
683
+ if (rejectRegex) {
684
+ const context = [aiInput.finding.surroundingLines, aiInput.finding.matchLine]
685
+ .filter(Boolean)
686
+ .join("\n");
687
+ try {
688
+ if (new RegExp(rejectRegex, "i").test(context)) {
689
+ return buildResult({
690
+ applied: true,
691
+ reason: "",
692
+ message: "Already resolved by a prior fix.",
693
+ changedFiles: [],
694
+ patch: "",
695
+ verifyRule: "",
696
+ verifyRoute: "/",
697
+ findingTitle: finding.title || "",
698
+ branchSlug: slugify(`${findingId}-${patternId}`),
699
+ usage: claudeUsage,
700
+ });
701
+ }
702
+ } catch {
703
+ // Invalid regex in pattern definition — fall through to the error return
704
+ }
705
+ }
706
+ }
671
707
  return buildResult({
672
708
  applied: false,
673
709
  reason: FIX_ERROR_CODES.PATCH_GENERATION_FAILED,