@aiready/cli 0.14.9 → 0.14.11

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/src/index.ts CHANGED
@@ -57,6 +57,12 @@ export interface UnifiedAnalysisOptions extends ScanOptions {
57
57
  total?: number;
58
58
  message?: string;
59
59
  }) => void;
60
+ /** Files or directories to include in scan */
61
+ include?: string[];
62
+ /** Files or directories to exclude from scan */
63
+ exclude?: string[];
64
+ /** Batch size for comparisons */
65
+ batchSize?: number;
60
66
  }
61
67
 
62
68
  /**
@@ -161,7 +167,7 @@ export async function analyzeUnified(
161
167
  await initializeParsers();
162
168
 
163
169
  const startTime = Date.now();
164
- const requestedTools = options.tools || [
170
+ const requestedTools = options.tools ?? [
165
171
  'patterns',
166
172
  'context',
167
173
  'consistency',
@@ -186,7 +192,7 @@ export async function analyzeUnified(
186
192
  // Dynamic Loading: If provider not found, attempt to import the package
187
193
  if (!provider) {
188
194
  const packageName =
189
- TOOL_PACKAGE_MAP[toolName] ||
195
+ TOOL_PACKAGE_MAP[toolName] ??
190
196
  (toolName.startsWith('@aiready/') ? toolName : `@aiready/${toolName}`);
191
197
  try {
192
198
  await import(packageName);
@@ -301,34 +307,16 @@ export async function analyzeUnified(
301
307
 
302
308
  // Track total files analyzed across all tools
303
309
  const toolFiles =
304
- output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
310
+ output.summary?.totalFiles ?? output.summary?.filesAnalyzed ?? 0;
305
311
  if (toolFiles > result.summary.totalFiles) {
306
312
  result.summary.totalFiles = toolFiles;
307
313
  }
308
314
 
309
315
  const issueCount = output.results.reduce(
310
- (sum: number, file: any) => sum + (file.issues?.length || 0),
316
+ (sum: number, file: any) => sum + (file.issues?.length ?? 0),
311
317
  0
312
318
  );
313
319
  result.summary.totalIssues += issueCount;
314
-
315
- // Robust backward compatibility fallbacks
316
- // 1. Add all aliases as keys (e.g., 'patterns', 'context', 'consistency')
317
- if (provider.alias && Array.isArray(provider.alias)) {
318
- for (const alias of provider.alias) {
319
- if (!result[alias]) {
320
- (result as any)[alias] = output;
321
- }
322
- }
323
- }
324
-
325
- // 2. Add camelCase version of canonical ID (e.g., 'patternDetect', 'contextAnalyzer')
326
- const camelCaseId = provider.id.replace(/-([a-z])/g, (g) =>
327
- g[1].toUpperCase()
328
- );
329
- if (camelCaseId !== provider.id && !result[camelCaseId]) {
330
- (result as any)[camelCaseId] = output;
331
- }
332
320
  } catch (err) {
333
321
  console.error(`❌ Error running tool '${provider.id}':`, err);
334
322
  }
@@ -347,6 +335,28 @@ export async function analyzeUnified(
347
335
  });
348
336
 
349
337
  result.summary.executionTime = Date.now() - startTime;
338
+
339
+ // Add backward compatibility key mappings (kebab-case -> camelCase and aliases)
340
+ const keyMappings: Record<string, string[]> = {
341
+ 'pattern-detect': ['patternDetect', 'patterns'],
342
+ 'context-analyzer': ['contextAnalyzer', 'context'],
343
+ 'naming-consistency': ['namingConsistency', 'consistency'],
344
+ 'ai-signal-clarity': ['aiSignalClarity'],
345
+ 'agent-grounding': ['agentGrounding'],
346
+ 'testability-index': ['testabilityIndex', 'testability'],
347
+ 'doc-drift': ['docDrift'],
348
+ 'dependency-health': ['dependencyHealth', 'deps'],
349
+ 'change-amplification': ['changeAmplification'],
350
+ };
351
+
352
+ for (const [kebabKey, aliases] of Object.entries(keyMappings)) {
353
+ if (result[kebabKey]) {
354
+ for (const alias of aliases) {
355
+ result[alias] = result[kebabKey];
356
+ }
357
+ }
358
+ }
359
+
350
360
  return result;
351
361
  }
352
362
 
@@ -378,7 +388,7 @@ export async function scoreUnified(
378
388
  if (!toolScore.tokenBudget) {
379
389
  if (toolId === ToolName.PatternDetect && (output as any).duplicates) {
380
390
  const wastedTokens = (output as any).duplicates.reduce(
381
- (sum: number, d: any) => sum + (d.tokenCost || 0),
391
+ (sum: number, d: any) => sum + (d.tokenCost ?? 0),
382
392
  0
383
393
  );
384
394
  toolScore.tokenBudget = calculateTokenBudget({
@@ -394,7 +404,7 @@ export async function scoreUnified(
394
404
  totalContextTokens: output.summary.totalTokens,
395
405
  wastedTokens: {
396
406
  duplication: 0,
397
- fragmentation: output.summary.totalPotentialSavings || 0,
407
+ fragmentation: output.summary.totalPotentialSavings ?? 0,
398
408
  chattiness: 0,
399
409
  },
400
410
  });
@@ -444,7 +454,7 @@ export function generateUnifiedSummary(result: UnifiedAnalysisResult): string {
444
454
  const toolResult = result[provider.id];
445
455
  if (toolResult) {
446
456
  const issueCount = toolResult.results.reduce(
447
- (sum: number, r: any) => sum + (r.issues?.length || 0),
457
+ (sum: number, r: any) => sum + (r.issues?.length ?? 0),
448
458
  0
449
459
  );
450
460
  output += `• ${provider.id}: ${issueCount} issues\n`;