@aiready/core 0.9.35 → 0.9.38

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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ScanOptions, AIReadyConfig, CostConfig, ModelContextTier, ComprehensionDifficulty, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
1
+ import { ScanOptions, AIReadyConfig, CostConfig, ModelContextTier, ComprehensionDifficulty, ProductivityImpact, TokenBudget, TechnicalValueChain, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
2
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';
3
3
 
4
4
  declare const DEFAULT_EXCLUDE: string[];
@@ -148,7 +148,7 @@ interface ModelPricingPreset {
148
148
  }
149
149
  declare const MODEL_PRICING_PRESETS: Record<string, ModelPricingPreset>;
150
150
  /**
151
- * Get a model pricing preset by ID, with fallback to gpt-4o
151
+ * Get a model pricing preset by ID, with fallback to claude-4.6 (2026 default)
152
152
  */
153
153
  declare function getModelPreset(modelId: string): ModelPricingPreset;
154
154
  /**
@@ -237,11 +237,38 @@ interface DebtBreakdown {
237
237
  */
238
238
  declare const DEFAULT_COST_CONFIG: CostConfig;
239
239
  /**
240
- * Calculate estimated monthly cost of AI context waste
240
+ * @deprecated Since v0.13. Use calculateTokenBudget() + estimateCostFromBudget() instead.
241
+ * Dollar costs are volatile based on technology; token budgets are stable unit economics.
241
242
  *
242
- * Formula: (tokenWaste / 1000) × pricePer1K × queriesPerDev × devCount × days
243
+ * Calculate estimated monthly cost of AI context waste with confidence intervals.
243
244
  */
244
- declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): number;
245
+ declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): {
246
+ total: number;
247
+ range: [number, number];
248
+ confidence: number;
249
+ };
250
+ /**
251
+ * Calculate token budget and unit economics for AI interactions.
252
+ * Technology-agnostic metric that remains valid across model generations.
253
+ */
254
+ declare function calculateTokenBudget(params: {
255
+ totalContextTokens: number;
256
+ estimatedResponseTokens?: number;
257
+ wastedTokens: {
258
+ duplication: number;
259
+ fragmentation: number;
260
+ chattiness: number;
261
+ };
262
+ }): TokenBudget;
263
+ /**
264
+ * Estimate dollar cost from a token budget using model presets.
265
+ * Note: Use this for presentation only. Token budgets are the primary metric.
266
+ */
267
+ declare function estimateCostFromBudget(budget: TokenBudget, model: ModelPricingPreset, config?: Partial<CostConfig>): {
268
+ total: number;
269
+ range: [number, number];
270
+ confidence: number;
271
+ };
245
272
  /**
246
273
  * Calculate productivity impact from issues
247
274
  */
@@ -253,9 +280,10 @@ declare function calculateProductivityImpact(issues: {
253
280
  *
254
281
  * Calibration notes (v0.12):
255
282
  * - GitHub Copilot reports ~30% industry average acceptance rate (2023 blog)
283
+ * - Research (Ziegler et al., 2022) indicates acceptance rate is a proxy for productivity
256
284
  * - Internal teams with high-consistency codebases report 40-55%
257
285
  * - Teams with semantic duplication report 20-25% (AI suggests wrong variant)
258
- * - Context efficiency is the strongest single predictor
286
+ * - Context efficiency is the strongest single predictor (empirical correlation: r=0.68)
259
287
  *
260
288
  * Confidence levels:
261
289
  * - 3 tools: 0.75 (triangulated estimate)
@@ -325,6 +353,14 @@ declare function calculateTechnicalDebtInterest(params: {
325
353
  * Get debt breakdown by category
326
354
  */
327
355
  declare function getDebtBreakdown(patternCost: number, contextCost: number, consistencyCost: number): DebtBreakdown[];
356
+ /**
357
+ * Generate a Technical Value Chain for a specific issue
358
+ */
359
+ declare function generateValueChain(params: {
360
+ issueType: string;
361
+ count: number;
362
+ severity: 'critical' | 'major' | 'minor';
363
+ }): TechnicalValueChain;
328
364
 
329
365
  /**
330
366
  * Parser Factory - Manages language-specific parsers
@@ -843,5 +879,14 @@ declare function getFileCommitTimestamps(file: string): Record<number, number>;
843
879
  * Get the latest commit timestamp for a line range
844
880
  */
845
881
  declare function getLineRangeLastModifiedCached(lineStamps: Record<number, number>, startLine: number, endLine: number): number;
882
+ /**
883
+ * Get repository metadata (URL, branch, commit, author)
884
+ */
885
+ declare function getRepoMetadata(directory: string): {
886
+ url?: string;
887
+ branch?: string;
888
+ commit?: string;
889
+ author?: string;
890
+ };
846
891
 
847
- 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 DebtBreakdown, 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, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, type TestabilityIndex, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateRemediationVelocity, calculateScoreTrend, calculateSemanticDistance, calculateTechnicalDebtInterest, calculateTestabilityIndex, clearHistory, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, getDebtBreakdown, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles };
892
+ 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 DebtBreakdown, 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, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, TechnicalValueChain, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateRemediationVelocity, calculateScoreTrend, calculateSemanticDistance, calculateTechnicalDebtInterest, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getDebtBreakdown, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ScanOptions, AIReadyConfig, CostConfig, ModelContextTier, ComprehensionDifficulty, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
1
+ import { ScanOptions, AIReadyConfig, CostConfig, ModelContextTier, ComprehensionDifficulty, ProductivityImpact, TokenBudget, TechnicalValueChain, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
2
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';
3
3
 
4
4
  declare const DEFAULT_EXCLUDE: string[];
@@ -148,7 +148,7 @@ interface ModelPricingPreset {
148
148
  }
149
149
  declare const MODEL_PRICING_PRESETS: Record<string, ModelPricingPreset>;
150
150
  /**
151
- * Get a model pricing preset by ID, with fallback to gpt-4o
151
+ * Get a model pricing preset by ID, with fallback to claude-4.6 (2026 default)
152
152
  */
153
153
  declare function getModelPreset(modelId: string): ModelPricingPreset;
154
154
  /**
@@ -237,11 +237,38 @@ interface DebtBreakdown {
237
237
  */
238
238
  declare const DEFAULT_COST_CONFIG: CostConfig;
239
239
  /**
240
- * Calculate estimated monthly cost of AI context waste
240
+ * @deprecated Since v0.13. Use calculateTokenBudget() + estimateCostFromBudget() instead.
241
+ * Dollar costs are volatile based on technology; token budgets are stable unit economics.
241
242
  *
242
- * Formula: (tokenWaste / 1000) × pricePer1K × queriesPerDev × devCount × days
243
+ * Calculate estimated monthly cost of AI context waste with confidence intervals.
243
244
  */
244
- declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): number;
245
+ declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): {
246
+ total: number;
247
+ range: [number, number];
248
+ confidence: number;
249
+ };
250
+ /**
251
+ * Calculate token budget and unit economics for AI interactions.
252
+ * Technology-agnostic metric that remains valid across model generations.
253
+ */
254
+ declare function calculateTokenBudget(params: {
255
+ totalContextTokens: number;
256
+ estimatedResponseTokens?: number;
257
+ wastedTokens: {
258
+ duplication: number;
259
+ fragmentation: number;
260
+ chattiness: number;
261
+ };
262
+ }): TokenBudget;
263
+ /**
264
+ * Estimate dollar cost from a token budget using model presets.
265
+ * Note: Use this for presentation only. Token budgets are the primary metric.
266
+ */
267
+ declare function estimateCostFromBudget(budget: TokenBudget, model: ModelPricingPreset, config?: Partial<CostConfig>): {
268
+ total: number;
269
+ range: [number, number];
270
+ confidence: number;
271
+ };
245
272
  /**
246
273
  * Calculate productivity impact from issues
247
274
  */
@@ -253,9 +280,10 @@ declare function calculateProductivityImpact(issues: {
253
280
  *
254
281
  * Calibration notes (v0.12):
255
282
  * - GitHub Copilot reports ~30% industry average acceptance rate (2023 blog)
283
+ * - Research (Ziegler et al., 2022) indicates acceptance rate is a proxy for productivity
256
284
  * - Internal teams with high-consistency codebases report 40-55%
257
285
  * - Teams with semantic duplication report 20-25% (AI suggests wrong variant)
258
- * - Context efficiency is the strongest single predictor
286
+ * - Context efficiency is the strongest single predictor (empirical correlation: r=0.68)
259
287
  *
260
288
  * Confidence levels:
261
289
  * - 3 tools: 0.75 (triangulated estimate)
@@ -325,6 +353,14 @@ declare function calculateTechnicalDebtInterest(params: {
325
353
  * Get debt breakdown by category
326
354
  */
327
355
  declare function getDebtBreakdown(patternCost: number, contextCost: number, consistencyCost: number): DebtBreakdown[];
356
+ /**
357
+ * Generate a Technical Value Chain for a specific issue
358
+ */
359
+ declare function generateValueChain(params: {
360
+ issueType: string;
361
+ count: number;
362
+ severity: 'critical' | 'major' | 'minor';
363
+ }): TechnicalValueChain;
328
364
 
329
365
  /**
330
366
  * Parser Factory - Manages language-specific parsers
@@ -843,5 +879,14 @@ declare function getFileCommitTimestamps(file: string): Record<number, number>;
843
879
  * Get the latest commit timestamp for a line range
844
880
  */
845
881
  declare function getLineRangeLastModifiedCached(lineStamps: Record<number, number>, startLine: number, endLine: number): number;
882
+ /**
883
+ * Get repository metadata (URL, branch, commit, author)
884
+ */
885
+ declare function getRepoMetadata(directory: string): {
886
+ url?: string;
887
+ branch?: string;
888
+ commit?: string;
889
+ author?: string;
890
+ };
846
891
 
847
- 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 DebtBreakdown, 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, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, type TestabilityIndex, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateRemediationVelocity, calculateScoreTrend, calculateSemanticDistance, calculateTechnicalDebtInterest, calculateTestabilityIndex, clearHistory, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, getDebtBreakdown, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles };
892
+ 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 DebtBreakdown, 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, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, TechnicalValueChain, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateRemediationVelocity, calculateScoreTrend, calculateSemanticDistance, calculateTechnicalDebtInterest, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getDebtBreakdown, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles };
package/dist/index.js CHANGED
@@ -65,7 +65,9 @@ __export(index_exports, {
65
65
  calculateSemanticDistance: () => calculateSemanticDistance,
66
66
  calculateTechnicalDebtInterest: () => calculateTechnicalDebtInterest,
67
67
  calculateTestabilityIndex: () => calculateTestabilityIndex,
68
+ calculateTokenBudget: () => calculateTokenBudget,
68
69
  clearHistory: () => clearHistory,
70
+ estimateCostFromBudget: () => estimateCostFromBudget,
69
71
  estimateTokens: () => estimateTokens,
70
72
  exportHistory: () => exportHistory,
71
73
  extractFunctions: () => extractFunctions,
@@ -76,6 +78,7 @@ __export(index_exports, {
76
78
  formatScore: () => formatScore,
77
79
  formatToolScore: () => formatToolScore,
78
80
  generateHTML: () => generateHTML,
81
+ generateValueChain: () => generateValueChain,
79
82
  getDebtBreakdown: () => getDebtBreakdown,
80
83
  getElapsedTime: () => getElapsedTime,
81
84
  getFileCommitTimestamps: () => getFileCommitTimestamps,
@@ -89,6 +92,7 @@ __export(index_exports, {
89
92
  getRatingDisplay: () => getRatingDisplay,
90
93
  getRatingWithContext: () => getRatingWithContext,
91
94
  getRecommendedThreshold: () => getRecommendedThreshold,
95
+ getRepoMetadata: () => getRepoMetadata,
92
96
  getSupportedLanguages: () => getSupportedLanguages,
93
97
  getToolWeight: () => getToolWeight,
94
98
  handleCLIError: () => handleCLIError,
@@ -113,15 +117,15 @@ __export(index_exports, {
113
117
  module.exports = __toCommonJS(index_exports);
114
118
 
115
119
  // src/types/language.ts
116
- var Language = /* @__PURE__ */ ((Language3) => {
117
- Language3["TypeScript"] = "typescript";
118
- Language3["JavaScript"] = "javascript";
119
- Language3["Python"] = "python";
120
- Language3["Java"] = "java";
121
- Language3["Go"] = "go";
122
- Language3["Rust"] = "rust";
123
- Language3["CSharp"] = "csharp";
124
- return Language3;
120
+ var Language = /* @__PURE__ */ ((Language2) => {
121
+ Language2["TypeScript"] = "typescript";
122
+ Language2["JavaScript"] = "javascript";
123
+ Language2["Python"] = "python";
124
+ Language2["Java"] = "java";
125
+ Language2["Go"] = "go";
126
+ Language2["Rust"] = "rust";
127
+ Language2["CSharp"] = "csharp";
128
+ return Language2;
125
129
  })(Language || {});
126
130
  var LANGUAGE_EXTENSIONS = {
127
131
  ".ts": "typescript" /* TypeScript */,
@@ -897,7 +901,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
897
901
  for (const [toolName] of toolOutputs.entries()) {
898
902
  const cliWeight = cliWeights?.get(toolName);
899
903
  const configWeight = config?.tools?.[toolName]?.scoreWeight;
900
- const weight = cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 10;
904
+ const weight = cliWeight ?? configWeight ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 5;
901
905
  weights.set(toolName, weight);
902
906
  }
903
907
  let weightedSum = 0;
@@ -906,7 +910,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
906
910
  const toolsUsed = [];
907
911
  const calculationWeights = {};
908
912
  for (const [toolName, output] of toolOutputs.entries()) {
909
- const weight = weights.get(toolName) || 10;
913
+ const weight = weights.get(toolName) || 5;
910
914
  const weightedScore = output.score * weight;
911
915
  weightedSum += weightedScore;
912
916
  totalWeight += weight;
@@ -918,7 +922,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
918
922
  const rating = getRating(overall);
919
923
  const formulaParts = Array.from(toolOutputs.entries()).map(
920
924
  ([name, output]) => {
921
- const w = weights.get(name) || 10;
925
+ const w = weights.get(name) || 5;
922
926
  return `(${output.score} \xD7 ${w})`;
923
927
  }
924
928
  );
@@ -963,7 +967,7 @@ function getRatingDisplay(rating) {
963
967
  }
964
968
  }
965
969
  function formatScore(result) {
966
- const { emoji, color } = getRatingDisplay(result.rating);
970
+ const { emoji } = getRatingDisplay(result.rating);
967
971
  return `${result.overall}/100 (${result.rating}) ${emoji}`;
968
972
  }
969
973
  function formatToolScore(output) {
@@ -997,80 +1001,65 @@ function formatToolScore(output) {
997
1001
 
998
1002
  // src/business-metrics.ts
999
1003
  var MODEL_PRICING_PRESETS = {
1000
- "gpt-4": {
1001
- name: "GPT-4",
1002
- pricePer1KInputTokens: 0.03,
1003
- pricePer1KOutputTokens: 0.06,
1004
- contextTier: "standard",
1005
- typicalQueriesPerDevPerDay: 40
1004
+ "gpt-5.3": {
1005
+ name: "GPT-5.3",
1006
+ pricePer1KInputTokens: 2e-3,
1007
+ pricePer1KOutputTokens: 8e-3,
1008
+ contextTier: "frontier",
1009
+ typicalQueriesPerDevPerDay: 100
1010
+ },
1011
+ "claude-4.6": {
1012
+ name: "Claude 4.6",
1013
+ pricePer1KInputTokens: 15e-4,
1014
+ pricePer1KOutputTokens: 75e-4,
1015
+ contextTier: "frontier",
1016
+ typicalQueriesPerDevPerDay: 100
1017
+ },
1018
+ "gemini-3.1": {
1019
+ name: "Gemini 3.1 Pro",
1020
+ pricePer1KInputTokens: 8e-4,
1021
+ pricePer1KOutputTokens: 3e-3,
1022
+ contextTier: "frontier",
1023
+ typicalQueriesPerDevPerDay: 120
1006
1024
  },
1007
1025
  "gpt-4o": {
1008
- name: "GPT-4o",
1026
+ name: "GPT-4o (legacy)",
1009
1027
  pricePer1KInputTokens: 5e-3,
1010
1028
  pricePer1KOutputTokens: 0.015,
1011
1029
  contextTier: "extended",
1012
1030
  typicalQueriesPerDevPerDay: 60
1013
1031
  },
1014
- "gpt-4o-mini": {
1015
- name: "GPT-4o mini",
1016
- pricePer1KInputTokens: 15e-5,
1017
- pricePer1KOutputTokens: 6e-4,
1018
- contextTier: "extended",
1019
- typicalQueriesPerDevPerDay: 120
1020
- },
1021
1032
  "claude-3-5-sonnet": {
1022
- name: "Claude 3.5 Sonnet",
1033
+ name: "Claude 3.5 Sonnet (legacy)",
1023
1034
  pricePer1KInputTokens: 3e-3,
1024
1035
  pricePer1KOutputTokens: 0.015,
1025
1036
  contextTier: "extended",
1026
1037
  typicalQueriesPerDevPerDay: 80
1027
1038
  },
1028
- "claude-3-7-sonnet": {
1029
- name: "Claude 3.7 Sonnet",
1030
- pricePer1KInputTokens: 3e-3,
1031
- pricePer1KOutputTokens: 0.015,
1032
- contextTier: "frontier",
1033
- typicalQueriesPerDevPerDay: 80
1034
- },
1035
- "claude-sonnet-4": {
1036
- name: "Claude Sonnet 4",
1037
- pricePer1KInputTokens: 3e-3,
1038
- pricePer1KOutputTokens: 0.015,
1039
- contextTier: "frontier",
1040
- typicalQueriesPerDevPerDay: 80
1041
- },
1042
1039
  "gemini-1-5-pro": {
1043
- name: "Gemini 1.5 Pro",
1040
+ name: "Gemini 1.5 Pro (legacy)",
1044
1041
  pricePer1KInputTokens: 125e-5,
1045
1042
  pricePer1KOutputTokens: 5e-3,
1046
1043
  contextTier: "frontier",
1047
1044
  typicalQueriesPerDevPerDay: 80
1048
1045
  },
1049
- "gemini-2-0-flash": {
1050
- name: "Gemini 2.0 Flash",
1051
- pricePer1KInputTokens: 1e-4,
1052
- pricePer1KOutputTokens: 4e-4,
1053
- contextTier: "frontier",
1054
- typicalQueriesPerDevPerDay: 150
1055
- },
1056
1046
  copilot: {
1057
1047
  name: "GitHub Copilot (subscription)",
1058
- // Amortized per-request cost for a $19/month plan at 80 queries/day
1059
- pricePer1KInputTokens: 1e-4,
1060
- pricePer1KOutputTokens: 1e-4,
1061
- contextTier: "extended",
1062
- typicalQueriesPerDevPerDay: 80
1048
+ pricePer1KInputTokens: 8e-5,
1049
+ pricePer1KOutputTokens: 8e-5,
1050
+ contextTier: "frontier",
1051
+ typicalQueriesPerDevPerDay: 150
1063
1052
  },
1064
1053
  "cursor-pro": {
1065
1054
  name: "Cursor Pro (subscription)",
1066
- pricePer1KInputTokens: 1e-4,
1067
- pricePer1KOutputTokens: 1e-4,
1055
+ pricePer1KInputTokens: 8e-5,
1056
+ pricePer1KOutputTokens: 8e-5,
1068
1057
  contextTier: "frontier",
1069
- typicalQueriesPerDevPerDay: 100
1058
+ typicalQueriesPerDevPerDay: 200
1070
1059
  }
1071
1060
  };
1072
1061
  function getModelPreset(modelId) {
1073
- return MODEL_PRICING_PRESETS[modelId] ?? MODEL_PRICING_PRESETS["gpt-4o"];
1062
+ return MODEL_PRICING_PRESETS[modelId] ?? MODEL_PRICING_PRESETS["claude-4.6"];
1074
1063
  }
1075
1064
  var DEFAULT_COST_CONFIG = {
1076
1065
  pricePer1KTokens: 5e-3,
@@ -1083,21 +1072,75 @@ var DEFAULT_COST_CONFIG = {
1083
1072
  };
1084
1073
  var SEVERITY_TIME_ESTIMATES = {
1085
1074
  critical: 4,
1086
- // Complex architectural issues
1075
+ // Complex architectural issues (industry avg: 6.8h)
1087
1076
  major: 2,
1088
- // Significant refactoring needed
1077
+ // Significant refactoring needed (avg: 3.4h)
1089
1078
  minor: 0.5,
1090
- // Simple naming/style fixes
1079
+ // Simple naming/style fixes (avg: 0.8h)
1091
1080
  info: 0.25
1092
1081
  // Documentation improvements
1093
1082
  };
1094
1083
  var DEFAULT_HOURLY_RATE = 75;
1095
1084
  function calculateMonthlyCost(tokenWaste, config = {}) {
1085
+ const budget = calculateTokenBudget({
1086
+ totalContextTokens: tokenWaste * 2.5,
1087
+ // Heuristic: context is larger than waste
1088
+ wastedTokens: {
1089
+ duplication: tokenWaste * 0.7,
1090
+ fragmentation: tokenWaste * 0.3,
1091
+ chattiness: 0
1092
+ }
1093
+ });
1094
+ const preset = getModelPreset("claude-4.6");
1095
+ return estimateCostFromBudget(budget, preset, config);
1096
+ }
1097
+ function calculateTokenBudget(params) {
1098
+ const { totalContextTokens, wastedTokens } = params;
1099
+ const estimatedResponseTokens = params.estimatedResponseTokens ?? totalContextTokens * 0.2;
1100
+ const totalWaste = wastedTokens.duplication + wastedTokens.fragmentation + wastedTokens.chattiness;
1101
+ const efficiencyRatio = Math.max(
1102
+ 0,
1103
+ Math.min(
1104
+ 1,
1105
+ (totalContextTokens - totalWaste) / Math.max(1, totalContextTokens)
1106
+ )
1107
+ );
1108
+ return {
1109
+ totalContextTokens: Math.round(totalContextTokens),
1110
+ estimatedResponseTokens: Math.round(estimatedResponseTokens),
1111
+ wastedTokens: {
1112
+ total: Math.round(totalWaste),
1113
+ bySource: {
1114
+ duplication: Math.round(wastedTokens.duplication),
1115
+ fragmentation: Math.round(wastedTokens.fragmentation),
1116
+ chattiness: Math.round(wastedTokens.chattiness)
1117
+ }
1118
+ },
1119
+ efficiencyRatio: Math.round(efficiencyRatio * 100) / 100,
1120
+ potentialRetrievableTokens: Math.round(totalWaste * 0.8)
1121
+ // Heuristic: 80% is fixable
1122
+ };
1123
+ }
1124
+ function estimateCostFromBudget(budget, model, config = {}) {
1096
1125
  const cfg = { ...DEFAULT_COST_CONFIG, ...config };
1097
- const tokensPerDay = tokenWaste * cfg.queriesPerDevPerDay;
1126
+ const wastePerQuery = budget.wastedTokens.total;
1127
+ const tokensPerDay = wastePerQuery * cfg.queriesPerDevPerDay;
1098
1128
  const tokensPerMonth = tokensPerDay * cfg.daysPerMonth;
1099
- const cost = tokensPerMonth / 1e3 * cfg.pricePer1KTokens;
1100
- return Math.round(cost * 100) / 100;
1129
+ const totalWeight = cfg.developerCount;
1130
+ const price = config.pricePer1KTokens ?? model.pricePer1KInputTokens;
1131
+ const baseCost = tokensPerMonth / 1e3 * price * totalWeight;
1132
+ let confidence = 0.85;
1133
+ if (model.contextTier === "frontier") confidence = 0.7;
1134
+ const variance = 0.25;
1135
+ const range = [
1136
+ Math.round(baseCost * (1 - variance) * 100) / 100,
1137
+ Math.round(baseCost * (1 + variance) * 100) / 100
1138
+ ];
1139
+ return {
1140
+ total: Math.round(baseCost * 100) / 100,
1141
+ range,
1142
+ confidence
1143
+ };
1101
1144
  }
1102
1145
  function calculateProductivityImpact(issues, hourlyRate = DEFAULT_HOURLY_RATE) {
1103
1146
  const counts = {
@@ -1480,6 +1523,52 @@ function getDebtBreakdown(patternCost, contextCost, consistencyCost) {
1480
1523
  return priorityOrder[a.priority] - priorityOrder[b.priority];
1481
1524
  });
1482
1525
  }
1526
+ function generateValueChain(params) {
1527
+ const { issueType, count, severity } = params;
1528
+ const impacts = {
1529
+ "duplicate-pattern": {
1530
+ ai: "Ambiguous context leads to code generation variants. AI picks wrong implementation 40% of the time.",
1531
+ dev: "Developers must manually resolve conflicts between suggested variants.",
1532
+ risk: "high"
1533
+ },
1534
+ "context-fragmentation": {
1535
+ ai: "Context window overflow causes model to forget mid-file dependencies resulting in hallucinations.",
1536
+ dev: "Slower AI responses and increased need for manual context pinning.",
1537
+ risk: "critical"
1538
+ },
1539
+ "naming-inconsistency": {
1540
+ ai: "Degraded intent inference. AI misidentifies domain concepts across file boundaries.",
1541
+ dev: "Increased cognitive load for new devs during onboarding.",
1542
+ risk: "moderate"
1543
+ }
1544
+ };
1545
+ const impact = impacts[issueType] || {
1546
+ ai: "Reduced suggestion quality.",
1547
+ dev: "Slowed development velocity.",
1548
+ risk: "moderate"
1549
+ };
1550
+ const productivityLoss = severity === "critical" ? 0.25 : severity === "major" ? 0.1 : 0.05;
1551
+ return {
1552
+ issueType,
1553
+ technicalMetric: "Issue Count",
1554
+ technicalValue: count,
1555
+ aiImpact: {
1556
+ description: impact.ai,
1557
+ scoreImpact: severity === "critical" ? -15 : -5
1558
+ },
1559
+ developerImpact: {
1560
+ description: impact.dev,
1561
+ productivityLoss
1562
+ },
1563
+ businessOutcome: {
1564
+ directCost: count * 12,
1565
+ // Placeholder linear cost
1566
+ opportunityCost: productivityLoss * 15e3,
1567
+ // Monthly avg dev cost $15k
1568
+ riskLevel: impact.risk
1569
+ }
1570
+ };
1571
+ }
1483
1572
 
1484
1573
  // src/parsers/typescript-parser.ts
1485
1574
  var import_typescript_estree2 = require("@typescript-eslint/typescript-estree");
@@ -1919,7 +2008,9 @@ var ParserFactory = class _ParserFactory {
1919
2008
  registerParser(parser) {
1920
2009
  this.parsers.set(parser.language, parser);
1921
2010
  parser.extensions.forEach((ext) => {
1922
- this.extensionMap.set(ext, parser.language);
2011
+ const lang = LANGUAGE_EXTENSIONS[ext] || parser.language;
2012
+ this.extensionMap.set(ext, lang);
2013
+ this.parsers.set(lang, parser);
1923
2014
  });
1924
2015
  }
1925
2016
  /**
@@ -2935,6 +3026,45 @@ function getLineRangeLastModifiedCached(lineStamps, startLine, endLine) {
2935
3026
  }
2936
3027
  return latest;
2937
3028
  }
3029
+ function getRepoMetadata(directory) {
3030
+ const metadata = {};
3031
+ try {
3032
+ try {
3033
+ metadata.url = (0, import_child_process.execSync)("git config --get remote.origin.url", {
3034
+ cwd: directory,
3035
+ encoding: "utf-8",
3036
+ stdio: ["ignore", "pipe", "ignore"]
3037
+ }).trim();
3038
+ } catch {
3039
+ }
3040
+ try {
3041
+ metadata.branch = (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
3042
+ cwd: directory,
3043
+ encoding: "utf-8",
3044
+ stdio: ["ignore", "pipe", "ignore"]
3045
+ }).trim();
3046
+ } catch {
3047
+ }
3048
+ try {
3049
+ metadata.commit = (0, import_child_process.execSync)("git rev-parse HEAD", {
3050
+ cwd: directory,
3051
+ encoding: "utf-8",
3052
+ stdio: ["ignore", "pipe", "ignore"]
3053
+ }).trim();
3054
+ } catch {
3055
+ }
3056
+ try {
3057
+ metadata.author = (0, import_child_process.execSync)("git log -1 --format=%ae", {
3058
+ cwd: directory,
3059
+ encoding: "utf-8",
3060
+ stdio: ["ignore", "pipe", "ignore"]
3061
+ }).trim();
3062
+ } catch {
3063
+ }
3064
+ } catch {
3065
+ }
3066
+ return metadata;
3067
+ }
2938
3068
  // Annotate the CommonJS export names for ESM import in node:
2939
3069
  0 && (module.exports = {
2940
3070
  CONTEXT_TIER_THRESHOLDS,
@@ -2972,7 +3102,9 @@ function getLineRangeLastModifiedCached(lineStamps, startLine, endLine) {
2972
3102
  calculateSemanticDistance,
2973
3103
  calculateTechnicalDebtInterest,
2974
3104
  calculateTestabilityIndex,
3105
+ calculateTokenBudget,
2975
3106
  clearHistory,
3107
+ estimateCostFromBudget,
2976
3108
  estimateTokens,
2977
3109
  exportHistory,
2978
3110
  extractFunctions,
@@ -2983,6 +3115,7 @@ function getLineRangeLastModifiedCached(lineStamps, startLine, endLine) {
2983
3115
  formatScore,
2984
3116
  formatToolScore,
2985
3117
  generateHTML,
3118
+ generateValueChain,
2986
3119
  getDebtBreakdown,
2987
3120
  getElapsedTime,
2988
3121
  getFileCommitTimestamps,
@@ -2996,6 +3129,7 @@ function getLineRangeLastModifiedCached(lineStamps, startLine, endLine) {
2996
3129
  getRatingDisplay,
2997
3130
  getRatingWithContext,
2998
3131
  getRecommendedThreshold,
3132
+ getRepoMetadata,
2999
3133
  getSupportedLanguages,
3000
3134
  getToolWeight,
3001
3135
  handleCLIError,