claude-flow 2.0.0-alpha.7 → 2.0.0-alpha.9

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <div align="center">
4
4
 
5
5
  [![🌟 Star on GitHub](https://img.shields.io/github/stars/ruvnet/claude-code-flow?style=for-the-badge&logo=github&color=gold)](https://github.com/ruvnet/claude-code-flow)
6
- [![šŸ“¦ NPX Ready](https://img.shields.io/npm/v/claude-flow?style=for-the-badge&logo=npm&color=blue&label=v2.0.0-alpha.6)](https://www.npmjs.com/package/claude-flow)
6
+ [![šŸ“¦ NPX Ready](https://img.shields.io/npm/v/claude-flow?style=for-the-badge&logo=npm&color=blue&label=v2.0.0-alpha.8)](https://www.npmjs.com/package/claude-flow)
7
7
  [![⚔ Claude Code](https://img.shields.io/badge/Claude%20Code-MCP%20Ready-green?style=for-the-badge&logo=anthropic)](https://github.com/ruvnet/claude-code-flow)
8
8
  [![šŸ ruv-swarm](https://img.shields.io/badge/ruv--swarm-87%20Tools-purple?style=for-the-badge&logo=gitswarm)](https://github.com/ruvnet/ruv-FANN)
9
9
  [![🧠 Neural](https://img.shields.io/badge/WASM-Neural%20Networks-red?style=for-the-badge&logo=webassembly)](https://github.com/ruvnet/claude-code-flow)
@@ -50,7 +50,7 @@ Instead of promising "AI magic," Claude Flow delivers practical improvements:
50
50
 
51
51
  ---
52
52
 
53
- ## šŸš€ **What's New in v2.0.0-alpha.6**
53
+ ## šŸš€ **What's New in v2.0.0-alpha.8**
54
54
 
55
55
  ### šŸ”Œ **Automatic MCP Setup (NEW!)**
56
56
  - **Smart Detection** - Automatically detects Claude Code CLI installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)",
5
5
  "main": "cli.mjs",
6
6
  "bin": {
@@ -348,7 +348,9 @@ export class HiveMindCore extends EventEmitter {
348
348
  * Create and distribute task with performance optimization
349
349
  */
350
350
  async createTask(description, priority = 5, metadata = {}) {
351
- const taskId = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
351
+ const timestamp = Date.now();
352
+ const randomPart = Math.random().toString(36).substring(2, 11); // Use substring instead of substr
353
+ const taskId = `task-${timestamp}-${randomPart}`;
352
354
  const createdAt = Date.now();
353
355
 
354
356
  const task = {
@@ -384,7 +384,26 @@ async function spawnSwarm(args, flags) {
384
384
  mkdirSync(dbDir, { recursive: true });
385
385
  }
386
386
 
387
- const db = new Database(dbPath);
387
+ // Check if database file exists and try to create a clean one if needed
388
+ let db;
389
+ try {
390
+ db = new Database(dbPath);
391
+ // Test the database with a simple query
392
+ db.prepare('SELECT 1').get();
393
+ } catch (error) {
394
+ console.warn('Database issue detected, recreating...', error.message);
395
+ // Remove corrupted database
396
+ if (existsSync(dbPath)) {
397
+ try {
398
+ const fs = await import('fs');
399
+ fs.unlinkSync(dbPath);
400
+ } catch (e) {
401
+ console.warn('Could not remove corrupted database:', e.message);
402
+ }
403
+ }
404
+ // Create new database
405
+ db = new Database(dbPath);
406
+ }
388
407
 
389
408
  // Initialize database schema if not exists
390
409
  db.exec(`
@@ -422,8 +441,10 @@ async function spawnSwarm(args, flags) {
422
441
  );
423
442
  `);
424
443
 
425
- // Create swarm record
426
- const swarmId = `swarm-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
444
+ // Create swarm record with safe ID generation
445
+ const timestamp = Date.now();
446
+ const randomPart = Math.random().toString(36).substring(2, 11); // Use substring instead of substr
447
+ const swarmId = `swarm-${timestamp}-${randomPart}`;
427
448
  db.prepare(`
428
449
  INSERT INTO swarms (id, name, objective, queen_type)
429
450
  VALUES (?, ?, ?, ?)
@@ -116,7 +116,7 @@ export async function initCommand(subArgs, flags) {
116
116
  // Default to enhanced Claude Flow v2 init
117
117
  // Use --basic flag for old behavior
118
118
  if (!flags.basic && !flags.minimal && !flags.sparc) {
119
- return await enhancedClaudeFlowInit(flags);
119
+ return await enhancedClaudeFlowInit(flags, subArgs);
120
120
  }
121
121
 
122
122
  // Check for validation and rollback commands
@@ -494,17 +494,17 @@ export async function initCommand(subArgs, flags) {
494
494
  console.log(' • Monitor performance with real-time metrics');
495
495
  }
496
496
 
497
- // Check for Claude Code and set up MCP servers
498
- if (!initDryRun && isClaudeCodeInstalled()) {
497
+ // Check for Claude Code and set up MCP servers (always enabled by default)
498
+ if (!dryRun && isClaudeCodeInstalled()) {
499
499
  console.log('\nšŸ” Claude Code CLI detected!');
500
- const setupMcp = !subArgs.includes('--skip-mcp');
500
+ const skipMcp = args && args.includes && args.includes('--skip-mcp');
501
501
 
502
- if (setupMcp) {
503
- await setupMcpServers(initDryRun);
502
+ if (!skipMcp) {
503
+ await setupMcpServers(dryRun);
504
504
  } else {
505
505
  console.log(' ā„¹ļø Skipping MCP setup (--skip-mcp flag used)');
506
506
  }
507
- } else if (!initDryRun && !isClaudeCodeInstalled()) {
507
+ } else if (!dryRun && !isClaudeCodeInstalled()) {
508
508
  console.log('\nāš ļø Claude Code CLI not detected!');
509
509
  console.log(' šŸ“„ Install with: npm install -g @anthropics/claude-code');
510
510
  console.log(' šŸ“‹ Then add MCP servers manually with:');
@@ -591,6 +591,10 @@ async function handleBatchInit(subArgs, flags) {
591
591
  async function enhancedInitCommand(subArgs, flags) {
592
592
  console.log('šŸ›”ļø Starting enhanced initialization with validation and rollback...');
593
593
 
594
+ // Store parameters to avoid scope issues in async context
595
+ const args = subArgs || [];
596
+ const options = flags || {};
597
+
594
598
  // Get the working directory
595
599
  const workingDir = Deno.env.get('PWD') || Deno.cwd();
596
600
 
@@ -602,19 +606,19 @@ async function enhancedInitCommand(subArgs, flags) {
602
606
 
603
607
  try {
604
608
  // Parse options
605
- const options = {
606
- force: subArgs.includes('--force') || subArgs.includes('-f') || flags.force,
607
- minimal: subArgs.includes('--minimal') || subArgs.includes('-m') || flags.minimal,
608
- sparc: subArgs.includes('--sparc') || subArgs.includes('-s') || flags.sparc,
609
- skipPreValidation: subArgs.includes('--skip-pre-validation'),
610
- skipBackup: subArgs.includes('--skip-backup'),
611
- validateOnly: subArgs.includes('--validate-only')
609
+ const initOptions = {
610
+ force: args.includes('--force') || args.includes('-f') || options.force,
611
+ minimal: args.includes('--minimal') || args.includes('-m') || options.minimal,
612
+ sparc: args.includes('--sparc') || args.includes('-s') || options.sparc,
613
+ skipPreValidation: args.includes('--skip-pre-validation'),
614
+ skipBackup: args.includes('--skip-backup'),
615
+ validateOnly: args.includes('--validate-only')
612
616
  };
613
617
 
614
618
  // Phase 1: Pre-initialization validation
615
- if (!options.skipPreValidation) {
619
+ if (!initOptions.skipPreValidation) {
616
620
  console.log('\nšŸ” Phase 1: Pre-initialization validation...');
617
- const preValidation = await validationSystem.validatePreInit(options);
621
+ const preValidation = await validationSystem.validatePreInit(initOptions);
618
622
 
619
623
  if (!preValidation.success) {
620
624
  printError('Pre-initialization validation failed:');
@@ -945,13 +949,17 @@ async function setupCoordinationSystem(workingDir) {
945
949
  /**
946
950
  * Enhanced Claude Flow v2.0.0 initialization
947
951
  */
948
- async function enhancedClaudeFlowInit(flags) {
952
+ async function enhancedClaudeFlowInit(flags, subArgs = []) {
949
953
  console.log('šŸš€ Initializing Claude Flow v2.0.0 with enhanced features...');
950
954
 
951
955
  const workingDir = process.cwd();
952
956
  const force = flags.force || flags.f;
953
957
  const dryRun = flags.dryRun || flags['dry-run'] || flags.d;
954
958
 
959
+ // Store parameters to avoid scope issues in async context
960
+ const args = subArgs || [];
961
+ const options = flags || {};
962
+
955
963
  // Import fs module for Node.js
956
964
  const fs = await import('fs/promises');
957
965
  const { chmod } = fs;
@@ -1099,15 +1107,15 @@ ${commands.map(cmd => `- [${cmd}](./${cmd}.md)`).join('\n')}
1099
1107
  printSuccess('āœ“ Initialized memory system');
1100
1108
  }
1101
1109
 
1102
- // Check for Claude Code and set up MCP servers
1110
+ // Check for Claude Code and set up MCP servers (always enabled by default)
1103
1111
  if (!dryRun && isClaudeCodeInstalled()) {
1104
1112
  console.log('\nšŸ” Claude Code CLI detected!');
1105
- const setupMcp = !flags['skip-mcp'] && !subArgs.includes('--skip-mcp');
1113
+ const skipMcp = (options && options['skip-mcp']) || (args && args.includes && args.includes('--skip-mcp'));
1106
1114
 
1107
- if (setupMcp) {
1115
+ if (!skipMcp) {
1108
1116
  await setupMcpServers(dryRun);
1109
1117
  } else {
1110
- console.log(' ā„¹ļø Skipping MCP setup (use --skip-mcp to disable)');
1118
+ console.log(' ā„¹ļø Skipping MCP setup (--skip-mcp flag used)');
1111
1119
  console.log('\n šŸ“‹ To add MCP servers manually:');
1112
1120
  console.log(' claude mcp add claude-flow claude-flow mcp start');
1113
1121
  console.log(' claude mcp add ruv-swarm npx ruv-swarm mcp start');