@aiready/core 0.23.6 → 0.23.8
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/chunk-5SHLHMH7.mjs +760 -0
- package/dist/chunk-TJXR2CHZ.mjs +799 -0
- package/dist/client-BrIMPk89.d.mts +1214 -0
- package/dist/client-BrIMPk89.d.ts +1214 -0
- package/dist/client-C5BuGX4F.d.mts +1205 -0
- package/dist/client-C5BuGX4F.d.ts +1205 -0
- package/dist/client-CLulBnie.d.mts +1182 -0
- package/dist/client-CLulBnie.d.ts +1182 -0
- package/dist/client-CQwvp8ep.d.mts +1182 -0
- package/dist/client-CQwvp8ep.d.ts +1182 -0
- package/dist/client-PFPdeo-z.d.mts +1186 -0
- package/dist/client-PFPdeo-z.d.ts +1186 -0
- package/dist/client-wk2fgk1q.d.mts +1184 -0
- package/dist/client-wk2fgk1q.d.ts +1184 -0
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +42 -4
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +495 -149
- package/dist/index.d.ts +495 -149
- package/dist/index.js +507 -385
- package/dist/index.mjs +447 -364
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { T as ToolName, S as ScanOptions, a as SpokeOutput, b as ToolScoringOutput, c as Severity, A as AnalysisResult, E as ExportWithImports,
|
|
2
|
-
export {
|
|
1
|
+
import { T as ToolName, S as ScanOptions, a as SpokeOutput, b as ToolScoringOutput, c as ToolOptions, d as Severity, A as AnalysisResult, E as ExportWithImports, F as FileImport, e as AIReadyConfig, I as Issue, M as Metrics, f as ModelContextTier, C as CostConfig, g as TokenBudget, P as ProductivityImpact, h as AcceptancePrediction, i as ComprehensionDifficulty, j as TechnicalValueChainSummary, k as TechnicalValueChain, L as LanguageParser, l as Language, m as ParseResult, N as NamingConvention, n as ExportInfo } from './client-wk2fgk1q.mjs';
|
|
2
|
+
export { o as AIReadyConfigSchema, p as ASTNode, q as AnalysisResultSchema, r as AnalysisStatus, s as AnalysisStatusSchema, B as BusinessMetrics, t as COMMON_FINE_TUNING_OPTIONS, u as CONTEXT_TIER_THRESHOLDS, v as CommonASTNode, w as Config, D as DEFAULT_TOOL_WEIGHTS, x as FRIENDLY_TOOL_NAMES, y as FileContent, G as GLOBAL_INFRA_OPTIONS, z as GLOBAL_SCAN_OPTIONS, H as GraphData, J as GraphEdge, K as GraphIssueSeverity, O as GraphMetadata, Q as GraphNode, R as IssueSchema, U as IssueType, V as IssueTypeSchema, W as LANGUAGE_EXTENSIONS, X as LanguageConfig, Y as Lead, Z as LeadSchema, _ as LeadSource, $ as LeadSourceSchema, a0 as LeadSubmission, a1 as LeadSubmissionSchema, a2 as Location, a3 as LocationSchema, a4 as ManagedAccount, a5 as ManagedAccountSchema, a6 as MetricsSchema, a7 as ModelTier, a8 as ModelTierSchema, a9 as ParseError, aa as ParseStatistics, ab as ReadinessRating, ac as RecommendationPriority, ad as SCORING_PROFILES, ae as SIZE_ADJUSTED_THRESHOLDS, af as ScanResult, ag as ScoringConfig, ah as ScoringProfile, ai as ScoringResult, aj as SeveritySchema, ak as SourceLocation, al as SourceRange, am as SpokeOutputSchema, an as SpokeSummary, ao as SpokeSummarySchema, ap as TOOL_NAME_MAP, aq as ToolNameSchema, ar as ToolOutput, as as UnifiedReport, at as UnifiedReportSchema, au as calculateOverallScore, av as formatScore, aw as formatToolScore, ax as generateHTML, ay as getProjectSizeTier, az as getRating, aA as getRatingDisplay, aB as getRatingSlug, aC as getRatingWithContext, aD as getRecommendedThreshold, aE as getToolWeight, aF as normalizeToolName, aG as parseWeightString } from './client-wk2fgk1q.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as Parser from 'web-tree-sitter';
|
|
5
|
-
import { TSESTree } from '@typescript-eslint/typescript-estree';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Spoke-to-Hub Contract Definitions
|
|
@@ -29,13 +28,22 @@ interface ToolProvider {
|
|
|
29
28
|
/**
|
|
30
29
|
* Validation utility to ensure a spoke's output matches the expected contract.
|
|
31
30
|
* Used in spoke tests to catch breakages early.
|
|
31
|
+
*
|
|
32
|
+
* @param toolName - Name of the tool being validated.
|
|
33
|
+
* @param output - The raw output data to check.
|
|
34
|
+
* @returns Validation result with boolean flag and any errors found.
|
|
32
35
|
*/
|
|
33
36
|
declare function validateSpokeOutput(toolName: string, output: any): {
|
|
34
37
|
valid: boolean;
|
|
35
38
|
errors: string[];
|
|
36
39
|
};
|
|
37
40
|
/**
|
|
38
|
-
* Zod-based validation (Round 1 improvement)
|
|
41
|
+
* Zod-based validation (Round 1 improvement).
|
|
42
|
+
*
|
|
43
|
+
* @param schema - Zod schema to validate against.
|
|
44
|
+
* @param data - Raw data to parse.
|
|
45
|
+
* @returns Result object with valid flag and typed data or errors.
|
|
46
|
+
* @lastUpdated 2026-03-18
|
|
39
47
|
*/
|
|
40
48
|
declare function validateWithSchema<T>(schema: z.ZodSchema<T>, data: any): {
|
|
41
49
|
valid: boolean;
|
|
@@ -136,18 +144,19 @@ declare const DEFAULT_EXCLUDE: string[];
|
|
|
136
144
|
*/
|
|
137
145
|
declare const VAGUE_FILE_NAMES: Set<string>;
|
|
138
146
|
/**
|
|
139
|
-
* Scan files in a directory using glob patterns
|
|
140
|
-
*
|
|
141
|
-
* Note: This scanner supports multiple languages (.ts, .tsx, .js, .jsx, .py, .java, etc.)
|
|
142
|
-
* Individual tools can filter to their supported languages if needed.
|
|
147
|
+
* Scan files in a directory using glob patterns, respecting .aireadyignore and defaults.
|
|
143
148
|
*
|
|
144
|
-
* @param options - Scan configuration
|
|
145
|
-
* @returns Array of absolute file paths matching the patterns
|
|
149
|
+
* @param options - Scan configuration including rootDir, include/exclude, and includeTests.
|
|
150
|
+
* @returns Array of absolute file paths matching the patterns.
|
|
146
151
|
*/
|
|
147
152
|
declare function scanFiles(options: ScanOptions): Promise<string[]>;
|
|
148
153
|
/**
|
|
149
|
-
* Scan for both files and directories, respecting ignore rules.
|
|
154
|
+
* Scan for both files and directories, respecting ignore rules and .gitignore.
|
|
150
155
|
* Useful for tools that need to analyze directory structure.
|
|
156
|
+
*
|
|
157
|
+
* @param options - Scan configuration.
|
|
158
|
+
* @returns Object containing arrays of files and directories.
|
|
159
|
+
* @lastUpdated 2026-03-18
|
|
151
160
|
*/
|
|
152
161
|
declare function scanEntries(options: ScanOptions): Promise<{
|
|
153
162
|
files: string[];
|
|
@@ -191,32 +200,28 @@ declare function isSourceFile(filePath: string): boolean;
|
|
|
191
200
|
|
|
192
201
|
/**
|
|
193
202
|
* Common CLI configuration interface
|
|
203
|
+
* @deprecated Use ToolOptions from @aiready/core instead
|
|
194
204
|
*/
|
|
195
|
-
|
|
196
|
-
/** Root directory for analysis */
|
|
197
|
-
rootDir: string;
|
|
198
|
-
/** Glob patterns to include */
|
|
199
|
-
include?: string[];
|
|
200
|
-
/** Glob patterns to exclude */
|
|
201
|
-
exclude?: string[];
|
|
202
|
-
/** Any other tool-specific options */
|
|
203
|
-
[key: string]: any;
|
|
204
|
-
}
|
|
205
|
+
type CLIOptions = ToolOptions;
|
|
205
206
|
/**
|
|
206
|
-
* Resolve output file path, defaulting to .aiready directory
|
|
207
|
+
* Resolve output file path, defaulting to .aiready directory.
|
|
207
208
|
* Creates parent directories if they don't exist.
|
|
208
|
-
*
|
|
209
|
-
* @param
|
|
210
|
-
* @param
|
|
211
|
-
* @
|
|
209
|
+
*
|
|
210
|
+
* @param userPath - User-provided output path (optional).
|
|
211
|
+
* @param defaultFilename - Default filename to use.
|
|
212
|
+
* @param workingDir - Working directory (default: process.cwd()).
|
|
213
|
+
* @returns Resolved absolute path.
|
|
214
|
+
* @lastUpdated 2026-03-18
|
|
212
215
|
*/
|
|
213
216
|
declare function resolveOutputPath(userPath: string | undefined, defaultFilename: string, workingDir?: string): string;
|
|
214
217
|
/**
|
|
215
|
-
* Load and merge configuration with CLI options
|
|
216
|
-
*
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
219
|
-
* @
|
|
218
|
+
* Load and merge configuration with CLI options.
|
|
219
|
+
*
|
|
220
|
+
* @param directory - Root directory to load config from.
|
|
221
|
+
* @param defaults - Default configuration values.
|
|
222
|
+
* @param cliOptions - Configuration overrides from CLI arguments.
|
|
223
|
+
* @returns Merged configuration object.
|
|
224
|
+
* @lastUpdated 2026-03-18
|
|
220
225
|
*/
|
|
221
226
|
declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): Promise<T & {
|
|
222
227
|
rootDir: string;
|
|
@@ -224,34 +229,45 @@ declare function loadMergedConfig<T extends Record<string, any>>(directory: stri
|
|
|
224
229
|
/**
|
|
225
230
|
* Handle JSON output for CLI commands.
|
|
226
231
|
* Writes to file if outputFile is provided, otherwise logs to console.
|
|
227
|
-
*
|
|
228
|
-
* @param
|
|
229
|
-
* @param
|
|
232
|
+
*
|
|
233
|
+
* @param data - Data to output.
|
|
234
|
+
* @param outputFile - Optional path to save JSON file.
|
|
235
|
+
* @param successMessage - Optional message to show on success.
|
|
236
|
+
* @lastUpdated 2026-03-18
|
|
230
237
|
*/
|
|
231
238
|
declare function handleJSONOutput(data: any, outputFile?: string, successMessage?: string): void;
|
|
232
239
|
/**
|
|
233
240
|
* Common error handler for CLI commands.
|
|
234
241
|
* Logs error and exits process with code 1.
|
|
235
|
-
*
|
|
236
|
-
* @param
|
|
242
|
+
*
|
|
243
|
+
* @param error - Error object or message.
|
|
244
|
+
* @param commandName - Name of the command that failed.
|
|
245
|
+
* @returns Never returns as it exits the process.
|
|
246
|
+
* @lastUpdated 2026-03-18
|
|
237
247
|
*/
|
|
238
248
|
declare function handleCLIError(error: unknown, commandName: string): never;
|
|
239
249
|
/**
|
|
240
250
|
* Calculate elapsed time and format for display
|
|
241
|
-
*
|
|
242
|
-
* @
|
|
251
|
+
*
|
|
252
|
+
* @param startTime - Start timestamp in milliseconds.
|
|
253
|
+
* @returns Formatted duration string in seconds.
|
|
254
|
+
* @lastUpdated 2026-03-18
|
|
243
255
|
*/
|
|
244
256
|
declare function getElapsedTime(startTime: number): string;
|
|
245
257
|
/**
|
|
246
258
|
* Generate a visual score bar for console output
|
|
247
|
-
*
|
|
248
|
-
* @
|
|
259
|
+
*
|
|
260
|
+
* @param val - Score value between 0 and 100.
|
|
261
|
+
* @returns String representation of the bar (e.g., "█████░░░░░").
|
|
262
|
+
* @lastUpdated 2026-03-18
|
|
249
263
|
*/
|
|
250
264
|
declare function getScoreBar(val: number): string;
|
|
251
265
|
/**
|
|
252
266
|
* Get status icon for safety ratings
|
|
253
|
-
*
|
|
254
|
-
* @
|
|
267
|
+
*
|
|
268
|
+
* @param rating - The safety rating slug.
|
|
269
|
+
* @returns Emoji icon representing the rating.
|
|
270
|
+
* @lastUpdated 2026-03-18
|
|
255
271
|
*/
|
|
256
272
|
declare function getSafetyIcon(rating: string): string;
|
|
257
273
|
/**
|
|
@@ -266,9 +282,11 @@ declare function getSafetyIcon(rating: string): string;
|
|
|
266
282
|
declare function emitProgress(processed: number, total: number, toolId: string, message: string, onProgress?: (processed: number, total: number, message: string) => void, throttleCount?: number): void;
|
|
267
283
|
/**
|
|
268
284
|
* Get chalk color function for a given severity
|
|
269
|
-
*
|
|
270
|
-
* @param
|
|
271
|
-
* @
|
|
285
|
+
*
|
|
286
|
+
* @param severity - Severity level string.
|
|
287
|
+
* @param chalkInstance - Optional chalk instance to use.
|
|
288
|
+
* @returns Chalk color function.
|
|
289
|
+
* @lastUpdated 2026-03-18
|
|
272
290
|
*/
|
|
273
291
|
declare function getSeverityColor(severity: string, chalkInstance?: any): any;
|
|
274
292
|
/**
|
|
@@ -299,15 +317,19 @@ declare function getSeverityEnum(s: string | undefined): any;
|
|
|
299
317
|
/**
|
|
300
318
|
* Find the latest aiready report in a directory by modification time.
|
|
301
319
|
* Searches for both new format (aiready-report-*) and legacy format (aiready-scan-*).
|
|
302
|
-
*
|
|
303
|
-
* @
|
|
320
|
+
*
|
|
321
|
+
* @param dirPath - The directory path to search for .aiready directory.
|
|
322
|
+
* @returns The path to the latest report or null if not found.
|
|
323
|
+
* @lastUpdated 2026-03-18
|
|
304
324
|
*/
|
|
305
325
|
declare function findLatestReport(dirPath: string): string | null;
|
|
306
326
|
/**
|
|
307
327
|
* Find the latest scan report file with a specific prefix.
|
|
308
|
-
*
|
|
309
|
-
* @param
|
|
310
|
-
* @
|
|
328
|
+
*
|
|
329
|
+
* @param scanReportsDir - Directory containing reports.
|
|
330
|
+
* @param reportFilePrefix - Filename prefix to match (e.g. "report-").
|
|
331
|
+
* @returns Path to the latest matching report or null.
|
|
332
|
+
* @lastUpdated 2026-03-18
|
|
311
333
|
*/
|
|
312
334
|
declare function findLatestScanReport(scanReportsDir: string, reportFilePrefix: string): string | null;
|
|
313
335
|
|
|
@@ -320,14 +342,26 @@ declare function findLatestScanReport(scanReportsDir: string, reportFilePrefix:
|
|
|
320
342
|
*/
|
|
321
343
|
declare function groupIssuesByFile(issues: any[]): AnalysisResult[];
|
|
322
344
|
/**
|
|
323
|
-
* Builds a simple
|
|
345
|
+
* Builds a simple ToolScoringOutput from a spoke summary object.
|
|
324
346
|
* Shared across providers whose scoring logic is purely pass-through
|
|
325
347
|
* (score and recommendations are already computed in the analyzer).
|
|
348
|
+
*
|
|
349
|
+
* @param toolName - Identifier for the tool.
|
|
350
|
+
* @param summary - The tool's summary object containing score and recs.
|
|
351
|
+
* @param rawData - Additional raw metrics to include.
|
|
352
|
+
* @returns Standardized scoring output.
|
|
326
353
|
*/
|
|
327
354
|
declare function buildSimpleProviderScore(toolName: string, summary: any, rawData?: any): ToolScoringOutput;
|
|
328
355
|
/**
|
|
329
|
-
* Builds and validates a
|
|
356
|
+
* Builds and validates a SpokeOutput with common provider metadata.
|
|
330
357
|
* This removes repeated schema/metadata boilerplate from spoke providers.
|
|
358
|
+
*
|
|
359
|
+
* @param toolName - Identifier for the tool.
|
|
360
|
+
* @param version - Current version of the spoke.
|
|
361
|
+
* @param summary - Consolidated summary metrics.
|
|
362
|
+
* @param results - Array of file-level analysis results.
|
|
363
|
+
* @param metadata - Optional additional metadata.
|
|
364
|
+
* @returns Validated spoke output object.
|
|
331
365
|
*/
|
|
332
366
|
declare function buildSpokeOutput(toolName: string, version: string, summary: any, results: AnalysisResult[], metadata?: Record<string, unknown>): SpokeOutput;
|
|
333
367
|
interface ProviderFactoryConfig<TReport> {
|
|
@@ -344,21 +378,13 @@ interface ProviderFactoryConfig<TReport> {
|
|
|
344
378
|
/**
|
|
345
379
|
* Creates a tool provider from shared analyze/score plumbing.
|
|
346
380
|
* Spokes only provide report adapters and scoring behavior.
|
|
381
|
+
*
|
|
382
|
+
* @param config - Provider factory configuration with analyze/score logic.
|
|
383
|
+
* @returns A complete ToolProvider implementation.
|
|
384
|
+
* @lastUpdated 2026-03-18
|
|
347
385
|
*/
|
|
348
386
|
declare function createProvider<TReport>(config: ProviderFactoryConfig<TReport>): ToolProvider;
|
|
349
387
|
|
|
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
|
|
357
|
-
*/
|
|
358
|
-
declare function parseFileExports(code: string, filePath: string): {
|
|
359
|
-
exports: ExportWithImports[];
|
|
360
|
-
imports: FileImport[];
|
|
361
|
-
};
|
|
362
388
|
/**
|
|
363
389
|
* Calculate import-based similarity between two exports using Jaccard index.
|
|
364
390
|
* Returns a score between 0 and 1 representing the overlap in imported symbols.
|
|
@@ -368,31 +394,19 @@ declare function parseFileExports(code: string, filePath: string): {
|
|
|
368
394
|
* @returns Similarity score (0 = no overlap, 1 = identical imports)
|
|
369
395
|
*/
|
|
370
396
|
declare function calculateImportSimilarity(export1: ExportWithImports, export2: ExportWithImports): number;
|
|
397
|
+
|
|
371
398
|
/**
|
|
372
|
-
* Parse
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
* @param code - Source code to parse
|
|
376
|
-
* @param language - Target language
|
|
377
|
-
* @returns Generic AST node or null if unsupported
|
|
378
|
-
*/
|
|
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
|
-
*/
|
|
387
|
-
declare function extractFunctions(_ast: ASTNode): ASTNode[];
|
|
388
|
-
/**
|
|
389
|
-
* Extract imports from an AST.
|
|
390
|
-
* @deprecated Use parseFileExports instead for structured import info.
|
|
399
|
+
* Parse TypeScript/JavaScript file and extract exports with their import dependencies.
|
|
400
|
+
* Automatically handles different languages via the parser factory.
|
|
391
401
|
*
|
|
392
|
-
* @param
|
|
393
|
-
* @
|
|
402
|
+
* @param code - The source code to parse
|
|
403
|
+
* @param filePath - Path to the file (used for language detection and AST metadata)
|
|
404
|
+
* @returns Object containing all identified exports and imports
|
|
394
405
|
*/
|
|
395
|
-
declare function
|
|
406
|
+
declare function parseFileExports(code: string, filePath: string): {
|
|
407
|
+
exports: ExportWithImports[];
|
|
408
|
+
imports: FileImport[];
|
|
409
|
+
};
|
|
396
410
|
|
|
397
411
|
/**
|
|
398
412
|
* Estimate token count for text (rough approximation)
|
|
@@ -414,6 +428,23 @@ declare function loadConfig(rootDir: string): Promise<AIReadyConfig | null>;
|
|
|
414
428
|
*/
|
|
415
429
|
declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
|
|
416
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Normalizes raw issue data into a strict Issue object.
|
|
433
|
+
*/
|
|
434
|
+
declare function normalizeIssue(raw: any): Issue;
|
|
435
|
+
/**
|
|
436
|
+
* Normalizes raw metrics into a strict Metrics object.
|
|
437
|
+
*/
|
|
438
|
+
declare function normalizeMetrics(raw: any): Metrics;
|
|
439
|
+
/**
|
|
440
|
+
* Normalizes raw analysis result from any spoke into a strict AnalysisResult object.
|
|
441
|
+
*/
|
|
442
|
+
declare function normalizeAnalysisResult(raw: any): AnalysisResult;
|
|
443
|
+
/**
|
|
444
|
+
* Normalizes a full SpokeOutput.
|
|
445
|
+
*/
|
|
446
|
+
declare function normalizeSpokeOutput(raw: any, toolName: string): SpokeOutput;
|
|
447
|
+
|
|
417
448
|
/**
|
|
418
449
|
* AI model pricing presets for cost estimation.
|
|
419
450
|
* Prices are input token costs per 1K tokens (USD), as of Q1 2026.
|
|
@@ -533,9 +564,11 @@ declare function calculateTechnicalValueChain(params: {
|
|
|
533
564
|
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, modelTier?: ModelContextTier | string): ComprehensionDifficulty;
|
|
534
565
|
|
|
535
566
|
/**
|
|
536
|
-
* Business Value Metrics Module
|
|
567
|
+
* Business Value Metrics Module.
|
|
537
568
|
*
|
|
538
569
|
* Provides business-aligned metrics that quantify ROI and survive technology changes.
|
|
570
|
+
*
|
|
571
|
+
* @lastUpdated 2026-03-18
|
|
539
572
|
*/
|
|
540
573
|
|
|
541
574
|
/**
|
|
@@ -619,8 +652,9 @@ declare function formatHours(hours: number): string;
|
|
|
619
652
|
|
|
620
653
|
/**
|
|
621
654
|
* Format AI acceptance rate as a human-readable percentage string.
|
|
622
|
-
*
|
|
623
|
-
* @
|
|
655
|
+
*
|
|
656
|
+
* @param rate - Rate value between 0 and 1 (e.g. 0.85).
|
|
657
|
+
* @returns Formatted percentage string (e.g. "85%").
|
|
624
658
|
*/
|
|
625
659
|
declare function formatAcceptanceRate(rate: number): string;
|
|
626
660
|
/**
|
|
@@ -650,8 +684,9 @@ declare function generateValueChain(params: {
|
|
|
650
684
|
|
|
651
685
|
/**
|
|
652
686
|
* Factory for creating and managing language parsers.
|
|
653
|
-
*
|
|
654
687
|
* Supports both singleton usage and multiple instances for test isolation.
|
|
688
|
+
*
|
|
689
|
+
* @lastUpdated 2026-03-18
|
|
655
690
|
*/
|
|
656
691
|
declare class ParserFactory {
|
|
657
692
|
private static instance;
|
|
@@ -709,7 +744,11 @@ declare class ParserFactory {
|
|
|
709
744
|
initializeAll(): Promise<void>;
|
|
710
745
|
}
|
|
711
746
|
/**
|
|
712
|
-
* Convenience function to get parser for a file
|
|
747
|
+
* Convenience function to get parser for a file.
|
|
748
|
+
*
|
|
749
|
+
* @param filePath - Path to the file to get a parser for.
|
|
750
|
+
* @returns LanguageParser instance or null if unsupported.
|
|
751
|
+
* @lastUpdated 2026-03-18
|
|
713
752
|
*/
|
|
714
753
|
declare function getParser(filePath: string): LanguageParser | null;
|
|
715
754
|
/**
|
|
@@ -717,7 +756,11 @@ declare function getParser(filePath: string): LanguageParser | null;
|
|
|
717
756
|
*/
|
|
718
757
|
declare function initializeParsers(): Promise<void>;
|
|
719
758
|
/**
|
|
720
|
-
* Convenience function to check if file is supported
|
|
759
|
+
* Convenience function to check if file is supported.
|
|
760
|
+
*
|
|
761
|
+
* @param filePath - Path to the file to check.
|
|
762
|
+
* @returns True if the file extension is supported.
|
|
763
|
+
* @lastUpdated 2026-03-18
|
|
721
764
|
*/
|
|
722
765
|
declare function isFileSupported(filePath: string): boolean;
|
|
723
766
|
/**
|
|
@@ -726,15 +769,21 @@ declare function isFileSupported(filePath: string): boolean;
|
|
|
726
769
|
declare function getSupportedLanguages(): Language[];
|
|
727
770
|
|
|
728
771
|
/**
|
|
729
|
-
* Initialize tree-sitter once
|
|
772
|
+
* Initialize tree-sitter once.
|
|
773
|
+
*
|
|
774
|
+
* @lastUpdated 2026-03-18
|
|
730
775
|
*/
|
|
731
776
|
declare function initTreeSitter(): Promise<void>;
|
|
732
777
|
/**
|
|
733
|
-
* Find a WASM file for a specific language
|
|
778
|
+
* Find a WASM file for a specific language.
|
|
779
|
+
*
|
|
780
|
+
* @lastUpdated 2026-03-18
|
|
734
781
|
*/
|
|
735
782
|
declare function getWasmPath(language: string): string | null;
|
|
736
783
|
/**
|
|
737
|
-
* Load a language and return a configured parser
|
|
784
|
+
* Load a language and return a configured parser.
|
|
785
|
+
*
|
|
786
|
+
* @lastUpdated 2026-03-18
|
|
738
787
|
*/
|
|
739
788
|
declare function setupParser(language: string): Promise<Parser.Parser | null>;
|
|
740
789
|
|
|
@@ -748,14 +797,16 @@ declare class TypeScriptParser implements LanguageParser {
|
|
|
748
797
|
readonly language = Language.TypeScript;
|
|
749
798
|
readonly extensions: string[];
|
|
750
799
|
initialize(): Promise<void>;
|
|
751
|
-
|
|
752
|
-
|
|
800
|
+
canHandle(filePath: string): boolean;
|
|
801
|
+
getAST(code: string, filePath: string): Promise<any>;
|
|
753
802
|
parse(code: string, filePath: string): ParseResult;
|
|
754
803
|
getNamingConventions(): NamingConvention;
|
|
755
|
-
|
|
804
|
+
analyzeMetadata(node: any, code: string): Partial<ExportInfo>;
|
|
756
805
|
private extractImports;
|
|
757
806
|
private extractExports;
|
|
758
|
-
private
|
|
807
|
+
private createExport;
|
|
808
|
+
private extractDocumentation;
|
|
809
|
+
private isLikelyPure;
|
|
759
810
|
}
|
|
760
811
|
|
|
761
812
|
/**
|
|
@@ -777,7 +828,7 @@ declare abstract class BaseLanguageParser implements LanguageParser {
|
|
|
777
828
|
getAST(code: string, _filePath?: string): Promise<Parser.Tree | null>;
|
|
778
829
|
abstract analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
|
|
779
830
|
parse(code: string, filePath: string): ParseResult;
|
|
780
|
-
protected abstract extractImportsAST(rootNode: Parser.Node):
|
|
831
|
+
protected abstract extractImportsAST(rootNode: Parser.Node): FileImport[];
|
|
781
832
|
protected abstract extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
|
|
782
833
|
protected abstract parseRegex(code: string, filePath: string): ParseResult;
|
|
783
834
|
abstract getNamingConventions(): NamingConvention;
|
|
@@ -785,16 +836,52 @@ declare abstract class BaseLanguageParser implements LanguageParser {
|
|
|
785
836
|
}
|
|
786
837
|
|
|
787
838
|
/**
|
|
788
|
-
* Python Parser implementation using tree-sitter
|
|
839
|
+
* Python Parser implementation using tree-sitter.
|
|
840
|
+
* Handles AST-based and Regex-based extraction of imports and exports.
|
|
841
|
+
*
|
|
842
|
+
* @lastUpdated 2026-03-18
|
|
789
843
|
*/
|
|
790
844
|
declare class PythonParser extends BaseLanguageParser {
|
|
791
845
|
readonly language = Language.Python;
|
|
792
846
|
readonly extensions: string[];
|
|
793
847
|
protected getParserName(): string;
|
|
848
|
+
/**
|
|
849
|
+
* Analyze metadata for a Python node (purity, side effects).
|
|
850
|
+
*
|
|
851
|
+
* @param node - Tree-sitter node to analyze.
|
|
852
|
+
* @param code - Source code for context.
|
|
853
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
854
|
+
*/
|
|
794
855
|
analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
|
|
795
|
-
|
|
856
|
+
/**
|
|
857
|
+
* Extract import information using AST walk.
|
|
858
|
+
*
|
|
859
|
+
* @param rootNode - Root node of the Python AST.
|
|
860
|
+
* @returns Array of discovered FileImport objects.
|
|
861
|
+
*/
|
|
862
|
+
protected extractImportsAST(rootNode: Parser.Node): FileImport[];
|
|
863
|
+
/**
|
|
864
|
+
* Extract export information using AST walk.
|
|
865
|
+
*
|
|
866
|
+
* @param rootNode - Root node of the Python AST.
|
|
867
|
+
* @param code - Source code for documentation extraction.
|
|
868
|
+
* @returns Array of discovered ExportInfo objects.
|
|
869
|
+
*/
|
|
796
870
|
protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
|
|
871
|
+
/**
|
|
872
|
+
* Extract parameter names from a function definition node.
|
|
873
|
+
*
|
|
874
|
+
* @param node - Function definition node.
|
|
875
|
+
* @returns Array of parameter name strings.
|
|
876
|
+
*/
|
|
797
877
|
private extractParameters;
|
|
878
|
+
/**
|
|
879
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
880
|
+
*
|
|
881
|
+
* @param code - Source code content.
|
|
882
|
+
* @param filePath - Path to the file being parsed.
|
|
883
|
+
* @returns Consolidated ParseResult.
|
|
884
|
+
*/
|
|
798
885
|
protected parseRegex(code: string, filePath: string): ParseResult;
|
|
799
886
|
getNamingConventions(): NamingConvention;
|
|
800
887
|
canHandle(filePath: string): boolean;
|
|
@@ -803,17 +890,54 @@ declare class PythonParser extends BaseLanguageParser {
|
|
|
803
890
|
}
|
|
804
891
|
|
|
805
892
|
/**
|
|
806
|
-
* Java Parser implementation using tree-sitter
|
|
893
|
+
* Java Parser implementation using tree-sitter.
|
|
894
|
+
* Supports AST-based and Regex-based extraction of class and method metadata.
|
|
895
|
+
*
|
|
896
|
+
* @lastUpdated 2026-03-18
|
|
807
897
|
*/
|
|
808
898
|
declare class JavaParser extends BaseLanguageParser {
|
|
809
899
|
readonly language = Language.Java;
|
|
810
900
|
readonly extensions: string[];
|
|
811
901
|
protected getParserName(): string;
|
|
902
|
+
/**
|
|
903
|
+
* Analyze metadata for a Java node (purity, side effects).
|
|
904
|
+
*
|
|
905
|
+
* @param node - Tree-sitter node to analyze.
|
|
906
|
+
* @param code - Source code for context.
|
|
907
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
908
|
+
*/
|
|
812
909
|
analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
|
|
813
910
|
protected parseRegex(code: string): ParseResult;
|
|
814
|
-
|
|
911
|
+
/**
|
|
912
|
+
* Extract import information using AST walk.
|
|
913
|
+
*
|
|
914
|
+
* @param rootNode - Root node of the Java AST.
|
|
915
|
+
* @returns Array of discovered FileImport objects.
|
|
916
|
+
*/
|
|
917
|
+
protected extractImportsAST(rootNode: Parser.Node): FileImport[];
|
|
918
|
+
/**
|
|
919
|
+
* Extract export information (classes, interfaces, methods) using AST walk.
|
|
920
|
+
*
|
|
921
|
+
* @param rootNode - Root node of the Java AST.
|
|
922
|
+
* @param code - Source code for documentation extraction.
|
|
923
|
+
* @returns Array of discovered ExportInfo objects.
|
|
924
|
+
*/
|
|
815
925
|
protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
|
|
926
|
+
/**
|
|
927
|
+
* Extract modifiers (visibility, static, etc.) from a node.
|
|
928
|
+
*
|
|
929
|
+
* @param node - AST node to extract modifiers from.
|
|
930
|
+
* @returns Array of modifier strings.
|
|
931
|
+
*/
|
|
816
932
|
private getModifiers;
|
|
933
|
+
/**
|
|
934
|
+
* Extract methods and nested exports from a class or interface body.
|
|
935
|
+
*
|
|
936
|
+
* @param parentNode - Class or interface declaration node.
|
|
937
|
+
* @param parentName - Name of the parent class/interface.
|
|
938
|
+
* @param exports - Array to collect discovered exports into.
|
|
939
|
+
* @param code - Source code for context.
|
|
940
|
+
*/
|
|
817
941
|
private extractSubExports;
|
|
818
942
|
private extractParameters;
|
|
819
943
|
getNamingConventions(): NamingConvention;
|
|
@@ -821,15 +945,45 @@ declare class JavaParser extends BaseLanguageParser {
|
|
|
821
945
|
}
|
|
822
946
|
|
|
823
947
|
/**
|
|
824
|
-
* C# Parser implementation using tree-sitter
|
|
948
|
+
* C# Parser implementation using tree-sitter.
|
|
949
|
+
* Supports AST-based and Regex-based extraction of namespace-scoped classes and methods.
|
|
950
|
+
*
|
|
951
|
+
* @lastUpdated 2026-03-18
|
|
825
952
|
*/
|
|
826
953
|
declare class CSharpParser extends BaseLanguageParser {
|
|
827
954
|
readonly language = Language.CSharp;
|
|
828
955
|
readonly extensions: string[];
|
|
829
956
|
protected getParserName(): string;
|
|
957
|
+
/**
|
|
958
|
+
* Analyze metadata for a C# node (purity, side effects).
|
|
959
|
+
*
|
|
960
|
+
* @param node - Tree-sitter node to analyze.
|
|
961
|
+
* @param code - Source code for context.
|
|
962
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
963
|
+
*/
|
|
830
964
|
analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
|
|
965
|
+
/**
|
|
966
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
967
|
+
*
|
|
968
|
+
* @param code - Source code content.
|
|
969
|
+
* @returns Consolidated ParseResult.
|
|
970
|
+
*/
|
|
831
971
|
protected parseRegex(code: string): ParseResult;
|
|
832
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Extract import information (usings) using AST walk.
|
|
974
|
+
*
|
|
975
|
+
* @param rootNode - Root node of the C# AST.
|
|
976
|
+
* @returns Array of discovered FileImport objects.
|
|
977
|
+
*/
|
|
978
|
+
protected extractImportsAST(rootNode: Parser.Node): FileImport[];
|
|
979
|
+
/**
|
|
980
|
+
* Extract export information (classes, methods, properties) using AST walk.
|
|
981
|
+
* Handles nested namespaces and classes.
|
|
982
|
+
*
|
|
983
|
+
* @param rootNode - Root node of the C# AST.
|
|
984
|
+
* @param code - Source code for documentation extraction.
|
|
985
|
+
* @returns Array of discovered ExportInfo objects.
|
|
986
|
+
*/
|
|
833
987
|
protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
|
|
834
988
|
private getModifiers;
|
|
835
989
|
private extractParameters;
|
|
@@ -838,15 +992,44 @@ declare class CSharpParser extends BaseLanguageParser {
|
|
|
838
992
|
}
|
|
839
993
|
|
|
840
994
|
/**
|
|
841
|
-
* Go Parser implementation using tree-sitter
|
|
995
|
+
* Go Parser implementation using tree-sitter.
|
|
996
|
+
* Handles AST-based and Regex-based extraction of functions and types.
|
|
997
|
+
*
|
|
998
|
+
* @lastUpdated 2026-03-18
|
|
842
999
|
*/
|
|
843
1000
|
declare class GoParser extends BaseLanguageParser {
|
|
844
1001
|
readonly language = Language.Go;
|
|
845
1002
|
readonly extensions: string[];
|
|
846
1003
|
protected getParserName(): string;
|
|
1004
|
+
/**
|
|
1005
|
+
* Analyze metadata for a Go node (purity, side effects).
|
|
1006
|
+
*
|
|
1007
|
+
* @param node - Tree-sitter node to analyze.
|
|
1008
|
+
* @param code - Source code for context.
|
|
1009
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
1010
|
+
*/
|
|
847
1011
|
analyzeMetadata(node: Parser.Node, code: string): Partial<ExportInfo>;
|
|
1012
|
+
/**
|
|
1013
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
1014
|
+
*
|
|
1015
|
+
* @param code - Source code content.
|
|
1016
|
+
* @returns Consolidated ParseResult.
|
|
1017
|
+
*/
|
|
848
1018
|
protected parseRegex(code: string): ParseResult;
|
|
849
|
-
|
|
1019
|
+
/**
|
|
1020
|
+
* Extract import information using AST walk.
|
|
1021
|
+
*
|
|
1022
|
+
* @param rootNode - Root node of the Go AST.
|
|
1023
|
+
* @returns Array of discovered FileImport objects.
|
|
1024
|
+
*/
|
|
1025
|
+
protected extractImportsAST(rootNode: Parser.Node): FileImport[];
|
|
1026
|
+
/**
|
|
1027
|
+
* Extract export information (functions, types, vars) using AST walk.
|
|
1028
|
+
*
|
|
1029
|
+
* @param rootNode - Root node of the Go AST.
|
|
1030
|
+
* @param code - Source code for documentation extraction.
|
|
1031
|
+
* @returns Array of discovered ExportInfo objects.
|
|
1032
|
+
*/
|
|
850
1033
|
protected extractExportsAST(rootNode: Parser.Node, code: string): ExportInfo[];
|
|
851
1034
|
private extractParameters;
|
|
852
1035
|
getNamingConventions(): NamingConvention;
|
|
@@ -854,8 +1037,13 @@ declare class GoParser extends BaseLanguageParser {
|
|
|
854
1037
|
}
|
|
855
1038
|
|
|
856
1039
|
/**
|
|
857
|
-
* Cognitive Load Metrics
|
|
1040
|
+
* Cognitive Load Metrics.
|
|
858
1041
|
* Measures how much mental effort is required for an AI to understand a file.
|
|
1042
|
+
*
|
|
1043
|
+
* @lastUpdated 2026-03-18
|
|
1044
|
+
*/
|
|
1045
|
+
/**
|
|
1046
|
+
* Individual factor contributing to total cognitive load.
|
|
859
1047
|
*/
|
|
860
1048
|
interface LoadFactor {
|
|
861
1049
|
name: string;
|
|
@@ -863,6 +1051,9 @@ interface LoadFactor {
|
|
|
863
1051
|
weight: number;
|
|
864
1052
|
description: string;
|
|
865
1053
|
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Consolidated Cognitive Load measurement for a source file.
|
|
1056
|
+
*/
|
|
866
1057
|
interface CognitiveLoad {
|
|
867
1058
|
score: number;
|
|
868
1059
|
rating: 'trivial' | 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
@@ -874,6 +1065,17 @@ interface CognitiveLoad {
|
|
|
874
1065
|
conceptCount: number;
|
|
875
1066
|
};
|
|
876
1067
|
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Calculate the Cognitive Load for a file based on its structural properties.
|
|
1070
|
+
*
|
|
1071
|
+
* @param params - Metrics gathered from parsing the file.
|
|
1072
|
+
* @param params.linesOfCode - Number of lines of code.
|
|
1073
|
+
* @param params.exportCount - Number of public exports.
|
|
1074
|
+
* @param params.importCount - Number of external dependencies.
|
|
1075
|
+
* @param params.uniqueConcepts - Number of unique semantic concepts.
|
|
1076
|
+
* @param params.cyclomaticComplexity - Optional complexity score.
|
|
1077
|
+
* @returns Comprehensive CognitiveLoad analysis.
|
|
1078
|
+
*/
|
|
877
1079
|
declare function calculateCognitiveLoad(params: {
|
|
878
1080
|
linesOfCode: number;
|
|
879
1081
|
exportCount: number;
|
|
@@ -883,8 +1085,10 @@ declare function calculateCognitiveLoad(params: {
|
|
|
883
1085
|
}): CognitiveLoad;
|
|
884
1086
|
|
|
885
1087
|
/**
|
|
886
|
-
* Semantic Distance Metrics
|
|
887
|
-
* Measures the conceptual distance between files or domains.
|
|
1088
|
+
* Semantic Distance Metrics.
|
|
1089
|
+
* Measures the conceptual distance between files or domains using import overlap.
|
|
1090
|
+
*
|
|
1091
|
+
* @lastUpdated 2026-03-18
|
|
888
1092
|
*/
|
|
889
1093
|
interface SemanticDistance {
|
|
890
1094
|
between: [string, string];
|
|
@@ -893,6 +1097,19 @@ interface SemanticDistance {
|
|
|
893
1097
|
path: string[];
|
|
894
1098
|
reason: string;
|
|
895
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Calculate the semantic distance between two files based on domain and dependency overlap.
|
|
1102
|
+
*
|
|
1103
|
+
* @param params - Comparison parameters.
|
|
1104
|
+
* @param params.file1 - Path to the first file.
|
|
1105
|
+
* @param params.file2 - Path to the second file.
|
|
1106
|
+
* @param params.file1Domain - Logical domain of the first file.
|
|
1107
|
+
* @param params.file2Domain - Logical domain of the second file.
|
|
1108
|
+
* @param params.file1Imports - Set of imports in the first file.
|
|
1109
|
+
* @param params.file2Imports - Set of imports in the second file.
|
|
1110
|
+
* @param params.sharedDependencies - Intersection of imports between both files.
|
|
1111
|
+
* @returns Calculated semantic distance and relationship assessment.
|
|
1112
|
+
*/
|
|
896
1113
|
declare function calculateSemanticDistance(params: {
|
|
897
1114
|
file1: string;
|
|
898
1115
|
file2: string;
|
|
@@ -904,8 +1121,10 @@ declare function calculateSemanticDistance(params: {
|
|
|
904
1121
|
}): SemanticDistance;
|
|
905
1122
|
|
|
906
1123
|
/**
|
|
907
|
-
* Structural Metrics
|
|
1124
|
+
* Structural Metrics.
|
|
908
1125
|
* Measures pattern entropy and concept cohesion.
|
|
1126
|
+
*
|
|
1127
|
+
* @lastUpdated 2026-03-18
|
|
909
1128
|
*/
|
|
910
1129
|
/**
|
|
911
1130
|
* Represents the entropy of patterns in a domain
|
|
@@ -932,8 +1151,13 @@ interface PatternEntropy {
|
|
|
932
1151
|
/**
|
|
933
1152
|
* A file path with its inferred domain
|
|
934
1153
|
*/
|
|
1154
|
+
/**
|
|
1155
|
+
* Represents a file path associated with its inferred domain.
|
|
1156
|
+
*/
|
|
935
1157
|
interface FileWithDomain {
|
|
1158
|
+
/** Relative or absolute path to the file. */
|
|
936
1159
|
path: string;
|
|
1160
|
+
/** Logical domain the file belongs to (e.g., "auth", "api"). */
|
|
937
1161
|
domain: string;
|
|
938
1162
|
}
|
|
939
1163
|
/**
|
|
@@ -943,20 +1167,21 @@ interface FileWithDomain {
|
|
|
943
1167
|
*/
|
|
944
1168
|
declare function calculatePatternEntropy(files: FileWithDomain[]): PatternEntropy;
|
|
945
1169
|
/**
|
|
946
|
-
* Measures how focused a set of concepts is within a domain
|
|
1170
|
+
* Measures how focused a set of concepts is within a domain.
|
|
1171
|
+
* Higher cohesion indicates better semantic alignment.
|
|
947
1172
|
*/
|
|
948
1173
|
interface ConceptCohesion {
|
|
949
|
-
/** Normalized score (0-1) where 1 is perfect cohesion */
|
|
1174
|
+
/** Normalized score (0-1) where 1 is perfect cohesion. */
|
|
950
1175
|
score: number;
|
|
951
|
-
/** Human-readable rating */
|
|
1176
|
+
/** Human-readable rating. */
|
|
952
1177
|
rating: 'excellent' | 'good' | 'moderate' | 'poor';
|
|
953
|
-
/** Detailed cohesion metrics */
|
|
1178
|
+
/** Detailed cohesion metrics. */
|
|
954
1179
|
analysis: {
|
|
955
|
-
/** Number of distinct domains involved */
|
|
1180
|
+
/** Number of distinct domains involved. */
|
|
956
1181
|
uniqueDomains: number;
|
|
957
|
-
/** Percentage of exports belonging to the dominant domain */
|
|
1182
|
+
/** Percentage of exports belonging to the dominant domain. */
|
|
958
1183
|
domainConcentration: number;
|
|
959
|
-
/** Ratio of unique domains to total exports */
|
|
1184
|
+
/** Ratio of unique domains to total exports. */
|
|
960
1185
|
exportPurposeClarity: number;
|
|
961
1186
|
};
|
|
962
1187
|
}
|
|
@@ -974,8 +1199,10 @@ declare function calculateConceptCohesion(params: {
|
|
|
974
1199
|
}): ConceptCohesion;
|
|
975
1200
|
|
|
976
1201
|
/**
|
|
977
|
-
* AI Signal Clarity Metrics
|
|
1202
|
+
* AI Signal Clarity Metrics.
|
|
978
1203
|
* Measures code patterns that increase the likelihood of AI generating incorrect code.
|
|
1204
|
+
*
|
|
1205
|
+
* @lastUpdated 2026-03-18
|
|
979
1206
|
*/
|
|
980
1207
|
/**
|
|
981
1208
|
* Represents a single risk signal affecting AI clarity
|
|
@@ -1008,9 +1235,20 @@ interface AiSignalClarity {
|
|
|
1008
1235
|
recommendations: string[];
|
|
1009
1236
|
}
|
|
1010
1237
|
/**
|
|
1011
|
-
* Calculate AI Signal Clarity metrics based on various code patterns
|
|
1012
|
-
*
|
|
1013
|
-
* @
|
|
1238
|
+
* Calculate AI Signal Clarity metrics based on various documented and undocumented code patterns.
|
|
1239
|
+
*
|
|
1240
|
+
* @param params - Counts of various problematic or beneficial patterns detected during scanning.
|
|
1241
|
+
* @param params.overloadedSymbols - Count of symbols with identical names in different scopes.
|
|
1242
|
+
* @param params.magicLiterals - Count of unnamed constant values.
|
|
1243
|
+
* @param params.booleanTraps - Count of functions with multiple boolean parameters.
|
|
1244
|
+
* @param params.implicitSideEffects - Count of functions with undocumented side effects.
|
|
1245
|
+
* @param params.deepCallbacks - Count of nested callback structures.
|
|
1246
|
+
* @param params.ambiguousNames - Count of non-descriptive identifiers (e.g., 'data', 'info').
|
|
1247
|
+
* @param params.undocumentedExports - Count of public exports missing JSDoc/docstrings.
|
|
1248
|
+
* @param params.largeFiles - Optional count of files exceeding size limits.
|
|
1249
|
+
* @param params.totalSymbols - Total number of symbols analyzed.
|
|
1250
|
+
* @param params.totalExports - Total number of public exports analyzed.
|
|
1251
|
+
* @returns Comprehensive AiSignalClarity analysis.
|
|
1014
1252
|
*/
|
|
1015
1253
|
declare function calculateAiSignalClarity(params: {
|
|
1016
1254
|
overloadedSymbols: number;
|
|
@@ -1026,8 +1264,10 @@ declare function calculateAiSignalClarity(params: {
|
|
|
1026
1264
|
}): AiSignalClarity;
|
|
1027
1265
|
|
|
1028
1266
|
/**
|
|
1029
|
-
* Agent Grounding Metrics
|
|
1030
|
-
* Measures how well an AI agent can navigate a codebase independently.
|
|
1267
|
+
* Agent Grounding Metrics.
|
|
1268
|
+
* Measures how well an AI agent can navigate and understand a codebase independently.
|
|
1269
|
+
*
|
|
1270
|
+
* @lastUpdated 2026-03-18
|
|
1031
1271
|
*/
|
|
1032
1272
|
interface AgentGroundingScore {
|
|
1033
1273
|
score: number;
|
|
@@ -1041,6 +1281,23 @@ interface AgentGroundingScore {
|
|
|
1041
1281
|
};
|
|
1042
1282
|
recommendations: string[];
|
|
1043
1283
|
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Calculate Agent Grounding metrics based on repository structure and documentation quality.
|
|
1286
|
+
*
|
|
1287
|
+
* @param params - Structural and documentation metrics gathered during scanning.
|
|
1288
|
+
* @param params.deepDirectories - Count of directories nested deeper than recommended.
|
|
1289
|
+
* @param params.totalDirectories - Total number of directories analyzed.
|
|
1290
|
+
* @param params.vagueFileNames - Count of files with non-descriptive names.
|
|
1291
|
+
* @param params.totalFiles - Total number of files analyzed.
|
|
1292
|
+
* @param params.hasRootReadme - Whether a README exists in the repository root.
|
|
1293
|
+
* @param params.readmeIsFresh - Whether the root README has been updated recently.
|
|
1294
|
+
* @param params.barrelExports - Count of 'index' files providing consolidated exports.
|
|
1295
|
+
* @param params.untypedExports - Count of exports missing explicit type annotations.
|
|
1296
|
+
* @param params.totalExports - Total number of public exports analyzed.
|
|
1297
|
+
* @param params.inconsistentDomainTerms - Count of terms that conflict with the domain vocabulary.
|
|
1298
|
+
* @param params.domainVocabularySize - Total number of unique domain terms identified.
|
|
1299
|
+
* @returns Comprehensive AgentGroundingScore.
|
|
1300
|
+
*/
|
|
1044
1301
|
declare function calculateAgentGrounding(params: {
|
|
1045
1302
|
deepDirectories: number;
|
|
1046
1303
|
totalDirectories: number;
|
|
@@ -1056,8 +1313,10 @@ declare function calculateAgentGrounding(params: {
|
|
|
1056
1313
|
}): AgentGroundingScore;
|
|
1057
1314
|
|
|
1058
1315
|
/**
|
|
1059
|
-
* Testability Index Metrics
|
|
1060
|
-
* Measures how verifiable AI-generated changes are.
|
|
1316
|
+
* Testability Index Metrics.
|
|
1317
|
+
* Measures how verifiable AI-generated changes are based on local testing infrastructure.
|
|
1318
|
+
*
|
|
1319
|
+
* @lastUpdated 2026-03-18
|
|
1061
1320
|
*/
|
|
1062
1321
|
interface TestabilityIndex {
|
|
1063
1322
|
score: number;
|
|
@@ -1072,6 +1331,22 @@ interface TestabilityIndex {
|
|
|
1072
1331
|
aiChangeSafetyRating: 'safe' | 'moderate-risk' | 'high-risk' | 'blind-risk';
|
|
1073
1332
|
recommendations: string[];
|
|
1074
1333
|
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Calculate the Testability Index for a project.
|
|
1336
|
+
*
|
|
1337
|
+
* @param params - Metrics including coverage, purity, and dependency patterns.
|
|
1338
|
+
* @param params.testFiles - Count of identifiable test files.
|
|
1339
|
+
* @param params.sourceFiles - Total number of source files.
|
|
1340
|
+
* @param params.pureFunctions - Count of functions without side effects.
|
|
1341
|
+
* @param params.totalFunctions - Total number of functions analyzed.
|
|
1342
|
+
* @param params.injectionPatterns - Count of classes using dependency injection.
|
|
1343
|
+
* @param params.totalClasses - Total number of classes analyzed.
|
|
1344
|
+
* @param params.bloatedInterfaces - Count of interfaces with too many methods.
|
|
1345
|
+
* @param params.totalInterfaces - Total number of interfaces analyzed.
|
|
1346
|
+
* @param params.externalStateMutations - Count of nodes that mutate external state.
|
|
1347
|
+
* @param params.hasTestFramework - Whether a testing framework (e.g., Vitest) is detected.
|
|
1348
|
+
* @returns Comprehensive TestabilityIndex analysis.
|
|
1349
|
+
*/
|
|
1075
1350
|
declare function calculateTestabilityIndex(params: {
|
|
1076
1351
|
testFiles: number;
|
|
1077
1352
|
sourceFiles: number;
|
|
@@ -1086,8 +1361,10 @@ declare function calculateTestabilityIndex(params: {
|
|
|
1086
1361
|
}): TestabilityIndex;
|
|
1087
1362
|
|
|
1088
1363
|
/**
|
|
1089
|
-
* Documentation Drift Metrics
|
|
1364
|
+
* Documentation Drift Metrics.
|
|
1090
1365
|
* Measures the risk of documentation becoming out of sync with code.
|
|
1366
|
+
*
|
|
1367
|
+
* @lastUpdated 2026-03-18
|
|
1091
1368
|
*/
|
|
1092
1369
|
interface DocDriftRisk {
|
|
1093
1370
|
score: number;
|
|
@@ -1103,8 +1380,13 @@ interface DocDriftRisk {
|
|
|
1103
1380
|
/**
|
|
1104
1381
|
* Calculate the documentation drift risk score based on various metrics.
|
|
1105
1382
|
*
|
|
1106
|
-
* @param params - The raw metrics for doc-drift analysis
|
|
1107
|
-
* @
|
|
1383
|
+
* @param params - The raw metrics for doc-drift analysis gathered during scanning.
|
|
1384
|
+
* @param params.uncommentedExports - Number of public exports missing documentation.
|
|
1385
|
+
* @param params.totalExports - Total number of public exports analyzed.
|
|
1386
|
+
* @param params.outdatedComments - Count of comments that conflict with recent code changes.
|
|
1387
|
+
* @param params.undocumentedComplexity - Count of complex nodes without explanatory comments.
|
|
1388
|
+
* @param params.actualDrift - Raw drift metric calculated from temporal analysis.
|
|
1389
|
+
* @returns The calculated risk score and prioritized recommendations.
|
|
1108
1390
|
*/
|
|
1109
1391
|
declare function calculateDocDrift(params: {
|
|
1110
1392
|
uncommentedExports: number;
|
|
@@ -1115,8 +1397,10 @@ declare function calculateDocDrift(params: {
|
|
|
1115
1397
|
}): DocDriftRisk;
|
|
1116
1398
|
|
|
1117
1399
|
/**
|
|
1118
|
-
* Dependency Health Metrics
|
|
1119
|
-
* Measures the health and
|
|
1400
|
+
* Dependency Health Metrics.
|
|
1401
|
+
* Measures the health, recency, and security of project dependencies.
|
|
1402
|
+
*
|
|
1403
|
+
* @lastUpdated 2026-03-18
|
|
1120
1404
|
*/
|
|
1121
1405
|
interface DependencyHealthScore {
|
|
1122
1406
|
score: number;
|
|
@@ -1129,6 +1413,16 @@ interface DependencyHealthScore {
|
|
|
1129
1413
|
aiKnowledgeConfidence: 'high' | 'moderate' | 'low' | 'blind';
|
|
1130
1414
|
recommendations: string[];
|
|
1131
1415
|
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Calculate Dependency Health metrics based on version freshness and package metadata.
|
|
1418
|
+
*
|
|
1419
|
+
* @param params - Metrics gathered from package.json and registry lookups.
|
|
1420
|
+
* @param params.totalPackages - Total number of dependencies analyzed.
|
|
1421
|
+
* @param params.outdatedPackages - Count of packages with newer versions available.
|
|
1422
|
+
* @param params.deprecatedPackages - Count of packages marked as deprecated by maintainers.
|
|
1423
|
+
* @param params.trainingCutoffSkew - Normalized skew between dependency release dates and AI training cutoffs.
|
|
1424
|
+
* @returns Comprehensive DependencyHealthScore.
|
|
1425
|
+
*/
|
|
1132
1426
|
declare function calculateDependencyHealth(params: {
|
|
1133
1427
|
totalPackages: number;
|
|
1134
1428
|
outdatedPackages: number;
|
|
@@ -1136,6 +1430,11 @@ declare function calculateDependencyHealth(params: {
|
|
|
1136
1430
|
trainingCutoffSkew: number;
|
|
1137
1431
|
}): DependencyHealthScore;
|
|
1138
1432
|
|
|
1433
|
+
/**
|
|
1434
|
+
* Parameters for generating comprehensive future-proof recommendations.
|
|
1435
|
+
*
|
|
1436
|
+
* @lastUpdated 2026-03-18
|
|
1437
|
+
*/
|
|
1139
1438
|
interface FutureProofRecommendationParams {
|
|
1140
1439
|
cognitiveLoad: CognitiveLoad;
|
|
1141
1440
|
patternEntropy: PatternEntropy;
|
|
@@ -1148,8 +1447,10 @@ interface FutureProofRecommendationParams {
|
|
|
1148
1447
|
}
|
|
1149
1448
|
|
|
1150
1449
|
/**
|
|
1151
|
-
* Change Amplification Metrics
|
|
1152
|
-
* Measures how a change in one file ripples through the system.
|
|
1450
|
+
* Change Amplification Metrics.
|
|
1451
|
+
* Measures how a change in one file ripples through the system via dependency fan-out.
|
|
1452
|
+
*
|
|
1453
|
+
* @lastUpdated 2026-03-18
|
|
1153
1454
|
*/
|
|
1154
1455
|
interface ChangeAmplificationScore {
|
|
1155
1456
|
score: number;
|
|
@@ -1164,6 +1465,13 @@ interface ChangeAmplificationScore {
|
|
|
1164
1465
|
}>;
|
|
1165
1466
|
recommendations: string[];
|
|
1166
1467
|
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Calculate Change Amplification metrics for a set of files in a dependency graph.
|
|
1470
|
+
*
|
|
1471
|
+
* @param params - Structural metrics gathered from link analysis.
|
|
1472
|
+
* @param params.files - List of files with their fan-in/fan-out counts.
|
|
1473
|
+
* @returns Comprehensive ChangeAmplificationScore.
|
|
1474
|
+
*/
|
|
1167
1475
|
declare function calculateChangeAmplification(params: {
|
|
1168
1476
|
files: Array<{
|
|
1169
1477
|
file: string;
|
|
@@ -1173,12 +1481,14 @@ declare function calculateChangeAmplification(params: {
|
|
|
1173
1481
|
}): ChangeAmplificationScore;
|
|
1174
1482
|
|
|
1175
1483
|
/**
|
|
1176
|
-
* Future-Proof AI Metrics Abstraction Layer
|
|
1484
|
+
* Future-Proof AI Metrics Abstraction Layer.
|
|
1177
1485
|
*
|
|
1178
1486
|
* This module provides technology-agnostic metric primitives that will
|
|
1179
1487
|
* remain valid across changes in AI models, tokenization, and paradigms.
|
|
1180
1488
|
*
|
|
1181
1489
|
* It focuses on cognitive load, semantic cohesion, and structural entropy.
|
|
1490
|
+
*
|
|
1491
|
+
* @lastUpdated 2026-03-18
|
|
1182
1492
|
*/
|
|
1183
1493
|
|
|
1184
1494
|
/**
|
|
@@ -1206,8 +1516,8 @@ declare function calculateFutureProofScore(params: {
|
|
|
1206
1516
|
* Incorporates secondary signals like documentation drift, dependency health,
|
|
1207
1517
|
* and testability index to provide a holistic view of the repository's AI readiness.
|
|
1208
1518
|
*
|
|
1209
|
-
* @param params - Comprehensive set of metric outputs
|
|
1210
|
-
* @returns ToolScoringOutput with extended analysis results
|
|
1519
|
+
* @param params - Comprehensive set of metric outputs including grounding and testability.
|
|
1520
|
+
* @returns ToolScoringOutput with extended analysis results and prioritized fixes.
|
|
1211
1521
|
*/
|
|
1212
1522
|
declare function calculateExtendedFutureProofScore(params: FutureProofRecommendationParams & {
|
|
1213
1523
|
semanticDistances?: SemanticDistance[];
|
|
@@ -1220,11 +1530,18 @@ declare function calculateExtendedFutureProofScore(params: FutureProofRecommenda
|
|
|
1220
1530
|
* Stores data in .aiready/history/ directory.
|
|
1221
1531
|
*/
|
|
1222
1532
|
/**
|
|
1223
|
-
* Load score history from disk
|
|
1533
|
+
* Load score history from disk.
|
|
1534
|
+
*
|
|
1535
|
+
* @param rootDir - The project root directory.
|
|
1536
|
+
* @returns Array of history entries.
|
|
1224
1537
|
*/
|
|
1225
1538
|
declare function loadScoreHistory(rootDir: string): any[];
|
|
1226
1539
|
/**
|
|
1227
|
-
* Save score entry to history
|
|
1540
|
+
* Save a new score entry to history.
|
|
1541
|
+
*
|
|
1542
|
+
* @param rootDir - The project root directory.
|
|
1543
|
+
* @param entry - The score data to persist.
|
|
1544
|
+
* @lastUpdated 2026-03-18
|
|
1228
1545
|
*/
|
|
1229
1546
|
declare function saveScoreEntry(rootDir: string, entry: {
|
|
1230
1547
|
overallScore: number;
|
|
@@ -1233,7 +1550,10 @@ declare function saveScoreEntry(rootDir: string, entry: {
|
|
|
1233
1550
|
totalTokens: number;
|
|
1234
1551
|
}): void;
|
|
1235
1552
|
/**
|
|
1236
|
-
* Get summary of recent history
|
|
1553
|
+
* Get a summary of recent history metrics.
|
|
1554
|
+
*
|
|
1555
|
+
* @param rootDir - The project root directory.
|
|
1556
|
+
* @returns Summary object with totals and averages.
|
|
1237
1557
|
*/
|
|
1238
1558
|
declare function getHistorySummary(rootDir: string): {
|
|
1239
1559
|
totalScans: number;
|
|
@@ -1242,24 +1562,42 @@ declare function getHistorySummary(rootDir: string): {
|
|
|
1242
1562
|
avgScore: number;
|
|
1243
1563
|
};
|
|
1244
1564
|
/**
|
|
1245
|
-
* Export history for external analysis
|
|
1565
|
+
* Export history for external analysis.
|
|
1566
|
+
*
|
|
1567
|
+
* @param rootDir - The project root directory.
|
|
1568
|
+
* @param format - Export format ('json' or 'csv').
|
|
1569
|
+
* @returns Formatted history string.
|
|
1246
1570
|
*/
|
|
1247
1571
|
declare function exportHistory(rootDir: string, format?: 'json' | 'csv'): string;
|
|
1248
1572
|
/**
|
|
1249
|
-
* Clear history (for testing or reset)
|
|
1573
|
+
* Clear history (for testing or reset).
|
|
1574
|
+
*
|
|
1575
|
+
* @param rootDir - The project root directory.
|
|
1250
1576
|
*/
|
|
1251
1577
|
declare function clearHistory(rootDir: string): void;
|
|
1252
1578
|
|
|
1253
1579
|
/**
|
|
1254
|
-
* Get git commit timestamps for each line in a file
|
|
1580
|
+
* Get git commit timestamps for each line in a file using git blame.
|
|
1581
|
+
*
|
|
1582
|
+
* @param file - Absolute path to the file to blame.
|
|
1583
|
+
* @returns Map of line numbers to unix timestamps.
|
|
1255
1584
|
*/
|
|
1256
1585
|
declare function getFileCommitTimestamps(file: string): Record<number, number>;
|
|
1257
1586
|
/**
|
|
1258
|
-
* Get the latest commit timestamp for a line range
|
|
1587
|
+
* Get the latest commit timestamp for a specific line range.
|
|
1588
|
+
*
|
|
1589
|
+
* @param lineStamps - Pre-computed map of line timestamps.
|
|
1590
|
+
* @param startLine - Start of the range (1-indexed).
|
|
1591
|
+
* @param endLine - End of the range (inclusive).
|
|
1592
|
+
* @returns The most recent unix timestamp in the range.
|
|
1259
1593
|
*/
|
|
1260
1594
|
declare function getLineRangeLastModifiedCached(lineStamps: Record<number, number>, startLine: number, endLine: number): number;
|
|
1261
1595
|
/**
|
|
1262
|
-
* Get repository metadata
|
|
1596
|
+
* Get repository metadata including URL, branch, commit, and last author.
|
|
1597
|
+
*
|
|
1598
|
+
* @param directory - The repository root directory.
|
|
1599
|
+
* @returns Metadata object with git details.
|
|
1600
|
+
* @lastUpdated 2026-03-18
|
|
1263
1601
|
*/
|
|
1264
1602
|
declare function getRepoMetadata(directory: string): {
|
|
1265
1603
|
url?: string;
|
|
@@ -1272,8 +1610,10 @@ declare function getRepoMetadata(directory: string): {
|
|
|
1272
1610
|
* Utilities for GitHub Actions integration
|
|
1273
1611
|
*/
|
|
1274
1612
|
/**
|
|
1275
|
-
* Emit a GitHub Action annotation
|
|
1613
|
+
* Emit a GitHub Action annotation.
|
|
1276
1614
|
* Format: ::(error|warning|notice) file={file},line={line},col={col},title={title}::{message}
|
|
1615
|
+
*
|
|
1616
|
+
* @param params - Annotation parameters including level, file, and message.
|
|
1277
1617
|
*/
|
|
1278
1618
|
declare function emitAnnotation(params: {
|
|
1279
1619
|
level: 'error' | 'warning' | 'notice';
|
|
@@ -1284,12 +1624,18 @@ declare function emitAnnotation(params: {
|
|
|
1284
1624
|
message: string;
|
|
1285
1625
|
}): void;
|
|
1286
1626
|
/**
|
|
1287
|
-
* Map AIReady severity to GitHub Action annotation level
|
|
1627
|
+
* Map AIReady severity to GitHub Action annotation level.
|
|
1628
|
+
*
|
|
1629
|
+
* @param severity - AIReady severity string (e.g., 'critical', 'major').
|
|
1630
|
+
* @returns GitHub Action annotation level ('error', 'warning', or 'notice').
|
|
1288
1631
|
*/
|
|
1289
1632
|
declare function severityToAnnotationLevel(severity: string): 'error' | 'warning' | 'notice';
|
|
1290
1633
|
/**
|
|
1291
|
-
* Emit multiple annotations from an array of issues
|
|
1634
|
+
* Emit multiple annotations from an array of issues.
|
|
1635
|
+
*
|
|
1636
|
+
* @param issues - Array of issue objects to annotate.
|
|
1637
|
+
* @lastUpdated 2026-03-18
|
|
1292
1638
|
*/
|
|
1293
1639
|
declare function emitIssuesAsAnnotations(issues: any[]): void;
|
|
1294
1640
|
|
|
1295
|
-
export { AIReadyConfig,
|
|
1641
|
+
export { AIReadyConfig, 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, Issue, JavaParser, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, Metrics, 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, ToolOptions, 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, 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, normalizeAnalysisResult, normalizeIssue, normalizeMetrics, normalizeSpokeOutput, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, setupParser, severityToAnnotationLevel, validateSpokeOutput, validateWithSchema };
|