@aiready/core 0.21.17 → 0.21.21

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/dist/client.d.mts CHANGED
@@ -235,6 +235,11 @@ declare const UnifiedReportSchema: z.ZodObject<{
235
235
  totalIssues: z.ZodNumber;
236
236
  criticalIssues: z.ZodNumber;
237
237
  majorIssues: z.ZodNumber;
238
+ businessImpact: z.ZodOptional<z.ZodObject<{
239
+ estimatedMonthlyWaste: z.ZodOptional<z.ZodNumber>;
240
+ potentialSavings: z.ZodOptional<z.ZodNumber>;
241
+ productivityHours: z.ZodOptional<z.ZodNumber>;
242
+ }, z.core.$strip>>;
238
243
  }, z.core.$strip>;
239
244
  results: z.ZodArray<z.ZodObject<{
240
245
  fileName: z.ZodString;
@@ -443,103 +448,142 @@ declare const GLOBAL_INFRA_OPTIONS: string[];
443
448
  */
444
449
  declare const COMMON_FINE_TUNING_OPTIONS: string[];
445
450
  declare const GLOBAL_SCAN_OPTIONS: string[];
451
+ /**
452
+ * Base configuration for any AIReady tool
453
+ */
454
+ interface BaseToolConfig {
455
+ /** Whether this tool is enabled for the scan */
456
+ enabled?: boolean;
457
+ /** Custom weight for overall score calculation (sum should be 100) */
458
+ scoreWeight?: number;
459
+ /** Catch-all for any other tool-specific options */
460
+ [key: string]: any;
461
+ }
462
+ /**
463
+ * Configuration for the pattern-detect tool (semantic duplicate detection)
464
+ */
465
+ interface PatternDetectConfig extends BaseToolConfig {
466
+ /** Similarity threshold (0-1). Higher = more strict. */
467
+ minSimilarity?: number;
468
+ /** Minimum lines to consider a block */
469
+ minLines?: number;
470
+ /** Batch size for parallel processing */
471
+ batchSize?: number;
472
+ /** Use approximate matching engine for faster results on large repos */
473
+ approx?: boolean;
474
+ /** Minimum tokens shared between blocks for candidates */
475
+ minSharedTokens?: number;
476
+ /** Maximum number of candidates to compare per block */
477
+ maxCandidatesPerBlock?: number;
478
+ }
479
+ /**
480
+ * Configuration for the context-analyzer tool (fragmentation and budget)
481
+ */
482
+ interface ContextAnalyzerConfig extends BaseToolConfig {
483
+ /** Maximum directory depth to traverse */
484
+ maxDepth?: number;
485
+ /** Maximum tokens allowed per context window */
486
+ maxContextBudget?: number;
487
+ /** Minimum cohesion score required (0-1) */
488
+ minCohesion?: number;
489
+ /** Maximum fragmentation ratio allowed (0-1) */
490
+ maxFragmentation?: number;
491
+ /** Primary focus area for the analyzer */
492
+ focus?: 'fragmentation' | 'cohesion' | 'depth' | 'all';
493
+ /** Whether to include dependencies from node_modules */
494
+ includeNodeModules?: boolean;
495
+ /** Project-specific domain keywords for better inference */
496
+ domainKeywords?: string[];
497
+ }
498
+ /**
499
+ * Configuration for the naming-consistency tool
500
+ */
501
+ interface NamingConsistencyConfig extends BaseToolConfig {
502
+ /** Project-approved abbreviations */
503
+ acceptedAbbreviations?: string[];
504
+ /** Words that are allowed to be short (like 'id', 'db') */
505
+ shortWords?: string[];
506
+ /** Specific checks to disable */
507
+ disableChecks?: ('single-letter' | 'abbreviation' | 'convention-mix' | 'unclear' | 'poor-naming')[];
508
+ }
509
+ /**
510
+ * Configuration for the ai-signal-clarity tool
511
+ */
512
+ interface AiSignalClarityConfig extends BaseToolConfig {
513
+ /** Detect unnamed constants */
514
+ checkMagicLiterals?: boolean;
515
+ /** Detect positional boolean arguments */
516
+ checkBooleanTraps?: boolean;
517
+ /** Detect generic names like 'temp', 'data' */
518
+ checkAmbiguousNames?: boolean;
519
+ /** Detect public exports missing JSDoc */
520
+ checkUndocumentedExports?: boolean;
521
+ /** Detect implicit state mutations */
522
+ checkImplicitSideEffects?: boolean;
523
+ /** Detect deeply nested callbacks */
524
+ checkDeepCallbacks?: boolean;
525
+ }
526
+ /**
527
+ * Consolidated AIReady configuration schema
528
+ */
446
529
  interface AIReadyConfig {
530
+ /** Global scan settings */
447
531
  scan?: {
532
+ /** Glob patterns to include */
448
533
  include?: string[];
534
+ /** Glob patterns to exclude */
449
535
  exclude?: string[];
536
+ /** List of tools to execute */
450
537
  tools?: string[];
451
538
  };
539
+ /** Tool-specific configurations */
452
540
  tools?: {
453
- 'pattern-detect'?: {
454
- enabled?: boolean;
455
- scoreWeight?: number;
456
- minSimilarity?: number;
457
- minLines?: number;
458
- batchSize?: number;
459
- approx?: boolean;
460
- minSharedTokens?: number;
461
- maxCandidatesPerBlock?: number;
462
- streamResults?: boolean;
463
- maxResults?: number;
464
- };
465
- 'context-analyzer'?: {
466
- enabled?: boolean;
467
- scoreWeight?: number;
468
- maxDepth?: number;
469
- maxContextBudget?: number;
470
- minCohesion?: number;
471
- maxFragmentation?: number;
472
- focus?: 'fragmentation' | 'cohesion' | 'depth' | 'all';
473
- includeNodeModules?: boolean;
474
- maxResults?: number;
475
- domainKeywords?: string[];
476
- domainPatterns?: string[];
477
- pathDomainMap?: Record<string, string>;
478
- };
479
- [ToolName.NamingConsistency]?: {
480
- enabled?: boolean;
481
- scoreWeight?: number;
482
- acceptedAbbreviations?: string[];
483
- shortWords?: string[];
484
- disableChecks?: ('single-letter' | 'abbreviation' | 'convention-mix' | 'unclear' | 'poor-naming')[];
485
- };
486
- [ToolName.AiSignalClarity]?: {
487
- enabled?: boolean;
488
- scoreWeight?: number;
489
- checkMagicLiterals?: boolean;
490
- checkBooleanTraps?: boolean;
491
- checkAmbiguousNames?: boolean;
492
- checkUndocumentedExports?: boolean;
493
- checkImplicitSideEffects?: boolean;
494
- checkDeepCallbacks?: boolean;
495
- minSeverity?: string;
496
- };
497
- [ToolName.AgentGrounding]?: {
498
- enabled?: boolean;
499
- scoreWeight?: number;
541
+ 'pattern-detect'?: PatternDetectConfig;
542
+ 'context-analyzer'?: ContextAnalyzerConfig;
543
+ [ToolName.NamingConsistency]?: NamingConsistencyConfig;
544
+ [ToolName.AiSignalClarity]?: AiSignalClarityConfig;
545
+ [ToolName.AgentGrounding]?: BaseToolConfig & {
500
546
  maxRecommendedDepth?: number;
501
547
  readmeStaleDays?: number;
502
- additionalVagueNames?: string[];
503
548
  };
504
- [ToolName.TestabilityIndex]?: {
505
- enabled?: boolean;
506
- scoreWeight?: number;
549
+ [ToolName.TestabilityIndex]?: BaseToolConfig & {
507
550
  minCoverageRatio?: number;
508
551
  testPatterns?: string[];
509
552
  };
510
- [ToolName.DocDrift]?: {
511
- enabled?: boolean;
512
- scoreWeight?: number;
553
+ [ToolName.DocDrift]?: BaseToolConfig & {
513
554
  maxCommits?: number;
514
555
  staleMonths?: number;
515
556
  };
516
- [ToolName.DependencyHealth]?: {
517
- enabled?: boolean;
518
- scoreWeight?: number;
557
+ [ToolName.DependencyHealth]?: BaseToolConfig & {
519
558
  trainingCutoffYear?: number;
520
559
  };
521
- [ToolName.ChangeAmplification]?: {
522
- enabled?: boolean;
523
- scoreWeight?: number;
524
- };
525
- [toolName: string]: {
526
- enabled?: boolean;
527
- scoreWeight?: number;
528
- [key: string]: any;
529
- } | undefined;
560
+ [ToolName.ChangeAmplification]?: BaseToolConfig;
561
+ /** Support for custom/third-party tools */
562
+ [toolName: string]: BaseToolConfig | undefined;
530
563
  };
564
+ /** Global scoring and threshold settings */
531
565
  scoring?: {
566
+ /** Minimum overall score required to pass CI/CD */
532
567
  threshold?: number;
568
+ /** Detailed breakdown in terminal output */
533
569
  showBreakdown?: boolean;
570
+ /** Comparison with a previous run */
534
571
  compareBaseline?: string;
572
+ /** Auto-persist result to this path */
535
573
  saveTo?: string;
536
574
  };
575
+ /** Console and file output preferences */
537
576
  output?: {
577
+ /** Output format (console, json, html) */
538
578
  format?: 'console' | 'json' | 'html';
579
+ /** Target file for the full report */
539
580
  file?: string;
540
581
  };
582
+ /** Graph Visualizer preferences */
541
583
  visualizer?: {
584
+ /** Custom directory grouping levels */
542
585
  groupingDirs?: string[];
586
+ /** Performance constraints for large graphs */
543
587
  graph?: {
544
588
  maxNodes?: number;
545
589
  maxEdges?: number;
@@ -817,10 +861,25 @@ interface ParseStatistics {
817
861
  }
818
862
 
819
863
  /**
820
- * AI Readiness Scoring System
821
- *
822
- * Provides dynamic, composable scoring across multiple analysis tools.
823
- * Each tool contributes a 0-100 score with configurable weights.
864
+ * Priority levels for actionable recommendations
865
+ */
866
+ declare enum RecommendationPriority {
867
+ High = "high",
868
+ Medium = "medium",
869
+ Low = "low"
870
+ }
871
+ /**
872
+ * AI Readiness Rating categories
873
+ */
874
+ declare enum ReadinessRating {
875
+ Excellent = "Excellent",
876
+ Good = "Good",
877
+ Fair = "Fair",
878
+ NeedsWork = "Needs Work",
879
+ Critical = "Critical"
880
+ }
881
+ /**
882
+ * Output structure for a single tool's scoring analysis
824
883
  */
825
884
  interface ToolScoringOutput {
826
885
  /** Unique tool identifier (e.g., "pattern-detect") */
@@ -833,43 +892,58 @@ interface ToolScoringOutput {
833
892
  rawMetrics: Record<string, any>;
834
893
  /** Factors that influenced the score */
835
894
  factors: Array<{
895
+ /** Human-readable name of the factor */
836
896
  name: string;
897
+ /** Points contribution (positive or negative) */
837
898
  impact: number;
899
+ /** Explanation of the factor's impact */
838
900
  description: string;
839
901
  }>;
840
902
  /** Actionable recommendations with estimated impact */
841
903
  recommendations: Array<{
904
+ /** The recommended action to take */
842
905
  action: string;
906
+ /** Potential points increase if implemented */
843
907
  estimatedImpact: number;
844
- priority: 'high' | 'medium' | 'low';
908
+ /** Implementation priority */
909
+ priority: RecommendationPriority | 'high' | 'medium' | 'low';
845
910
  }>;
846
911
  }
912
+ /**
913
+ * Consolidated scoring result across all tools
914
+ */
847
915
  interface ScoringResult {
848
916
  /** Overall AI Readiness Score (0-100) */
849
917
  overall: number;
850
- /** Rating category */
851
- rating: 'Excellent' | 'Good' | 'Fair' | 'Needs Work' | 'Critical';
918
+ /** Rating category representing the overall readiness */
919
+ rating: ReadinessRating | string;
852
920
  /** Timestamp of score calculation */
853
921
  timestamp: string;
854
922
  /** Tools that contributed to this score */
855
923
  toolsUsed: string[];
856
- /** Breakdown by tool */
924
+ /** Breakdown by individual tool */
857
925
  breakdown: ToolScoringOutput[];
858
- /** Calculation details */
926
+ /** Internal calculation details for transparency */
859
927
  calculation: {
928
+ /** Textual representation of the calculation formula */
860
929
  formula: string;
930
+ /** Weights applied to each tool */
861
931
  weights: Record<string, number>;
932
+ /** Simplified normalized formula output */
862
933
  normalized: string;
863
934
  };
864
935
  }
936
+ /**
937
+ * Configuration options for the scoring system
938
+ */
865
939
  interface ScoringConfig {
866
- /** Minimum passing score (exit code 1 if below) */
940
+ /** Minimum passing score (CLI will exit with non-zero if below) */
867
941
  threshold?: number;
868
- /** Show detailed breakdown in output */
942
+ /** Whether to show the detailed tool-by-tool breakdown */
869
943
  showBreakdown?: boolean;
870
- /** Path to baseline JSON for comparison */
944
+ /** Path to a baseline report JSON for trend comparison */
871
945
  compareBaseline?: string;
872
- /** Auto-save score to this path */
946
+ /** Target file path to persist the calculated score */
873
947
  saveTo?: string;
874
948
  }
875
949
  /**
@@ -899,52 +973,92 @@ declare const CONTEXT_TIER_THRESHOLDS: Record<ModelContextTier, {
899
973
  */
900
974
  declare const SIZE_ADJUSTED_THRESHOLDS: Record<string, number>;
901
975
  /**
902
- * Determine project size tier from file count
976
+ * Determine project size tier based on the total number of files
977
+ *
978
+ * @param fileCount Total number of files in the project
979
+ * @returns A string identifier for the project size tier (xs, small, medium, large, enterprise)
903
980
  */
904
981
  declare function getProjectSizeTier(fileCount: number): keyof typeof SIZE_ADJUSTED_THRESHOLDS;
905
982
  /**
906
- * Get the recommended minimum threshold for a project
983
+ * Calculate the recommended minimum AI readiness threshold for a project
984
+ *
985
+ * @param fileCount Total number of files in the project
986
+ * @param modelTier The model context tier targeted (compact, standard, extended, frontier)
987
+ * @returns The recommended score threshold (0-100)
907
988
  */
908
989
  declare function getRecommendedThreshold(fileCount: number, modelTier?: ModelContextTier): number;
909
990
  /**
910
- * Normalize tool name from shorthand to canonical name
991
+ * Normalize a tool name from a shorthand or alias to its canonical ID
992
+ *
993
+ * @param shortName The tool shorthand or alias name
994
+ * @returns The canonical tool ID
911
995
  */
912
996
  declare function normalizeToolName(shortName: string): string;
913
997
  /**
914
- * Get tool weight
998
+ * Retrieve the weight for a specific tool, considering overrides
999
+ *
1000
+ * @param toolName The canonical tool ID
1001
+ * @param toolConfig Optional configuration for the tool containing a weight
1002
+ * @param cliOverride Optional weight override from the CLI
1003
+ * @returns The weight to be used for this tool in overall scoring
915
1004
  */
916
1005
  declare function getToolWeight(toolName: string, toolConfig?: {
917
1006
  scoreWeight?: number;
918
1007
  }, cliOverride?: number): number;
919
1008
  /**
920
- * Parse weight string from CLI
1009
+ * Parse a comma-separated weight string (e.g. "patterns:30,context:10")
1010
+ *
1011
+ * @param weightStr The raw weight string from the CLI or config
1012
+ * @returns A Map of tool IDs to their parsed weights
921
1013
  */
922
1014
  declare function parseWeightString(weightStr?: string): Map<string, number>;
923
1015
  /**
924
- * Calculate overall AI Readiness Score
1016
+ * Calculate the overall consolidated AI Readiness Score
1017
+ *
1018
+ * @param toolOutputs Map of tool IDs to their individual scoring outputs
1019
+ * @param config Optional global configuration
1020
+ * @param cliWeights Optional weight overrides from the CLI
1021
+ * @returns Consolidate ScoringResult including overall score and rating
925
1022
  */
926
1023
  declare function calculateOverallScore(toolOutputs: Map<string, ToolScoringOutput>, config?: any, cliWeights?: Map<string, number>): ScoringResult;
927
1024
  /**
928
1025
  * Convert numeric score to rating category
1026
+ *
1027
+ * @param score The numerical AI readiness score (0-100)
1028
+ * @returns The corresponding ReadinessRating category
929
1029
  */
930
- declare function getRating(score: number): ScoringResult['rating'];
1030
+ declare function getRating(score: number): ReadinessRating;
931
1031
  /**
932
1032
  * Convert score to rating with project-size awareness.
1033
+ *
1034
+ * @param score The numerical AI readiness score
1035
+ * @param fileCount Total number of files in the project
1036
+ * @param modelTier The model context tier being targeted
1037
+ * @returns The size-adjusted ReadinessRating
933
1038
  */
934
- declare function getRatingWithContext(score: number, fileCount: number, modelTier?: ModelContextTier): ScoringResult['rating'];
1039
+ declare function getRatingWithContext(score: number, fileCount: number, modelTier?: ModelContextTier): ReadinessRating;
935
1040
  /**
936
- * Get rating display properties
1041
+ * Get rating display properties (emoji and color)
1042
+ *
1043
+ * @param rating The readiness rating category
1044
+ * @returns Object containing display emoji and color string
937
1045
  */
938
- declare function getRatingDisplay(rating: ScoringResult['rating']): {
1046
+ declare function getRatingDisplay(rating: ReadinessRating | string): {
939
1047
  emoji: string;
940
1048
  color: string;
941
1049
  };
942
1050
  /**
943
- * Format score for display
1051
+ * Format score for human-readable console display
1052
+ *
1053
+ * @param result The consolidated scoring result
1054
+ * @returns Formatted string for display
944
1055
  */
945
1056
  declare function formatScore(result: ScoringResult): string;
946
1057
  /**
947
- * Format individual tool score for display
1058
+ * Format individual tool score for detailed console display
1059
+ *
1060
+ * @param output The scoring output for a single tool
1061
+ * @returns Formatted string with factors and recommendations
948
1062
  */
949
1063
  declare function formatToolScore(output: ToolScoringOutput): string;
950
1064
 
@@ -961,4 +1075,4 @@ declare function formatToolScore(output: ToolScoringOutput): string;
961
1075
  */
962
1076
  declare function generateHTML(graph: GraphData): string;
963
1077
 
964
- export { type AIReadyConfig, type AcceptancePrediction, type AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, type BusinessReport, COMMON_FINE_TUNING_OPTIONS, CONTEXT_TIER_THRESHOLDS, type CommonASTNode, type ComprehensionDifficulty, type CostConfig, DEFAULT_TOOL_WEIGHTS, type ExportInfo, FRIENDLY_TOOL_NAMES, GLOBAL_INFRA_OPTIONS, GLOBAL_SCAN_OPTIONS, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, LocationSchema, type Metrics, MetricsSchema, type ModelContextTier, ModelTier, ModelTierSchema, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type ProductivityImpact, type Report, SIZE_ADJUSTED_THRESHOLDS, type ScanOptions, type ScoringConfig, type ScoringResult, Severity, SeveritySchema, type SourceLocation, type SourceRange, type SpokeOutput, SpokeOutputSchema, type SpokeSummary, SpokeSummarySchema, TOOL_NAME_MAP, type TechnicalValueChain, type TechnicalValueChainSummary, type TokenBudget, ToolName, ToolNameSchema, type ToolScoringOutput, type UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString };
1078
+ export { type AIReadyConfig, type AcceptancePrediction, type AiSignalClarityConfig, type AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, type BaseToolConfig, type BusinessReport, COMMON_FINE_TUNING_OPTIONS, CONTEXT_TIER_THRESHOLDS, type CommonASTNode, type ComprehensionDifficulty, type ContextAnalyzerConfig, type CostConfig, DEFAULT_TOOL_WEIGHTS, type ExportInfo, FRIENDLY_TOOL_NAMES, GLOBAL_INFRA_OPTIONS, GLOBAL_SCAN_OPTIONS, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, LocationSchema, type Metrics, MetricsSchema, type ModelContextTier, ModelTier, ModelTierSchema, type NamingConsistencyConfig, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type PatternDetectConfig, type ProductivityImpact, ReadinessRating, RecommendationPriority, type Report, SIZE_ADJUSTED_THRESHOLDS, type ScanOptions, type ScoringConfig, type ScoringResult, Severity, SeveritySchema, type SourceLocation, type SourceRange, type SpokeOutput, SpokeOutputSchema, type SpokeSummary, SpokeSummarySchema, TOOL_NAME_MAP, type TechnicalValueChain, type TechnicalValueChainSummary, type TokenBudget, ToolName, ToolNameSchema, type ToolScoringOutput, type UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString };