@aiready/core 0.19.2 → 0.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -20,13 +20,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/client.ts
21
21
  var client_exports = {};
22
22
  __export(client_exports, {
23
+ AnalysisResultSchema: () => AnalysisResultSchema,
24
+ AnalysisStatus: () => AnalysisStatus,
25
+ AnalysisStatusSchema: () => AnalysisStatusSchema,
23
26
  CONTEXT_TIER_THRESHOLDS: () => CONTEXT_TIER_THRESHOLDS,
24
27
  DEFAULT_TOOL_WEIGHTS: () => DEFAULT_TOOL_WEIGHTS,
28
+ FRIENDLY_TOOL_NAMES: () => FRIENDLY_TOOL_NAMES,
29
+ IssueSchema: () => IssueSchema,
30
+ IssueType: () => IssueType,
31
+ IssueTypeSchema: () => IssueTypeSchema,
25
32
  LANGUAGE_EXTENSIONS: () => LANGUAGE_EXTENSIONS,
26
33
  Language: () => Language,
34
+ LocationSchema: () => LocationSchema,
35
+ MetricsSchema: () => MetricsSchema,
36
+ ModelTier: () => ModelTier,
37
+ ModelTierSchema: () => ModelTierSchema,
27
38
  ParseError: () => ParseError,
28
39
  SIZE_ADJUSTED_THRESHOLDS: () => SIZE_ADJUSTED_THRESHOLDS,
40
+ Severity: () => Severity,
41
+ SeveritySchema: () => SeveritySchema,
42
+ SpokeOutputSchema: () => SpokeOutputSchema,
29
43
  TOOL_NAME_MAP: () => TOOL_NAME_MAP,
44
+ ToolName: () => ToolName,
45
+ ToolNameSchema: () => ToolNameSchema,
46
+ UnifiedReportSchema: () => UnifiedReportSchema,
30
47
  calculateOverallScore: () => calculateOverallScore,
31
48
  formatScore: () => formatScore,
32
49
  formatToolScore: () => formatToolScore,
@@ -42,6 +59,154 @@ __export(client_exports, {
42
59
  });
43
60
  module.exports = __toCommonJS(client_exports);
44
61
 
62
+ // src/types/schema.ts
63
+ var import_zod = require("zod");
64
+ var Severity = /* @__PURE__ */ ((Severity2) => {
65
+ Severity2["Critical"] = "critical";
66
+ Severity2["Major"] = "major";
67
+ Severity2["Minor"] = "minor";
68
+ Severity2["Info"] = "info";
69
+ return Severity2;
70
+ })(Severity || {});
71
+ var SeveritySchema = import_zod.z.nativeEnum(Severity);
72
+ var ToolName = /* @__PURE__ */ ((ToolName2) => {
73
+ ToolName2["PatternDetect"] = "pattern-detect";
74
+ ToolName2["ContextAnalyzer"] = "context-analyzer";
75
+ ToolName2["NamingConsistency"] = "naming-consistency";
76
+ ToolName2["AiSignalClarity"] = "ai-signal-clarity";
77
+ ToolName2["AgentGrounding"] = "agent-grounding";
78
+ ToolName2["TestabilityIndex"] = "testability-index";
79
+ ToolName2["DocDrift"] = "doc-drift";
80
+ ToolName2["DependencyHealth"] = "dependency-health";
81
+ ToolName2["ChangeAmplification"] = "change-amplification";
82
+ ToolName2["CognitiveLoad"] = "cognitive-load";
83
+ ToolName2["PatternEntropy"] = "pattern-entropy";
84
+ ToolName2["ConceptCohesion"] = "concept-cohesion";
85
+ ToolName2["SemanticDistance"] = "semantic-distance";
86
+ return ToolName2;
87
+ })(ToolName || {});
88
+ var ToolNameSchema = import_zod.z.nativeEnum(ToolName);
89
+ var FRIENDLY_TOOL_NAMES = {
90
+ ["pattern-detect" /* PatternDetect */]: "Semantic Duplicates",
91
+ ["context-analyzer" /* ContextAnalyzer */]: "Context Fragmentation",
92
+ ["naming-consistency" /* NamingConsistency */]: "Naming Consistency",
93
+ ["ai-signal-clarity" /* AiSignalClarity */]: "AI Signal Clarity",
94
+ ["agent-grounding" /* AgentGrounding */]: "Agent Grounding",
95
+ ["testability-index" /* TestabilityIndex */]: "Testability Index",
96
+ ["doc-drift" /* DocDrift */]: "Documentation Health",
97
+ ["dependency-health" /* DependencyHealth */]: "Dependency Health",
98
+ ["change-amplification" /* ChangeAmplification */]: "Change Amplification",
99
+ ["cognitive-load" /* CognitiveLoad */]: "Cognitive Load",
100
+ ["pattern-entropy" /* PatternEntropy */]: "Pattern Entropy",
101
+ ["concept-cohesion" /* ConceptCohesion */]: "Concept Cohesion",
102
+ ["semantic-distance" /* SemanticDistance */]: "Semantic Distance"
103
+ };
104
+ var IssueType = /* @__PURE__ */ ((IssueType2) => {
105
+ IssueType2["DuplicatePattern"] = "duplicate-pattern";
106
+ IssueType2["PatternInconsistency"] = "pattern-inconsistency";
107
+ IssueType2["ContextFragmentation"] = "context-fragmentation";
108
+ IssueType2["DependencyHealth"] = "dependency-health";
109
+ IssueType2["CircularDependency"] = "circular-dependency";
110
+ IssueType2["DocDrift"] = "doc-drift";
111
+ IssueType2["NamingInconsistency"] = "naming-inconsistency";
112
+ IssueType2["NamingQuality"] = "naming-quality";
113
+ IssueType2["ArchitectureInconsistency"] = "architecture-inconsistency";
114
+ IssueType2["DeadCode"] = "dead-code";
115
+ IssueType2["MissingTypes"] = "missing-types";
116
+ IssueType2["MagicLiteral"] = "magic-literal";
117
+ IssueType2["BooleanTrap"] = "boolean-trap";
118
+ IssueType2["AiSignalClarity"] = "ai-signal-clarity";
119
+ IssueType2["LowTestability"] = "low-testability";
120
+ IssueType2["AgentNavigationFailure"] = "agent-navigation-failure";
121
+ IssueType2["AmbiguousApi"] = "ambiguous-api";
122
+ IssueType2["ChangeAmplification"] = "change-amplification";
123
+ return IssueType2;
124
+ })(IssueType || {});
125
+ var IssueTypeSchema = import_zod.z.nativeEnum(IssueType);
126
+ var AnalysisStatus = /* @__PURE__ */ ((AnalysisStatus2) => {
127
+ AnalysisStatus2["Processing"] = "processing";
128
+ AnalysisStatus2["Completed"] = "completed";
129
+ AnalysisStatus2["Failed"] = "failed";
130
+ return AnalysisStatus2;
131
+ })(AnalysisStatus || {});
132
+ var AnalysisStatusSchema = import_zod.z.nativeEnum(AnalysisStatus);
133
+ var ModelTier = /* @__PURE__ */ ((ModelTier2) => {
134
+ ModelTier2["Compact"] = "compact";
135
+ ModelTier2["Standard"] = "standard";
136
+ ModelTier2["Extended"] = "extended";
137
+ ModelTier2["Frontier"] = "frontier";
138
+ return ModelTier2;
139
+ })(ModelTier || {});
140
+ var ModelTierSchema = import_zod.z.nativeEnum(ModelTier);
141
+ var LocationSchema = import_zod.z.object({
142
+ file: import_zod.z.string(),
143
+ line: import_zod.z.number(),
144
+ column: import_zod.z.number().optional(),
145
+ endLine: import_zod.z.number().optional(),
146
+ endColumn: import_zod.z.number().optional()
147
+ });
148
+ var IssueSchema = import_zod.z.object({
149
+ type: IssueTypeSchema,
150
+ severity: SeveritySchema,
151
+ message: import_zod.z.string(),
152
+ location: LocationSchema,
153
+ suggestion: import_zod.z.string().optional()
154
+ });
155
+ var MetricsSchema = import_zod.z.object({
156
+ tokenCost: import_zod.z.number().optional(),
157
+ complexityScore: import_zod.z.number().optional(),
158
+ consistencyScore: import_zod.z.number().optional(),
159
+ docFreshnessScore: import_zod.z.number().optional(),
160
+ // AI agent readiness metrics (v0.12+)
161
+ aiSignalClarityScore: import_zod.z.number().optional(),
162
+ agentGroundingScore: import_zod.z.number().optional(),
163
+ testabilityScore: import_zod.z.number().optional(),
164
+ docDriftScore: import_zod.z.number().optional(),
165
+ dependencyHealthScore: import_zod.z.number().optional(),
166
+ modelContextTier: ModelTierSchema.optional(),
167
+ // Business value metrics
168
+ estimatedMonthlyCost: import_zod.z.number().optional(),
169
+ estimatedDeveloperHours: import_zod.z.number().optional(),
170
+ comprehensionDifficultyIndex: import_zod.z.number().optional(),
171
+ // Extended metrics for specific spokes
172
+ totalSymbols: import_zod.z.number().optional(),
173
+ totalExports: import_zod.z.number().optional()
174
+ });
175
+ var AnalysisResultSchema = import_zod.z.object({
176
+ fileName: import_zod.z.string(),
177
+ issues: import_zod.z.array(IssueSchema),
178
+ metrics: MetricsSchema
179
+ });
180
+ var SpokeOutputSchema = import_zod.z.object({
181
+ results: import_zod.z.array(AnalysisResultSchema),
182
+ summary: import_zod.z.any(),
183
+ metadata: import_zod.z.object({
184
+ toolName: import_zod.z.string(),
185
+ version: import_zod.z.string(),
186
+ timestamp: import_zod.z.string()
187
+ }).catchall(import_zod.z.any()).optional()
188
+ });
189
+ var UnifiedReportSchema = import_zod.z.object({
190
+ summary: import_zod.z.object({
191
+ totalFiles: import_zod.z.number(),
192
+ totalIssues: import_zod.z.number(),
193
+ criticalIssues: import_zod.z.number(),
194
+ majorIssues: import_zod.z.number()
195
+ }),
196
+ results: import_zod.z.array(AnalysisResultSchema),
197
+ scoring: import_zod.z.object({
198
+ overall: import_zod.z.number(),
199
+ rating: import_zod.z.string(),
200
+ timestamp: import_zod.z.string(),
201
+ breakdown: import_zod.z.array(
202
+ import_zod.z.object({
203
+ toolName: import_zod.z.union([ToolNameSchema, import_zod.z.string()]),
204
+ score: import_zod.z.number()
205
+ }).catchall(import_zod.z.any())
206
+ )
207
+ }).optional()
208
+ }).catchall(import_zod.z.any());
209
+
45
210
  // src/types/language.ts
46
211
  var Language = /* @__PURE__ */ ((Language2) => {
47
212
  Language2["TypeScript"] = "typescript";
@@ -75,28 +240,34 @@ var ParseError = class extends Error {
75
240
 
76
241
  // src/scoring.ts
77
242
  var DEFAULT_TOOL_WEIGHTS = {
78
- "pattern-detect": 22,
79
- "context-analyzer": 19,
80
- consistency: 14,
81
- "ai-signal-clarity": 11,
82
- "agent-grounding": 10,
83
- testability: 10,
84
- "doc-drift": 8,
85
- deps: 6
243
+ ["pattern-detect" /* PatternDetect */]: 22,
244
+ ["context-analyzer" /* ContextAnalyzer */]: 19,
245
+ ["naming-consistency" /* NamingConsistency */]: 14,
246
+ ["ai-signal-clarity" /* AiSignalClarity */]: 11,
247
+ ["agent-grounding" /* AgentGrounding */]: 10,
248
+ ["testability-index" /* TestabilityIndex */]: 10,
249
+ ["doc-drift" /* DocDrift */]: 8,
250
+ ["dependency-health" /* DependencyHealth */]: 6,
251
+ ["change-amplification" /* ChangeAmplification */]: 8
86
252
  };
87
253
  var TOOL_NAME_MAP = {
88
- patterns: "pattern-detect",
89
- context: "context-analyzer",
90
- consistency: "consistency",
91
- "AI signal clarity": "ai-signal-clarity",
92
- "ai-signal-clarity": "ai-signal-clarity",
93
- grounding: "agent-grounding",
94
- "agent-grounding": "agent-grounding",
95
- testability: "testability",
96
- tests: "testability",
97
- "doc-drift": "doc-drift",
98
- docs: "doc-drift",
99
- deps: "deps"
254
+ patterns: "pattern-detect" /* PatternDetect */,
255
+ "pattern-detect": "pattern-detect" /* PatternDetect */,
256
+ context: "context-analyzer" /* ContextAnalyzer */,
257
+ "context-analyzer": "context-analyzer" /* ContextAnalyzer */,
258
+ consistency: "naming-consistency" /* NamingConsistency */,
259
+ "naming-consistency": "naming-consistency" /* NamingConsistency */,
260
+ "ai-signal": "ai-signal-clarity" /* AiSignalClarity */,
261
+ "ai-signal-clarity": "ai-signal-clarity" /* AiSignalClarity */,
262
+ grounding: "agent-grounding" /* AgentGrounding */,
263
+ "agent-grounding": "agent-grounding" /* AgentGrounding */,
264
+ testability: "testability-index" /* TestabilityIndex */,
265
+ "testability-index": "testability-index" /* TestabilityIndex */,
266
+ "doc-drift": "doc-drift" /* DocDrift */,
267
+ "deps-health": "dependency-health" /* DependencyHealth */,
268
+ "dependency-health": "dependency-health" /* DependencyHealth */,
269
+ "change-amp": "change-amplification" /* ChangeAmplification */,
270
+ "change-amplification": "change-amplification" /* ChangeAmplification */
100
271
  };
101
272
  var CONTEXT_TIER_THRESHOLDS = {
102
273
  compact: { idealTokens: 3e3, criticalTokens: 1e4, idealDepth: 4 },
@@ -130,22 +301,16 @@ function getRecommendedThreshold(fileCount, modelTier = "standard") {
130
301
  return base + modelBonus;
131
302
  }
132
303
  function normalizeToolName(shortName) {
133
- return TOOL_NAME_MAP[shortName] || shortName;
304
+ return TOOL_NAME_MAP[shortName.toLowerCase()] || shortName;
134
305
  }
135
306
  function getToolWeight(toolName, toolConfig, cliOverride) {
136
- if (cliOverride !== void 0) {
137
- return cliOverride;
138
- }
139
- if (toolConfig?.scoreWeight !== void 0) {
140
- return toolConfig.scoreWeight;
141
- }
307
+ if (cliOverride !== void 0) return cliOverride;
308
+ if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
142
309
  return DEFAULT_TOOL_WEIGHTS[toolName] || 5;
143
310
  }
144
311
  function parseWeightString(weightStr) {
145
312
  const weights = /* @__PURE__ */ new Map();
146
- if (!weightStr) {
147
- return weights;
148
- }
313
+ if (!weightStr) return weights;
149
314
  const pairs = weightStr.split(",");
150
315
  for (const pair of pairs) {
151
316
  const [toolShortName, weightStr2] = pair.split(":");
@@ -177,8 +342,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
177
342
  const calculationWeights = {};
178
343
  for (const [toolName, output] of toolOutputs.entries()) {
179
344
  const weight = weights.get(toolName) || 5;
180
- const weightedScore = output.score * weight;
181
- weightedSum += weightedScore;
345
+ weightedSum += output.score * weight;
182
346
  totalWeight += weight;
183
347
  toolsUsed.push(toolName);
184
348
  calculationWeights[toolName] = weight;
@@ -432,13 +596,30 @@ function generateHTML(graph) {
432
596
  }
433
597
  // Annotate the CommonJS export names for ESM import in node:
434
598
  0 && (module.exports = {
599
+ AnalysisResultSchema,
600
+ AnalysisStatus,
601
+ AnalysisStatusSchema,
435
602
  CONTEXT_TIER_THRESHOLDS,
436
603
  DEFAULT_TOOL_WEIGHTS,
604
+ FRIENDLY_TOOL_NAMES,
605
+ IssueSchema,
606
+ IssueType,
607
+ IssueTypeSchema,
437
608
  LANGUAGE_EXTENSIONS,
438
609
  Language,
610
+ LocationSchema,
611
+ MetricsSchema,
612
+ ModelTier,
613
+ ModelTierSchema,
439
614
  ParseError,
440
615
  SIZE_ADJUSTED_THRESHOLDS,
616
+ Severity,
617
+ SeveritySchema,
618
+ SpokeOutputSchema,
441
619
  TOOL_NAME_MAP,
620
+ ToolName,
621
+ ToolNameSchema,
622
+ UnifiedReportSchema,
442
623
  calculateOverallScore,
443
624
  formatScore,
444
625
  formatToolScore,
package/dist/client.mjs CHANGED
@@ -1,11 +1,28 @@
1
1
  import {
2
+ AnalysisResultSchema,
3
+ AnalysisStatus,
4
+ AnalysisStatusSchema,
2
5
  CONTEXT_TIER_THRESHOLDS,
3
6
  DEFAULT_TOOL_WEIGHTS,
7
+ FRIENDLY_TOOL_NAMES,
8
+ IssueSchema,
9
+ IssueType,
10
+ IssueTypeSchema,
4
11
  LANGUAGE_EXTENSIONS,
5
12
  Language,
13
+ LocationSchema,
14
+ MetricsSchema,
15
+ ModelTier,
16
+ ModelTierSchema,
6
17
  ParseError,
7
18
  SIZE_ADJUSTED_THRESHOLDS,
19
+ Severity,
20
+ SeveritySchema,
21
+ SpokeOutputSchema,
8
22
  TOOL_NAME_MAP,
23
+ ToolName,
24
+ ToolNameSchema,
25
+ UnifiedReportSchema,
9
26
  calculateOverallScore,
10
27
  formatScore,
11
28
  formatToolScore,
@@ -18,15 +35,32 @@ import {
18
35
  getToolWeight,
19
36
  normalizeToolName,
20
37
  parseWeightString
21
- } from "./chunk-UQGI67WR.mjs";
38
+ } from "./chunk-QAFB3HXQ.mjs";
22
39
  export {
40
+ AnalysisResultSchema,
41
+ AnalysisStatus,
42
+ AnalysisStatusSchema,
23
43
  CONTEXT_TIER_THRESHOLDS,
24
44
  DEFAULT_TOOL_WEIGHTS,
45
+ FRIENDLY_TOOL_NAMES,
46
+ IssueSchema,
47
+ IssueType,
48
+ IssueTypeSchema,
25
49
  LANGUAGE_EXTENSIONS,
26
50
  Language,
51
+ LocationSchema,
52
+ MetricsSchema,
53
+ ModelTier,
54
+ ModelTierSchema,
27
55
  ParseError,
28
56
  SIZE_ADJUSTED_THRESHOLDS,
57
+ Severity,
58
+ SeveritySchema,
59
+ SpokeOutputSchema,
29
60
  TOOL_NAME_MAP,
61
+ ToolName,
62
+ ToolNameSchema,
63
+ UnifiedReportSchema,
30
64
  calculateOverallScore,
31
65
  formatScore,
32
66
  formatToolScore,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { AnalysisResult, ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
2
- export { BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, SIZE_ADJUSTED_THRESHOLDS, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString } from './client.mjs';
1
+ import { ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
2
+ export { AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, FRIENDLY_TOOL_NAMES, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, LanguageConfig, Location, LocationSchema, Metrics, MetricsSchema, ModelTier, ModelTierSchema, ParseError, ParseStatistics, Report, SIZE_ADJUSTED_THRESHOLDS, ScoringConfig, ScoringResult, Severity, SeveritySchema, SourceLocation, SourceRange, SpokeOutput, SpokeOutputSchema, TOOL_NAME_MAP, ToolName, ToolNameSchema, UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString } from './client.mjs';
3
+ import { z } from 'zod';
3
4
 
4
5
  /**
5
6
  * Spoke-to-Hub Contract Definitions
@@ -7,20 +8,6 @@ export { BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WE
7
8
  * changes in spokes don't break the CLI, Platform, or Visualizer.
8
9
  */
9
10
 
10
- /**
11
- * The standard output every spoke MUST provide when analyzed.
12
- * Some fields are optional depending on the tool's focus.
13
- */
14
- interface SpokeOutput {
15
- results: AnalysisResult[];
16
- summary: any;
17
- metadata?: {
18
- toolName: string;
19
- version: string;
20
- timestamp: string;
21
- [key: string]: any;
22
- };
23
- }
24
11
  /**
25
12
  * Validation utility to ensure a spoke's output matches the expected contract.
26
13
  * Used in spoke tests to catch breakages early.
@@ -30,29 +17,13 @@ declare function validateSpokeOutput(toolName: string, output: any): {
30
17
  errors: string[];
31
18
  };
32
19
  /**
33
- * The unified report format produced by the CLI and consumed by the Platform.
34
- * This is the master contract for the entire system.
20
+ * Zod-based validation (Round 1 improvement)
35
21
  */
36
- interface UnifiedReport {
37
- summary: {
38
- totalFiles: number;
39
- totalIssues: number;
40
- criticalIssues: number;
41
- majorIssues: number;
42
- };
43
- results: AnalysisResult[];
44
- scoring?: {
45
- overall: number;
46
- rating: string;
47
- timestamp: string;
48
- breakdown: Array<{
49
- toolName: string;
50
- score: number;
51
- [key: string]: any;
52
- }>;
53
- };
54
- [toolKey: string]: any;
55
- }
22
+ declare function validateWithSchema<T>(schema: z.ZodSchema<T>, data: any): {
23
+ valid: boolean;
24
+ data?: T;
25
+ errors?: string[];
26
+ };
56
27
 
57
28
  declare const DEFAULT_EXCLUDE: string[];
58
29
  declare const VAGUE_FILE_NAMES: Set<string>;
@@ -829,4 +800,4 @@ declare function getRepoMetadata(directory: string): {
829
800
  author?: string;
830
801
  };
831
802
 
832
- export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, AnalysisResult, type CLIOptions, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, type ExportWithImports, type FileImport, type FileWithDomain, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type SpokeOutput, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, type UnifiedReport, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityColor, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, validateSpokeOutput };
803
+ export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, type CLIOptions, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, type ExportWithImports, type FileImport, type FileWithDomain, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityColor, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, validateSpokeOutput, validateWithSchema };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { AnalysisResult, ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
2
- export { BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, SIZE_ADJUSTED_THRESHOLDS, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString } from './client.js';
1
+ import { ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
2
+ export { AnalysisResult, AnalysisResultSchema, AnalysisStatus, AnalysisStatusSchema, BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, FRIENDLY_TOOL_NAMES, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueSchema, IssueType, IssueTypeSchema, LANGUAGE_EXTENSIONS, LanguageConfig, Location, LocationSchema, Metrics, MetricsSchema, ModelTier, ModelTierSchema, ParseError, ParseStatistics, Report, SIZE_ADJUSTED_THRESHOLDS, ScoringConfig, ScoringResult, Severity, SeveritySchema, SourceLocation, SourceRange, SpokeOutput, SpokeOutputSchema, TOOL_NAME_MAP, ToolName, ToolNameSchema, UnifiedReport, UnifiedReportSchema, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString } from './client.js';
3
+ import { z } from 'zod';
3
4
 
4
5
  /**
5
6
  * Spoke-to-Hub Contract Definitions
@@ -7,20 +8,6 @@ export { BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WE
7
8
  * changes in spokes don't break the CLI, Platform, or Visualizer.
8
9
  */
9
10
 
10
- /**
11
- * The standard output every spoke MUST provide when analyzed.
12
- * Some fields are optional depending on the tool's focus.
13
- */
14
- interface SpokeOutput {
15
- results: AnalysisResult[];
16
- summary: any;
17
- metadata?: {
18
- toolName: string;
19
- version: string;
20
- timestamp: string;
21
- [key: string]: any;
22
- };
23
- }
24
11
  /**
25
12
  * Validation utility to ensure a spoke's output matches the expected contract.
26
13
  * Used in spoke tests to catch breakages early.
@@ -30,29 +17,13 @@ declare function validateSpokeOutput(toolName: string, output: any): {
30
17
  errors: string[];
31
18
  };
32
19
  /**
33
- * The unified report format produced by the CLI and consumed by the Platform.
34
- * This is the master contract for the entire system.
20
+ * Zod-based validation (Round 1 improvement)
35
21
  */
36
- interface UnifiedReport {
37
- summary: {
38
- totalFiles: number;
39
- totalIssues: number;
40
- criticalIssues: number;
41
- majorIssues: number;
42
- };
43
- results: AnalysisResult[];
44
- scoring?: {
45
- overall: number;
46
- rating: string;
47
- timestamp: string;
48
- breakdown: Array<{
49
- toolName: string;
50
- score: number;
51
- [key: string]: any;
52
- }>;
53
- };
54
- [toolKey: string]: any;
55
- }
22
+ declare function validateWithSchema<T>(schema: z.ZodSchema<T>, data: any): {
23
+ valid: boolean;
24
+ data?: T;
25
+ errors?: string[];
26
+ };
56
27
 
57
28
  declare const DEFAULT_EXCLUDE: string[];
58
29
  declare const VAGUE_FILE_NAMES: Set<string>;
@@ -829,4 +800,4 @@ declare function getRepoMetadata(directory: string): {
829
800
  author?: string;
830
801
  };
831
802
 
832
- export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, AnalysisResult, type CLIOptions, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, type ExportWithImports, type FileImport, type FileWithDomain, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type SpokeOutput, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, type UnifiedReport, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityColor, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, validateSpokeOutput };
803
+ export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, type CLIOptions, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, type ExportWithImports, type FileImport, type FileWithDomain, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityColor, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles, validateSpokeOutput, validateWithSchema };