@aiready/core 0.23.21 → 0.23.22

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.mjs CHANGED
@@ -52,7 +52,7 @@ import {
52
52
  getToolWeight,
53
53
  normalizeToolName,
54
54
  parseWeightString
55
- } from "./chunk-WVNVC2PP.mjs";
55
+ } from "./chunk-E55RNGGK.mjs";
56
56
  import {
57
57
  TypeScriptParser
58
58
  } from "./chunk-UTCRW3N7.mjs";
@@ -2026,6 +2026,99 @@ function predictAcceptanceRate(toolOutputs) {
2026
2026
  return { rate: Math.round(rate * 100) / 100, confidence, factors };
2027
2027
  }
2028
2028
 
2029
+ // src/business-metrics.ts
2030
+ function calculateBusinessROI(params) {
2031
+ const model = getModelPreset(params.modelId || "claude-4.6");
2032
+ const devCount = params.developerCount || 5;
2033
+ const budget = calculateTokenBudget({
2034
+ totalContextTokens: params.tokenWaste * 2.5,
2035
+ wastedTokens: {
2036
+ duplication: params.tokenWaste * 0.7,
2037
+ fragmentation: params.tokenWaste * 0.3,
2038
+ chattiness: 0
2039
+ }
2040
+ });
2041
+ const cost = estimateCostFromBudget(budget, model, {
2042
+ developerCount: devCount
2043
+ });
2044
+ const productivity = calculateProductivityImpact(params.issues);
2045
+ const monthlySavings = cost.total;
2046
+ const productivityGainHours = productivity.totalHours;
2047
+ const annualValue = (monthlySavings + productivityGainHours * 75) * 12;
2048
+ return {
2049
+ monthlySavings: Math.round(monthlySavings),
2050
+ productivityGainHours: Math.round(productivityGainHours),
2051
+ annualValue: Math.round(annualValue)
2052
+ };
2053
+ }
2054
+ function formatCost(cost) {
2055
+ if (cost < 1) {
2056
+ return `$${cost.toFixed(2)}`;
2057
+ } else if (cost < 1e3) {
2058
+ return `$${cost.toFixed(0)}`;
2059
+ } else {
2060
+ return `$${(cost / 1e3).toFixed(1)}k`;
2061
+ }
2062
+ }
2063
+ function formatHours(hours) {
2064
+ if (hours < 1) {
2065
+ return `${Math.round(hours * 60)}min`;
2066
+ } else if (hours < 8) {
2067
+ return `${hours.toFixed(1)}h`;
2068
+ } else if (hours < 40) {
2069
+ return `${Math.round(hours)}h`;
2070
+ } else {
2071
+ return `${(hours / 40).toFixed(1)} weeks`;
2072
+ }
2073
+ }
2074
+ function formatAcceptanceRate(rate) {
2075
+ return `${Math.round(rate * 100)}%`;
2076
+ }
2077
+ function generateValueChain(params) {
2078
+ const { issueType, count, severity } = params;
2079
+ const impacts = {
2080
+ "duplicate-pattern": {
2081
+ ai: "Ambiguous context leads to code generation variants. AI picks wrong implementation 40% of the time.",
2082
+ dev: "Developers must manually resolve conflicts between suggested variants.",
2083
+ risk: "high"
2084
+ },
2085
+ "context-fragmentation": {
2086
+ ai: "Context window overflow causes model to forget mid-file dependencies resulting in hallucinations.",
2087
+ dev: "Slower AI responses and increased need for manual context pinning.",
2088
+ risk: "critical"
2089
+ },
2090
+ "naming-inconsistency": {
2091
+ ai: "Degraded intent inference. AI misidentifies domain concepts across file boundaries.",
2092
+ dev: "Increased cognitive load for new devs during onboarding.",
2093
+ risk: "moderate"
2094
+ }
2095
+ };
2096
+ const impact = impacts[issueType] || {
2097
+ ai: "Reduced suggestion quality.",
2098
+ dev: "Slowed development velocity.",
2099
+ risk: "moderate"
2100
+ };
2101
+ const productivityLoss = severity === "critical" ? 0.25 : severity === "major" ? 0.1 : 0.05;
2102
+ return {
2103
+ issueType,
2104
+ technicalMetric: "Issue Count",
2105
+ technicalValue: count,
2106
+ aiImpact: {
2107
+ description: impact.ai,
2108
+ scoreImpact: severity === "critical" ? -15 : -5
2109
+ },
2110
+ developerImpact: {
2111
+ description: impact.dev,
2112
+ productivityLoss
2113
+ },
2114
+ businessOutcome: {
2115
+ directCost: count * 12,
2116
+ opportunityCost: productivityLoss * 15e3,
2117
+ riskLevel: impact.risk
2118
+ }
2119
+ };
2120
+ }
2121
+
2029
2122
  // src/business/risk-metrics.ts
2030
2123
  function calculateKnowledgeConcentration(params) {
2031
2124
  const { uniqueConceptFiles, totalFiles, singleAuthorFiles, orphanFiles } = params;
@@ -2120,99 +2213,6 @@ function calculateComprehensionDifficulty(contextBudget, importDepth, fragmentat
2120
2213
  };
2121
2214
  }
2122
2215
 
2123
- // src/business-metrics.ts
2124
- function calculateBusinessROI(params) {
2125
- const model = getModelPreset(params.modelId || "claude-4.6");
2126
- const devCount = params.developerCount || 5;
2127
- const budget = calculateTokenBudget({
2128
- totalContextTokens: params.tokenWaste * 2.5,
2129
- wastedTokens: {
2130
- duplication: params.tokenWaste * 0.7,
2131
- fragmentation: params.tokenWaste * 0.3,
2132
- chattiness: 0
2133
- }
2134
- });
2135
- const cost = estimateCostFromBudget(budget, model, {
2136
- developerCount: devCount
2137
- });
2138
- const productivity = calculateProductivityImpact(params.issues);
2139
- const monthlySavings = cost.total;
2140
- const productivityGainHours = productivity.totalHours;
2141
- const annualValue = (monthlySavings + productivityGainHours * 75) * 12;
2142
- return {
2143
- monthlySavings: Math.round(monthlySavings),
2144
- productivityGainHours: Math.round(productivityGainHours),
2145
- annualValue: Math.round(annualValue)
2146
- };
2147
- }
2148
- function formatCost(cost) {
2149
- if (cost < 1) {
2150
- return `$${cost.toFixed(2)}`;
2151
- } else if (cost < 1e3) {
2152
- return `$${cost.toFixed(0)}`;
2153
- } else {
2154
- return `$${(cost / 1e3).toFixed(1)}k`;
2155
- }
2156
- }
2157
- function formatHours(hours) {
2158
- if (hours < 1) {
2159
- return `${Math.round(hours * 60)}min`;
2160
- } else if (hours < 8) {
2161
- return `${hours.toFixed(1)}h`;
2162
- } else if (hours < 40) {
2163
- return `${Math.round(hours)}h`;
2164
- } else {
2165
- return `${(hours / 40).toFixed(1)} weeks`;
2166
- }
2167
- }
2168
- function formatAcceptanceRate(rate) {
2169
- return `${Math.round(rate * 100)}%`;
2170
- }
2171
- function generateValueChain(params) {
2172
- const { issueType, count, severity } = params;
2173
- const impacts = {
2174
- "duplicate-pattern": {
2175
- ai: "Ambiguous context leads to code generation variants. AI picks wrong implementation 40% of the time.",
2176
- dev: "Developers must manually resolve conflicts between suggested variants.",
2177
- risk: "high"
2178
- },
2179
- "context-fragmentation": {
2180
- ai: "Context window overflow causes model to forget mid-file dependencies resulting in hallucinations.",
2181
- dev: "Slower AI responses and increased need for manual context pinning.",
2182
- risk: "critical"
2183
- },
2184
- "naming-inconsistency": {
2185
- ai: "Degraded intent inference. AI misidentifies domain concepts across file boundaries.",
2186
- dev: "Increased cognitive load for new devs during onboarding.",
2187
- risk: "moderate"
2188
- }
2189
- };
2190
- const impact = impacts[issueType] || {
2191
- ai: "Reduced suggestion quality.",
2192
- dev: "Slowed development velocity.",
2193
- risk: "moderate"
2194
- };
2195
- const productivityLoss = severity === "critical" ? 0.25 : severity === "major" ? 0.1 : 0.05;
2196
- return {
2197
- issueType,
2198
- technicalMetric: "Issue Count",
2199
- technicalValue: count,
2200
- aiImpact: {
2201
- description: impact.ai,
2202
- scoreImpact: severity === "critical" ? -15 : -5
2203
- },
2204
- developerImpact: {
2205
- description: impact.dev,
2206
- productivityLoss
2207
- },
2208
- businessOutcome: {
2209
- directCost: count * 12,
2210
- opportunityCost: productivityLoss * 15e3,
2211
- riskLevel: impact.risk
2212
- }
2213
- };
2214
- }
2215
-
2216
2216
  // src/metrics/remediation-utils.ts
2217
2217
  function collectFutureProofRecommendations(params) {
2218
2218
  const recommendations = [];
@@ -2279,6 +2279,136 @@ function collectBaseFutureProofRecommendations(params) {
2279
2279
  return recommendations;
2280
2280
  }
2281
2281
 
2282
+ // src/future-proof-metrics.ts
2283
+ function calculateFutureProofScore(params) {
2284
+ const loadScore = 100 - params.cognitiveLoad.score;
2285
+ const entropyScore = 100 - params.patternEntropy.entropy * 100;
2286
+ const cohesionScore = params.conceptCohesion.score * 100;
2287
+ const overall = Math.round(
2288
+ loadScore * 0.4 + entropyScore * 0.3 + cohesionScore * 0.3
2289
+ );
2290
+ const factors = [
2291
+ {
2292
+ name: "Cognitive Load",
2293
+ impact: Math.round(loadScore - 50),
2294
+ description: params.cognitiveLoad.rating
2295
+ },
2296
+ {
2297
+ name: "Pattern Entropy",
2298
+ impact: Math.round(entropyScore - 50),
2299
+ description: params.patternEntropy.rating
2300
+ },
2301
+ {
2302
+ name: "Concept Cohesion",
2303
+ impact: Math.round(cohesionScore - 50),
2304
+ description: params.conceptCohesion.rating
2305
+ }
2306
+ ];
2307
+ const recommendations = collectBaseFutureProofRecommendations({
2308
+ patternEntropy: params.patternEntropy,
2309
+ conceptCohesion: params.conceptCohesion
2310
+ });
2311
+ const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
2312
+ return {
2313
+ toolName: "future-proof",
2314
+ score: overall,
2315
+ rawMetrics: {
2316
+ cognitiveLoadScore: params.cognitiveLoad.score,
2317
+ entropyScore: params.patternEntropy.entropy,
2318
+ cohesionScore: params.conceptCohesion.score,
2319
+ semanticDistanceAvg
2320
+ },
2321
+ factors,
2322
+ recommendations
2323
+ };
2324
+ }
2325
+ function calculateExtendedFutureProofScore(params) {
2326
+ const loadScore = 100 - params.cognitiveLoad.score;
2327
+ const entropyScore = 100 - params.patternEntropy.entropy * 100;
2328
+ const cohesionScore = params.conceptCohesion.score * 100;
2329
+ const aiSignalClarityScore = 100 - params.aiSignalClarity.score;
2330
+ const groundingScore = params.agentGrounding.score;
2331
+ const testabilityScore = params.testability.score;
2332
+ const docDriftScore = params.docDrift ? 100 - params.docDrift.score : 100;
2333
+ const depsHealthScore = params.dependencyHealth?.score ?? 100;
2334
+ let totalWeight = 0.8;
2335
+ let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 + aiSignalClarityScore * 0.15 + groundingScore * 0.15 + testabilityScore * 0.15;
2336
+ if (params.docDrift) {
2337
+ overall += docDriftScore * 0.1;
2338
+ totalWeight += 0.1;
2339
+ }
2340
+ if (params.dependencyHealth) {
2341
+ overall += depsHealthScore * 0.1;
2342
+ totalWeight += 0.1;
2343
+ }
2344
+ overall = Math.round(overall / totalWeight);
2345
+ const factors = [
2346
+ {
2347
+ name: "Cognitive Load",
2348
+ impact: Math.round(loadScore - 50),
2349
+ description: params.cognitiveLoad.rating
2350
+ },
2351
+ {
2352
+ name: "Pattern Entropy",
2353
+ impact: Math.round(entropyScore - 50),
2354
+ description: params.patternEntropy.rating
2355
+ },
2356
+ {
2357
+ name: "Concept Cohesion",
2358
+ impact: Math.round(cohesionScore - 50),
2359
+ description: params.conceptCohesion.rating
2360
+ },
2361
+ {
2362
+ name: "AI Signal Clarity",
2363
+ impact: Math.round(aiSignalClarityScore - 50),
2364
+ description: `${params.aiSignalClarity.rating} risk`
2365
+ },
2366
+ {
2367
+ name: "Agent Grounding",
2368
+ impact: Math.round(groundingScore - 50),
2369
+ description: params.agentGrounding.rating
2370
+ },
2371
+ {
2372
+ name: "Testability",
2373
+ impact: Math.round(testabilityScore - 50),
2374
+ description: params.testability.rating
2375
+ }
2376
+ ];
2377
+ if (params.docDrift) {
2378
+ factors.push({
2379
+ name: "Documentation Drift",
2380
+ impact: Math.round(docDriftScore - 50),
2381
+ description: params.docDrift.rating
2382
+ });
2383
+ }
2384
+ if (params.dependencyHealth) {
2385
+ factors.push({
2386
+ name: "Dependency Health",
2387
+ impact: Math.round(depsHealthScore - 50),
2388
+ description: params.dependencyHealth.rating
2389
+ });
2390
+ }
2391
+ const recommendations = collectFutureProofRecommendations(params);
2392
+ const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
2393
+ return {
2394
+ toolName: "future-proof",
2395
+ score: overall,
2396
+ rawMetrics: {
2397
+ cognitiveLoadScore: params.cognitiveLoad.score,
2398
+ entropyScore: params.patternEntropy.entropy,
2399
+ cohesionScore: params.conceptCohesion.score,
2400
+ aiSignalClarityScore: params.aiSignalClarity.score,
2401
+ agentGroundingScore: params.agentGrounding.score,
2402
+ testabilityScore: params.testability.score,
2403
+ docDriftScore: params.docDrift?.score,
2404
+ dependencyHealthScore: params.dependencyHealth?.score,
2405
+ semanticDistanceAvg
2406
+ },
2407
+ factors,
2408
+ recommendations
2409
+ };
2410
+ }
2411
+
2282
2412
  // src/metrics/cognitive-load.ts
2283
2413
  function calculateCognitiveLoad(params) {
2284
2414
  const {
@@ -2485,136 +2615,6 @@ function calculateConceptCohesion(params) {
2485
2615
  };
2486
2616
  }
2487
2617
 
2488
- // src/future-proof-metrics.ts
2489
- function calculateFutureProofScore(params) {
2490
- const loadScore = 100 - params.cognitiveLoad.score;
2491
- const entropyScore = 100 - params.patternEntropy.entropy * 100;
2492
- const cohesionScore = params.conceptCohesion.score * 100;
2493
- const overall = Math.round(
2494
- loadScore * 0.4 + entropyScore * 0.3 + cohesionScore * 0.3
2495
- );
2496
- const factors = [
2497
- {
2498
- name: "Cognitive Load",
2499
- impact: Math.round(loadScore - 50),
2500
- description: params.cognitiveLoad.rating
2501
- },
2502
- {
2503
- name: "Pattern Entropy",
2504
- impact: Math.round(entropyScore - 50),
2505
- description: params.patternEntropy.rating
2506
- },
2507
- {
2508
- name: "Concept Cohesion",
2509
- impact: Math.round(cohesionScore - 50),
2510
- description: params.conceptCohesion.rating
2511
- }
2512
- ];
2513
- const recommendations = collectBaseFutureProofRecommendations({
2514
- patternEntropy: params.patternEntropy,
2515
- conceptCohesion: params.conceptCohesion
2516
- });
2517
- const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
2518
- return {
2519
- toolName: "future-proof",
2520
- score: overall,
2521
- rawMetrics: {
2522
- cognitiveLoadScore: params.cognitiveLoad.score,
2523
- entropyScore: params.patternEntropy.entropy,
2524
- cohesionScore: params.conceptCohesion.score,
2525
- semanticDistanceAvg
2526
- },
2527
- factors,
2528
- recommendations
2529
- };
2530
- }
2531
- function calculateExtendedFutureProofScore(params) {
2532
- const loadScore = 100 - params.cognitiveLoad.score;
2533
- const entropyScore = 100 - params.patternEntropy.entropy * 100;
2534
- const cohesionScore = params.conceptCohesion.score * 100;
2535
- const aiSignalClarityScore = 100 - params.aiSignalClarity.score;
2536
- const groundingScore = params.agentGrounding.score;
2537
- const testabilityScore = params.testability.score;
2538
- const docDriftScore = params.docDrift ? 100 - params.docDrift.score : 100;
2539
- const depsHealthScore = params.dependencyHealth?.score ?? 100;
2540
- let totalWeight = 0.8;
2541
- let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 + aiSignalClarityScore * 0.15 + groundingScore * 0.15 + testabilityScore * 0.15;
2542
- if (params.docDrift) {
2543
- overall += docDriftScore * 0.1;
2544
- totalWeight += 0.1;
2545
- }
2546
- if (params.dependencyHealth) {
2547
- overall += depsHealthScore * 0.1;
2548
- totalWeight += 0.1;
2549
- }
2550
- overall = Math.round(overall / totalWeight);
2551
- const factors = [
2552
- {
2553
- name: "Cognitive Load",
2554
- impact: Math.round(loadScore - 50),
2555
- description: params.cognitiveLoad.rating
2556
- },
2557
- {
2558
- name: "Pattern Entropy",
2559
- impact: Math.round(entropyScore - 50),
2560
- description: params.patternEntropy.rating
2561
- },
2562
- {
2563
- name: "Concept Cohesion",
2564
- impact: Math.round(cohesionScore - 50),
2565
- description: params.conceptCohesion.rating
2566
- },
2567
- {
2568
- name: "AI Signal Clarity",
2569
- impact: Math.round(aiSignalClarityScore - 50),
2570
- description: `${params.aiSignalClarity.rating} risk`
2571
- },
2572
- {
2573
- name: "Agent Grounding",
2574
- impact: Math.round(groundingScore - 50),
2575
- description: params.agentGrounding.rating
2576
- },
2577
- {
2578
- name: "Testability",
2579
- impact: Math.round(testabilityScore - 50),
2580
- description: params.testability.rating
2581
- }
2582
- ];
2583
- if (params.docDrift) {
2584
- factors.push({
2585
- name: "Documentation Drift",
2586
- impact: Math.round(docDriftScore - 50),
2587
- description: params.docDrift.rating
2588
- });
2589
- }
2590
- if (params.dependencyHealth) {
2591
- factors.push({
2592
- name: "Dependency Health",
2593
- impact: Math.round(depsHealthScore - 50),
2594
- description: params.dependencyHealth.rating
2595
- });
2596
- }
2597
- const recommendations = collectFutureProofRecommendations(params);
2598
- const semanticDistanceAvg = params.semanticDistances?.length ? params.semanticDistances.reduce((s, d) => s + d.distance, 0) / params.semanticDistances.length : 0;
2599
- return {
2600
- toolName: "future-proof",
2601
- score: overall,
2602
- rawMetrics: {
2603
- cognitiveLoadScore: params.cognitiveLoad.score,
2604
- entropyScore: params.patternEntropy.entropy,
2605
- cohesionScore: params.conceptCohesion.score,
2606
- aiSignalClarityScore: params.aiSignalClarity.score,
2607
- agentGroundingScore: params.agentGrounding.score,
2608
- testabilityScore: params.testability.score,
2609
- docDriftScore: params.docDrift?.score,
2610
- dependencyHealthScore: params.dependencyHealth?.score,
2611
- semanticDistanceAvg
2612
- },
2613
- factors,
2614
- recommendations
2615
- };
2616
- }
2617
-
2618
2618
  // src/metrics/ai-signal-clarity.ts
2619
2619
  function calculateAiSignalClarity(params) {
2620
2620
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.23.21",
3
+ "version": "0.23.22",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -12,9 +12,9 @@
12
12
  "import": "./dist/index.mjs"
13
13
  },
14
14
  "./client": {
15
- "types": "./dist/client.d.ts",
16
- "require": "./dist/client.js",
17
- "import": "./dist/client.mjs"
15
+ "types": "./dist/client/index.d.ts",
16
+ "require": "./dist/client/index.js",
17
+ "import": "./dist/client/index.mjs"
18
18
  }
19
19
  },
20
20
  "keywords": [
@@ -57,8 +57,8 @@
57
57
  "zod": "^4.3.6"
58
58
  },
59
59
  "scripts": {
60
- "build": "tsup src/index.ts src/client.ts --format cjs,esm --dts",
61
- "dev": "tsup src/index.ts src/client.ts --format cjs,esm --watch",
60
+ "build": "tsup src/index.ts src/client/index.ts --format cjs,esm --dts",
61
+ "dev": "tsup src/index.ts src/client/index.ts --format cjs,esm --watch",
62
62
  "test": "vitest run --hookTimeout=30000",
63
63
  "lint": "eslint src",
64
64
  "clean": "rm -rf dist",