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.md CHANGED
@@ -1,786 +1,174 @@
1
- # Snow-Flow Development with Claude Code
1
+ # Claude Code Configuration - SPARC Development Environment (Batchtools Optimized)
2
2
 
3
- ## 🚨 CRITICAL: MCP-FIRST WORKFLOW (READ THIS FIRST!)
3
+ ## 🚨 CRITICAL: CONCURRENT EXECUTION FOR ALL ACTIONS
4
4
 
5
- **Snow-flow's core value is REAL ServiceNow integration through MCP tools. NEVER work in offline mode!**
5
+ **ABSOLUTE RULE**: ALL operations MUST be concurrent/parallel in a single message:
6
6
 
7
- ### ⚠️ MANDATORY WORKFLOW - NO EXCEPTIONS
7
+ ### 🔴 MANDATORY CONCURRENT PATTERNS:
8
+ 1. **TodoWrite**: ALWAYS batch ALL todos in ONE call (5-10+ todos minimum)
9
+ 2. **Task tool**: ALWAYS spawn ALL agents in ONE message with full instructions
10
+ 3. **File operations**: ALWAYS batch ALL reads/writes/edits in ONE message
11
+ 4. **Bash commands**: ALWAYS batch ALL terminal operations in ONE message
12
+ 5. **Memory operations**: ALWAYS batch ALL memory store/retrieve in ONE message
8
13
 
9
- **Every ServiceNow task MUST start with this sequence:**
14
+ ### GOLDEN RULE: "1 MESSAGE = ALL RELATED OPERATIONS"
10
15
 
16
+ **Examples of CORRECT concurrent execution:**
11
17
  ```javascript
12
- // 1. MANDATORY: Pre-flight authentication check
13
- const authCheck = await snow_validate_live_connection({ test_level: "permissions" });
14
- if (!authCheck.success) {
15
- // STOP! Fix authentication first
16
- return authenticationError(authCheck.error);
17
- }
18
-
19
- // 2. MANDATORY: Discovery before creation
20
- const discovery = await snow_find_artifact({
21
- query: "your objective",
22
- type: "widget|flow|script|any"
23
- });
24
-
25
- // 3. 🧠 INTELLIGENT GAP ANALYSIS (Beyond MCP Tools)
26
- const gapAnalysis = await analyzeGaps("your objective", mcpTools, logger, {
27
- autoPermissions: true,
28
- environment: "development",
29
- enableAutomation: true,
30
- includeManualGuides: true
31
- });
32
-
33
- // 4. 🚀 NEW v1.1.93: REVOLUTIONARY PARALLEL AGENT SPAWNING - FULLY WORKING!
34
- // Queen Agent automatically spawns 6+ specialized agents for widget development:
35
- // widget-creator, css-specialist, backend-specialist, frontend-specialist,
36
- // integration-specialist, performance-specialist, ui-ux-specialist, tester
37
- // Achieves proven 2.8x speedup through intelligent parallel execution
38
- console.log('🧠 Queen Agent spawning 6+ parallel agents for 2.8x faster development...');
39
-
40
- // 5. MANDATORY: Real ServiceNow deployment
41
- // For flows: Use XML-first approach with full automation (NEW v1.3.17!)
42
- if (isFlowDesignerTask) {
43
- // ✅ SINGLE COMMAND: XML generation + automatic deployment
44
- const deployment = await snow_create_flow({
45
- instruction: "your natural language flow description",
46
- deploy_immediately: true // 🚀 Fully automated: Generate → Import → Preview → Commit
47
- });
48
-
49
- // That's it! Flow is now live in ServiceNow Flow Designer
50
- } else {
51
- // For widgets, applications, scripts: Use standard MCP deployment
52
- const deployment = await snow_deploy({
53
- type: "widget|application|script",
54
- config: { /* your config */ },
55
- auto_update_set: true // Always track changes
56
- });
57
-
58
- // Track in Update Set
59
- await snow_update_set_add_artifact({
60
- type: deployment.type,
61
- sys_id: deployment.result.sys_id,
62
- name: deployment.result.name
63
- });
64
- }
18
+ // CORRECT: Everything in ONE message
19
+ [Single Message]:
20
+ - TodoWrite { todos: [10+ todos with all statuses/priorities] }
21
+ - Task("Agent 1 with full instructions and hooks")
22
+ - Task("Agent 2 with full instructions and hooks")
23
+ - Task("Agent 3 with full instructions and hooks")
24
+ - Read("file1.js")
25
+ - Read("file2.js")
26
+ - Write("output1.js", content)
27
+ - Write("output2.js", content)
28
+ - Bash("npm install")
29
+ - Bash("npm test")
30
+ - Bash("npm run build")
65
31
  ```
66
32
 
67
- ### 🚫 FORBIDDEN ACTIONS
68
-
69
- **THESE ACTIONS ARE BANNED - NEVER DO THESE:**
70
-
71
- ❌ **Creating local files** without MCP check first
72
- ❌ **Generating mock data** instead of using MCP tools
73
- ❌ **Working in "offline mode"** when ServiceNow is available
74
- ❌ **Skipping authentication validation**
75
- ❌ **Planning mode** without trying MCP tools first
76
-
77
- ### ✅ CORRECT: MCP-First Decision Tree
78
-
79
- ```
80
- User Request → ALWAYS START HERE:
81
-
82
- 1. snow_validate_live_connection()
83
-
84
- SUCCESS? → Continue to Step 2
85
-
86
- FAILURE? → Fix auth: snow_auth_diagnostics()
87
- Then guide user: "snow-flow auth login"
88
- STOP until auth works
89
-
90
- 2. snow_find_artifact() // Check if exists
91
-
92
- FOUND? → Ask: "Reuse existing or create new?"
93
-
94
- NOT FOUND? → Continue to Step 3
95
-
96
- 3. 🧠 analyzeGaps() // NEW: Intelligent Gap Analysis
97
-
98
- DETECTS: All ServiceNow configs beyond MCP tools
99
- AUTOMATES: System properties, navigation, auth configs
100
- PROVIDES: Manual guides for complex setups
101
-
102
- 4. snow_deploy() // Real deployment to ServiceNow
103
-
104
- SUCCESS? → Step 5: Track in Update Set
105
-
106
- FAILURE? → Use fallback strategies (see below)
107
-
108
- 5. snow_update_set_add_artifact() // Always track
109
-
110
- DONE! ✅
111
- ```
112
-
113
- ## 🔧 Error Recovery - MCP Fallback Strategies
114
-
115
- **Only if MCP tools fail, use these fallbacks:**
116
-
117
- ### Authentication Failures
118
- ```javascript
119
- if (error.includes('authentication') || error.includes('401') || error.includes('403')) {
120
- return `
121
- ❌ ServiceNow Authentication Required
122
-
123
- Fix this now:
124
- 1. Run: snow-flow auth login
125
- 2. Check .env: SNOW_INSTANCE, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET
126
- 3. Test: snow_validate_live_connection()
127
-
128
- Cannot proceed until authentication works!
129
- `;
130
- }
131
- ```
132
-
133
- ### Permission Escalation
134
- ```javascript
135
- if (error.includes('insufficient privileges')) {
136
- await snow_escalate_permissions({
137
- required_roles: ['admin', 'app_creator'],
138
- reason: 'ServiceNow development requires elevated permissions'
139
- });
140
- }
141
- ```
142
-
143
- ### Deployment Failures - Graceful Degradation
144
- ```javascript
145
- if (deployment.failed) {
146
- // Strategy 1: Try global scope
147
- const globalAttempt = await snow_deploy({
148
- ...config,
149
- scope_preference: 'global'
150
- });
151
-
152
- if (globalAttempt.failed) {
153
- // Strategy 2: Manual steps guide
154
- return createManualStepsGuide(config, error);
155
- }
156
- }
157
- ```
158
-
159
- ## 🚀 Swarm Command - MCP-Orchestrated Multi-Agent Intelligence
160
-
161
- **The Swarm system is now MCP-native and ALWAYS uses ServiceNow tools first!**
162
-
163
- ### 🚀 Primary Development Interface (RECOMMENDED)
164
-
165
- ```bash
166
- # Swarm with automatic MCP-first workflow
167
- snow-flow swarm "create incident dashboard with charts and real-time data"
168
- snow-flow swarm "build approval workflow for equipment requests"
169
- snow-flow swarm "deploy mobile-responsive widget with accessibility features"
170
- ```
171
-
172
- **What happens internally in every swarm (v1.3.1):**
173
- 1. ✅ **Pre-flight auth check** with `snow_validate_live_connection()`
174
- 2. ✅ **Smart discovery** with `snow_comprehensive_search()`
175
- 3. 🧠 **Intelligent Gap Analysis** - detects ALL required ServiceNow configurations
176
- 4. 🔧 **NEW: Automatic Flow Designer Detection** - auto-switches to XML-first for Flow Designer flows
177
- 5. 🚀 **REVOLUTIONARY: 6+ Parallel Agent Spawning** - automatic specialized team creation
178
- 6. ✅ **Multi-agent coordination** with shared MCP context and 2.8x speedup
179
- 7. ✅ **Real deployment** with `snow_deploy()` or **XML Auto-Import** for flows
180
- 8. ✅ **Automatic tracking** with `snow_update_set_add_artifact()`
181
- 9. ✅ **Live testing** with `snow_test_flow_with_mock()` or `snow_widget_test()`
182
-
183
- ### Swarm MCP Integration Features
184
-
185
- - **🎯 Auto MCP Validation**: Every swarm operation starts with auth check
186
- - **📊 Smart Discovery**: Uses `snow_comprehensive_search()` to find existing artifacts
187
- - **🔄 Update Set Management**: Automatic `snow_smart_update_set()` creation
188
- - **🐝 Swarm Coordination**: All agents share MCP context and coordinate via real ServiceNow data
189
- - **🚀 Live Deployment**: Direct ServiceNow integration via MCP tools
190
- - **🔧 Flow Designer Auto-Detection**: Automatically detects Flow Designer tasks and uses XML-first approach
191
- - **📦 XML Auto-Import**: Automatically imports, previews, and commits XML update sets to ServiceNow
192
- - **⚡ Revolutionary Parallel Execution**: 6+ specialized agents (widget-creator, css-specialist, backend-specialist, frontend-specialist, integration-specialist, performance-specialist, tester) work simultaneously for 2.8x faster development
193
-
194
- ## 🔧 NEW: Flow Designer XML Auto-Deployment (v1.3.1)
195
-
196
- **No more manual XML imports! Snow-flow now automatically deploys Flow Designer flows to ServiceNow.**
197
-
198
- ### ⚡ Automatic Detection & Deployment
199
-
200
- When you run any flow-related swarm command, Snow-flow automatically:
201
-
202
- 1. **🔍 Detects Flow Designer Tasks**:
203
- ```bash
204
- snow-flow swarm "create approval flow for equipment requests"
205
- snow-flow swarm "build automated notification workflow"
206
- snow-flow swarm "design escalation flow with manager approval"
207
- ```
208
-
209
- 2. **🔧 Shows XML-First Detection**:
210
- ```
211
- 🔧 Flow Designer Detected - Using XML-First Approach!
212
- 📋 Creating production-ready ServiceNow flow XML...
213
- 💡 Reason: Flow Designer flows are most reliable with XML-first approach
214
- ```
215
-
216
- 3. **📦 Generates Complete XML**: Creates production-ready Update Set XML with:
217
- - `sys_hub_flow` - Main flow record
218
- - `sys_hub_flow_snapshot` - Flow definition and structure
219
- - `sys_hub_trigger_instance` - Flow trigger configuration
220
- - `sys_hub_action_instance` - All flow activities (approval, notification, etc.)
221
- - `sys_hub_flow_logic` - Activity connections and flow paths
222
-
223
- 4. **🚀 Fully Automated Deployment** (NEW v1.3.17!):
224
- ```bash
225
- 🚀 Auto-Deploy enabled - deploying directly to ServiceNow...
226
- ✅ XML imported successfully (sys_id: abc123...)
227
- ✅ Update set loaded: Flow_Import_2025
228
- 🔍 Preview completed with no problems
229
- ✅ Update set committed successfully!
230
- 🎉 Flow is ready in Flow Designer!
231
- ```
232
-
233
- ### 🚀 Zero-Manual-Steps Deployment
234
-
235
- **No commands needed!** Everything happens automatically in one swarm call:
236
-
237
- **What happens automatically:**
238
- 1. ✅ **Generate**: Creates production-ready Update Set XML
239
- 2. ✅ **Import**: Uploads XML to ServiceNow as remote update set
240
- 3. ✅ **Load**: Loads the update set into local update sets
241
- 4. ✅ **Preview**: Checks for problems and conflicts
242
- 5. ✅ **Commit**: Auto-commits if preview is clean
243
- 6. ✅ **Verify**: Confirms flow is available in Flow Designer
244
-
245
- ### 🎯 Complete Flow Development Workflow
246
-
247
- **End-to-End Flow Creation (Truly Zero Manual Steps):**
248
-
249
- ```bash
250
- # Single command creates AND deploys flow automatically!
251
- snow-flow swarm "create incident escalation flow with email notifications"
252
-
253
- # Complete Output:
254
- # 🔧 Flow Designer Detected - Using XML-First Approach!
255
- # 📋 Creating production-ready ServiceNow flow XML...
256
- # ✅ XML Generated Successfully!
257
- # 📁 File saved to: flow-update-sets/incident_escalation_flow.xml
258
- # 🚀 Auto-Deploy enabled - deploying directly to ServiceNow...
259
- # ✅ XML imported successfully (sys_id: abc123...)
260
- # ✅ Update set loaded: Incident_Escalation_Flow_Import
261
- # 🔍 Previewing update set...
262
- # ✅ Preview successful - no problems found
263
- # 🚀 Committing update set...
264
- # ✅ Update Set committed successfully!
265
- # 📍 Navigate to Flow Designer > Designer to see your flow
266
- # 🎉 Flow deployed and ready to use!
267
- ```
268
-
269
- **That's it! One command, zero manual steps.** 🚀
270
-
271
- ### 🔧 Advanced Auto-Deployment Features
272
-
273
- **Built-in Safety & Intelligence**:
274
- - **Preview Problems Detection**: Automatically detects and reports conflicts
275
- - **Safe Auto-Commit**: Only commits if preview is completely clean
276
- - **Graceful Fallbacks**: Provides manual instructions if auto-deployment fails
277
- - **Authentication Validation**: Ensures valid ServiceNow connection before deployment
278
- - **Error Recovery**: Intelligent retry and fallback strategies
279
-
280
- **What Happens Behind the Scenes**:
281
- ```javascript
282
- // When you run: snow-flow swarm "create approval flow"
283
- await snow_create_flow({
284
- instruction: "create approval flow",
285
- deploy_immediately: true // This triggers all safety checks:
286
- });
287
-
288
- // 1. ✅ Authentication check
289
- // 2. ✅ XML generation with validation
290
- // 3. ✅ Import to ServiceNow as remote update set
291
- // 4. ✅ Preview for conflicts
292
- // 5. ✅ Auto-commit only if clean
293
- // 6. ✅ Error handling with manual fallback instructions
294
- ```
295
-
296
- **Troubleshooting (if auto-deployment fails)**:
297
- - Error messages include specific troubleshooting steps
298
- - Authentication issues: `snow-flow auth status`
299
- - Manual fallback: `snow-flow deploy-xml filename.xml`
300
- - Permission issues: Check admin roles in ServiceNow
301
-
302
- ## 🔒 MANDATORY ServiceNow Development Workflow
303
-
304
- ### **STEP 1: Authentication Validation (ALWAYS FIRST)**
305
-
306
- ```javascript
307
- // This happens automatically in ALL MCP tools
308
- const connectionResult = await snow_validate_live_connection({
309
- test_level: "permissions" // Test actual write capabilities
310
- });
311
-
312
- if (!connectionResult.success) {
313
- throw new AuthenticationError(`
314
- ❌ ServiceNow Connection Failed: ${connectionResult.error}
315
-
316
- 🔧 Fix this now:
317
- 1. Check .env credentials
318
- 2. Run: snow-flow auth login
319
- 3. Test: snow_auth_diagnostics()
320
- `);
321
- }
322
- ```
323
-
324
- ### **STEP 2: Smart Discovery (Prevent Duplication)**
325
-
326
- ```javascript
327
- // ALWAYS check before creating
328
- const discovery = await snow_comprehensive_search({
329
- query: "incident dashboard widget",
330
- include_inactive: false
331
- });
332
-
333
- if (discovery.found.length > 0) {
334
- console.log(`🔍 Found ${discovery.found.length} similar artifacts:`);
335
- discovery.found.forEach(artifact => {
336
- console.log(`💡 Consider reusing: ${artifact.name} (${artifact.sys_id})`);
337
- });
338
- }
339
- ```
340
-
341
- ### **STEP 3: 🧠 Intelligent Gap Analysis (NEW!)**
342
-
343
- ```javascript
344
- // NEW: Automatically detects ALL ServiceNow configurations needed beyond MCP tools
345
- const gapAnalysis = await analyzeGaps("create incident management with LDAP auth", mcpTools, logger, {
346
- autoPermissions: true, // Automatic configuration when possible
347
- environment: "development", // Environment-specific guidance
348
- enableAutomation: true, // Attempt automatic resolution
349
- includeManualGuides: true, // Generate manual instructions
350
- riskTolerance: "medium" // Risk assessment level
351
- });
352
-
353
- console.log(`📊 Gap Analysis Results:`);
354
- console.log(` • Total Requirements: ${gapAnalysis.totalRequirements}`);
355
- console.log(` • MCP Coverage: ${gapAnalysis.mcpCoverage.coveragePercentage}%`);
356
- console.log(` • Auto-Resolved: ${gapAnalysis.summary.successfulAutomation} configs`);
357
- console.log(` • Manual Setup: ${gapAnalysis.summary.requiresManualWork} items`);
358
-
359
- // Display automatic configurations
360
- if (gapAnalysis.summary.successfulAutomation > 0) {
361
- console.log('\n✅ Automatically Configured:');
362
- gapAnalysis.nextSteps.automated.forEach(step => console.log(` • ${step}`));
363
- }
364
-
365
- // Display manual setup requirements
366
- if (gapAnalysis.summary.requiresManualWork > 0) {
367
- console.log('\n📋 Manual Configuration Required:');
368
- gapAnalysis.nextSteps.manual.forEach(step => console.log(` • ${step}`));
369
-
370
- // Detailed manual guides available
371
- if (gapAnalysis.manualGuides) {
372
- console.log('\n📚 Detailed step-by-step guides:');
373
- gapAnalysis.manualGuides.guides.forEach(guide => {
374
- console.log(` 📖 ${guide.title} - ${guide.totalEstimatedTime}`);
375
- console.log(` Risk: ${guide.riskLevel} | Roles: ${guide.requiredRoles.join(', ')}`);
376
- });
377
- }
378
- }
379
- ```
380
-
381
- ### **STEP 4: Real ServiceNow Deployment**
382
-
383
- ```javascript
384
- // Deploy directly to ServiceNow - NO local files!
385
- const deployment = await snow_deploy({
386
- type: "widget",
387
- config: {
388
- name: "incident_dashboard",
389
- title: "Incident Dashboard",
390
- template: htmlContent,
391
- server_script: serverJS,
392
- client_script: clientJS,
393
- css: cssStyles
394
- },
395
- auto_update_set: true, // Automatic Update Set management
396
- fallback_strategy: "manual_steps" // Graceful degradation
397
- });
398
- ```
399
-
400
- ### **STEP 5: Automatic Update Set Tracking**
401
-
402
- ```javascript
403
- // Every deployment is automatically tracked
404
- await snow_update_set_add_artifact({
405
- type: deployment.type,
406
- sys_id: deployment.result.sys_id,
407
- name: deployment.result.name
408
- });
409
-
410
- console.log(`✅ Widget deployed: ${deployment.result.sys_id}`);
411
- console.log(`📋 Tracked in Update Set: ${deployment.update_set_id}`);
412
- ```
413
-
414
- ## 🧠 Intelligent Gap Analysis Engine (Revolutionary New Feature!)
415
-
416
- **The breakthrough solution for handling ALL ServiceNow configurations beyond MCP tools!**
417
-
418
- ### What It Does
419
-
420
- The Gap Analysis Engine automatically detects **60+ types of ServiceNow configurations** that your objective requires but that fall outside the scope of standard MCP tools:
421
-
422
- **🔐 Authentication & Security:**
423
- - LDAP, SAML, OAuth provider configurations
424
- - SSO setup, MFA configurations
425
- - ACL rules, data policies, user roles
426
-
427
- **🗄️ Database & Performance:**
428
- - Database indexes, views, partitioning
429
- - Performance analytics, monitoring configs
430
- - System properties, cache settings
431
-
432
- **🧭 Navigation & UI:**
433
- - Application menus, navigation modules
434
- - Form layouts, sections, list configurations
435
- - UI actions, policies, client scripts
436
-
437
- **📧 Communication & Integration:**
438
- - Email templates, notification rules
439
- - Web services, SOAP messages, import sets
440
- - Transform maps, integration endpoints
441
-
442
- **🔄 Workflow & Automation:**
443
- - Workflow activities, transitions
444
- - SLA definitions, escalation rules
445
- - Scheduled jobs, event rules
446
-
447
- ### How It Works
448
-
33
+ **Examples of WRONG sequential execution:**
449
34
  ```javascript
450
- // The engine analyzes your objective and automatically:
451
-
452
- 1. 🎯 REQUIREMENTS ANALYSIS
453
- - Parses natural language objective
454
- - Identifies ALL required ServiceNow configurations
455
- - Maps dependencies and relationships
456
-
457
- 2. 📊 MCP COVERAGE ANALYSIS
458
- - Checks what current MCP tools can handle
459
- - Identifies gaps requiring manual setup
460
- - Calculates automation potential
461
-
462
- 3. 🤖 AUTO-RESOLUTION ENGINE
463
- - Attempts automatic configuration via ServiceNow APIs
464
- - Handles system properties, navigation, basic auth
465
- - Respects risk levels and permission requirements
466
-
467
- 4. 📚 MANUAL INSTRUCTIONS GENERATOR
468
- - Creates detailed step-by-step guides
469
- - Environment-specific instructions (dev/test/prod)
470
- - Role requirements, warnings, verification steps
35
+ // WRONG: Multiple messages (NEVER DO THIS)
36
+ Message 1: TodoWrite { todos: [single todo] }
37
+ Message 2: Task("Agent 1")
38
+ Message 3: Task("Agent 2")
39
+ Message 4: Read("file1.js")
40
+ Message 5: Write("output1.js")
41
+ Message 6: Bash("npm install")
42
+ // This is 6x slower and breaks coordination!
471
43
  ```
472
44
 
473
- ### Example Output
474
-
475
- ```bash
476
- snow-flow queen "create incident management with LDAP authentication"
477
-
478
- 🧠 Step 4: Running Intelligent Gap Analysis...
479
- 📊 Gap Analysis Complete:
480
- • Total Requirements: 12
481
- • MCP Coverage: 67%
482
- • Automated: 6 configurations
483
- • Manual Work: 4 items
484
-
485
- ✅ Automatically Configured:
486
- • System property created: glide.ui.incident_management
487
- • Navigation module: Incident Management added to Service Desk
488
- • Email template: incident_notification configured
489
- • Database index: incident.priority_state for performance
490
- • Form layout: incident form sections optimized
491
- • UI action: "Escalate Priority" button added
492
-
493
- 📋 Manual Configuration Required:
494
- • LDAP authentication setup (high-risk operation)
495
- • SSO configuration with Active Directory
496
- • Custom ACL rules for incident priority restrictions
497
- • Email server configuration for notifications
498
-
499
- 📚 Detailed Manual Guides Available:
500
- 📖 Configure LDAP Authentication - 25 minutes
501
- Risk: high | Roles: security_admin, admin
502
- 📖 Setup SSO with Active Directory - 45 minutes
503
- Risk: high | Roles: security_admin
504
- 📖 Create Custom ACL Rules - 15 minutes
505
- Risk: medium | Roles: admin
506
- 📖 Configure Email Server - 20 minutes
507
- Risk: low | Roles: email_admin
508
-
509
- 💡 Recommendations:
510
- • Test LDAP configuration in development environment first
511
- • Coordinate with security team for SSO setup
512
- • Review ACL rules with business stakeholders
513
- ```
514
-
515
- ### Advanced Usage
516
-
517
- ```javascript
518
- // Direct access to Gap Analysis Engine
519
- import { analyzeGaps, quickAnalyze } from './intelligence/gap-analysis-engine';
520
-
521
- // Quick analysis without resolution (planning mode)
522
- const quickResult = quickAnalyze("create mobile app with push notifications");
523
- console.log(`Complexity: ${quickResult.estimatedComplexity}`);
524
- console.log(`Requirements: ${quickResult.requirements.length}`);
525
-
526
- // Full analysis with automatic resolution
527
- const fullResult = await analyzeGaps("objective", mcpTools, logger, {
528
- autoPermissions: false, // Prompt before high-risk operations
529
- environment: "production", // Production-specific guidance
530
- enableAutomation: true, // Attempt automatic fixes
531
- includeManualGuides: true, // Generate detailed guides
532
- riskTolerance: "low" // Conservative approach
533
- });
534
-
535
- // Access manual guides for specific configurations
536
- if (fullResult.manualGuides) {
537
- fullResult.manualGuides.guides.forEach(guide => {
538
- console.log(`\n📖 ${guide.title}`);
539
- console.log(`⏱️ Estimated time: ${guide.totalEstimatedTime}`);
540
- console.log(`🛡️ Risk level: ${guide.riskLevel}`);
541
- console.log(`👥 Required roles: ${guide.requiredRoles.join(', ')}`);
542
-
543
- guide.instructions.forEach((instruction, index) => {
544
- console.log(`\n${index + 1}. ${instruction.title}`);
545
- console.log(` ${instruction.description}`);
546
- if (instruction.warnings) {
547
- instruction.warnings.forEach(warning => {
548
- console.log(` ⚠️ ${warning}`);
549
- });
550
- }
551
- });
552
- });
553
- }
554
- ```
45
+ ### 🎯 CONCURRENT EXECUTION CHECKLIST:
555
46
 
556
- ### Queen Agent Integration
557
-
558
- The Gap Analysis Engine is **automatically integrated** into the Queen Agent workflow:
559
-
560
- ```bash
561
- # Every Queen Agent execution now includes:
562
- snow-flow queen "create ITSM solution with approval workflows"
563
-
564
- # Workflow: Auth → Discovery → 🧠 Gap Analysis → MCP Tools → Deployment
565
- ```
566
-
567
- **No additional configuration needed!** The engine runs automatically and provides:
568
- - ✅ **Automatic configuration** of detectable items
569
- - 📋 **Detailed manual guides** for complex setups
570
- - 💡 **Strategic recommendations** for optimal implementation
571
- - 🛡️ **Risk assessment** and safety warnings
572
-
573
- ### Why This Is Revolutionary
574
-
575
- **Before:** "Sorry, dat kunnen de MCP tools niet - je moet het handmatig doen"
576
-
577
- **After:** "🧠 Ik heb 8 configurations automatisch ingesteld en hier zijn de gedetailleerde instructies voor de 3 items die handmatige setup vereisen, inclusief stappenplannen per rol en risico-assessment"
578
-
579
- **This completely solves the original request: "alle mogelijke soorten handelingen die nodig zouden zijn om een objective te bereiken die vallen buiten de standaard mcps"**
580
-
581
- ## 🎯 MCP Tool Reference (Use These ALWAYS!)
582
-
583
- ### Core Deployment Tools
584
- ```javascript
585
- // Universal deployment (replaces all old deploy_* tools)
586
- snow_deploy({ type: "widget|application|script", config: {...} })
587
-
588
- // NEW: XML Update Set deployment for flows
589
- snow_deploy({
590
- type: "xml_update_set",
591
- xml_file_path: "/path/to/flow.xml",
592
- auto_preview: true,
593
- auto_commit: true
594
- })
595
-
596
- // Smart artifact discovery
597
- snow_find_artifact({ query: "natural language", type: "widget" })
598
- snow_comprehensive_search({ query: "broader search" })
599
-
600
- // Live connection testing
601
- snow_validate_live_connection({ test_level: "permissions" })
602
-
603
- // Update Set management (automatic in snow_deploy)
604
- snow_smart_update_set({ auto_track_related_artifacts: true })
605
- ```
47
+ Before sending ANY message, ask yourself:
48
+ - ✅ Are ALL related TodoWrite operations batched together?
49
+ - Are ALL Task spawning operations in ONE message?
50
+ - ✅ Are ALL file operations (Read/Write/Edit) batched together?
51
+ - ✅ Are ALL bash commands grouped in ONE message?
52
+ - Are ALL memory operations concurrent?
606
53
 
607
- ### Testing & Validation Tools
608
- ```javascript
609
- // Test flows with mock data (safer than live testing)
610
- snow_test_flow_with_mock({
611
- flow_id: "approval_flow",
612
- create_test_user: true,
613
- cleanup_after_test: true
614
- })
615
-
616
- // Widget testing
617
- snow_widget_test({
618
- sys_id: "widget_sys_id",
619
- test_scenarios: [...]
620
- })
621
-
622
- // Live deployment validation
623
- snow_validate_deployment({ type: "widget", artifact: {...} })
624
- ```
54
+ If ANY answer is "No", you MUST combine operations into a single message!
625
55
 
626
- ### Authentication & Recovery Tools
627
- ```javascript
628
- // Authentication diagnostics
629
- snow_auth_diagnostics({
630
- run_write_test: true,
631
- include_recommendations: true
632
- })
633
-
634
- // Permission escalation (when needed)
635
- snow_escalate_permissions({
636
- required_roles: ['admin'],
637
- reason: 'Widget deployment requires admin access'
638
- })
639
- ```
56
+ ## Project Overview
57
+ This project uses the SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) methodology for systematic Test-Driven Development with AI assistance through Claude-Flow orchestration.
640
58
 
641
- ## 🚨 Error Patterns & Recovery
59
+ **🚀 Batchtools Optimization Enabled**: This configuration includes optimized prompts and parallel processing capabilities for improved performance and efficiency.
642
60
 
643
- ### Common Errors & MCP Solutions
61
+ ## SPARC Development Commands
644
62
 
645
- **Authentication Errors (401/403)**
646
- ```javascript
647
- if (error.status === 401 || error.status === 403) {
648
- const diagnostics = await snow_auth_diagnostics();
649
- if (!diagnostics.oauth_configured) {
650
- return "Run: snow-flow auth login";
651
- }
652
- if (diagnostics.token_expired) {
653
- return "Token expired - please re-authenticate";
654
- }
655
- }
656
- ```
63
+ ### Core SPARC Commands
64
+ - `npx claude-flow sparc modes`: List all available SPARC development modes
65
+ - `npx claude-flow sparc run <mode> "<task>"`: Execute specific SPARC mode for a task
66
+ - `npx claude-flow sparc tdd "<feature>"`: Run complete TDD workflow using SPARC methodology
67
+ - `npx claude-flow sparc info <mode>`: Get detailed information about a specific mode
657
68
 
658
- **Permission Errors**
659
- ```javascript
660
- if (error.includes('insufficient privileges')) {
661
- await snow_escalate_permissions({
662
- required_roles: ['admin', 'app_creator'],
663
- workflow_context: 'ServiceNow widget development'
664
- });
665
- }
666
- ```
69
+ ### Batchtools Commands (Optimized)
70
+ - `npx claude-flow sparc batch <modes> "<task>"`: Execute multiple SPARC modes in parallel
71
+ - `npx claude-flow sparc pipeline "<task>"`: Execute full SPARC pipeline with parallel processing
72
+ - `npx claude-flow sparc concurrent <mode> "<tasks-file>"`: Process multiple tasks concurrently
667
73
 
668
- **Deployment Conflicts**
669
- ```javascript
670
- if (error.includes('already exists')) {
671
- const existing = await snow_find_artifact({
672
- query: config.name,
673
- type: config.type
674
- });
675
-
676
- return `
677
- 🔍 Artifact exists: ${existing.name} (${existing.sys_id})
678
- Options:
679
- 1. Update existing: snow_edit_by_sysid()
680
- 2. Create with different name
681
- 3. Use existing as-is
682
- `;
683
- }
684
- ```
74
+ ### Standard Build Commands
75
+ - `npm run build`: Build the project
76
+ - `npm run test`: Run the test suite
77
+ - `npm run lint`: Run linter and format checks
78
+ - `npm run typecheck`: Run TypeScript type checking
685
79
 
686
- ## 📋 Quick Start Workflows
80
+ ## SPARC Methodology Workflow (Batchtools Enhanced)
687
81
 
688
- ### 🚀 Widget Development (MCP-First)
82
+ ### 1. Specification Phase (Parallel Analysis)
689
83
  ```bash
690
- # 1. Authentication check (automatic in Swarm)
691
- snow-flow swarm "create incident dashboard widget"
692
-
693
- # Manual MCP workflow (what happens internally):
694
- # snow_validate_live_connection() → snow_find_artifact() → snow_deploy() → snow_update_set_add_artifact()
84
+ # Create detailed specifications with concurrent requirements analysis
85
+ npx claude-flow sparc run spec-pseudocode "Define user authentication requirements" --parallel
695
86
  ```
87
+ **Batchtools Optimization**: Simultaneously analyze multiple requirement sources, validate constraints in parallel, and generate comprehensive specifications.
696
88
 
697
- ### 🔄 Flow Development (MCP-First)
89
+ ### 2. Pseudocode Phase (Concurrent Logic Design)
698
90
  ```bash
699
- # Swarm handles all MCP orchestration with multiple agents
700
- snow-flow swarm "create approval workflow for equipment requests"
701
-
702
- # What happens: snow_create_flow({ deploy_immediately: true }) → live deployment → flow ready in ServiceNow
91
+ # Develop algorithmic logic with parallel pattern analysis
92
+ npx claude-flow sparc run spec-pseudocode "Create authentication flow pseudocode" --batch-optimize
703
93
  ```
94
+ **Batchtools Optimization**: Process multiple algorithm patterns concurrently, validate logic flows in parallel, and optimize data structures simultaneously.
704
95
 
705
- ### 🎯 Smart Discovery Before Creation
96
+ ### 3. Architecture Phase (Parallel Component Design)
706
97
  ```bash
707
- # Always check first!
708
- snow-flow swarm "find existing incident widgets and create improved version"
709
-
710
- # Uses: snow_comprehensive_search() → swarm analysis → smart reuse recommendations
98
+ # Design system architecture with concurrent component analysis
99
+ npx claude-flow sparc run architect "Design authentication service architecture" --parallel
711
100
  ```
101
+ **Batchtools Optimization**: Generate multiple architectural alternatives simultaneously, validate integration points in parallel, and create comprehensive documentation concurrently.
712
102
 
713
- ## 🔧 Build Commands & Testing
714
- - `npm run build`: Build project
715
- - `npm run test`: Run test suite
716
- - `npm run lint`: Code quality checks
717
- - `npm run typecheck`: TypeScript validation
718
- - `snow-flow auth login`: ServiceNow authentication
719
- - `snow-flow status`: System health check
720
-
721
- ## 💡 Important Development Rules
722
-
723
- ### ✅ DO THESE ALWAYS:
724
- - ✅ **Start with MCP tools** - `snow_validate_live_connection()` first
725
- - ✅ **Use discovery** - `snow_find_artifact()` before creating
726
- - ✅ **Deploy real artifacts** - `snow_deploy()` to ServiceNow
727
- - ✅ **Track everything** - Automatic in `snow_deploy()` with `auto_update_set: true`
728
- - ✅ **Test with mock data** - `snow_test_flow_with_mock()` for safety
729
-
730
- ### ❌ NEVER DO THESE:
731
- - ❌ **Create local files** without MCP check first
732
- - ❌ **Generate mock sys_ids** instead of real deployment
733
- - ❌ **Skip authentication** validation
734
- - ❌ **Work offline** when ServiceNow is available
735
- - ❌ **Ignore discovery** results
736
-
737
- ## 🚀 System Architecture
738
-
739
- Snow-flow is built on **MCP-native architecture**:
740
-
741
- 1. **BaseMCPServer Pattern**: All 11 MCP servers use consistent error handling
742
- 2. **MCPExecutionBridge**: Queen Agent uses real MCP tools, not mocks
743
- 3. **Smart Update Sets**: Automatic artifact tracking and management
744
- 4. **Authentication-First**: Every operation validates ServiceNow access
745
- 5. **Discovery-Driven**: Prevent duplication through intelligent search
746
-
747
- ---
748
-
749
- **Remember: Snow-flow's value is REAL ServiceNow integration. Always use `snow-flow swarm` with MCP tools first!** 🚀
750
-
751
- ## 🎯 PRIMARY COMMAND: snow-flow swarm
752
-
753
- **The `swarm` command is your main interface - it orchestrates everything MCP-first:**
754
-
103
+ ### 4. Refinement Phase (Parallel TDD Implementation)
755
104
  ```bash
756
- # PRIMARY INTERFACE - Use this!
757
- snow-flow swarm "create incident dashboard widget"
758
- snow-flow swarm "build approval flow for equipment requests" # Auto-detects Flow Designer!
759
- snow-flow swarm "deploy mobile-responsive widget with accessibility features"
760
-
761
- # ✅ All swarm operations automatically include:
762
- # 1. snow_validate_live_connection() - Auth check
763
- # 2. snow_comprehensive_search() - Smart discovery
764
- # 3. 🔧 Automatic Flow Designer detection (NEW!)
765
- # 4. snow_deploy() OR XML generation + auto-import for flows
766
- # 5. snow_update_set_add_artifact() - Automatic tracking
105
+ # Execute Test-Driven Development with parallel test generation
106
+ npx claude-flow sparc tdd "implement user authentication system" --batch-tdd
767
107
  ```
108
+ **Batchtools Optimization**: Generate multiple test scenarios simultaneously, implement and validate code in parallel, and optimize performance concurrently.
768
109
 
769
- **Every swarm operation is MCP-native and ServiceNow-first!** 🐝
770
-
771
- ### 🚀 Complete Commands Reference
772
-
110
+ ### 5. Completion Phase (Concurrent Integration)
773
111
  ```bash
774
- # Flow Designer workflows (fully automated generation + deployment)
775
- snow-flow swarm "create approval flow for equipment requests"
776
- # ✅ Above command automatically deploys! No manual steps needed.
777
-
778
- # Widget development (standard MCP deployment)
779
- snow-flow swarm "create incident dashboard widget"
780
-
781
- # Application development (standard MCP deployment)
782
- snow-flow swarm "build complete ITSM application"
783
-
784
- # Mixed development (intelligent routing)
785
- snow-flow swarm "create incident management system with approval flows and dashboard widgets"
786
- ```
112
+ # Integration with parallel validation and documentation
113
+ npx claude-flow sparc run integration "integrate authentication with user management" --parallel
114
+ ```
115
+ **Batchtools Optimization**: Run integration tests in parallel, generate documentation concurrently, and validate requirements simultaneously.
116
+
117
+ ## Batchtools Integration Features
118
+
119
+ ### Parallel Processing Capabilities
120
+ - **Concurrent File Operations**: Read, analyze, and modify multiple files simultaneously
121
+ - **Parallel Code Analysis**: Analyze dependencies, patterns, and architecture concurrently
122
+ - **Batch Test Generation**: Create comprehensive test suites in parallel
123
+ - **Concurrent Documentation**: Generate multiple documentation formats simultaneously
124
+
125
+ ### Performance Optimizations
126
+ - **Smart Batching**: Group related operations for optimal performance
127
+ - **Pipeline Processing**: Chain dependent operations with parallel stages
128
+ - **Resource Management**: Efficient utilization of system resources
129
+ - **Error Resilience**: Robust error handling with parallel recovery
130
+
131
+ ## Performance Benchmarks
132
+
133
+ ### Batchtools Performance Improvements
134
+ - **File Operations**: Up to 300% faster with parallel processing
135
+ - **Code Analysis**: 250% improvement with concurrent pattern recognition
136
+ - **Test Generation**: 400% faster with parallel test creation
137
+ - **Documentation**: 200% improvement with concurrent content generation
138
+ - **Memory Operations**: 180% faster with batched read/write operations
139
+
140
+ ## Code Style and Best Practices (Batchtools Enhanced)
141
+
142
+ ### SPARC Development Principles with Batchtools
143
+ - **Modular Design**: Keep files under 500 lines, optimize with parallel analysis
144
+ - **Environment Safety**: Never hardcode secrets, validate with concurrent checks
145
+ - **Test-First**: Always write tests before implementation using parallel generation
146
+ - **Clean Architecture**: Separate concerns with concurrent validation
147
+ - **Parallel Documentation**: Maintain clear, up-to-date documentation with concurrent updates
148
+
149
+ ### Batchtools Best Practices
150
+ - **Parallel Operations**: Use batchtools for independent tasks
151
+ - **Concurrent Validation**: Validate multiple aspects simultaneously
152
+ - **Batch Processing**: Group similar operations for efficiency
153
+ - **Pipeline Optimization**: Chain operations with parallel stages
154
+ - **Resource Management**: Monitor and optimize resource usage
155
+
156
+ ## Important Notes (Enhanced)
157
+
158
+ - Always run tests before committing with parallel execution (`npm run test --parallel`)
159
+ - Use SPARC memory system with concurrent operations to maintain context across sessions
160
+ - Follow the Red-Green-Refactor cycle with parallel test generation during TDD phases
161
+ - Document architectural decisions with concurrent validation in memory
162
+ - Regular security reviews with parallel analysis for authentication or data handling code
163
+ - Claude Code slash commands provide quick access to batchtools-optimized SPARC modes
164
+ - Monitor system resources during parallel operations for optimal performance
165
+
166
+ For more information about SPARC methodology and batchtools optimization, see:
167
+ - SPARC Guide: https://github.com/ruvnet/claude-code-flow/docs/sparc.md
168
+ - Batchtools Documentation: https://github.com/ruvnet/claude-code-flow/docs/batchtools.md
169
+
170
+ # important-instruction-reminders
171
+ Do what has been asked; nothing more, nothing less.
172
+ NEVER create files unless they're absolutely necessary for achieving your goal.
173
+ ALWAYS prefer editing an existing file to creating a new one.
174
+ NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.