@aiready/core 0.23.2 → 0.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/parser-factory.test.d.ts +1 -1
- package/dist/__tests__/parser-factory.test.js +62 -50
- package/dist/__tests__/python-parser.test.d.ts +1 -1
- package/dist/__tests__/python-parser.test.js +111 -109
- package/dist/__tests__/scoring.test.d.ts +1 -1
- package/dist/__tests__/scoring.test.js +193 -176
- package/dist/chunk-3YI4IS3D.mjs +191 -173
- package/dist/chunk-5HIXDC3X.mjs +273 -251
- package/dist/chunk-5V3L53AE.mjs +805 -0
- package/dist/chunk-CKVKHN3G.mjs +228 -211
- package/dist/chunk-COHIBX3Q.mjs +213 -195
- package/dist/chunk-CWRCDSKZ.mjs +91 -82
- package/dist/chunk-D3D3NCRR.mjs +147 -129
- package/dist/chunk-HCFYP7UD.mjs +805 -0
- package/dist/chunk-HFLFBA6F.mjs +79 -72
- package/dist/chunk-HKSARRCD.mjs +66 -58
- package/dist/chunk-JJ5JL5FX.mjs +91 -82
- package/dist/chunk-KDSTXVLQ.mjs +724 -0
- package/dist/chunk-KI7XORTN.mjs +91 -82
- package/dist/chunk-LTMHFNFK.mjs +690 -0
- package/dist/chunk-LTNXTXRI.mjs +228 -211
- package/dist/chunk-M22BXHBR.mjs +805 -0
- package/dist/chunk-MH3A3LX6.mjs +200 -182
- package/dist/chunk-NGHT7JOG.mjs +697 -0
- package/dist/chunk-OQ6IGDXG.mjs +147 -129
- package/dist/chunk-QAFB3HXQ.mjs +181 -165
- package/dist/chunk-QQBKXHLU.mjs +678 -0
- package/dist/chunk-RDHYGES7.mjs +678 -0
- package/dist/chunk-SWTDBVYJ.mjs +228 -213
- package/dist/chunk-UIWL5JQB.mjs +79 -72
- package/dist/chunk-UQGI67WR.mjs +79 -72
- package/dist/chunk-UTZOO4XO.mjs +147 -131
- package/dist/chunk-X4F46I5L.mjs +213 -195
- package/dist/chunk-XKK7YHPX.mjs +204 -186
- package/dist/chunk-YCA4FTEK.mjs +190 -172
- package/dist/chunk-ZSZRRTJM.mjs +719 -0
- package/dist/client-BgmiMoil.d.mts +1344 -0
- package/dist/client-BgmiMoil.d.ts +1344 -0
- package/dist/client-BxGrPuuN.d.mts +1191 -0
- package/dist/client-BxGrPuuN.d.ts +1191 -0
- package/dist/client-D-cn9ydj.d.mts +1136 -0
- package/dist/client-D-cn9ydj.d.ts +1136 -0
- package/dist/client-D9seCH4K.d.mts +1334 -0
- package/dist/client-D9seCH4K.d.ts +1334 -0
- package/dist/client-DIXIh7rw.d.mts +1193 -0
- package/dist/client-DIXIh7rw.d.ts +1193 -0
- package/dist/client-DVHXWOHw.d.mts +1245 -0
- package/dist/client-DVHXWOHw.d.ts +1245 -0
- package/dist/client.d.mts +2 -1098
- package/dist/client.d.ts +2 -1098
- package/dist/client.js +23 -43
- package/dist/client.mjs +3 -25
- package/dist/index.d.mts +325 -103
- package/dist/index.d.ts +325 -103
- package/dist/index.js +307 -324
- package/dist/index.mjs +283 -306
- package/dist/parsers/parser-factory.d.ts +45 -45
- package/dist/parsers/parser-factory.js +86 -84
- package/dist/parsers/python-parser.d.ts +33 -28
- package/dist/parsers/python-parser.js +224 -222
- package/dist/parsers/typescript-parser.d.ts +15 -10
- package/dist/parsers/typescript-parser.js +223 -197
- package/dist/scoring.d.ts +59 -49
- package/dist/scoring.js +129 -127
- package/dist/types/language.d.ts +104 -93
- package/dist/types/language.js +23 -23
- package/dist/types.d.ts +105 -87
- package/dist/types.js +1 -1
- package/dist/utils/ast-parser.d.ts +42 -33
- package/dist/utils/ast-parser.js +159 -162
- package/dist/utils/cli-helpers.d.ts +27 -10
- package/dist/utils/cli-helpers.js +45 -43
- package/dist/utils/config.d.ts +8 -3
- package/dist/utils/config.js +67 -69
- package/dist/utils/file-scanner.d.ts +1 -1
- package/dist/utils/file-scanner.js +80 -76
- package/dist/utils/metrics.d.ts +1 -1
- package/dist/utils/metrics.js +2 -2
- package/package.json +1 -1
package/dist/scoring.js
CHANGED
|
@@ -9,27 +9,27 @@
|
|
|
9
9
|
* New tools get weight of 10 if not specified.
|
|
10
10
|
*/
|
|
11
11
|
export const DEFAULT_TOOL_WEIGHTS = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
'pattern-detect': 40,
|
|
13
|
+
'context-analyzer': 35,
|
|
14
|
+
consistency: 25,
|
|
15
|
+
'doc-drift': 20,
|
|
16
|
+
deps: 15,
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Tool name normalization map (shorthand -> full name)
|
|
20
20
|
*/
|
|
21
21
|
export const TOOL_NAME_MAP = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
patterns: 'pattern-detect',
|
|
23
|
+
context: 'context-analyzer',
|
|
24
|
+
consistency: 'consistency',
|
|
25
|
+
'doc-drift': 'doc-drift',
|
|
26
|
+
deps: 'deps',
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* Normalize tool name from shorthand to full name
|
|
30
30
|
*/
|
|
31
31
|
export function normalizeToolName(shortName) {
|
|
32
|
-
|
|
32
|
+
return TOOL_NAME_MAP[shortName] || shortName;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Get tool weight with fallback priority:
|
|
@@ -39,37 +39,37 @@ export function normalizeToolName(shortName) {
|
|
|
39
39
|
* 4. 10 (for unknown tools)
|
|
40
40
|
*/
|
|
41
41
|
export function getToolWeight(toolName, toolConfig, cliOverride) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Parse weight string from CLI (e.g., "patterns:50,context:30")
|
|
55
55
|
*/
|
|
56
56
|
export function parseWeightString(weightStr) {
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
}
|
|
57
|
+
const weights = new Map();
|
|
58
|
+
if (!weightStr) {
|
|
72
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
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Calculate overall AI Readiness Score from multiple tool scores.
|
|
@@ -80,116 +80,118 @@ export function parseWeightString(weightStr) {
|
|
|
80
80
|
* based on which tools actually ran.
|
|
81
81
|
*/
|
|
82
82
|
export function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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 =
|
|
92
|
+
cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 10;
|
|
93
|
+
weights.set(toolName, weight);
|
|
94
|
+
}
|
|
95
|
+
// Calculate weighted sum and total weight
|
|
96
|
+
let weightedSum = 0;
|
|
97
|
+
let totalWeight = 0;
|
|
98
|
+
const breakdown = [];
|
|
99
|
+
const toolsUsed = [];
|
|
100
|
+
const calculationWeights = {};
|
|
101
|
+
for (const [toolName, output] of toolOutputs.entries()) {
|
|
102
|
+
const weight = weights.get(toolName) || 10;
|
|
103
|
+
const weightedScore = output.score * weight;
|
|
104
|
+
weightedSum += weightedScore;
|
|
105
|
+
totalWeight += weight;
|
|
106
|
+
toolsUsed.push(toolName);
|
|
107
|
+
calculationWeights[toolName] = weight;
|
|
108
|
+
breakdown.push(output);
|
|
109
|
+
}
|
|
110
|
+
// Calculate final score
|
|
111
|
+
const overall = Math.round(weightedSum / totalWeight);
|
|
112
|
+
// Determine rating
|
|
113
|
+
const rating = getRating(overall);
|
|
114
|
+
// Build formula string
|
|
115
|
+
const formulaParts = Array.from(toolOutputs.entries()).map(
|
|
116
|
+
([name, output]) => {
|
|
117
|
+
const w = weights.get(name) || 10;
|
|
118
|
+
return `(${output.score} × ${w})`;
|
|
93
119
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
};
|
|
120
|
+
);
|
|
121
|
+
const formulaStr = `[${formulaParts.join(' + ')}] / ${totalWeight} = ${overall}`;
|
|
122
|
+
return {
|
|
123
|
+
overall,
|
|
124
|
+
rating,
|
|
125
|
+
timestamp: new Date().toISOString(),
|
|
126
|
+
toolsUsed,
|
|
127
|
+
breakdown,
|
|
128
|
+
calculation: {
|
|
129
|
+
formula: formulaStr,
|
|
130
|
+
weights: calculationWeights,
|
|
131
|
+
normalized: formulaStr,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
132
134
|
}
|
|
133
135
|
/**
|
|
134
136
|
* Convert numeric score to rating category
|
|
135
137
|
*/
|
|
136
138
|
export function getRating(score) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return 'Fair';
|
|
143
|
-
if (score >= 40)
|
|
144
|
-
return 'Needs Work';
|
|
145
|
-
return 'Critical';
|
|
139
|
+
if (score >= 90) return 'Excellent';
|
|
140
|
+
if (score >= 75) return 'Good';
|
|
141
|
+
if (score >= 60) return 'Fair';
|
|
142
|
+
if (score >= 40) return 'Needs Work';
|
|
143
|
+
return 'Critical';
|
|
146
144
|
}
|
|
147
145
|
/**
|
|
148
146
|
* Get rating emoji and color for display
|
|
149
147
|
*/
|
|
150
148
|
export function getRatingDisplay(rating) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
149
|
+
switch (rating) {
|
|
150
|
+
case 'Excellent':
|
|
151
|
+
return { emoji: '✅', color: 'green' };
|
|
152
|
+
case 'Good':
|
|
153
|
+
return { emoji: '👍', color: 'blue' };
|
|
154
|
+
case 'Fair':
|
|
155
|
+
return { emoji: '⚠️', color: 'yellow' };
|
|
156
|
+
case 'Needs Work':
|
|
157
|
+
return { emoji: '🔨', color: 'orange' };
|
|
158
|
+
case 'Critical':
|
|
159
|
+
return { emoji: '❌', color: 'red' };
|
|
160
|
+
}
|
|
163
161
|
}
|
|
164
162
|
/**
|
|
165
163
|
* Format score for display with rating
|
|
166
164
|
*/
|
|
167
165
|
export function formatScore(result) {
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
const { emoji, color } = getRatingDisplay(result.rating);
|
|
167
|
+
return `${result.overall}/100 (${result.rating}) ${emoji}`;
|
|
170
168
|
}
|
|
171
169
|
/**
|
|
172
170
|
* Format individual tool score for display
|
|
173
171
|
*/
|
|
174
172
|
export function formatToolScore(output) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
173
|
+
let result = ` Score: ${output.score}/100\n\n`;
|
|
174
|
+
if (output.factors && output.factors.length > 0) {
|
|
175
|
+
result += ` Factors:\n`;
|
|
176
|
+
output.factors.forEach((factor) => {
|
|
177
|
+
const impactSign = factor.impact > 0 ? '+' : '';
|
|
178
|
+
result += ` • ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}\n`;
|
|
179
|
+
});
|
|
180
|
+
result += '\n';
|
|
181
|
+
}
|
|
182
|
+
if (output.recommendations && output.recommendations.length > 0) {
|
|
183
|
+
result += ` Recommendations:\n`;
|
|
184
|
+
output.recommendations.forEach((rec, i) => {
|
|
185
|
+
const priorityIcon =
|
|
186
|
+
rec.priority === 'high'
|
|
187
|
+
? '🔴'
|
|
188
|
+
: rec.priority === 'medium'
|
|
189
|
+
? '🟡'
|
|
190
|
+
: '🔵';
|
|
191
|
+
result += ` ${i + 1}. ${priorityIcon} ${rec.action}\n`;
|
|
192
|
+
result += ` Impact: +${rec.estimatedImpact} points\n\n`;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
194
196
|
}
|
|
195
|
-
//# sourceMappingURL=scoring.js.map
|
|
197
|
+
//# sourceMappingURL=scoring.js.map
|
package/dist/types/language.d.ts
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* Supported programming languages
|
|
9
9
|
*/
|
|
10
10
|
export declare enum Language {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
TypeScript = 'typescript',
|
|
12
|
+
JavaScript = 'javascript',
|
|
13
|
+
Python = 'python',
|
|
14
|
+
Java = 'java',
|
|
15
|
+
Go = 'go',
|
|
16
|
+
Rust = 'rust',
|
|
17
|
+
CSharp = 'csharp',
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* File extensions mapped to languages
|
|
@@ -24,138 +24,149 @@ export declare const LANGUAGE_EXTENSIONS: Record<string, Language>;
|
|
|
24
24
|
* Location information in source code
|
|
25
25
|
*/
|
|
26
26
|
export interface SourceLocation {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
line: number;
|
|
28
|
+
column: number;
|
|
29
29
|
}
|
|
30
30
|
export interface SourceRange {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
start: SourceLocation;
|
|
32
|
+
end: SourceLocation;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Common AST node type (language-agnostic)
|
|
36
36
|
*/
|
|
37
37
|
export interface CommonASTNode {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
type: string;
|
|
39
|
+
loc?: SourceRange;
|
|
40
|
+
raw?: any;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Export information (function, class, variable, etc.)
|
|
44
44
|
*/
|
|
45
45
|
export interface ExportInfo {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
name: string;
|
|
47
|
+
type:
|
|
48
|
+
| 'function'
|
|
49
|
+
| 'class'
|
|
50
|
+
| 'const'
|
|
51
|
+
| 'type'
|
|
52
|
+
| 'interface'
|
|
53
|
+
| 'default'
|
|
54
|
+
| 'variable';
|
|
55
|
+
loc?: SourceRange;
|
|
56
|
+
/** Imports used within this export */
|
|
57
|
+
imports?: string[];
|
|
58
|
+
/** Dependencies on other exports in same file */
|
|
59
|
+
dependencies?: string[];
|
|
60
|
+
/** TypeScript types referenced */
|
|
61
|
+
typeReferences?: string[];
|
|
62
|
+
/** For methods: parent class name */
|
|
63
|
+
parentClass?: string;
|
|
64
|
+
/** For functions/methods: parameters */
|
|
65
|
+
parameters?: string[];
|
|
66
|
+
/** Visibility (public, private, protected) */
|
|
67
|
+
visibility?: 'public' | 'private' | 'protected';
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* Import information
|
|
64
71
|
*/
|
|
65
72
|
export interface ImportInfo {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
/** Module being imported from */
|
|
74
|
+
source: string;
|
|
75
|
+
/** What's being imported */
|
|
76
|
+
specifiers: string[];
|
|
77
|
+
/** Is this a type-only import (TypeScript) */
|
|
78
|
+
isTypeOnly?: boolean;
|
|
79
|
+
/** Location in source */
|
|
80
|
+
loc?: SourceRange;
|
|
74
81
|
}
|
|
75
82
|
/**
|
|
76
83
|
* Parse result containing exports and imports
|
|
77
84
|
*/
|
|
78
85
|
export interface ParseResult {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
exports: ExportInfo[];
|
|
87
|
+
imports: ImportInfo[];
|
|
88
|
+
/** Language of the parsed file */
|
|
89
|
+
language: Language;
|
|
90
|
+
/** Any parse warnings (non-fatal) */
|
|
91
|
+
warnings?: string[];
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* Naming convention rules per language
|
|
88
95
|
*/
|
|
89
96
|
export interface NamingConvention {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
/** Allowed variable naming patterns */
|
|
98
|
+
variablePattern: RegExp;
|
|
99
|
+
/** Allowed function naming patterns */
|
|
100
|
+
functionPattern: RegExp;
|
|
101
|
+
/** Allowed class naming patterns */
|
|
102
|
+
classPattern: RegExp;
|
|
103
|
+
/** Allowed constant naming patterns */
|
|
104
|
+
constantPattern: RegExp;
|
|
105
|
+
/** Language-specific exceptions (e.g., __init__ in Python) */
|
|
106
|
+
exceptions?: string[];
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
102
109
|
* Language-specific configuration
|
|
103
110
|
*/
|
|
104
111
|
export interface LanguageConfig {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
language: Language;
|
|
113
|
+
/** File extensions for this language */
|
|
114
|
+
extensions: string[];
|
|
115
|
+
/** Naming conventions */
|
|
116
|
+
namingConventions: NamingConvention;
|
|
117
|
+
/** Common abbreviations allowed */
|
|
118
|
+
allowedAbbreviations?: string[];
|
|
119
|
+
/** Language-specific keywords to ignore */
|
|
120
|
+
keywords?: string[];
|
|
114
121
|
}
|
|
115
122
|
/**
|
|
116
123
|
* Abstract interface for language parsers
|
|
117
124
|
* Each language implementation should implement this interface
|
|
118
125
|
*/
|
|
119
126
|
export interface LanguageParser {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
/** Language this parser handles */
|
|
128
|
+
readonly language: Language;
|
|
129
|
+
/** File extensions this parser supports */
|
|
130
|
+
readonly extensions: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Parse source code and extract structure
|
|
133
|
+
* @param code - Source code to parse
|
|
134
|
+
* @param filePath - Path to the file (for context)
|
|
135
|
+
* @returns Parse result with exports and imports
|
|
136
|
+
* @throws ParseError if code has syntax errors
|
|
137
|
+
*/
|
|
138
|
+
parse(code: string, filePath: string): ParseResult;
|
|
139
|
+
/**
|
|
140
|
+
* Get naming conventions for this language
|
|
141
|
+
*/
|
|
142
|
+
getNamingConventions(): NamingConvention;
|
|
143
|
+
/**
|
|
144
|
+
* Check if this parser can handle a file
|
|
145
|
+
* @param filePath - File path to check
|
|
146
|
+
*/
|
|
147
|
+
canHandle(filePath: string): boolean;
|
|
141
148
|
}
|
|
142
149
|
/**
|
|
143
150
|
* Parser error with location information
|
|
144
151
|
*/
|
|
145
152
|
export declare class ParseError extends Error {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
readonly filePath: string;
|
|
154
|
+
readonly loc?: SourceLocation | undefined;
|
|
155
|
+
constructor(
|
|
156
|
+
message: string,
|
|
157
|
+
filePath: string,
|
|
158
|
+
loc?: SourceLocation | undefined
|
|
159
|
+
);
|
|
149
160
|
}
|
|
150
161
|
/**
|
|
151
162
|
* Statistics about parsed code
|
|
152
163
|
*/
|
|
153
164
|
export interface ParseStatistics {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
language: Language;
|
|
166
|
+
filesAnalyzed: number;
|
|
167
|
+
totalExports: number;
|
|
168
|
+
totalImports: number;
|
|
169
|
+
parseErrors: number;
|
|
170
|
+
warnings: number;
|
|
160
171
|
}
|
|
161
|
-
//# sourceMappingURL=language.d.ts.map
|
|
172
|
+
//# sourceMappingURL=language.d.ts.map
|
package/dist/types/language.js
CHANGED
|
@@ -9,37 +9,37 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export var Language;
|
|
11
11
|
(function (Language) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
19
|
})(Language || (Language = {}));
|
|
20
20
|
/**
|
|
21
21
|
* File extensions mapped to languages
|
|
22
22
|
*/
|
|
23
23
|
export const LANGUAGE_EXTENSIONS = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Parser error with location information
|
|
36
36
|
*/
|
|
37
37
|
export class ParseError extends Error {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
constructor(message, filePath, loc) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.filePath = filePath;
|
|
41
|
+
this.loc = loc;
|
|
42
|
+
this.name = 'ParseError';
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
|
-
//# sourceMappingURL=language.js.map
|
|
45
|
+
//# sourceMappingURL=language.js.map
|