@aiready/core 0.23.5 → 0.23.7

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