snow-flow 1.4.3 → 1.4.5

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 (2) hide show
  1. package/dist/cli.js +103 -32
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2064,6 +2064,7 @@ program
2064
2064
  .description('Initialize a Snow-Flow project with SPARC environment')
2065
2065
  .option('--sparc', 'Initialize with SPARC methodology and MCP servers (recommended)', true)
2066
2066
  .option('--skip-mcp', 'Skip MCP server activation prompt')
2067
+ .option('--force', 'Overwrite existing files without prompting')
2067
2068
  .action(async (options) => {
2068
2069
  console.log(chalk_1.default.blue.bold(`\nšŸš€ Initializing Snow-Flow Project v${version_js_1.VERSION}...`));
2069
2070
  console.log('='.repeat(60));
@@ -2071,19 +2072,19 @@ program
2071
2072
  try {
2072
2073
  // Create directory structure
2073
2074
  console.log('\nšŸ“ Creating project structure...');
2074
- await createDirectoryStructure(targetDir);
2075
+ await createDirectoryStructure(targetDir, options.force);
2075
2076
  // Create .env file
2076
2077
  console.log('šŸ” Creating environment configuration...');
2077
- await createEnvFile(targetDir);
2078
+ await createEnvFile(targetDir, options.force);
2078
2079
  // Create MCP configuration
2079
2080
  if (options.sparc) {
2080
2081
  console.log('šŸ”§ Setting up MCP servers for Claude Code...');
2081
- await createMCPConfig(targetDir);
2082
+ await createMCPConfig(targetDir, options.force);
2082
2083
  // Copy CLAUDE.md file
2083
2084
  console.log('šŸ“š Creating documentation files...');
2084
- await copyCLAUDEmd(targetDir);
2085
+ await copyCLAUDEmd(targetDir, options.force);
2085
2086
  // Create README files
2086
- await createReadmeFiles(targetDir);
2087
+ await createReadmeFiles(targetDir, options.force);
2087
2088
  }
2088
2089
  console.log(chalk_1.default.green.bold('\nāœ… Snow-Flow project initialized successfully!'));
2089
2090
  console.log('\nšŸ“‹ Created files and directories:');
@@ -2096,9 +2097,25 @@ program
2096
2097
  console.log(' āœ“ CLAUDE.md - Development documentation');
2097
2098
  console.log(' āœ“ README.md - Project documentation');
2098
2099
  if (!options.skipMcp) {
2099
- console.log(chalk_1.default.yellow.bold('\nšŸ“ MCP servers are configured for Claude Code'));
2100
- console.log('\nTo activate MCP servers in Claude Code, run:');
2101
- console.log(chalk_1.default.cyan(' claude --mcp-config .mcp.json .'));
2100
+ // Start MCP servers automatically
2101
+ console.log(chalk_1.default.yellow.bold('\nšŸš€ Starting MCP servers in the background...'));
2102
+ try {
2103
+ const { MCPServerManager } = await Promise.resolve().then(() => __importStar(require('./utils/mcp-server-manager.js')));
2104
+ const manager = new MCPServerManager();
2105
+ await manager.initialize();
2106
+ console.log('šŸ“” Starting all ServiceNow MCP servers...');
2107
+ await manager.startAllServers();
2108
+ const status = manager.getServerStatus();
2109
+ const running = status.filter((s) => s.status === 'running').length;
2110
+ const total = status.length;
2111
+ console.log(chalk_1.default.green(`āœ… Started ${running}/${total} MCP servers successfully!`));
2112
+ console.log(chalk_1.default.blue('\nšŸ“‹ MCP servers are now running in the background'));
2113
+ console.log('šŸŽÆ They will be available when you run swarm commands');
2114
+ }
2115
+ catch (error) {
2116
+ console.log(chalk_1.default.yellow('\nāš ļø Could not start MCP servers automatically'));
2117
+ console.log('šŸ“ You can start them manually with: ' + chalk_1.default.cyan('snow-flow mcp start'));
2118
+ }
2102
2119
  }
2103
2120
  }
2104
2121
  console.log(chalk_1.default.blue.bold('\nšŸŽÆ Next steps:'));
@@ -2106,6 +2123,8 @@ program
2106
2123
  console.log('2. Run: ' + chalk_1.default.cyan('snow-flow auth login'));
2107
2124
  console.log('3. Start developing: ' + chalk_1.default.cyan('snow-flow swarm "your objective"'));
2108
2125
  console.log('\nšŸ“š Full documentation: https://github.com/groeimetai/snow-flow');
2126
+ // Force exit to prevent hanging
2127
+ process.exit(0);
2109
2128
  }
2110
2129
  catch (error) {
2111
2130
  console.error(chalk_1.default.red('\nāŒ Initialization failed:'), error);
@@ -2174,7 +2193,7 @@ program
2174
2193
  `);
2175
2194
  });
2176
2195
  // Helper functions for init command
2177
- async function createDirectoryStructure(targetDir) {
2196
+ async function createDirectoryStructure(targetDir, force = false) {
2178
2197
  const directories = [
2179
2198
  '.claude', '.claude/commands', '.claude/commands/sparc', '.claude/configs',
2180
2199
  '.swarm', '.swarm/sessions', '.swarm/agents',
@@ -2213,10 +2232,10 @@ async function createBasicConfig(targetDir) {
2213
2232
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.claude/config.json'), JSON.stringify(claudeConfig, null, 2));
2214
2233
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.swarm/config.json'), JSON.stringify(swarmConfig, null, 2));
2215
2234
  }
2216
- async function createReadmeFiles(targetDir) {
2235
+ async function createReadmeFiles(targetDir, force = false) {
2217
2236
  // Only create README.md if it doesn't exist already
2218
2237
  const readmePath = (0, path_1.join)(targetDir, 'README.md');
2219
- if (!(0, fs_2.existsSync)(readmePath)) {
2238
+ if (!(0, fs_2.existsSync)(readmePath) || force) {
2220
2239
  const mainReadme = `# Snow-Flow: Multi-Agent ServiceNow Development Platform šŸš€
2221
2240
 
2222
2241
  Snow-Flow is a powerful multi-agent AI platform that revolutionizes ServiceNow development through intelligent automation, natural language processing, and autonomous deployment capabilities. Built with 11 specialized MCP (Model Context Protocol) servers, Snow-Flow enables developers to create, manage, and deploy ServiceNow artifacts using simple natural language commands.
@@ -3889,7 +3908,7 @@ For full documentation, visit: https://github.com/groeimetai/snow-flow
3889
3908
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdFallback);
3890
3909
  }
3891
3910
  }
3892
- async function copyCLAUDEmd(targetDir) {
3911
+ async function copyCLAUDEmd(targetDir, force = false) {
3893
3912
  let claudeMdContent = '';
3894
3913
  try {
3895
3914
  // First try to find the CLAUDE.md in the source directory (for global installs)
@@ -4327,7 +4346,20 @@ This is a minimal CLAUDE.md file. The full documentation should be available in
4327
4346
  For full documentation, visit: https://github.com/groeimetai/snow-flow
4328
4347
  `;
4329
4348
  }
4330
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdContent);
4349
+ const claudeMdPath = (0, path_1.join)(targetDir, 'CLAUDE.md');
4350
+ try {
4351
+ await fs_1.promises.access(claudeMdPath);
4352
+ if (force) {
4353
+ console.log('āš ļø CLAUDE.md already exists, overwriting with --force flag');
4354
+ await fs_1.promises.writeFile(claudeMdPath, claudeMdContent);
4355
+ }
4356
+ else {
4357
+ console.log('āš ļø CLAUDE.md already exists, skipping (use --force to overwrite)');
4358
+ }
4359
+ }
4360
+ catch {
4361
+ await fs_1.promises.writeFile(claudeMdPath, claudeMdContent);
4362
+ }
4331
4363
  }
4332
4364
  catch (error) {
4333
4365
  console.log('āš ļø Error copying CLAUDE.md, creating minimal version');
@@ -4342,10 +4374,13 @@ For full documentation, visit: https://github.com/groeimetai/snow-flow
4342
4374
 
4343
4375
  For full documentation, visit: https://github.com/groeimetai/snow-flow
4344
4376
  `;
4345
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdFallback);
4377
+ const claudeMdPath = (0, path_1.join)(targetDir, 'CLAUDE.md');
4378
+ if (force || !(0, fs_2.existsSync)(claudeMdPath)) {
4379
+ await fs_1.promises.writeFile(claudeMdPath, claudeMdFallback);
4380
+ }
4346
4381
  }
4347
4382
  }
4348
- async function createEnvFile(targetDir) {
4383
+ async function createEnvFile(targetDir, force = false) {
4349
4384
  const envContent = `# ServiceNow OAuth Configuration
4350
4385
  # Replace these values with your actual ServiceNow instance and OAuth credentials
4351
4386
 
@@ -4400,10 +4435,17 @@ SNOW_FLOW_TIMEOUT_MINUTES=0
4400
4435
  // Check if .env already exists
4401
4436
  try {
4402
4437
  await fs_1.promises.access(envFilePath);
4403
- console.log('āš ļø .env file already exists, creating .env.example template instead');
4404
- console.log('šŸ“ To recreate .env: delete existing .env file and run init again');
4405
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.env.example'), envContent);
4406
- console.log('āœ… .env.example template created');
4438
+ if (force) {
4439
+ console.log('āš ļø .env file already exists, overwriting with --force flag');
4440
+ await fs_1.promises.writeFile(envFilePath, envContent);
4441
+ console.log('āœ… .env file overwritten successfully');
4442
+ }
4443
+ else {
4444
+ console.log('āš ļø .env file already exists, creating .env.example template instead');
4445
+ console.log('šŸ“ To overwrite: use --force flag or delete existing .env file');
4446
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.env.example'), envContent);
4447
+ console.log('āœ… .env.example template created');
4448
+ }
4407
4449
  }
4408
4450
  catch {
4409
4451
  // .env doesn't exist, create it
@@ -4437,13 +4479,30 @@ async function checkNeo4jAvailability() {
4437
4479
  return false;
4438
4480
  }
4439
4481
  }
4440
- async function createMCPConfig(targetDir) {
4482
+ async function createMCPConfig(targetDir, force = false) {
4483
+ // Determine the snow-flow installation directory
4484
+ let snowFlowRoot;
4485
+ // Check if we're in a global npm installation
4486
+ const isGlobalInstall = __dirname.includes('node_modules/snow-flow') ||
4487
+ __dirname.includes('node_modules/.pnpm') ||
4488
+ __dirname.includes('npm/snow-flow');
4489
+ if (isGlobalInstall) {
4490
+ // For global installs, find the snow-flow package root
4491
+ const parts = __dirname.split(/node_modules[\/\\]/);
4492
+ snowFlowRoot = parts[0] + 'node_modules/snow-flow';
4493
+ }
4494
+ else {
4495
+ // For local development or local install
4496
+ snowFlowRoot = process.cwd();
4497
+ }
4498
+ // Ensure we have the correct path to dist directory
4499
+ const distPath = (0, path_1.join)(snowFlowRoot, 'dist');
4441
4500
  // Create the correct .mcp.json file for Claude Code discovery
4442
4501
  const mcpConfig = {
4443
4502
  "mcpServers": {
4444
4503
  "servicenow-deployment": {
4445
4504
  "command": "node",
4446
- "args": ["dist/mcp/servicenow-deployment-mcp.js"],
4505
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-deployment-mcp.js")],
4447
4506
  "env": {
4448
4507
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4449
4508
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4452,7 +4511,7 @@ async function createMCPConfig(targetDir) {
4452
4511
  },
4453
4512
  "servicenow-flow-composer": {
4454
4513
  "command": "node",
4455
- "args": ["dist/mcp/servicenow-flow-composer-mcp.js"],
4514
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-flow-composer-mcp.js")],
4456
4515
  "env": {
4457
4516
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4458
4517
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4461,7 +4520,7 @@ async function createMCPConfig(targetDir) {
4461
4520
  },
4462
4521
  "servicenow-update-set": {
4463
4522
  "command": "node",
4464
- "args": ["dist/mcp/servicenow-update-set-mcp.js"],
4523
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-update-set-mcp.js")],
4465
4524
  "env": {
4466
4525
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4467
4526
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4470,7 +4529,7 @@ async function createMCPConfig(targetDir) {
4470
4529
  },
4471
4530
  "servicenow-intelligent": {
4472
4531
  "command": "node",
4473
- "args": ["dist/mcp/servicenow-intelligent-mcp.js"],
4532
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-intelligent-mcp.js")],
4474
4533
  "env": {
4475
4534
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4476
4535
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4479,7 +4538,7 @@ async function createMCPConfig(targetDir) {
4479
4538
  },
4480
4539
  "servicenow-graph-memory": {
4481
4540
  "command": "node",
4482
- "args": ["dist/mcp/servicenow-graph-memory-mcp.js"],
4541
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-graph-memory-mcp.js")],
4483
4542
  "env": {
4484
4543
  "NEO4J_URI": "${NEO4J_URI}",
4485
4544
  "NEO4J_USER": "${NEO4J_USER}",
@@ -4491,7 +4550,7 @@ async function createMCPConfig(targetDir) {
4491
4550
  },
4492
4551
  "servicenow-operations": {
4493
4552
  "command": "node",
4494
- "args": ["dist/mcp/servicenow-operations-mcp.js"],
4553
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-operations-mcp.js")],
4495
4554
  "env": {
4496
4555
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4497
4556
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4500,7 +4559,7 @@ async function createMCPConfig(targetDir) {
4500
4559
  },
4501
4560
  "servicenow-platform-development": {
4502
4561
  "command": "node",
4503
- "args": ["dist/mcp/servicenow-platform-development-mcp.js"],
4562
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-platform-development-mcp.js")],
4504
4563
  "env": {
4505
4564
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4506
4565
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4509,7 +4568,7 @@ async function createMCPConfig(targetDir) {
4509
4568
  },
4510
4569
  "servicenow-integration": {
4511
4570
  "command": "node",
4512
- "args": ["dist/mcp/servicenow-integration-mcp.js"],
4571
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-integration-mcp.js")],
4513
4572
  "env": {
4514
4573
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4515
4574
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4518,7 +4577,7 @@ async function createMCPConfig(targetDir) {
4518
4577
  },
4519
4578
  "servicenow-automation": {
4520
4579
  "command": "node",
4521
- "args": ["dist/mcp/servicenow-automation-mcp.js"],
4580
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-automation-mcp.js")],
4522
4581
  "env": {
4523
4582
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4524
4583
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4527,7 +4586,7 @@ async function createMCPConfig(targetDir) {
4527
4586
  },
4528
4587
  "servicenow-security-compliance": {
4529
4588
  "command": "node",
4530
- "args": ["dist/mcp/servicenow-security-compliance-mcp.js"],
4589
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-security-compliance-mcp.js")],
4531
4590
  "env": {
4532
4591
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4533
4592
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4536,7 +4595,7 @@ async function createMCPConfig(targetDir) {
4536
4595
  },
4537
4596
  "servicenow-reporting-analytics": {
4538
4597
  "command": "node",
4539
- "args": ["dist/mcp/servicenow-reporting-analytics-mcp.js"],
4598
+ "args": [(0, path_1.join)(distPath, "mcp/servicenow-reporting-analytics-mcp.js")],
4540
4599
  "env": {
4541
4600
  "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4542
4601
  "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
@@ -4547,7 +4606,19 @@ async function createMCPConfig(targetDir) {
4547
4606
  };
4548
4607
  // Create .mcp.json in project root for Claude Code discovery
4549
4608
  const mcpConfigPath = (0, path_1.join)(targetDir, '.mcp.json');
4550
- await fs_1.promises.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
4609
+ try {
4610
+ await fs_1.promises.access(mcpConfigPath);
4611
+ if (force) {
4612
+ console.log('āš ļø .mcp.json already exists, overwriting with --force flag');
4613
+ await fs_1.promises.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
4614
+ }
4615
+ else {
4616
+ console.log('āš ļø .mcp.json already exists, skipping (use --force to overwrite)');
4617
+ }
4618
+ }
4619
+ catch {
4620
+ await fs_1.promises.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
4621
+ }
4551
4622
  // Also create legacy config in .claude for backward compatibility
4552
4623
  const legacyConfigPath = (0, path_1.join)(targetDir, '.claude/mcp-config.json');
4553
4624
  await fs_1.promises.writeFile(legacyConfigPath, JSON.stringify(mcpConfig, null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development inspired by claude-flow. Transform complex workflows into elegant one-command orchestration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",