@claude-flow/cli 3.1.0-alpha.2 → 3.1.0-alpha.21

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.
Files changed (36) hide show
  1. package/.claude/helpers/auto-memory-hook.mjs +350 -0
  2. package/.claude/helpers/hook-handler.cjs +185 -0
  3. package/.claude/settings.json +86 -141
  4. package/README.md +603 -353
  5. package/bin/cli.js +6 -2
  6. package/dist/src/commands/hooks.d.ts.map +1 -1
  7. package/dist/src/commands/hooks.js +209 -2
  8. package/dist/src/commands/hooks.js.map +1 -1
  9. package/dist/src/commands/init.d.ts.map +1 -1
  10. package/dist/src/commands/init.js +190 -4
  11. package/dist/src/commands/init.js.map +1 -1
  12. package/dist/src/commands/memory.d.ts.map +1 -1
  13. package/dist/src/commands/memory.js +12 -2
  14. package/dist/src/commands/memory.js.map +1 -1
  15. package/dist/src/init/executor.d.ts +8 -2
  16. package/dist/src/init/executor.d.ts.map +1 -1
  17. package/dist/src/init/executor.js +247 -5
  18. package/dist/src/init/executor.js.map +1 -1
  19. package/dist/src/init/settings-generator.d.ts.map +1 -1
  20. package/dist/src/init/settings-generator.js +146 -14
  21. package/dist/src/init/settings-generator.js.map +1 -1
  22. package/dist/src/init/types.d.ts +10 -0
  23. package/dist/src/init/types.d.ts.map +1 -1
  24. package/dist/src/init/types.js +11 -0
  25. package/dist/src/init/types.js.map +1 -1
  26. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  27. package/dist/src/mcp-tools/memory-tools.js +4 -1
  28. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  29. package/dist/src/memory/memory-initializer.d.ts +1 -0
  30. package/dist/src/memory/memory-initializer.d.ts.map +1 -1
  31. package/dist/src/memory/memory-initializer.js +14 -9
  32. package/dist/src/memory/memory-initializer.js.map +1 -1
  33. package/dist/src/services/headless-worker-executor.js +3 -3
  34. package/dist/src/services/headless-worker-executor.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +4 -2
package/bin/cli.js CHANGED
@@ -11,8 +11,12 @@
11
11
  import { randomUUID } from 'crypto';
12
12
 
13
13
  // Check if we should run in MCP server mode
14
- // Conditions: stdin is being piped AND no CLI arguments provided
15
- const isMCPMode = !process.stdin.isTTY && process.argv.length === 2;
14
+ // Conditions:
15
+ // 1. stdin is being piped AND no CLI arguments provided (auto-detect)
16
+ // 2. stdin is being piped AND args are "mcp start" (explicit, e.g. npx claude-flow@alpha mcp start)
17
+ const cliArgs = process.argv.slice(2);
18
+ const isExplicitMCP = cliArgs.length >= 1 && cliArgs[0] === 'mcp' && (cliArgs.length === 1 || cliArgs[1] === 'start');
19
+ const isMCPMode = !process.stdin.isTTY && (process.argv.length === 2 || isExplicitMCP);
16
20
 
17
21
  if (isMCPMode) {
18
22
  // Run MCP server mode
@@ -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;AA4lI1E,eAAO,MAAM,YAAY,EAAE,OAiG1B,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;AAq0I1E,eAAO,MAAM,YAAY,EAAE,OAyG1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -3447,6 +3447,205 @@ const modelStatsCommand = {
3447
3447
  }
3448
3448
  }
3449
3449
  };
3450
+ // Teammate Idle command - Agent Teams integration
3451
+ const teammateIdleCommand = {
3452
+ name: 'teammate-idle',
3453
+ description: 'Handle idle teammate in Agent Teams - auto-assign tasks or notify lead',
3454
+ options: [
3455
+ {
3456
+ name: 'auto-assign',
3457
+ short: 'a',
3458
+ description: 'Automatically assign pending tasks to idle teammate',
3459
+ type: 'boolean',
3460
+ default: true
3461
+ },
3462
+ {
3463
+ name: 'check-task-list',
3464
+ short: 'c',
3465
+ description: 'Check shared task list for available work',
3466
+ type: 'boolean',
3467
+ default: true
3468
+ },
3469
+ {
3470
+ name: 'teammate-id',
3471
+ short: 't',
3472
+ description: 'ID of the idle teammate',
3473
+ type: 'string'
3474
+ },
3475
+ {
3476
+ name: 'team-name',
3477
+ description: 'Team name for context',
3478
+ type: 'string'
3479
+ }
3480
+ ],
3481
+ examples: [
3482
+ { command: 'claude-flow hooks teammate-idle --auto-assign true', description: 'Auto-assign tasks to idle teammate' },
3483
+ { command: 'claude-flow hooks teammate-idle -t worker-1 --check-task-list', description: 'Check tasks for specific teammate' }
3484
+ ],
3485
+ action: async (ctx) => {
3486
+ const autoAssign = ctx.flags.autoAssign !== false;
3487
+ const checkTaskList = ctx.flags.checkTaskList !== false;
3488
+ const teammateId = ctx.flags.teammateId;
3489
+ const teamName = ctx.flags.teamName;
3490
+ if (ctx.flags.format !== 'json') {
3491
+ output.printInfo(`Teammate idle hook triggered${teammateId ? ` for: ${output.highlight(teammateId)}` : ''}`);
3492
+ }
3493
+ try {
3494
+ const result = await callMCPTool('hooks_teammate-idle', {
3495
+ autoAssign,
3496
+ checkTaskList,
3497
+ teammateId,
3498
+ teamName,
3499
+ timestamp: Date.now(),
3500
+ });
3501
+ if (ctx.flags.format === 'json') {
3502
+ output.printJson(result);
3503
+ return { success: true, data: result };
3504
+ }
3505
+ output.writeln();
3506
+ if (result.action === 'assigned' && result.taskAssigned) {
3507
+ output.printSuccess(`Task assigned: ${result.taskAssigned.subject}`);
3508
+ output.printList([
3509
+ `Task ID: ${result.taskAssigned.taskId}`,
3510
+ `Priority: ${result.taskAssigned.priority}`,
3511
+ `Pending tasks remaining: ${result.pendingTasks}`
3512
+ ]);
3513
+ }
3514
+ else if (result.action === 'waiting') {
3515
+ output.printInfo('No pending tasks available - teammate waiting for work');
3516
+ }
3517
+ else {
3518
+ output.printInfo(`Team lead notified: ${result.message}`);
3519
+ }
3520
+ return { success: true, data: result };
3521
+ }
3522
+ catch (error) {
3523
+ // Graceful fallback - don't fail hard, just report
3524
+ if (ctx.flags.format === 'json') {
3525
+ output.printJson({ success: true, action: 'waiting', message: 'Teammate idle - no MCP server' });
3526
+ }
3527
+ else {
3528
+ output.printInfo('Teammate idle - awaiting task assignment');
3529
+ }
3530
+ return { success: true };
3531
+ }
3532
+ }
3533
+ };
3534
+ // Task Completed command - Agent Teams integration
3535
+ const taskCompletedCommand = {
3536
+ name: 'task-completed',
3537
+ description: 'Handle task completion in Agent Teams - train patterns and notify lead',
3538
+ options: [
3539
+ {
3540
+ name: 'task-id',
3541
+ short: 'i',
3542
+ description: 'ID of the completed task',
3543
+ type: 'string',
3544
+ required: true
3545
+ },
3546
+ {
3547
+ name: 'train-patterns',
3548
+ short: 'p',
3549
+ description: 'Train neural patterns from successful task',
3550
+ type: 'boolean',
3551
+ default: true
3552
+ },
3553
+ {
3554
+ name: 'notify-lead',
3555
+ short: 'n',
3556
+ description: 'Notify team lead of task completion',
3557
+ type: 'boolean',
3558
+ default: true
3559
+ },
3560
+ {
3561
+ name: 'success',
3562
+ short: 's',
3563
+ description: 'Whether the task succeeded',
3564
+ type: 'boolean',
3565
+ default: true
3566
+ },
3567
+ {
3568
+ name: 'quality',
3569
+ short: 'q',
3570
+ description: 'Quality score (0-1)',
3571
+ type: 'number'
3572
+ },
3573
+ {
3574
+ name: 'teammate-id',
3575
+ short: 't',
3576
+ description: 'ID of the teammate that completed the task',
3577
+ type: 'string'
3578
+ }
3579
+ ],
3580
+ examples: [
3581
+ { command: 'claude-flow hooks task-completed -i task-123 --train-patterns', description: 'Complete task and train patterns' },
3582
+ { command: 'claude-flow hooks task-completed -i task-456 --notify-lead --quality 0.95', description: 'Complete with quality score' }
3583
+ ],
3584
+ action: async (ctx) => {
3585
+ const taskId = ctx.args[0] || ctx.flags.taskId;
3586
+ const trainPatterns = ctx.flags.trainPatterns !== false;
3587
+ const notifyLead = ctx.flags.notifyLead !== false;
3588
+ const success = ctx.flags.success !== false;
3589
+ const quality = ctx.flags.quality;
3590
+ const teammateId = ctx.flags.teammateId;
3591
+ if (!taskId) {
3592
+ output.printError('Task ID is required. Use --task-id or -i flag.');
3593
+ return { success: false, exitCode: 1 };
3594
+ }
3595
+ if (ctx.flags.format !== 'json') {
3596
+ output.printInfo(`Task completed: ${output.highlight(taskId)}`);
3597
+ }
3598
+ try {
3599
+ const result = await callMCPTool('hooks_task-completed', {
3600
+ taskId,
3601
+ trainPatterns,
3602
+ notifyLead,
3603
+ success,
3604
+ quality,
3605
+ teammateId,
3606
+ timestamp: Date.now(),
3607
+ });
3608
+ if (ctx.flags.format === 'json') {
3609
+ output.printJson(result);
3610
+ return { success: true, data: result };
3611
+ }
3612
+ output.writeln();
3613
+ output.printSuccess(`Task ${taskId} marked complete`);
3614
+ output.writeln();
3615
+ output.writeln(output.bold('Completion Metrics'));
3616
+ output.printTable({
3617
+ columns: [
3618
+ { key: 'metric', header: 'Metric', width: 25 },
3619
+ { key: 'value', header: 'Value', width: 20, align: 'right' }
3620
+ ],
3621
+ data: [
3622
+ { metric: 'Patterns Learned', value: result.patternsLearned },
3623
+ { metric: 'Quality Score', value: quality ? `${(quality * 100).toFixed(0)}%` : 'N/A' },
3624
+ { metric: 'Lead Notified', value: result.leadNotified ? 'Yes' : 'No' },
3625
+ { metric: 'Learning Updates', value: result.metrics?.learningUpdates || 0 }
3626
+ ]
3627
+ });
3628
+ if (result.nextTask) {
3629
+ output.writeln();
3630
+ output.printInfo(`Next available task: ${result.nextTask.subject}`);
3631
+ }
3632
+ return { success: true, data: result };
3633
+ }
3634
+ catch (error) {
3635
+ // Graceful fallback
3636
+ if (ctx.flags.format === 'json') {
3637
+ output.printJson({ success: true, taskId, message: 'Task completed - patterns pending' });
3638
+ }
3639
+ else {
3640
+ output.printSuccess(`Task ${taskId} completed`);
3641
+ if (trainPatterns) {
3642
+ output.printInfo('Pattern training queued for next sync');
3643
+ }
3644
+ }
3645
+ return { success: true };
3646
+ }
3647
+ }
3648
+ };
3450
3649
  // Main hooks command
3451
3650
  export const hooksCommand = {
3452
3651
  name: 'hooks',
@@ -3486,6 +3685,9 @@ export const hooksCommand = {
3486
3685
  sessionStartCommand,
3487
3686
  preBashCommand,
3488
3687
  postBashCommand,
3688
+ // Agent Teams integration
3689
+ teammateIdleCommand,
3690
+ taskCompletedCommand,
3489
3691
  ],
3490
3692
  options: [],
3491
3693
  examples: [
@@ -3528,7 +3730,11 @@ export const hooksCommand = {
3528
3730
  `${output.highlight('token-optimize')} - Token optimization (30-50% savings)`,
3529
3731
  `${output.highlight('model-route')} - Route to optimal model (haiku/sonnet/opus)`,
3530
3732
  `${output.highlight('model-outcome')} - Record model routing outcome`,
3531
- `${output.highlight('model-stats')} - View model routing statistics`
3733
+ `${output.highlight('model-stats')} - View model routing statistics`,
3734
+ '',
3735
+ output.bold('Agent Teams:'),
3736
+ `${output.highlight('teammate-idle')} - Handle idle teammate (auto-assign tasks)`,
3737
+ `${output.highlight('task-completed')} - Handle task completion (train patterns)`
3532
3738
  ]);
3533
3739
  output.writeln();
3534
3740
  output.writeln('Run "claude-flow hooks <subcommand> --help" for subcommand help');
@@ -3540,7 +3746,8 @@ export const hooksCommand = {
3540
3746
  '🔍 AgentDB integration (150x faster search)',
3541
3747
  '📊 84.8% SWE-Bench solve rate',
3542
3748
  '🎯 32.3% token reduction',
3543
- '🚀 2.8-4.4x speed improvement'
3749
+ '🚀 2.8-4.4x speed improvement',
3750
+ '👥 Agent Teams integration (auto task assignment)'
3544
3751
  ]);
3545
3752
  return { success: true };
3546
3753
  }