@aiready/core 0.23.15 → 0.23.20

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
@@ -41,16 +41,20 @@ import {
41
41
  formatScore,
42
42
  formatToolScore,
43
43
  generateHTML,
44
+ getPriorityIcon,
44
45
  getProjectSizeTier,
45
46
  getRating,
46
47
  getRatingDisplay,
48
+ getRatingEmoji,
49
+ getRatingLabel,
47
50
  getRatingSlug,
48
51
  getRatingWithContext,
49
52
  getRecommendedThreshold,
53
+ getToolEmoji,
50
54
  getToolWeight,
51
55
  normalizeToolName,
52
56
  parseWeightString
53
- } from "./chunk-CGOS2J6T.mjs";
57
+ } from "./chunk-SQHS6PFL.mjs";
54
58
 
55
59
  // src/utils/normalization.ts
56
60
  function normalizeIssue(raw) {
@@ -2947,6 +2951,83 @@ function mergeConfigWithDefaults(userConfig, defaults) {
2947
2951
  return mergedConfig;
2948
2952
  }
2949
2953
 
2954
+ // src/utils/html-report-builder.ts
2955
+ function generateReportHead(title) {
2956
+ return `<!DOCTYPE html>
2957
+ <html lang="en">
2958
+ <head>
2959
+ <meta charset="UTF-8">
2960
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2961
+ <title>${title}</title>
2962
+ <style>
2963
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; line-height: 1.6; color: #333; max-width: 1200px; margin: 0 auto; padding: 2rem; background-color: #f9f9f9; }
2964
+ h1, h2, h3 { color: #1a1a1a; border-bottom: 2px solid #eaeaea; padding-bottom: 0.5rem; }
2965
+ .card { background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 2rem; border: 1px solid #eaeaea; }
2966
+ .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
2967
+ .stat-card { background: #fff; padding: 1rem; border-radius: 6px; text-align: center; border: 1px solid #eaeaea; }
2968
+ .stat-value { font-size: 1.8rem; font-weight: bold; color: #2563eb; }
2969
+ .stat-label { font-size: 0.875rem; color: #666; text-transform: uppercase; }
2970
+ table { width: 100%; border-collapse: collapse; margin-top: 1rem; background: white; border-radius: 4px; overflow: hidden; }
2971
+ th, td { text-align: left; padding: 0.875rem 1rem; border-bottom: 1px solid #eaeaea; }
2972
+ th { background-color: #f8fafc; font-weight: 600; color: #475569; }
2973
+ tr:last-child td { border-bottom: none; }
2974
+ .critical { color: #dc2626; font-weight: bold; }
2975
+ .major { color: #ea580c; font-weight: bold; }
2976
+ .minor { color: #2563eb; }
2977
+ code { background: #f1f5f9; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.875rem; color: #334155; }
2978
+ .footer { margin-top: 4rem; text-align: center; color: #94a3b8; font-size: 0.875rem; }
2979
+ </style>
2980
+ </head>`;
2981
+ }
2982
+ function generateStatCards(cards) {
2983
+ const cardsHtml = cards.map(
2984
+ (card) => `
2985
+ <div class="stat-card">
2986
+ <div class="stat-value"${card.color ? ` style="color: ${card.color}"` : ""}>${card.value}</div>
2987
+ <div class="stat-label">${card.label}</div>
2988
+ </div>`
2989
+ ).join("");
2990
+ return `<div class="stats">${cardsHtml}</div>`;
2991
+ }
2992
+ function generateTable(config) {
2993
+ const headersHtml = config.headers.map((h) => `<th>${h}</th>`).join("");
2994
+ const rowsHtml = config.rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("");
2995
+ return `<table>
2996
+ <thead><tr>${headersHtml}</tr></thead>
2997
+ <tbody>${rowsHtml}</tbody>
2998
+ </table>`;
2999
+ }
3000
+ function generateReportFooter(options) {
3001
+ const versionText = options.version ? ` v${options.version}` : "";
3002
+ const links = [];
3003
+ if (options.packageUrl) {
3004
+ links.push(`<a href="${options.packageUrl}">Star us on GitHub</a>`);
3005
+ }
3006
+ if (options.bugUrl) {
3007
+ links.push(`<a href="${options.bugUrl}">Report it here</a>`);
3008
+ }
3009
+ const linksHtml = links.length ? links.map((l) => `<p>Like AIReady? ${l}</p>`).join("\n ") : "";
3010
+ return `<div class="footer">
3011
+ <p>Generated by <strong>@aiready/${options.packageName}</strong>${versionText}</p>
3012
+ ${linksHtml}
3013
+ </div>`;
3014
+ }
3015
+ function wrapInCard(content, title) {
3016
+ const titleHtml = title ? `<h2>${title}</h2>` : "";
3017
+ return `<div class="card">
3018
+ ${titleHtml}
3019
+ ${content}
3020
+ </div>`;
3021
+ }
3022
+ function generateCompleteReport(options, bodyContent) {
3023
+ return `${generateReportHead(options.title)}
3024
+ <body>
3025
+ ${bodyContent}
3026
+ ${generateReportFooter(options)}
3027
+ </body>
3028
+ </html>`;
3029
+ }
3030
+
2950
3031
  // src/business/pricing-models.ts
2951
3032
  var MODEL_PRICING_PRESETS = {
2952
3033
  "gpt-5.4-mini": {
@@ -3010,20 +3091,52 @@ var DEFAULT_COST_CONFIG = {
3010
3091
  developerCount: 5,
3011
3092
  daysPerMonth: 30
3012
3093
  };
3013
- function calculateMonthlyCost(tokenWaste, config = {}) {
3014
- const multiplier = tokenWaste > 5e4 ? 5 : tokenWaste > 1e4 ? 3.5 : 2.5;
3094
+ function calculateMonthlyCost(tokenWaste, config = {}, options) {
3095
+ const baseMultiplier = tokenWaste > 5e4 ? 5 : tokenWaste > 1e4 ? 3.5 : 2.5;
3096
+ const contextMultiplier = options?.avgContextBudget ? options.avgContextBudget / Math.max(1, tokenWaste) : baseMultiplier;
3097
+ const fragRatio = options?.fragmentationScore ?? 0.3;
3098
+ const dupRatio = 1 - fragRatio;
3015
3099
  const budget = calculateTokenBudget({
3016
- totalContextTokens: tokenWaste * multiplier,
3100
+ totalContextTokens: tokenWaste * contextMultiplier,
3017
3101
  wastedTokens: {
3018
- duplication: tokenWaste * 0.7,
3019
- fragmentation: tokenWaste * 0.3,
3102
+ duplication: tokenWaste * dupRatio * (options?.potentialSavings ? 1.2 : 1),
3103
+ fragmentation: tokenWaste * fragRatio,
3020
3104
  chattiness: 0.1 * tokenWaste
3021
- // Added baseline chattiness
3022
3105
  }
3023
3106
  });
3024
- const preset = getModelPreset("gpt-5.4-mini");
3107
+ const preset = getModelPreset("claude-3.5-sonnet");
3025
3108
  return estimateCostFromBudget(budget, preset, config);
3026
3109
  }
3110
+ function calculateDetailedTokenROI(params) {
3111
+ const {
3112
+ totalTokens,
3113
+ avgContextBudget,
3114
+ potentialSavings,
3115
+ fragmentationScore,
3116
+ developerCount,
3117
+ queriesPerDevPerDay = 60
3118
+ } = params;
3119
+ const budget = calculateTokenBudget({
3120
+ totalContextTokens: avgContextBudget,
3121
+ wastedTokens: {
3122
+ duplication: potentialSavings * 0.8,
3123
+ // 80% of potential savings are duplication-based
3124
+ fragmentation: totalTokens * fragmentationScore * 0.5,
3125
+ // fragmentation impact
3126
+ chattiness: totalTokens * 0.1
3127
+ }
3128
+ });
3129
+ const model = getModelPreset("claude-3.5-sonnet");
3130
+ const cost = estimateCostFromBudget(budget, model, {
3131
+ developerCount,
3132
+ queriesPerDevPerDay
3133
+ });
3134
+ return {
3135
+ monthlySavings: Math.round(cost.total),
3136
+ contextTaxPerDev: Math.round(cost.total / (developerCount || 1) * 100) / 100,
3137
+ efficiencyGain: Math.round(budget.efficiencyRatio * 100) / 100
3138
+ };
3139
+ }
3027
3140
  function calculateTokenBudget(params) {
3028
3141
  const { totalContextTokens, wastedTokens } = params;
3029
3142
  const estimatedResponseTokens = params.estimatedResponseTokens ?? totalContextTokens * 0.2;
@@ -4550,6 +4663,7 @@ export {
4550
4663
  calculateConceptCohesion,
4551
4664
  calculateDebtInterest,
4552
4665
  calculateDependencyHealth,
4666
+ calculateDetailedTokenROI,
4553
4667
  calculateDocDrift,
4554
4668
  calculateExtendedFutureProofScore,
4555
4669
  calculateFutureProofScore,
@@ -4578,7 +4692,12 @@ export {
4578
4692
  formatHours,
4579
4693
  formatScore,
4580
4694
  formatToolScore,
4695
+ generateCompleteReport,
4581
4696
  generateHTML,
4697
+ generateReportFooter,
4698
+ generateReportHead,
4699
+ generateStatCards,
4700
+ generateTable,
4582
4701
  generateValueChain,
4583
4702
  getElapsedTime,
4584
4703
  getFileCommitTimestamps,
@@ -4587,9 +4706,12 @@ export {
4587
4706
  getLineRangeLastModifiedCached,
4588
4707
  getModelPreset,
4589
4708
  getParser,
4709
+ getPriorityIcon,
4590
4710
  getProjectSizeTier,
4591
4711
  getRating,
4592
4712
  getRatingDisplay,
4713
+ getRatingEmoji,
4714
+ getRatingLabel,
4593
4715
  getRatingSlug,
4594
4716
  getRatingWithContext,
4595
4717
  getRecommendedThreshold,
@@ -4602,6 +4724,7 @@ export {
4602
4724
  getSeverityLevel,
4603
4725
  getSeverityValue,
4604
4726
  getSupportedLanguages,
4727
+ getToolEmoji,
4605
4728
  getToolWeight,
4606
4729
  getWasmPath,
4607
4730
  groupIssuesByFile,
@@ -4631,5 +4754,6 @@ export {
4631
4754
  setupParser,
4632
4755
  severityToAnnotationLevel,
4633
4756
  validateSpokeOutput,
4634
- validateWithSchema
4757
+ validateWithSchema,
4758
+ wrapInCard
4635
4759
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.23.15",
3
+ "version": "0.23.20",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",