snow-flow 1.3.25 → 1.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.claude/config.json +33 -9
  2. package/.claude-flow/queen/queen-memory.db +0 -0
  3. package/.roo/README.md +56 -0
  4. package/.roo/workflows/basic-tdd.json +32 -0
  5. package/.roomodes +122 -0
  6. package/CLAUDE.md +140 -752
  7. package/claude-flow +30 -75
  8. package/dist/cli.js +250 -7
  9. package/dist/compliance/advanced-compliance-system.js +857 -0
  10. package/dist/compliance/index.js +8 -0
  11. package/dist/documentation/index.js +8 -0
  12. package/dist/documentation/self-documenting-system.js +1006 -0
  13. package/dist/healing/index.js +8 -0
  14. package/dist/healing/self-healing-system.js +1041 -0
  15. package/dist/intelligence/performance-recommendations-engine.js +479 -4
  16. package/dist/managers/scope-manager.js +5 -2
  17. package/dist/mcp/servicenow-deployment-mcp.js +113 -15
  18. package/dist/mcp/servicenow-flow-composer-mcp.js +4 -2
  19. package/dist/mcp/servicenow-intelligent-mcp.js +351 -0
  20. package/dist/mcp/servicenow-operations-mcp.js +2 -2
  21. package/dist/memory/memory-system.js +146 -0
  22. package/dist/monitoring/enhanced-monitoring-system.js +1085 -0
  23. package/dist/optimization/cost-optimization-engine.js +771 -0
  24. package/dist/optimization/flow-performance-optimizer.js +723 -0
  25. package/dist/optimization/index.js +10 -0
  26. package/dist/orchestration/flow-update-orchestrator.js +648 -0
  27. package/dist/rollback/smart-rollback-system.js +462 -0
  28. package/dist/templates/flow-template-system.js +625 -0
  29. package/dist/testing/flow-testing-automation.js +641 -0
  30. package/dist/testing/integration-test-suite.js +890 -0
  31. package/dist/utils/flow-structure-builder.js +1 -1
  32. package/dist/utils/servicenow-client.js +50 -2
  33. package/dist/utils/snow-oauth.js +66 -8
  34. package/dist/utils/xml-first-flow-generator.js +6 -0
  35. package/dist/version.js +13 -1
  36. package/package.json +1 -1
package/claude-flow CHANGED
@@ -1,79 +1,34 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bash
2
+ # Claude-Flow local wrapper
3
+ # This script ensures claude-flow runs from your project directory
2
4
 
3
- /**
4
- * Claude Flow CLI - Universal Wrapper
5
- * Works in both CommonJS and ES Module projects
6
- */
5
+ # Save the current directory
6
+ PROJECT_DIR="${PWD}"
7
7
 
8
- // Use dynamic import to work in both CommonJS and ES modules
9
- (async () => {
10
- const { spawn } = await import('child_process');
11
- const { resolve } = await import('path');
12
- const { fileURLToPath } = await import('url');
13
-
14
- // Detect if we're running in ES module context
15
- let __dirname;
16
- try {
17
- // Check if import.meta is available (ES modules)
18
- if (typeof import.meta !== 'undefined' && import.meta.url) {
19
- const __filename = fileURLToPath(import.meta.url);
20
- __dirname = resolve(__filename, '..');
21
- } else {
22
- // Fallback for CommonJS
23
- __dirname = process.cwd();
24
- }
25
- } catch {
26
- // Fallback for CommonJS
27
- __dirname = process.cwd();
28
- }
8
+ # Set environment to ensure correct working directory
9
+ export PWD="${PROJECT_DIR}"
10
+ export CLAUDE_WORKING_DIR="${PROJECT_DIR}"
29
11
 
30
- // Try multiple strategies to find claude-flow
31
- const strategies = [
32
- // 1. Local node_modules
33
- async () => {
34
- try {
35
- const localPath = resolve(process.cwd(), 'node_modules/.bin/claude-flow');
36
- const { existsSync } = await import('fs');
37
- if (existsSync(localPath)) {
38
- return spawn(localPath, process.argv.slice(2), { stdio: 'inherit' });
39
- }
40
- } catch {}
41
- },
42
-
43
- // 2. Parent node_modules (monorepo)
44
- async () => {
45
- try {
46
- const parentPath = resolve(process.cwd(), '../node_modules/.bin/claude-flow');
47
- const { existsSync } = await import('fs');
48
- if (existsSync(parentPath)) {
49
- return spawn(parentPath, process.argv.slice(2), { stdio: 'inherit' });
50
- }
51
- } catch {}
52
- },
53
-
54
- // 3. NPX with latest alpha version (prioritized over global)
55
- async () => {
56
- return spawn('npx', ['claude-flow@2.0.0-alpha.27', ...process.argv.slice(2)], { stdio: 'inherit' });
57
- }
58
- ];
12
+ # Try to find claude-flow binary
13
+ # Check common locations for npm/npx installations
59
14
 
60
- // Try each strategy
61
- for (const strategy of strategies) {
62
- try {
63
- const child = await strategy();
64
- if (child) {
65
- child.on('exit', (code) => process.exit(code || 0));
66
- child.on('error', (err) => {
67
- if (err.code !== 'ENOENT') {
68
- console.error('Error:', err);
69
- process.exit(1);
70
- }
71
- });
72
- return;
73
- }
74
- } catch {}
75
- }
76
-
77
- console.error('Could not find claude-flow. Please install it with: npm install claude-flow');
78
- process.exit(1);
79
- })();
15
+ # 1. Local node_modules (npm install claude-flow)
16
+ if [ -f "${PROJECT_DIR}/node_modules/.bin/claude-flow" ]; then
17
+ cd "${PROJECT_DIR}"
18
+ exec "${PROJECT_DIR}/node_modules/.bin/claude-flow" "$@"
19
+
20
+ # 2. Parent directory node_modules (monorepo setup)
21
+ elif [ -f "${PROJECT_DIR}/../node_modules/.bin/claude-flow" ]; then
22
+ cd "${PROJECT_DIR}"
23
+ exec "${PROJECT_DIR}/../node_modules/.bin/claude-flow" "$@"
24
+
25
+ # 3. Global installation (npm install -g claude-flow)
26
+ elif command -v claude-flow &> /dev/null; then
27
+ cd "${PROJECT_DIR}"
28
+ exec claude-flow "$@"
29
+
30
+ # 4. Fallback to npx (will download if needed)
31
+ else
32
+ cd "${PROJECT_DIR}"
33
+ exec npx claude-flow@latest "$@"
34
+ fi
package/dist/cli.js CHANGED
@@ -238,6 +238,16 @@ program
238
238
  .option('--no-progress-monitoring', 'Disable progress monitoring')
239
239
  .option('--xml-first', 'Use XML-first approach for flow creation (MOST RELIABLE!)')
240
240
  .option('--xml-output <path>', 'Save generated XML to specific path (with --xml-first)')
241
+ .option('--autonomous-documentation', 'Enable autonomous documentation system (default: true)', true)
242
+ .option('--no-autonomous-documentation', 'Disable autonomous documentation system')
243
+ .option('--autonomous-cost-optimization', 'Enable autonomous cost optimization engine (default: true)', true)
244
+ .option('--no-autonomous-cost-optimization', 'Disable autonomous cost optimization engine')
245
+ .option('--autonomous-compliance', 'Enable autonomous compliance monitoring (default: true)', true)
246
+ .option('--no-autonomous-compliance', 'Disable autonomous compliance monitoring')
247
+ .option('--autonomous-healing', 'Enable autonomous self-healing capabilities (default: true)', true)
248
+ .option('--no-autonomous-healing', 'Disable autonomous self-healing capabilities')
249
+ .option('--autonomous-all', 'Force enable all autonomous systems (overrides individual --no- flags)')
250
+ .option('--no-autonomous-all', 'Disable all autonomous systems (overrides individual settings)')
241
251
  .option('--verbose', 'Show detailed execution information')
242
252
  .action(async (objective, options) => {
243
253
  // Always show essential info
@@ -255,11 +265,68 @@ program
255
265
  cliLogger.info(` 🚀 Auto Deploy: ${options.autoDeploy ? '✅ DEPLOYMENT MODE - WILL CREATE REAL ARTIFACTS' : '❌ PLANNING MODE - ANALYSIS ONLY'}`);
256
266
  cliLogger.info(` 🔄 Auto Rollback: ${options.autoRollback ? '✅ Yes' : '❌ No'}`);
257
267
  cliLogger.info(` 💾 Shared Memory: ${options.sharedMemory ? '✅ Yes' : '❌ No'}`);
258
- cliLogger.info(` 📊 Progress Monitoring: ${options.progressMonitoring ? '✅ Yes' : '❌ No'}\n`);
268
+ cliLogger.info(` 📊 Progress Monitoring: ${options.progressMonitoring ? '✅ Yes' : '❌ No'}`);
269
+ // Calculate actual autonomous system states (with override logic)
270
+ // Commander.js converts --no-autonomous-all to autonomousAll: false
271
+ const noAutonomousAll = options.autonomousAll === false;
272
+ const forceAutonomousAll = options.autonomousAll === true;
273
+ const autonomousDocActive = noAutonomousAll ? false :
274
+ forceAutonomousAll ? true :
275
+ options.autonomousDocumentation !== false;
276
+ const autonomousCostActive = noAutonomousAll ? false :
277
+ forceAutonomousAll ? true :
278
+ options.autonomousCostOptimization !== false;
279
+ const autonomousComplianceActive = noAutonomousAll ? false :
280
+ forceAutonomousAll ? true :
281
+ options.autonomousCompliance !== false;
282
+ const autonomousHealingActive = noAutonomousAll ? false :
283
+ forceAutonomousAll ? true :
284
+ options.autonomousHealing !== false;
285
+ const hasAutonomousSystems = autonomousDocActive || autonomousCostActive ||
286
+ autonomousComplianceActive || autonomousHealingActive;
287
+ cliLogger.info(`\n🤖 Autonomous Systems (DEFAULT ENABLED):`);
288
+ cliLogger.info(` 📚 Documentation: ${autonomousDocActive ? '✅ ACTIVE' : '❌ Disabled'}`);
289
+ cliLogger.info(` 💰 Cost Optimization: ${autonomousCostActive ? '✅ ACTIVE' : '❌ Disabled'}`);
290
+ cliLogger.info(` 🔐 Compliance Monitoring: ${autonomousComplianceActive ? '✅ ACTIVE' : '❌ Disabled'}`);
291
+ cliLogger.info(` 🏥 Self-Healing: ${autonomousHealingActive ? '✅ ACTIVE' : '❌ Disabled'}`);
292
+ cliLogger.info('');
259
293
  }
260
- else if (options.autoDeploy) {
261
- // In non-verbose mode, only show critical deployment warning
262
- cliLogger.info(`🚀 Auto-Deploy: ENABLED - Will create real artifacts in ServiceNow`);
294
+ else {
295
+ // In non-verbose mode, only show critical info
296
+ if (options.autoDeploy) {
297
+ cliLogger.info(`🚀 Auto-Deploy: ENABLED - Will create real artifacts in ServiceNow`);
298
+ }
299
+ // Calculate autonomous systems for non-verbose mode (same logic as verbose)
300
+ const noAutonomousAll = options.autonomousAll === false;
301
+ const forceAutonomousAll = options.autonomousAll === true;
302
+ const autonomousDocActive = noAutonomousAll ? false :
303
+ forceAutonomousAll ? true :
304
+ options.autonomousDocumentation !== false;
305
+ const autonomousCostActive = noAutonomousAll ? false :
306
+ forceAutonomousAll ? true :
307
+ options.autonomousCostOptimization !== false;
308
+ const autonomousComplianceActive = noAutonomousAll ? false :
309
+ forceAutonomousAll ? true :
310
+ options.autonomousCompliance !== false;
311
+ const autonomousHealingActive = noAutonomousAll ? false :
312
+ forceAutonomousAll ? true :
313
+ options.autonomousHealing !== false;
314
+ // Show active autonomous systems
315
+ const activeSystems = [];
316
+ if (autonomousDocActive)
317
+ activeSystems.push('📚 Documentation');
318
+ if (autonomousCostActive)
319
+ activeSystems.push('💰 Cost Optimization');
320
+ if (autonomousComplianceActive)
321
+ activeSystems.push('🔐 Compliance');
322
+ if (autonomousHealingActive)
323
+ activeSystems.push('🏥 Self-Healing');
324
+ if (activeSystems.length > 0) {
325
+ cliLogger.info(`🤖 Autonomous Systems: ${activeSystems.join(', ')}`);
326
+ }
327
+ else {
328
+ cliLogger.info(`🤖 Autonomous Systems: ❌ All Disabled`);
329
+ }
263
330
  }
264
331
  // Analyze the objective using intelligent agent detection
265
332
  const taskAnalysis = analyzeObjective(objective, parseInt(options.maxAgents));
@@ -642,6 +709,23 @@ function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated
642
709
  const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
643
710
  options.liveTesting || options.autoDeploy || options.autoRollback ||
644
711
  options.sharedMemory || options.progressMonitoring;
712
+ // Calculate actual autonomous system states (with override logic)
713
+ const noAutonomousAll = options.autonomousAll === false;
714
+ const forceAutonomousAll = options.autonomousAll === true;
715
+ const autonomousDocActive = noAutonomousAll ? false :
716
+ forceAutonomousAll ? true :
717
+ options.autonomousDocumentation !== false;
718
+ const autonomousCostActive = noAutonomousAll ? false :
719
+ forceAutonomousAll ? true :
720
+ options.autonomousCostOptimization !== false;
721
+ const autonomousComplianceActive = noAutonomousAll ? false :
722
+ forceAutonomousAll ? true :
723
+ options.autonomousCompliance !== false;
724
+ const autonomousHealingActive = noAutonomousAll ? false :
725
+ forceAutonomousAll ? true :
726
+ options.autonomousHealing !== false;
727
+ const hasAutonomousSystems = autonomousDocActive || autonomousCostActive ||
728
+ autonomousComplianceActive || autonomousHealingActive;
645
729
  const prompt = `# 👑 Snow-Flow Queen Agent Orchestration
646
730
 
647
731
  ## 🎯 Mission Brief
@@ -1408,7 +1492,17 @@ const mockTest = await snow_test_flow_with_mock({
1408
1492
  test_inputs: { /* test data */ }
1409
1493
  });
1410
1494
  // Then try comprehensive if authenticated
1411
- const liveTest = await snow_comprehensive_flow_test({ flow_sys_id: "id" });
1495
+ // 🔧 TEST-001 FIX: Skip live test if no valid flow sys_id is available
1496
+ // Only run live test if we have a real sys_id from previous flow creation
1497
+ let liveTest: any = { error: "No valid flow_sys_id available for live testing" };
1498
+
1499
+ // In practice, this would get the sys_id from a previously created flow:
1500
+ // if (Memory.get("last_created_flow_sys_id")) {
1501
+ // liveTest = await snow_comprehensive_flow_test({
1502
+ // flow_sys_id: Memory.get("last_created_flow_sys_id")
1503
+ // });
1504
+ // }
1505
+
1412
1506
  if (liveTest.error) {
1413
1507
  // Document test results from mock only
1414
1508
  Memory.store("test_results", mockTest);
@@ -1426,6 +1520,126 @@ Now execute this Queen Agent orchestration plan:
1426
1520
 
1427
1521
  Remember: You are the Queen Agent - the master coordinator. Your role is to ensure all agents work harmoniously to achieve the objective: "${objective}"
1428
1522
 
1523
+ ${hasAutonomousSystems ? `
1524
+
1525
+ ## 🤖 AUTONOMOUS SYSTEMS INTEGRATION
1526
+
1527
+ **CRITICAL: The following autonomous systems have been enabled and MUST be initialized:**
1528
+
1529
+ ${autonomousDocActive ? `
1530
+ ### 📚 Self-Documenting System
1531
+ **MANDATORY**: Initialize and start autonomous documentation:
1532
+ \`\`\`javascript
1533
+ // Start continuous documentation monitoring
1534
+ await snow_start_continuous_documentation({
1535
+ auto_commit: true,
1536
+ include_diagrams: true,
1537
+ scope: "full"
1538
+ });
1539
+
1540
+ // Store status in memory
1541
+ await mcp__servicenow-memory__memory_store({
1542
+ key: "autonomous_documentation_${sessionId}",
1543
+ value: JSON.stringify({
1544
+ status: "active",
1545
+ started_at: new Date().toISOString(),
1546
+ auto_commit: true
1547
+ }),
1548
+ namespace: "swarm_${sessionId}"
1549
+ });
1550
+ \`\`\`
1551
+ ` : ''}
1552
+
1553
+ ${autonomousCostActive ? `
1554
+ ### 💰 Cost Optimization Engine
1555
+ **MANDATORY**: Initialize and start autonomous cost optimization:
1556
+ \`\`\`javascript
1557
+ // Start autonomous cost optimization
1558
+ await snow_start_autonomous_cost_optimization({
1559
+ target_savings: 30,
1560
+ auto_implement: true,
1561
+ monitor_real_time: true
1562
+ });
1563
+
1564
+ // Store status in memory
1565
+ await mcp__servicenow-memory__memory_store({
1566
+ key: "autonomous_cost_optimization_${sessionId}",
1567
+ value: JSON.stringify({
1568
+ status: "active",
1569
+ started_at: new Date().toISOString(),
1570
+ target_savings: 30,
1571
+ auto_implement: true
1572
+ }),
1573
+ namespace: "swarm_${sessionId}"
1574
+ });
1575
+ \`\`\`
1576
+ ` : ''}
1577
+
1578
+ ${autonomousComplianceActive ? `
1579
+ ### 🔐 Advanced Compliance System
1580
+ **MANDATORY**: Initialize and start autonomous compliance monitoring:
1581
+ \`\`\`javascript
1582
+ // Start compliance monitoring
1583
+ await snow_start_compliance_monitoring({
1584
+ frameworks: ["GDPR", "SOX", "HIPAA"],
1585
+ auto_remediate: true,
1586
+ continuous_monitoring: true
1587
+ });
1588
+
1589
+ // Store status in memory
1590
+ await mcp__servicenow-memory__memory_store({
1591
+ key: "autonomous_compliance_${sessionId}",
1592
+ value: JSON.stringify({
1593
+ status: "active",
1594
+ started_at: new Date().toISOString(),
1595
+ frameworks: ["GDPR", "SOX", "HIPAA"],
1596
+ auto_remediate: true
1597
+ }),
1598
+ namespace: "swarm_${sessionId}"
1599
+ });
1600
+ \`\`\`
1601
+ ` : ''}
1602
+
1603
+ ${autonomousHealingActive ? `
1604
+ ### 🏥 Self-Healing System
1605
+ **MANDATORY**: Initialize and start autonomous self-healing:
1606
+ \`\`\`javascript
1607
+ // Start self-healing system
1608
+ await snow_start_autonomous_healing({
1609
+ preventive: true,
1610
+ auto_heal: true,
1611
+ learn_patterns: true
1612
+ });
1613
+
1614
+ // Store status in memory
1615
+ await mcp__servicenow-memory__memory_store({
1616
+ key: "autonomous_healing_${sessionId}",
1617
+ value: JSON.stringify({
1618
+ status: "active",
1619
+ started_at: new Date().toISOString(),
1620
+ preventive: true,
1621
+ auto_heal: true
1622
+ }),
1623
+ namespace: "swarm_${sessionId}"
1624
+ });
1625
+ \`\`\`
1626
+ ` : ''}
1627
+
1628
+ **🎯 ORCHESTRATOR SHOWCASE:** These autonomous systems operate without manual intervention, demonstrating true orchestration capabilities. They will:
1629
+ - Monitor continuously in the background
1630
+ - Make intelligent decisions automatically
1631
+ - Adapt and learn from patterns
1632
+ - Provide real-time dashboards and insights
1633
+ - Execute actions autonomously when needed
1634
+
1635
+ **Integration with Main Objective:** All autonomous systems will coordinate with your main objective ("${objective}") by providing:
1636
+ - Automatic documentation of created artifacts
1637
+ - Cost optimization of operations performed
1638
+ - Compliance validation of all changes
1639
+ - Self-healing of any issues that arise
1640
+
1641
+ ` : ''}
1642
+
1429
1643
  Session ID for this swarm: ${sessionId}`;
1430
1644
  return prompt;
1431
1645
  }
@@ -2189,7 +2403,7 @@ snow_link_catalog_to_flow({
2189
2403
  ],
2190
2404
  trigger_condition: 'current.stage == "request_approved"',
2191
2405
  execution_options: {
2192
- run_as: "system",
2406
+ run_as: "user", // 🔒 SEC-001 FIX: Default to 'user' to prevent privilege escalation
2193
2407
  wait_for_completion: true
2194
2408
  },
2195
2409
  test_link: true // Creates test request
@@ -3403,10 +3617,39 @@ if (deployment.failed) {
3403
3617
  The swarm command now includes intelligent features that are **enabled by default**:
3404
3618
 
3405
3619
  \`\`\`bash
3406
- # Simple usage - all intelligent features enabled!
3620
+ # Simple usage - ALL autonomous systems enabled by default!
3407
3621
  snow-flow swarm "create incident management dashboard"
3622
+
3623
+ # Disable specific autonomous systems if needed
3624
+ snow-flow swarm "create simple widget" --no-autonomous-cost-optimization --no-autonomous-compliance
3625
+
3626
+ # Disable ALL autonomous systems
3627
+ snow-flow swarm "basic development only" --no-autonomous-all
3628
+
3629
+ # Force enable all (overrides any --no- flags)
3630
+ snow-flow swarm "full orchestration mode" --autonomous-all
3408
3631
  \`\`\`
3409
3632
 
3633
+ ### 🤖 NEW: Autonomous Systems (v1.3.26+) - **ENABLED BY DEFAULT!**
3634
+ True orchestration with zero manual intervention - all systems active unless disabled:
3635
+
3636
+ - ✅ **Documentation**: Self-documenting system (auto-generates and updates docs)
3637
+ - ✅ **Cost Optimization**: AI-driven cost management with auto-optimization
3638
+ - ✅ **Compliance**: Multi-framework compliance monitoring with auto-remediation
3639
+ - ✅ **Self-Healing**: Predictive failure detection with automatic recovery
3640
+
3641
+ **Disable Options**:
3642
+ - \`--no-autonomous-documentation\`: Disable documentation system
3643
+ - \`--no-autonomous-cost-optimization\`: Disable cost optimization
3644
+ - \`--no-autonomous-compliance\`: Disable compliance monitoring
3645
+ - \`--no-autonomous-healing\`: Disable self-healing
3646
+ - \`--no-autonomous-all\`: Disable ALL autonomous systems
3647
+
3648
+ **Force Options**:
3649
+ - \`--autonomous-all\`: Force enable all (overrides --no- flags)
3650
+
3651
+ **Perfect Orchestrator**: Systems work autonomously, make intelligent decisions, and continuously improve - no manual intervention needed!
3652
+
3410
3653
  ### Default Settings (no flags needed):
3411
3654
  - ✅ \`--smart-discovery\` - Automatically discovers and reuses existing artifacts
3412
3655
  - ✅ \`--live-testing\` - Tests in real-time on your ServiceNow instance