snow-flow 1.4.4 → 1.4.6

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/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.
@@ -2269,17 +2272,17 @@ Most intelligent features are now **enabled by default** - ÊÊn command voor al
2269
2272
  ### 🤖 11 Specialized MCP Servers
2270
2273
  Each server provides autonomous capabilities for different aspects of ServiceNow development:
2271
2274
 
2272
- 1. **Deployment MCP** - Autonomous widget, flow, and application deployment
2273
- 2. **Flow Composer MCP** - Natural language flow creation with intelligent analysis
2274
- 3. **Update Set MCP** - Professional change tracking and deployment management
2275
- 4. **Intelligent MCP** - AI-powered artifact discovery and editing
2276
- 5. **Graph Memory MCP** - Relationship tracking and impact analysis
2277
- 6. **Platform Development MCP** - Development workflow automation
2278
- 7. **Integration MCP** - Third-party system integration
2279
- 8. **Operations MCP** - Operations and monitoring management
2280
- 9. **Automation MCP** - Workflow and process automation
2281
- 10. **Security & Compliance MCP** - Security auditing and compliance
2282
- 11. **Reporting & Analytics MCP** - Data analysis and reporting
2275
+ 1. **Deployment MCP** - Autonomous widget and application deployment
2276
+ 2. **Update Set MCP** - Professional change tracking and deployment management
2277
+ 3. **Intelligent MCP** - AI-powered artifact discovery and editing
2278
+ 4. **Graph Memory MCP** - Relationship tracking and impact analysis
2279
+ 5. **Platform Development MCP** - Development workflow automation
2280
+ 6. **Integration MCP** - Third-party system integration
2281
+ 7. **Operations MCP** - Operations and monitoring management
2282
+ 8. **Automation MCP** - Workflow and process automation
2283
+ 9. **Security & Compliance MCP** - Security auditing and compliance
2284
+ 10. **Reporting & Analytics MCP** - Data analysis and reporting
2285
+ 11. **Memory MCP** - Multi-agent coordination and todo management
2283
2286
 
2284
2287
  ### đŸŽ¯ Core Capabilities
2285
2288
 
@@ -2556,7 +2559,6 @@ npm run build
2556
2559
 
2557
2560
  - [MCP Server Documentation](./MCP_SERVERS.md) - Detailed info on all 11 MCP servers
2558
2561
  - [OAuth Setup Guide](./SERVICENOW-OAUTH-SETUP.md) - ServiceNow OAuth configuration
2559
- - [Flow Composer Guide](./ENHANCED_FLOW_COMPOSER_DOCUMENTATION.md) - Advanced flow creation
2560
2562
  - [Update Set Guide](./UPDATE_SET_DEPLOYMENT_GUIDE.md) - Professional change management
2561
2563
  - [API Integration Guide](./API_INTEGRATION_GUIDE.md) - ServiceNow API details
2562
2564
 
@@ -3273,183 +3275,9 @@ await snow_update_set_add_artifact({
3273
3275
  ]
3274
3276
  };
3275
3277
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'memory/patterns/workflow-templates.json'), JSON.stringify(workflowPatternsContent, null, 2));
3276
- // Create quick start guide
3277
- const quickStartContent = `# Snow-Flow Quick Start Guide
3278
-
3279
- ## 🚀 5-Minute Setup
3280
-
3281
- ### 1. Initialize Your Project
3282
- \`\`\`bash
3283
- snow-flow init --sparc
3284
- \`\`\`
3285
-
3286
- ### 2. Configure ServiceNow OAuth
3287
- Edit the .env file with your ServiceNow credentials:
3288
- \`\`\`env
3289
- SNOW_INSTANCE=dev123456.service-now.com
3290
- SNOW_CLIENT_ID=your_oauth_client_id
3291
- SNOW_CLIENT_SECRET=your_oauth_client_secret
3292
- \`\`\`
3293
-
3294
- ### 3. Authenticate
3295
- \`\`\`bash
3296
- snow-flow auth login
3297
- \`\`\`
3298
-
3299
- ### 4. Create Your First Widget
3300
- \`\`\`bash
3301
- snow-flow swarm "create simple incident counter widget"
3302
- \`\`\`
3303
-
3304
- ## 📋 What Just Happened?
3305
-
3306
- When you ran the swarm command, Snow-Flow:
3307
- 1. ✅ Validated your ServiceNow connection
3308
- 2. ✅ Analyzed your objective using Queen Agent
3309
- 3. ✅ Spawned 6+ parallel agents (widget-creator, css-specialist, backend-specialist, frontend-specialist, integration-specialist, tester)
3310
- 4. ✅ Created a real widget in your ServiceNow instance
3311
- 5. ✅ Tracked everything in an Update Set
3312
- 6. ✅ Tested the widget automatically
3313
-
3314
- ## đŸŽ¯ Next Steps
3315
-
3316
- ### Try More Examples
3317
- \`\`\`bash
3318
- # Create a workflow
3319
- snow-flow swarm "create simple approval workflow"
3320
-
3321
- # Build a dashboard
3322
- snow-flow swarm "create IT dashboard with KPIs"
3323
-
3324
- # Develop an application
3325
- snow-flow swarm "create basic ticketing system"
3326
- \`\`\`
3327
-
3328
- ### Explore Documentation
3329
- - **Swarm Patterns**: .claude/commands/swarm-patterns.md
3330
- - **Agent Types**: .claude/commands/agent-types.md
3331
- - **MCP Tools**: .claude/commands/mcp-tools-quick-ref.md
3332
- - **Examples**: ./examples/
3333
-
3334
- ### Monitor Progress
3335
- \`\`\`bash
3336
- # Check swarm status
3337
- snow-flow swarm-status <sessionId>
3338
-
3339
- # View system status
3340
- snow-flow status
3341
- \`\`\`
3342
-
3343
- ## 💡 Pro Tips
3344
-
3345
- 1. **Start Simple**: Let the Queen Agent handle complexity
3346
- 2. **Use Natural Language**: Describe what you want, not how
3347
- 3. **Trust the Defaults**: Intelligent features are enabled
3348
- 4. **Check Examples**: Run scripts in ./examples/ folder
3349
-
3350
- ## 🆘 Need Help?
3351
-
3352
- - **Auth Issues**: Run \`snow-flow auth status\`
3353
- - **MCP Tools**: Check .claude/commands/mcp-tools-quick-ref.md
3354
- - **Agent Info**: See .claude/commands/agent-types.md
3355
- - **GitHub**: https://github.com/groeimetai/snow-flow
3356
-
3357
- Happy ServiceNow Development! 🎉
3358
- `;
3359
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'QUICK_START.md'), quickStartContent);
3360
- // Create example scripts
3361
- const widgetExampleContent = `#!/bin/bash
3362
- # Example: Create an incident dashboard widget
3363
-
3364
- # This example shows how to create a comprehensive incident dashboard
3365
- # with real-time data, charts, and mobile responsiveness
3366
-
3367
- snow-flow swarm "create incident dashboard widget with:
3368
- - Real-time incident counts by priority (Critical, High, Medium, Low)
3369
- - Chart.js bar chart showing incidents by category
3370
- - Line graph for incident trends over the last 7 days
3371
- - Responsive grid layout for mobile devices
3372
- - Auto-refresh every 30 seconds
3373
- - Click-through to incident details
3374
- - Color coding for priority levels (red for critical, orange for high)
3375
- - Export to PDF functionality
3376
- - Filter by assignment group"
3377
-
3378
- # The Queen Agent will:
3379
- # 1. Spawn widget-creator as primary agent
3380
- # 2. Add ui-designer for responsive design
3381
- # 3. Add tester for validation
3382
- # 4. Create complete widget in ServiceNow
3383
- # 5. Test on mobile and desktop
3384
- # 6. Deploy with Update Set tracking
3385
- `;
3386
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'examples/widget-dashboard.sh'), widgetExampleContent);
3387
- await fs_1.promises.chmod((0, path_1.join)(targetDir, 'examples/widget-dashboard.sh'), '755');
3388
- const approvalFlowExampleContent = `#!/bin/bash
3389
- # Example: Create equipment approval workflow
3390
-
3391
- # This example demonstrates creating a multi-level approval workflow
3392
- # with dynamic routing based on cost and department
3393
-
3394
- snow-flow swarm "create approval workflow for equipment requests with:
3395
- - Automatic approval for items under $100
3396
- - Manager approval for items $100-$1000
3397
- - Department head approval for items $1000-$5000
3398
- - VP approval for items over $5000
3399
- - IT approval required for all technology items regardless of cost
3400
- - Finance review for items over $10000
3401
- - Email notifications at each approval step
3402
- - Slack notifications for urgent requests
3403
- - 48-hour SLA with escalation
3404
- - Rejection reasons and resubmission process
3405
- - Integration with catalog items for equipment selection
3406
- - Automatic PO generation upon final approval"
3407
-
3408
- # The Queen Agent will:
3409
- # 1. Spawn flow-builder as primary agent
3410
- # 2. Add security agent for approval permissions
3411
- # 3. Add tester for all approval paths
3412
- # 4. Create complex flow with conditions
3413
- # 5. Link to catalog items
3414
- # 6. Test all approval scenarios
3415
- # 7. Validate email notifications
3416
- `;
3417
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'examples/approval-workflow.sh'), approvalFlowExampleContent);
3418
- await fs_1.promises.chmod((0, path_1.join)(targetDir, 'examples/approval-workflow.sh'), '755');
3419
- const itsmApplicationExampleContent = `#!/bin/bash
3420
- # Example: Create complete ITSM solution
3421
-
3422
- # This example shows how to build a full IT Service Management application
3423
- # with custom tables, workflows, and user interfaces
3424
-
3425
- snow-flow swarm "create complete ITSM solution for laptop provisioning with:
3426
- - Custom request table extending task table
3427
- - Fields: laptop_model, specifications, justification, cost_center
3428
- - Catalog item for laptop requests with dynamic pricing
3429
- - Multi-stage approval workflow based on cost and user role
3430
- - Integration with asset management for laptop assignment
3431
- - Automated Active Directory account provisioning
3432
- - Email notifications to user, manager, and IT
3433
- - Dashboard showing request status and metrics
3434
- - SLA tracking with 5-day fulfillment target
3435
- - Mobile-friendly request portal
3436
- - Reporting on request volumes and fulfillment times
3437
- - Return process for laptop replacement
3438
- - Integration with purchase order system"
3439
-
3440
- # The Queen Agent will:
3441
- # 1. Spawn app-architect to design the solution
3442
- # 2. Add flow-builder for approval workflows
3443
- # 3. Add widget-creator for dashboards
3444
- # 4. Add script-writer for integrations
3445
- # 5. Add security for access controls
3446
- # 6. Add tester for end-to-end validation
3447
- # 7. Create all components in sequence
3448
- # 8. Deploy complete solution
3449
- `;
3450
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'examples/itsm-application.sh'), itsmApplicationExampleContent);
3451
- await fs_1.promises.chmod((0, path_1.join)(targetDir, 'examples/itsm-application.sh'), '755');
3452
- // Create CLAUDE.md by copying from source (v1.1.62+)
3278
+ }
3279
+ // Helper functions
3280
+ async function copyCLAUDEmd(targetDir, force = false) {
3453
3281
  let claudeMdContent = '';
3454
3282
  try {
3455
3283
  // First try to find the CLAUDE.md in the source directory (for global installs)
@@ -3477,56 +3305,96 @@ snow-flow swarm "create complete ITSM solution for laptop provisioning with:
3477
3305
  }
3478
3306
  }
3479
3307
  if (!foundSource) {
3480
- // Fallback to a minimal CLAUDE.md if source not found
3308
+ // Use Snow-Flow specific CLAUDE.md content
3481
3309
  console.log('âš ī¸ Could not find CLAUDE.md source, creating minimal version');
3482
3310
  claudeMdContent = `# Snow-Flow Development with Claude Code
3483
3311
 
3484
- ## 🚀 Core Development Principles
3312
+ ## 🚨 CRITICAL: MCP-FIRST WORKFLOW (READ THIS FIRST!)
3485
3313
 
3486
- ### Concurrent Execution Strategy
3487
- **Golden Rule**: "1 MESSAGE = ALL RELATED OPERATIONS"
3488
- - Always batch related MCP tool calls in a single response
3489
- - Use TodoWrite extensively for complex task coordination
3490
- - Launch multiple agents concurrently for maximum performance
3491
- - Leverage batch file operations whenever reading/writing multiple files
3314
+ **Snow-flow's core value is REAL ServiceNow integration through MCP tools. NEVER work in offline mode!**
3492
3315
 
3493
- ### ServiceNow Development Best Practices
3494
- 1. **Never hardcode credentials** - Use OAuth and environment variables
3495
- 2. **Always work in Update Sets** - Provides rollback safety
3496
- 3. **Test before deploy** - Use mock testing tools for validation
3497
- 4. **Validate permissions** - Check OAuth scopes before operations
3498
- 5. **Use fuzzy search** - ServiceNow names can vary (iPhone vs iPhone 6S)
3316
+ ### âš ī¸ MANDATORY WORKFLOW - NO EXCEPTIONS
3499
3317
 
3500
- ## 📋 Essential MCP Tool Patterns
3318
+ **Every ServiceNow task MUST start with this sequence:**
3501
3319
 
3502
- ### Batch Operations for Maximum Efficiency
3503
3320
  \`\`\`javascript
3504
- // GOOD: Single message with multiple tool calls
3505
- TodoWrite([...tasks]);
3506
- Task("Architect", "Design system architecture");
3507
- Task("Developer", "Implement components");
3508
- Task("Tester", "Create test scenarios");
3509
-
3510
- // BAD: Sequential single operations
3511
- TodoWrite([task1]);
3512
- // wait for response
3513
- TodoWrite([task2]);
3514
- // wait for response
3515
- \`\`\`
3321
+ // 1. MANDATORY: Pre-flight authentication check
3322
+ const authCheck = await snow_validate_live_connection({ test_level: "permissions" });
3323
+ if (!authCheck.success) {
3324
+ // STOP! Fix authentication first
3325
+ return authenticationError(authCheck.error);
3326
+ }
3516
3327
 
3517
- ### Memory-Driven Coordination
3518
- Use Memory to coordinate information across agents:
3519
- \`\`\`javascript
3520
- // Store architecture decisions
3521
- snow_memory_store({
3522
- key: "widget_architecture",
3523
- value: "Service Portal widget with Chart.js for data visualization"
3328
+ // 2. MANDATORY: Discovery before creation
3329
+ const discovery = await snow_find_artifact({
3330
+ query: "your objective",
3331
+ type: "widget|flow|script|any"
3524
3332
  });
3525
3333
 
3526
- // All agents can reference this
3527
- Task("Frontend Dev", "Implement widget based on widget_architecture in memory");
3528
- Task("Backend Dev", "Create REST endpoints for widget_architecture requirements");
3334
+ // 3. MANDATORY: Real ServiceNow deployment
3335
+ const deployment = await snow_deploy({
3336
+ type: "widget|application", // Note: flow removed in v1.4.0+
3337
+ config: { /* your config */ },
3338
+ auto_update_set: true // Always track changes
3339
+ });
3340
+
3341
+ // 4. MANDATORY: Track in Update Set
3342
+ await snow_update_set_add_artifact({
3343
+ type: deployment.type,
3344
+ sys_id: deployment.result.sys_id,
3345
+ name: deployment.result.name
3346
+ });
3347
+ \`\`\`
3348
+
3349
+ ### đŸšĢ FORBIDDEN ACTIONS
3350
+
3351
+ **THESE ACTIONS ARE BANNED - NEVER DO THESE:**
3352
+
3353
+ ❌ **Creating local files** without MCP check first
3354
+ ❌ **Generating mock data** instead of using MCP tools
3355
+ ❌ **Working in "offline mode"** when ServiceNow is available
3356
+ ❌ **Skipping authentication validation**
3357
+ ❌ **Planning mode** without trying MCP tools first
3358
+
3359
+ ### ✅ CORRECT: MCP-First Decision Tree
3360
+
3529
3361
  \`\`\`
3362
+ User Request → ALWAYS START HERE:
3363
+ ↓
3364
+ 1. snow_validate_live_connection()
3365
+ ↓
3366
+ SUCCESS? → Continue to Step 2
3367
+ ↓
3368
+ FAILURE? → Fix auth: snow_auth_diagnostics()
3369
+ Then guide user: "snow-flow auth login"
3370
+ STOP until auth works
3371
+ ↓
3372
+ 2. snow_find_artifact() // Check if exists
3373
+ ↓
3374
+ FOUND? → Ask: "Reuse existing or create new?"
3375
+ ↓
3376
+ NOT FOUND? → Continue to Step 3
3377
+ ↓
3378
+ 3. snow_deploy() // Real deployment to ServiceNow
3379
+ ↓
3380
+ SUCCESS? → Step 4: Track in Update Set
3381
+ ↓
3382
+ FAILURE? → Use fallback strategies
3383
+ ↓
3384
+ 4. snow_update_set_add_artifact() // Always track
3385
+ ↓
3386
+ DONE! ✅
3387
+ \`\`\`
3388
+
3389
+ ## 🚀 Snow-Flow Swarm Command - MCP-Orchestrated Multi-Agent Intelligence
3390
+
3391
+ **The Swarm system is MCP-native and ALWAYS uses ServiceNow tools first!**
3392
+
3393
+ ### 🧠 Queen Agent with Parallel Execution (v1.4.0+)
3394
+ - Automatically spawns 6+ specialized agents for widget development
3395
+ - Achieves proven 2.8x speedup through intelligent parallel execution
3396
+ - All agents coordinate through Snow-Flow's memory system
3397
+ - Every agent uses MCP tools directly - no offline mode
3530
3398
 
3531
3399
  ## đŸ› ī¸ Complete ServiceNow MCP Tools Reference
3532
3400
 
@@ -3887,101 +3755,123 @@ This is a minimal CLAUDE.md file. The full documentation should be available in
3887
3755
  For full documentation, visit: https://github.com/groeimetai/snow-flow
3888
3756
  `;
3889
3757
  }
3890
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdContent);
3758
+ const claudeMdPath = (0, path_1.join)(targetDir, 'CLAUDE.md');
3759
+ try {
3760
+ await fs_1.promises.access(claudeMdPath);
3761
+ if (force) {
3762
+ console.log('âš ī¸ CLAUDE.md already exists, overwriting with --force flag');
3763
+ await fs_1.promises.writeFile(claudeMdPath, claudeMdContent);
3764
+ }
3765
+ else {
3766
+ console.log('âš ī¸ CLAUDE.md already exists, skipping (use --force to overwrite)');
3767
+ }
3768
+ }
3769
+ catch {
3770
+ await fs_1.promises.writeFile(claudeMdPath, claudeMdContent);
3771
+ }
3891
3772
  }
3892
3773
  catch (error) {
3893
- console.log('âš ī¸ Error copying CLAUDE.md, creating minimal version');
3894
- // Minimal fallback
3774
+ console.log('âš ī¸ Error copying CLAUDE.md, creating Snow-Flow specific version');
3775
+ // Snow-Flow specific fallback content
3895
3776
  const claudeMdFallback = `# Snow-Flow Development with Claude Code
3896
3777
 
3897
- ## Quick Start
3898
- 1. \`snow-flow init --sparc\` - Initialize project with SPARC environment
3899
- 2. Configure ServiceNow credentials in .env file
3900
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow OAuth
3901
- 4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
3778
+ ## 🚨 CRITICAL: MCP-FIRST WORKFLOW (READ THIS FIRST!)
3902
3779
 
3903
- For full documentation, visit: https://github.com/groeimetai/snow-flow
3904
- `;
3905
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdFallback);
3906
- }
3780
+ **Snow-flow's core value is REAL ServiceNow integration through MCP tools. NEVER work in offline mode!**
3781
+
3782
+ ### âš ī¸ MANDATORY WORKFLOW - NO EXCEPTIONS
3783
+
3784
+ **Every ServiceNow task MUST start with this sequence:**
3785
+
3786
+ \`\`\`javascript
3787
+ // 1. MANDATORY: Pre-flight authentication check
3788
+ const authCheck = await snow_validate_live_connection({ test_level: "permissions" });
3789
+ if (!authCheck.success) {
3790
+ // STOP! Fix authentication first
3791
+ return authenticationError(authCheck.error);
3907
3792
  }
3908
- async function copyCLAUDEmd(targetDir) {
3909
- let claudeMdContent = '';
3910
- try {
3911
- // First try to find the CLAUDE.md in the source directory (for global installs)
3912
- const sourceClaudeFiles = [
3913
- // Try the project root (when running from dist/)
3914
- (0, path_1.join)(__dirname, '..', 'CLAUDE.md'),
3915
- // Try when running directly from src/
3916
- (0, path_1.join)(__dirname, 'CLAUDE.md'),
3917
- // Try npm global installation paths
3918
- (0, path_1.join)(__dirname, '..', '..', '..', 'CLAUDE.md'),
3919
- (0, path_1.join)(__dirname, '..', '..', '..', '..', 'CLAUDE.md'),
3920
- // Try current working directory as fallback
3921
- (0, path_1.join)(process.cwd(), 'CLAUDE.md')
3922
- ];
3923
- let foundSource = false;
3924
- for (const sourcePath of sourceClaudeFiles) {
3925
- try {
3926
- claudeMdContent = await fs_1.promises.readFile(sourcePath, 'utf8');
3927
- foundSource = true;
3928
- console.log(`✅ Found CLAUDE.md source at: ${sourcePath}`);
3929
- break;
3930
- }
3931
- catch {
3932
- // Continue to next path
3933
- }
3934
- }
3935
- if (!foundSource) {
3936
- // Fallback to a minimal CLAUDE.md if source not found
3937
- console.log('âš ī¸ Could not find CLAUDE.md source, creating minimal version');
3938
- claudeMdContent = `# Snow-Flow Development with Claude Code
3939
3793
 
3940
- ## 🚀 Core Development Principles
3794
+ // 2. MANDATORY: Discovery before creation
3795
+ const discovery = await snow_find_artifact({
3796
+ query: "your objective",
3797
+ type: "widget|flow|script|any"
3798
+ });
3799
+
3800
+ // 3. MANDATORY: Real ServiceNow deployment
3801
+ const deployment = await snow_deploy({
3802
+ type: "widget|application", // Note: flow removed in v1.4.0+
3803
+ config: { /* your config */ },
3804
+ auto_update_set: true // Always track changes
3805
+ });
3806
+
3807
+ // 4. MANDATORY: Track in Update Set
3808
+ await snow_update_set_add_artifact({
3809
+ type: deployment.type,
3810
+ sys_id: deployment.result.sys_id,
3811
+ name: deployment.result.name
3812
+ });
3813
+ \`\`\`
3814
+
3815
+ ### đŸšĢ FORBIDDEN ACTIONS
3941
3816
 
3942
- ### Concurrent Execution Strategy
3943
- **Golden Rule**: "1 MESSAGE = ALL RELATED OPERATIONS"
3944
- - Always batch related MCP tool calls in a single response
3945
- - Use TodoWrite extensively for complex task coordination
3946
- - Launch multiple agents concurrently for maximum performance
3947
- - Leverage batch file operations whenever reading/writing multiple files
3817
+ **THESE ACTIONS ARE BANNED - NEVER DO THESE:**
3948
3818
 
3949
- ### ServiceNow Development Best Practices
3950
- 1. **Never hardcode credentials** - Use OAuth and environment variables
3951
- 2. **Always work in Update Sets** - Provides rollback safety
3952
- 3. **Test before deploy** - Use mock testing tools for validation
3953
- 4. **Validate permissions** - Check OAuth scopes before operations
3954
- 5. **Use fuzzy search** - ServiceNow names can vary (iPhone vs iPhone 6S)
3819
+ ❌ **Creating local files** without MCP check first
3820
+ ❌ **Generating mock data** instead of using MCP tools
3821
+ ❌ **Working in "offline mode"** when ServiceNow is available
3822
+ ❌ **Skipping authentication validation**
3823
+ ❌ **Planning mode** without trying MCP tools first
3955
3824
 
3956
- ## 📋 Essential MCP Tool Patterns
3825
+ ### ✅ CORRECT: MCP-First Decision Tree
3957
3826
 
3958
- ### Batch Operations for Maximum Efficiency
3959
- \`\`\`javascript
3960
- // GOOD: Single message with multiple tool calls
3961
- TodoWrite([...tasks]);
3962
- Task("Architect", "Design system architecture");
3963
- Task("Developer", "Implement components");
3964
- Task("Tester", "Create test scenarios");
3965
-
3966
- // BAD: Sequential single operations
3967
- TodoWrite([task1]);
3968
- // wait for response
3969
- TodoWrite([task2]);
3970
- // wait for response
3827
+ \`\`\`
3828
+ User Request → ALWAYS START HERE:
3829
+ ↓
3830
+ 1. snow_validate_live_connection()
3831
+ ↓
3832
+ SUCCESS? → Continue to Step 2
3833
+ ↓
3834
+ FAILURE? → Fix auth: snow_auth_diagnostics()
3835
+ Then guide user: "snow-flow auth login"
3836
+ STOP until auth works
3837
+ ↓
3838
+ 2. snow_find_artifact() // Check if exists
3839
+ ↓
3840
+ FOUND? → Ask: "Reuse existing or create new?"
3841
+ ↓
3842
+ NOT FOUND? → Continue to Step 3
3843
+ ↓
3844
+ 3. snow_deploy() // Real deployment to ServiceNow
3845
+ ↓
3846
+ SUCCESS? → Step 4: Track in Update Set
3847
+ ↓
3848
+ FAILURE? → Use fallback strategies
3849
+ ↓
3850
+ 4. snow_update_set_add_artifact() // Always track
3851
+ ↓
3852
+ DONE! ✅
3971
3853
  \`\`\`
3972
3854
 
3973
- ### Memory-Driven Coordination
3974
- Use Memory to coordinate information across agents:
3975
- \`\`\`javascript
3976
- // Store architecture decisions
3977
- snow_memory_store({
3978
- key: "widget_architecture",
3979
- value: "Service Portal widget with Chart.js for data visualization"
3980
- });
3855
+ ## 🚀 Snow-Flow Swarm Command - MCP-Orchestrated Multi-Agent Intelligence
3981
3856
 
3982
- // All agents can reference this
3983
- Task("Frontend Dev", "Implement widget based on widget_architecture in memory");
3984
- Task("Backend Dev", "Create REST endpoints for widget_architecture requirements");
3857
+ **The Swarm system is MCP-native and ALWAYS uses ServiceNow tools first!**
3858
+
3859
+ ### 🧠 Queen Agent with Parallel Execution (v1.4.0+)
3860
+ - Automatically spawns 6+ specialized agents for widget development
3861
+ - Achieves proven 2.8x speedup through intelligent parallel execution
3862
+ - All agents coordinate through Snow-Flow's memory system
3863
+ - Every agent uses MCP tools directly - no offline mode
3864
+
3865
+ ### Swarm Command Examples
3866
+ \`\`\`bash
3867
+ # Simple widget creation
3868
+ snow-flow swarm "create incident dashboard widget"
3869
+
3870
+ # Complex development
3871
+ snow-flow swarm "build employee onboarding portal with approval workflows"
3872
+
3873
+ # With specific options
3874
+ snow-flow swarm "create service catalog item" --no-auto-deploy --monitor
3985
3875
  \`\`\`
3986
3876
 
3987
3877
  ## đŸ› ī¸ Complete ServiceNow MCP Tools Reference
@@ -3998,370 +3888,161 @@ snow_find_artifact({
3998
3888
  snow_catalog_item_search({
3999
3889
  query: "laptop",
4000
3890
  fuzzy_match: true, // Finds variations: notebook, MacBook, etc.
4001
- category_filter: "hardware",
4002
- include_variables: true // Get catalog variables too
3891
+ include_variables: true // Include catalog variables
4003
3892
  });
4004
3893
 
4005
- // Direct sys_id lookup (faster than search)
4006
- snow_get_by_sysid({
4007
- sys_id: "<artifact_sys_id>",
4008
- table: "sp_widget"
3894
+ // Comprehensive search across all tables
3895
+ snow_comprehensive_search({
3896
+ query: "approval",
3897
+ include_inactive: false
4009
3898
  });
4010
3899
  \`\`\`
4011
3900
 
4012
- ### Flow Development Tools
3901
+ ### Deployment Tools
4013
3902
  \`\`\`javascript
4014
- // Create flows from natural language
4015
- snow_create_flow({
4016
- instruction: "create a flow that sends email when incident priority is high",
4017
- deploy_immediately: true // Automatically deploys XML to ServiceNow
4018
- });
4019
-
4020
- // Test flows with mock data
4021
- snow_test_flow_with_mock({
4022
- flow_id: "incident_notification_flow",
4023
- create_test_user: true,
4024
- mock_catalog_items: true,
4025
- test_inputs: {
4026
- priority: "1",
4027
- category: "hardware"
3903
+ // Universal deployment tool
3904
+ snow_deploy({
3905
+ type: "widget",
3906
+ config: {
3907
+ name: "Incident Dashboard",
3908
+ template: "<html>...</html>",
3909
+ css: "/* styles */",
3910
+ server_script: "// server code",
3911
+ client_script: "// client code"
4028
3912
  },
4029
- simulate_approvals: true
3913
+ auto_update_set: true
4030
3914
  });
4031
3915
 
4032
- // Link catalog items to flows
4033
- snow_link_catalog_to_flow({
4034
- catalog_item_id: "New Laptop Request",
4035
- flow_id: "laptop_provisioning_flow",
4036
- link_type: "flow_catalog_process",
4037
- variable_mapping: [
4038
- {
4039
- catalog_variable: "laptop_model",
4040
- flow_input: "equipment_type"
4041
- }
4042
- ]
3916
+ // Bulk deployment
3917
+ snow_bulk_deploy({
3918
+ artifacts: [...],
3919
+ transaction_mode: true,
3920
+ rollback_on_error: true
4043
3921
  });
4044
3922
  \`\`\`
4045
3923
 
4046
- ### Widget Development Tools
3924
+ ### Update Set Management
4047
3925
  \`\`\`javascript
4048
- // Deploy widgets with automatic validation
4049
- snow_deploy_widget({
4050
- name: "incident_dashboard",
4051
- title: "Incident Dashboard",
4052
- template: htmlContent,
4053
- css: cssContent,
4054
- client_script: clientJS,
4055
- server_script: serverJS,
4056
- demo_data: { incidents: [...] }
3926
+ // Ensure active Update Set
3927
+ snow_ensure_active_update_set({
3928
+ context: "Widget development"
4057
3929
  });
4058
3930
 
4059
- // Preview and test widgets
4060
- snow_preview_widget({
4061
- widget_id: "incident_dashboard",
4062
- check_dependencies: true
3931
+ // Track artifacts
3932
+ snow_update_set_add_artifact({
3933
+ type: "widget",
3934
+ sys_id: "abc123",
3935
+ name: "My Widget"
4063
3936
  });
4064
3937
 
4065
- snow_widget_test({
4066
- widget_id: "incident_dashboard",
4067
- test_scenarios: [
4068
- {
4069
- name: "Load with no data",
4070
- server_data: { incidents: [] }
4071
- }
4072
- ]
3938
+ // Preview changes
3939
+ snow_update_set_preview({
3940
+ update_set_id: "current"
4073
3941
  });
4074
3942
  \`\`\`
4075
3943
 
4076
- ### Bulk Operations
4077
- \`\`\`javascript
4078
- // Deploy multiple artifacts at once
4079
- snow_bulk_deploy({
4080
- artifacts: [
4081
- { type: "widget", data: widgetData },
4082
- { type: "flow", data: flowData },
4083
- { type: "script", data: scriptData }
4084
- ],
4085
- transaction_mode: true, // All or nothing
4086
- parallel: true, // Deploy simultaneously
4087
- dry_run: false
4088
- });
4089
- \`\`\`
4090
-
4091
- ### Intelligent Analysis
3944
+ ### Testing Tools
4092
3945
  \`\`\`javascript
4093
- // Analyze incidents with AI
4094
- snow_analyze_incident({
4095
- incident_id: "INC0010001",
4096
- include_similar: true,
4097
- suggest_resolution: true
3946
+ // Test flows with mock data
3947
+ snow_test_flow_with_mock({
3948
+ flow_id: "equipment_provisioning_flow",
3949
+ create_test_user: true,
3950
+ mock_catalog_items: true,
3951
+ simulate_approvals: true,
3952
+ cleanup_after_test: true
4098
3953
  });
4099
3954
 
4100
- // Pattern analysis
4101
- snow_pattern_analysis({
4102
- analysis_type: "incident_patterns",
4103
- timeframe: "month"
3955
+ // Link catalog to flow
3956
+ snow_link_catalog_to_flow({
3957
+ catalog_item_id: "iPhone 6S",
3958
+ flow_id: "mobile_provisioning_flow",
3959
+ test_link: true
4104
3960
  });
4105
3961
  \`\`\`
4106
3962
 
4107
- ## ⚡ Performance Optimization
4108
-
4109
- ### Parallel Execution Patterns
4110
- \`\`\`javascript
4111
- // Execute multiple searches concurrently
4112
- Promise.all([
4113
- snow_find_artifact({ query: "incident widget" }),
4114
- snow_catalog_item_search({ query: "laptop" }),
4115
- snow_query_incidents({ query: "priority=1" })
4116
- ]);
4117
- \`\`\`
3963
+ ## 📋 Essential Patterns
4118
3964
 
4119
- ### Batch File Operations
3965
+ ### Authentication Handling
4120
3966
  \`\`\`javascript
4121
- // Read multiple files in one operation
4122
- MultiRead([
4123
- "/path/to/widget.html",
4124
- "/path/to/widget.css",
4125
- "/path/to/widget.js"
4126
- ]);
3967
+ // Always handle auth failures gracefully
3968
+ if (error.includes('401') || error.includes('403')) {
3969
+ // Guide user to fix authentication
3970
+ console.log('Run: snow-flow auth login');
3971
+ console.log('Check .env file for credentials');
3972
+ // STOP - don't continue without auth
3973
+ }
4127
3974
  \`\`\`
4128
3975
 
4129
- ## 📝 Workflow Guidelines
4130
-
4131
- ### Standard Development Flow
4132
- 1. **Discovery Phase**: Use search tools to find existing artifacts
4133
- 2. **Planning Phase**: Use TodoWrite to plan all tasks
4134
- 3. **Development Phase**: Launch agents concurrently
4135
- 4. **Testing Phase**: Use mock testing tools
4136
- 5. **Deployment Phase**: Use bulk deploy with validation
4137
-
4138
- ### Error Recovery Patterns
3976
+ ### Error Recovery
4139
3977
  \`\`\`javascript
4140
- // Always implement rollback strategies
3978
+ // Implement fallback strategies
4141
3979
  if (deployment.failed) {
4142
- snow_deployment_rollback_manager({
4143
- update_set_id: deployment.update_set,
4144
- restore_point: deployment.backup_id
3980
+ // Try global scope
3981
+ const globalAttempt = await snow_deploy({
3982
+ ...config,
3983
+ scope_preference: 'global'
4145
3984
  });
3985
+
3986
+ if (globalAttempt.failed) {
3987
+ // Provide manual instructions
3988
+ return createManualStepsGuide(config, error);
3989
+ }
4146
3990
  }
4147
3991
  \`\`\`
4148
3992
 
4149
- ## 🔧 Advanced Configuration
3993
+ ## 🔧 Configuration
4150
3994
 
4151
- ## Build Commands
3995
+ ### Build Commands
4152
3996
  - \`npm run build\`: Build the project
4153
3997
  - \`npm run test\`: Run the full test suite
4154
3998
  - \`npm run lint\`: Run ESLint and format checks
4155
3999
  - \`npm run typecheck\`: Run TypeScript type checking
4156
4000
 
4157
- ## Snow-Flow Commands
4158
- - \`snow-flow init --sparc\`: Initialize project with SPARC environment
4159
- - \`snow-flow auth login\`: Authenticate with ServiceNow OAuth
4160
- - \`snow-flow swarm "<objective>"\`: Start multi-agent swarm - ÊÊn command voor alles!
4161
- - \`snow-flow sparc <mode> "<task>"\`: Run specific SPARC mode
4162
-
4163
- ## Enhanced Swarm Command (v1.1.41+)
4164
- The swarm command now includes intelligent features that are **enabled by default**:
4001
+ ### Snow-Flow Commands
4002
+ - \`snow-flow init --sparc\`: Initialize project with MCP servers
4003
+ - \`snow-flow auth login\`: Authenticate with ServiceNow
4004
+ - \`snow-flow swarm "<objective>"\`: Execute multi-agent development
4005
+ - \`snow-flow mcp start\`: Start MCP servers manually
4165
4006
 
4007
+ ### Environment Setup
4166
4008
  \`\`\`bash
4167
- # Simple usage - ALL autonomous systems enabled by default!
4168
- snow-flow swarm "create incident management dashboard"
4169
-
4170
- # Disable specific autonomous systems if needed
4171
- snow-flow swarm "create simple widget" --no-autonomous-cost-optimization --no-autonomous-compliance
4172
-
4173
- # Disable ALL autonomous systems
4174
- snow-flow swarm "basic development only" --no-autonomous-all
4175
-
4176
- # Force enable all (overrides any --no- flags)
4177
- snow-flow swarm "full orchestration mode" --autonomous-all
4178
- \`\`\`
4179
-
4180
- ### 🤖 NEW: Autonomous Systems (v1.3.26+) - **ENABLED BY DEFAULT!**
4181
- True orchestration with zero manual intervention - all systems active unless disabled:
4182
-
4183
- - ✅ **Documentation**: Self-documenting system (auto-generates and updates docs)
4184
- - ✅ **Cost Optimization**: AI-driven cost management with auto-optimization
4185
- - ✅ **Compliance**: Multi-framework compliance monitoring with auto-remediation
4186
- - ✅ **Self-Healing**: Predictive failure detection with automatic recovery
4187
-
4188
- **Disable Options**:
4189
- - \`--no-autonomous-documentation\`: Disable documentation system
4190
- - \`--no-autonomous-cost-optimization\`: Disable cost optimization
4191
- - \`--no-autonomous-compliance\`: Disable compliance monitoring
4192
- - \`--no-autonomous-healing\`: Disable self-healing
4193
- - \`--no-autonomous-all\`: Disable ALL autonomous systems
4194
-
4195
- **Force Options**:
4196
- - \`--autonomous-all\`: Force enable all (overrides --no- flags)
4197
-
4198
- **Perfect Orchestrator**: Systems work autonomously, make intelligent decisions, and continuously improve - no manual intervention needed!
4199
-
4200
- ### Default Settings (no flags needed):
4201
- - ✅ \`--smart-discovery\` - Automatically discovers and reuses existing artifacts
4202
- - ✅ \`--live-testing\` - Tests in real-time on your ServiceNow instance
4203
- - ✅ \`--auto-deploy\` - Deploys automatically (safe with update sets)
4204
- - ✅ \`--auto-rollback\` - Automatically rollbacks on failures
4205
- - ✅ \`--shared-memory\` - All agents share context and coordination
4206
- - ✅ \`--progress-monitoring\` - Real-time progress tracking
4207
- - ❌ \`--auto-permissions\` - Disabled by default (enable with flag for automatic role elevation)
4208
-
4209
- ### Advanced Usage:
4210
- \`\`\`bash
4211
- # Enable automatic permission escalation
4212
- snow-flow swarm "create global workflow" --auto-permissions
4213
-
4214
- # Disable specific features
4215
- snow-flow swarm "test widget" --no-auto-deploy --no-live-testing
4216
-
4217
- # Full control
4218
- snow-flow swarm "complex integration" \\
4219
- --max-agents 8 \\
4220
- --strategy development \\
4221
- --mode distributed \\
4222
- --parallel \\
4223
- --auto-permissions
4224
- \`\`\`
4225
-
4226
- ## New MCP Tools (v1.1.44+)
4227
-
4228
- ### Catalog Item Search
4229
- Find catalog items with intelligent fuzzy matching:
4230
- \`\`\`javascript
4231
- snow_catalog_item_search({
4232
- query: "iPhone", // Will find iPhone 6S, iPhone 7, etc.
4233
- fuzzy_match: true, // Enable intelligent variations
4234
- include_variables: true // Include catalog variables
4235
- })
4236
- \`\`\`
4237
-
4238
- ### Flow Testing with Mock Data
4239
- Test flows without real data:
4240
- \`\`\`javascript
4241
- snow_test_flow_with_mock({
4242
- flow_id: "equipment_provisioning_flow",
4243
- create_test_user: true, // Creates test user
4244
- mock_catalog_items: true, // Creates test catalog items
4245
- simulate_approvals: true, // Auto-approves during test
4246
- cleanup_after_test: true // Removes test data after
4247
- })
4248
- \`\`\`
4249
-
4250
- ### Direct Catalog-Flow Linking
4251
- Link catalog items directly to flows:
4252
- \`\`\`javascript
4253
- snow_link_catalog_to_flow({
4254
- catalog_item_id: "iPhone 6S",
4255
- flow_id: "mobile_provisioning_flow",
4256
- link_type: "flow_catalog_process", // Modern approach
4257
- variable_mapping: [
4258
- {
4259
- catalog_variable: "phone_model",
4260
- flow_input: "device_type"
4261
- }
4262
- ],
4263
- test_link: true // Creates test request
4264
- })
4265
- \`\`\`
4266
-
4267
- ### OAuth Configuration
4268
- \`\`\`env
4269
4009
  # .env file
4270
4010
  SNOW_INSTANCE=dev123456
4271
4011
  SNOW_CLIENT_ID=your_oauth_client_id
4272
4012
  SNOW_CLIENT_SECRET=your_oauth_client_secret
4273
- SNOW_USERNAME=admin
4274
- SNOW_PASSWORD=admin_password
4275
- \`\`\`
4276
-
4277
- ### Update Set Management
4278
- \`\`\`javascript
4279
- // Smart update set creation
4280
- snow_smart_update_set({
4281
- name: "Auto-generated for widget development",
4282
- detect_context: true, // Auto-detects what you're working on
4283
- auto_switch: true // Switches when context changes
4284
- });
4285
4013
  \`\`\`
4286
4014
 
4287
- ## đŸŽ¯ Quick Start
4288
- 1. \`snow-flow init --sparc\` - Initialize project with SPARC environment
4289
- 2. Configure ServiceNow credentials in .env file
4290
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow OAuth
4291
- 4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
4292
-
4293
- ## 💡 Important Notes
4294
-
4295
- ### Do's
4296
- - ✅ Use TodoWrite extensively for task tracking
4297
- - ✅ Batch MCP tool calls for performance
4298
- - ✅ Store important data in Memory for coordination
4299
- - ✅ Test with mock data before deploying
4300
- - ✅ Work within Update Sets for safety
4301
- - ✅ Use fuzzy search for finding artifacts
4302
-
4303
- ### Don'ts
4304
- - ❌ Don't make sequential tool calls when batch is possible
4305
- - ❌ Don't hardcode credentials or sys_ids
4306
- - ❌ Don't deploy without testing
4307
- - ❌ Don't ignore OAuth permission errors
4308
- - ❌ Don't create artifacts without checking if they exist
4309
-
4310
- ## 🚀 Performance Benchmarks
4311
-
4312
- With concurrent execution and batch operations:
4313
- - **Widget Development**: 3x faster than sequential
4314
- - **Flow Creation**: 2.5x faster with parallel validation
4315
- - **Bulk Deployment**: Up to 5x faster with parallel mode
4316
- - **Search Operations**: 4x faster with concurrent queries
4317
-
4318
- ## 📚 Additional Resources
4319
-
4320
- ### MCP Server Documentation
4321
- - **servicenow-deployment**: Widget, flow, and application deployment
4322
- - **servicenow-intelligent**: Smart search and artifact discovery
4323
- - **servicenow-operations**: Incident management and catalog operations
4324
- - **servicenow-platform-development**: Scripts, rules, and policies
4325
-
4326
- ### SPARC Modes
4327
- - \`orchestrator\`: Coordinates complex multi-step tasks
4328
- - \`coder\`: Focused code implementation
4329
- - \`researcher\`: Deep analysis and discovery
4330
- - \`tester\`: Comprehensive testing strategies
4331
- - \`architect\`: System design and architecture
4015
+ ## 💡 Best Practices
4332
4016
 
4333
- ---
4017
+ ### DO's
4018
+ ✅ Always use \`snow_validate_live_connection()\` first
4019
+ ✅ Check for existing artifacts with \`snow_find_artifact()\`
4020
+ ✅ Use Update Sets for all changes
4021
+ ✅ Test with mock data before production
4022
+ ✅ Handle errors gracefully with fallbacks
4334
4023
 
4335
- This is a minimal CLAUDE.md file. The full documentation should be available in your Snow-Flow installation.
4024
+ ### DON'Ts
4025
+ ❌ Don't create local files first
4026
+ ❌ Don't skip authentication
4027
+ ❌ Don't hardcode sys_ids or credentials
4028
+ ❌ Don't work in offline mode
4029
+ ❌ Don't deploy without testing
4336
4030
 
4337
- ## Quick Start
4338
- 1. \`snow-flow init --sparc\` - Initialize project with SPARC environment
4031
+ ## đŸŽ¯ Quick Start
4032
+ 1. \`snow-flow init --sparc\` - Initialize project with MCP servers
4339
4033
  2. Configure ServiceNow credentials in .env file
4340
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow OAuth
4034
+ 3. \`snow-flow auth login\` - Authenticate with ServiceNow
4341
4035
  4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
4342
4036
 
4343
4037
  For full documentation, visit: https://github.com/groeimetai/snow-flow
4344
4038
  `;
4039
+ const claudeMdPath = (0, path_1.join)(targetDir, 'CLAUDE.md');
4040
+ if (force || !(0, fs_2.existsSync)(claudeMdPath)) {
4041
+ await fs_1.promises.writeFile(claudeMdPath, claudeMdFallback);
4345
4042
  }
4346
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdContent);
4347
- }
4348
- catch (error) {
4349
- console.log('âš ī¸ Error copying CLAUDE.md, creating minimal version');
4350
- // Minimal fallback
4351
- const claudeMdFallback = `# Snow-Flow Development with Claude Code
4352
-
4353
- ## Quick Start
4354
- 1. \`snow-flow init --sparc\` - Initialize project with SPARC environment
4355
- 2. Configure ServiceNow credentials in .env file
4356
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow OAuth
4357
- 4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
4358
-
4359
- For full documentation, visit: https://github.com/groeimetai/snow-flow
4360
- `;
4361
- await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'CLAUDE.md'), claudeMdFallback);
4362
4043
  }
4363
4044
  }
4364
- async function createEnvFile(targetDir) {
4045
+ async function createEnvFile(targetDir, force = false) {
4365
4046
  const envContent = `# ServiceNow OAuth Configuration
4366
4047
  # Replace these values with your actual ServiceNow instance and OAuth credentials
4367
4048
 
@@ -4416,10 +4097,17 @@ SNOW_FLOW_TIMEOUT_MINUTES=0
4416
4097
  // Check if .env already exists
4417
4098
  try {
4418
4099
  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');
4100
+ if (force) {
4101
+ console.log('âš ī¸ .env file already exists, overwriting with --force flag');
4102
+ await fs_1.promises.writeFile(envFilePath, envContent);
4103
+ console.log('✅ .env file overwritten successfully');
4104
+ }
4105
+ else {
4106
+ console.log('âš ī¸ .env file already exists, creating .env.example template instead');
4107
+ console.log('📝 To overwrite: use --force flag or delete existing .env file');
4108
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.env.example'), envContent);
4109
+ console.log('✅ .env.example template created');
4110
+ }
4423
4111
  }
4424
4112
  catch {
4425
4113
  // .env doesn't exist, create it
@@ -4453,7 +4141,7 @@ async function checkNeo4jAvailability() {
4453
4141
  return false;
4454
4142
  }
4455
4143
  }
4456
- async function createMCPConfig(targetDir) {
4144
+ async function createMCPConfig(targetDir, force = false) {
4457
4145
  // Determine the snow-flow installation directory
4458
4146
  let snowFlowRoot;
4459
4147
  // Check if we're in a global npm installation
@@ -4483,15 +4171,6 @@ async function createMCPConfig(targetDir) {
4483
4171
  "SNOW_CLIENT_SECRET": "${SNOW_CLIENT_SECRET}"
4484
4172
  }
4485
4173
  },
4486
- "servicenow-flow-composer": {
4487
- "command": "node",
4488
- "args": [(0, path_1.join)(distPath, "mcp/servicenow-flow-composer-mcp.js")],
4489
- "env": {
4490
- "SNOW_INSTANCE": "${SNOW_INSTANCE}",
4491
- "SNOW_CLIENT_ID": "${SNOW_CLIENT_ID}",
4492
- "SNOW_CLIENT_SECRET": "${SNOW_CLIENT_SECRET}"
4493
- }
4494
- },
4495
4174
  "servicenow-update-set": {
4496
4175
  "command": "node",
4497
4176
  "args": [(0, path_1.join)(distPath, "mcp/servicenow-update-set-mcp.js")],
@@ -4580,7 +4259,19 @@ async function createMCPConfig(targetDir) {
4580
4259
  };
4581
4260
  // Create .mcp.json in project root for Claude Code discovery
4582
4261
  const mcpConfigPath = (0, path_1.join)(targetDir, '.mcp.json');
4583
- await fs_1.promises.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
4262
+ try {
4263
+ await fs_1.promises.access(mcpConfigPath);
4264
+ if (force) {
4265
+ console.log('âš ī¸ .mcp.json already exists, overwriting with --force flag');
4266
+ await fs_1.promises.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
4267
+ }
4268
+ else {
4269
+ console.log('âš ī¸ .mcp.json already exists, skipping (use --force to overwrite)');
4270
+ }
4271
+ }
4272
+ catch {
4273
+ await fs_1.promises.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
4274
+ }
4584
4275
  // Also create legacy config in .claude for backward compatibility
4585
4276
  const legacyConfigPath = (0, path_1.join)(targetDir, '.claude/mcp-config.json');
4586
4277
  await fs_1.promises.writeFile(legacyConfigPath, JSON.stringify(mcpConfig, null, 2));