@aiready/core 0.9.4 → 0.9.5
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/__tests__/parser-factory.test.d.ts +5 -0
- package/dist/__tests__/parser-factory.test.d.ts.map +1 -0
- package/dist/__tests__/parser-factory.test.js +58 -0
- package/dist/__tests__/parser-factory.test.js.map +1 -0
- package/dist/__tests__/python-parser.test.d.ts +5 -0
- package/dist/__tests__/python-parser.test.d.ts.map +1 -0
- package/dist/__tests__/python-parser.test.js +192 -0
- package/dist/__tests__/python-parser.test.js.map +1 -0
- package/dist/__tests__/scoring.test.d.ts +2 -0
- package/dist/__tests__/scoring.test.d.ts.map +1 -0
- package/dist/__tests__/scoring.test.js +180 -0
- package/dist/__tests__/scoring.test.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/parser-factory.d.ts +69 -0
- package/dist/parsers/parser-factory.d.ts.map +1 -0
- package/dist/parsers/parser-factory.js +114 -0
- package/dist/parsers/parser-factory.js.map +1 -0
- package/dist/parsers/python-parser.d.ts +42 -0
- package/dist/parsers/python-parser.d.ts.map +1 -0
- package/dist/parsers/python-parser.js +241 -0
- package/dist/parsers/python-parser.js.map +1 -0
- package/dist/parsers/typescript-parser.d.ts +17 -0
- package/dist/parsers/typescript-parser.d.ts.map +1 -0
- package/dist/parsers/typescript-parser.js +216 -0
- package/dist/parsers/typescript-parser.js.map +1 -0
- package/dist/scoring.d.ts +110 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +195 -0
- package/dist/scoring.js.map +1 -0
- package/dist/types/language.d.ts +161 -0
- package/dist/types/language.d.ts.map +1 -0
- package/dist/types/language.js +45 -0
- package/dist/types/language.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/ast-parser.d.ts +50 -0
- package/dist/utils/ast-parser.d.ts.map +1 -0
- package/dist/utils/ast-parser.js +216 -0
- package/dist/utils/ast-parser.js.map +1 -0
- package/dist/utils/cli-helpers.d.ts +37 -0
- package/dist/utils/cli-helpers.d.ts.map +1 -0
- package/dist/utils/cli-helpers.js +76 -0
- package/dist/utils/cli-helpers.js.map +1 -0
- package/dist/utils/config.d.ts +4 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +82 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/file-scanner.d.ts +16 -0
- package/dist/utils/file-scanner.d.ts.map +1 -0
- package/dist/utils/file-scanner.js +100 -0
- package/dist/utils/file-scanner.js.map +1 -0
- package/dist/utils/metrics.d.ts +6 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +8 -0
- package/dist/utils/metrics.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Readiness Scoring System
|
|
3
|
+
*
|
|
4
|
+
* Provides dynamic, composable scoring across multiple analysis tools.
|
|
5
|
+
* Each tool contributes a 0-100 score with configurable weights.
|
|
6
|
+
*/
|
|
7
|
+
export interface ToolScoringOutput {
|
|
8
|
+
/** Unique tool identifier (e.g., "pattern-detect") */
|
|
9
|
+
toolName: string;
|
|
10
|
+
/** Normalized 0-100 score for this tool */
|
|
11
|
+
score: number;
|
|
12
|
+
/** Raw metrics used to calculate the score */
|
|
13
|
+
rawMetrics: Record<string, any>;
|
|
14
|
+
/** Factors that influenced the score */
|
|
15
|
+
factors: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
impact: number;
|
|
18
|
+
description: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** Actionable recommendations with estimated impact */
|
|
21
|
+
recommendations: Array<{
|
|
22
|
+
action: string;
|
|
23
|
+
estimatedImpact: number;
|
|
24
|
+
priority: 'high' | 'medium' | 'low';
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export interface ScoringResult {
|
|
28
|
+
/** Overall AI Readiness Score (0-100) */
|
|
29
|
+
overall: number;
|
|
30
|
+
/** Rating category */
|
|
31
|
+
rating: 'Excellent' | 'Good' | 'Fair' | 'Needs Work' | 'Critical';
|
|
32
|
+
/** Timestamp of score calculation */
|
|
33
|
+
timestamp: string;
|
|
34
|
+
/** Tools that contributed to this score */
|
|
35
|
+
toolsUsed: string[];
|
|
36
|
+
/** Breakdown by tool */
|
|
37
|
+
breakdown: ToolScoringOutput[];
|
|
38
|
+
/** Calculation details */
|
|
39
|
+
calculation: {
|
|
40
|
+
formula: string;
|
|
41
|
+
weights: Record<string, number>;
|
|
42
|
+
normalized: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface ScoringConfig {
|
|
46
|
+
/** Minimum passing score (exit code 1 if below) */
|
|
47
|
+
threshold?: number;
|
|
48
|
+
/** Show detailed breakdown in output */
|
|
49
|
+
showBreakdown?: boolean;
|
|
50
|
+
/** Path to baseline JSON for comparison */
|
|
51
|
+
compareBaseline?: string;
|
|
52
|
+
/** Auto-save score to this path */
|
|
53
|
+
saveTo?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Default weights for known tools.
|
|
57
|
+
* New tools get weight of 10 if not specified.
|
|
58
|
+
*/
|
|
59
|
+
export declare const DEFAULT_TOOL_WEIGHTS: Record<string, number>;
|
|
60
|
+
/**
|
|
61
|
+
* Tool name normalization map (shorthand -> full name)
|
|
62
|
+
*/
|
|
63
|
+
export declare const TOOL_NAME_MAP: Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Normalize tool name from shorthand to full name
|
|
66
|
+
*/
|
|
67
|
+
export declare function normalizeToolName(shortName: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get tool weight with fallback priority:
|
|
70
|
+
* 1. CLI override
|
|
71
|
+
* 2. Tool config scoreWeight
|
|
72
|
+
* 3. Default weight
|
|
73
|
+
* 4. 10 (for unknown tools)
|
|
74
|
+
*/
|
|
75
|
+
export declare function getToolWeight(toolName: string, toolConfig?: {
|
|
76
|
+
scoreWeight?: number;
|
|
77
|
+
}, cliOverride?: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* Parse weight string from CLI (e.g., "patterns:50,context:30")
|
|
80
|
+
*/
|
|
81
|
+
export declare function parseWeightString(weightStr?: string): Map<string, number>;
|
|
82
|
+
/**
|
|
83
|
+
* Calculate overall AI Readiness Score from multiple tool scores.
|
|
84
|
+
*
|
|
85
|
+
* Formula: Σ(tool_score × tool_weight) / Σ(active_tool_weights)
|
|
86
|
+
*
|
|
87
|
+
* This allows dynamic composition - score adjusts automatically
|
|
88
|
+
* based on which tools actually ran.
|
|
89
|
+
*/
|
|
90
|
+
export declare function calculateOverallScore(toolOutputs: Map<string, ToolScoringOutput>, config?: any, cliWeights?: Map<string, number>): ScoringResult;
|
|
91
|
+
/**
|
|
92
|
+
* Convert numeric score to rating category
|
|
93
|
+
*/
|
|
94
|
+
export declare function getRating(score: number): ScoringResult['rating'];
|
|
95
|
+
/**
|
|
96
|
+
* Get rating emoji and color for display
|
|
97
|
+
*/
|
|
98
|
+
export declare function getRatingDisplay(rating: ScoringResult['rating']): {
|
|
99
|
+
emoji: string;
|
|
100
|
+
color: string;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Format score for display with rating
|
|
104
|
+
*/
|
|
105
|
+
export declare function formatScore(result: ScoringResult): string;
|
|
106
|
+
/**
|
|
107
|
+
* Format individual tool score for display
|
|
108
|
+
*/
|
|
109
|
+
export declare function formatToolScore(output: ToolScoringOutput): string;
|
|
110
|
+
//# sourceMappingURL=scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../src/scoring.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,KAA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Each tool contributes a 0-100 score with configurable weights.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default weights for known tools.
|
|
9
|
+
* New tools get weight of 10 if not specified.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_TOOL_WEIGHTS = {
|
|
12
|
+
'pattern-detect': 40,
|
|
13
|
+
'context-analyzer': 35,
|
|
14
|
+
'consistency': 25,
|
|
15
|
+
'doc-drift': 20,
|
|
16
|
+
'deps': 15,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Tool name normalization map (shorthand -> full name)
|
|
20
|
+
*/
|
|
21
|
+
export const TOOL_NAME_MAP = {
|
|
22
|
+
'patterns': 'pattern-detect',
|
|
23
|
+
'context': 'context-analyzer',
|
|
24
|
+
'consistency': 'consistency',
|
|
25
|
+
'doc-drift': 'doc-drift',
|
|
26
|
+
'deps': 'deps',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Normalize tool name from shorthand to full name
|
|
30
|
+
*/
|
|
31
|
+
export function normalizeToolName(shortName) {
|
|
32
|
+
return TOOL_NAME_MAP[shortName] || shortName;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get tool weight with fallback priority:
|
|
36
|
+
* 1. CLI override
|
|
37
|
+
* 2. Tool config scoreWeight
|
|
38
|
+
* 3. Default weight
|
|
39
|
+
* 4. 10 (for unknown tools)
|
|
40
|
+
*/
|
|
41
|
+
export function getToolWeight(toolName, toolConfig, cliOverride) {
|
|
42
|
+
// CLI override has highest priority
|
|
43
|
+
if (cliOverride !== undefined) {
|
|
44
|
+
return cliOverride;
|
|
45
|
+
}
|
|
46
|
+
// Check tool's own config
|
|
47
|
+
if (toolConfig?.scoreWeight !== undefined) {
|
|
48
|
+
return toolConfig.scoreWeight;
|
|
49
|
+
}
|
|
50
|
+
// Fall back to defaults
|
|
51
|
+
return DEFAULT_TOOL_WEIGHTS[toolName] || 10;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse weight string from CLI (e.g., "patterns:50,context:30")
|
|
55
|
+
*/
|
|
56
|
+
export function parseWeightString(weightStr) {
|
|
57
|
+
const weights = new Map();
|
|
58
|
+
if (!weightStr) {
|
|
59
|
+
return weights;
|
|
60
|
+
}
|
|
61
|
+
const pairs = weightStr.split(',');
|
|
62
|
+
for (const pair of pairs) {
|
|
63
|
+
const [toolShortName, weightStr] = pair.split(':');
|
|
64
|
+
if (toolShortName && weightStr) {
|
|
65
|
+
const toolName = normalizeToolName(toolShortName.trim());
|
|
66
|
+
const weight = parseInt(weightStr.trim(), 10);
|
|
67
|
+
if (!isNaN(weight) && weight > 0) {
|
|
68
|
+
weights.set(toolName, weight);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return weights;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Calculate overall AI Readiness Score from multiple tool scores.
|
|
76
|
+
*
|
|
77
|
+
* Formula: Σ(tool_score × tool_weight) / Σ(active_tool_weights)
|
|
78
|
+
*
|
|
79
|
+
* This allows dynamic composition - score adjusts automatically
|
|
80
|
+
* based on which tools actually ran.
|
|
81
|
+
*/
|
|
82
|
+
export function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
83
|
+
if (toolOutputs.size === 0) {
|
|
84
|
+
throw new Error('No tool outputs provided for scoring');
|
|
85
|
+
}
|
|
86
|
+
// Build weights map with priority: CLI > config > defaults
|
|
87
|
+
const weights = new Map();
|
|
88
|
+
for (const [toolName] of toolOutputs.entries()) {
|
|
89
|
+
const cliWeight = cliWeights?.get(toolName);
|
|
90
|
+
const configWeight = config?.tools?.[toolName]?.scoreWeight;
|
|
91
|
+
const weight = cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 10;
|
|
92
|
+
weights.set(toolName, weight);
|
|
93
|
+
}
|
|
94
|
+
// Calculate weighted sum and total weight
|
|
95
|
+
let weightedSum = 0;
|
|
96
|
+
let totalWeight = 0;
|
|
97
|
+
const breakdown = [];
|
|
98
|
+
const toolsUsed = [];
|
|
99
|
+
const calculationWeights = {};
|
|
100
|
+
for (const [toolName, output] of toolOutputs.entries()) {
|
|
101
|
+
const weight = weights.get(toolName) || 10;
|
|
102
|
+
const weightedScore = output.score * weight;
|
|
103
|
+
weightedSum += weightedScore;
|
|
104
|
+
totalWeight += weight;
|
|
105
|
+
toolsUsed.push(toolName);
|
|
106
|
+
calculationWeights[toolName] = weight;
|
|
107
|
+
breakdown.push(output);
|
|
108
|
+
}
|
|
109
|
+
// Calculate final score
|
|
110
|
+
const overall = Math.round(weightedSum / totalWeight);
|
|
111
|
+
// Determine rating
|
|
112
|
+
const rating = getRating(overall);
|
|
113
|
+
// Build formula string
|
|
114
|
+
const formulaParts = Array.from(toolOutputs.entries())
|
|
115
|
+
.map(([name, output]) => {
|
|
116
|
+
const w = weights.get(name) || 10;
|
|
117
|
+
return `(${output.score} × ${w})`;
|
|
118
|
+
});
|
|
119
|
+
const formulaStr = `[${formulaParts.join(' + ')}] / ${totalWeight} = ${overall}`;
|
|
120
|
+
return {
|
|
121
|
+
overall,
|
|
122
|
+
rating,
|
|
123
|
+
timestamp: new Date().toISOString(),
|
|
124
|
+
toolsUsed,
|
|
125
|
+
breakdown,
|
|
126
|
+
calculation: {
|
|
127
|
+
formula: formulaStr,
|
|
128
|
+
weights: calculationWeights,
|
|
129
|
+
normalized: formulaStr,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert numeric score to rating category
|
|
135
|
+
*/
|
|
136
|
+
export function getRating(score) {
|
|
137
|
+
if (score >= 90)
|
|
138
|
+
return 'Excellent';
|
|
139
|
+
if (score >= 75)
|
|
140
|
+
return 'Good';
|
|
141
|
+
if (score >= 60)
|
|
142
|
+
return 'Fair';
|
|
143
|
+
if (score >= 40)
|
|
144
|
+
return 'Needs Work';
|
|
145
|
+
return 'Critical';
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get rating emoji and color for display
|
|
149
|
+
*/
|
|
150
|
+
export function getRatingDisplay(rating) {
|
|
151
|
+
switch (rating) {
|
|
152
|
+
case 'Excellent':
|
|
153
|
+
return { emoji: '✅', color: 'green' };
|
|
154
|
+
case 'Good':
|
|
155
|
+
return { emoji: '👍', color: 'blue' };
|
|
156
|
+
case 'Fair':
|
|
157
|
+
return { emoji: '⚠️', color: 'yellow' };
|
|
158
|
+
case 'Needs Work':
|
|
159
|
+
return { emoji: '🔨', color: 'orange' };
|
|
160
|
+
case 'Critical':
|
|
161
|
+
return { emoji: '❌', color: 'red' };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Format score for display with rating
|
|
166
|
+
*/
|
|
167
|
+
export function formatScore(result) {
|
|
168
|
+
const { emoji, color } = getRatingDisplay(result.rating);
|
|
169
|
+
return `${result.overall}/100 (${result.rating}) ${emoji}`;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Format individual tool score for display
|
|
173
|
+
*/
|
|
174
|
+
export function formatToolScore(output) {
|
|
175
|
+
let result = ` Score: ${output.score}/100\n\n`;
|
|
176
|
+
if (output.factors && output.factors.length > 0) {
|
|
177
|
+
result += ` Factors:\n`;
|
|
178
|
+
output.factors.forEach(factor => {
|
|
179
|
+
const impactSign = factor.impact > 0 ? '+' : '';
|
|
180
|
+
result += ` • ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}\n`;
|
|
181
|
+
});
|
|
182
|
+
result += '\n';
|
|
183
|
+
}
|
|
184
|
+
if (output.recommendations && output.recommendations.length > 0) {
|
|
185
|
+
result += ` Recommendations:\n`;
|
|
186
|
+
output.recommendations.forEach((rec, i) => {
|
|
187
|
+
const priorityIcon = rec.priority === 'high' ? '🔴' :
|
|
188
|
+
rec.priority === 'medium' ? '🟡' : '🔵';
|
|
189
|
+
result += ` ${i + 1}. ${priorityIcon} ${rec.action}\n`;
|
|
190
|
+
result += ` Impact: +${rec.estimatedImpact} points\n\n`;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../src/scoring.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiEH;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,gBAAgB,EAAE,EAAE;IACpB,kBAAkB,EAAE,EAAE;IACtB,aAAa,EAAE,EAAE;IACjB,WAAW,EAAE,EAAE;IACf,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,kBAAkB;IAC7B,aAAa,EAAE,aAAa;IAC5B,WAAW,EAAE,WAAW;IACxB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,UAAqC,EACrC,WAAoB;IAEpB,oCAAoC;IACpC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,0BAA0B;IAC1B,IAAI,UAAU,EAAE,WAAW,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,UAAU,CAAC,WAAW,CAAC;IAChC,CAAC;IAED,wBAAwB;IACxB,OAAO,oBAAoB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAkB;IAClD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE1C,IAAI,CAAC,SAAS,EA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AI,GAAG,CAAC,MAAM,IAAI,CAAC;YAC1D,MAAM,IAAI,mBAAmB,GAAG,CAAC,eAAe,aAAa,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language-agnostic AST and parser interfaces for multi-language support
|
|
3
|
+
*
|
|
4
|
+
* This module provides abstractions for parsing different programming languages
|
|
5
|
+
* while maintaining a consistent interface for analysis tools.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported programming languages
|
|
9
|
+
*/
|
|
10
|
+
export declare enum Language {
|
|
11
|
+
TypeScript = "typescript",
|
|
12
|
+
JavaScript = "javascript",
|
|
13
|
+
Python = "python",
|
|
14
|
+
Java = "java",
|
|
15
|
+
Go = "go",
|
|
16
|
+
Rust = "rust",
|
|
17
|
+
CSharp = "csharp"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* File extensions mapped to languages
|
|
21
|
+
*/
|
|
22
|
+
export declare const LANGUAGE_EXTENSIONS: Record<string, Language>;
|
|
23
|
+
/**
|
|
24
|
+
* Location information in source code
|
|
25
|
+
*/
|
|
26
|
+
export interface SourceLocation {
|
|
27
|
+
line: number;
|
|
28
|
+
column: number;
|
|
29
|
+
}
|
|
30
|
+
export interface SourceRange {
|
|
31
|
+
start: SourceLocation;
|
|
32
|
+
end: SourceLocation;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Common AST node type (language-agnostic)
|
|
36
|
+
*/
|
|
37
|
+
export interface CommonASTNode {
|
|
38
|
+
type: string;
|
|
39
|
+
loc?: SourceRange;
|
|
40
|
+
raw?: any;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Export information (function, class, variable, etc.)
|
|
44
|
+
*/
|
|
45
|
+
export interface ExportInfo {
|
|
46
|
+
name: string;
|
|
47
|
+
type: 'function' | 'class' | 'const' | 'type' | 'interface' | 'default' | 'variable';
|
|
48
|
+
loc?: SourceRange;
|
|
49
|
+
/** Imports used within this export */
|
|
50
|
+
imports?: string[];
|
|
51
|
+
/** Dependencies on other exports in same file */
|
|
52
|
+
dependencies?: string[];
|
|
53
|
+
/** TypeScript types referenced */
|
|
54
|
+
typeReferences?: string[];
|
|
55
|
+
/** For methods: parent class name */
|
|
56
|
+
parentClass?: string;
|
|
57
|
+
/** For functions/methods: parameters */
|
|
58
|
+
parameters?: string[];
|
|
59
|
+
/** Visibility (public, private, protected) */
|
|
60
|
+
visibility?: 'public' | 'private' | 'protected';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Import information
|
|
64
|
+
*/
|
|
65
|
+
export interface ImportInfo {
|
|
66
|
+
/** Module being imported from */
|
|
67
|
+
source: string;
|
|
68
|
+
/** What's being imported */
|
|
69
|
+
specifiers: string[];
|
|
70
|
+
/** Is this a type-only import (TypeScript) */
|
|
71
|
+
isTypeOnly?: boolean;
|
|
72
|
+
/** Location in source */
|
|
73
|
+
loc?: SourceRange;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parse result containing exports and imports
|
|
77
|
+
*/
|
|
78
|
+
export interface ParseResult {
|
|
79
|
+
exports: ExportInfo[];
|
|
80
|
+
imports: ImportInfo[];
|
|
81
|
+
/** Language of the parsed file */
|
|
82
|
+
language: Language;
|
|
83
|
+
/** Any parse warnings (non-fatal) */
|
|
84
|
+
warnings?: string[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Naming convention rules per language
|
|
88
|
+
*/
|
|
89
|
+
export interface NamingConvention {
|
|
90
|
+
/** Allowed variable naming patterns */
|
|
91
|
+
variablePattern: RegExp;
|
|
92
|
+
/** Allowed function naming patterns */
|
|
93
|
+
functionPattern: RegExp;
|
|
94
|
+
/** Allowed class naming patterns */
|
|
95
|
+
classPattern: RegExp;
|
|
96
|
+
/** Allowed constant naming patterns */
|
|
97
|
+
constantPattern: RegExp;
|
|
98
|
+
/** Language-specific exceptions (e.g., __init__ in Python) */
|
|
99
|
+
exceptions?: string[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Language-specific configuration
|
|
103
|
+
*/
|
|
104
|
+
export interface LanguageConfig {
|
|
105
|
+
language: Language;
|
|
106
|
+
/** File extensions for this language */
|
|
107
|
+
extensions: string[];
|
|
108
|
+
/** Naming conventions */
|
|
109
|
+
namingConventions: NamingConvention;
|
|
110
|
+
/** Common abbreviations allowed */
|
|
111
|
+
allowedAbbreviations?: string[];
|
|
112
|
+
/** Language-specific keywords to ignore */
|
|
113
|
+
keywords?: string[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Abstract interface for language parsers
|
|
117
|
+
* Each language implementation should implement this interface
|
|
118
|
+
*/
|
|
119
|
+
export interface LanguageParser {
|
|
120
|
+
/** Language this parser handles */
|
|
121
|
+
readonly language: Language;
|
|
122
|
+
/** File extensions this parser supports */
|
|
123
|
+
readonly extensions: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Parse source code and extract structure
|
|
126
|
+
* @param code - Source code to parse
|
|
127
|
+
* @param filePath - Path to the file (for context)
|
|
128
|
+
* @returns Parse result with exports and imports
|
|
129
|
+
* @throws ParseError if code has syntax errors
|
|
130
|
+
*/
|
|
131
|
+
parse(code: string, filePath: string): ParseResult;
|
|
132
|
+
/**
|
|
133
|
+
* Get naming conventions for this language
|
|
134
|
+
*/
|
|
135
|
+
getNamingConventions(): NamingConvention;
|
|
136
|
+
/**
|
|
137
|
+
* Check if this parser can handle a file
|
|
138
|
+
* @param filePath - File path to check
|
|
139
|
+
*/
|
|
140
|
+
canHandle(filePath: string): boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parser error with location information
|
|
144
|
+
*/
|
|
145
|
+
export declare class ParseError extends Error {
|
|
146
|
+
readonly filePath: string;
|
|
147
|
+
readonly loc?: SourceLocation | undefined;
|
|
148
|
+
constructor(message: string, filePath: string, loc?: SourceLocation | undefined);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Statistics about parsed code
|
|
152
|
+
*/
|
|
153
|
+
export interface ParseStatistics {
|
|
154
|
+
language: Language;
|
|
155
|
+
filesAnalyzed: number;
|
|
156
|
+
totalExports: number;
|
|
157
|
+
totalImports: number;
|
|
158
|
+
parseErrors: number;
|
|
159
|
+
warnings: number;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/types/language.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,EAAE,OAAO;IACT,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAUxD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,cAAc,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,WAAW,CAAC;IAElB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;IACrF,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,sCAAsC;IACtC,OAAO,C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,CAAC;IACpC,mCAAmC;IACnC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAE9B;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC;IAEnD;;OAEG;IACH,oBAAoB,IAAI,gBAAgB,CAAC;IAEzC;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CACtC;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;aAGjB,QAAQ,EAAE,MAAM;aAChB,GAAG,CAAC,EAAE,cAAc;gBAFpC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,cAAc,YAAA;CAKvC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language-agnostic AST and parser interfaces for multi-language support
|
|
3
|
+
*
|
|
4
|
+
* This module provides abstractions for parsing different programming languages
|
|
5
|
+
* while maintaining a consistent interface for analysis tools.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported programming languages
|
|
9
|
+
*/
|
|
10
|
+
export var Language;
|
|
11
|
+
(function (Language) {
|
|
12
|
+
Language["TypeScript"] = "typescript";
|
|
13
|
+
Language["JavaScript"] = "javascript";
|
|
14
|
+
Language["Python"] = "python";
|
|
15
|
+
Language["Java"] = "java";
|
|
16
|
+
Language["Go"] = "go";
|
|
17
|
+
Language["Rust"] = "rust";
|
|
18
|
+
Language["CSharp"] = "csharp";
|
|
19
|
+
})(Language || (Language = {}));
|
|
20
|
+
/**
|
|
21
|
+
* File extensions mapped to languages
|
|
22
|
+
*/
|
|
23
|
+
export const LANGUAGE_EXTENSIONS = {
|
|
24
|
+
'.ts': Language.TypeScript,
|
|
25
|
+
'.tsx': Language.TypeScript,
|
|
26
|
+
'.js': Language.JavaScript,
|
|
27
|
+
'.jsx': Language.JavaScript,
|
|
28
|
+
'.py': Language.Python,
|
|
29
|
+
'.java': Language.Java,
|
|
30
|
+
'.go': Language.Go,
|
|
31
|
+
'.rs': Language.Rust,
|
|
32
|
+
'.cs': Language.CSharp,
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Parser error with location information
|
|
36
|
+
*/
|
|
37
|
+
export class ParseError extends Error {
|
|
38
|
+
constructor(message, filePath, loc) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.filePath = filePath;
|
|
41
|
+
this.loc = loc;
|
|
42
|
+
this.name = 'ParseError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/types/language.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,6BAAiB,CAAA;AACnB,CAAC,EARW,QAAQ,KAAR,QAAQ,QAQnB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA6B;IAC3D,KAAK,EAAE,QAAQ,CAAC,UAAU;IAC1B,MAAM,EAAE,QAAQ,CAAC,UAAU;IAC3B,KAAK,EAAE,QAAQ,CAAC,UAAU;IAC1B,MAAM,EAAE,QAAQ,CAAC,UAAU;IAC3B,KAAK,EAAE,QAAQ,CAAC,MAAM;IACtB,OAAO,EAAE,QAAQ,CAAC,IAAI;IACtB,KAAK,EAAE,QAAQ,CAAC,EAAE;IAClB,KAAK,EAAE,QAAQ,CAAC,IAAI;IACpB,KAAK,EAAE,QAAQ,CAAC,MAAM;CACvB,CAAC;AAuIF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YACE,OAAe,EACC,QAAgB,EAChB,GAAoB;QAEpC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,QAAG,GAAH,GAAG,CAAiB;QAGpC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface AnalysisResult {
|
|
2
|
+
fileName: string;
|
|
3
|
+
issues: Issue[];
|
|
4
|
+
metrics: Metrics;
|
|
5
|
+
}
|
|
6
|
+
export interface Issue {
|
|
7
|
+
type: IssueType;
|
|
8
|
+
severity: 'critical' | 'major' | 'minor' | 'info';
|
|
9
|
+
message: string;
|
|
10
|
+
location: Location;
|
|
11
|
+
suggestion?: string;
|
|
12
|
+
}
|
|
13
|
+
export type IssueType = 'duplicate-pattern' | 'context-fragmentation' | 'doc-drift' | 'naming-inconsistency' | 'naming-quality' | 'pattern-inconsistency' | 'architecture-inconsistency' | 'dead-code' | 'circular-dependency' | 'missing-types';
|
|
14
|
+
export interface Location {
|
|
15
|
+
file: string;
|
|
16
|
+
line: number;
|
|
17
|
+
column?: number;
|
|
18
|
+
endLine?: number;
|
|
19
|
+
endColumn?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface Metrics {
|
|
22
|
+
tokenCost?: number;
|
|
23
|
+
complexityScore?: number;
|
|
24
|
+
consistencyScore?: number;
|
|
25
|
+
docFreshnessScore?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ScanOptions {
|
|
28
|
+
rootDir: string;
|
|
29
|
+
include?: string[];
|
|
30
|
+
exclude?: string[];
|
|
31
|
+
maxDepth?: number;
|
|
32
|
+
}
|
|
33
|
+
export 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
|
+
}
|
|
90
|
+
export interface Report {
|
|
91
|
+
summary: {
|
|
92
|
+
totalFiles: number;
|
|
93
|
+
totalIssues: number;
|
|
94
|
+
criticalIssues: number;
|
|
95
|
+
majorIssues: number;
|
|
96
|
+
};
|
|
97
|
+
results: AnalysisResult[];
|
|
98
|
+
metrics: {
|
|
99
|
+
overallScore: number;
|
|
100
|
+
tokenCostTotal: number;
|
|
101
|
+
avgConsistency: number;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,SAAS,GACjB,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