@aiready/core 0.9.39 → 0.18.0

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/README.md CHANGED
@@ -33,3 +33,6 @@ This package provides common utilities, type definitions, and helper functions u
33
33
  ## License
34
34
 
35
35
  MIT
36
+ // ping
37
+ // ping
38
+ // ping 2
package/dist/index.d.mts CHANGED
@@ -1,5 +1,58 @@
1
- import { ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
2
- export { AnalysisResult, 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 { 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';
3
+
4
+ /**
5
+ * Spoke-to-Hub Contract Definitions
6
+ * This file defines the expected JSON structure for tool outputs to ensure
7
+ * changes in spokes don't break the CLI, Platform, or Visualizer.
8
+ */
9
+
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
+ /**
25
+ * Validation utility to ensure a spoke's output matches the expected contract.
26
+ * Used in spoke tests to catch breakages early.
27
+ */
28
+ declare function validateSpokeOutput(toolName: string, output: any): {
29
+ valid: boolean;
30
+ errors: string[];
31
+ };
32
+ /**
33
+ * The unified report format produced by the CLI and consumed by the Platform.
34
+ * This is the master contract for the entire system.
35
+ */
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
+ }
3
56
 
4
57
  declare const DEFAULT_EXCLUDE: string[];
5
58
  declare const VAGUE_FILE_NAMES: Set<string>;
@@ -776,4 +829,4 @@ declare function getRepoMetadata(directory: string): {
776
829
  author?: string;
777
830
  };
778
831
 
779
- 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,58 @@
1
- import { ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
2
- export { AnalysisResult, 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 { 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';
3
+
4
+ /**
5
+ * Spoke-to-Hub Contract Definitions
6
+ * This file defines the expected JSON structure for tool outputs to ensure
7
+ * changes in spokes don't break the CLI, Platform, or Visualizer.
8
+ */
9
+
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
+ /**
25
+ * Validation utility to ensure a spoke's output matches the expected contract.
26
+ * Used in spoke tests to catch breakages early.
27
+ */
28
+ declare function validateSpokeOutput(toolName: string, output: any): {
29
+ valid: boolean;
30
+ errors: string[];
31
+ };
32
+ /**
33
+ * The unified report format produced by the CLI and consumed by the Platform.
34
+ * This is the master contract for the entire system.
35
+ */
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
+ }
3
56
 
4
57
  declare const DEFAULT_EXCLUDE: string[];
5
58
  declare const VAGUE_FILE_NAMES: Set<string>;
@@ -776,4 +829,4 @@ declare function getRepoMetadata(directory: string): {
776
829
  author?: string;
777
830
  };
778
831
 
779
- 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 };
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 };
package/dist/index.js CHANGED
@@ -115,7 +115,8 @@ __export(index_exports, {
115
115
  resolveOutputPath: () => resolveOutputPath,
116
116
  saveScoreEntry: () => saveScoreEntry,
117
117
  scanEntries: () => scanEntries,
118
- scanFiles: () => scanFiles
118
+ scanFiles: () => scanFiles,
119
+ validateSpokeOutput: () => validateSpokeOutput
119
120
  });
120
121
  module.exports = __toCommonJS(index_exports);
121
122
 
@@ -150,6 +151,54 @@ var ParseError = class extends Error {
150
151
  }
151
152
  };
152
153
 
154
+ // src/types/contract.ts
155
+ function validateSpokeOutput(toolName, output) {
156
+ const errors = [];
157
+ if (!output) {
158
+ return { valid: false, errors: ["Output is null or undefined"] };
159
+ }
160
+ if (!Array.isArray(output.results)) {
161
+ errors.push(`${toolName}: 'results' must be an array`);
162
+ } else {
163
+ output.results.forEach((res, idx) => {
164
+ const fileName = res.fileName || res.file || res.filePath;
165
+ if (!fileName)
166
+ errors.push(
167
+ `${toolName}: results[${idx}] missing 'fileName', 'file' or 'filePath'`
168
+ );
169
+ const issues = res.issues;
170
+ if (!Array.isArray(issues)) {
171
+ errors.push(`${toolName}: results[${idx}] 'issues' must be an array`);
172
+ } else if (issues.length > 0) {
173
+ issues.forEach((issue, iidx) => {
174
+ if (typeof issue === "string") return;
175
+ if (!issue.type && !res.file)
176
+ errors.push(
177
+ `${toolName}: results[${idx}].issues[${iidx}] missing 'type'`
178
+ );
179
+ if (!issue.severity && !res.severity)
180
+ errors.push(
181
+ `${toolName}: results[${idx}].issues[${iidx}] missing 'severity'`
182
+ );
183
+ const severity = issue.severity || res.severity;
184
+ if (severity && !["critical", "major", "minor", "info"].includes(severity)) {
185
+ errors.push(
186
+ `${toolName}: results[${idx}].issues[${iidx}] has invalid severity: ${severity}`
187
+ );
188
+ }
189
+ });
190
+ }
191
+ });
192
+ }
193
+ if (!output.summary) {
194
+ errors.push(`${toolName}: missing 'summary'`);
195
+ }
196
+ return {
197
+ valid: errors.length === 0,
198
+ errors
199
+ };
200
+ }
201
+
153
202
  // src/utils/file-scanner.ts
154
203
  var import_glob = require("glob");
155
204
  var import_promises = require("fs/promises");
@@ -3021,5 +3070,6 @@ function getRepoMetadata(directory) {
3021
3070
  resolveOutputPath,
3022
3071
  saveScoreEntry,
3023
3072
  scanEntries,
3024
- scanFiles
3073
+ scanFiles,
3074
+ validateSpokeOutput
3025
3075
  });
package/dist/index.mjs CHANGED
@@ -20,6 +20,54 @@ import {
20
20
  parseWeightString
21
21
  } from "./chunk-UQGI67WR.mjs";
22
22
 
23
+ // src/types/contract.ts
24
+ function validateSpokeOutput(toolName, output) {
25
+ const errors = [];
26
+ if (!output) {
27
+ return { valid: false, errors: ["Output is null or undefined"] };
28
+ }
29
+ if (!Array.isArray(output.results)) {
30
+ errors.push(`${toolName}: 'results' must be an array`);
31
+ } else {
32
+ output.results.forEach((res, idx) => {
33
+ const fileName = res.fileName || res.file || res.filePath;
34
+ if (!fileName)
35
+ errors.push(
36
+ `${toolName}: results[${idx}] missing 'fileName', 'file' or 'filePath'`
37
+ );
38
+ const issues = res.issues;
39
+ if (!Array.isArray(issues)) {
40
+ errors.push(`${toolName}: results[${idx}] 'issues' must be an array`);
41
+ } else if (issues.length > 0) {
42
+ issues.forEach((issue, iidx) => {
43
+ if (typeof issue === "string") return;
44
+ if (!issue.type && !res.file)
45
+ errors.push(
46
+ `${toolName}: results[${idx}].issues[${iidx}] missing 'type'`
47
+ );
48
+ if (!issue.severity && !res.severity)
49
+ errors.push(
50
+ `${toolName}: results[${idx}].issues[${iidx}] missing 'severity'`
51
+ );
52
+ const severity = issue.severity || res.severity;
53
+ if (severity && !["critical", "major", "minor", "info"].includes(severity)) {
54
+ errors.push(
55
+ `${toolName}: results[${idx}].issues[${iidx}] has invalid severity: ${severity}`
56
+ );
57
+ }
58
+ });
59
+ }
60
+ });
61
+ }
62
+ if (!output.summary) {
63
+ errors.push(`${toolName}: missing 'summary'`);
64
+ }
65
+ return {
66
+ valid: errors.length === 0,
67
+ errors
68
+ };
69
+ }
70
+
23
71
  // src/utils/file-scanner.ts
24
72
  import { glob } from "glob";
25
73
  import { readFile } from "fs/promises";
@@ -2532,5 +2580,6 @@ export {
2532
2580
  resolveOutputPath,
2533
2581
  saveScoreEntry,
2534
2582
  scanEntries,
2535
- scanFiles
2583
+ scanFiles,
2584
+ validateSpokeOutput
2536
2585
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.9.39",
3
+ "version": "0.18.0",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",