@aiready/core 0.23.1 → 0.23.3

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.
Files changed (79) hide show
  1. package/dist/__tests__/parser-factory.test.d.ts +1 -1
  2. package/dist/__tests__/parser-factory.test.js +62 -50
  3. package/dist/__tests__/python-parser.test.d.ts +1 -1
  4. package/dist/__tests__/python-parser.test.js +111 -109
  5. package/dist/__tests__/scoring.test.d.ts +1 -1
  6. package/dist/__tests__/scoring.test.js +193 -176
  7. package/dist/chunk-3YI4IS3D.mjs +191 -173
  8. package/dist/chunk-5HIXDC3X.mjs +273 -251
  9. package/dist/chunk-5V3L53AE.mjs +805 -0
  10. package/dist/chunk-CKVKHN3G.mjs +228 -211
  11. package/dist/chunk-COHIBX3Q.mjs +213 -195
  12. package/dist/chunk-CWRCDSKZ.mjs +91 -82
  13. package/dist/chunk-D3D3NCRR.mjs +147 -129
  14. package/dist/chunk-HCFYP7UD.mjs +805 -0
  15. package/dist/chunk-HFLFBA6F.mjs +79 -72
  16. package/dist/chunk-HKSARRCD.mjs +66 -58
  17. package/dist/chunk-JJ5JL5FX.mjs +91 -82
  18. package/dist/chunk-KDSTXVLQ.mjs +724 -0
  19. package/dist/chunk-KI7XORTN.mjs +91 -82
  20. package/dist/chunk-LTMHFNFK.mjs +690 -0
  21. package/dist/chunk-LTNXTXRI.mjs +228 -211
  22. package/dist/chunk-M22BXHBR.mjs +805 -0
  23. package/dist/chunk-MH3A3LX6.mjs +200 -182
  24. package/dist/chunk-NGHT7JOG.mjs +697 -0
  25. package/dist/chunk-OQ6IGDXG.mjs +147 -129
  26. package/dist/chunk-QAFB3HXQ.mjs +181 -165
  27. package/dist/chunk-QQBKXHLU.mjs +678 -0
  28. package/dist/chunk-RDHYGES7.mjs +678 -0
  29. package/dist/chunk-SWTDBVYJ.mjs +228 -213
  30. package/dist/chunk-UIWL5JQB.mjs +79 -72
  31. package/dist/chunk-UQGI67WR.mjs +79 -72
  32. package/dist/chunk-UTZOO4XO.mjs +147 -131
  33. package/dist/chunk-X4F46I5L.mjs +213 -195
  34. package/dist/chunk-XKK7YHPX.mjs +204 -186
  35. package/dist/chunk-YCA4FTEK.mjs +190 -172
  36. package/dist/chunk-ZSZRRTJM.mjs +719 -0
  37. package/dist/client-BgmiMoil.d.mts +1344 -0
  38. package/dist/client-BgmiMoil.d.ts +1344 -0
  39. package/dist/client-BxGrPuuN.d.mts +1191 -0
  40. package/dist/client-BxGrPuuN.d.ts +1191 -0
  41. package/dist/client-D-cn9ydj.d.mts +1136 -0
  42. package/dist/client-D-cn9ydj.d.ts +1136 -0
  43. package/dist/client-D9seCH4K.d.mts +1334 -0
  44. package/dist/client-D9seCH4K.d.ts +1334 -0
  45. package/dist/client-DIXIh7rw.d.mts +1193 -0
  46. package/dist/client-DIXIh7rw.d.ts +1193 -0
  47. package/dist/client-DVHXWOHw.d.mts +1245 -0
  48. package/dist/client-DVHXWOHw.d.ts +1245 -0
  49. package/dist/client.d.mts +2 -1094
  50. package/dist/client.d.ts +2 -1094
  51. package/dist/client.js +23 -43
  52. package/dist/client.mjs +3 -25
  53. package/dist/index.d.mts +380 -108
  54. package/dist/index.d.ts +380 -108
  55. package/dist/index.js +609 -445
  56. package/dist/index.mjs +587 -429
  57. package/dist/parsers/parser-factory.d.ts +45 -45
  58. package/dist/parsers/parser-factory.js +86 -84
  59. package/dist/parsers/python-parser.d.ts +33 -28
  60. package/dist/parsers/python-parser.js +224 -222
  61. package/dist/parsers/typescript-parser.d.ts +15 -10
  62. package/dist/parsers/typescript-parser.js +223 -197
  63. package/dist/scoring.d.ts +59 -49
  64. package/dist/scoring.js +129 -127
  65. package/dist/types/language.d.ts +104 -93
  66. package/dist/types/language.js +23 -23
  67. package/dist/types.d.ts +105 -87
  68. package/dist/types.js +1 -1
  69. package/dist/utils/ast-parser.d.ts +42 -33
  70. package/dist/utils/ast-parser.js +159 -162
  71. package/dist/utils/cli-helpers.d.ts +27 -10
  72. package/dist/utils/cli-helpers.js +45 -43
  73. package/dist/utils/config.d.ts +8 -3
  74. package/dist/utils/config.js +67 -69
  75. package/dist/utils/file-scanner.d.ts +1 -1
  76. package/dist/utils/file-scanner.js +80 -76
  77. package/dist/utils/metrics.d.ts +1 -1
  78. package/dist/utils/metrics.js +2 -2
  79. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ToolName, ScanOptions, SpokeOutput, ToolScoringOutput, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ExportInfo, ParseResult, NamingConvention } from './client.js';
2
- export { AiSignalClarityConfig, AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, BaseToolConfig, BusinessReport, COMMON_FINE_TUNING_OPTIONS, CONTEXT_TIER_THRESHOLDS, CommonASTNode, ContextAnalyzerConfig, DEFAULT_TOOL_WEIGHTS, FRIENDLY_TOOL_NAMES, GLOBAL_INFRA_OPTIONS, GLOBAL_SCAN_OPTIONS, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, LanguageConfig, Location, LocationSchema, Metrics, MetricsSchema, ModelTier, ModelTierSchema, NamingConsistencyConfig, ParseError, ParseStatistics, PatternDetectConfig, ReadinessRating, RecommendationPriority, Report, SCORING_PROFILES, SIZE_ADJUSTED_THRESHOLDS, ScoringConfig, ScoringProfile, ScoringResult, Severity, SeveritySchema, SourceLocation, SourceRange, SpokeOutputSchema, SpokeSummary, SpokeSummarySchema, TOOL_NAME_MAP, ToolNameSchema, UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString } from './client.js';
1
+ import { T as ToolName, S as ScanOptions, a as SpokeOutput, b as ToolScoringOutput, c as Severity, A as AnalysisResult, E as ExportWithImports, d as ASTNode, F as FileImport, e as AIReadyConfig, M as ModelContextTier, C as CostConfig, f as TokenBudget, P as ProductivityImpact, g as AcceptancePrediction, h as ComprehensionDifficulty, i as TechnicalValueChainSummary, j as TechnicalValueChain, L as LanguageParser, k as Language, l as ExportInfo, m as ParseResult, N as NamingConvention, I as ImportInfo } from './client-D-cn9ydj.js';
2
+ export { n as AnalysisResultSchema, o as AnalysisStatus, p as AnalysisStatusSchema, B as BusinessMetrics, q as COMMON_FINE_TUNING_OPTIONS, r as CONTEXT_TIER_THRESHOLDS, s as CommonASTNode, t as Config, D as DEFAULT_TOOL_WEIGHTS, u as FRIENDLY_TOOL_NAMES, v as FileContent, G as GLOBAL_INFRA_OPTIONS, w as GLOBAL_SCAN_OPTIONS, x as GraphData, y as GraphEdge, z as GraphIssueSeverity, H as GraphMetadata, J as GraphNode, K as Issue, O as IssueSchema, Q as IssueType, R as IssueTypeSchema, U as LANGUAGE_EXTENSIONS, V as LanguageConfig, W as Location, X as LocationSchema, Y as Metrics, Z as MetricsSchema, _ as ModelTier, $ as ModelTierSchema, a0 as ParseError, a1 as ParseStatistics, a2 as ReadinessRating, a3 as RecommendationPriority, a4 as SCORING_PROFILES, a5 as SIZE_ADJUSTED_THRESHOLDS, a6 as ScanResult, a7 as ScoringConfig, a8 as ScoringProfile, a9 as ScoringResult, aa as SeveritySchema, ab as SourceLocation, ac as SourceRange, ad as SpokeOutputSchema, ae as SpokeSummary, af as SpokeSummarySchema, ag as TOOL_NAME_MAP, ah as ToolNameSchema, ai as ToolOptions, aj as ToolOutput, ak as UnifiedReport, al as UnifiedReportSchema, am as calculateOverallScore, an as formatScore, ao as formatToolScore, ap as generateHTML, aq as getProjectSizeTier, ar as getRating, as as getRatingDisplay, at as getRatingSlug, au as getRatingWithContext, av as getRecommendedThreshold, aw as getToolWeight, ax as normalizeToolName, ay as parseWeightString } from './client-D-cn9ydj.js';
3
3
  import { z } from 'zod';
4
4
  import * as Parser from 'web-tree-sitter';
5
5
  import { TSESTree } from '@typescript-eslint/typescript-estree';
@@ -123,7 +123,17 @@ declare class ToolRegistry {
123
123
  static clear(): void;
124
124
  }
125
125
 
126
+ /**
127
+ * Default file exclusion patterns for AIReady scans.
128
+ * These patterns are applied to exclude build artifacts, dependencies,
129
+ * test files, and other non-source files from analysis.
130
+ */
126
131
  declare const DEFAULT_EXCLUDE: string[];
132
+ /**
133
+ * Set of vague/abiguous file names that indicate poor code organization.
134
+ * These names don't convey the file's purpose and make it harder for AI
135
+ * to understand the codebase structure.
136
+ */
127
137
  declare const VAGUE_FILE_NAMES: Set<string>;
128
138
  /**
129
139
  * Scan files in a directory using glob patterns
@@ -143,17 +153,53 @@ declare function scanEntries(options: ScanOptions): Promise<{
143
153
  files: string[];
144
154
  dirs: string[];
145
155
  }>;
156
+ /**
157
+ * Read the contents of a file as a UTF-8 string.
158
+ * @param filePath - Absolute path to the file to read
159
+ * @returns The file contents as a string
160
+ */
161
+ /**
162
+ * Read the contents of a file as a UTF-8 string.
163
+ * @param filePath - Absolute path to the file to read
164
+ * @returns The file contents as a string
165
+ */
146
166
  declare function readFileContent(filePath: string): Promise<string>;
167
+ /**
168
+ * Extract the file extension from a file path.
169
+ * @param filePath - The file path to extract extension from
170
+ * @returns The file extension without the dot (e.g., 'ts', 'js', 'py')
171
+ */
172
+ /**
173
+ * Extract the file extension from a file path.
174
+ * @param filePath - The file path to extract extension from
175
+ * @returns The file extension without the dot (e.g., 'ts', 'js', 'py')
176
+ */
147
177
  declare function getFileExtension(filePath: string): string;
178
+ /**
179
+ * Check if a file is a source code file based on its extension.
180
+ * Supports TypeScript, JavaScript, Python, Java, Go, Rust, and C#.
181
+ * @param filePath - The file path to check
182
+ * @returns True if the file has a source code extension
183
+ */
184
+ /**
185
+ * Check if a file is a source code file based on its extension.
186
+ * Supports TypeScript, JavaScript, Python, Java, Go, Rust, and C#.
187
+ * @param filePath - The file path to check
188
+ * @returns True if the file has a source code extension
189
+ */
148
190
  declare function isSourceFile(filePath: string): boolean;
149
191
 
150
192
  /**
151
193
  * Common CLI configuration interface
152
194
  */
153
195
  interface CLIOptions {
196
+ /** Root directory for analysis */
154
197
  rootDir: string;
198
+ /** Glob patterns to include */
155
199
  include?: string[];
200
+ /** Glob patterns to exclude */
156
201
  exclude?: string[];
202
+ /** Any other tool-specific options */
157
203
  [key: string]: any;
158
204
  }
159
205
  /**
@@ -167,89 +213,185 @@ interface CLIOptions {
167
213
  declare function resolveOutputPath(userPath: string | undefined, defaultFilename: string, workingDir?: string): string;
168
214
  /**
169
215
  * Load and merge configuration with CLI options
216
+ * @param directory Root directory to load config from
217
+ * @param defaults Default configuration values
218
+ * @param cliOptions Configuration overrides from CLI arguments
219
+ * @returns Merged configuration object
170
220
  */
171
221
  declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): Promise<T & {
172
222
  rootDir: string;
173
223
  }>;
174
224
  /**
175
- * Handle JSON output for CLI commands
225
+ * Handle JSON output for CLI commands.
226
+ * Writes to file if outputFile is provided, otherwise logs to console.
227
+ * @param data Data to output
228
+ * @param outputFile Optional path to save JSON file
229
+ * @param successMessage Optional message to show on success
176
230
  */
177
231
  declare function handleJSONOutput(data: any, outputFile?: string, successMessage?: string): void;
178
232
  /**
179
- * Common error handler for CLI commands
233
+ * Common error handler for CLI commands.
234
+ * Logs error and exits process with code 1.
235
+ * @param error Error object or message
236
+ * @param commandName Name of the command that failed
180
237
  */
181
238
  declare function handleCLIError(error: unknown, commandName: string): never;
182
239
  /**
183
240
  * Calculate elapsed time and format for display
241
+ * @param startTime timestamp in milliseconds
242
+ * @returns Formatted seconds (e.g. "1.23")
184
243
  */
185
244
  declare function getElapsedTime(startTime: number): string;
186
245
  /**
187
246
  * Generate a visual score bar for console output
247
+ * @param val Score value (0-100)
248
+ * @returns String representation of the bar (e.g. "█████░░░░░")
188
249
  */
189
250
  declare function getScoreBar(val: number): string;
190
251
  /**
191
252
  * Get status icon for safety ratings
253
+ * @param rating Safety rating slug
254
+ * @returns Emoji icon representating the rating
192
255
  */
193
256
  declare function getSafetyIcon(rating: string): string;
194
257
  /**
195
258
  * Emit progress update with throttling to reduce log noise
259
+ * @param processed Number of items processed
260
+ * @param total Total items to process
261
+ * @param toolId Tool identifier
262
+ * @param message Progress message
263
+ * @param onProgress Global progress callback
264
+ * @param throttleCount Frequency of updates (every N items)
196
265
  */
197
266
  declare function emitProgress(processed: number, total: number, toolId: string, message: string, onProgress?: (processed: number, total: number, message: string) => void, throttleCount?: number): void;
198
267
  /**
199
268
  * Get chalk color function for a given severity
200
- * @param severity severity level
201
- * @param chalk chalk instance
269
+ * @param severity Severity level string
270
+ * @param chalkInstance Chalk instance to use
271
+ * @returns Chalk color function
272
+ */
273
+ declare function getSeverityColor(severity: string, chalkInstance?: any): any;
274
+ /**
275
+ * Get numeric severity value for comparison (4-1)
276
+ * @param s Severity level string
277
+ * @returns Numeric value (4: critical, 3: major, 2: minor, 1: info)
202
278
  */
203
- declare function getSeverityColor(severity: string, chalk: any): any;
279
+ declare function getSeverityValue(s: string | undefined): number;
280
+ /**
281
+ * Get numeric severity level (alias for getSeverityValue)
282
+ * @param s Severity level string
283
+ * @returns Numeric value
284
+ */
285
+ declare function getSeverityLevel(s: string | undefined): number;
286
+ /**
287
+ * Get colored severity badge for console output
288
+ * @param severity Severity level
289
+ * @param chalkInstance Chalk instance (optional)
290
+ * @returns Formatted badge string
291
+ */
292
+ declare function getSeverityBadge(severity: Severity | string, chalkInstance?: any): string;
293
+ /**
294
+ * Get Severity enum from string for internal logic
295
+ * @param s Severity level string
296
+ * @returns Normalized severity string
297
+ */
298
+ declare function getSeverityEnum(s: string | undefined): any;
299
+ /**
300
+ * Find the latest aiready report in a directory by modification time.
301
+ * Searches for both new format (aiready-report-*) and legacy format (aiready-scan-*).
302
+ * @param dirPath - The directory path to search for .aiready directory
303
+ * @returns The path to the latest report or null if not found
304
+ */
305
+ declare function findLatestReport(dirPath: string): string | null;
306
+ /**
307
+ * Find the latest scan report file with a specific prefix.
308
+ * @param scanReportsDir Directory containing reports
309
+ * @param reportFilePrefix Filename prefix to match (e.g. "report-")
310
+ * @returns Path to the latest matching report or null
311
+ */
312
+ declare function findLatestScanReport(scanReportsDir: string, reportFilePrefix: string): string | null;
204
313
 
205
- interface ExportWithImports {
206
- name: string;
207
- type: 'function' | 'class' | 'const' | 'type' | 'interface' | 'default';
208
- imports: string[];
209
- dependencies: string[];
210
- typeReferences: string[];
211
- loc?: {
212
- start: {
213
- line: number;
214
- column: number;
215
- };
216
- end: {
217
- line: number;
218
- column: number;
219
- };
220
- };
221
- }
222
- interface FileImport {
223
- source: string;
224
- specifiers: string[];
225
- isTypeOnly: boolean;
314
+ /**
315
+ * Groups a flat array of issues by their `location.file` path into the
316
+ * `AnalysisResult[]` shape expected by `SpokeOutputSchema`.
317
+ *
318
+ * Shared across multiple spoke providers that follow the simple analyze → group
319
+ * → schema-parse pattern (doc-drift, deps, etc.).
320
+ */
321
+ declare function groupIssuesByFile(issues: any[]): AnalysisResult[];
322
+ /**
323
+ * Builds a simple `ToolScoringOutput` from a spoke summary object.
324
+ * Shared across providers whose scoring logic is purely pass-through
325
+ * (score and recommendations are already computed in the analyzer).
326
+ */
327
+ declare function buildSimpleProviderScore(toolName: string, summary: any, rawData?: any): ToolScoringOutput;
328
+ /**
329
+ * Builds and validates a `SpokeOutput` with common provider metadata.
330
+ * This removes repeated schema/metadata boilerplate from spoke providers.
331
+ */
332
+ declare function buildSpokeOutput(toolName: string, version: string, summary: any, results: AnalysisResult[], metadata?: Record<string, unknown>): SpokeOutput;
333
+ interface ProviderFactoryConfig<TReport> {
334
+ id: ToolName;
335
+ alias: string[];
336
+ version: string;
337
+ defaultWeight: number;
338
+ analyzeReport: (options: ScanOptions) => Promise<TReport>;
339
+ getResults: (report: TReport) => AnalysisResult[];
340
+ getSummary: (report: TReport) => any;
341
+ getMetadata?: (report: TReport) => Record<string, unknown>;
342
+ score: (output: SpokeOutput, options: ScanOptions) => ToolScoringOutput;
226
343
  }
227
344
  /**
228
- * Parse TypeScript/JavaScript file and extract exports with their import dependencies
345
+ * Creates a tool provider from shared analyze/score plumbing.
346
+ * Spokes only provide report adapters and scoring behavior.
347
+ */
348
+ declare function createProvider<TReport>(config: ProviderFactoryConfig<TReport>): ToolProvider;
349
+
350
+ /**
351
+ * Parse TypeScript/JavaScript file and extract exports with their import dependencies.
352
+ * Automatically handles different languages via the parser factory.
353
+ *
354
+ * @param code - The source code to parse
355
+ * @param filePath - Path to the file (used for language detection and AST metadata)
356
+ * @returns Object containing all identified exports and imports
229
357
  */
230
358
  declare function parseFileExports(code: string, filePath: string): {
231
359
  exports: ExportWithImports[];
232
360
  imports: FileImport[];
233
361
  };
234
362
  /**
235
- * Calculate import-based similarity between two exports (Jaccard index)
363
+ * Calculate import-based similarity between two exports using Jaccard index.
364
+ * Returns a score between 0 and 1 representing the overlap in imported symbols.
365
+ *
366
+ * @param export1 - First export to compare
367
+ * @param export2 - Second export to compare
368
+ * @returns Similarity score (0 = no overlap, 1 = identical imports)
236
369
  */
237
370
  declare function calculateImportSimilarity(export1: ExportWithImports, export2: ExportWithImports): number;
238
- interface ASTNode {
239
- type: string;
240
- loc?: {
241
- start: {
242
- line: number;
243
- column: number;
244
- };
245
- end: {
246
- line: number;
247
- column: number;
248
- };
249
- };
250
- }
371
+ /**
372
+ * Parse code into an AST node.
373
+ * @deprecated Use parseFileExports instead for full dependency analysis.
374
+ *
375
+ * @param code - Source code to parse
376
+ * @param language - Target language
377
+ * @returns Generic AST node or null if unsupported
378
+ */
251
379
  declare function parseCode(code: string, language: string): ASTNode | null;
380
+ /**
381
+ * Extract functions from an AST.
382
+ * @deprecated Use parseFileExports instead for complete export metadata.
383
+ *
384
+ * @param ast - The AST to scan
385
+ * @returns Array of function nodes
386
+ */
252
387
  declare function extractFunctions(ast: ASTNode): ASTNode[];
388
+ /**
389
+ * Extract imports from an AST.
390
+ * @deprecated Use parseFileExports instead for structured import info.
391
+ *
392
+ * @param ast - The AST to scan
393
+ * @returns Array of imported module names
394
+ */
253
395
  declare function extractImports(ast: ASTNode): string[];
254
396
 
255
397
  /**
@@ -258,7 +400,18 @@ declare function extractImports(ast: ASTNode): string[];
258
400
  */
259
401
  declare function estimateTokens(text: string): number;
260
402
 
403
+ /**
404
+ * Search upwards for AIReady configuration files and load the first one found.
405
+ * @param rootDir Starting directory for the search
406
+ * @returns Parsed configuration object or null if not found
407
+ */
261
408
  declare function loadConfig(rootDir: string): Promise<AIReadyConfig | null>;
409
+ /**
410
+ * Merge user-provided configuration with default settings.
411
+ * @param userConfig The configuration loaded from file
412
+ * @param defaults The default configuration object
413
+ * @returns Merged configuration with all defaults applied
414
+ */
262
415
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
263
416
 
264
417
  /**
@@ -386,27 +539,49 @@ declare function calculateComprehensionDifficulty(contextBudget: number, importD
386
539
  */
387
540
 
388
541
  /**
389
- * Historical score entry for trend tracking
542
+ * Historical score entry for trend tracking.
543
+ * Used to store and compare results across different points in time.
390
544
  */
391
545
  interface ScoreHistoryEntry {
546
+ /** ISO timestamp of the scan */
392
547
  timestamp: string;
548
+ /** Overall score (0-100) */
393
549
  overallScore: number;
550
+ /** Breakdown of scores by tool */
394
551
  breakdown: Record<string, number>;
552
+ /** Total number of issues detected */
395
553
  totalIssues: number;
554
+ /** Total tokens analyzed */
396
555
  totalTokens: number;
397
556
  }
398
557
  /**
399
- * Trend analysis comparing current vs historical scores
558
+ * Trend analysis comparing current vs historical scores.
559
+ * Helps teams understand if their AI-readiness is improving or degrading.
400
560
  */
401
561
  interface ScoreTrend {
562
+ /** Overall trend direction */
402
563
  direction: 'improving' | 'stable' | 'degrading';
564
+ /** Percentage change in score over last 30 days */
403
565
  change30Days: number;
566
+ /** Percentage change in score over last 90 days */
404
567
  change90Days: number;
568
+ /** Rate of change (points per week) */
405
569
  velocity: number;
570
+ /** Projected score in 30 days based on current velocity */
406
571
  projectedScore: number;
407
572
  }
408
573
  /**
409
- * Calculate Aggregate Business ROI
574
+ * Calculate Aggregate Business ROI from code analysis results.
575
+ *
576
+ * This high-level function combines token waste and productivity impact
577
+ * to produce a monthly and annual dollar value of the issues found.
578
+ *
579
+ * @param params - Parameters for ROI calculation
580
+ * @param params.tokenWaste - Estimated total tokens wasted on context inefficiencies
581
+ * @param params.issues - Array of issues with severity levels for productivity impact
582
+ * @param params.developerCount - Number of developers in the team (default: 5)
583
+ * @param params.modelId - AI model ID for pricing model selection (default: 'claude-4.6')
584
+ * @returns Business ROI metrics including savings and recommendations
410
585
  */
411
586
  declare function calculateBusinessROI(params: {
412
587
  tokenWaste: number;
@@ -416,25 +591,49 @@ declare function calculateBusinessROI(params: {
416
591
  developerCount?: number;
417
592
  modelId?: string;
418
593
  }): {
594
+ /** Estimated monthly savings if issues are resolved */
419
595
  monthlySavings: number;
596
+ /** Total developer hours gained per month */
420
597
  productivityGainHours: number;
598
+ /** Projected total annual business value gained */
421
599
  annualValue: number;
422
600
  };
423
601
  /**
424
- * Format cost for display
602
+ * Format currency value for display in console or reports.
603
+ *
604
+ * Handles small values with decimals and large values with 'k' suffix.
605
+ *
606
+ * @param cost Cost in USD
607
+ * @returns Formatted currency string (e.g. "$0.50", "$500", "$1.2k")
425
608
  */
426
609
  declare function formatCost(cost: number): string;
427
610
  /**
428
- * Format hours for display
611
+ * Format time duration in hours for display in console or reports.
612
+ *
613
+ * Automatically switches between minutes, hours, and weeks based on magnitude.
614
+ *
615
+ * @param hours Number of hours
616
+ * @returns Formatted duration string (e.g. "30min", "4.5h", "2.1 weeks")
429
617
  */
430
618
  declare function formatHours(hours: number): string;
431
619
 
432
620
  /**
433
- * Format acceptance rate for display
621
+ * Format AI acceptance rate as a human-readable percentage string.
622
+ * @param rate Rate value between 0 and 1
623
+ * @returns Formatted percentage (e.g. "85%")
434
624
  */
435
625
  declare function formatAcceptanceRate(rate: number): string;
436
626
  /**
437
- * Generate technical value chain for an issue (v0.12 legacy)
627
+ * Generate a technical value chain map for a specific issue category.
628
+ *
629
+ * maps technical metrics (like duplication count) to business outcomes
630
+ * by explaining the impact on AI models and developer workflow.
631
+ *
632
+ * @param params Issue information
633
+ * @param params.issueType Unique identifier for the issue type
634
+ * @param params.count Total occurrences of this issue
635
+ * @param params.severity Severity level of the issues
636
+ * @returns A structured technical value chain object
438
637
  */
439
638
  declare function generateValueChain(params: {
440
639
  issueType: string;
@@ -560,24 +759,43 @@ declare class TypeScriptParser implements LanguageParser {
560
759
  }
561
760
 
562
761
  /**
563
- * Python Parser implementation using tree-sitter
762
+ * Base Language Parser implementation to consolidate shared logic
564
763
  */
565
- declare class PythonParser implements LanguageParser {
566
- readonly language = Language.Python;
567
- readonly extensions: string[];
568
- private parser;
569
- private initialized;
764
+ declare abstract class BaseLanguageParser implements LanguageParser {
765
+ abstract readonly language: Language;
766
+ abstract readonly extensions: string[];
767
+ protected parser: Parser.Parser | null;
768
+ protected initialized: boolean;
570
769
  /**
571
770
  * Initialize the tree-sitter parser
572
771
  */
573
772
  initialize(): Promise<void>;
773
+ /**
774
+ * Get the parser name for tree-sitter setup
775
+ */
776
+ protected abstract getParserName(): string;
574
777
  getAST(code: string, filePath: string): Promise<Parser.Tree | null>;
575
- analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
778
+ abstract analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
576
779
  parse(code: string, filePath: string): ParseResult;
577
- private extractImportsAST;
578
- private extractExportsAST;
780
+ protected abstract extractImportsAST(rootNode: Parser.Node): ImportInfo[];
781
+ protected abstract extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
782
+ protected abstract parseRegex(code: string, filePath: string): ParseResult;
783
+ abstract getNamingConventions(): NamingConvention;
784
+ canHandle(filePath: string): boolean;
785
+ }
786
+
787
+ /**
788
+ * Python Parser implementation using tree-sitter
789
+ */
790
+ declare class PythonParser extends BaseLanguageParser {
791
+ readonly language = Language.Python;
792
+ readonly extensions: string[];
793
+ protected getParserName(): string;
794
+ analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
795
+ protected extractImportsAST(rootNode: Parser.Node): ImportInfo[];
796
+ protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
579
797
  private extractParameters;
580
- private parseRegex;
798
+ protected parseRegex(code: string, filePath: string): ParseResult;
581
799
  getNamingConventions(): NamingConvention;
582
800
  canHandle(filePath: string): boolean;
583
801
  private extractImportsRegex;
@@ -587,21 +805,14 @@ declare class PythonParser implements LanguageParser {
587
805
  /**
588
806
  * Java Parser implementation using tree-sitter
589
807
  */
590
- declare class JavaParser implements LanguageParser {
808
+ declare class JavaParser extends BaseLanguageParser {
591
809
  readonly language = Language.Java;
592
810
  readonly extensions: string[];
593
- private parser;
594
- private initialized;
595
- /**
596
- * Initialize the tree-sitter parser
597
- */
598
- initialize(): Promise<void>;
599
- getAST(code: string, filePath: string): Promise<Parser.Tree | null>;
811
+ protected getParserName(): string;
600
812
  analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
601
- parse(code: string, filePath: string): ParseResult;
602
- private parseRegex;
603
- private extractImportsAST;
604
- private extractExportsAST;
813
+ protected parseRegex(code: string, filePath: string): ParseResult;
814
+ protected extractImportsAST(rootNode: Parser.Node): ImportInfo[];
815
+ protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
605
816
  private getModifiers;
606
817
  private extractSubExports;
607
818
  private extractParameters;
@@ -612,21 +823,14 @@ declare class JavaParser implements LanguageParser {
612
823
  /**
613
824
  * C# Parser implementation using tree-sitter
614
825
  */
615
- declare class CSharpParser implements LanguageParser {
826
+ declare class CSharpParser extends BaseLanguageParser {
616
827
  readonly language = Language.CSharp;
617
828
  readonly extensions: string[];
618
- private parser;
619
- private initialized;
620
- /**
621
- * Initialize the tree-sitter parser
622
- */
623
- initialize(): Promise<void>;
624
- getAST(code: string, filePath: string): Promise<Parser.Tree | null>;
829
+ protected getParserName(): string;
625
830
  analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
626
- parse(code: string, filePath: string): ParseResult;
627
- private parseRegex;
628
- private extractImportsAST;
629
- private extractExportsAST;
831
+ protected parseRegex(code: string, filePath: string): ParseResult;
832
+ protected extractImportsAST(rootNode: Parser.Node): ImportInfo[];
833
+ protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
630
834
  private getModifiers;
631
835
  private extractParameters;
632
836
  getNamingConventions(): NamingConvention;
@@ -636,21 +840,14 @@ declare class CSharpParser implements LanguageParser {
636
840
  /**
637
841
  * Go Parser implementation using tree-sitter
638
842
  */
639
- declare class GoParser implements LanguageParser {
843
+ declare class GoParser extends BaseLanguageParser {
640
844
  readonly language = Language.Go;
641
845
  readonly extensions: string[];
642
- private parser;
643
- private initialized;
644
- /**
645
- * Initialize the tree-sitter parser
646
- */
647
- initialize(): Promise<void>;
648
- getAST(code: string, filePath: string): Promise<Parser.Tree | null>;
846
+ protected getParserName(): string;
649
847
  analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
650
- parse(code: string, filePath: string): ParseResult;
651
- private parseRegex;
652
- private extractImportsAST;
653
- private extractExportsAST;
848
+ protected parseRegex(code: string, filePath: string): ParseResult;
849
+ protected extractImportsAST(rootNode: Parser.Node): ImportInfo[];
850
+ protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
654
851
  private extractParameters;
655
852
  getNamingConventions(): NamingConvention;
656
853
  canHandle(filePath: string): boolean;
@@ -710,31 +907,64 @@ declare function calculateSemanticDistance(params: {
710
907
  * Structural Metrics
711
908
  * Measures pattern entropy and concept cohesion.
712
909
  */
910
+ /**
911
+ * Represents the entropy of patterns in a domain
912
+ */
713
913
  interface PatternEntropy {
914
+ /** Domain identifier */
714
915
  domain: string;
916
+ /** Entropy score (0-1) where higher mean more fragmented */
715
917
  entropy: number;
918
+ /** Human-readable structural rating */
716
919
  rating: 'crystalline' | 'well-structured' | 'moderate' | 'fragmented' | 'chaotic';
920
+ /** Distribution metrics */
717
921
  distribution: {
922
+ /** Number of distinct locations */
718
923
  locationCount: number;
924
+ /** Single most frequent location */
719
925
  dominantLocation: string;
926
+ /** Gini coefficient of concentration (0-1) */
720
927
  giniCoefficient: number;
721
928
  };
929
+ /** Recommendations for structural improvement */
722
930
  recommendations: string[];
723
931
  }
932
+ /**
933
+ * A file path with its inferred domain
934
+ */
724
935
  interface FileWithDomain {
725
936
  path: string;
726
937
  domain: string;
727
938
  }
939
+ /**
940
+ * Calculate pattern entropy (degree of fragmentation) for a set of files
941
+ * @param files Array of files with their domains
942
+ * @returns Entropy analysis result
943
+ */
728
944
  declare function calculatePatternEntropy(files: FileWithDomain[]): PatternEntropy;
945
+ /**
946
+ * Measures how focused a set of concepts is within a domain
947
+ */
729
948
  interface ConceptCohesion {
949
+ /** Normalized score (0-1) where 1 is perfect cohesion */
730
950
  score: number;
951
+ /** Human-readable rating */
731
952
  rating: 'excellent' | 'good' | 'moderate' | 'poor';
953
+ /** Detailed cohesion metrics */
732
954
  analysis: {
955
+ /** Number of distinct domains involved */
733
956
  uniqueDomains: number;
957
+ /** Percentage of exports belonging to the dominant domain */
734
958
  domainConcentration: number;
959
+ /** Ratio of unique domains to total exports */
735
960
  exportPurposeClarity: number;
736
961
  };
737
962
  }
963
+ /**
964
+ * Calculate concept cohesion for a set of exports
965
+ * @param params Object containing exports to analyze
966
+ * @returns Cohesion analysis result
967
+ */
738
968
  declare function calculateConceptCohesion(params: {
739
969
  exports: Array<{
740
970
  name: string;
@@ -747,20 +977,41 @@ declare function calculateConceptCohesion(params: {
747
977
  * AI Signal Clarity Metrics
748
978
  * Measures code patterns that increase the likelihood of AI generating incorrect code.
749
979
  */
980
+ /**
981
+ * Represents a single risk signal affecting AI clarity
982
+ */
750
983
  interface AiSignalClaritySignal {
984
+ /** Name of the signal */
751
985
  name: string;
986
+ /** Occurrences of this signal */
752
987
  count: number;
988
+ /** Numerical contribution to the risk score */
753
989
  riskContribution: number;
990
+ /** Human-readable description of the risk */
754
991
  description: string;
992
+ /** Examples of problematic patterns */
755
993
  examples?: string[];
756
994
  }
995
+ /**
996
+ * Complete AI Signal Clarity analysis result
997
+ */
757
998
  interface AiSignalClarity {
999
+ /** Normalized risk score (0-100) where higher means more confusion risk */
758
1000
  score: number;
1001
+ /** Human-readable risk rating */
759
1002
  rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
1003
+ /** Individual signals detected */
760
1004
  signals: AiSignalClaritySignal[];
1005
+ /** The single highest risk factor identified */
761
1006
  topRisk: string;
1007
+ /** Actionable recommendations to improve clarity */
762
1008
  recommendations: string[];
763
1009
  }
1010
+ /**
1011
+ * Calculate AI Signal Clarity metrics based on various code patterns
1012
+ * @param params Object containing counts of various problematic patterns
1013
+ * @returns Clarity analysis result
1014
+ */
764
1015
  declare function calculateAiSignalClarity(params: {
765
1016
  overloadedSymbols: number;
766
1017
  magicLiterals: number;
@@ -877,6 +1128,17 @@ declare function calculateDependencyHealth(params: {
877
1128
  trainingCutoffSkew: number;
878
1129
  }): DependencyHealthScore;
879
1130
 
1131
+ interface FutureProofRecommendationParams {
1132
+ cognitiveLoad: CognitiveLoad;
1133
+ patternEntropy: PatternEntropy;
1134
+ conceptCohesion: ConceptCohesion;
1135
+ aiSignalClarity: AiSignalClarity;
1136
+ agentGrounding: AgentGroundingScore;
1137
+ testability: TestabilityIndex;
1138
+ docDrift?: DocDriftRisk;
1139
+ dependencyHealth?: DependencyHealthScore;
1140
+ }
1141
+
880
1142
  /**
881
1143
  * Change Amplification Metrics
882
1144
  * Measures how a change in one file ripples through the system.
@@ -907,10 +1169,22 @@ declare function calculateChangeAmplification(params: {
907
1169
  *
908
1170
  * This module provides technology-agnostic metric primitives that will
909
1171
  * remain valid across changes in AI models, tokenization, and paradigms.
1172
+ *
1173
+ * It focuses on cognitive load, semantic cohesion, and structural entropy.
910
1174
  */
911
1175
 
912
1176
  /**
913
- * Aggregate Future-Proof Score (Base)
1177
+ * Calculate the Aggregate Future-Proof Score based on core structural metrics.
1178
+ *
1179
+ * Combines cognitive load, pattern entropy, and concept cohesion into a single
1180
+ * normalized score that predicts how well AI systems can handle this code in the long term.
1181
+ *
1182
+ * @param params - Configuration for score calculation
1183
+ * @param params.cognitiveLoad - Cognitive load metrics (file size, depth, fragmentation)
1184
+ * @param params.patternEntropy - Structural randomness vs consistency
1185
+ * @param params.conceptCohesion - Semantic alignment within logical blocks
1186
+ * @param params.semanticDistances - Optional measurements of conceptual drift
1187
+ * @returns ToolScoringOutput containing the final score and influencing factors
914
1188
  */
915
1189
  declare function calculateFutureProofScore(params: {
916
1190
  cognitiveLoad: CognitiveLoad;
@@ -919,17 +1193,15 @@ declare function calculateFutureProofScore(params: {
919
1193
  semanticDistances?: SemanticDistance[];
920
1194
  }): ToolScoringOutput;
921
1195
  /**
922
- * Complete Extended Future-Proof Score
1196
+ * Calculate a Comprehensive Extended Future-Proof Score.
1197
+ *
1198
+ * Incorporates secondary signals like documentation drift, dependency health,
1199
+ * and testability index to provide a holistic view of the repository's AI readiness.
1200
+ *
1201
+ * @param params - Comprehensive set of metric outputs
1202
+ * @returns ToolScoringOutput with extended analysis results
923
1203
  */
924
- declare function calculateExtendedFutureProofScore(params: {
925
- cognitiveLoad: CognitiveLoad;
926
- patternEntropy: PatternEntropy;
927
- conceptCohesion: ConceptCohesion;
928
- aiSignalClarity: AiSignalClarity;
929
- agentGrounding: AgentGroundingScore;
930
- testability: TestabilityIndex;
931
- docDrift?: DocDriftRisk;
932
- dependencyHealth?: DependencyHealthScore;
1204
+ declare function calculateExtendedFutureProofScore(params: FutureProofRecommendationParams & {
933
1205
  semanticDistances?: SemanticDistance[];
934
1206
  }): ToolScoringOutput;
935
1207
 
@@ -1012,4 +1284,4 @@ declare function severityToAnnotationLevel(severity: string): 'error' | 'warning
1012
1284
  */
1013
1285
  declare function emitIssuesAsAnnotations(issues: any[]): void;
1014
1286
 
1015
- export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, type CLIOptions, CSharpParser, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, ExportInfo, type ExportWithImports, type FileImport, type FileWithDomain, GoParser, JavaParser, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, SpokeOutput, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolName, type ToolProvider, ToolRegistry, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, emitAnnotation, emitIssuesAsAnnotations, emitProgress, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityColor, getSupportedLanguages, getWasmPath, handleCLIError, handleJSONOutput, initTreeSitter, initializeParsers, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, setupParser, severityToAnnotationLevel, validateSpokeOutput, validateWithSchema };
1287
+ export { AIReadyConfig, ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, AnalysisResult, type CLIOptions, CSharpParser, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, ExportInfo, ExportWithImports, FileImport, type FileWithDomain, GoParser, ImportInfo, JavaParser, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, type ProviderFactoryConfig, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, Severity, Severity as SeverityType, SpokeOutput, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolName, type ToolProvider, ToolRegistry, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, buildSimpleProviderScore, buildSpokeOutput, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, createProvider, emitAnnotation, emitIssuesAsAnnotations, emitProgress, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, findLatestReport, findLatestScanReport, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityBadge, getSeverityColor, getSeverityEnum, getSeverityLevel, getSeverityValue, getSupportedLanguages, getWasmPath, groupIssuesByFile, handleCLIError, handleJSONOutput, initTreeSitter, initializeParsers, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, setupParser, severityToAnnotationLevel, validateSpokeOutput, validateWithSchema };