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