@aiready/core 0.24.23 → 0.24.25

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 (59) hide show
  1. package/dist/chunk-3GCIM6XG.mjs +904 -0
  2. package/dist/chunk-3S5WU6KX.mjs +552 -0
  3. package/dist/chunk-4OMXBYX7.mjs +167 -0
  4. package/dist/chunk-6YWGFKZG.mjs +250 -0
  5. package/dist/chunk-A3BIROBZ.mjs +902 -0
  6. package/dist/chunk-BYMQDORS.mjs +256 -0
  7. package/dist/chunk-CBZNRNEF.mjs +309 -0
  8. package/dist/chunk-ET2WRQSM.mjs +262 -0
  9. package/dist/chunk-F4FTHFHK.mjs +552 -0
  10. package/dist/chunk-G737F72Q.mjs +256 -0
  11. package/dist/chunk-GVFUAIWU.mjs +864 -0
  12. package/dist/chunk-KSEA5XDH.mjs +894 -0
  13. package/dist/chunk-LMIZRJFV.mjs +256 -0
  14. package/dist/chunk-LRPBPWBM.mjs +170 -0
  15. package/dist/chunk-MOTBXU6W.mjs +902 -0
  16. package/dist/chunk-OAH6FVVF.mjs +919 -0
  17. package/dist/chunk-OCM6HLBM.mjs +262 -0
  18. package/dist/chunk-OFBRNGKT.mjs +893 -0
  19. package/dist/chunk-P3KYGPO4.mjs +262 -0
  20. package/dist/chunk-PNWSO6XQ.mjs +250 -0
  21. package/dist/chunk-SO6UKAPR.mjs +164 -0
  22. package/dist/chunk-T2FW6AAF.mjs +552 -0
  23. package/dist/chunk-TQX77RIC.mjs +250 -0
  24. package/dist/chunk-X64EJ3ZO.mjs +314 -0
  25. package/dist/client/index.d.mts +1 -1
  26. package/dist/client/index.d.ts +1 -1
  27. package/dist/client/index.js +32 -5
  28. package/dist/client/index.mjs +1 -1
  29. package/dist/csharp-parser-3CGM6FKB.mjs +9 -0
  30. package/dist/csharp-parser-UWRUYHUH.mjs +9 -0
  31. package/dist/csharp-parser-WIAIE3DD.mjs +9 -0
  32. package/dist/go-parser-AH5QNS4O.mjs +9 -0
  33. package/dist/go-parser-CSAB23BL.mjs +9 -0
  34. package/dist/go-parser-Q3HI32B7.mjs +9 -0
  35. package/dist/index-CL_0jxiJ.d.mts +1315 -0
  36. package/dist/index-CL_0jxiJ.d.ts +1315 -0
  37. package/dist/index-ClwnZa_Y.d.mts +1333 -0
  38. package/dist/index-ClwnZa_Y.d.ts +1333 -0
  39. package/dist/index-DC0cdf0g.d.mts +1321 -0
  40. package/dist/index-DC0cdf0g.d.ts +1321 -0
  41. package/dist/index-DKqKGhcJ.d.mts +1309 -0
  42. package/dist/index-DKqKGhcJ.d.ts +1309 -0
  43. package/dist/index-DNnlhdk0.d.mts +1318 -0
  44. package/dist/index-DNnlhdk0.d.ts +1318 -0
  45. package/dist/index-De2xy_k5.d.mts +1326 -0
  46. package/dist/index-De2xy_k5.d.ts +1326 -0
  47. package/dist/index.d.mts +104 -20
  48. package/dist/index.d.ts +104 -20
  49. package/dist/index.js +581 -147
  50. package/dist/index.mjs +507 -134
  51. package/dist/java-parser-GUKWCEYS.mjs +9 -0
  52. package/dist/java-parser-XTWT5Y5I.mjs +9 -0
  53. package/dist/java-parser-YP5XWLQK.mjs +9 -0
  54. package/dist/python-parser-AOPXUEIV.mjs +8 -0
  55. package/dist/python-parser-FB55P6UA.mjs +8 -0
  56. package/dist/python-parser-WIJPSRKC.mjs +8 -0
  57. package/dist/typescript-parser-5ZWLLMWJ.mjs +7 -0
  58. package/dist/typescript-parser-TWPRLYK6.mjs +7 -0
  59. package/package.json +5 -1
@@ -0,0 +1,919 @@
1
+ // src/types/enums.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
+ ToolName2["ContractEnforcement"] = "contract-enforcement";
26
+ return ToolName2;
27
+ })(ToolName || {});
28
+ var ToolNameSchema = z.nativeEnum(ToolName);
29
+ var FRIENDLY_TOOL_NAMES = {
30
+ ["pattern-detect" /* PatternDetect */]: "Semantic Duplicates",
31
+ ["context-analyzer" /* ContextAnalyzer */]: "Context Fragmentation",
32
+ ["naming-consistency" /* NamingConsistency */]: "Naming Consistency",
33
+ ["ai-signal-clarity" /* AiSignalClarity */]: "AI Signal Clarity",
34
+ ["agent-grounding" /* AgentGrounding */]: "Agent Grounding",
35
+ ["testability-index" /* TestabilityIndex */]: "Testability Index",
36
+ ["doc-drift" /* DocDrift */]: "Documentation Health",
37
+ ["dependency-health" /* DependencyHealth */]: "Dependency Health",
38
+ ["change-amplification" /* ChangeAmplification */]: "Change Amplification",
39
+ ["cognitive-load" /* CognitiveLoad */]: "Cognitive Load",
40
+ ["pattern-entropy" /* PatternEntropy */]: "Pattern Entropy",
41
+ ["concept-cohesion" /* ConceptCohesion */]: "Concept Cohesion",
42
+ ["semantic-distance" /* SemanticDistance */]: "Semantic Distance",
43
+ ["contract-enforcement" /* ContractEnforcement */]: "Contract Enforcement"
44
+ };
45
+ var IssueType = /* @__PURE__ */ ((IssueType2) => {
46
+ IssueType2["DuplicatePattern"] = "duplicate-pattern";
47
+ IssueType2["PatternInconsistency"] = "pattern-inconsistency";
48
+ IssueType2["ContextFragmentation"] = "context-fragmentation";
49
+ IssueType2["DependencyHealth"] = "dependency-health";
50
+ IssueType2["CircularDependency"] = "circular-dependency";
51
+ IssueType2["DocDrift"] = "doc-drift";
52
+ IssueType2["NamingInconsistency"] = "naming-inconsistency";
53
+ IssueType2["NamingQuality"] = "naming-quality";
54
+ IssueType2["ArchitectureInconsistency"] = "architecture-inconsistency";
55
+ IssueType2["DeadCode"] = "dead-code";
56
+ IssueType2["MissingTypes"] = "missing-types";
57
+ IssueType2["MagicLiteral"] = "magic-literal";
58
+ IssueType2["BooleanTrap"] = "boolean-trap";
59
+ IssueType2["AiSignalClarity"] = "ai-signal-clarity";
60
+ IssueType2["LowTestability"] = "low-testability";
61
+ IssueType2["AgentNavigationFailure"] = "agent-navigation-failure";
62
+ IssueType2["AmbiguousApi"] = "ambiguous-api";
63
+ IssueType2["ChangeAmplification"] = "change-amplification";
64
+ IssueType2["ContractGap"] = "contract-gap";
65
+ return IssueType2;
66
+ })(IssueType || {});
67
+ var IssueTypeSchema = z.nativeEnum(IssueType);
68
+ var AnalysisStatus = /* @__PURE__ */ ((AnalysisStatus2) => {
69
+ AnalysisStatus2["Processing"] = "processing";
70
+ AnalysisStatus2["Completed"] = "completed";
71
+ AnalysisStatus2["Failed"] = "failed";
72
+ return AnalysisStatus2;
73
+ })(AnalysisStatus || {});
74
+ var AnalysisStatusSchema = z.nativeEnum(AnalysisStatus);
75
+ var ModelTier = /* @__PURE__ */ ((ModelTier2) => {
76
+ ModelTier2["Compact"] = "compact";
77
+ ModelTier2["Standard"] = "standard";
78
+ ModelTier2["Extended"] = "extended";
79
+ ModelTier2["Frontier"] = "frontier";
80
+ return ModelTier2;
81
+ })(ModelTier || {});
82
+ var ModelTierSchema = z.nativeEnum(ModelTier);
83
+
84
+ // src/types/common.ts
85
+ import { z as z2 } from "zod";
86
+ var LocationSchema = z2.object({
87
+ file: z2.string(),
88
+ line: z2.number(),
89
+ column: z2.number().optional(),
90
+ endLine: z2.number().optional(),
91
+ endColumn: z2.number().optional()
92
+ });
93
+
94
+ // src/types/schemas/issue.ts
95
+ import { z as z3 } from "zod";
96
+ var IssueSchema = z3.object({
97
+ type: IssueTypeSchema,
98
+ severity: SeveritySchema,
99
+ category: z3.string().optional(),
100
+ message: z3.string(),
101
+ location: LocationSchema,
102
+ suggestion: z3.string().optional()
103
+ });
104
+
105
+ // src/types/schemas/metrics.ts
106
+ import { z as z4 } from "zod";
107
+ var MetricsSchema = z4.object({
108
+ tokenCost: z4.number().optional(),
109
+ complexityScore: z4.number().optional(),
110
+ consistencyScore: z4.number().optional(),
111
+ docFreshnessScore: z4.number().optional(),
112
+ // AI agent readiness metrics (v0.12+)
113
+ aiSignalClarityScore: z4.number().optional(),
114
+ agentGroundingScore: z4.number().optional(),
115
+ testabilityScore: z4.number().optional(),
116
+ docDriftScore: z4.number().optional(),
117
+ dependencyHealthScore: z4.number().optional(),
118
+ modelContextTier: ModelTierSchema.optional(),
119
+ // Business value metrics
120
+ estimatedMonthlyCost: z4.number().optional(),
121
+ estimatedDeveloperHours: z4.number().optional(),
122
+ comprehensionDifficultyIndex: z4.number().optional(),
123
+ // Extended metrics for specific spokes
124
+ totalSymbols: z4.number().optional(),
125
+ totalExports: z4.number().optional()
126
+ });
127
+
128
+ // src/types/schemas/report.ts
129
+ import { z as z5 } from "zod";
130
+ var AnalysisResultSchema = z5.object({
131
+ fileName: z5.string(),
132
+ issues: z5.array(IssueSchema),
133
+ metrics: MetricsSchema
134
+ });
135
+ var SpokeSummarySchema = z5.object({
136
+ totalFiles: z5.number().optional(),
137
+ totalIssues: z5.number().optional(),
138
+ criticalIssues: z5.number().optional(),
139
+ majorIssues: z5.number().optional(),
140
+ minorIssues: z5.number().optional(),
141
+ score: z5.number().optional()
142
+ }).catchall(z5.any());
143
+ var SpokeOutputSchema = z5.object({
144
+ results: z5.array(AnalysisResultSchema),
145
+ summary: SpokeSummarySchema,
146
+ metadata: z5.object({
147
+ toolName: z5.string(),
148
+ version: z5.string().optional(),
149
+ timestamp: z5.string().optional(),
150
+ config: z5.any().optional()
151
+ }).catchall(z5.any()).optional()
152
+ });
153
+ var UnifiedReportSchema = z5.object({
154
+ summary: z5.object({
155
+ totalFiles: z5.number(),
156
+ totalIssues: z5.number(),
157
+ criticalIssues: z5.number(),
158
+ majorIssues: z5.number(),
159
+ minorIssues: z5.number(),
160
+ businessImpact: z5.object({
161
+ estimatedMonthlyWaste: z5.number().optional(),
162
+ potentialSavings: z5.number().optional(),
163
+ productivityHours: z5.number().optional()
164
+ }).optional()
165
+ }),
166
+ results: z5.array(AnalysisResultSchema),
167
+ scoring: z5.object({
168
+ overall: z5.number(),
169
+ rating: z5.string(),
170
+ timestamp: z5.string(),
171
+ breakdown: z5.array(
172
+ z5.object({
173
+ toolName: z5.union([ToolNameSchema, z5.string()]),
174
+ score: z5.number()
175
+ }).catchall(z5.any())
176
+ )
177
+ }).optional()
178
+ }).catchall(z5.any());
179
+
180
+ // src/types/schemas/config.ts
181
+ import { z as z6 } from "zod";
182
+ var AutoExcludeSchema = z6.object({
183
+ /** Enable automatic detection of test files */
184
+ tests: z6.boolean().optional(),
185
+ /** Enable automatic detection of mock files */
186
+ mocks: z6.boolean().optional(),
187
+ /** Enable automatic detection of barrel/re-export files */
188
+ barrels: z6.boolean().optional(),
189
+ /** Enable automatic detection of generated files */
190
+ generated: z6.boolean().optional()
191
+ }).optional();
192
+ var TieredExcludeSchema = z6.record(z6.string(), z6.array(z6.string()));
193
+ var AIReadyConfigSchema = z6.object({
194
+ /** Extend from another config file (relative path) */
195
+ extends: z6.string().optional(),
196
+ /** Files or directories to exclude from scan (flat array or tiered) */
197
+ exclude: z6.union([z6.array(z6.string()), TieredExcludeSchema]).optional(),
198
+ /** Auto-exclusion settings for common patterns */
199
+ autoExclude: AutoExcludeSchema,
200
+ /** Fail CI/CD if score below threshold (0-100) */
201
+ threshold: z6.number().optional(),
202
+ /** Fail on issues: critical, major, any */
203
+ failOn: z6.enum(["critical", "major", "any", "none"]).optional(),
204
+ /** Scan-specific configuration */
205
+ scan: z6.object({
206
+ include: z6.array(z6.string()).optional(),
207
+ exclude: z6.array(z6.string()).optional(),
208
+ parallel: z6.boolean().optional(),
209
+ deep: z6.boolean().optional(),
210
+ tools: z6.array(z6.string()).optional()
211
+ }).optional(),
212
+ /** Output-specific configuration */
213
+ output: z6.object({
214
+ /** Output format (json, console, html) */
215
+ format: z6.enum(["json", "console", "html"]).optional(),
216
+ /** Output file path */
217
+ path: z6.string().optional(),
218
+ /** Output directory */
219
+ saveTo: z6.string().optional(),
220
+ /** Whether to show score breakdown in console */
221
+ showBreakdown: z6.boolean().optional(),
222
+ /** Baseline report to compare against */
223
+ compareBaseline: z6.string().optional()
224
+ }).optional(),
225
+ /** Tool-specific configuration overrides (Strictly ToolName -> Config) */
226
+ tools: z6.record(
227
+ z6.string(),
228
+ z6.object({
229
+ /** Whether to enable this tool */
230
+ enabled: z6.boolean().optional(),
231
+ /** Severity overrides for specific categories */
232
+ severityOverrides: z6.record(z6.string(), SeveritySchema).optional()
233
+ }).catchall(z6.any())
234
+ ).optional(),
235
+ /** Scoring profile and weights */
236
+ scoring: z6.object({
237
+ /** Name of the scoring profile (e.g. "strict", "balanced") */
238
+ profile: z6.string().optional(),
239
+ /** Custom weights for tools and metrics */
240
+ weights: z6.record(z6.string(), z6.number()).optional()
241
+ }).optional(),
242
+ /** Visualizer settings (interactive graph) */
243
+ visualizer: z6.object({
244
+ groupingDirs: z6.array(z6.string()).optional(),
245
+ graph: z6.object({
246
+ maxNodes: z6.number().optional(),
247
+ maxEdges: z6.number().optional()
248
+ }).optional()
249
+ }).optional()
250
+ }).catchall(z6.any());
251
+
252
+ // src/types/business.ts
253
+ import { z as z7 } from "zod";
254
+ var LeadSource = /* @__PURE__ */ ((LeadSource2) => {
255
+ LeadSource2["ClawMoreHero"] = "clawmore-hero";
256
+ LeadSource2["ClawMoreWaitlist"] = "clawmore-waitlist";
257
+ LeadSource2["ClawMoreBeta"] = "clawmore-beta";
258
+ LeadSource2["AiReadyPlatform"] = "aiready-platform";
259
+ return LeadSource2;
260
+ })(LeadSource || {});
261
+ var LeadSourceSchema = z7.nativeEnum(LeadSource);
262
+ var LeadSchema = z7.object({
263
+ id: z7.string(),
264
+ email: z7.string().email(),
265
+ name: z7.string().min(1),
266
+ interest: z7.string().default("General"),
267
+ notes: z7.string().optional(),
268
+ timestamp: z7.string().datetime(),
269
+ source: LeadSourceSchema,
270
+ status: z7.enum(["new", "contacted", "qualified", "converted", "archived"]).default("new")
271
+ });
272
+ var LeadSubmissionSchema = LeadSchema.omit({
273
+ id: true,
274
+ timestamp: true,
275
+ status: true
276
+ });
277
+ var ManagedAccountSchema = z7.object({
278
+ id: z7.string(),
279
+ // Internal UUID
280
+ accountId: z7.string(),
281
+ // AWS Account ID
282
+ userId: z7.string(),
283
+ // Owner (team@getaiready.dev)
284
+ stripeSubscriptionId: z7.string(),
285
+ // AI Token Management
286
+ tokenStrategy: z7.enum(["managed", "byok"]).default("managed"),
287
+ byokConfig: z7.object({
288
+ openaiKey: z7.string().optional(),
289
+ anthropicKey: z7.string().optional(),
290
+ openrouterKey: z7.string().optional()
291
+ }).optional(),
292
+ // Financials (in cents)
293
+ baseFeeCents: z7.number().default(2900),
294
+ includedComputeCents: z7.number().default(1500),
295
+ // $15.00 AWS included
296
+ includedTokenCents: z7.number().default(500),
297
+ // $5.00 Managed Tokens included
298
+ // Pre-paid Balance (credits)
299
+ prepaidTokenBalanceCents: z7.number().default(0),
300
+ // Users buy these in $10 packs
301
+ currentMonthlyTokenSpendCents: z7.number().default(0),
302
+ // Governance
303
+ status: z7.enum(["provisioning", "active", "warning", "quarantined", "suspended"]).default("provisioning"),
304
+ lastCostSyncAt: z7.string().datetime().optional(),
305
+ region: z7.string().default("ap-southeast-2"),
306
+ // Alerting thresholds (percentage of includedComputeCents)
307
+ alertThresholds: z7.array(z7.number()).default([50, 80, 100, 150])
308
+ });
309
+
310
+ // src/types.ts
311
+ var GLOBAL_INFRA_OPTIONS = [
312
+ "rootDir",
313
+ "include",
314
+ "exclude",
315
+ "tools",
316
+ "scoring",
317
+ "changedFilesOnly"
318
+ ];
319
+ var GLOBAL_SCAN_OPTIONS = [
320
+ "rootDir",
321
+ "include",
322
+ "exclude",
323
+ "config",
324
+ "threshold",
325
+ "output",
326
+ "format",
327
+ "parallel",
328
+ "changedFilesOnly"
329
+ ];
330
+ var COMMON_FINE_TUNING_OPTIONS = [
331
+ "maxDepth",
332
+ "minSimilarity",
333
+ "threshold",
334
+ "showBreakdown"
335
+ ];
336
+
337
+ // src/utils/visualization.ts
338
+ function generateHTML(graph) {
339
+ const payload = JSON.stringify(graph, null, 2);
340
+ return `<!doctype html>
341
+ <html>
342
+ <head>
343
+ <meta charset="utf-8" />
344
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
345
+ <title>AIReady Visualization</title>
346
+ <style>
347
+ html,body { height: 100%; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f172a; color: #e2e8f0 }
348
+ #container { display:flex; height:100vh }
349
+ #panel { width: 320px; padding: 16px; background: #071130; box-shadow: -2px 0 8px rgba(0,0,0,0.3); overflow:auto }
350
+ #canvasWrap { flex:1; display:flex; align-items:center; justify-content:center }
351
+ canvas { background: #0b1220; border-radius:8px }
352
+ .stat { margin-bottom:12px }
353
+ </style>
354
+ </head>
355
+ <body>
356
+ <div id="container">
357
+ <div id="canvasWrap"><canvas id="canvas" width="1200" height="800"></canvas></div>
358
+ <div id="panel">
359
+ <h2>AIReady Visualization</h2>
360
+ <div class="stat"><strong>Files:</strong> <span id="stat-files"></span></div>
361
+ <div class="stat"><strong>Dependencies:</strong> <span id="stat-deps"></span></div>
362
+ <div class="stat"><strong>Legend</strong></div>
363
+ <div style="font-size:13px;line-height:1.3;color:#cbd5e1;margin-top:8px">
364
+ <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>
365
+ <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>
366
+ <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>
367
+ <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>
368
+ <div style="margin-top:10px;color:#94a3b8"><strong>Node size</strong>: larger = higher token cost, more issues or dependency weight.</div>
369
+ <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>
370
+ <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>
371
+ </div>
372
+ </div>
373
+ </div>
374
+
375
+ <script>
376
+ const graphData = ${payload};
377
+ document.getElementById('stat-files').textContent = graphData.metadata.totalFiles;
378
+ document.getElementById('stat-deps').textContent = graphData.metadata.totalDependencies;
379
+
380
+ const canvas = document.getElementById('canvas');
381
+ const ctx = canvas.getContext('2d');
382
+
383
+ const nodes = graphData.nodes.map((n, i) => ({
384
+ ...n,
385
+ x: canvas.width / 2 + Math.cos(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
386
+ y: canvas.height / 2 + Math.sin(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
387
+ }));
388
+
389
+ function draw() {
390
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
391
+
392
+ graphData.edges.forEach(edge => {
393
+ const s = nodes.find(n => n.id === edge.source);
394
+ const t = nodes.find(n => n.id === edge.target);
395
+ if (!s || !t) return;
396
+ if (edge.type === 'related') return;
397
+ if (edge.type === 'similarity') {
398
+ ctx.strokeStyle = '#fb7e81';
399
+ ctx.lineWidth = 1.2;
400
+ } else if (edge.type === 'dependency') {
401
+ ctx.strokeStyle = '#84c1ff';
402
+ ctx.lineWidth = 1.0;
403
+ } else if (edge.type === 'reference') {
404
+ ctx.strokeStyle = '#ffa500';
405
+ ctx.lineWidth = 0.9;
406
+ } else {
407
+ ctx.strokeStyle = '#334155';
408
+ ctx.lineWidth = 0.8;
409
+ }
410
+ ctx.beginPath();
411
+ ctx.moveTo(s.x, s.y);
412
+ ctx.lineTo(t.x, t.y);
413
+ ctx.stroke();
414
+ });
415
+
416
+ const groups = {};
417
+ nodes.forEach(n => {
418
+ const g = n.group || '__default';
419
+ if (!groups[g]) groups[g] = { minX: n.x, minY: n.y, maxX: n.x, maxY: n.y };
420
+ groups[g].minX = Math.min(groups[g].minX, n.x);
421
+ groups[g].minY = Math.min(groups[g].minY, n.y);
422
+ groups[g].maxX = Math.max(groups[g].maxX, n.x);
423
+ groups[g].maxY = Math.max(groups[g].maxY, n.y);
424
+ });
425
+
426
+ const groupRelations = {};
427
+ graphData.edges.forEach(edge => {
428
+ const sNode = nodes.find(n => n.id === edge.source);
429
+ const tNode = nodes.find(n => n.id === edge.target);
430
+ if (!sNode || !tNode) return;
431
+ const g1 = sNode.group || '__default';
432
+ const g2 = tNode.group || '__default';
433
+ if (g1 === g2) return;
434
+ const key = g1 < g2 ? g1 + '::' + g2 : g2 + '::' + g1;
435
+ groupRelations[key] = (groupRelations[key] || 0) + 1;
436
+ });
437
+
438
+ Object.keys(groupRelations).forEach(k => {
439
+ const count = groupRelations[k];
440
+ const [ga, gb] = k.split('::');
441
+ if (!groups[ga] || !groups[gb]) return;
442
+ const ax = (groups[ga].minX + groups[ga].maxX) / 2;
443
+ const ay = (groups[ga].minY + groups[ga].maxY) / 2;
444
+ const bx = (groups[gb].minX + groups[gb].maxX) / 2;
445
+ const by = (groups[gb].minY + groups[gb].maxY) / 2;
446
+ ctx.beginPath();
447
+ ctx.strokeStyle = 'rgba(148,163,184,0.25)';
448
+ ctx.lineWidth = Math.min(6, 0.6 + Math.sqrt(count));
449
+ ctx.moveTo(ax, ay);
450
+ ctx.lineTo(bx, by);
451
+ ctx.stroke();
452
+ });
453
+
454
+ Object.keys(groups).forEach(g => {
455
+ if (g === '__default') return;
456
+ const box = groups[g];
457
+ const pad = 16;
458
+ const x = box.minX - pad;
459
+ const y = box.minY - pad;
460
+ const w = (box.maxX - box.minX) + pad * 2;
461
+ const h = (box.maxY - box.minY) + pad * 2;
462
+ ctx.save();
463
+ ctx.fillStyle = 'rgba(30,64,175,0.04)';
464
+ ctx.strokeStyle = 'rgba(30,64,175,0.12)';
465
+ ctx.lineWidth = 1.2;
466
+ const r = 8;
467
+ ctx.beginPath();
468
+ ctx.moveTo(x + r, y);
469
+ ctx.arcTo(x + w, y, x + w, y + h, r);
470
+ ctx.arcTo(x + w, y + h, x, y + h, r);
471
+ ctx.arcTo(x, y + h, x, y, r);
472
+ ctx.arcTo(x, y, x + w, y, r);
473
+ ctx.closePath();
474
+ ctx.fill();
475
+ ctx.stroke();
476
+ ctx.restore();
477
+ ctx.fillStyle = '#94a3b8';
478
+ ctx.font = '11px sans-serif';
479
+ ctx.fillText(g, x + 8, y + 14);
480
+ });
481
+
482
+ nodes.forEach(n => {
483
+ const sizeVal = (n.size || n.value || 1);
484
+ const r = 6 + (sizeVal / 2);
485
+ ctx.beginPath();
486
+ ctx.fillStyle = n.color || '#60a5fa';
487
+ ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
488
+ ctx.fill();
489
+
490
+ ctx.fillStyle = '#e2e8f0';
491
+ ctx.font = '11px sans-serif';
492
+ ctx.textAlign = 'center';
493
+ ctx.fillText(n.label || n.id.split('/').slice(-1)[0], n.x, n.y + r + 12);
494
+ });
495
+ }
496
+
497
+ draw();
498
+ </script>
499
+ </body>
500
+ </html>`;
501
+ }
502
+
503
+ // src/utils/rating-helpers.ts
504
+ var ReadinessRating = /* @__PURE__ */ ((ReadinessRating2) => {
505
+ ReadinessRating2["Excellent"] = "Excellent";
506
+ ReadinessRating2["Good"] = "Good";
507
+ ReadinessRating2["Fair"] = "Fair";
508
+ ReadinessRating2["NeedsWork"] = "Needs Work";
509
+ ReadinessRating2["Critical"] = "Critical";
510
+ return ReadinessRating2;
511
+ })(ReadinessRating || {});
512
+ function getRatingMetadata(score) {
513
+ if (score >= 90) {
514
+ return {
515
+ label: "Excellent",
516
+ slug: "excellent",
517
+ emoji: "\u2705",
518
+ rating: "Excellent" /* Excellent */
519
+ };
520
+ }
521
+ if (score >= 75) {
522
+ return {
523
+ label: "Good",
524
+ slug: "good",
525
+ emoji: "\u{1F44D}",
526
+ rating: "Good" /* Good */
527
+ };
528
+ }
529
+ if (score >= 60) {
530
+ return {
531
+ label: "Fair",
532
+ slug: "fair",
533
+ emoji: "\u{1F44C}",
534
+ rating: "Fair" /* Fair */
535
+ };
536
+ }
537
+ if (score >= 40) {
538
+ return {
539
+ label: "Needs Work",
540
+ slug: "needs-work",
541
+ emoji: "\u{1F528}",
542
+ rating: "Needs Work" /* NeedsWork */
543
+ };
544
+ }
545
+ return {
546
+ label: "Critical",
547
+ slug: "critical",
548
+ emoji: "\u{1F6A8}",
549
+ rating: "Critical" /* Critical */
550
+ };
551
+ }
552
+ function getRatingLabel(score) {
553
+ return getRatingMetadata(score).label;
554
+ }
555
+ function getRatingSlug(score) {
556
+ return getRatingMetadata(score).slug;
557
+ }
558
+ function getRatingEmoji(score) {
559
+ return getRatingMetadata(score).emoji;
560
+ }
561
+ function getToolEmoji(score) {
562
+ return getRatingEmoji(score);
563
+ }
564
+ function getPriorityIcon(priority) {
565
+ switch (priority) {
566
+ case "critical":
567
+ return "\u{1F534}";
568
+ case "high":
569
+ return "\u{1F7E0}";
570
+ case "medium":
571
+ return "\u{1F7E1}";
572
+ case "low":
573
+ return "\u{1F535}";
574
+ default:
575
+ return "\u26AA";
576
+ }
577
+ }
578
+ function getRating(score) {
579
+ return getRatingMetadata(score).rating;
580
+ }
581
+
582
+ // src/scoring-types.ts
583
+ var RecommendationPriority = /* @__PURE__ */ ((RecommendationPriority2) => {
584
+ RecommendationPriority2["High"] = "high";
585
+ RecommendationPriority2["Medium"] = "medium";
586
+ RecommendationPriority2["Low"] = "low";
587
+ return RecommendationPriority2;
588
+ })(RecommendationPriority || {});
589
+
590
+ // src/scoring.ts
591
+ var SCORING_CONSTANTS = {
592
+ WEIGHTS: {
593
+ DEFAULT: 5,
594
+ MAX: 100
595
+ },
596
+ THRESHOLDS: {
597
+ XS: 80,
598
+ SMALL: 75,
599
+ MEDIUM: 70,
600
+ LARGE: 65,
601
+ ENTERPRISE: 58,
602
+ NORMALIZATION_OFFSET: 70
603
+ },
604
+ FILE_COUNTS: {
605
+ XS: 50,
606
+ SMALL: 200,
607
+ MEDIUM: 500,
608
+ LARGE: 2e3
609
+ },
610
+ DELIMITERS: {
611
+ LIST: ",",
612
+ PAIR: ":",
613
+ FORMULA_JOIN: " + "
614
+ }
615
+ };
616
+ var DEFAULT_TOOL_WEIGHTS = {
617
+ ["pattern-detect" /* PatternDetect */]: 22,
618
+ ["context-analyzer" /* ContextAnalyzer */]: 19,
619
+ ["naming-consistency" /* NamingConsistency */]: 14,
620
+ ["ai-signal-clarity" /* AiSignalClarity */]: 11,
621
+ ["agent-grounding" /* AgentGrounding */]: 10,
622
+ ["testability-index" /* TestabilityIndex */]: 10,
623
+ ["doc-drift" /* DocDrift */]: 8,
624
+ ["dependency-health" /* DependencyHealth */]: 6,
625
+ ["change-amplification" /* ChangeAmplification */]: 8,
626
+ ["contract-enforcement" /* ContractEnforcement */]: 10,
627
+ ["cognitive-load" /* CognitiveLoad */]: 8,
628
+ ["pattern-entropy" /* PatternEntropy */]: 8,
629
+ ["concept-cohesion" /* ConceptCohesion */]: 10,
630
+ ["semantic-distance" /* SemanticDistance */]: 10
631
+ };
632
+ var TOOL_NAME_MAP = {
633
+ patterns: "pattern-detect" /* PatternDetect */,
634
+ "pattern-detect": "pattern-detect" /* PatternDetect */,
635
+ context: "context-analyzer" /* ContextAnalyzer */,
636
+ "context-analyzer": "context-analyzer" /* ContextAnalyzer */,
637
+ consistency: "naming-consistency" /* NamingConsistency */,
638
+ namingconsistency: "naming-consistency" /* NamingConsistency */,
639
+ "naming-consistency": "naming-consistency" /* NamingConsistency */,
640
+ "ai-signal": "ai-signal-clarity" /* AiSignalClarity */,
641
+ "ai-signal-clarity": "ai-signal-clarity" /* AiSignalClarity */,
642
+ grounding: "agent-grounding" /* AgentGrounding */,
643
+ "agent-grounding": "agent-grounding" /* AgentGrounding */,
644
+ testability: "testability-index" /* TestabilityIndex */,
645
+ "testability-index": "testability-index" /* TestabilityIndex */,
646
+ "doc-drift": "doc-drift" /* DocDrift */,
647
+ "deps-health": "dependency-health" /* DependencyHealth */,
648
+ "dependency-health": "dependency-health" /* DependencyHealth */,
649
+ "change-amp": "change-amplification" /* ChangeAmplification */,
650
+ "change-amplification": "change-amplification" /* ChangeAmplification */,
651
+ contract: "contract-enforcement" /* ContractEnforcement */,
652
+ "contract-enforcement": "contract-enforcement" /* ContractEnforcement */
653
+ };
654
+ var ScoringProfile = /* @__PURE__ */ ((ScoringProfile2) => {
655
+ ScoringProfile2["Default"] = "default";
656
+ ScoringProfile2["Agentic"] = "agentic";
657
+ ScoringProfile2["Logic"] = "logic";
658
+ ScoringProfile2["UI"] = "ui";
659
+ ScoringProfile2["Cost"] = "cost";
660
+ ScoringProfile2["Security"] = "security";
661
+ return ScoringProfile2;
662
+ })(ScoringProfile || {});
663
+ var SCORING_PROFILES = {
664
+ ["default" /* Default */]: DEFAULT_TOOL_WEIGHTS,
665
+ ["agentic" /* Agentic */]: {
666
+ ["ai-signal-clarity" /* AiSignalClarity */]: 25,
667
+ ["agent-grounding" /* AgentGrounding */]: 25,
668
+ ["testability-index" /* TestabilityIndex */]: 15,
669
+ ["contract-enforcement" /* ContractEnforcement */]: 15,
670
+ ["context-analyzer" /* ContextAnalyzer */]: 10,
671
+ ["naming-consistency" /* NamingConsistency */]: 10
672
+ },
673
+ ["logic" /* Logic */]: {
674
+ ["testability-index" /* TestabilityIndex */]: 40,
675
+ ["naming-consistency" /* NamingConsistency */]: 20,
676
+ ["context-analyzer" /* ContextAnalyzer */]: 20,
677
+ ["pattern-detect" /* PatternDetect */]: 10,
678
+ ["change-amplification" /* ChangeAmplification */]: 10
679
+ },
680
+ ["ui" /* UI */]: {
681
+ ["naming-consistency" /* NamingConsistency */]: 30,
682
+ ["context-analyzer" /* ContextAnalyzer */]: 30,
683
+ ["pattern-detect" /* PatternDetect */]: 20,
684
+ ["doc-drift" /* DocDrift */]: 10,
685
+ ["ai-signal-clarity" /* AiSignalClarity */]: 10
686
+ },
687
+ ["cost" /* Cost */]: {
688
+ ["pattern-detect" /* PatternDetect */]: 50,
689
+ ["context-analyzer" /* ContextAnalyzer */]: 30,
690
+ ["change-amplification" /* ChangeAmplification */]: 10,
691
+ ["dependency-health" /* DependencyHealth */]: 10
692
+ },
693
+ ["security" /* Security */]: {
694
+ ["naming-consistency" /* NamingConsistency */]: 30,
695
+ ["testability-index" /* TestabilityIndex */]: 25,
696
+ ["contract-enforcement" /* ContractEnforcement */]: 15,
697
+ ["dependency-health" /* DependencyHealth */]: 20,
698
+ ["context-analyzer" /* ContextAnalyzer */]: 10
699
+ }
700
+ };
701
+ var CONTEXT_TIER_THRESHOLDS = {
702
+ compact: { idealTokens: 3e3, criticalTokens: 1e4, idealDepth: 4 },
703
+ standard: { idealTokens: 5e3, criticalTokens: 15e3, idealDepth: 5 },
704
+ extended: { idealTokens: 15e3, criticalTokens: 5e4, idealDepth: 7 },
705
+ frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
706
+ };
707
+ var SIZE_ADJUSTED_THRESHOLDS = {
708
+ xs: SCORING_CONSTANTS.THRESHOLDS.XS,
709
+ // < 50 files
710
+ small: SCORING_CONSTANTS.THRESHOLDS.SMALL,
711
+ // 50-200 files
712
+ medium: SCORING_CONSTANTS.THRESHOLDS.MEDIUM,
713
+ // 200-500 files
714
+ large: SCORING_CONSTANTS.THRESHOLDS.LARGE,
715
+ // 500-2000 files
716
+ enterprise: SCORING_CONSTANTS.THRESHOLDS.ENTERPRISE
717
+ // 2000+ files
718
+ };
719
+ function getProjectSizeTier(fileCount) {
720
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.XS) return "xs";
721
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.SMALL) return "small";
722
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.MEDIUM) return "medium";
723
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.LARGE) return "large";
724
+ return "enterprise";
725
+ }
726
+ function getRecommendedThreshold(fileCount, modelTier = "standard") {
727
+ const sizeTier = getProjectSizeTier(fileCount);
728
+ const base = SIZE_ADJUSTED_THRESHOLDS[sizeTier];
729
+ const modelBonus = modelTier === "frontier" ? -3 : modelTier === "extended" ? -2 : 0;
730
+ return base + modelBonus;
731
+ }
732
+ function normalizeToolName(shortName) {
733
+ return TOOL_NAME_MAP[shortName.toLowerCase()] ?? shortName;
734
+ }
735
+ function getToolWeight(toolName, toolConfig, cliOverride, profile = "default" /* Default */) {
736
+ if (cliOverride !== void 0) return cliOverride;
737
+ if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
738
+ const profileWeights = SCORING_PROFILES[profile] ?? DEFAULT_TOOL_WEIGHTS;
739
+ return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
740
+ }
741
+ function parseWeightString(weightStr) {
742
+ const weights = /* @__PURE__ */ new Map();
743
+ if (!weightStr) return weights;
744
+ const pairs = weightStr.split(SCORING_CONSTANTS.DELIMITERS.LIST);
745
+ for (const pair of pairs) {
746
+ const [toolShortName, weightValueStr] = pair.split(
747
+ SCORING_CONSTANTS.DELIMITERS.PAIR
748
+ );
749
+ if (toolShortName && weightValueStr) {
750
+ const toolName = normalizeToolName(toolShortName.trim());
751
+ const weight = parseInt(weightValueStr.trim(), 10);
752
+ if (!isNaN(weight) && weight > 0) {
753
+ weights.set(toolName, weight);
754
+ }
755
+ }
756
+ }
757
+ return weights;
758
+ }
759
+ function calculateOverallScore(toolOutputs, config, cliWeights) {
760
+ if (toolOutputs.size === 0) {
761
+ throw new Error("No tool outputs provided for scoring");
762
+ }
763
+ const profile = config?.profile || "default" /* Default */;
764
+ const weights = /* @__PURE__ */ new Map();
765
+ for (const [toolName] of toolOutputs.entries()) {
766
+ const cliWeight = cliWeights?.get(toolName);
767
+ const configWeight = config?.tools?.[toolName]?.scoreWeight;
768
+ const weight = cliWeight ?? configWeight ?? getToolWeight(toolName, void 0, void 0, profile);
769
+ weights.set(toolName, weight);
770
+ }
771
+ let weightedSum = 0;
772
+ let totalWeight = 0;
773
+ const breakdown = [];
774
+ const toolsUsed = [];
775
+ const calculationWeights = {};
776
+ for (const [toolName, output] of toolOutputs.entries()) {
777
+ const weight = weights.get(toolName) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
778
+ weightedSum += output.score * weight;
779
+ totalWeight += weight;
780
+ toolsUsed.push(toolName);
781
+ calculationWeights[toolName] = weight;
782
+ breakdown.push(output);
783
+ }
784
+ const overall = Math.round(weightedSum / totalWeight);
785
+ const rating = getRating(overall);
786
+ const formulaParts = Array.from(toolOutputs.entries()).map(
787
+ ([name, output]) => {
788
+ const weight = weights.get(name) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
789
+ return `(${output.score} \xD7 ${weight})`;
790
+ }
791
+ );
792
+ const formulaStr = `[${formulaParts.join(SCORING_CONSTANTS.DELIMITERS.FORMULA_JOIN)}] / ${totalWeight} = ${overall}`;
793
+ return {
794
+ overall,
795
+ rating,
796
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
797
+ toolsUsed,
798
+ breakdown,
799
+ calculation: {
800
+ formula: formulaStr,
801
+ weights: calculationWeights,
802
+ normalized: formulaStr
803
+ }
804
+ };
805
+ }
806
+ function getRatingWithContext(score, fileCount, modelTier = "standard") {
807
+ const threshold = getRecommendedThreshold(fileCount, modelTier);
808
+ const normalized = score - threshold + SCORING_CONSTANTS.THRESHOLDS.NORMALIZATION_OFFSET;
809
+ return getRating(normalized);
810
+ }
811
+ function getRatingDisplay(rating) {
812
+ switch (rating) {
813
+ case "Excellent" /* Excellent */:
814
+ return { emoji: "\u2705", color: "green" };
815
+ case "Good" /* Good */:
816
+ return { emoji: "\u{1F44D}", color: "blue" };
817
+ case "Fair" /* Fair */:
818
+ return { emoji: "\u26A0\uFE0F", color: "yellow" };
819
+ case "Needs Work" /* NeedsWork */:
820
+ return { emoji: "\u{1F528}", color: "orange" };
821
+ case "Critical" /* Critical */:
822
+ return { emoji: "\u274C", color: "red" };
823
+ default:
824
+ return { emoji: "\u2753", color: "gray" };
825
+ }
826
+ }
827
+ function formatScore(result) {
828
+ const { emoji } = getRatingDisplay(result.rating);
829
+ return `${result.overall}/100 (${result.rating}) ${emoji}`;
830
+ }
831
+ function formatToolScore(output) {
832
+ let result = ` Score: ${output.score}/100
833
+
834
+ `;
835
+ if (output.factors && output.factors.length > 0) {
836
+ result += ` Factors:
837
+ `;
838
+ output.factors.forEach((factor) => {
839
+ const impactSign = factor.impact > 0 ? "+" : "";
840
+ result += ` \u2022 ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}
841
+ `;
842
+ });
843
+ result += "\n";
844
+ }
845
+ if (output.recommendations && output.recommendations.length > 0) {
846
+ result += ` Recommendations:
847
+ `;
848
+ output.recommendations.forEach((rec, i) => {
849
+ let priorityIcon = "\u{1F535}";
850
+ const prio = rec.priority;
851
+ if (prio === "high" /* High */ || prio === "high")
852
+ priorityIcon = "\u{1F534}";
853
+ else if (prio === "medium" /* Medium */ || prio === "medium")
854
+ priorityIcon = "\u{1F7E1}";
855
+ result += ` ${i + 1}. ${priorityIcon} ${rec.action}
856
+ `;
857
+ result += ` Impact: +${rec.estimatedImpact} points
858
+
859
+ `;
860
+ });
861
+ }
862
+ return result;
863
+ }
864
+
865
+ export {
866
+ Severity,
867
+ SeveritySchema,
868
+ ToolName,
869
+ ToolNameSchema,
870
+ FRIENDLY_TOOL_NAMES,
871
+ IssueType,
872
+ IssueTypeSchema,
873
+ AnalysisStatus,
874
+ AnalysisStatusSchema,
875
+ ModelTier,
876
+ ModelTierSchema,
877
+ LocationSchema,
878
+ IssueSchema,
879
+ MetricsSchema,
880
+ AnalysisResultSchema,
881
+ SpokeSummarySchema,
882
+ SpokeOutputSchema,
883
+ UnifiedReportSchema,
884
+ AIReadyConfigSchema,
885
+ LeadSource,
886
+ LeadSourceSchema,
887
+ LeadSchema,
888
+ LeadSubmissionSchema,
889
+ ManagedAccountSchema,
890
+ GLOBAL_INFRA_OPTIONS,
891
+ GLOBAL_SCAN_OPTIONS,
892
+ COMMON_FINE_TUNING_OPTIONS,
893
+ generateHTML,
894
+ ReadinessRating,
895
+ getRatingMetadata,
896
+ getRatingLabel,
897
+ getRatingSlug,
898
+ getRatingEmoji,
899
+ getToolEmoji,
900
+ getPriorityIcon,
901
+ getRating,
902
+ RecommendationPriority,
903
+ DEFAULT_TOOL_WEIGHTS,
904
+ TOOL_NAME_MAP,
905
+ ScoringProfile,
906
+ SCORING_PROFILES,
907
+ CONTEXT_TIER_THRESHOLDS,
908
+ SIZE_ADJUSTED_THRESHOLDS,
909
+ getProjectSizeTier,
910
+ getRecommendedThreshold,
911
+ normalizeToolName,
912
+ getToolWeight,
913
+ parseWeightString,
914
+ calculateOverallScore,
915
+ getRatingWithContext,
916
+ getRatingDisplay,
917
+ formatScore,
918
+ formatToolScore
919
+ };