@aiready/core 0.9.22 → 0.9.23

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.
@@ -0,0 +1,457 @@
1
+ interface AnalysisResult {
2
+ fileName: string;
3
+ issues: Issue[];
4
+ metrics: Metrics;
5
+ }
6
+ interface Issue {
7
+ type: IssueType;
8
+ severity: 'critical' | 'major' | 'minor' | 'info';
9
+ message: string;
10
+ location: Location;
11
+ suggestion?: string;
12
+ }
13
+ type IssueType = 'duplicate-pattern' | 'context-fragmentation' | 'doc-drift' | 'naming-inconsistency' | 'naming-quality' | 'pattern-inconsistency' | 'architecture-inconsistency' | 'dead-code' | 'circular-dependency' | 'missing-types';
14
+ interface Location {
15
+ file: string;
16
+ line: number;
17
+ column?: number;
18
+ endLine?: number;
19
+ endColumn?: number;
20
+ }
21
+ interface Metrics {
22
+ tokenCost?: number;
23
+ complexityScore?: number;
24
+ consistencyScore?: number;
25
+ docFreshnessScore?: number;
26
+ }
27
+ interface ScanOptions {
28
+ rootDir: string;
29
+ include?: string[];
30
+ exclude?: string[];
31
+ maxDepth?: number;
32
+ }
33
+ interface AIReadyConfig {
34
+ scan?: {
35
+ include?: string[];
36
+ exclude?: string[];
37
+ tools?: string[];
38
+ };
39
+ tools?: {
40
+ 'pattern-detect'?: {
41
+ enabled?: boolean;
42
+ scoreWeight?: number;
43
+ minSimilarity?: number;
44
+ minLines?: number;
45
+ batchSize?: number;
46
+ approx?: boolean;
47
+ minSharedTokens?: number;
48
+ maxCandidatesPerBlock?: number;
49
+ streamResults?: boolean;
50
+ maxResults?: number;
51
+ };
52
+ 'context-analyzer'?: {
53
+ enabled?: boolean;
54
+ scoreWeight?: number;
55
+ maxDepth?: number;
56
+ maxContextBudget?: number;
57
+ minCohesion?: number;
58
+ maxFragmentation?: number;
59
+ focus?: 'fragmentation' | 'cohesion' | 'depth' | 'all';
60
+ includeNodeModules?: boolean;
61
+ maxResults?: number;
62
+ domainKeywords?: string[];
63
+ domainPatterns?: string[];
64
+ pathDomainMap?: Record<string, string>;
65
+ };
66
+ 'consistency'?: {
67
+ enabled?: boolean;
68
+ scoreWeight?: number;
69
+ acceptedAbbreviations?: string[];
70
+ shortWords?: string[];
71
+ disableChecks?: ('single-letter' | 'abbreviation' | 'convention-mix' | 'unclear' | 'poor-naming')[];
72
+ };
73
+ [toolName: string]: {
74
+ enabled?: boolean;
75
+ scoreWeight?: number;
76
+ [key: string]: any;
77
+ } | undefined;
78
+ };
79
+ scoring?: {
80
+ threshold?: number;
81
+ showBreakdown?: boolean;
82
+ compareBaseline?: string;
83
+ saveTo?: string;
84
+ };
85
+ output?: {
86
+ format?: 'console' | 'json' | 'html';
87
+ file?: string;
88
+ };
89
+ visualizer?: {
90
+ groupingDirs?: string[];
91
+ graph?: {
92
+ maxNodes?: number;
93
+ maxEdges?: number;
94
+ };
95
+ };
96
+ }
97
+ interface Report {
98
+ summary: {
99
+ totalFiles: number;
100
+ totalIssues: number;
101
+ criticalIssues: number;
102
+ majorIssues: number;
103
+ };
104
+ results: AnalysisResult[];
105
+ metrics: {
106
+ overallScore: number;
107
+ tokenCostTotal: number;
108
+ avgConsistency: number;
109
+ };
110
+ }
111
+ /**
112
+ * Severity levels for issues
113
+ */
114
+ type GraphIssueSeverity = 'critical' | 'major' | 'minor' | 'info';
115
+ /**
116
+ * Base graph node
117
+ */
118
+ interface GraphNode {
119
+ id: string;
120
+ label: string;
121
+ path?: string;
122
+ size?: number;
123
+ value?: number;
124
+ color?: string;
125
+ group?: string;
126
+ x?: number;
127
+ y?: number;
128
+ }
129
+ /**
130
+ * Graph edge between nodes
131
+ */
132
+ interface GraphEdge {
133
+ source: string | GraphNode;
134
+ target: string | GraphNode;
135
+ type?: string;
136
+ weight?: number;
137
+ }
138
+ /**
139
+ * Graph metadata
140
+ */
141
+ interface GraphMetadata {
142
+ projectName?: string;
143
+ timestamp: string;
144
+ totalFiles: number;
145
+ totalDependencies: number;
146
+ analysisTypes: string[];
147
+ criticalIssues: number;
148
+ majorIssues: number;
149
+ minorIssues: number;
150
+ infoIssues: number;
151
+ }
152
+ /**
153
+ * Complete graph data structure for visualization
154
+ */
155
+ interface GraphData {
156
+ nodes: GraphNode[];
157
+ edges: GraphEdge[];
158
+ clusters?: {
159
+ id: string;
160
+ name: string;
161
+ nodeIds: string[];
162
+ }[];
163
+ issues?: {
164
+ id: string;
165
+ type: string;
166
+ severity: GraphIssueSeverity;
167
+ nodeIds: string[];
168
+ message: string;
169
+ }[];
170
+ metadata: GraphMetadata;
171
+ }
172
+
173
+ /**
174
+ * Language-agnostic AST and parser interfaces for multi-language support
175
+ *
176
+ * This module provides abstractions for parsing different programming languages
177
+ * while maintaining a consistent interface for analysis tools.
178
+ */
179
+ /**
180
+ * Supported programming languages
181
+ */
182
+ declare enum Language {
183
+ TypeScript = "typescript",
184
+ JavaScript = "javascript",
185
+ Python = "python",
186
+ Java = "java",
187
+ Go = "go",
188
+ Rust = "rust",
189
+ CSharp = "csharp"
190
+ }
191
+ /**
192
+ * File extensions mapped to languages
193
+ */
194
+ declare const LANGUAGE_EXTENSIONS: Record<string, Language>;
195
+ /**
196
+ * Location information in source code
197
+ */
198
+ interface SourceLocation {
199
+ line: number;
200
+ column: number;
201
+ }
202
+ interface SourceRange {
203
+ start: SourceLocation;
204
+ end: SourceLocation;
205
+ }
206
+ /**
207
+ * Common AST node type (language-agnostic)
208
+ */
209
+ interface CommonASTNode {
210
+ type: string;
211
+ loc?: SourceRange;
212
+ raw?: any;
213
+ }
214
+ /**
215
+ * Export information (function, class, variable, etc.)
216
+ */
217
+ interface ExportInfo {
218
+ name: string;
219
+ type: 'function' | 'class' | 'const' | 'type' | 'interface' | 'default' | 'variable';
220
+ loc?: SourceRange;
221
+ /** Imports used within this export */
222
+ imports?: string[];
223
+ /** Dependencies on other exports in same file */
224
+ dependencies?: string[];
225
+ /** TypeScript types referenced */
226
+ typeReferences?: string[];
227
+ /** For methods: parent class name */
228
+ parentClass?: string;
229
+ /** For functions/methods: parameters */
230
+ parameters?: string[];
231
+ /** Visibility (public, private, protected) */
232
+ visibility?: 'public' | 'private' | 'protected';
233
+ }
234
+ /**
235
+ * Import information
236
+ */
237
+ interface ImportInfo {
238
+ /** Module being imported from */
239
+ source: string;
240
+ /** What's being imported */
241
+ specifiers: string[];
242
+ /** Is this a type-only import (TypeScript) */
243
+ isTypeOnly?: boolean;
244
+ /** Location in source */
245
+ loc?: SourceRange;
246
+ }
247
+ /**
248
+ * Parse result containing exports and imports
249
+ */
250
+ interface ParseResult {
251
+ exports: ExportInfo[];
252
+ imports: ImportInfo[];
253
+ /** Language of the parsed file */
254
+ language: Language;
255
+ /** Any parse warnings (non-fatal) */
256
+ warnings?: string[];
257
+ }
258
+ /**
259
+ * Naming convention rules per language
260
+ */
261
+ interface NamingConvention {
262
+ /** Allowed variable naming patterns */
263
+ variablePattern: RegExp;
264
+ /** Allowed function naming patterns */
265
+ functionPattern: RegExp;
266
+ /** Allowed class naming patterns */
267
+ classPattern: RegExp;
268
+ /** Allowed constant naming patterns */
269
+ constantPattern: RegExp;
270
+ /** Language-specific exceptions (e.g., __init__ in Python) */
271
+ exceptions?: string[];
272
+ }
273
+ /**
274
+ * Language-specific configuration
275
+ */
276
+ interface LanguageConfig {
277
+ language: Language;
278
+ /** File extensions for this language */
279
+ extensions: string[];
280
+ /** Naming conventions */
281
+ namingConventions: NamingConvention;
282
+ /** Common abbreviations allowed */
283
+ allowedAbbreviations?: string[];
284
+ /** Language-specific keywords to ignore */
285
+ keywords?: string[];
286
+ }
287
+ /**
288
+ * Abstract interface for language parsers
289
+ * Each language implementation should implement this interface
290
+ */
291
+ interface LanguageParser {
292
+ /** Language this parser handles */
293
+ readonly language: Language;
294
+ /** File extensions this parser supports */
295
+ readonly extensions: string[];
296
+ /**
297
+ * Parse source code and extract structure
298
+ * @param code - Source code to parse
299
+ * @param filePath - Path to the file (for context)
300
+ * @returns Parse result with exports and imports
301
+ * @throws ParseError if code has syntax errors
302
+ */
303
+ parse(code: string, filePath: string): ParseResult;
304
+ /**
305
+ * Get naming conventions for this language
306
+ */
307
+ getNamingConventions(): NamingConvention;
308
+ /**
309
+ * Check if this parser can handle a file
310
+ * @param filePath - File path to check
311
+ */
312
+ canHandle(filePath: string): boolean;
313
+ }
314
+ /**
315
+ * Parser error with location information
316
+ */
317
+ declare class ParseError extends Error {
318
+ readonly filePath: string;
319
+ readonly loc?: SourceLocation | undefined;
320
+ constructor(message: string, filePath: string, loc?: SourceLocation | undefined);
321
+ }
322
+ /**
323
+ * Statistics about parsed code
324
+ */
325
+ interface ParseStatistics {
326
+ language: Language;
327
+ filesAnalyzed: number;
328
+ totalExports: number;
329
+ totalImports: number;
330
+ parseErrors: number;
331
+ warnings: number;
332
+ }
333
+
334
+ /**
335
+ * AI Readiness Scoring System
336
+ *
337
+ * Provides dynamic, composable scoring across multiple analysis tools.
338
+ * Each tool contributes a 0-100 score with configurable weights.
339
+ */
340
+ interface ToolScoringOutput {
341
+ /** Unique tool identifier (e.g., "pattern-detect") */
342
+ toolName: string;
343
+ /** Normalized 0-100 score for this tool */
344
+ score: number;
345
+ /** Raw metrics used to calculate the score */
346
+ rawMetrics: Record<string, any>;
347
+ /** Factors that influenced the score */
348
+ factors: Array<{
349
+ name: string;
350
+ impact: number;
351
+ description: string;
352
+ }>;
353
+ /** Actionable recommendations with estimated impact */
354
+ recommendations: Array<{
355
+ action: string;
356
+ estimatedImpact: number;
357
+ priority: 'high' | 'medium' | 'low';
358
+ }>;
359
+ }
360
+ interface ScoringResult {
361
+ /** Overall AI Readiness Score (0-100) */
362
+ overall: number;
363
+ /** Rating category */
364
+ rating: 'Excellent' | 'Good' | 'Fair' | 'Needs Work' | 'Critical';
365
+ /** Timestamp of score calculation */
366
+ timestamp: string;
367
+ /** Tools that contributed to this score */
368
+ toolsUsed: string[];
369
+ /** Breakdown by tool */
370
+ breakdown: ToolScoringOutput[];
371
+ /** Calculation details */
372
+ calculation: {
373
+ formula: string;
374
+ weights: Record<string, number>;
375
+ normalized: string;
376
+ };
377
+ }
378
+ interface ScoringConfig {
379
+ /** Minimum passing score (exit code 1 if below) */
380
+ threshold?: number;
381
+ /** Show detailed breakdown in output */
382
+ showBreakdown?: boolean;
383
+ /** Path to baseline JSON for comparison */
384
+ compareBaseline?: string;
385
+ /** Auto-save score to this path */
386
+ saveTo?: string;
387
+ }
388
+ /**
389
+ * Default weights for known tools.
390
+ * New tools get weight of 10 if not specified.
391
+ */
392
+ declare const DEFAULT_TOOL_WEIGHTS: Record<string, number>;
393
+ /**
394
+ * Tool name normalization map (shorthand -> full name)
395
+ */
396
+ declare const TOOL_NAME_MAP: Record<string, string>;
397
+ /**
398
+ * Normalize tool name from shorthand to full name
399
+ */
400
+ declare function normalizeToolName(shortName: string): string;
401
+ /**
402
+ * Get tool weight with fallback priority:
403
+ * 1. CLI override
404
+ * 2. Tool config scoreWeight
405
+ * 3. Default weight
406
+ * 4. 10 (for unknown tools)
407
+ */
408
+ declare function getToolWeight(toolName: string, toolConfig?: {
409
+ scoreWeight?: number;
410
+ }, cliOverride?: number): number;
411
+ /**
412
+ * Parse weight string from CLI (e.g., "patterns:50,context:30")
413
+ */
414
+ declare function parseWeightString(weightStr?: string): Map<string, number>;
415
+ /**
416
+ * Calculate overall AI Readiness Score from multiple tool scores.
417
+ *
418
+ * Formula: Σ(tool_score × tool_weight) / Σ(active_tool_weights)
419
+ *
420
+ * This allows dynamic composition - score adjusts automatically
421
+ * based on which tools actually ran.
422
+ */
423
+ declare function calculateOverallScore(toolOutputs: Map<string, ToolScoringOutput>, config?: any, cliWeights?: Map<string, number>): ScoringResult;
424
+ /**
425
+ * Convert numeric score to rating category
426
+ */
427
+ declare function getRating(score: number): ScoringResult['rating'];
428
+ /**
429
+ * Get rating emoji and color for display
430
+ */
431
+ declare function getRatingDisplay(rating: ScoringResult['rating']): {
432
+ emoji: string;
433
+ color: string;
434
+ };
435
+ /**
436
+ * Format score for display with rating
437
+ */
438
+ declare function formatScore(result: ScoringResult): string;
439
+ /**
440
+ * Format individual tool score for display
441
+ */
442
+ declare function formatToolScore(output: ToolScoringOutput): string;
443
+
444
+ /**
445
+ * Visualization utilities for generating HTML from graph data
446
+ */
447
+
448
+ /**
449
+ * Generate HTML visualization from graph data
450
+ * Creates an interactive HTML page with a canvas-based graph visualization
451
+ *
452
+ * @param graph - The graph data to visualize
453
+ * @returns HTML string representing the interactive visualization
454
+ */
455
+ declare function generateHTML(graph: GraphData): string;
456
+
457
+ export { type AIReadyConfig, type AnalysisResult, type CommonASTNode, DEFAULT_TOOL_WEIGHTS, type ExportInfo, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, type IssueType, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, type Metrics, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type Report, type ScanOptions, type ScoringConfig, type ScoringResult, type SourceLocation, type SourceRange, TOOL_NAME_MAP, type ToolScoringOutput, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString };