@link-assistant/hive-mind 1.5.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,17 @@
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
+
9
+ ## 1.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 56d95bd: Add `--prompt-subagents-via-agent-commander` option to guide Claude to use agent-commander CLI for subagent delegation instead of native Task tool. This allows using any supported agent type (claude, opencode, codex, agent) with a unified API and saves main agent context. The prompt guidance is only included when agent-commander (start-agent) is actually installed on the system.
14
+
3
15
  ## 1.5.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.5.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",
@@ -25,21 +25,13 @@ const showResumeCommand = async (sessionId, tempDir, claudePath, model, log) =>
25
25
  await log(` ${cmd}\n`);
26
26
  };
27
27
 
28
- /**
29
- * Format numbers with spaces as thousands separator (no commas)
30
- * Per issue #667: Use spaces for thousands, . for decimals
31
- * @param {number|null|undefined} num - Number to format
32
- * @returns {string} Formatted number string
33
- */
28
+ /** Format numbers with spaces as thousands separator (no commas) */
34
29
  export const formatNumber = num => {
35
30
  if (num === null || num === undefined) return 'N/A';
36
- // Convert to string and split on decimal point
37
31
  const parts = num.toString().split('.');
38
32
  const integerPart = parts[0];
39
33
  const decimalPart = parts[1];
40
- // Add spaces every 3 digits from the right
41
34
  const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
42
- // Return with decimal part if it exists
43
35
  return decimalPart !== undefined ? `${formattedInteger}.${decimalPart}` : formattedInteger;
44
36
  };
45
37
  // Available model configurations
@@ -414,6 +406,18 @@ export const checkPlaywrightMcpAvailability = async () => {
414
406
  */
415
407
  export const executeClaude = async params => {
416
408
  const { issueUrl, issueNumber, prNumber, prUrl, branchName, tempDir, workspaceTmpDir, isContinueMode, mergeStateStatus, forkedRepo, feedbackLines, forkActionsUrl, owner, repo, argv, log, setLogFile, getLogFile, formatAligned, getResourceSnapshot, claudePath, $ } = params;
409
+
410
+ // Check if agent-commander is installed when the option is enabled
411
+ if (argv.promptSubagentsViaAgentCommander) {
412
+ try {
413
+ await $`which start-agent`;
414
+ argv.agentCommanderInstalled = true;
415
+ } catch {
416
+ argv.agentCommanderInstalled = false;
417
+ await log('⚠️ agent-commander not installed; prompt guidance will be skipped (npm i -g @link-assistant/agent-commander)');
418
+ }
419
+ }
420
+
417
421
  // Import prompt building functions from claude.prompts.lib.mjs
418
422
  const { buildUserPrompt, buildSystemPrompt } = await import('./claude.prompts.lib.mjs');
419
423
  // Build the user prompt
@@ -282,6 +282,31 @@ Plan sub-agent usage.
282
282
  - When using the Plan sub-agent, you can add it as the first item in your todo list.
283
283
  - When you delegate planning, use the Task tool with subagent_type="Plan" before starting implementation work.`
284
284
  : ''
285
+ }${
286
+ argv && argv.promptSubagentsViaAgentCommander && argv.agentCommanderInstalled
287
+ ? `
288
+
289
+ Agent Commander usage (unified subagent delegation).
290
+ - When you need to delegate tasks to subagents, use the agent-commander CLI tool (start-agent) instead of the native Task tool.
291
+ - Agent Commander provides a unified API for different agent types (claude, opencode, codex, agent) and supports various isolation modes.
292
+ - To delegate a task, use the Bash tool to run start-agent with appropriate parameters:
293
+ \`\`\`bash
294
+ start-agent --tool claude --working-directory "$(pwd)" --prompt "Your task description here"
295
+ \`\`\`
296
+ - Common start-agent parameters:
297
+ --tool <name>: Agent to use (claude, opencode, codex, agent)
298
+ --working-directory <path>: Execution directory (use current directory for context)
299
+ --prompt <text>: The task to delegate
300
+ --model <name>: Model to use (sonnet, opus, haiku, grok, etc.)
301
+ --isolation <mode>: Execution context (none, screen, docker)
302
+ --detached: Run in background mode
303
+ - Examples:
304
+ Explore codebase: start-agent --tool claude --working-directory "$(pwd)" --prompt "Explore the codebase structure and find how authentication is implemented"
305
+ Run with specific model: start-agent --tool claude --working-directory "$(pwd)" --model opus --prompt "Review this complex algorithm"
306
+ Use different agent: start-agent --tool opencode --working-directory "$(pwd)" --model grok --prompt "Analyze performance issues"
307
+ - Benefits: Saves main agent context, supports any agent type, provides unified API across different AI tools.
308
+ - Note: The subagent will have access to the same working directory and can read/write files as needed.`
309
+ : ''
285
310
  }${ciExamples}${getArchitectureCareSubPrompt(argv)}`;
286
311
  };
287
312
 
@@ -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)
@@ -326,6 +326,11 @@ export const createYargsConfig = yargsInstance => {
326
326
  description: 'Automatically repair git configuration using gh-setup-git-identity --repair when git identity is not configured. Requires gh-setup-git-identity to be installed.',
327
327
  default: false,
328
328
  })
329
+ .option('prompt-subagents-via-agent-commander', {
330
+ type: 'boolean',
331
+ description: 'Guide Claude to use agent-commander CLI (start-agent) instead of native Task tool for subagent delegation. Allows using any supported agent type (claude, opencode, codex, agent) with unified API. Only works with --tool claude and requires agent-commander to be installed.',
332
+ default: false,
333
+ })
329
334
  .parserConfiguration({
330
335
  'boolean-negation': true,
331
336
  })