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