@claude-flow/cli 3.0.0-alpha.53 → 3.0.0-alpha.55

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.
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AA2gG1E,eAAO,MAAM,YAAY,EAAE,OAgF1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAixG1E,eAAO,MAAM,YAAY,EAAE,OAkF1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -2457,6 +2457,243 @@ const workerCommand = {
2457
2457
  return { success: true };
2458
2458
  }
2459
2459
  };
2460
+ // Statusline subcommand - generates dynamic status display
2461
+ const statuslineCommand = {
2462
+ name: 'statusline',
2463
+ description: 'Generate dynamic statusline with V3 progress and system status',
2464
+ options: [
2465
+ {
2466
+ name: 'json',
2467
+ description: 'Output as JSON',
2468
+ type: 'boolean',
2469
+ default: false
2470
+ },
2471
+ {
2472
+ name: 'compact',
2473
+ description: 'Compact single-line output',
2474
+ type: 'boolean',
2475
+ default: false
2476
+ },
2477
+ {
2478
+ name: 'no-color',
2479
+ description: 'Disable ANSI colors',
2480
+ type: 'boolean',
2481
+ default: false
2482
+ }
2483
+ ],
2484
+ examples: [
2485
+ { command: 'claude-flow hooks statusline', description: 'Display full statusline' },
2486
+ { command: 'claude-flow hooks statusline --json', description: 'JSON output for hooks' },
2487
+ { command: 'claude-flow hooks statusline --compact', description: 'Single-line status' }
2488
+ ],
2489
+ action: async (ctx) => {
2490
+ const fs = await import('fs');
2491
+ const path = await import('path');
2492
+ const { execSync } = await import('child_process');
2493
+ // Get learning stats from memory database
2494
+ function getLearningStats() {
2495
+ const memoryPaths = [
2496
+ path.join(process.cwd(), '.swarm', 'memory.db'),
2497
+ path.join(process.cwd(), '.claude', 'memory.db'),
2498
+ ];
2499
+ let patterns = 0;
2500
+ let sessions = 0;
2501
+ let trajectories = 0;
2502
+ for (const dbPath of memoryPaths) {
2503
+ if (fs.existsSync(dbPath)) {
2504
+ try {
2505
+ const stats = fs.statSync(dbPath);
2506
+ const sizeKB = stats.size / 1024;
2507
+ patterns = Math.floor(sizeKB / 2);
2508
+ sessions = Math.max(1, Math.floor(patterns / 10));
2509
+ trajectories = Math.floor(patterns / 5);
2510
+ break;
2511
+ }
2512
+ catch {
2513
+ // Ignore
2514
+ }
2515
+ }
2516
+ }
2517
+ const sessionsPath = path.join(process.cwd(), '.claude', 'sessions');
2518
+ if (fs.existsSync(sessionsPath)) {
2519
+ try {
2520
+ const sessionFiles = fs.readdirSync(sessionsPath).filter((f) => f.endsWith('.json'));
2521
+ sessions = Math.max(sessions, sessionFiles.length);
2522
+ }
2523
+ catch {
2524
+ // Ignore
2525
+ }
2526
+ }
2527
+ return { patterns, sessions, trajectories };
2528
+ }
2529
+ // Get V3 progress
2530
+ function getV3Progress() {
2531
+ const learning = getLearningStats();
2532
+ let domainsCompleted = 0;
2533
+ if (learning.patterns >= 500)
2534
+ domainsCompleted = 5;
2535
+ else if (learning.patterns >= 200)
2536
+ domainsCompleted = 4;
2537
+ else if (learning.patterns >= 100)
2538
+ domainsCompleted = 3;
2539
+ else if (learning.patterns >= 50)
2540
+ domainsCompleted = 2;
2541
+ else if (learning.patterns >= 10)
2542
+ domainsCompleted = 1;
2543
+ const totalDomains = 5;
2544
+ const dddProgress = Math.min(100, Math.floor((domainsCompleted / totalDomains) * 100));
2545
+ return { domainsCompleted, totalDomains, dddProgress, patternsLearned: learning.patterns, sessionsCompleted: learning.sessions };
2546
+ }
2547
+ // Get security status
2548
+ function getSecurityStatus() {
2549
+ const scanResultsPath = path.join(process.cwd(), '.claude', 'security-scans');
2550
+ let cvesFixed = 0;
2551
+ const totalCves = 3;
2552
+ if (fs.existsSync(scanResultsPath)) {
2553
+ try {
2554
+ const scans = fs.readdirSync(scanResultsPath).filter((f) => f.endsWith('.json'));
2555
+ cvesFixed = Math.min(totalCves, scans.length);
2556
+ }
2557
+ catch {
2558
+ // Ignore
2559
+ }
2560
+ }
2561
+ const auditPath = path.join(process.cwd(), '.swarm', 'security');
2562
+ if (fs.existsSync(auditPath)) {
2563
+ try {
2564
+ const audits = fs.readdirSync(auditPath).filter((f) => f.includes('audit'));
2565
+ cvesFixed = Math.min(totalCves, Math.max(cvesFixed, audits.length));
2566
+ }
2567
+ catch {
2568
+ // Ignore
2569
+ }
2570
+ }
2571
+ const status = cvesFixed >= totalCves ? 'CLEAN' : cvesFixed > 0 ? 'IN_PROGRESS' : 'PENDING';
2572
+ return { status, cvesFixed, totalCves };
2573
+ }
2574
+ // Get swarm status
2575
+ function getSwarmStatus() {
2576
+ let activeAgents = 0;
2577
+ let coordinationActive = false;
2578
+ const maxAgents = 15;
2579
+ try {
2580
+ const ps = execSync('ps aux 2>/dev/null | grep -c agentic-flow || echo "0"', { encoding: 'utf-8' });
2581
+ activeAgents = Math.max(0, parseInt(ps.trim()) - 1);
2582
+ coordinationActive = activeAgents > 0;
2583
+ }
2584
+ catch {
2585
+ // Ignore
2586
+ }
2587
+ return { activeAgents, maxAgents, coordinationActive };
2588
+ }
2589
+ // Get system metrics
2590
+ function getSystemMetrics() {
2591
+ let memoryMB = 0;
2592
+ let subAgents = 0;
2593
+ const learning = getLearningStats();
2594
+ try {
2595
+ memoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);
2596
+ }
2597
+ catch {
2598
+ // Ignore
2599
+ }
2600
+ const intelligencePct = Math.min(100, Math.floor((learning.patterns / 10) * 1));
2601
+ const contextPct = Math.min(100, Math.floor(learning.sessions * 5));
2602
+ return { memoryMB, contextPct, intelligencePct, subAgents };
2603
+ }
2604
+ // Get user info
2605
+ function getUserInfo() {
2606
+ let name = 'user';
2607
+ let gitBranch = '';
2608
+ const modelName = 'Opus 4.5';
2609
+ try {
2610
+ name = execSync('git config user.name 2>/dev/null || echo "user"', { encoding: 'utf-8' }).trim();
2611
+ gitBranch = execSync('git branch --show-current 2>/dev/null || echo ""', { encoding: 'utf-8' }).trim();
2612
+ }
2613
+ catch {
2614
+ // Ignore
2615
+ }
2616
+ return { name, gitBranch, modelName };
2617
+ }
2618
+ // Collect all status
2619
+ const progress = getV3Progress();
2620
+ const security = getSecurityStatus();
2621
+ const swarm = getSwarmStatus();
2622
+ const system = getSystemMetrics();
2623
+ const user = getUserInfo();
2624
+ const statusData = {
2625
+ user,
2626
+ v3Progress: progress,
2627
+ security,
2628
+ swarm,
2629
+ system,
2630
+ timestamp: new Date().toISOString()
2631
+ };
2632
+ // JSON output
2633
+ if (ctx.flags.json || ctx.flags.format === 'json') {
2634
+ output.printJson(statusData);
2635
+ return { success: true, data: statusData };
2636
+ }
2637
+ // Compact output
2638
+ if (ctx.flags.compact) {
2639
+ const line = `DDD:${progress.domainsCompleted}/${progress.totalDomains} CVE:${security.cvesFixed}/${security.totalCves} Swarm:${swarm.activeAgents}/${swarm.maxAgents} Ctx:${system.contextPct}% Int:${system.intelligencePct}%`;
2640
+ output.writeln(line);
2641
+ return { success: true, data: statusData };
2642
+ }
2643
+ // Full colored output
2644
+ const noColor = ctx.flags['no-color'] || ctx.flags.noColor;
2645
+ const c = noColor ? {
2646
+ reset: '', bold: '', dim: '', red: '', green: '', yellow: '', blue: '',
2647
+ purple: '', cyan: '', brightRed: '', brightGreen: '', brightYellow: '',
2648
+ brightBlue: '', brightPurple: '', brightCyan: '', brightWhite: ''
2649
+ } : {
2650
+ reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m', red: '\x1b[0;31m',
2651
+ green: '\x1b[0;32m', yellow: '\x1b[0;33m', blue: '\x1b[0;34m',
2652
+ purple: '\x1b[0;35m', cyan: '\x1b[0;36m', brightRed: '\x1b[1;31m',
2653
+ brightGreen: '\x1b[1;32m', brightYellow: '\x1b[1;33m', brightBlue: '\x1b[1;34m',
2654
+ brightPurple: '\x1b[1;35m', brightCyan: '\x1b[1;36m', brightWhite: '\x1b[1;37m'
2655
+ };
2656
+ // Progress bar helper
2657
+ const progressBar = (current, total) => {
2658
+ const filled = Math.round((current / total) * 5);
2659
+ const empty = 5 - filled;
2660
+ return '[' + '●'.repeat(filled) + '○'.repeat(empty) + ']';
2661
+ };
2662
+ // Generate lines
2663
+ let header = `${c.bold}${c.brightPurple}▊ Claude Flow V3 ${c.reset}`;
2664
+ header += `${swarm.coordinationActive ? c.brightCyan : c.dim}● ${c.brightCyan}${user.name}${c.reset}`;
2665
+ if (user.gitBranch) {
2666
+ header += ` ${c.dim}│${c.reset} ${c.brightBlue}⎇ ${user.gitBranch}${c.reset}`;
2667
+ }
2668
+ header += ` ${c.dim}│${c.reset} ${c.purple}${user.modelName}${c.reset}`;
2669
+ const separator = `${c.dim}─────────────────────────────────────────────────────${c.reset}`;
2670
+ const domainsColor = progress.domainsCompleted >= 3 ? c.brightGreen : progress.domainsCompleted > 0 ? c.yellow : c.red;
2671
+ const line1 = `${c.brightCyan}🏗️ DDD Domains${c.reset} ${progressBar(progress.domainsCompleted, progress.totalDomains)} ` +
2672
+ `${domainsColor}${progress.domainsCompleted}${c.reset}/${c.brightWhite}${progress.totalDomains}${c.reset} ` +
2673
+ `${c.brightYellow}⚡ 1.0x${c.reset} ${c.dim}→${c.reset} ${c.brightYellow}2.49x-7.47x${c.reset}`;
2674
+ const swarmIndicator = swarm.coordinationActive ? `${c.brightGreen}◉${c.reset}` : `${c.dim}○${c.reset}`;
2675
+ const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
2676
+ const securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'IN_PROGRESS' ? '🟡' : '🔴';
2677
+ const securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
2678
+ const line2 = `${c.brightYellow}🤖 Swarm${c.reset} ${swarmIndicator} [${agentsColor}${String(swarm.activeAgents).padStart(2)}${c.reset}/${c.brightWhite}${swarm.maxAgents}${c.reset}] ` +
2679
+ `${c.brightPurple}👥 ${system.subAgents}${c.reset} ` +
2680
+ `${securityIcon} ${securityColor}CVE ${security.cvesFixed}${c.reset}/${c.brightWhite}${security.totalCves}${c.reset} ` +
2681
+ `${c.brightCyan}💾 ${system.memoryMB}MB${c.reset} ` +
2682
+ `${c.brightGreen}📂 ${String(system.contextPct).padStart(3)}%${c.reset} ` +
2683
+ `${c.brightPurple}🧠 ${String(system.intelligencePct).padStart(3)}%${c.reset}`;
2684
+ const line3 = `${c.brightCyan}🔧 Architecture${c.reset} ` +
2685
+ `DDD ${c.brightGreen}●${progress.dddProgress}%${c.reset} ${c.dim}│${c.reset} ` +
2686
+ `Security ${securityColor}●${security.status}${c.reset} ${c.dim}│${c.reset} ` +
2687
+ `Memory ${c.brightGreen}●AgentDB${c.reset} ${c.dim}│${c.reset} ` +
2688
+ `Integration ${c.brightGreen}●${c.reset}`;
2689
+ output.writeln(header);
2690
+ output.writeln(separator);
2691
+ output.writeln(line1);
2692
+ output.writeln(line2);
2693
+ output.writeln(line3);
2694
+ return { success: true, data: statusData };
2695
+ }
2696
+ };
2460
2697
  // Main hooks command
2461
2698
  export const hooksCommand = {
2462
2699
  name: 'hooks',
@@ -2480,6 +2717,7 @@ export const hooksCommand = {
2480
2717
  intelligenceCommand,
2481
2718
  workerCommand,
2482
2719
  progressHookCommand,
2720
+ statuslineCommand,
2483
2721
  // Coverage-aware routing commands
2484
2722
  coverageRouteCommand,
2485
2723
  coverageSuggestCommand,
@@ -2519,6 +2757,7 @@ export const hooksCommand = {
2519
2757
  `${output.highlight('list')} - List all registered hooks`,
2520
2758
  `${output.highlight('worker')} - Background worker management (12 workers)`,
2521
2759
  `${output.highlight('progress')} - Check V3 implementation progress`,
2760
+ `${output.highlight('statusline')} - Generate dynamic statusline display`,
2522
2761
  `${output.highlight('coverage-route')} - Route tasks based on coverage gaps (ruvector)`,
2523
2762
  `${output.highlight('coverage-suggest')}- Suggest coverage improvements`,
2524
2763
  `${output.highlight('coverage-gaps')} - List all coverage gaps with agents`