@aiready/core 0.23.5 → 0.23.6
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/{client-BF9NjhE8.d.mts → client-CKcjnPXt.d.mts} +1 -0
- package/dist/{client-BF9NjhE8.d.ts → client-CKcjnPXt.d.ts} +1 -0
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +74 -13
- package/dist/index.mjs +74 -13
- package/package.json +1 -1
- package/dist/__tests__/parser-factory.test.d.ts +0 -5
- package/dist/__tests__/parser-factory.test.d.ts.map +0 -1
- package/dist/__tests__/parser-factory.test.js +0 -70
- package/dist/__tests__/parser-factory.test.js.map +0 -1
- package/dist/__tests__/python-parser.test.d.ts +0 -5
- package/dist/__tests__/python-parser.test.d.ts.map +0 -1
- package/dist/__tests__/python-parser.test.js +0 -194
- package/dist/__tests__/python-parser.test.js.map +0 -1
- package/dist/__tests__/scoring.test.d.ts +0 -2
- package/dist/__tests__/scoring.test.d.ts.map +0 -1
- package/dist/__tests__/scoring.test.js +0 -197
- package/dist/__tests__/scoring.test.js.map +0 -1
- package/dist/chunk-3YI4IS3D.mjs +0 -601
- package/dist/chunk-5HIXDC3X.mjs +0 -716
- package/dist/chunk-5V3L53AE.mjs +0 -805
- package/dist/chunk-CKVKHN3G.mjs +0 -660
- package/dist/chunk-COHIBX3Q.mjs +0 -635
- package/dist/chunk-CWRCDSKZ.mjs +0 -417
- package/dist/chunk-D3D3NCRR.mjs +0 -556
- package/dist/chunk-HCFYP7UD.mjs +0 -805
- package/dist/chunk-HFLFBA6F.mjs +0 -417
- package/dist/chunk-HKSARRCD.mjs +0 -365
- package/dist/chunk-JJ5JL5FX.mjs +0 -417
- package/dist/chunk-KDSTXVLQ.mjs +0 -724
- package/dist/chunk-KI7XORTN.mjs +0 -417
- package/dist/chunk-LTMHFNFK.mjs +0 -690
- package/dist/chunk-LTNXTXRI.mjs +0 -659
- package/dist/chunk-M22BXHBR.mjs +0 -805
- package/dist/chunk-MH3A3LX6.mjs +0 -615
- package/dist/chunk-NGHT7JOG.mjs +0 -697
- package/dist/chunk-OQ6IGDXG.mjs +0 -553
- package/dist/chunk-QAFB3HXQ.mjs +0 -590
- package/dist/chunk-QQBKXHLU.mjs +0 -678
- package/dist/chunk-RDHYGES7.mjs +0 -678
- package/dist/chunk-SWTDBVYJ.mjs +0 -660
- package/dist/chunk-UIWL5JQB.mjs +0 -417
- package/dist/chunk-UQGI67WR.mjs +0 -417
- package/dist/chunk-UTZOO4XO.mjs +0 -553
- package/dist/chunk-X4F46I5L.mjs +0 -635
- package/dist/chunk-XKK7YHPX.mjs +0 -619
- package/dist/chunk-YCA4FTEK.mjs +0 -600
- package/dist/chunk-ZSZRRTJM.mjs +0 -719
- package/dist/client-BgmiMoil.d.mts +0 -1344
- package/dist/client-BgmiMoil.d.ts +0 -1344
- package/dist/client-BxGrPuuN.d.mts +0 -1191
- package/dist/client-BxGrPuuN.d.ts +0 -1191
- package/dist/client-D-cn9ydj.d.mts +0 -1136
- package/dist/client-D-cn9ydj.d.ts +0 -1136
- package/dist/client-D9seCH4K.d.mts +0 -1334
- package/dist/client-D9seCH4K.d.ts +0 -1334
- package/dist/client-DIXIh7rw.d.mts +0 -1193
- package/dist/client-DIXIh7rw.d.ts +0 -1193
- package/dist/client-DVHXWOHw.d.mts +0 -1245
- package/dist/client-DVHXWOHw.d.ts +0 -1245
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parsers/parser-factory.d.ts +0 -69
- package/dist/parsers/parser-factory.d.ts.map +0 -1
- package/dist/parsers/parser-factory.js +0 -116
- package/dist/parsers/parser-factory.js.map +0 -1
- package/dist/parsers/python-parser.d.ts +0 -47
- package/dist/parsers/python-parser.d.ts.map +0 -1
- package/dist/parsers/python-parser.js +0 -243
- package/dist/parsers/python-parser.js.map +0 -1
- package/dist/parsers/typescript-parser.d.ts +0 -22
- package/dist/parsers/typescript-parser.d.ts.map +0 -1
- package/dist/parsers/typescript-parser.js +0 -242
- package/dist/parsers/typescript-parser.js.map +0 -1
- package/dist/scoring.d.ts +0 -120
- package/dist/scoring.d.ts.map +0 -1
- package/dist/scoring.js +0 -197
- package/dist/scoring.js.map +0 -1
- package/dist/types/language.d.ts +0 -172
- package/dist/types/language.d.ts.map +0 -1
- package/dist/types/language.js +0 -45
- package/dist/types/language.js.map +0 -1
- package/dist/types.d.ts +0 -122
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/ast-parser.d.ts +0 -59
- package/dist/utils/ast-parser.d.ts.map +0 -1
- package/dist/utils/ast-parser.js +0 -213
- package/dist/utils/ast-parser.js.map +0 -1
- package/dist/utils/cli-helpers.d.ts +0 -54
- package/dist/utils/cli-helpers.d.ts.map +0 -1
- package/dist/utils/cli-helpers.js +0 -78
- package/dist/utils/cli-helpers.js.map +0 -1
- package/dist/utils/config.d.ts +0 -9
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -80
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/file-scanner.d.ts +0 -16
- package/dist/utils/file-scanner.d.ts.map +0 -1
- package/dist/utils/file-scanner.js +0 -104
- package/dist/utils/file-scanner.js.map +0 -1
- package/dist/utils/metrics.d.ts +0 -6
- package/dist/utils/metrics.d.ts.map +0 -1
- package/dist/utils/metrics.js +0 -8
- package/dist/utils/metrics.js.map +0 -1
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript/JavaScript Parser
|
|
3
|
-
*
|
|
4
|
-
* Parses TypeScript and JavaScript files using @typescript-eslint/typescript-estree
|
|
5
|
-
*/
|
|
6
|
-
import { parse } from '@typescript-eslint/typescript-estree';
|
|
7
|
-
import { Language, ParseError } from '../types/language';
|
|
8
|
-
export class TypeScriptParser {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.language = Language.TypeScript;
|
|
11
|
-
this.extensions = ['.ts', '.tsx', '.js', '.jsx'];
|
|
12
|
-
}
|
|
13
|
-
parse(code, filePath) {
|
|
14
|
-
try {
|
|
15
|
-
const isJavaScript = filePath.match(/\.jsx?$/i);
|
|
16
|
-
const ast = parse(code, {
|
|
17
|
-
loc: true,
|
|
18
|
-
range: true,
|
|
19
|
-
jsx: filePath.match(/\.[jt]sx$/i) !== null,
|
|
20
|
-
filePath,
|
|
21
|
-
sourceType: 'module',
|
|
22
|
-
ecmaVersion: 'latest',
|
|
23
|
-
});
|
|
24
|
-
const imports = this.extractImports(ast);
|
|
25
|
-
const exports = this.extractExports(ast, imports);
|
|
26
|
-
return {
|
|
27
|
-
exports,
|
|
28
|
-
imports,
|
|
29
|
-
language: isJavaScript ? Language.JavaScript : Language.TypeScript,
|
|
30
|
-
warnings: [],
|
|
31
|
-
};
|
|
32
|
-
} catch (error) {
|
|
33
|
-
const err = error;
|
|
34
|
-
throw new ParseError(
|
|
35
|
-
`Failed to parse ${filePath}: ${err.message}`,
|
|
36
|
-
filePath
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
getNamingConventions() {
|
|
41
|
-
return {
|
|
42
|
-
// camelCase for variables and functions
|
|
43
|
-
variablePattern: /^[a-z][a-zA-Z0-9]*$/,
|
|
44
|
-
functionPattern: /^[a-z][a-zA-Z0-9]*$/,
|
|
45
|
-
// PascalCase for classes
|
|
46
|
-
classPattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
47
|
-
// UPPER_CASE for constants
|
|
48
|
-
constantPattern: /^[A-Z][A-Z0-9_]*$/,
|
|
49
|
-
// Common exceptions (React hooks, etc.)
|
|
50
|
-
exceptions: ['__filename', '__dirname', '__esModule'],
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
canHandle(filePath) {
|
|
54
|
-
return this.extensions.some((ext) => filePath.toLowerCase().endsWith(ext));
|
|
55
|
-
}
|
|
56
|
-
extractImports(ast) {
|
|
57
|
-
const imports = [];
|
|
58
|
-
for (const node of ast.body) {
|
|
59
|
-
if (node.type === 'ImportDeclaration') {
|
|
60
|
-
const specifiers = [];
|
|
61
|
-
let isTypeOnly = false;
|
|
62
|
-
// @ts-ignore - importKind exists but not in types
|
|
63
|
-
if (node.importKind === 'type') {
|
|
64
|
-
isTypeOnly = true;
|
|
65
|
-
}
|
|
66
|
-
for (const spec of node.specifiers) {
|
|
67
|
-
if (spec.type === 'ImportSpecifier') {
|
|
68
|
-
const imported = spec.imported;
|
|
69
|
-
const name =
|
|
70
|
-
imported.type === 'Identifier' ? imported.name : imported.value;
|
|
71
|
-
specifiers.push(name);
|
|
72
|
-
} else if (spec.type === 'ImportDefaultSpecifier') {
|
|
73
|
-
specifiers.push('default');
|
|
74
|
-
} else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
75
|
-
specifiers.push('*');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
imports.push({
|
|
79
|
-
source: node.source.value,
|
|
80
|
-
specifiers,
|
|
81
|
-
isTypeOnly,
|
|
82
|
-
loc: node.loc
|
|
83
|
-
? {
|
|
84
|
-
start: {
|
|
85
|
-
line: node.loc.start.line,
|
|
86
|
-
column: node.loc.start.column,
|
|
87
|
-
},
|
|
88
|
-
end: { line: node.loc.end.line, column: node.loc.end.column },
|
|
89
|
-
}
|
|
90
|
-
: undefined,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return imports;
|
|
95
|
-
}
|
|
96
|
-
extractExports(ast, imports) {
|
|
97
|
-
const exports = [];
|
|
98
|
-
const importedNames = new Set(
|
|
99
|
-
imports.flatMap((imp) =>
|
|
100
|
-
imp.specifiers.filter((s) => s !== '*' && s !== 'default')
|
|
101
|
-
)
|
|
102
|
-
);
|
|
103
|
-
for (const node of ast.body) {
|
|
104
|
-
if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
105
|
-
const extracted = this.extractFromDeclaration(
|
|
106
|
-
node.declaration,
|
|
107
|
-
importedNames
|
|
108
|
-
);
|
|
109
|
-
exports.push(...extracted);
|
|
110
|
-
} else if (node.type === 'ExportDefaultDeclaration') {
|
|
111
|
-
// Default export
|
|
112
|
-
let name = 'default';
|
|
113
|
-
let type = 'default';
|
|
114
|
-
if (
|
|
115
|
-
node.declaration.type === 'FunctionDeclaration' &&
|
|
116
|
-
node.declaration.id
|
|
117
|
-
) {
|
|
118
|
-
name = node.declaration.id.name;
|
|
119
|
-
type = 'function';
|
|
120
|
-
} else if (
|
|
121
|
-
node.declaration.type === 'ClassDeclaration' &&
|
|
122
|
-
node.declaration.id
|
|
123
|
-
) {
|
|
124
|
-
name = node.declaration.id.name;
|
|
125
|
-
type = 'class';
|
|
126
|
-
}
|
|
127
|
-
exports.push({
|
|
128
|
-
name,
|
|
129
|
-
type,
|
|
130
|
-
loc: node.loc
|
|
131
|
-
? {
|
|
132
|
-
start: {
|
|
133
|
-
line: node.loc.start.line,
|
|
134
|
-
column: node.loc.start.column,
|
|
135
|
-
},
|
|
136
|
-
end: { line: node.loc.end.line, column: node.loc.end.column },
|
|
137
|
-
}
|
|
138
|
-
: undefined,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return exports;
|
|
143
|
-
}
|
|
144
|
-
extractFromDeclaration(declaration, importedNames) {
|
|
145
|
-
const exports = [];
|
|
146
|
-
if (declaration.type === 'FunctionDeclaration' && declaration.id) {
|
|
147
|
-
exports.push({
|
|
148
|
-
name: declaration.id.name,
|
|
149
|
-
type: 'function',
|
|
150
|
-
parameters: declaration.params.map((p) =>
|
|
151
|
-
p.type === 'Identifier' ? p.name : 'unknown'
|
|
152
|
-
),
|
|
153
|
-
loc: declaration.loc
|
|
154
|
-
? {
|
|
155
|
-
start: {
|
|
156
|
-
line: declaration.loc.start.line,
|
|
157
|
-
column: declaration.loc.start.column,
|
|
158
|
-
},
|
|
159
|
-
end: {
|
|
160
|
-
line: declaration.loc.end.line,
|
|
161
|
-
column: declaration.loc.end.column,
|
|
162
|
-
},
|
|
163
|
-
}
|
|
164
|
-
: undefined,
|
|
165
|
-
});
|
|
166
|
-
} else if (declaration.type === 'ClassDeclaration' && declaration.id) {
|
|
167
|
-
exports.push({
|
|
168
|
-
name: declaration.id.name,
|
|
169
|
-
type: 'class',
|
|
170
|
-
loc: declaration.loc
|
|
171
|
-
? {
|
|
172
|
-
start: {
|
|
173
|
-
line: declaration.loc.start.line,
|
|
174
|
-
column: declaration.loc.start.column,
|
|
175
|
-
},
|
|
176
|
-
end: {
|
|
177
|
-
line: declaration.loc.end.line,
|
|
178
|
-
column: declaration.loc.end.column,
|
|
179
|
-
},
|
|
180
|
-
}
|
|
181
|
-
: undefined,
|
|
182
|
-
});
|
|
183
|
-
} else if (declaration.type === 'VariableDeclaration') {
|
|
184
|
-
for (const declarator of declaration.declarations) {
|
|
185
|
-
if (declarator.id.type === 'Identifier') {
|
|
186
|
-
exports.push({
|
|
187
|
-
name: declarator.id.name,
|
|
188
|
-
type: 'const',
|
|
189
|
-
loc: declarator.loc
|
|
190
|
-
? {
|
|
191
|
-
start: {
|
|
192
|
-
line: declarator.loc.start.line,
|
|
193
|
-
column: declarator.loc.start.column,
|
|
194
|
-
},
|
|
195
|
-
end: {
|
|
196
|
-
line: declarator.loc.end.line,
|
|
197
|
-
column: declarator.loc.end.column,
|
|
198
|
-
},
|
|
199
|
-
}
|
|
200
|
-
: undefined,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
} else if (declaration.type === 'TSTypeAliasDeclaration') {
|
|
205
|
-
exports.push({
|
|
206
|
-
name: declaration.id.name,
|
|
207
|
-
type: 'type',
|
|
208
|
-
loc: declaration.loc
|
|
209
|
-
? {
|
|
210
|
-
start: {
|
|
211
|
-
line: declaration.loc.start.line,
|
|
212
|
-
column: declaration.loc.start.column,
|
|
213
|
-
},
|
|
214
|
-
end: {
|
|
215
|
-
line: declaration.loc.end.line,
|
|
216
|
-
column: declaration.loc.end.column,
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
: undefined,
|
|
220
|
-
});
|
|
221
|
-
} else if (declaration.type === 'TSInterfaceDeclaration') {
|
|
222
|
-
exports.push({
|
|
223
|
-
name: declaration.id.name,
|
|
224
|
-
type: 'interface',
|
|
225
|
-
loc: declaration.loc
|
|
226
|
-
? {
|
|
227
|
-
start: {
|
|
228
|
-
line: declaration.loc.start.line,
|
|
229
|
-
column: declaration.loc.start.column,
|
|
230
|
-
},
|
|
231
|
-
end: {
|
|
232
|
-
line: declaration.loc.end.line,
|
|
233
|
-
column: declaration.loc.end.column,
|
|
234
|
-
},
|
|
235
|
-
}
|
|
236
|
-
: undefined,
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
return exports;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
//# sourceMappingURL=typescript-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-parser.js","sourceRoot":"","sources":["../../src/parsers/typescript-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAY,MAAM,sCAAsC,CAAC;AACvE,OAAO,EACL,QAAQ,EAMR,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,MAAM,OAAO,gBAAgB;IAA7B;QACW,aAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC;QAC/B,eAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAmOvD,CAAC;IAjOC,KAAK,CAAC,IAAY,EAAE,QAAgB;QAClC,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAChD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE;gBACtB,GAAG,EAAE,IAAI;gBACT,KAAK,EAAE,IAAI;gBACX,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,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C,GAAG,CAAC,KAAK,CAAC,MAAM;yBACrC;wBACD,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE;qBAC5E;oBACH,CAAC,CAAC,SAAS;aACd,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
package/dist/scoring.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
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(
|
|
76
|
-
toolName: string,
|
|
77
|
-
toolConfig?: {
|
|
78
|
-
scoreWeight?: number;
|
|
79
|
-
},
|
|
80
|
-
cliOverride?: number
|
|
81
|
-
): number;
|
|
82
|
-
/**
|
|
83
|
-
* Parse weight string from CLI (e.g., "patterns:50,context:30")
|
|
84
|
-
*/
|
|
85
|
-
export declare function parseWeightString(
|
|
86
|
-
weightStr?: string
|
|
87
|
-
): Map<string, number>;
|
|
88
|
-
/**
|
|
89
|
-
* Calculate overall AI Readiness Score from multiple tool scores.
|
|
90
|
-
*
|
|
91
|
-
* Formula: Σ(tool_score × tool_weight) / Σ(active_tool_weights)
|
|
92
|
-
*
|
|
93
|
-
* This allows dynamic composition - score adjusts automatically
|
|
94
|
-
* based on which tools actually ran.
|
|
95
|
-
*/
|
|
96
|
-
export declare function calculateOverallScore(
|
|
97
|
-
toolOutputs: Map<string, ToolScoringOutput>,
|
|
98
|
-
config?: any,
|
|
99
|
-
cliWeights?: Map<string, number>
|
|
100
|
-
): ScoringResult;
|
|
101
|
-
/**
|
|
102
|
-
* Convert numeric score to rating category
|
|
103
|
-
*/
|
|
104
|
-
export declare function getRating(score: number): ScoringResult['rating'];
|
|
105
|
-
/**
|
|
106
|
-
* Get rating emoji and color for display
|
|
107
|
-
*/
|
|
108
|
-
export declare function getRatingDisplay(rating: ScoringResult['rating']): {
|
|
109
|
-
emoji: string;
|
|
110
|
-
color: string;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Format score for display with rating
|
|
114
|
-
*/
|
|
115
|
-
export declare function formatScore(result: ScoringResult): string;
|
|
116
|
-
/**
|
|
117
|
-
* Format individual tool score for display
|
|
118
|
-
*/
|
|
119
|
-
export declare function formatToolScore(output: ToolScoringOutput): string;
|
|
120
|
-
//# sourceMappingURL=scoring.d.ts.map
|
package/dist/scoring.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,KAAK,EAAE,MAAM,CAAC;IAEd,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC,MAA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E,MAAM,CAMhD,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EACrC,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAaR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBzE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC3C,MAAM,CAAC,EAAE,GAAG,EACZ,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,aAAa,CA2Df;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAMhE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAalG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAGzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAuBjE"}
|
package/dist/scoring.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
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
|
-
/**
|
|
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 =
|
|
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})`;
|
|
119
|
-
}
|
|
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
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Convert numeric score to rating category
|
|
137
|
-
*/
|
|
138
|
-
export function getRating(score) {
|
|
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';
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Get rating emoji and color for display
|
|
147
|
-
*/
|
|
148
|
-
export function getRatingDisplay(rating) {
|
|
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
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Format score for display with rating
|
|
164
|
-
*/
|
|
165
|
-
export function formatScore(result) {
|
|
166
|
-
const { emoji, color } = getRatingDisplay(result.rating);
|
|
167
|
-
return `${result.overall}/100 (${result.rating}) ${emoji}`;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Format individual tool score for display
|
|
171
|
-
*/
|
|
172
|
-
export function formatToolScore(output) {
|
|
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;
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=scoring.js.map
|
package/dist/scoring.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,CAAC;QACf,OAAO,OAAO,CA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