@diegovelasquezweb/a11y-engine 0.11.17 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegovelasquezweb/a11y-engine",
3
- "version": "0.11.17",
3
+ "version": "0.11.19",
4
4
  "description": "WCAG 2.2 accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli/audit.mjs CHANGED
@@ -221,21 +221,20 @@ async function main() {
221
221
  try {
222
222
  log.info("Starting accessibility audit pipeline...");
223
223
 
224
- const nodeModulesPath = path.join(SKILL_ROOT, "node_modules");
225
- if (!fs.existsSync(nodeModulesPath)) {
226
- log.info(
227
- "First run detected — installing skill dependencies (one-time setup)...",
228
- );
229
- try {
230
- execSync("pnpm install", { cwd: SKILL_ROOT, stdio: "ignore" });
231
- } catch {
232
- execSync("npm install", { cwd: SKILL_ROOT, stdio: "ignore" });
224
+ if (!SKILL_ROOT.includes(`${path.sep}node_modules${path.sep}`)) {
225
+ const nodeModulesPath = path.join(SKILL_ROOT, "node_modules");
226
+ if (!fs.existsSync(nodeModulesPath)) {
227
+ log.info("First run detected — installing skill dependencies (one-time setup)...");
228
+ try {
229
+ execSync("pnpm install", { cwd: SKILL_ROOT, stdio: "ignore" });
230
+ } catch {
231
+ execSync("npm install", { cwd: SKILL_ROOT, stdio: "ignore" });
232
+ }
233
+ log.success("Dependencies ready.");
233
234
  }
234
- log.success("Dependencies ready.");
235
+ await runScript("../core/toolchain.mjs");
235
236
  }
236
237
 
237
- await runScript("../core/toolchain.mjs");
238
-
239
238
  const screenshotsDir = getInternalPath("screenshots");
240
239
  fs.rmSync(screenshotsDir, { recursive: true, force: true });
241
240
 
@@ -37,9 +37,7 @@ function parseArgs(argv) {
37
37
  */
38
38
  function checkNodeModules() {
39
39
  const nodeModulesPath = path.join(SKILL_ROOT, "node_modules");
40
- if (fs.existsSync(nodeModulesPath)) return true;
41
- // When installed as an npm package, deps are hoisted — check passes.
42
- return SKILL_ROOT.includes(`${path.sep}node_modules${path.sep}`);
40
+ return fs.existsSync(nodeModulesPath);
43
41
  }
44
42
 
45
43
  /**
@@ -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
- return parsed;
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
- patchOutput = await callClaudeForPatch({ apiKey, model, aiInput });
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
  }