@diegovelasquezweb/a11y-engine 0.11.18 → 0.11.19
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
|
@@ -53,6 +53,10 @@ function buildResult(data = {}) {
|
|
|
53
53
|
const verifyRoute = data.verifyRoute || "/";
|
|
54
54
|
const findingTitle = data.findingTitle || "";
|
|
55
55
|
const branchSlug = data.branchSlug || "a11y-fix";
|
|
56
|
+
const usage = {
|
|
57
|
+
input_tokens: data.usage?.input_tokens ?? 0,
|
|
58
|
+
output_tokens: data.usage?.output_tokens ?? 0,
|
|
59
|
+
};
|
|
56
60
|
|
|
57
61
|
return {
|
|
58
62
|
applied,
|
|
@@ -64,6 +68,7 @@ function buildResult(data = {}) {
|
|
|
64
68
|
verifyRoute,
|
|
65
69
|
findingTitle,
|
|
66
70
|
branchSlug,
|
|
71
|
+
usage,
|
|
67
72
|
|
|
68
73
|
status: mapStatus(applied, reason),
|
|
69
74
|
patchedFile: changedFiles[0] || "",
|
|
@@ -243,7 +248,11 @@ async function callClaudeForPatch({ apiKey, model, aiInput }) {
|
|
|
243
248
|
const content = data.content?.[0]?.text || "";
|
|
244
249
|
const parsed = parseJsonBlock(content);
|
|
245
250
|
if (!isObject(parsed)) throw new Error("AI patch output is not valid JSON object");
|
|
246
|
-
|
|
251
|
+
const usage = {
|
|
252
|
+
input_tokens: data.usage?.input_tokens ?? 0,
|
|
253
|
+
output_tokens: data.usage?.output_tokens ?? 0,
|
|
254
|
+
};
|
|
255
|
+
return { patch: parsed, usage };
|
|
247
256
|
}
|
|
248
257
|
|
|
249
258
|
function validateAiPatchOutput(output, projectDir, fileSet) {
|
|
@@ -376,9 +385,12 @@ export async function applyFindingFix(input) {
|
|
|
376
385
|
const model = input.ai?.model || DEFAULT_MODEL;
|
|
377
386
|
|
|
378
387
|
let patchOutput = null;
|
|
388
|
+
let claudeUsage = { input_tokens: 0, output_tokens: 0 };
|
|
379
389
|
if (apiKey) {
|
|
380
390
|
try {
|
|
381
|
-
|
|
391
|
+
const { patch, usage } = await callClaudeForPatch({ apiKey, model, aiInput });
|
|
392
|
+
patchOutput = patch;
|
|
393
|
+
claudeUsage = usage;
|
|
382
394
|
} catch {
|
|
383
395
|
patchOutput = null;
|
|
384
396
|
}
|
|
@@ -393,6 +405,7 @@ export async function applyFindingFix(input) {
|
|
|
393
405
|
verifyRoute: execution.verify.route,
|
|
394
406
|
findingTitle: finding.title || "",
|
|
395
407
|
branchSlug: slugify(`${findingId}-${ruleId}`),
|
|
408
|
+
usage: claudeUsage,
|
|
396
409
|
});
|
|
397
410
|
}
|
|
398
411
|
|
|
@@ -406,6 +419,7 @@ export async function applyFindingFix(input) {
|
|
|
406
419
|
verifyRoute: execution.verify.route,
|
|
407
420
|
findingTitle: finding.title || "",
|
|
408
421
|
branchSlug: slugify(`${findingId}-${ruleId}`),
|
|
422
|
+
usage: claudeUsage,
|
|
409
423
|
});
|
|
410
424
|
}
|
|
411
425
|
|
|
@@ -419,6 +433,7 @@ export async function applyFindingFix(input) {
|
|
|
419
433
|
verifyRoute: execution.verify.route,
|
|
420
434
|
findingTitle: finding.title || "",
|
|
421
435
|
branchSlug: slugify(`${findingId}-${ruleId}`),
|
|
436
|
+
usage: claudeUsage,
|
|
422
437
|
});
|
|
423
438
|
}
|
|
424
439
|
|
|
@@ -432,5 +447,6 @@ export async function applyFindingFix(input) {
|
|
|
432
447
|
verifyRoute: patchOutput.verifyRoute || execution.verify.route,
|
|
433
448
|
findingTitle: finding.title || "",
|
|
434
449
|
branchSlug: slugify(`${findingId}-${ruleId}`),
|
|
450
|
+
usage: claudeUsage,
|
|
435
451
|
});
|
|
436
452
|
}
|