kynjal-cli 3.1.2 → 3.1.3

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.
@@ -305,14 +305,31 @@ function getSwarmStatus() {
305
305
  let activeAgents = 0;
306
306
  let coordinationActive = false;
307
307
 
308
+ // 1. Check metrics file first (written by swarm/agents during operation)
309
+ try {
310
+ const metricsPath = path.join(process.cwd(), '.claude-flow', 'metrics', 'swarm-activity.json');
311
+ if (fs.existsSync(metricsPath)) {
312
+ const metrics = JSON.parse(fs.readFileSync(metricsPath, 'utf-8'));
313
+ // Only trust metrics if updated within last 60 seconds
314
+ const age = Date.now() - (metrics.lastUpdated || 0);
315
+ if (age < 60000) {
316
+ activeAgents = metrics.activeAgents || 0;
317
+ coordinationActive = metrics.coordinationActive || activeAgents > 0;
318
+ return { activeAgents, maxAgents: CONFIG.maxAgents, coordinationActive };
319
+ }
320
+ }
321
+ } catch (e) {
322
+ // Fall through to process detection
323
+ }
324
+
325
+ // 2. Detect running agents from processes (safe: no user input in commands)
308
326
  try {
309
327
  if (isWindows) {
310
- // Windows: use tasklist and findstr
311
- const ps = execSync('tasklist 2>NUL | findstr /I "agentic-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });
328
+ const ps = execSync('tasklist 2>NUL | findstr /I "agentic-flow kynjalflow claude-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });
312
329
  activeAgents = Math.max(0, parseInt(ps.trim()) || 0);
313
330
  } else {
314
- const ps = execSync('ps aux 2>/dev/null | grep -c agentic-flow || echo "0"', { encoding: 'utf-8' });
315
- activeAgents = Math.max(0, parseInt(ps.trim()) - 1);
331
+ const ps = execSync('ps aux 2>/dev/null | grep -E "(agentic-flow|kynjalflow|claude-flow)" | grep -v grep | wc -l || echo "0"', { encoding: 'utf-8' });
332
+ activeAgents = Math.max(0, parseInt(ps.trim()) || 0);
316
333
  }
317
334
  coordinationActive = activeAgents > 0;
318
335
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kynjal-cli",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "type": "module",
5
5
  "description": "Claude Flow CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",