@diegovelasquezweb/a11y-engine 0.11.34 → 0.11.35
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
|
@@ -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:
|
|
176
|
+
line: lineNumber,
|
|
162
177
|
match: finding.match || "",
|
|
163
|
-
|
|
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
|
};
|
|
@@ -377,6 +394,7 @@ async function callClaudeForPatch({ apiKey, model, aiInput }) {
|
|
|
377
394
|
"Generate text-replacement changes in the provided source files.",
|
|
378
395
|
"CRITICAL — filePath rules: use the EXACT filePath string from the files array. Never derive filePath from area, url, selector, or any other field. Never add or remove leading slashes or file extensions.",
|
|
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.",
|
|
397
|
+
"For PAT findings: finding.matchLine contains the EXACT content of the line to fix — use it as your primary search anchor. finding.surroundingLines gives the wider context if you need a multi-line anchor.",
|
|
380
398
|
"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
399
|
"Do not create new files. Only write changes for filePaths listed in the files array.",
|
|
382
400
|
"Schema:",
|