@aiready/core 0.21.8 → 0.21.10

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.
@@ -0,0 +1,601 @@
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
+ }),
143
+ results: z.array(AnalysisResultSchema),
144
+ scoring: z.object({
145
+ overall: z.number(),
146
+ rating: z.string(),
147
+ timestamp: z.string(),
148
+ breakdown: z.array(
149
+ z.object({
150
+ toolName: z.union([ToolNameSchema, z.string()]),
151
+ score: z.number()
152
+ }).catchall(z.any())
153
+ )
154
+ }).optional()
155
+ }).catchall(z.any());
156
+
157
+ // src/types.ts
158
+ var GLOBAL_SCAN_OPTIONS = [
159
+ "rootDir",
160
+ "tools",
161
+ "toolConfigs",
162
+ "include",
163
+ "exclude",
164
+ "onProgress",
165
+ "progressCallback",
166
+ "includeTests",
167
+ "useSmartDefaults",
168
+ "maxDepth",
169
+ "streamResults",
170
+ "batchSize",
171
+ "costConfig"
172
+ ];
173
+
174
+ // src/types/language.ts
175
+ var Language = /* @__PURE__ */ ((Language2) => {
176
+ Language2["TypeScript"] = "typescript";
177
+ Language2["JavaScript"] = "javascript";
178
+ Language2["Python"] = "python";
179
+ Language2["Java"] = "java";
180
+ Language2["Go"] = "go";
181
+ Language2["Rust"] = "rust";
182
+ Language2["CSharp"] = "csharp";
183
+ return Language2;
184
+ })(Language || {});
185
+ var LANGUAGE_EXTENSIONS = {
186
+ ".ts": "typescript" /* TypeScript */,
187
+ ".tsx": "typescript" /* TypeScript */,
188
+ ".js": "javascript" /* JavaScript */,
189
+ ".jsx": "javascript" /* JavaScript */,
190
+ ".py": "python" /* Python */,
191
+ ".java": "java" /* Java */,
192
+ ".go": "go" /* Go */,
193
+ ".rs": "rust" /* Rust */,
194
+ ".cs": "csharp" /* CSharp */
195
+ };
196
+ var ParseError = class extends Error {
197
+ constructor(message, filePath, loc) {
198
+ super(message);
199
+ this.filePath = filePath;
200
+ this.loc = loc;
201
+ this.name = "ParseError";
202
+ }
203
+ };
204
+
205
+ // src/scoring.ts
206
+ var DEFAULT_TOOL_WEIGHTS = {
207
+ ["pattern-detect" /* PatternDetect */]: 22,
208
+ ["context-analyzer" /* ContextAnalyzer */]: 19,
209
+ ["naming-consistency" /* NamingConsistency */]: 14,
210
+ ["ai-signal-clarity" /* AiSignalClarity */]: 11,
211
+ ["agent-grounding" /* AgentGrounding */]: 10,
212
+ ["testability-index" /* TestabilityIndex */]: 10,
213
+ ["doc-drift" /* DocDrift */]: 8,
214
+ ["dependency-health" /* DependencyHealth */]: 6,
215
+ ["change-amplification" /* ChangeAmplification */]: 8
216
+ };
217
+ var TOOL_NAME_MAP = {
218
+ patterns: "pattern-detect" /* PatternDetect */,
219
+ "pattern-detect": "pattern-detect" /* PatternDetect */,
220
+ context: "context-analyzer" /* ContextAnalyzer */,
221
+ "context-analyzer": "context-analyzer" /* ContextAnalyzer */,
222
+ consistency: "naming-consistency" /* NamingConsistency */,
223
+ "naming-consistency": "naming-consistency" /* NamingConsistency */,
224
+ "ai-signal": "ai-signal-clarity" /* AiSignalClarity */,
225
+ "ai-signal-clarity": "ai-signal-clarity" /* AiSignalClarity */,
226
+ grounding: "agent-grounding" /* AgentGrounding */,
227
+ "agent-grounding": "agent-grounding" /* AgentGrounding */,
228
+ testability: "testability-index" /* TestabilityIndex */,
229
+ "testability-index": "testability-index" /* TestabilityIndex */,
230
+ "doc-drift": "doc-drift" /* DocDrift */,
231
+ "deps-health": "dependency-health" /* DependencyHealth */,
232
+ "dependency-health": "dependency-health" /* DependencyHealth */,
233
+ "change-amp": "change-amplification" /* ChangeAmplification */,
234
+ "change-amplification": "change-amplification" /* ChangeAmplification */
235
+ };
236
+ var CONTEXT_TIER_THRESHOLDS = {
237
+ compact: { idealTokens: 3e3, criticalTokens: 1e4, idealDepth: 4 },
238
+ standard: { idealTokens: 5e3, criticalTokens: 15e3, idealDepth: 5 },
239
+ extended: { idealTokens: 15e3, criticalTokens: 5e4, idealDepth: 7 },
240
+ frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
241
+ };
242
+ var SIZE_ADJUSTED_THRESHOLDS = {
243
+ xs: 80,
244
+ // < 50 files
245
+ small: 75,
246
+ // 50-200 files
247
+ medium: 70,
248
+ // 200-500 files
249
+ large: 65,
250
+ // 500-2000 files
251
+ enterprise: 58
252
+ // 2000+ files
253
+ };
254
+ function getProjectSizeTier(fileCount) {
255
+ if (fileCount < 50) return "xs";
256
+ if (fileCount < 200) return "small";
257
+ if (fileCount < 500) return "medium";
258
+ if (fileCount < 2e3) return "large";
259
+ return "enterprise";
260
+ }
261
+ function getRecommendedThreshold(fileCount, modelTier = "standard") {
262
+ const sizeTier = getProjectSizeTier(fileCount);
263
+ const base = SIZE_ADJUSTED_THRESHOLDS[sizeTier];
264
+ const modelBonus = modelTier === "frontier" ? -3 : modelTier === "extended" ? -2 : 0;
265
+ return base + modelBonus;
266
+ }
267
+ function normalizeToolName(shortName) {
268
+ return TOOL_NAME_MAP[shortName.toLowerCase()] || shortName;
269
+ }
270
+ function getToolWeight(toolName, toolConfig, cliOverride) {
271
+ if (cliOverride !== void 0) return cliOverride;
272
+ if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
273
+ return DEFAULT_TOOL_WEIGHTS[toolName] || 5;
274
+ }
275
+ function parseWeightString(weightStr) {
276
+ const weights = /* @__PURE__ */ new Map();
277
+ if (!weightStr) return weights;
278
+ const pairs = weightStr.split(",");
279
+ for (const pair of pairs) {
280
+ const [toolShortName, weightStr2] = pair.split(":");
281
+ if (toolShortName && weightStr2) {
282
+ const toolName = normalizeToolName(toolShortName.trim());
283
+ const weight = parseInt(weightStr2.trim(), 10);
284
+ if (!isNaN(weight) && weight > 0) {
285
+ weights.set(toolName, weight);
286
+ }
287
+ }
288
+ }
289
+ return weights;
290
+ }
291
+ function calculateOverallScore(toolOutputs, config, cliWeights) {
292
+ if (toolOutputs.size === 0) {
293
+ throw new Error("No tool outputs provided for scoring");
294
+ }
295
+ const weights = /* @__PURE__ */ new Map();
296
+ for (const [toolName] of toolOutputs.entries()) {
297
+ const cliWeight = cliWeights?.get(toolName);
298
+ const configWeight = config?.tools?.[toolName]?.scoreWeight;
299
+ const weight = cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 5;
300
+ weights.set(toolName, weight);
301
+ }
302
+ let weightedSum = 0;
303
+ let totalWeight = 0;
304
+ const breakdown = [];
305
+ const toolsUsed = [];
306
+ const calculationWeights = {};
307
+ for (const [toolName, output] of toolOutputs.entries()) {
308
+ const weight = weights.get(toolName) || 5;
309
+ weightedSum += output.score * weight;
310
+ totalWeight += weight;
311
+ toolsUsed.push(toolName);
312
+ calculationWeights[toolName] = weight;
313
+ breakdown.push(output);
314
+ }
315
+ const overall = Math.round(weightedSum / totalWeight);
316
+ const rating = getRating(overall);
317
+ const formulaParts = Array.from(toolOutputs.entries()).map(
318
+ ([name, output]) => {
319
+ const w = weights.get(name) || 5;
320
+ return `(${output.score} \xD7 ${w})`;
321
+ }
322
+ );
323
+ const formulaStr = `[${formulaParts.join(" + ")}] / ${totalWeight} = ${overall}`;
324
+ return {
325
+ overall,
326
+ rating,
327
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
328
+ toolsUsed,
329
+ breakdown,
330
+ calculation: {
331
+ formula: formulaStr,
332
+ weights: calculationWeights,
333
+ normalized: formulaStr
334
+ }
335
+ };
336
+ }
337
+ function getRating(score) {
338
+ if (score >= 90) return "Excellent";
339
+ if (score >= 75) return "Good";
340
+ if (score >= 60) return "Fair";
341
+ if (score >= 40) return "Needs Work";
342
+ return "Critical";
343
+ }
344
+ function getRatingWithContext(score, fileCount, modelTier = "standard") {
345
+ const threshold = getRecommendedThreshold(fileCount, modelTier);
346
+ const normalized = score - threshold + 70;
347
+ return getRating(normalized);
348
+ }
349
+ function getRatingDisplay(rating) {
350
+ switch (rating) {
351
+ case "Excellent":
352
+ return { emoji: "\u2705", color: "green" };
353
+ case "Good":
354
+ return { emoji: "\u{1F44D}", color: "blue" };
355
+ case "Fair":
356
+ return { emoji: "\u26A0\uFE0F", color: "yellow" };
357
+ case "Needs Work":
358
+ return { emoji: "\u{1F528}", color: "orange" };
359
+ case "Critical":
360
+ return { emoji: "\u274C", color: "red" };
361
+ }
362
+ }
363
+ function formatScore(result) {
364
+ const { emoji } = getRatingDisplay(result.rating);
365
+ return `${result.overall}/100 (${result.rating}) ${emoji}`;
366
+ }
367
+ function formatToolScore(output) {
368
+ let result = ` Score: ${output.score}/100
369
+
370
+ `;
371
+ if (output.factors && output.factors.length > 0) {
372
+ result += ` Factors:
373
+ `;
374
+ output.factors.forEach((factor) => {
375
+ const impactSign = factor.impact > 0 ? "+" : "";
376
+ result += ` \u2022 ${factor.name}: ${impactSign}${factor.impact} - ${factor.description}
377
+ `;
378
+ });
379
+ result += "\n";
380
+ }
381
+ if (output.recommendations && output.recommendations.length > 0) {
382
+ result += ` Recommendations:
383
+ `;
384
+ output.recommendations.forEach((rec, i) => {
385
+ const priorityIcon = rec.priority === "high" ? "\u{1F534}" : rec.priority === "medium" ? "\u{1F7E1}" : "\u{1F535}";
386
+ result += ` ${i + 1}. ${priorityIcon} ${rec.action}
387
+ `;
388
+ result += ` Impact: +${rec.estimatedImpact} points
389
+
390
+ `;
391
+ });
392
+ }
393
+ return result;
394
+ }
395
+
396
+ // src/utils/visualization.ts
397
+ function generateHTML(graph) {
398
+ const payload = JSON.stringify(graph, null, 2);
399
+ return `<!doctype html>
400
+ <html>
401
+ <head>
402
+ <meta charset="utf-8" />
403
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
404
+ <title>AIReady Visualization</title>
405
+ <style>
406
+ html,body { height: 100%; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f172a; color: #e2e8f0 }
407
+ #container { display:flex; height:100vh }
408
+ #panel { width: 320px; padding: 16px; background: #071130; box-shadow: -2px 0 8px rgba(0,0,0,0.3); overflow:auto }
409
+ #canvasWrap { flex:1; display:flex; align-items:center; justify-content:center }
410
+ canvas { background: #0b1220; border-radius:8px }
411
+ .stat { margin-bottom:12px }
412
+ </style>
413
+ </head>
414
+ <body>
415
+ <div id="container">
416
+ <div id="canvasWrap"><canvas id="canvas" width="1200" height="800"></canvas></div>
417
+ <div id="panel">
418
+ <h2>AIReady Visualization</h2>
419
+ <div class="stat"><strong>Files:</strong> <span id="stat-files"></span></div>
420
+ <div class="stat"><strong>Dependencies:</strong> <span id="stat-deps"></span></div>
421
+ <div class="stat"><strong>Legend</strong></div>
422
+ <div style="font-size:13px;line-height:1.3;color:#cbd5e1;margin-top:8px">
423
+ <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>
424
+ <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>
425
+ <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>
426
+ <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>
427
+ <div style="margin-top:10px;color:#94a3b8"><strong>Node size</strong>: larger = higher token cost, more issues or dependency weight.</div>
428
+ <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>
429
+ <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>
430
+ </div>
431
+ </div>
432
+ </div>
433
+
434
+ <script>
435
+ const graphData = ${payload};
436
+ document.getElementById('stat-files').textContent = graphData.metadata.totalFiles;
437
+ document.getElementById('stat-deps').textContent = graphData.metadata.totalDependencies;
438
+
439
+ const canvas = document.getElementById('canvas');
440
+ const ctx = canvas.getContext('2d');
441
+
442
+ const nodes = graphData.nodes.map((n, i) => ({
443
+ ...n,
444
+ x: canvas.width / 2 + Math.cos(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
445
+ y: canvas.height / 2 + Math.sin(i / graphData.nodes.length * Math.PI * 2) * (Math.min(canvas.width, canvas.height) / 3),
446
+ }));
447
+
448
+ function draw() {
449
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
450
+
451
+ graphData.edges.forEach(edge => {
452
+ const s = nodes.find(n => n.id === edge.source);
453
+ const t = nodes.find(n => n.id === edge.target);
454
+ if (!s || !t) return;
455
+ if (edge.type === 'related') return;
456
+ if (edge.type === 'similarity') {
457
+ ctx.strokeStyle = '#fb7e81';
458
+ ctx.lineWidth = 1.2;
459
+ } else if (edge.type === 'dependency') {
460
+ ctx.strokeStyle = '#84c1ff';
461
+ ctx.lineWidth = 1.0;
462
+ } else if (edge.type === 'reference') {
463
+ ctx.strokeStyle = '#ffa500';
464
+ ctx.lineWidth = 0.9;
465
+ } else {
466
+ ctx.strokeStyle = '#334155';
467
+ ctx.lineWidth = 0.8;
468
+ }
469
+ ctx.beginPath();
470
+ ctx.moveTo(s.x, s.y);
471
+ ctx.lineTo(t.x, t.y);
472
+ ctx.stroke();
473
+ });
474
+
475
+ const groups = {};
476
+ nodes.forEach(n => {
477
+ const g = n.group || '__default';
478
+ if (!groups[g]) groups[g] = { minX: n.x, minY: n.y, maxX: n.x, maxY: n.y };
479
+ groups[g].minX = Math.min(groups[g].minX, n.x);
480
+ groups[g].minY = Math.min(groups[g].minY, n.y);
481
+ groups[g].maxX = Math.max(groups[g].maxX, n.x);
482
+ groups[g].maxY = Math.max(groups[g].maxY, n.y);
483
+ });
484
+
485
+ const groupRelations = {};
486
+ graphData.edges.forEach(edge => {
487
+ const sNode = nodes.find(n => n.id === edge.source);
488
+ const tNode = nodes.find(n => n.id === edge.target);
489
+ if (!sNode || !tNode) return;
490
+ const g1 = sNode.group || '__default';
491
+ const g2 = tNode.group || '__default';
492
+ if (g1 === g2) return;
493
+ const key = g1 < g2 ? g1 + '::' + g2 : g2 + '::' + g1;
494
+ groupRelations[key] = (groupRelations[key] || 0) + 1;
495
+ });
496
+
497
+ Object.keys(groupRelations).forEach(k => {
498
+ const count = groupRelations[k];
499
+ const [ga, gb] = k.split('::');
500
+ if (!groups[ga] || !groups[gb]) return;
501
+ const ax = (groups[ga].minX + groups[ga].maxX) / 2;
502
+ const ay = (groups[ga].minY + groups[ga].maxY) / 2;
503
+ const bx = (groups[gb].minX + groups[gb].maxX) / 2;
504
+ const by = (groups[gb].minY + groups[gb].maxY) / 2;
505
+ ctx.beginPath();
506
+ ctx.strokeStyle = 'rgba(148,163,184,0.25)';
507
+ ctx.lineWidth = Math.min(6, 0.6 + Math.sqrt(count));
508
+ ctx.moveTo(ax, ay);
509
+ ctx.lineTo(bx, by);
510
+ ctx.stroke();
511
+ });
512
+
513
+ Object.keys(groups).forEach(g => {
514
+ if (g === '__default') return;
515
+ const box = groups[g];
516
+ const pad = 16;
517
+ const x = box.minX - pad;
518
+ const y = box.minY - pad;
519
+ const w = (box.maxX - box.minX) + pad * 2;
520
+ const h = (box.maxY - box.minY) + pad * 2;
521
+ ctx.save();
522
+ ctx.fillStyle = 'rgba(30,64,175,0.04)';
523
+ ctx.strokeStyle = 'rgba(30,64,175,0.12)';
524
+ ctx.lineWidth = 1.2;
525
+ const r = 8;
526
+ ctx.beginPath();
527
+ ctx.moveTo(x + r, y);
528
+ ctx.arcTo(x + w, y, x + w, y + h, r);
529
+ ctx.arcTo(x + w, y + h, x, y + h, r);
530
+ ctx.arcTo(x, y + h, x, y, r);
531
+ ctx.arcTo(x, y, x + w, y, r);
532
+ ctx.closePath();
533
+ ctx.fill();
534
+ ctx.stroke();
535
+ ctx.restore();
536
+ ctx.fillStyle = '#94a3b8';
537
+ ctx.font = '11px sans-serif';
538
+ ctx.fillText(g, x + 8, y + 14);
539
+ });
540
+
541
+ nodes.forEach(n => {
542
+ const sizeVal = (n.size || n.value || 1);
543
+ const r = 6 + (sizeVal / 2);
544
+ ctx.beginPath();
545
+ ctx.fillStyle = n.color || '#60a5fa';
546
+ ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
547
+ ctx.fill();
548
+
549
+ ctx.fillStyle = '#e2e8f0';
550
+ ctx.font = '11px sans-serif';
551
+ ctx.textAlign = 'center';
552
+ ctx.fillText(n.label || n.id.split('/').slice(-1)[0], n.x, n.y + r + 12);
553
+ });
554
+ }
555
+
556
+ draw();
557
+ </script>
558
+ </body>
559
+ </html>`;
560
+ }
561
+
562
+ export {
563
+ Severity,
564
+ SeveritySchema,
565
+ ToolName,
566
+ ToolNameSchema,
567
+ FRIENDLY_TOOL_NAMES,
568
+ IssueType,
569
+ IssueTypeSchema,
570
+ AnalysisStatus,
571
+ AnalysisStatusSchema,
572
+ ModelTier,
573
+ ModelTierSchema,
574
+ LocationSchema,
575
+ IssueSchema,
576
+ MetricsSchema,
577
+ AnalysisResultSchema,
578
+ SpokeSummarySchema,
579
+ SpokeOutputSchema,
580
+ UnifiedReportSchema,
581
+ GLOBAL_SCAN_OPTIONS,
582
+ Language,
583
+ LANGUAGE_EXTENSIONS,
584
+ ParseError,
585
+ DEFAULT_TOOL_WEIGHTS,
586
+ TOOL_NAME_MAP,
587
+ CONTEXT_TIER_THRESHOLDS,
588
+ SIZE_ADJUSTED_THRESHOLDS,
589
+ getProjectSizeTier,
590
+ getRecommendedThreshold,
591
+ normalizeToolName,
592
+ getToolWeight,
593
+ parseWeightString,
594
+ calculateOverallScore,
595
+ getRating,
596
+ getRatingWithContext,
597
+ getRatingDisplay,
598
+ formatScore,
599
+ formatToolScore,
600
+ generateHTML
601
+ };
package/dist/client.d.mts CHANGED
@@ -222,6 +222,7 @@ declare const SpokeOutputSchema: z.ZodObject<{
222
222
  toolName: z.ZodString;
223
223
  version: z.ZodOptional<z.ZodString>;
224
224
  timestamp: z.ZodOptional<z.ZodString>;
225
+ config: z.ZodOptional<z.ZodAny>;
225
226
  }, z.core.$catchall<z.ZodAny>>>;
226
227
  }, z.core.$strip>;
227
228
  type SpokeOutput = z.infer<typeof SpokeOutputSchema>;
@@ -431,6 +432,10 @@ interface ScanOptions {
431
432
  onProgress?: (processed: number, total: number, message: string) => void;
432
433
  includeTests?: boolean;
433
434
  }
435
+ /**
436
+ * Global options that should not be repeated in tool-specific audit logs
437
+ */
438
+ declare const GLOBAL_SCAN_OPTIONS: string[];
434
439
  interface AIReadyConfig {
435
440
  scan?: {
436
441
  include?: string[];
@@ -464,13 +469,52 @@ interface AIReadyConfig {
464
469
  domainPatterns?: string[];
465
470
  pathDomainMap?: Record<string, string>;
466
471
  };
467
- consistency?: {
472
+ [ToolName.NamingConsistency]?: {
468
473
  enabled?: boolean;
469
474
  scoreWeight?: number;
470
475
  acceptedAbbreviations?: string[];
471
476
  shortWords?: string[];
472
477
  disableChecks?: ('single-letter' | 'abbreviation' | 'convention-mix' | 'unclear' | 'poor-naming')[];
473
478
  };
479
+ [ToolName.AiSignalClarity]?: {
480
+ enabled?: boolean;
481
+ scoreWeight?: number;
482
+ checkMagicLiterals?: boolean;
483
+ checkBooleanTraps?: boolean;
484
+ checkAmbiguousNames?: boolean;
485
+ checkUndocumentedExports?: boolean;
486
+ checkImplicitSideEffects?: boolean;
487
+ checkDeepCallbacks?: boolean;
488
+ minSeverity?: string;
489
+ };
490
+ [ToolName.AgentGrounding]?: {
491
+ enabled?: boolean;
492
+ scoreWeight?: number;
493
+ maxRecommendedDepth?: number;
494
+ readmeStaleDays?: number;
495
+ additionalVagueNames?: string[];
496
+ };
497
+ [ToolName.TestabilityIndex]?: {
498
+ enabled?: boolean;
499
+ scoreWeight?: number;
500
+ minCoverageRatio?: number;
501
+ testPatterns?: string[];
502
+ };
503
+ [ToolName.DocDrift]?: {
504
+ enabled?: boolean;
505
+ scoreWeight?: number;
506
+ maxCommits?: number;
507
+ staleMonths?: number;
508
+ };
509
+ [ToolName.DependencyHealth]?: {
510
+ enabled?: boolean;
511
+ scoreWeight?: number;
512
+ trainingCutoffYear?: number;
513
+ };
514
+ [ToolName.ChangeAmplification]?: {
515
+ enabled?: boolean;
516
+ scoreWeight?: number;
517
+ };
474
518
  [toolName: string]: {
475
519
  enabled?: boolean;
476
520
  scoreWeight?: number;
@@ -879,4 +923,4 @@ declare function formatToolScore(output: ToolScoringOutput): string;
879
923
  */
880
924
  declare function generateHTML(graph: GraphData): string;
881
925
 
882
- export { type AIReadyConfig, type AcceptancePrediction, type AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, type BusinessReport, CONTEXT_TIER_THRESHOLDS, type CommonASTNode, type ComprehensionDifficulty, type CostConfig, DEFAULT_TOOL_WEIGHTS, type ExportInfo, FRIENDLY_TOOL_NAMES, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, LocationSchema, type Metrics, MetricsSchema, type ModelContextTier, ModelTier, ModelTierSchema, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type ProductivityImpact, type Report, SIZE_ADJUSTED_THRESHOLDS, type ScanOptions, type ScoringConfig, type ScoringResult, Severity, SeveritySchema, type SourceLocation, type SourceRange, type SpokeOutput, SpokeOutputSchema, type SpokeSummary, SpokeSummarySchema, TOOL_NAME_MAP, type TechnicalValueChain, type TechnicalValueChainSummary, type TokenBudget, ToolName, ToolNameSchema, type ToolScoringOutput, type UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString };
926
+ export { type AIReadyConfig, type AcceptancePrediction, type AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, type BusinessReport, CONTEXT_TIER_THRESHOLDS, type CommonASTNode, type ComprehensionDifficulty, type CostConfig, DEFAULT_TOOL_WEIGHTS, type ExportInfo, FRIENDLY_TOOL_NAMES, GLOBAL_SCAN_OPTIONS, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, LocationSchema, type Metrics, MetricsSchema, type ModelContextTier, ModelTier, ModelTierSchema, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type ProductivityImpact, type Report, SIZE_ADJUSTED_THRESHOLDS, type ScanOptions, type ScoringConfig, type ScoringResult, Severity, SeveritySchema, type SourceLocation, type SourceRange, type SpokeOutput, SpokeOutputSchema, type SpokeSummary, SpokeSummarySchema, TOOL_NAME_MAP, type TechnicalValueChain, type TechnicalValueChainSummary, type TokenBudget, ToolName, ToolNameSchema, type ToolScoringOutput, type UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString };