@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
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
// src/types/schema.ts
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
4
|
+
Severity2['Critical'] = 'critical';
|
|
5
|
+
Severity2['Major'] = 'major';
|
|
6
|
+
Severity2['Minor'] = 'minor';
|
|
7
|
+
Severity2['Info'] = 'info';
|
|
8
|
+
return Severity2;
|
|
9
|
+
})(Severity || {});
|
|
10
|
+
var SeveritySchema = z.nativeEnum(Severity);
|
|
11
|
+
var ToolName = /* @__PURE__ */ ((ToolName2) => {
|
|
12
|
+
ToolName2['PatternDetect'] = 'pattern-detect';
|
|
13
|
+
ToolName2['ContextAnalyzer'] = 'context-analyzer';
|
|
14
|
+
ToolName2['NamingConsistency'] = 'naming-consistency';
|
|
15
|
+
ToolName2['AiSignalClarity'] = 'ai-signal-clarity';
|
|
16
|
+
ToolName2['AgentGrounding'] = 'agent-grounding';
|
|
17
|
+
ToolName2['TestabilityIndex'] = 'testability-index';
|
|
18
|
+
ToolName2['DocDrift'] = 'doc-drift';
|
|
19
|
+
ToolName2['DependencyHealth'] = 'dependency-health';
|
|
20
|
+
ToolName2['ChangeAmplification'] = 'change-amplification';
|
|
21
|
+
ToolName2['CognitiveLoad'] = 'cognitive-load';
|
|
22
|
+
ToolName2['PatternEntropy'] = 'pattern-entropy';
|
|
23
|
+
ToolName2['ConceptCohesion'] = 'concept-cohesion';
|
|
24
|
+
ToolName2['SemanticDistance'] = 'semantic-distance';
|
|
25
|
+
return ToolName2;
|
|
26
|
+
})(ToolName || {});
|
|
27
|
+
var ToolNameSchema = z.nativeEnum(ToolName);
|
|
28
|
+
var IssueType = /* @__PURE__ */ ((IssueType2) => {
|
|
29
|
+
IssueType2['DuplicatePattern'] = 'duplicate-pattern';
|
|
30
|
+
IssueType2['PatternInconsistency'] = 'pattern-inconsistency';
|
|
31
|
+
IssueType2['ContextFragmentation'] = 'context-fragmentation';
|
|
32
|
+
IssueType2['DependencyHealth'] = 'dependency-health';
|
|
33
|
+
IssueType2['CircularDependency'] = 'circular-dependency';
|
|
34
|
+
IssueType2['DocDrift'] = 'doc-drift';
|
|
35
|
+
IssueType2['NamingInconsistency'] = 'naming-inconsistency';
|
|
36
|
+
IssueType2['NamingQuality'] = 'naming-quality';
|
|
37
|
+
IssueType2['ArchitectureInconsistency'] = 'architecture-inconsistency';
|
|
38
|
+
IssueType2['DeadCode'] = 'dead-code';
|
|
39
|
+
IssueType2['MissingTypes'] = 'missing-types';
|
|
40
|
+
IssueType2['MagicLiteral'] = 'magic-literal';
|
|
41
|
+
IssueType2['BooleanTrap'] = 'boolean-trap';
|
|
42
|
+
IssueType2['AiSignalClarity'] = 'ai-signal-clarity';
|
|
43
|
+
IssueType2['LowTestability'] = 'low-testability';
|
|
44
|
+
IssueType2['AgentNavigationFailure'] = 'agent-navigation-failure';
|
|
45
|
+
IssueType2['AmbiguousApi'] = 'ambiguous-api';
|
|
46
|
+
IssueType2['ChangeAmplification'] = 'change-amplification';
|
|
47
|
+
return IssueType2;
|
|
48
|
+
})(IssueType || {});
|
|
49
|
+
var IssueTypeSchema = z.nativeEnum(IssueType);
|
|
50
|
+
var AnalysisStatus = /* @__PURE__ */ ((AnalysisStatus2) => {
|
|
51
|
+
AnalysisStatus2['Processing'] = 'processing';
|
|
52
|
+
AnalysisStatus2['Completed'] = 'completed';
|
|
53
|
+
AnalysisStatus2['Failed'] = 'failed';
|
|
54
|
+
return AnalysisStatus2;
|
|
55
|
+
})(AnalysisStatus || {});
|
|
56
|
+
var AnalysisStatusSchema = z.nativeEnum(AnalysisStatus);
|
|
57
|
+
var ModelTier = /* @__PURE__ */ ((ModelTier2) => {
|
|
58
|
+
ModelTier2['Compact'] = 'compact';
|
|
59
|
+
ModelTier2['Standard'] = 'standard';
|
|
60
|
+
ModelTier2['Extended'] = 'extended';
|
|
61
|
+
ModelTier2['Frontier'] = 'frontier';
|
|
62
|
+
return ModelTier2;
|
|
63
|
+
})(ModelTier || {});
|
|
64
|
+
var ModelTierSchema = z.nativeEnum(ModelTier);
|
|
65
|
+
var LocationSchema = z.object({
|
|
66
|
+
file: z.string(),
|
|
67
|
+
line: z.number(),
|
|
68
|
+
column: z.number().optional(),
|
|
69
|
+
endLine: z.number().optional(),
|
|
70
|
+
endColumn: z.number().optional(),
|
|
71
|
+
});
|
|
72
|
+
var IssueSchema = z.object({
|
|
73
|
+
type: IssueTypeSchema,
|
|
74
|
+
severity: SeveritySchema,
|
|
75
|
+
message: z.string(),
|
|
76
|
+
location: LocationSchema,
|
|
77
|
+
suggestion: z.string().optional(),
|
|
78
|
+
});
|
|
79
|
+
var MetricsSchema = z.object({
|
|
80
|
+
tokenCost: z.number().optional(),
|
|
81
|
+
complexityScore: z.number().optional(),
|
|
82
|
+
consistencyScore: z.number().optional(),
|
|
83
|
+
docFreshnessScore: z.number().optional(),
|
|
84
|
+
// AI agent readiness metrics (v0.12+)
|
|
85
|
+
aiSignalClarityScore: z.number().optional(),
|
|
86
|
+
agentGroundingScore: z.number().optional(),
|
|
87
|
+
testabilityScore: z.number().optional(),
|
|
88
|
+
docDriftScore: z.number().optional(),
|
|
89
|
+
dependencyHealthScore: z.number().optional(),
|
|
90
|
+
modelContextTier: ModelTierSchema.optional(),
|
|
91
|
+
// Business value metrics
|
|
92
|
+
estimatedMonthlyCost: z.number().optional(),
|
|
93
|
+
estimatedDeveloperHours: z.number().optional(),
|
|
94
|
+
comprehensionDifficultyIndex: z.number().optional(),
|
|
95
|
+
// Extended metrics for specific spokes
|
|
96
|
+
totalSymbols: z.number().optional(),
|
|
97
|
+
totalExports: z.number().optional(),
|
|
98
|
+
});
|
|
99
|
+
var AnalysisResultSchema = z.object({
|
|
100
|
+
fileName: z.string(),
|
|
101
|
+
issues: z.array(IssueSchema),
|
|
102
|
+
metrics: MetricsSchema,
|
|
103
|
+
});
|
|
104
|
+
var SpokeSummarySchema = z
|
|
105
|
+
.object({
|
|
106
|
+
totalFiles: z.number().optional(),
|
|
107
|
+
totalIssues: z.number().optional(),
|
|
108
|
+
criticalIssues: z.number().optional(),
|
|
109
|
+
majorIssues: z.number().optional(),
|
|
110
|
+
score: z.number().optional(),
|
|
111
|
+
})
|
|
112
|
+
.catchall(z.any());
|
|
113
|
+
var SpokeOutputSchema = z.object({
|
|
114
|
+
results: z.array(AnalysisResultSchema),
|
|
115
|
+
summary: SpokeSummarySchema,
|
|
116
|
+
metadata: z
|
|
117
|
+
.object({
|
|
118
|
+
toolName: z.string(),
|
|
119
|
+
version: z.string().optional(),
|
|
120
|
+
timestamp: z.string().optional(),
|
|
121
|
+
config: z.any().optional(),
|
|
122
|
+
})
|
|
123
|
+
.catchall(z.any())
|
|
124
|
+
.optional(),
|
|
125
|
+
});
|
|
126
|
+
var UnifiedReportSchema = z
|
|
127
|
+
.object({
|
|
128
|
+
summary: z.object({
|
|
129
|
+
totalFiles: z.number(),
|
|
130
|
+
totalIssues: z.number(),
|
|
131
|
+
criticalIssues: z.number(),
|
|
132
|
+
majorIssues: z.number(),
|
|
133
|
+
businessImpact: z
|
|
134
|
+
.object({
|
|
135
|
+
estimatedMonthlyWaste: z.number().optional(),
|
|
136
|
+
potentialSavings: z.number().optional(),
|
|
137
|
+
productivityHours: z.number().optional(),
|
|
138
|
+
})
|
|
139
|
+
.optional(),
|
|
140
|
+
}),
|
|
141
|
+
results: z.array(AnalysisResultSchema),
|
|
142
|
+
scoring: z
|
|
143
|
+
.object({
|
|
144
|
+
overall: z.number(),
|
|
145
|
+
rating: z.string(),
|
|
146
|
+
timestamp: z.string(),
|
|
147
|
+
breakdown: z.array(
|
|
148
|
+
z
|
|
149
|
+
.object({
|
|
150
|
+
toolName: z.union([ToolNameSchema, z.string()]),
|
|
151
|
+
score: z.number(),
|
|
152
|
+
})
|
|
153
|
+
.catchall(z.any())
|
|
154
|
+
),
|
|
155
|
+
})
|
|
156
|
+
.optional(),
|
|
157
|
+
})
|
|
158
|
+
.catchall(z.any());
|
|
159
|
+
|
|
160
|
+
// src/types.ts
|
|
161
|
+
var GLOBAL_INFRA_OPTIONS = [
|
|
162
|
+
'rootDir',
|
|
163
|
+
'include',
|
|
164
|
+
'exclude',
|
|
165
|
+
'tools',
|
|
166
|
+
'scoring',
|
|
167
|
+
];
|
|
168
|
+
var GLOBAL_SCAN_OPTIONS = [
|
|
169
|
+
'rootDir',
|
|
170
|
+
'include',
|
|
171
|
+
'exclude',
|
|
172
|
+
'config',
|
|
173
|
+
'threshold',
|
|
174
|
+
'output',
|
|
175
|
+
'format',
|
|
176
|
+
'parallel',
|
|
177
|
+
'showBreakdown',
|
|
178
|
+
];
|
|
179
|
+
var COMMON_FINE_TUNING_OPTIONS = [
|
|
180
|
+
'maxDepth',
|
|
181
|
+
'minSimilarity',
|
|
182
|
+
'threshold',
|
|
183
|
+
'showBreakdown',
|
|
184
|
+
];
|
|
185
|
+
|
|
186
|
+
// src/types/language.ts
|
|
187
|
+
var Language = /* @__PURE__ */ ((Language2) => {
|
|
188
|
+
Language2['TypeScript'] = 'typescript';
|
|
189
|
+
Language2['JavaScript'] = 'javascript';
|
|
190
|
+
Language2['Python'] = 'python';
|
|
191
|
+
Language2['Java'] = 'java';
|
|
192
|
+
Language2['Go'] = 'go';
|
|
193
|
+
Language2['Rust'] = 'rust';
|
|
194
|
+
Language2['CSharp'] = 'csharp';
|
|
195
|
+
return Language2;
|
|
196
|
+
})(Language || {});
|
|
197
|
+
var LANGUAGE_EXTENSIONS = {
|
|
198
|
+
'.ts': 'typescript' /* TypeScript */,
|
|
199
|
+
'.tsx': 'typescript' /* TypeScript */,
|
|
200
|
+
'.js': 'javascript' /* JavaScript */,
|
|
201
|
+
'.jsx': 'javascript' /* JavaScript */,
|
|
202
|
+
'.py': 'python' /* Python */,
|
|
203
|
+
'.java': 'java' /* Java */,
|
|
204
|
+
'.go': 'go' /* Go */,
|
|
205
|
+
'.rs': 'rust' /* Rust */,
|
|
206
|
+
'.cs': 'csharp' /* CSharp */,
|
|
207
|
+
};
|
|
208
|
+
var ParseError = class extends Error {
|
|
209
|
+
constructor(message, filePath, loc) {
|
|
210
|
+
super(message);
|
|
211
|
+
this.filePath = filePath;
|
|
212
|
+
this.loc = loc;
|
|
213
|
+
this.name = 'ParseError';
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/scoring.ts
|
|
218
|
+
var RecommendationPriority = /* @__PURE__ */ ((RecommendationPriority2) => {
|
|
219
|
+
RecommendationPriority2['High'] = 'high';
|
|
220
|
+
RecommendationPriority2['Medium'] = 'medium';
|
|
221
|
+
RecommendationPriority2['Low'] = 'low';
|
|
222
|
+
return RecommendationPriority2;
|
|
223
|
+
})(RecommendationPriority || {});
|
|
224
|
+
var ReadinessRating = /* @__PURE__ */ ((ReadinessRating2) => {
|
|
225
|
+
ReadinessRating2['Excellent'] = 'Excellent';
|
|
226
|
+
ReadinessRating2['Good'] = 'Good';
|
|
227
|
+
ReadinessRating2['Fair'] = 'Fair';
|
|
228
|
+
ReadinessRating2['NeedsWork'] = 'Needs Work';
|
|
229
|
+
ReadinessRating2['Critical'] = 'Critical';
|
|
230
|
+
return ReadinessRating2;
|
|
231
|
+
})(ReadinessRating || {});
|
|
232
|
+
var DEFAULT_TOOL_WEIGHTS = {
|
|
233
|
+
['pattern-detect' /* PatternDetect */]: 22,
|
|
234
|
+
['context-analyzer' /* ContextAnalyzer */]: 19,
|
|
235
|
+
['naming-consistency' /* NamingConsistency */]: 14,
|
|
236
|
+
['ai-signal-clarity' /* AiSignalClarity */]: 11,
|
|
237
|
+
['agent-grounding' /* AgentGrounding */]: 10,
|
|
238
|
+
['testability-index' /* TestabilityIndex */]: 10,
|
|
239
|
+
['doc-drift' /* DocDrift */]: 8,
|
|
240
|
+
['dependency-health' /* DependencyHealth */]: 6,
|
|
241
|
+
['change-amplification' /* ChangeAmplification */]: 8,
|
|
242
|
+
};
|
|
243
|
+
var TOOL_NAME_MAP = {
|
|
244
|
+
patterns: 'pattern-detect' /* PatternDetect */,
|
|
245
|
+
'pattern-detect': 'pattern-detect' /* PatternDetect */,
|
|
246
|
+
context: 'context-analyzer' /* ContextAnalyzer */,
|
|
247
|
+
'context-analyzer': 'context-analyzer' /* ContextAnalyzer */,
|
|
248
|
+
consistency: 'naming-consistency' /* NamingConsistency */,
|
|
249
|
+
'naming-consistency': 'naming-consistency' /* NamingConsistency */,
|
|
250
|
+
'ai-signal': 'ai-signal-clarity' /* AiSignalClarity */,
|
|
251
|
+
'ai-signal-clarity': 'ai-signal-clarity' /* AiSignalClarity */,
|
|
252
|
+
grounding: 'agent-grounding' /* AgentGrounding */,
|
|
253
|
+
'agent-grounding': 'agent-grounding' /* AgentGrounding */,
|
|
254
|
+
testability: 'testability-index' /* TestabilityIndex */,
|
|
255
|
+
'testability-index': 'testability-index' /* TestabilityIndex */,
|
|
256
|
+
'doc-drift': 'doc-drift' /* DocDrift */,
|
|
257
|
+
'deps-health': 'dependency-health' /* DependencyHealth */,
|
|
258
|
+
'dependency-health': 'dependency-health' /* DependencyHealth */,
|
|
259
|
+
'change-amp': 'change-amplification' /* ChangeAmplification */,
|
|
260
|
+
'change-amplification': 'change-amplification' /* ChangeAmplification */,
|
|
261
|
+
};
|
|
262
|
+
var ScoringProfile = /* @__PURE__ */ ((ScoringProfile2) => {
|
|
263
|
+
ScoringProfile2['Default'] = 'default';
|
|
264
|
+
ScoringProfile2['Agentic'] = 'agentic';
|
|
265
|
+
ScoringProfile2['Logic'] = 'logic';
|
|
266
|
+
ScoringProfile2['UI'] = 'ui';
|
|
267
|
+
ScoringProfile2['Cost'] = 'cost';
|
|
268
|
+
ScoringProfile2['Security'] = 'security';
|
|
269
|
+
return ScoringProfile2;
|
|
270
|
+
})(ScoringProfile || {});
|
|
271
|
+
var SCORING_PROFILES = {
|
|
272
|
+
['default' /* Default */]: DEFAULT_TOOL_WEIGHTS,
|
|
273
|
+
['agentic' /* Agentic */]: {
|
|
274
|
+
['ai-signal-clarity' /* AiSignalClarity */]: 30,
|
|
275
|
+
['agent-grounding' /* AgentGrounding */]: 30,
|
|
276
|
+
['testability-index' /* TestabilityIndex */]: 20,
|
|
277
|
+
['context-analyzer' /* ContextAnalyzer */]: 10,
|
|
278
|
+
['naming-consistency' /* NamingConsistency */]: 10,
|
|
279
|
+
},
|
|
280
|
+
['logic' /* Logic */]: {
|
|
281
|
+
['testability-index' /* TestabilityIndex */]: 40,
|
|
282
|
+
['naming-consistency' /* NamingConsistency */]: 20,
|
|
283
|
+
['context-analyzer' /* ContextAnalyzer */]: 20,
|
|
284
|
+
['pattern-detect' /* PatternDetect */]: 10,
|
|
285
|
+
['change-amplification' /* ChangeAmplification */]: 10,
|
|
286
|
+
},
|
|
287
|
+
['ui' /* UI */]: {
|
|
288
|
+
['naming-consistency' /* NamingConsistency */]: 30,
|
|
289
|
+
['context-analyzer' /* ContextAnalyzer */]: 30,
|
|
290
|
+
['pattern-detect' /* PatternDetect */]: 20,
|
|
291
|
+
['doc-drift' /* DocDrift */]: 10,
|
|
292
|
+
['ai-signal-clarity' /* AiSignalClarity */]: 10,
|
|
293
|
+
},
|
|
294
|
+
['cost' /* Cost */]: {
|
|
295
|
+
['pattern-detect' /* PatternDetect */]: 50,
|
|
296
|
+
['context-analyzer' /* ContextAnalyzer */]: 30,
|
|
297
|
+
['change-amplification' /* ChangeAmplification */]: 10,
|
|
298
|
+
['dependency-health' /* DependencyHealth */]: 10,
|
|
299
|
+
},
|
|
300
|
+
['security' /* Security */]: {
|
|
301
|
+
['naming-consistency' /* NamingConsistency */]: 40,
|
|
302
|
+
['testability-index' /* TestabilityIndex */]: 30,
|
|
303
|
+
['dependency-health' /* DependencyHealth */]: 20,
|
|
304
|
+
['context-analyzer' /* ContextAnalyzer */]: 10,
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
var CONTEXT_TIER_THRESHOLDS = {
|
|
308
|
+
compact: { idealTokens: 3e3, criticalTokens: 1e4, idealDepth: 4 },
|
|
309
|
+
standard: { idealTokens: 5e3, criticalTokens: 15e3, idealDepth: 5 },
|
|
310
|
+
extended: { idealTokens: 15e3, criticalTokens: 5e4, idealDepth: 7 },
|
|
311
|
+
frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 },
|
|
312
|
+
};
|
|
313
|
+
var SIZE_ADJUSTED_THRESHOLDS = {
|
|
314
|
+
xs: 80,
|
|
315
|
+
// < 50 files
|
|
316
|
+
small: 75,
|
|
317
|
+
// 50-200 files
|
|
318
|
+
medium: 70,
|
|
319
|
+
// 200-500 files
|
|
320
|
+
large: 65,
|
|
321
|
+
// 500-2000 files
|
|
322
|
+
enterprise: 58,
|
|
323
|
+
// 2000+ files
|
|
324
|
+
};
|
|
325
|
+
function getProjectSizeTier(fileCount) {
|
|
326
|
+
if (fileCount < 50) return 'xs';
|
|
327
|
+
if (fileCount < 200) return 'small';
|
|
328
|
+
if (fileCount < 500) return 'medium';
|
|
329
|
+
if (fileCount < 2e3) return 'large';
|
|
330
|
+
return 'enterprise';
|
|
331
|
+
}
|
|
332
|
+
function getRecommendedThreshold(fileCount, modelTier = 'standard') {
|
|
333
|
+
const sizeTier = getProjectSizeTier(fileCount);
|
|
334
|
+
const base = SIZE_ADJUSTED_THRESHOLDS[sizeTier];
|
|
335
|
+
const modelBonus =
|
|
336
|
+
modelTier === 'frontier' ? -3 : modelTier === 'extended' ? -2 : 0;
|
|
337
|
+
return base + modelBonus;
|
|
338
|
+
}
|
|
339
|
+
function normalizeToolName(shortName) {
|
|
340
|
+
return TOOL_NAME_MAP[shortName.toLowerCase()] || shortName;
|
|
341
|
+
}
|
|
342
|
+
function getToolWeight(
|
|
343
|
+
toolName,
|
|
344
|
+
toolConfig,
|
|
345
|
+
cliOverride,
|
|
346
|
+
profile = 'default' /* Default */
|
|
347
|
+
) {
|
|
348
|
+
if (cliOverride !== void 0) return cliOverride;
|
|
349
|
+
if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
|
|
350
|
+
const profileWeights = SCORING_PROFILES[profile] || DEFAULT_TOOL_WEIGHTS;
|
|
351
|
+
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 5;
|
|
352
|
+
}
|
|
353
|
+
function parseWeightString(weightStr) {
|
|
354
|
+
const weights = /* @__PURE__ */ new Map();
|
|
355
|
+
if (!weightStr) return weights;
|
|
356
|
+
const pairs = weightStr.split(',');
|
|
357
|
+
for (const pair of pairs) {
|
|
358
|
+
const [toolShortName, weightValueStr] = pair.split(':');
|
|
359
|
+
if (toolShortName && weightValueStr) {
|
|
360
|
+
const toolName = normalizeToolName(toolShortName.trim());
|
|
361
|
+
const weight = parseInt(weightValueStr.trim(), 10);
|
|
362
|
+
if (!isNaN(weight) && weight > 0) {
|
|
363
|
+
weights.set(toolName, weight);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return weights;
|
|
368
|
+
}
|
|
369
|
+
function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
370
|
+
if (toolOutputs.size === 0) {
|
|
371
|
+
throw new Error('No tool outputs provided for scoring');
|
|
372
|
+
}
|
|
373
|
+
const profile = config?.scoring?.profile || 'default'; /* Default */
|
|
374
|
+
const weights = /* @__PURE__ */ new Map();
|
|
375
|
+
for (const [toolName] of toolOutputs.entries()) {
|
|
376
|
+
const cliWeight = cliWeights?.get(toolName);
|
|
377
|
+
const configWeight = config?.tools?.[toolName]?.scoreWeight;
|
|
378
|
+
const weight =
|
|
379
|
+
cliWeight ??
|
|
380
|
+
configWeight ??
|
|
381
|
+
getToolWeight(toolName, void 0, void 0, profile);
|
|
382
|
+
weights.set(toolName, weight);
|
|
383
|
+
}
|
|
384
|
+
let weightedSum = 0;
|
|
385
|
+
let totalWeight = 0;
|
|
386
|
+
const breakdown = [];
|
|
387
|
+
const toolsUsed = [];
|
|
388
|
+
const calculationWeights = {};
|
|
389
|
+
for (const [toolName, output] of toolOutputs.entries()) {
|
|
390
|
+
const weight = weights.get(toolName) || 5;
|
|
391
|
+
weightedSum += output.score * weight;
|
|
392
|
+
totalWeight += weight;
|
|
393
|
+
toolsUsed.push(toolName);
|
|
394
|
+
calculationWeights[toolName] = weight;
|
|
395
|
+
breakdown.push(output);
|
|
396
|
+
}
|
|
397
|
+
const overall = Math.round(weightedSum / totalWeight);
|
|
398
|
+
const rating = getRating(overall);
|
|
399
|
+
const formulaParts = Array.from(toolOutputs.entries()).map(
|
|
400
|
+
([name, output]) => {
|
|
401
|
+
const w = weights.get(name) || 5;
|
|
402
|
+
return `(${output.score} \xD7 ${w})`;
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
const formulaStr = `[${formulaParts.join(' + ')}] / ${totalWeight} = ${overall}`;
|
|
406
|
+
return {
|
|
407
|
+
overall,
|
|
408
|
+
rating,
|
|
409
|
+
timestamp: /* @__PURE__ */ new Date().toISOString(),
|
|
410
|
+
toolsUsed,
|
|
411
|
+
breakdown,
|
|
412
|
+
calculation: {
|
|
413
|
+
formula: formulaStr,
|
|
414
|
+
weights: calculationWeights,
|
|
415
|
+
normalized: formulaStr,
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function getRating(score) {
|
|
420
|
+
if (score >= 90) return 'Excellent' /* Excellent */;
|
|
421
|
+
if (score >= 75) return 'Good' /* Good */;
|
|
422
|
+
if (score >= 60) return 'Fair' /* Fair */;
|
|
423
|
+
if (score >= 40) return 'Needs Work' /* NeedsWork */;
|
|
424
|
+
return 'Critical' /* Critical */;
|
|
425
|
+
}
|
|
426
|
+
function getRatingSlug(score) {
|
|
427
|
+
if (score >= 90) return 'excellent';
|
|
428
|
+
if (score >= 75) return 'good';
|
|
429
|
+
if (score >= 60) return 'fair';
|
|
430
|
+
if (score >= 40) return 'needs-work';
|
|
431
|
+
return 'critical';
|
|
432
|
+
}
|
|
433
|
+
function getRatingWithContext(score, fileCount, modelTier = 'standard') {
|
|
434
|
+
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
435
|
+
const normalized = score - threshold + 70;
|
|
436
|
+
return getRating(normalized);
|
|
437
|
+
}
|
|
438
|
+
function getRatingDisplay(rating) {
|
|
439
|
+
switch (rating) {
|
|
440
|
+
case 'Excellent' /* Excellent */:
|
|
441
|
+
return { emoji: '\u2705', color: 'green' };
|
|
442
|
+
case 'Good' /* Good */:
|
|
443
|
+
return { emoji: '\u{1F44D}', color: 'blue' };
|
|
444
|
+
case 'Fair' /* Fair */:
|
|
445
|
+
return { emoji: '\u26A0\uFE0F', color: 'yellow' };
|
|
446
|
+
case 'Needs Work' /* NeedsWork */:
|
|
447
|
+
return { emoji: '\u{1F528}', color: 'orange' };
|
|
448
|
+
case 'Critical' /* Critical */:
|
|
449
|
+
return { emoji: '\u274C', color: 'red' };
|
|
450
|
+
default:
|
|
451
|
+
return { emoji: '\u2753', color: 'gray' };
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function formatScore(result) {
|
|
455
|
+
const { emoji } = getRatingDisplay(result.rating);
|
|
456
|
+
return `${result.overall}/100 (${result.rating}) ${emoji}`;
|
|
457
|
+
}
|
|
458
|
+
function formatToolScore(output) {
|
|
459
|
+
let result = ` Score: ${output.score}/100
|
|
460
|
+
|
|
461
|
+
`;
|
|
462
|
+
if (output.factors && output.factors.length > 0) {
|
|
463
|
+
result += ` Factors:
|
|
464
|
+
`;
|
|
465
|
+
output.factors.forEach((factor) => {
|
|
466
|
+
const impactSign = factor.impact > 0 ? '+' : '';
|
|
467
|
+
result += ` \u2022 ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}
|
|
468
|
+
`;
|
|
469
|
+
});
|
|
470
|
+
result += '\n';
|
|
471
|
+
}
|
|
472
|
+
if (output.recommendations && output.recommendations.length > 0) {
|
|
473
|
+
result += ` Recommendations:
|
|
474
|
+
`;
|
|
475
|
+
output.recommendations.forEach((rec, i) => {
|
|
476
|
+
let priorityIcon = '\u{1F535}';
|
|
477
|
+
const prio = rec.priority;
|
|
478
|
+
if (prio === 'high' /* High */ || prio === 'high')
|
|
479
|
+
priorityIcon = '\u{1F534}';
|
|
480
|
+
else if (prio === 'medium' /* Medium */ || prio === 'medium')
|
|
481
|
+
priorityIcon = '\u{1F7E1}';
|
|
482
|
+
result += ` ${i + 1}. ${priorityIcon} ${rec.action}
|
|
483
|
+
`;
|
|
484
|
+
result += ` Impact: +${rec.estimatedImpact} points
|
|
485
|
+
|
|
486
|
+
`;
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// src/utils/visualization.ts
|
|
493
|
+
function generateHTML(graph) {
|
|
494
|
+
const payload = JSON.stringify(graph, null, 2);
|
|
495
|
+
return `<!doctype html>
|
|
496
|
+
<html>
|
|
497
|
+
<head>
|
|
498
|
+
<meta charset="utf-8" />
|
|
499
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
500
|
+
<title>AIReady Visualization</title>
|
|
501
|
+
<style>
|
|
502
|
+
html,body { height: 100%; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f172a; color: #e2e8f0 }
|
|
503
|
+
#container { display:flex; height:100vh }
|
|
504
|
+
#panel { width: 320px; padding: 16px; background: #071130; box-shadow: -2px 0 8px rgba(0,0,0,0.3); overflow:auto }
|
|
505
|
+
#canvasWrap { flex:1; display:flex; align-items:center; justify-content:center }
|
|
506
|
+
canvas { background: #0b1220; border-radius:8px }
|
|
507
|
+
.stat { margin-bottom:12px }
|
|
508
|
+
</style>
|
|
509
|
+
</head>
|
|
510
|
+
<body>
|
|
511
|
+
<div id="container">
|
|
512
|
+
<div id="canvasWrap"><canvas id="canvas" width="1200" height="800"></canvas></div>
|
|
513
|
+
<div id="panel">
|
|
514
|
+
<h2>AIReady Visualization</h2>
|
|
515
|
+
<div class="stat"><strong>Files:</strong> <span id="stat-files"></span></div>
|
|
516
|
+
<div class="stat"><strong>Dependencies:</strong> <span id="stat-deps"></span></div>
|
|
517
|
+
<div class="stat"><strong>Legend</strong></div>
|
|
518
|
+
<div style="font-size:13px;line-height:1.3;color:#cbd5e1;margin-top:8px">
|
|
519
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#ff4d4f;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Critical</strong>: highest severity issues.</div>
|
|
520
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#ff9900;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Major</strong>: important issues.</div>
|
|
521
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#ffd666;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Minor</strong>: low priority issues.</div>
|
|
522
|
+
<div style="margin-bottom:8px"><span style="display:inline-block;width:12px;height:12px;background:#91d5ff;margin-right:8px;border:1px solid rgba(255,255,255,0.06)"></span><strong>Info</strong>: informational notes.</div>
|
|
523
|
+
<div style="margin-top:10px;color:#94a3b8"><strong>Node size</strong>: larger = higher token cost, more issues or dependency weight.</div>
|
|
524
|
+
<div style="margin-top:6px;color:#94a3b8"><strong>Proximity</strong>: nodes that are spatially close are more contextually related; relatedness is represented by distance and size rather than explicit edges.</div>
|
|
525
|
+
<div style="margin-top:6px;color:#94a3b8"><strong>Edge colors</strong>: <span style="color:#fb7e81">Similarity</span>, <span style="color:#84c1ff">Dependency</span>, <span style="color:#ffa500">Reference</span>, default <span style="color:#334155">Other</span>.</div>
|
|
526
|
+
</div>
|
|
527
|
+
</div>
|
|
528
|
+
</div>
|
|
529
|
+
|
|
530
|
+
<script>
|
|
531
|
+
const graphData = ${payload};
|
|
532
|
+
document.getElementById('stat-files').textContent = graphData.metadata.totalFiles;
|
|
533
|
+
document.getElementById('stat-deps').textContent = graphData.metadata.totalDependencies;
|
|
534
|
+
|
|
535
|
+
const canvas = document.getElementById('canvas');
|
|
536
|
+
const ctx = canvas.getContext('2d');
|
|
537
|
+
|
|
538
|
+
const nodes = graphData.nodes.map((n, i) => ({
|
|
539
|
+
...n,
|
|
540
|
+
x: canvas.width / 2 + Math.cos(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
|
|
541
|
+
y: canvas.height / 2 + Math.sin(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
|
|
542
|
+
}));
|
|
543
|
+
|
|
544
|
+
function draw() {
|
|
545
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
546
|
+
|
|
547
|
+
graphData.edges.forEach(edge => {
|
|
548
|
+
const s = nodes.find(n => n.id === edge.source);
|
|
549
|
+
const t = nodes.find(n => n.id === edge.target);
|
|
550
|
+
if (!s || !t) return;
|
|
551
|
+
if (edge.type === 'related') return;
|
|
552
|
+
if (edge.type === 'similarity') {
|
|
553
|
+
ctx.strokeStyle = '#fb7e81';
|
|
554
|
+
ctx.lineWidth = 1.2;
|
|
555
|
+
} else if (edge.type === 'dependency') {
|
|
556
|
+
ctx.strokeStyle = '#84c1ff';
|
|
557
|
+
ctx.lineWidth = 1.0;
|
|
558
|
+
} else if (edge.type === 'reference') {
|
|
559
|
+
ctx.strokeStyle = '#ffa500';
|
|
560
|
+
ctx.lineWidth = 0.9;
|
|
561
|
+
} else {
|
|
562
|
+
ctx.strokeStyle = '#334155';
|
|
563
|
+
ctx.lineWidth = 0.8;
|
|
564
|
+
}
|
|
565
|
+
ctx.beginPath();
|
|
566
|
+
ctx.moveTo(s.x, s.y);
|
|
567
|
+
ctx.lineTo(t.x, t.y);
|
|
568
|
+
ctx.stroke();
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
const groups = {};
|
|
572
|
+
nodes.forEach(n => {
|
|
573
|
+
const g = n.group || '__default';
|
|
574
|
+
if (!groups[g]) groups[g] = { minX: n.x, minY: n.y, maxX: n.x, maxY: n.y };
|
|
575
|
+
groups[g].minX = Math.min(groups[g].minX, n.x);
|
|
576
|
+
groups[g].minY = Math.min(groups[g].minY, n.y);
|
|
577
|
+
groups[g].maxX = Math.max(groups[g].maxX, n.x);
|
|
578
|
+
groups[g].maxY = Math.max(groups[g].maxY, n.y);
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
const groupRelations = {};
|
|
582
|
+
graphData.edges.forEach(edge => {
|
|
583
|
+
const sNode = nodes.find(n => n.id === edge.source);
|
|
584
|
+
const tNode = nodes.find(n => n.id === edge.target);
|
|
585
|
+
if (!sNode || !tNode) return;
|
|
586
|
+
const g1 = sNode.group || '__default';
|
|
587
|
+
const g2 = tNode.group || '__default';
|
|
588
|
+
if (g1 === g2) return;
|
|
589
|
+
const key = g1 < g2 ? g1 + '::' + g2 : g2 + '::' + g1;
|
|
590
|
+
groupRelations[key] = (groupRelations[key] || 0) + 1;
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
Object.keys(groupRelations).forEach(k => {
|
|
594
|
+
const count = groupRelations[k];
|
|
595
|
+
const [ga, gb] = k.split('::');
|
|
596
|
+
if (!groups[ga] || !groups[gb]) return;
|
|
597
|
+
const ax = (groups[ga].minX + groups[ga].maxX) / 2;
|
|
598
|
+
const ay = (groups[ga].minY + groups[ga].maxY) / 2;
|
|
599
|
+
const bx = (groups[gb].minX + groups[gb].maxX) / 2;
|
|
600
|
+
const by = (groups[gb].minY + groups[gb].maxY) / 2;
|
|
601
|
+
ctx.beginPath();
|
|
602
|
+
ctx.strokeStyle = 'rgba(148,163,184,0.25)';
|
|
603
|
+
ctx.lineWidth = Math.min(6, 0.6 + Math.sqrt(count));
|
|
604
|
+
ctx.moveTo(ax, ay);
|
|
605
|
+
ctx.lineTo(bx, by);
|
|
606
|
+
ctx.stroke();
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
Object.keys(groups).forEach(g => {
|
|
610
|
+
if (g === '__default') return;
|
|
611
|
+
const box = groups[g];
|
|
612
|
+
const pad = 16;
|
|
613
|
+
const x = box.minX - pad;
|
|
614
|
+
const y = box.minY - pad;
|
|
615
|
+
const w = (box.maxX - box.minX) + pad * 2;
|
|
616
|
+
const h = (box.maxY - box.minY) + pad * 2;
|
|
617
|
+
ctx.save();
|
|
618
|
+
ctx.fillStyle = 'rgba(30,64,175,0.04)';
|
|
619
|
+
ctx.strokeStyle = 'rgba(30,64,175,0.12)';
|
|
620
|
+
ctx.lineWidth = 1.2;
|
|
621
|
+
const r = 8;
|
|
622
|
+
ctx.beginPath();
|
|
623
|
+
ctx.moveTo(x + r, y);
|
|
624
|
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
|
625
|
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
|
626
|
+
ctx.arcTo(x, y + h, x, y, r);
|
|
627
|
+
ctx.arcTo(x, y, x + w, y, r);
|
|
628
|
+
ctx.closePath();
|
|
629
|
+
ctx.fill();
|
|
630
|
+
ctx.stroke();
|
|
631
|
+
ctx.restore();
|
|
632
|
+
ctx.fillStyle = '#94a3b8';
|
|
633
|
+
ctx.font = '11px sans-serif';
|
|
634
|
+
ctx.fillText(g, x + 8, y + 14);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
nodes.forEach(n => {
|
|
638
|
+
const sizeVal = (n.size || n.value || 1);
|
|
639
|
+
const r = 6 + (sizeVal / 2);
|
|
640
|
+
ctx.beginPath();
|
|
641
|
+
ctx.fillStyle = n.color || '#60a5fa';
|
|
642
|
+
ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
|
|
643
|
+
ctx.fill();
|
|
644
|
+
|
|
645
|
+
ctx.fillStyle = '#e2e8f0';
|
|
646
|
+
ctx.font = '11px sans-serif';
|
|
647
|
+
ctx.textAlign = 'center';
|
|
648
|
+
ctx.fillText(n.label || n.id.split('/').slice(-1)[0], n.x, n.y + r + 12);
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
draw();
|
|
653
|
+
</script>
|
|
654
|
+
</body>
|
|
655
|
+
</html>`;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
export {
|
|
659
|
+
Severity,
|
|
660
|
+
ToolName,
|
|
661
|
+
IssueType,
|
|
662
|
+
SpokeOutputSchema,
|
|
663
|
+
GLOBAL_INFRA_OPTIONS,
|
|
664
|
+
GLOBAL_SCAN_OPTIONS,
|
|
665
|
+
COMMON_FINE_TUNING_OPTIONS,
|
|
666
|
+
Language,
|
|
667
|
+
LANGUAGE_EXTENSIONS,
|
|
668
|
+
ParseError,
|
|
669
|
+
RecommendationPriority,
|
|
670
|
+
ReadinessRating,
|
|
671
|
+
DEFAULT_TOOL_WEIGHTS,
|
|
672
|
+
TOOL_NAME_MAP,
|
|
673
|
+
ScoringProfile,
|
|
674
|
+
SCORING_PROFILES,
|
|
675
|
+
CONTEXT_TIER_THRESHOLDS,
|
|
676
|
+
SIZE_ADJUSTED_THRESHOLDS,
|
|
677
|
+
getProjectSizeTier,
|
|
678
|
+
getRecommendedThreshold,
|
|
679
|
+
normalizeToolName,
|
|
680
|
+
getToolWeight,
|
|
681
|
+
parseWeightString,
|
|
682
|
+
calculateOverallScore,
|
|
683
|
+
getRating,
|
|
684
|
+
getRatingSlug,
|
|
685
|
+
getRatingWithContext,
|
|
686
|
+
getRatingDisplay,
|
|
687
|
+
formatScore,
|
|
688
|
+
formatToolScore,
|
|
689
|
+
generateHTML,
|
|
690
|
+
};
|