claude-flow 3.5.29 → 3.5.30

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.
@@ -236,49 +236,64 @@ function getV3Progress() {
236
236
 
237
237
  // Security status (pure file reads)
238
238
  function getSecurityStatus() {
239
- const totalCves = 3;
240
239
  const auditData = readJSON(path.join(CWD, '.claude-flow', 'security', 'audit-status.json'));
241
240
  if (auditData) {
241
+ // Check freshness — flag if audit is older than 7 days
242
+ const auditAge = auditData.lastAudit ? Date.now() - new Date(auditData.lastAudit).getTime() : Infinity;
243
+ const isStale = auditAge > 7 * 24 * 60 * 60 * 1000;
242
244
  return {
243
- status: auditData.status || 'PENDING',
245
+ status: isStale ? 'STALE' : (auditData.status || 'PENDING'),
244
246
  cvesFixed: auditData.cvesFixed || 0,
245
- totalCves: auditData.totalCves || 3,
247
+ totalCves: auditData.totalCves || 0,
246
248
  };
247
249
  }
248
250
 
249
- let cvesFixed = 0;
251
+ let scanCount = 0;
250
252
  try {
251
253
  const scanDir = path.join(CWD, '.claude', 'security-scans');
252
254
  if (fs.existsSync(scanDir)) {
253
- cvesFixed = Math.min(totalCves, fs.readdirSync(scanDir).filter(f => f.endsWith('.json')).length);
255
+ scanCount = fs.readdirSync(scanDir).filter(f => f.endsWith('.json')).length;
254
256
  }
255
257
  } catch { /* ignore */ }
256
258
 
257
259
  return {
258
- status: cvesFixed >= totalCves ? 'CLEAN' : cvesFixed > 0 ? 'IN_PROGRESS' : 'PENDING',
259
- cvesFixed,
260
- totalCves,
260
+ status: scanCount > 0 ? 'SCANNED' : 'NONE',
261
+ cvesFixed: 0,
262
+ totalCves: 0,
261
263
  };
262
264
  }
263
265
 
264
266
  // Swarm status (pure file reads, NO ps aux)
265
267
  function getSwarmStatus() {
266
- const activityData = readJSON(path.join(CWD, '.claude-flow', 'metrics', 'swarm-activity.json'));
267
- if (activityData?.swarm) {
268
- return {
269
- activeAgents: activityData.swarm.agent_count || 0,
270
- maxAgents: CONFIG.maxAgents,
271
- coordinationActive: activityData.swarm.coordination_active || activityData.swarm.active || false,
272
- };
268
+ // Check swarm state file — only trust if recently updated (within 5 min)
269
+ const staleThresholdMs = 5 * 60 * 1000;
270
+ const now = Date.now();
271
+
272
+ const swarmStatePath = path.join(CWD, '.claude-flow', 'swarm', 'swarm-state.json');
273
+ const swarmState = readJSON(swarmStatePath);
274
+ if (swarmState) {
275
+ const updatedAt = swarmState.updatedAt || swarmState.startedAt;
276
+ const age = updatedAt ? now - new Date(updatedAt).getTime() : Infinity;
277
+ if (age < staleThresholdMs) {
278
+ return {
279
+ activeAgents: swarmState.agents?.length || swarmState.agentCount || 0,
280
+ maxAgents: swarmState.maxAgents || CONFIG.maxAgents,
281
+ coordinationActive: true,
282
+ };
283
+ }
273
284
  }
274
285
 
275
- const progressData = readJSON(path.join(CWD, '.claude-flow', 'metrics', 'v3-progress.json'));
276
- if (progressData?.swarm) {
277
- return {
278
- activeAgents: progressData.swarm.activeAgents || progressData.swarm.agent_count || 0,
279
- maxAgents: progressData.swarm.totalAgents || CONFIG.maxAgents,
280
- coordinationActive: progressData.swarm.active || (progressData.swarm.activeAgents > 0),
281
- };
286
+ const activityData = readJSON(path.join(CWD, '.claude-flow', 'metrics', 'swarm-activity.json'));
287
+ if (activityData?.swarm) {
288
+ const updatedAt = activityData.timestamp || activityData.swarm.timestamp;
289
+ const age = updatedAt ? now - new Date(updatedAt).getTime() : Infinity;
290
+ if (age < staleThresholdMs) {
291
+ return {
292
+ activeAgents: activityData.swarm.agent_count || 0,
293
+ maxAgents: CONFIG.maxAgents,
294
+ coordinationActive: activityData.swarm.coordination_active || activityData.swarm.active || false,
295
+ };
296
+ }
282
297
  }
283
298
 
284
299
  return { activeAgents: 0, maxAgents: CONFIG.maxAgents, coordinationActive: false };
@@ -298,8 +313,9 @@ function getSystemMetrics() {
298
313
  if (learningData?.intelligence?.score !== undefined) {
299
314
  intelligencePct = Math.min(100, Math.floor(learningData.intelligence.score));
300
315
  } else {
301
- const fromPatterns = learning.patterns > 0 ? Math.min(100, Math.floor(learning.patterns / 10)) : 0;
302
- const fromVectors = agentdb.vectorCount > 0 ? Math.min(100, Math.floor(agentdb.vectorCount / 100)) : 0;
316
+ // Use actual vector/entry counts 2000 entries = 100%
317
+ const fromPatterns = learning.patterns > 0 ? Math.min(100, Math.floor(learning.patterns / 20)) : 0;
318
+ const fromVectors = agentdb.vectorCount > 0 ? Math.min(100, Math.floor(agentdb.vectorCount / 20)) : 0;
303
319
  intelligencePct = Math.max(fromPatterns, fromVectors);
304
320
  }
305
321
 
@@ -334,15 +350,7 @@ function getSystemMetrics() {
334
350
 
335
351
  // ADR status (count files only — don't read contents)
336
352
  function getADRStatus() {
337
- const complianceData = readJSON(path.join(CWD, '.claude-flow', 'metrics', 'adr-compliance.json'));
338
- if (complianceData) {
339
- const checks = complianceData.checks || {};
340
- const total = Object.keys(checks).length;
341
- const impl = Object.values(checks).filter(c => c.compliant).length;
342
- return { count: total, implemented: impl, compliance: complianceData.compliance || 0 };
343
- }
344
-
345
- // Fallback: just count ADR files (don't read them)
353
+ // Count actual ADR files first compliance JSON may be stale
346
354
  const adrPaths = [
347
355
  path.join(CWD, 'v3', 'implementation', 'adrs'),
348
356
  path.join(CWD, 'docs', 'adrs'),
@@ -355,10 +363,8 @@ function getADRStatus() {
355
363
  const files = fs.readdirSync(adrPath).filter(f =>
356
364
  f.endsWith('.md') && (f.startsWith('ADR-') || f.startsWith('adr-') || /^\d{4}-/.test(f))
357
365
  );
358
- // Estimate: ~70% implemented in mature projects
359
- const implemented = Math.floor(files.length * 0.7);
360
- const compliance = files.length > 0 ? Math.floor((implemented / files.length) * 100) : 0;
361
- return { count: files.length, implemented, compliance };
366
+ // Report actual count don't guess compliance without reading files
367
+ return { count: files.length, implemented: files.length, compliance: 0 };
362
368
  }
363
369
  } catch { /* ignore */ }
364
370
  }
@@ -369,13 +375,20 @@ function getADRStatus() {
369
375
  // Hooks status (shared settings cache)
370
376
  function getHooksStatus() {
371
377
  let enabled = 0;
372
- const total = 17;
378
+ let total = 0;
373
379
  const settings = getSettings();
374
380
 
375
381
  if (settings?.hooks) {
376
382
  for (const category of Object.keys(settings.hooks)) {
377
- const h = settings.hooks[category];
378
- if (Array.isArray(h) && h.length > 0) enabled++;
383
+ const matchers = settings.hooks[category];
384
+ if (!Array.isArray(matchers)) continue;
385
+ for (const matcher of matchers) {
386
+ const hooks = matcher?.hooks;
387
+ if (Array.isArray(hooks)) {
388
+ total += hooks.length;
389
+ enabled += hooks.length;
390
+ }
391
+ }
379
392
  }
380
393
  }
381
394
 
@@ -383,6 +396,7 @@ function getHooksStatus() {
383
396
  const hooksDir = path.join(CWD, '.claude', 'hooks');
384
397
  if (fs.existsSync(hooksDir)) {
385
398
  const hookFiles = fs.readdirSync(hooksDir).filter(f => f.endsWith('.js') || f.endsWith('.sh')).length;
399
+ total = Math.max(total, hookFiles);
386
400
  enabled = Math.max(enabled, hookFiles);
387
401
  }
388
402
  } catch { /* ignore */ }
@@ -390,52 +404,52 @@ function getHooksStatus() {
390
404
  return { enabled, total };
391
405
  }
392
406
 
393
- // AgentDB stats (pure stat calls)
407
+ // AgentDB stats count real entries, not file-size heuristics
394
408
  function getAgentDBStats() {
395
409
  let vectorCount = 0;
396
410
  let dbSizeKB = 0;
397
411
  let namespaces = 0;
398
412
  let hasHnsw = false;
399
413
 
414
+ // 1. Count real entries from auto-memory-store.json
415
+ const storePath = path.join(CWD, '.claude-flow', 'data', 'auto-memory-store.json');
416
+ const storeStat = safeStat(storePath);
417
+ if (storeStat) {
418
+ dbSizeKB += storeStat.size / 1024;
419
+ try {
420
+ const store = JSON.parse(fs.readFileSync(storePath, 'utf-8'));
421
+ if (Array.isArray(store)) vectorCount += store.length;
422
+ else if (store?.entries) vectorCount += store.entries.length;
423
+ } catch { /* fall back to size estimate */ }
424
+ }
425
+
426
+ // 2. Count entries from ranked-context.json
427
+ const rankedPath = path.join(CWD, '.claude-flow', 'data', 'ranked-context.json');
428
+ try {
429
+ const ranked = readJSON(rankedPath);
430
+ if (ranked?.entries?.length > vectorCount) vectorCount = ranked.entries.length;
431
+ } catch { /* ignore */ }
432
+
433
+ // 3. Add DB file sizes
400
434
  const dbFiles = [
401
- path.join(CWD, '.swarm', 'memory.db'),
402
- path.join(CWD, '.claude-flow', 'memory.db'),
403
- path.join(CWD, '.claude', 'memory.db'),
404
435
  path.join(CWD, 'data', 'memory.db'),
436
+ path.join(CWD, '.claude-flow', 'memory.db'),
437
+ path.join(CWD, '.swarm', 'memory.db'),
405
438
  ];
406
-
407
439
  for (const f of dbFiles) {
408
440
  const stat = safeStat(f);
409
441
  if (stat) {
410
- dbSizeKB = stat.size / 1024;
411
- vectorCount = Math.floor(dbSizeKB / 2);
412
- namespaces = 1;
413
- break;
442
+ dbSizeKB += stat.size / 1024;
443
+ namespaces++;
414
444
  }
415
445
  }
416
446
 
417
- if (vectorCount === 0) {
418
- const dbDirs = [
419
- path.join(CWD, '.claude-flow', 'agentdb'),
420
- path.join(CWD, '.swarm', 'agentdb'),
421
- path.join(CWD, '.agentdb'),
422
- ];
423
- for (const dir of dbDirs) {
424
- try {
425
- if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
426
- const files = fs.readdirSync(dir);
427
- namespaces = files.filter(f => f.endsWith('.db') || f.endsWith('.sqlite')).length;
428
- for (const file of files) {
429
- const stat = safeStat(path.join(dir, file));
430
- if (stat?.isFile()) dbSizeKB += stat.size / 1024;
431
- }
432
- vectorCount = Math.floor(dbSizeKB / 2);
433
- break;
434
- }
435
- } catch { /* ignore */ }
436
- }
437
- }
447
+ // 4. Check for graph data
448
+ const graphPath = path.join(CWD, 'data', 'memory.graph');
449
+ const graphStat = safeStat(graphPath);
450
+ if (graphStat) dbSizeKB += graphStat.size / 1024;
438
451
 
452
+ // 5. HNSW index
439
453
  const hnswPaths = [
440
454
  path.join(CWD, '.swarm', 'hnsw.index'),
441
455
  path.join(CWD, '.claude-flow', 'hnsw.index'),
@@ -444,11 +458,21 @@ function getAgentDBStats() {
444
458
  const stat = safeStat(p);
445
459
  if (stat) {
446
460
  hasHnsw = true;
447
- vectorCount = Math.max(vectorCount, Math.floor(stat.size / 512));
448
461
  break;
449
462
  }
450
463
  }
451
464
 
465
+ // HNSW is available if memory package is present
466
+ if (!hasHnsw) {
467
+ const memPkgPaths = [
468
+ path.join(CWD, 'v3', '@claude-flow', 'memory', 'dist'),
469
+ path.join(CWD, 'node_modules', '@claude-flow', 'memory'),
470
+ ];
471
+ for (const p of memPkgPaths) {
472
+ if (fs.existsSync(p)) { hasHnsw = true; break; }
473
+ }
474
+ }
475
+
452
476
  return { vectorCount, dbSizeKB: Math.floor(dbSizeKB), namespaces, hasHnsw };
453
477
  }
454
478
 
@@ -457,7 +481,7 @@ function getTestStats() {
457
481
  let testFiles = 0;
458
482
 
459
483
  function countTestFiles(dir, depth = 0) {
460
- if (depth > 2) return; // Shallower recursion limit
484
+ if (depth > 6) return;
461
485
  try {
462
486
  if (!fs.existsSync(dir)) return;
463
487
  const entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -474,10 +498,10 @@ function getTestStats() {
474
498
  } catch { /* ignore */ }
475
499
  }
476
500
 
477
- for (const d of ['tests', 'test', '__tests__', 'v3/__tests__']) {
501
+ // Scan all source directories
502
+ for (const d of ['tests', 'test', '__tests__', 'src', 'v3']) {
478
503
  countTestFiles(path.join(CWD, d));
479
504
  }
480
- countTestFiles(path.join(CWD, 'src'));
481
505
 
482
506
  // Estimate ~4 test cases per file (avoids reading every file)
483
507
  return { testFiles, testCases: testFiles * 4 };
@@ -658,8 +682,8 @@ function generateDashboard() {
658
682
  // Line 2: Swarm + Hooks + CVE + Memory + Intelligence
659
683
  const swarmInd = swarm.coordinationActive ? `${c.brightGreen}\u25C9${c.reset}` : `${c.dim}\u25CB${c.reset}`;
660
684
  const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
661
- const secIcon = security.status === 'CLEAN' ? '\uD83D\uDFE2' : security.status === 'IN_PROGRESS' ? '\uD83D\uDFE1' : '\uD83D\uDD34';
662
- const secColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
685
+ const secIcon = security.status === 'CLEAN' ? '\uD83D\uDFE2' : (security.status === 'IN_PROGRESS' || security.status === 'STALE') ? '\uD83D\uDFE1' : '\uD83D\uDD34';
686
+ const secColor = security.status === 'CLEAN' ? c.brightGreen : (security.status === 'IN_PROGRESS' || security.status === 'STALE') ? c.brightYellow : c.brightRed;
663
687
  const hooksColor = hooks.enabled > 0 ? c.brightGreen : c.dim;
664
688
  const intellColor = system.intelligencePct >= 80 ? c.brightGreen : system.intelligencePct >= 40 ? c.brightYellow : c.dim;
665
689
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.5.29",
3
+ "version": "3.5.30",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.5.29",
3
+ "version": "3.5.30",
4
4
  "type": "module",
5
5
  "description": "Ruflo 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",