@aiready/core 0.23.21 → 0.23.23

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.js CHANGED
@@ -4874,6 +4874,99 @@ function predictAcceptanceRate(toolOutputs) {
4874
4874
  return { rate: Math.round(rate * 100) / 100, confidence, factors };
4875
4875
  }
4876
4876
 
4877
+ // src/business-metrics.ts
4878
+ function calculateBusinessROI(params) {
4879
+ const model = getModelPreset(params.modelId || "claude-4.6");
4880
+ const devCount = params.developerCount || 5;
4881
+ const budget = calculateTokenBudget({
4882
+ totalContextTokens: params.tokenWaste * 2.5,
4883
+ wastedTokens: {
4884
+ duplication: params.tokenWaste * 0.7,
4885
+ fragmentation: params.tokenWaste * 0.3,
4886
+ chattiness: 0
4887
+ }
4888
+ });
4889
+ const cost = estimateCostFromBudget(budget, model, {
4890
+ developerCount: devCount
4891
+ });
4892
+ const productivity = calculateProductivityImpact(params.issues);
4893
+ const monthlySavings = cost.total;
4894
+ const productivityGainHours = productivity.totalHours;
4895
+ const annualValue = (monthlySavings + productivityGainHours * 75) * 12;
4896
+ return {
4897
+ monthlySavings: Math.round(monthlySavings),
4898
+ productivityGainHours: Math.round(productivityGainHours),
4899
+ annualValue: Math.round(annualValue)
4900
+ };
4901
+ }
4902
+ function formatCost(cost) {
4903
+ if (cost < 1) {
4904
+ return `$${cost.toFixed(2)}`;
4905
+ } else if (cost < 1e3) {
4906
+ return `$${cost.toFixed(0)}`;
4907
+ } else {
4908
+ return `$${(cost / 1e3).toFixed(1)}k`;
4909
+ }
4910
+ }
4911
+ function formatHours(hours) {
4912
+ if (hours < 1) {
4913
+ return `${Math.round(hours * 60)}min`;
4914
+ } else if (hours < 8) {
4915
+ return `${hours.toFixed(1)}h`;
4916
+ } else if (hours < 40) {
4917
+ return `${Math.round(hours)}h`;
4918
+ } else {
4919
+ return `${(hours / 40).toFixed(1)} weeks`;
4920
+ }
4921
+ }
4922
+ function formatAcceptanceRate(rate) {
4923
+ return `${Math.round(rate * 100)}%`;
4924
+ }
4925
+ function generateValueChain(params) {
4926
+ const { issueType, count, severity } = params;
4927
+ const impacts = {
4928
+ "duplicate-pattern": {
4929
+ ai: "Ambiguous context leads to code generation variants. AI picks wrong implementation 40% of the time.",
4930
+ dev: "Developers must manually resolve conflicts between suggested variants.",
4931
+ risk: "high"
4932
+ },
4933
+ "context-fragmentation": {
4934
+ ai: "Context window overflow causes model to forget mid-file dependencies resulting in hallucinations.",
4935
+ dev: "Slower AI responses and increased need for manual context pinning.",
4936
+ risk: "critical"
4937
+ },
4938
+ "naming-inconsistency": {
4939
+ ai: "Degraded intent inference. AI misidentifies domain concepts across file boundaries.",
4940
+ dev: "Increased cognitive load for new devs during onboarding.",
4941
+ risk: "moderate"
4942
+ }
4943
+ };
4944
+ const impact = impacts[issueType] || {
4945
+ ai: "Reduced suggestion quality.",
4946
+ dev: "Slowed development velocity.",
4947
+ risk: "moderate"
4948
+ };
4949
+ const productivityLoss = severity === "critical" ? 0.25 : severity === "major" ? 0.1 : 0.05;
4950
+ return {
4951
+ issueType,
4952
+ technicalMetric: "Issue Count",
4953
+ technicalValue: count,
4954
+ aiImpact: {
4955
+ description: impact.ai,
4956
+ scoreImpact: severity === "critical" ? -15 : -5
4957
+ },
4958
+ developerImpact: {
4959
+ description: impact.dev,
4960
+ productivityLoss
4961
+ },
4962
+ businessOutcome: {
4963
+ directCost: count * 12,
4964
+ opportunityCost: productivityLoss * 15e3,
4965
+ riskLevel: impact.risk
4966
+ }
4967
+ };
4968
+ }
4969
+
4877
4970
  // src/business/risk-metrics.ts
4878
4971
  function calculateKnowledgeConcentration(params) {
4879
4972
  const { uniqueConceptFiles, totalFiles, singleAuthorFiles, orphanFiles } = params;
@@ -4968,99 +5061,6 @@ function calculateComprehensionDifficulty(contextBudget, importDepth, fragmentat
4968
5061
  };
4969
5062
  }
4970
5063
 
4971
- // src/business-metrics.ts
4972
- function calculateBusinessROI(params) {
4973
- const model = getModelPreset(params.modelId || "claude-4.6");
4974
- const devCount = params.developerCount || 5;
4975
- const budget = calculateTokenBudget({
4976
- totalContextTokens: params.tokenWaste * 2.5,
4977
- wastedTokens: {
4978
- duplication: params.tokenWaste * 0.7,
4979
- fragmentation: params.tokenWaste * 0.3,
4980
- chattiness: 0
4981
- }
4982
- });
4983
- const cost = estimateCostFromBudget(budget, model, {
4984
- developerCount: devCount
4985
- });
4986
- const productivity = calculateProductivityImpact(params.issues);
4987
- const monthlySavings = cost.total;
4988
- const productivityGainHours = productivity.totalHours;
4989
- const annualValue = (monthlySavings + productivityGainHours * 75) * 12;
4990
- return {
4991
- monthlySavings: Math.round(monthlySavings),
4992
- productivityGainHours: Math.round(productivityGainHours),
4993
- annualValue: Math.round(annualValue)
4994
- };
4995
- }
4996
- function formatCost(cost) {
4997
- if (cost < 1) {
4998
- return `$${cost.toFixed(2)}`;
4999
- } else if (cost < 1e3) {
5000
- return `$${cost.toFixed(0)}`;
5001
- } else {
5002
- return `$${(cost / 1e3).toFixed(1)}k`;
5003
- }
5004
- }
5005
- function formatHours(hours) {
5006
- if (hours < 1) {
5007
- return `${Math.round(hours * 60)}min`;
5008
- } else if (hours < 8) {
5009
- return `${hours.toFixed(1)}h`;
5010
- } else if (hours < 40) {
5011
- return `${Math.round(hours)}h`;
5012
- } else {
5013
- return `${(hours / 40).toFixed(1)} weeks`;
5014
- }
5015
- }
5016
- function formatAcceptanceRate(rate) {
5017
- return `${Math.round(rate * 100)}%`;
5018
- }
5019
- function generateValueChain(params) {
5020
- const { issueType, count, severity } = params;
5021
- const impacts = {
5022
- "duplicate-pattern": {
5023
- ai: "Ambiguous context leads to code generation variants. AI picks wrong implementation 40% of the time.",
5024
- dev: "Developers must manually resolve conflicts between suggested variants.",
5025
- risk: "high"
5026
- },
5027
- "context-fragmentation": {
5028
- ai: "Context window overflow causes model to forget mid-file dependencies resulting in hallucinations.",
5029
- dev: "Slower AI responses and increased need for manual context pinning.",
5030
- risk: "critical"
5031
- },
5032
- "naming-inconsistency": {
5033
- ai: "Degraded intent inference. AI misidentifies domain concepts across file boundaries.",
5034
- dev: "Increased cognitive load for new devs during onboarding.",
5035
- risk: "moderate"
5036
- }
5037
- };
5038
- const impact = impacts[issueType] || {
5039
- ai: "Reduced suggestion quality.",
5040
- dev: "Slowed development velocity.",
5041
- risk: "moderate"
5042
- };
5043
- const productivityLoss = severity === "critical" ? 0.25 : severity === "major" ? 0.1 : 0.05;
5044
- return {
5045
- issueType,
5046
- technicalMetric: "Issue Count",
5047
- technicalValue: count,
5048
- aiImpact: {
5049
- description: impact.ai,
5050
- scoreImpact: severity === "critical" ? -15 : -5
5051
- },
5052
- developerImpact: {
5053
- description: impact.dev,
5054
- productivityLoss
5055
- },
5056
- businessOutcome: {
5057
- directCost: count * 12,
5058
- opportunityCost: productivityLoss * 15e3,
5059
- riskLevel: impact.risk
5060
- }
5061
- };
5062
- }
5063
-
5064
5064
  // src/index.ts
5065
5065
  init_tree_sitter_utils();
5066
5066
  init_typescript_parser();
@@ -5135,6 +5135,136 @@ function collectBaseFutureProofRecommendations(params) {
5135
5135
  return recommendations;
5136
5136
  }
5137
5137
 
5138
+ // src/future-proof-metrics.ts
5139
+ function calculateFutureProofScore(params) {
5140
+ const loadScore = 100 - params.cognitiveLoad.score;
5141
+ const entropyScore = 100 - params.patternEntropy.entropy * 100;
5142
+ const cohesionScore = params.conceptCohesion.score * 100;
5143
+ const overall = Math.round(
5144
+ loadScore * 0.4 + entropyScore * 0.3 + cohesionScore * 0.3
5145
+ );
5146
+ const factors = [
5147
+ {
5148
+ name: "Cognitive Load",
5149
+ impact: Math.round(loadScore - 50),
5150
+ description: params.cognitiveLoad.rating
5151
+ },
5152
+ {
5153
+ name: "Pattern Entropy",
5154
+ impact: Math.round(entropyScore - 50),
5155
+ description: params.patternEntropy.rating
5156
+ },
5157
+ {
5158
+ name: "Concept Cohesion",
5159
+ impact: Math.round(cohesionScore - 50),
5160
+ description: params.conceptCohesion.rating
5161
+ }
5162
+ ];
5163
+ const recommendations = collectBaseFutureProofRecommendations({
5164
+ patternEntropy: params.patternEntropy,
5165
+ conceptCohesion: params.conceptCohesion
5166
+ });
5167
+ const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
5168
+ return {
5169
+ toolName: "future-proof",
5170
+ score: overall,
5171
+ rawMetrics: {
5172
+ cognitiveLoadScore: params.cognitiveLoad.score,
5173
+ entropyScore: params.patternEntropy.entropy,
5174
+ cohesionScore: params.conceptCohesion.score,
5175
+ semanticDistanceAvg
5176
+ },
5177
+ factors,
5178
+ recommendations
5179
+ };
5180
+ }
5181
+ function calculateExtendedFutureProofScore(params) {
5182
+ const loadScore = 100 - params.cognitiveLoad.score;
5183
+ const entropyScore = 100 - params.patternEntropy.entropy * 100;
5184
+ const cohesionScore = params.conceptCohesion.score * 100;
5185
+ const aiSignalClarityScore = 100 - params.aiSignalClarity.score;
5186
+ const groundingScore = params.agentGrounding.score;
5187
+ const testabilityScore = params.testability.score;
5188
+ const docDriftScore = params.docDrift ? 100 - params.docDrift.score : 100;
5189
+ const depsHealthScore = params.dependencyHealth?.score ?? 100;
5190
+ let totalWeight = 0.8;
5191
+ let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 + aiSignalClarityScore * 0.15 + groundingScore * 0.15 + testabilityScore * 0.15;
5192
+ if (params.docDrift) {
5193
+ overall += docDriftScore * 0.1;
5194
+ totalWeight += 0.1;
5195
+ }
5196
+ if (params.dependencyHealth) {
5197
+ overall += depsHealthScore * 0.1;
5198
+ totalWeight += 0.1;
5199
+ }
5200
+ overall = Math.round(overall / totalWeight);
5201
+ const factors = [
5202
+ {
5203
+ name: "Cognitive Load",
5204
+ impact: Math.round(loadScore - 50),
5205
+ description: params.cognitiveLoad.rating
5206
+ },
5207
+ {
5208
+ name: "Pattern Entropy",
5209
+ impact: Math.round(entropyScore - 50),
5210
+ description: params.patternEntropy.rating
5211
+ },
5212
+ {
5213
+ name: "Concept Cohesion",
5214
+ impact: Math.round(cohesionScore - 50),
5215
+ description: params.conceptCohesion.rating
5216
+ },
5217
+ {
5218
+ name: "AI Signal Clarity",
5219
+ impact: Math.round(aiSignalClarityScore - 50),
5220
+ description: `${params.aiSignalClarity.rating} risk`
5221
+ },
5222
+ {
5223
+ name: "Agent Grounding",
5224
+ impact: Math.round(groundingScore - 50),
5225
+ description: params.agentGrounding.rating
5226
+ },
5227
+ {
5228
+ name: "Testability",
5229
+ impact: Math.round(testabilityScore - 50),
5230
+ description: params.testability.rating
5231
+ }
5232
+ ];
5233
+ if (params.docDrift) {
5234
+ factors.push({
5235
+ name: "Documentation Drift",
5236
+ impact: Math.round(docDriftScore - 50),
5237
+ description: params.docDrift.rating
5238
+ });
5239
+ }
5240
+ if (params.dependencyHealth) {
5241
+ factors.push({
5242
+ name: "Dependency Health",
5243
+ impact: Math.round(depsHealthScore - 50),
5244
+ description: params.dependencyHealth.rating
5245
+ });
5246
+ }
5247
+ const recommendations = collectFutureProofRecommendations(params);
5248
+ const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
5249
+ return {
5250
+ toolName: "future-proof",
5251
+ score: overall,
5252
+ rawMetrics: {
5253
+ cognitiveLoadScore: params.cognitiveLoad.score,
5254
+ entropyScore: params.patternEntropy.entropy,
5255
+ cohesionScore: params.conceptCohesion.score,
5256
+ aiSignalClarityScore: params.aiSignalClarity.score,
5257
+ agentGroundingScore: params.agentGrounding.score,
5258
+ testabilityScore: params.testability.score,
5259
+ docDriftScore: params.docDrift?.score,
5260
+ dependencyHealthScore: params.dependencyHealth?.score,
5261
+ semanticDistanceAvg
5262
+ },
5263
+ factors,
5264
+ recommendations
5265
+ };
5266
+ }
5267
+
5138
5268
  // src/metrics/cognitive-load.ts
5139
5269
  function calculateCognitiveLoad(params) {
5140
5270
  const {
@@ -5341,136 +5471,6 @@ function calculateConceptCohesion(params) {
5341
5471
  };
5342
5472
  }
5343
5473
 
5344
- // src/future-proof-metrics.ts
5345
- function calculateFutureProofScore(params) {
5346
- const loadScore = 100 - params.cognitiveLoad.score;
5347
- const entropyScore = 100 - params.patternEntropy.entropy * 100;
5348
- const cohesionScore = params.conceptCohesion.score * 100;
5349
- const overall = Math.round(
5350
- loadScore * 0.4 + entropyScore * 0.3 + cohesionScore * 0.3
5351
- );
5352
- const factors = [
5353
- {
5354
- name: "Cognitive Load",
5355
- impact: Math.round(loadScore - 50),
5356
- description: params.cognitiveLoad.rating
5357
- },
5358
- {
5359
- name: "Pattern Entropy",
5360
- impact: Math.round(entropyScore - 50),
5361
- description: params.patternEntropy.rating
5362
- },
5363
- {
5364
- name: "Concept Cohesion",
5365
- impact: Math.round(cohesionScore - 50),
5366
- description: params.conceptCohesion.rating
5367
- }
5368
- ];
5369
- const recommendations = collectBaseFutureProofRecommendations({
5370
- patternEntropy: params.patternEntropy,
5371
- conceptCohesion: params.conceptCohesion
5372
- });
5373
- const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
5374
- return {
5375
- toolName: "future-proof",
5376
- score: overall,
5377
- rawMetrics: {
5378
- cognitiveLoadScore: params.cognitiveLoad.score,
5379
- entropyScore: params.patternEntropy.entropy,
5380
- cohesionScore: params.conceptCohesion.score,
5381
- semanticDistanceAvg
5382
- },
5383
- factors,
5384
- recommendations
5385
- };
5386
- }
5387
- function calculateExtendedFutureProofScore(params) {
5388
- const loadScore = 100 - params.cognitiveLoad.score;
5389
- const entropyScore = 100 - params.patternEntropy.entropy * 100;
5390
- const cohesionScore = params.conceptCohesion.score * 100;
5391
- const aiSignalClarityScore = 100 - params.aiSignalClarity.score;
5392
- const groundingScore = params.agentGrounding.score;
5393
- const testabilityScore = params.testability.score;
5394
- const docDriftScore = params.docDrift ? 100 - params.docDrift.score : 100;
5395
- const depsHealthScore = params.dependencyHealth?.score ?? 100;
5396
- let totalWeight = 0.8;
5397
- let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 + aiSignalClarityScore * 0.15 + groundingScore * 0.15 + testabilityScore * 0.15;
5398
- if (params.docDrift) {
5399
- overall += docDriftScore * 0.1;
5400
- totalWeight += 0.1;
5401
- }
5402
- if (params.dependencyHealth) {
5403
- overall += depsHealthScore * 0.1;
5404
- totalWeight += 0.1;
5405
- }
5406
- overall = Math.round(overall / totalWeight);
5407
- const factors = [
5408
- {
5409
- name: "Cognitive Load",
5410
- impact: Math.round(loadScore - 50),
5411
- description: params.cognitiveLoad.rating
5412
- },
5413
- {
5414
- name: "Pattern Entropy",
5415
- impact: Math.round(entropyScore - 50),
5416
- description: params.patternEntropy.rating
5417
- },
5418
- {
5419
- name: "Concept Cohesion",
5420
- impact: Math.round(cohesionScore - 50),
5421
- description: params.conceptCohesion.rating
5422
- },
5423
- {
5424
- name: "AI Signal Clarity",
5425
- impact: Math.round(aiSignalClarityScore - 50),
5426
- description: `${params.aiSignalClarity.rating} risk`
5427
- },
5428
- {
5429
- name: "Agent Grounding",
5430
- impact: Math.round(groundingScore - 50),
5431
- description: params.agentGrounding.rating
5432
- },
5433
- {
5434
- name: "Testability",
5435
- impact: Math.round(testabilityScore - 50),
5436
- description: params.testability.rating
5437
- }
5438
- ];
5439
- if (params.docDrift) {
5440
- factors.push({
5441
- name: "Documentation Drift",
5442
- impact: Math.round(docDriftScore - 50),
5443
- description: params.docDrift.rating
5444
- });
5445
- }
5446
- if (params.dependencyHealth) {
5447
- factors.push({
5448
- name: "Dependency Health",
5449
- impact: Math.round(depsHealthScore - 50),
5450
- description: params.dependencyHealth.rating
5451
- });
5452
- }
5453
- const recommendations = collectFutureProofRecommendations(params);
5454
- const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
5455
- return {
5456
- toolName: "future-proof",
5457
- score: overall,
5458
- rawMetrics: {
5459
- cognitiveLoadScore: params.cognitiveLoad.score,
5460
- entropyScore: params.patternEntropy.entropy,
5461
- cohesionScore: params.conceptCohesion.score,
5462
- aiSignalClarityScore: params.aiSignalClarity.score,
5463
- agentGroundingScore: params.agentGrounding.score,
5464
- testabilityScore: params.testability.score,
5465
- docDriftScore: params.docDrift?.score,
5466
- dependencyHealthScore: params.dependencyHealth?.score,
5467
- semanticDistanceAvg
5468
- },
5469
- factors,
5470
- recommendations
5471
- };
5472
- }
5473
-
5474
5474
  // src/metrics/ai-signal-clarity.ts
5475
5475
  function calculateAiSignalClarity(params) {
5476
5476
  const {