@aiready/core 0.23.2 → 0.23.4
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 +329 -107
- package/dist/index.d.ts +329 -107
- package/dist/index.js +329 -340
- package/dist/index.mjs +305 -322
- 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
|
@@ -1,180 +1,197 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
calculateOverallScore,
|
|
4
|
+
getRating,
|
|
5
|
+
parseWeightString,
|
|
6
|
+
normalizeToolName,
|
|
7
|
+
getToolWeight,
|
|
8
|
+
DEFAULT_TOOL_WEIGHTS,
|
|
9
|
+
} from '../scoring';
|
|
3
10
|
describe('Core Scoring Infrastructure', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
it('should apply CLI weight overrides', () => {
|
|
37
|
-
const toolOutputs = new Map([
|
|
38
|
-
[
|
|
39
|
-
'pattern-detect',
|
|
40
|
-
{
|
|
41
|
-
toolName: 'pattern-detect',
|
|
42
|
-
score: 80,
|
|
43
|
-
rawMetrics: {},
|
|
44
|
-
factors: [],
|
|
45
|
-
recommendations: [],
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
[
|
|
49
|
-
'context-analyzer',
|
|
50
|
-
{
|
|
51
|
-
toolName: 'context-analyzer',
|
|
52
|
-
score: 60,
|
|
53
|
-
rawMetrics: {},
|
|
54
|
-
factors: [],
|
|
55
|
-
recommendations: [],
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
]);
|
|
59
|
-
const cliWeights = new Map([
|
|
60
|
-
['pattern-detect', 50],
|
|
61
|
-
['context-analyzer', 50],
|
|
62
|
-
]);
|
|
63
|
-
// Equal weights: (80 * 50 + 60 * 50) / 100 = 7000 / 100 = 70
|
|
64
|
-
const result = calculateOverallScore(toolOutputs, undefined, cliWeights);
|
|
65
|
-
expect(result.overall).toBe(70);
|
|
66
|
-
expect(result.calculation.weights['pattern-detect']).toBe(50);
|
|
67
|
-
expect(result.calculation.weights['context-analyzer']).toBe(50);
|
|
68
|
-
});
|
|
69
|
-
it('should handle single tool scoring', () => {
|
|
70
|
-
const toolOutputs = new Map([
|
|
71
|
-
[
|
|
72
|
-
'pattern-detect',
|
|
73
|
-
{
|
|
74
|
-
toolName: 'pattern-detect',
|
|
75
|
-
score: 85,
|
|
76
|
-
rawMetrics: {},
|
|
77
|
-
factors: [],
|
|
78
|
-
recommendations: [],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
]);
|
|
82
|
-
const result = calculateOverallScore(toolOutputs);
|
|
83
|
-
expect(result.overall).toBe(85);
|
|
84
|
-
expect(result.toolsUsed).toEqual(['pattern-detect']);
|
|
85
|
-
});
|
|
86
|
-
it('should apply config weights when no CLI override', () => {
|
|
87
|
-
const toolOutputs = new Map([
|
|
88
|
-
[
|
|
89
|
-
'pattern-detect',
|
|
90
|
-
{
|
|
91
|
-
toolName: 'pattern-detect',
|
|
92
|
-
score: 90,
|
|
93
|
-
rawMetrics: {},
|
|
94
|
-
factors: [],
|
|
95
|
-
recommendations: [],
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
]);
|
|
99
|
-
const config = {
|
|
100
|
-
tools: {
|
|
101
|
-
'pattern-detect': {
|
|
102
|
-
scoreWeight: 60,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
const result = calculateOverallScore(toolOutputs, config);
|
|
107
|
-
expect(result.overall).toBe(90);
|
|
108
|
-
expect(result.calculation.weights['pattern-detect']).toBe(60);
|
|
109
|
-
});
|
|
110
|
-
it('should throw error when no tool outputs provided', () => {
|
|
111
|
-
const toolOutputs = new Map();
|
|
112
|
-
expect(() => calculateOverallScore(toolOutputs)).toThrow('No tool outputs provided for scoring');
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
describe('getRating', () => {
|
|
116
|
-
it('should return correct ratings for score ranges', () => {
|
|
117
|
-
expect(getRating(100)).toBe('Excellent');
|
|
118
|
-
expect(getRating(90)).toBe('Excellent');
|
|
119
|
-
expect(getRating(89)).toBe('Good');
|
|
120
|
-
expect(getRating(75)).toBe('Good');
|
|
121
|
-
expect(getRating(74)).toBe('Fair');
|
|
122
|
-
expect(getRating(60)).toBe('Fair');
|
|
123
|
-
expect(getRating(59)).toBe('Needs Work');
|
|
124
|
-
expect(getRating(40)).toBe('Needs Work');
|
|
125
|
-
expect(getRating(39)).toBe('Critical');
|
|
126
|
-
expect(getRating(0)).toBe('Critical');
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe('parseWeightString', () => {
|
|
130
|
-
it('should parse valid weight string', () => {
|
|
131
|
-
const weights = parseWeightString('patterns:50,context:30,consistency:20');
|
|
132
|
-
expect(weights.get('pattern-detect')).toBe(50);
|
|
133
|
-
expect(weights.get('context-analyzer')).toBe(30);
|
|
134
|
-
expect(weights.get('consistency')).toBe(20);
|
|
135
|
-
});
|
|
136
|
-
it('should return empty map for undefined input', () => {
|
|
137
|
-
const weights = parseWeightString(undefined);
|
|
138
|
-
expect(weights.size).toBe(0);
|
|
139
|
-
});
|
|
140
|
-
it('should skip invalid pairs', () => {
|
|
141
|
-
const weights = parseWeightString('patterns:50,invalid,context:abc,consistency:30');
|
|
142
|
-
expect(weights.get('pattern-detect')).toBe(50);
|
|
143
|
-
expect(weights.get('context-analyzer')).toBeUndefined();
|
|
144
|
-
expect(weights.get('consistency')).toBe(30);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
describe('normalizeToolName', () => {
|
|
148
|
-
it('should normalize shorthand tool names', () => {
|
|
149
|
-
expect(normalizeToolName('patterns')).toBe('pattern-detect');
|
|
150
|
-
expect(normalizeToolName('context')).toBe('context-analyzer');
|
|
151
|
-
expect(normalizeToolName('consistency')).toBe('consistency');
|
|
152
|
-
});
|
|
153
|
-
it('should return full names unchanged', () => {
|
|
154
|
-
expect(normalizeToolName('pattern-detect')).toBe('pattern-detect');
|
|
155
|
-
expect(normalizeToolName('context-analyzer')).toBe('context-analyzer');
|
|
156
|
-
});
|
|
157
|
-
it('should return unknown names unchanged', () => {
|
|
158
|
-
expect(normalizeToolName('unknown-tool')).toBe('unknown-tool');
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
describe('getToolWeight', () => {
|
|
162
|
-
it('should prioritize CLI override', () => {
|
|
163
|
-
const weight = getToolWeight('pattern-detect', { scoreWeight: 30 }, 50);
|
|
164
|
-
expect(weight).toBe(50);
|
|
165
|
-
});
|
|
166
|
-
it('should use config weight when no CLI override', () => {
|
|
167
|
-
const weight = getToolWeight('pattern-detect', { scoreWeight: 30 }, undefined);
|
|
168
|
-
expect(weight).toBe(30);
|
|
169
|
-
});
|
|
170
|
-
it('should fall back to default weight', () => {
|
|
171
|
-
const weight = getToolWeight('pattern-detect', undefined, undefined);
|
|
172
|
-
expect(weight).toBe(DEFAULT_TOOL_WEIGHTS['pattern-detect']);
|
|
173
|
-
});
|
|
174
|
-
it('should use 10 for unknown tools', () => {
|
|
175
|
-
const weight = getToolWeight('unknown-tool', undefined, undefined);
|
|
176
|
-
expect(weight).toBe(10);
|
|
177
|
-
});
|
|
11
|
+
describe('calculateOverallScore', () => {
|
|
12
|
+
it('should calculate weighted average correctly', () => {
|
|
13
|
+
const toolOutputs = new Map([
|
|
14
|
+
[
|
|
15
|
+
'pattern-detect',
|
|
16
|
+
{
|
|
17
|
+
toolName: 'pattern-detect',
|
|
18
|
+
score: 80,
|
|
19
|
+
rawMetrics: {},
|
|
20
|
+
factors: [],
|
|
21
|
+
recommendations: [],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
'context-analyzer',
|
|
26
|
+
{
|
|
27
|
+
toolName: 'context-analyzer',
|
|
28
|
+
score: 60,
|
|
29
|
+
rawMetrics: {},
|
|
30
|
+
factors: [],
|
|
31
|
+
recommendations: [],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
]);
|
|
35
|
+
// Default weights: pattern-detect=40, context-analyzer=35
|
|
36
|
+
// (80 * 40 + 60 * 35) / (40 + 35) = (3200 + 2100) / 75 = 5300 / 75 = 70.67 → 71
|
|
37
|
+
const result = calculateOverallScore(toolOutputs);
|
|
38
|
+
expect(result.overall).toBe(71);
|
|
39
|
+
expect(result.rating).toBe('Fair'); // 71 is in Fair range (60-74)
|
|
40
|
+
expect(result.toolsUsed).toEqual(['pattern-detect', 'context-analyzer']);
|
|
41
|
+
expect(result.breakdown).toHaveLength(2);
|
|
178
42
|
});
|
|
43
|
+
it('should apply CLI weight overrides', () => {
|
|
44
|
+
const toolOutputs = new Map([
|
|
45
|
+
[
|
|
46
|
+
'pattern-detect',
|
|
47
|
+
{
|
|
48
|
+
toolName: 'pattern-detect',
|
|
49
|
+
score: 80,
|
|
50
|
+
rawMetrics: {},
|
|
51
|
+
factors: [],
|
|
52
|
+
recommendations: [],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
'context-analyzer',
|
|
57
|
+
{
|
|
58
|
+
toolName: 'context-analyzer',
|
|
59
|
+
score: 60,
|
|
60
|
+
rawMetrics: {},
|
|
61
|
+
factors: [],
|
|
62
|
+
recommendations: [],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
]);
|
|
66
|
+
const cliWeights = new Map([
|
|
67
|
+
['pattern-detect', 50],
|
|
68
|
+
['context-analyzer', 50],
|
|
69
|
+
]);
|
|
70
|
+
// Equal weights: (80 * 50 + 60 * 50) / 100 = 7000 / 100 = 70
|
|
71
|
+
const result = calculateOverallScore(toolOutputs, undefined, cliWeights);
|
|
72
|
+
expect(result.overall).toBe(70);
|
|
73
|
+
expect(result.calculation.weights['pattern-detect']).toBe(50);
|
|
74
|
+
expect(result.calculation.weights['context-analyzer']).toBe(50);
|
|
75
|
+
});
|
|
76
|
+
it('should handle single tool scoring', () => {
|
|
77
|
+
const toolOutputs = new Map([
|
|
78
|
+
[
|
|
79
|
+
'pattern-detect',
|
|
80
|
+
{
|
|
81
|
+
toolName: 'pattern-detect',
|
|
82
|
+
score: 85,
|
|
83
|
+
rawMetrics: {},
|
|
84
|
+
factors: [],
|
|
85
|
+
recommendations: [],
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
]);
|
|
89
|
+
const result = calculateOverallScore(toolOutputs);
|
|
90
|
+
expect(result.overall).toBe(85);
|
|
91
|
+
expect(result.toolsUsed).toEqual(['pattern-detect']);
|
|
92
|
+
});
|
|
93
|
+
it('should apply config weights when no CLI override', () => {
|
|
94
|
+
const toolOutputs = new Map([
|
|
95
|
+
[
|
|
96
|
+
'pattern-detect',
|
|
97
|
+
{
|
|
98
|
+
toolName: 'pattern-detect',
|
|
99
|
+
score: 90,
|
|
100
|
+
rawMetrics: {},
|
|
101
|
+
factors: [],
|
|
102
|
+
recommendations: [],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
]);
|
|
106
|
+
const config = {
|
|
107
|
+
tools: {
|
|
108
|
+
'pattern-detect': {
|
|
109
|
+
scoreWeight: 60,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const result = calculateOverallScore(toolOutputs, config);
|
|
114
|
+
expect(result.overall).toBe(90);
|
|
115
|
+
expect(result.calculation.weights['pattern-detect']).toBe(60);
|
|
116
|
+
});
|
|
117
|
+
it('should throw error when no tool outputs provided', () => {
|
|
118
|
+
const toolOutputs = new Map();
|
|
119
|
+
expect(() => calculateOverallScore(toolOutputs)).toThrow(
|
|
120
|
+
'No tool outputs provided for scoring'
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe('getRating', () => {
|
|
125
|
+
it('should return correct ratings for score ranges', () => {
|
|
126
|
+
expect(getRating(100)).toBe('Excellent');
|
|
127
|
+
expect(getRating(90)).toBe('Excellent');
|
|
128
|
+
expect(getRating(89)).toBe('Good');
|
|
129
|
+
expect(getRating(75)).toBe('Good');
|
|
130
|
+
expect(getRating(74)).toBe('Fair');
|
|
131
|
+
expect(getRating(60)).toBe('Fair');
|
|
132
|
+
expect(getRating(59)).toBe('Needs Work');
|
|
133
|
+
expect(getRating(40)).toBe('Needs Work');
|
|
134
|
+
expect(getRating(39)).toBe('Critical');
|
|
135
|
+
expect(getRating(0)).toBe('Critical');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
describe('parseWeightString', () => {
|
|
139
|
+
it('should parse valid weight string', () => {
|
|
140
|
+
const weights = parseWeightString(
|
|
141
|
+
'patterns:50,context:30,consistency:20'
|
|
142
|
+
);
|
|
143
|
+
expect(weights.get('pattern-detect')).toBe(50);
|
|
144
|
+
expect(weights.get('context-analyzer')).toBe(30);
|
|
145
|
+
expect(weights.get('consistency')).toBe(20);
|
|
146
|
+
});
|
|
147
|
+
it('should return empty map for undefined input', () => {
|
|
148
|
+
const weights = parseWeightString(undefined);
|
|
149
|
+
expect(weights.size).toBe(0);
|
|
150
|
+
});
|
|
151
|
+
it('should skip invalid pairs', () => {
|
|
152
|
+
const weights = parseWeightString(
|
|
153
|
+
'patterns:50,invalid,context:abc,consistency:30'
|
|
154
|
+
);
|
|
155
|
+
expect(weights.get('pattern-detect')).toBe(50);
|
|
156
|
+
expect(weights.get('context-analyzer')).toBeUndefined();
|
|
157
|
+
expect(weights.get('consistency')).toBe(30);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
describe('normalizeToolName', () => {
|
|
161
|
+
it('should normalize shorthand tool names', () => {
|
|
162
|
+
expect(normalizeToolName('patterns')).toBe('pattern-detect');
|
|
163
|
+
expect(normalizeToolName('context')).toBe('context-analyzer');
|
|
164
|
+
expect(normalizeToolName('consistency')).toBe('consistency');
|
|
165
|
+
});
|
|
166
|
+
it('should return full names unchanged', () => {
|
|
167
|
+
expect(normalizeToolName('pattern-detect')).toBe('pattern-detect');
|
|
168
|
+
expect(normalizeToolName('context-analyzer')).toBe('context-analyzer');
|
|
169
|
+
});
|
|
170
|
+
it('should return unknown names unchanged', () => {
|
|
171
|
+
expect(normalizeToolName('unknown-tool')).toBe('unknown-tool');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('getToolWeight', () => {
|
|
175
|
+
it('should prioritize CLI override', () => {
|
|
176
|
+
const weight = getToolWeight('pattern-detect', { scoreWeight: 30 }, 50);
|
|
177
|
+
expect(weight).toBe(50);
|
|
178
|
+
});
|
|
179
|
+
it('should use config weight when no CLI override', () => {
|
|
180
|
+
const weight = getToolWeight(
|
|
181
|
+
'pattern-detect',
|
|
182
|
+
{ scoreWeight: 30 },
|
|
183
|
+
undefined
|
|
184
|
+
);
|
|
185
|
+
expect(weight).toBe(30);
|
|
186
|
+
});
|
|
187
|
+
it('should fall back to default weight', () => {
|
|
188
|
+
const weight = getToolWeight('pattern-detect', undefined, undefined);
|
|
189
|
+
expect(weight).toBe(DEFAULT_TOOL_WEIGHTS['pattern-detect']);
|
|
190
|
+
});
|
|
191
|
+
it('should use 10 for unknown tools', () => {
|
|
192
|
+
const weight = getToolWeight('unknown-tool', undefined, undefined);
|
|
193
|
+
expect(weight).toBe(10);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
179
196
|
});
|
|
180
|
-
//# sourceMappingURL=scoring.test.js.map
|
|
197
|
+
//# sourceMappingURL=scoring.test.js.map
|