@aiready/cli 0.10.2 → 0.10.4

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.
@@ -22,6 +22,8 @@ import {
22
22
  getRatingDisplay,
23
23
  parseWeightString,
24
24
  getRepoMetadata,
25
+ Severity,
26
+ IssueType,
25
27
  type ToolScoringOutput,
26
28
  } from '@aiready/core';
27
29
  import { analyzeUnified, scoreUnified, type ScoringResult } from '../index';
@@ -364,7 +366,7 @@ export async function scanAction(directory: string, options: ScanOptions) {
364
366
  // Count severities
365
367
  const counts = issues.reduce(
366
368
  (acc: any, it: any) => {
367
- const s = (it.severity || 'info').toLowerCase();
369
+ const s = (it.severity || Severity.Info).toLowerCase();
368
370
  acc[s] = (acc[s] || 0) + 1;
369
371
  return acc;
370
372
  },
@@ -374,12 +376,13 @@ export async function scanAction(directory: string, options: ScanOptions) {
374
376
  const sample =
375
377
  issues.find(
376
378
  (it: any) =>
377
- it.severity === 'critical' || it.severity === 'major'
379
+ it.severity === Severity.Critical ||
380
+ it.severity === Severity.Major
378
381
  ) || issues[0];
379
382
  const sampleMsg = sample ? ` — ${sample.message}` : '';
380
383
 
381
384
  console.log(
382
- ` ${idx + 1}. ${file} — ${issues.length} issue(s) (critical:${counts.critical || 0} major:${counts.major || 0} minor:${counts.minor || 0} info:${counts.info || 0})${sampleMsg}`
385
+ ` ${idx + 1}. ${file} — ${issues.length} issue(s) (critical:${counts[Severity.Critical] || 0} major:${counts[Severity.Major] || 0} minor:${counts[Severity.Minor] || 0} info:${counts[Severity.Info] || 0})${sampleMsg}`
383
386
  );
384
387
  });
385
388
 
@@ -653,6 +656,114 @@ export async function scanAction(directory: string, options: ScanOptions) {
653
656
  }
654
657
  }
655
658
 
659
+ // Helper to map CLI results to UnifiedReport schema
660
+ const mapToUnifiedReport = (
661
+ res: any,
662
+ scoring: ScoringResult | undefined
663
+ ) => {
664
+ const allResults: any[] = [];
665
+ let totalFilesSet = new Set<string>();
666
+ let criticalCount = 0;
667
+ let majorCount = 0;
668
+
669
+ // Collect from all spokes and normalize to AnalysisResult
670
+ const collect = (
671
+ spokeRes: any,
672
+ defaultType: IssueType = IssueType.AiSignalClarity
673
+ ) => {
674
+ if (!spokeRes || !spokeRes.results) return;
675
+ spokeRes.results.forEach((r: any) => {
676
+ const fileName = r.fileName || r.file || 'unknown';
677
+ totalFilesSet.add(fileName);
678
+
679
+ // Enforce strict AnalysisResult schema
680
+ const normalizedResult = {
681
+ fileName,
682
+ issues: [] as any[],
683
+ metrics: r.metrics || { tokenCost: r.tokenCost || 0 },
684
+ };
685
+
686
+ if (r.issues && Array.isArray(r.issues)) {
687
+ r.issues.forEach((i: any) => {
688
+ const normalizedIssue =
689
+ typeof i === 'string'
690
+ ? {
691
+ type: defaultType,
692
+ severity: (r.severity || Severity.Info) as Severity,
693
+ message: i,
694
+ location: { file: fileName, line: 1 },
695
+ }
696
+ : {
697
+ type: i.type || defaultType,
698
+ severity: (i.severity ||
699
+ r.severity ||
700
+ Severity.Info) as Severity,
701
+ message: i.message || String(i),
702
+ location: i.location || { file: fileName, line: 1 },
703
+ suggestion: i.suggestion,
704
+ };
705
+
706
+ if (
707
+ normalizedIssue.severity === Severity.Critical ||
708
+ normalizedIssue.severity === 'critical'
709
+ )
710
+ criticalCount++;
711
+ if (
712
+ normalizedIssue.severity === Severity.Major ||
713
+ normalizedIssue.severity === 'major'
714
+ )
715
+ majorCount++;
716
+
717
+ normalizedResult.issues.push(normalizedIssue);
718
+ });
719
+ } else if (r.severity) {
720
+ // handle context-analyzer style if issues missing but severity present
721
+ const normalizedIssue = {
722
+ type: defaultType,
723
+ severity: r.severity as Severity,
724
+ message: r.message || 'General issue',
725
+ location: { file: fileName, line: 1 },
726
+ };
727
+ if (
728
+ normalizedIssue.severity === Severity.Critical ||
729
+ normalizedIssue.severity === 'critical'
730
+ )
731
+ criticalCount++;
732
+ if (
733
+ normalizedIssue.severity === Severity.Major ||
734
+ normalizedIssue.severity === 'major'
735
+ )
736
+ majorCount++;
737
+ normalizedResult.issues.push(normalizedIssue);
738
+ }
739
+
740
+ allResults.push(normalizedResult);
741
+ });
742
+ };
743
+
744
+ collect(res.patternDetect, IssueType.DuplicatePattern);
745
+ collect(res.contextAnalyzer, IssueType.ContextFragmentation);
746
+ collect(res.consistency, IssueType.NamingInconsistency);
747
+ collect(res.docDrift, IssueType.DocDrift);
748
+ collect(res.dependencyHealth, IssueType.DependencyHealth);
749
+ collect(res.aiSignalClarity, IssueType.AiSignalClarity);
750
+ collect(res.agentGrounding, IssueType.AgentNavigationFailure);
751
+ collect(res.testability, IssueType.LowTestability);
752
+ collect(res.changeAmplification, IssueType.ChangeAmplification);
753
+
754
+ return {
755
+ ...res,
756
+ results: allResults,
757
+ summary: {
758
+ ...res.summary,
759
+ totalFiles: totalFilesSet.size,
760
+ criticalIssues: criticalCount,
761
+ majorIssues: majorCount,
762
+ },
763
+ scoring: scoring,
764
+ };
765
+ };
766
+
656
767
  // Persist JSON summary when output format is json
657
768
  const outputFormat =
658
769
  options.output || finalOptions.output?.format || 'console';
@@ -666,8 +777,7 @@ export async function scanAction(directory: string, options: ScanOptions) {
666
777
  resolvedDir
667
778
  );
668
779
  const outputData = {
669
- ...results,
670
- scoring: scoringResult,
780
+ ...mapToUnifiedReport(results, scoringResult),
671
781
  repository: repoMetadata,
672
782
  };
673
783
  handleJSONOutput(
@@ -697,8 +807,7 @@ export async function scanAction(directory: string, options: ScanOptions) {
697
807
  resolvedDir
698
808
  );
699
809
  const outputData = {
700
- ...results,
701
- scoring: scoringResult,
810
+ ...mapToUnifiedReport(results, scoringResult),
702
811
  repository: repoMetadata,
703
812
  };
704
813
 
@@ -757,7 +866,8 @@ export async function scanAction(directory: string, options: ScanOptions) {
757
866
  // Output annotations for critical issues
758
867
  if (results.patternDetect) {
759
868
  const criticalPatterns = results.patternDetect.results.flatMap(
760
- (p: any) => p.issues.filter((i: any) => i.severity === 'critical')
869
+ (p: any) =>
870
+ p.issues.filter((i: any) => i.severity === Severity.Critical)
761
871
  );
762
872
  criticalPatterns.slice(0, 10).forEach((issue: any) => {
763
873
  console.log(
@@ -789,22 +899,22 @@ export async function scanAction(directory: string, options: ScanOptions) {
789
899
  if (results.patternDetect) {
790
900
  results.patternDetect.results.forEach((p: any) => {
791
901
  p.issues.forEach((i: any) => {
792
- if (i.severity === 'critical') criticalCount++;
793
- if (i.severity === 'major') majorCount++;
902
+ if (i.severity === Severity.Critical) criticalCount++;
903
+ if (i.severity === Severity.Major) majorCount++;
794
904
  });
795
905
  });
796
906
  }
797
907
  if (results.contextAnalyzer) {
798
908
  results.contextAnalyzer.results.forEach((c: any) => {
799
- if (c.severity === 'critical') criticalCount++;
800
- if (c.severity === 'major') majorCount++;
909
+ if (c.severity === Severity.Critical) criticalCount++;
910
+ if (c.severity === Severity.Major) majorCount++;
801
911
  });
802
912
  }
803
913
  if (results.consistency) {
804
914
  results.consistency.results.forEach((r: any) => {
805
915
  r.issues?.forEach((i: any) => {
806
- if (i.severity === 'critical') criticalCount++;
807
- if (i.severity === 'major') majorCount++;
916
+ if (i.severity === Severity.Critical) criticalCount++;
917
+ if (i.severity === Severity.Major) majorCount++;
808
918
  });
809
919
  });
810
920
  }
@@ -26,7 +26,9 @@ export async function uploadAction(file: string, options: UploadOptions) {
26
26
  )
27
27
  );
28
28
  console.log(
29
- chalk.dim(' Get an API key from https://getaiready.dev/dashboard')
29
+ chalk.dim(
30
+ ' Get an API key from https://platform.getaiready.dev/dashboard'
31
+ )
30
32
  );
31
33
  process.exit(1);
32
34
  }
package/src/index.ts CHANGED
@@ -180,10 +180,13 @@ export async function analyzeUnified(
180
180
  options.progressCallback({ tool: 'doc-drift', data: report });
181
181
  }
182
182
  result.docDrift = {
183
- results: report.results || [],
183
+ results: (report as any).results || (report as any).issues || [],
184
184
  summary: report.summary || {},
185
185
  };
186
- result.summary.totalIssues += report.issues?.length || 0;
186
+ const issueCount =
187
+ (report as any).issues?.length ||
188
+ ((report as any).results ? (report as any).results.length : 0);
189
+ result.summary.totalIssues += issueCount;
187
190
  }
188
191
 
189
192
  // Run Dependency Health analysis
@@ -199,10 +202,13 @@ export async function analyzeUnified(
199
202
  options.progressCallback({ tool: 'deps-health', data: report });
200
203
  }
201
204
  result.dependencyHealth = {
202
- results: report.results || [],
205
+ results: (report as any).results || (report as any).issues || [],
203
206
  summary: report.summary || {},
204
207
  };
205
- result.summary.totalIssues += report.issues?.length || 0;
208
+ const issueCount =
209
+ (report as any).issues?.length ||
210
+ ((report as any).results ? (report as any).results.length : 0);
211
+ result.summary.totalIssues += issueCount;
206
212
  }
207
213
 
208
214
  // Run AI Signal Clarity analysis
@@ -220,12 +226,12 @@ export async function analyzeUnified(
220
226
  }
221
227
  result.aiSignalClarity = {
222
228
  ...report,
223
- results: report.results || [],
229
+ results: report.results || report.issues || [],
224
230
  summary: report.summary || {},
225
231
  };
226
232
  result.summary.totalIssues +=
227
- report.results?.reduce(
228
- (sum: number, r: any) => sum + (r.issues?.length || 0),
233
+ (report.results || report.issues)?.reduce(
234
+ (sum: number, r: any) => sum + (r.issues?.length || 1),
229
235
  0
230
236
  ) || 0;
231
237
  }
@@ -243,11 +249,15 @@ export async function analyzeUnified(
243
249
  options.progressCallback({ tool: 'agent-grounding', data: report });
244
250
  }
245
251
  result.agentGrounding = {
246
- ...report,
247
- results: report.results || [],
252
+ ...(report as any),
253
+ results: (report as any).results || (report as any).issues || [],
248
254
  summary: report.summary || {},
249
255
  };
250
- result.summary.totalIssues += report.issues?.length || 0;
256
+ result.summary.totalIssues += (
257
+ (report as any).issues ||
258
+ (report as any).results ||
259
+ []
260
+ ).length;
251
261
  }
252
262
 
253
263
  // Run Testability analysis
@@ -263,11 +273,15 @@ export async function analyzeUnified(
263
273
  options.progressCallback({ tool: 'testability', data: report });
264
274
  }
265
275
  result.testability = {
266
- ...report,
267
- results: report.results || [],
276
+ ...(report as any),
277
+ results: (report as any).results || (report as any).issues || [],
268
278
  summary: report.summary || {},
269
279
  };
270
- result.summary.totalIssues += report.issues?.length || 0;
280
+ result.summary.totalIssues += (
281
+ (report as any).issues ||
282
+ (report as any).results ||
283
+ []
284
+ ).length;
271
285
  }
272
286
 
273
287
  // Run Change Amplification analysis