snow-flow 1.4.4 → 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 +56 -18
  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:');
@@ -2122,6 +2123,8 @@ program
2122
2123
  console.log('2. Run: ' + chalk_1.default.cyan('snow-flow auth login'));
2123
2124
  console.log('3. Start developing: ' + chalk_1.default.cyan('snow-flow swarm "your objective"'));
2124
2125
  console.log('\nšŸ“š Full documentation: https://github.com/groeimetai/snow-flow');
2126
+ // Force exit to prevent hanging
2127
+ process.exit(0);
2125
2128
  }
2126
2129
  catch (error) {
2127
2130
  console.error(chalk_1.default.red('\nāŒ Initialization failed:'), error);
@@ -2190,7 +2193,7 @@ program
2190
2193
  `);
2191
2194
  });
2192
2195
  // Helper functions for init command
2193
- async function createDirectoryStructure(targetDir) {
2196
+ async function createDirectoryStructure(targetDir, force = false) {
2194
2197
  const directories = [
2195
2198
  '.claude', '.claude/commands', '.claude/commands/sparc', '.claude/configs',
2196
2199
  '.swarm', '.swarm/sessions', '.swarm/agents',
@@ -2229,10 +2232,10 @@ async function createBasicConfig(targetDir) {
2229
2232
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.claude/config.json'), JSON.stringify(claudeConfig, null, 2));
2230
2233
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.swarm/config.json'), JSON.stringify(swarmConfig, null, 2));
2231
2234
  }
2232
- async function createReadmeFiles(targetDir) {
2235
+ async function createReadmeFiles(targetDir, force = false) {
2233
2236
  // Only create README.md if it doesn't exist already
2234
2237
  const readmePath = (0, path_1.join)(targetDir, 'README.md');
2235
- if (!(0, fs_2.existsSync)(readmePath)) {
2238
+ if (!(0, fs_2.existsSync)(readmePath) || force) {
2236
2239
  const mainReadme = `# Snow-Flow: Multi-Agent ServiceNow Development Platform šŸš€
2237
2240
 
2238
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.
@@ -3905,7 +3908,7 @@ For full documentation, visit: https://github.com/groeimetai/snow-flow
3905
3908
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdFallback);
3906
3909
  }
3907
3910
  }
3908
- async function copyCLAUDEmd(targetDir) {
3911
+ async function copyCLAUDEmd(targetDir, force = false) {
3909
3912
  let claudeMdContent = '';
3910
3913
  try {
3911
3914
  // First try to find the CLAUDE.md in the source directory (for global installs)
@@ -4343,7 +4346,20 @@ This is a minimal CLAUDE.md file. The full documentation should be available in
4343
4346
  For full documentation, visit: https://github.com/groeimetai/snow-flow
4344
4347
  `;
4345
4348
  }
4346
- 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
+ }
4347
4363
  }
4348
4364
  catch (error) {
4349
4365
  console.log('āš ļø Error copying CLAUDE.md, creating minimal version');
@@ -4358,10 +4374,13 @@ For full documentation, visit: https://github.com/groeimetai/snow-flow
4358
4374
 
4359
4375
  For full documentation, visit: https://github.com/groeimetai/snow-flow
4360
4376
  `;
4361
- 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
+ }
4362
4381
  }
4363
4382
  }
4364
- async function createEnvFile(targetDir) {
4383
+ async function createEnvFile(targetDir, force = false) {
4365
4384
  const envContent = `# ServiceNow OAuth Configuration
4366
4385
  # Replace these values with your actual ServiceNow instance and OAuth credentials
4367
4386
 
@@ -4416,10 +4435,17 @@ SNOW_FLOW_TIMEOUT_MINUTES=0
4416
4435
  // Check if .env already exists
4417
4436
  try {
4418
4437
  await fs_1.promises.access(envFilePath);
4419
- console.log('āš ļø .env file already exists, creating .env.example template instead');
4420
- console.log('šŸ“ To recreate .env: delete existing .env file and run init again');
4421
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.env.example'), envContent);
4422
- 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
+ }
4423
4449
  }
4424
4450
  catch {
4425
4451
  // .env doesn't exist, create it
@@ -4453,7 +4479,7 @@ async function checkNeo4jAvailability() {
4453
4479
  return false;
4454
4480
  }
4455
4481
  }
4456
- async function createMCPConfig(targetDir) {
4482
+ async function createMCPConfig(targetDir, force = false) {
4457
4483
  // Determine the snow-flow installation directory
4458
4484
  let snowFlowRoot;
4459
4485
  // Check if we're in a global npm installation
@@ -4580,7 +4606,19 @@ async function createMCPConfig(targetDir) {
4580
4606
  };
4581
4607
  // Create .mcp.json in project root for Claude Code discovery
4582
4608
  const mcpConfigPath = (0, path_1.join)(targetDir, '.mcp.json');
4583
- 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
+ }
4584
4622
  // Also create legacy config in .claude for backward compatibility
4585
4623
  const legacyConfigPath = (0, path_1.join)(targetDir, '.claude/mcp-config.json');
4586
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.4",
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",