@link-assistant/hive-mind 1.6.0 → 1.6.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @link-assistant/hive-mind
2
2
 
3
+ ## 1.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b07fa91: Improve /limits output format for better clarity and consistency: use 5m load average for CPU calculation (matching /solve queue), show CPU cores as "X.XX/Y CPU cores used" format consistent with RAM and Disk display
8
+
3
9
  ## 1.6.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "AI-powered issue solver and hive mind for collaborative problem solving",
5
5
  "main": "src/hive.mjs",
6
6
  "type": "module",
@@ -139,6 +139,25 @@ function formatBytes(bytes) {
139
139
  return `${value.toFixed(decimals)} ${sizes[i]}`;
140
140
  }
141
141
 
142
+ /**
143
+ * Format two byte values into a combined "used/total UNIT used" format
144
+ * @param {number} usedBytes - Used size in bytes
145
+ * @param {number} totalBytes - Total size in bytes
146
+ * @returns {string} Formatted string (e.g., "2.8/11.7 GB used")
147
+ */
148
+ function formatBytesRange(usedBytes, totalBytes) {
149
+ if (totalBytes === 0) return '0/0 B used';
150
+ const k = 1024;
151
+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
152
+ // Determine unit based on total (larger value)
153
+ const i = Math.floor(Math.log(totalBytes) / Math.log(k));
154
+ const usedValue = usedBytes / Math.pow(k, i);
155
+ const totalValue = totalBytes / Math.pow(k, i);
156
+ // Use 1 decimal place for GB and above, none for smaller units
157
+ const decimals = i >= 3 ? 1 : 0;
158
+ return `${usedValue.toFixed(decimals)}/${totalValue.toFixed(decimals)} ${sizes[i]} used`;
159
+ }
160
+
142
161
  /**
143
162
  * Get GitHub API rate limits by calling gh api rate_limit
144
163
  * Returns rate limit info for core, search, graphql, and other resources
@@ -266,9 +285,10 @@ export async function getCpuLoadInfo(verbose = false) {
266
285
  };
267
286
  }
268
287
 
269
- // Calculate usage percentage based on load average vs CPU count
288
+ // Calculate usage percentage based on 5-minute load average vs CPU count
270
289
  // Load average of 1.0 per CPU = 100% utilization
271
- const usagePercentage = Math.min(100, Math.round((loadAvg1 / cpuCount) * 100));
290
+ // Using 5m average for consistency with solve queue (see issue #1137)
291
+ const usagePercentage = Math.min(100, Math.round((loadAvg5 / cpuCount) * 100));
272
292
 
273
293
  if (verbose) {
274
294
  console.log(`[VERBOSE] /limits CPU load: ${loadAvg1.toFixed(2)} (1m), ${loadAvg5.toFixed(2)} (5m), ${loadAvg15.toFixed(2)} (15m), ${cpuCount} CPUs, ${usagePercentage}% used`);
@@ -663,8 +683,9 @@ export function formatUsageMessage(usage, diskSpace = null, githubRateLimit = nu
663
683
  message += 'CPU\n';
664
684
  const usedBar = getProgressBar(cpuLoad.usagePercentage);
665
685
  message += `${usedBar} ${cpuLoad.usagePercentage}% used\n`;
666
- message += `Load avg: ${cpuLoad.loadAvg1.toFixed(2)} (1m) ${cpuLoad.loadAvg5.toFixed(2)} (5m) ${cpuLoad.loadAvg15.toFixed(2)} (15m)\n`;
667
- message += `${cpuLoad.cpuCount} CPU core${cpuLoad.cpuCount > 1 ? 's' : ''}\n\n`;
686
+ // Show cores used based on 5m load average (e.g., "0.04/6 CPU cores used" or "3/6 CPU cores used")
687
+ // Use parseFloat to strip unnecessary trailing zeros (3.00 -> 3, 0.10 -> 0.1, 0.04 -> 0.04)
688
+ message += `${parseFloat(cpuLoad.loadAvg5.toFixed(2))}/${cpuLoad.cpuCount} CPU cores used\n\n`;
668
689
  }
669
690
 
670
691
  // Memory section (if provided)
@@ -672,7 +693,7 @@ export function formatUsageMessage(usage, diskSpace = null, githubRateLimit = nu
672
693
  message += 'RAM\n';
673
694
  const usedBar = getProgressBar(memory.usedPercentage);
674
695
  message += `${usedBar} ${memory.usedPercentage}% used\n`;
675
- message += `${memory.usedFormatted} used of ${memory.totalFormatted}\n\n`;
696
+ message += `${formatBytesRange(memory.usedBytes, memory.totalBytes)}\n\n`;
676
697
  }
677
698
 
678
699
  // Disk space section (if provided)
@@ -681,7 +702,7 @@ export function formatUsageMessage(usage, diskSpace = null, githubRateLimit = nu
681
702
  // Show used percentage with progress bar
682
703
  const usedBar = getProgressBar(diskSpace.usedPercentage);
683
704
  message += `${usedBar} ${diskSpace.usedPercentage}% used\n`;
684
- message += `${diskSpace.usedFormatted} used of ${diskSpace.totalFormatted}\n\n`;
705
+ message += `${formatBytesRange(diskSpace.usedBytes, diskSpace.totalBytes)}\n\n`;
685
706
  }
686
707
 
687
708
  // GitHub API rate limits section (if provided)