snow-flow 1.1.82 → 1.1.84

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 (82) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/.claude-flow/queen/queen-memory.db +0 -0
  3. package/CLAUDE.md +276 -972
  4. package/dist/cli.js +806 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/mcp/base-mcp-server.d.ts +117 -0
  7. package/dist/mcp/base-mcp-server.d.ts.map +1 -0
  8. package/dist/mcp/base-mcp-server.js +351 -0
  9. package/dist/mcp/base-mcp-server.js.map +1 -0
  10. package/dist/mcp/example-refactored-server.d.ts +18 -0
  11. package/dist/mcp/example-refactored-server.d.ts.map +1 -0
  12. package/dist/mcp/example-refactored-server.js +58 -0
  13. package/dist/mcp/example-refactored-server.js.map +1 -0
  14. package/dist/mcp/servicenow-automation-mcp-refactored.d.ts +26 -0
  15. package/dist/mcp/servicenow-automation-mcp-refactored.d.ts.map +1 -0
  16. package/dist/mcp/servicenow-automation-mcp-refactored.js +552 -0
  17. package/dist/mcp/servicenow-automation-mcp-refactored.js.map +1 -0
  18. package/dist/mcp/servicenow-flow-composer-mcp-refactored.d.ts +25 -0
  19. package/dist/mcp/servicenow-flow-composer-mcp-refactored.d.ts.map +1 -0
  20. package/dist/mcp/servicenow-flow-composer-mcp-refactored.js +566 -0
  21. package/dist/mcp/servicenow-flow-composer-mcp-refactored.js.map +1 -0
  22. package/dist/mcp/servicenow-graph-memory-mcp-refactored.d.ts +32 -0
  23. package/dist/mcp/servicenow-graph-memory-mcp-refactored.d.ts.map +1 -0
  24. package/dist/mcp/servicenow-graph-memory-mcp-refactored.js +642 -0
  25. package/dist/mcp/servicenow-graph-memory-mcp-refactored.js.map +1 -0
  26. package/dist/mcp/servicenow-integration-mcp-refactored.d.ts +24 -0
  27. package/dist/mcp/servicenow-integration-mcp-refactored.d.ts.map +1 -0
  28. package/dist/mcp/servicenow-integration-mcp-refactored.js +521 -0
  29. package/dist/mcp/servicenow-integration-mcp-refactored.js.map +1 -0
  30. package/dist/mcp/servicenow-operations-mcp-refactored.d.ts +65 -0
  31. package/dist/mcp/servicenow-operations-mcp-refactored.d.ts.map +1 -0
  32. package/dist/mcp/servicenow-operations-mcp-refactored.js +1913 -0
  33. package/dist/mcp/servicenow-operations-mcp-refactored.js.map +1 -0
  34. package/dist/mcp/servicenow-platform-development-mcp-refactored.d.ts +25 -0
  35. package/dist/mcp/servicenow-platform-development-mcp-refactored.d.ts.map +1 -0
  36. package/dist/mcp/servicenow-platform-development-mcp-refactored.js +542 -0
  37. package/dist/mcp/servicenow-platform-development-mcp-refactored.js.map +1 -0
  38. package/dist/mcp/servicenow-reporting-analytics-mcp-refactored.d.ts +26 -0
  39. package/dist/mcp/servicenow-reporting-analytics-mcp-refactored.d.ts.map +1 -0
  40. package/dist/mcp/servicenow-reporting-analytics-mcp-refactored.js +646 -0
  41. package/dist/mcp/servicenow-reporting-analytics-mcp-refactored.js.map +1 -0
  42. package/dist/mcp/servicenow-security-compliance-mcp-refactored.d.ts +25 -0
  43. package/dist/mcp/servicenow-security-compliance-mcp-refactored.d.ts.map +1 -0
  44. package/dist/mcp/servicenow-security-compliance-mcp-refactored.js +600 -0
  45. package/dist/mcp/servicenow-security-compliance-mcp-refactored.js.map +1 -0
  46. package/dist/mcp/servicenow-update-set-mcp-refactored.d.ts +31 -0
  47. package/dist/mcp/servicenow-update-set-mcp-refactored.d.ts.map +1 -0
  48. package/dist/mcp/servicenow-update-set-mcp-refactored.js +658 -0
  49. package/dist/mcp/servicenow-update-set-mcp-refactored.js.map +1 -0
  50. package/dist/orchestrator/flow-composer.d.ts.map +1 -1
  51. package/dist/orchestrator/flow-composer.js +13 -30
  52. package/dist/orchestrator/flow-composer.js.map +1 -1
  53. package/dist/queen/advanced-integration-test.js +1 -1
  54. package/dist/queen/advanced-integration-test.js.map +1 -1
  55. package/dist/queen/mcp-execution-bridge.d.ts +111 -0
  56. package/dist/queen/mcp-execution-bridge.d.ts.map +1 -0
  57. package/dist/queen/mcp-execution-bridge.js +547 -0
  58. package/dist/queen/mcp-execution-bridge.js.map +1 -0
  59. package/dist/queen/queen-memory.d.ts +28 -0
  60. package/dist/queen/queen-memory.d.ts.map +1 -1
  61. package/dist/queen/queen-memory.js +75 -0
  62. package/dist/queen/queen-memory.js.map +1 -1
  63. package/dist/queen/servicenow-queen.d.ts +3 -1
  64. package/dist/queen/servicenow-queen.d.ts.map +1 -1
  65. package/dist/queen/servicenow-queen.js +93 -12
  66. package/dist/queen/servicenow-queen.js.map +1 -1
  67. package/dist/snow-flow-system.d.ts.map +1 -1
  68. package/dist/snow-flow-system.js +22 -11
  69. package/dist/snow-flow-system.js.map +1 -1
  70. package/dist/sparc/sparc-help.d.ts +2 -4
  71. package/dist/sparc/sparc-help.d.ts.map +1 -1
  72. package/dist/sparc/sparc-help.js +32 -290
  73. package/dist/sparc/sparc-help.js.map +1 -1
  74. package/dist/sparc/team-sparc.d.ts +4 -28
  75. package/dist/sparc/team-sparc.d.ts.map +1 -1
  76. package/dist/sparc/team-sparc.js +23 -201
  77. package/dist/sparc/team-sparc.js.map +1 -1
  78. package/dist/version.d.ts +11 -1
  79. package/dist/version.d.ts.map +1 -1
  80. package/dist/version.js +38 -1
  81. package/dist/version.js.map +1 -1
  82. package/package.json +1 -1
package/CLAUDE.md CHANGED
@@ -1,1103 +1,407 @@
1
1
  # Snow-Flow Development with Claude Code
2
2
 
3
- ## 👑 Queen Agent - The claude-flow Revolution
3
+ ## 🚨 CRITICAL: MCP-FIRST WORKFLOW (READ THIS FIRST!)
4
4
 
5
- **The future of ServiceNow development is here!** The ServiceNow Queen Agent embodies the claude-flow philosophy: **elegant simplicity through hive-mind intelligence**.
5
+ **Snow-flow's core value is REAL ServiceNow integration through MCP tools. NEVER work in offline mode!**
6
6
 
7
- ### 🧠 Claude-Flow Philosophy
7
+ ### ⚠️ MANDATORY WORKFLOW - NO EXCEPTIONS
8
8
 
9
- Inspired by Claude's natural language capabilities, the Queen Agent transforms complex multi-agent orchestration into simple, intuitive commands. Just as Claude understands human intent from natural language, the Queen Agent understands development objectives and automatically orchestrates the perfect team.
10
-
11
- **Core Principles:**
12
- - **Hive-Mind Intelligence**: All agents share knowledge and learn collectively
13
- - **Intent-Driven Development**: Describe what you want, not how to build it
14
- - **Memory-Driven Patterns**: Learn from every execution, improve over time
15
- - **Elegant Simplicity**: One command replaces complex coordination
16
-
17
- ### 🚀 Primary Development Interface (RECOMMENDED)
18
-
19
- ```bash
20
- # The Queen Agent - One Command Does Everything!
21
- snow-flow queen "create incident dashboard with charts and real-time data"
22
- snow-flow queen "build approval workflow for equipment requests"
23
- snow-flow queen "deploy mobile-responsive widget with accessibility features"
24
- snow-flow queen "create complete ITSM solution with custom tables and workflows"
25
- ```
26
-
27
- #### Queen Commands Overview
28
-
29
- | Command | Purpose | Example |
30
- |---------|---------|----------|
31
- | `snow-flow queen "<objective>"` | Primary development command | `snow-flow queen "create incident widget"` |
32
- | `snow-flow queen-memory export [file]` | Export learning patterns | `snow-flow queen-memory export patterns.json` |
33
- | `snow-flow queen-memory import [file]` | Import previous learning | `snow-flow queen-memory import patterns.json` |
34
- | `snow-flow queen-memory clear --confirm` | Reset all learning | `snow-flow queen-memory clear --confirm` |
35
- | `snow-flow queen-status [--detailed]` | View hive-mind status | `snow-flow queen-status --detailed` |
36
- | `snow-flow queen-insights` | Get AI recommendations | `snow-flow queen-insights` |
37
-
38
- ### 🔄 Enhanced Backward Compatibility
39
-
40
- ```bash
41
- # Queen intelligence can enhance existing commands
42
- snow-flow swarm "create widget" --queen # Adds Queen intelligence to swarm
43
- snow-flow sparc "create flow" --queen # Queen-powered SPARC execution
44
- ```
45
-
46
- ### Queen vs Traditional Development
47
-
48
- | Traditional Approach | Queen Agent Approach |
49
- |---------------------|----------------------|
50
- | `snow-flow swarm "objective" --strategy development --mode hierarchical --max-agents 8 --parallel --monitor --shared-memory --validation --auto-deploy` | `snow-flow queen "objective" --monitor` |
51
- | `snow-flow sparc team widget "dashboard" --shared-memory --validation` | `snow-flow queen "create dashboard"` |
52
- | Complex team assembly and coordination | Automatic hive-mind orchestration |
53
- | Manual memory management | Memory-driven pattern learning |
54
- | Separate commands for different artifact types | Universal objective understanding |
55
-
56
- ### 🧠 Queen Intelligence Features
57
-
58
- - **🎯 Automatic Agent Spawning**: Analyzes objectives and spawns optimal specialist teams
59
- - **📊 Memory-Driven Development**: Learns successful patterns and applies them automatically
60
- - **🔄 Graceful Fallbacks**: Falls back to traditional methods when needed
61
- - **👑 Hive-Mind Coordination**: All agents share context and learn collectively
62
- - **🚀 One Command Philosophy**: Analyze → Spawn → Coordinate → Deploy in one step
63
-
64
- ### 🎯 Quick Start with Queen (RECOMMENDED)
65
-
66
- ```bash
67
- # 1. Initialize project
68
- snow-flow init --sparc
69
-
70
- # 2. Authenticate
71
- snow-flow auth login
72
-
73
- # 3. Start developing with Queen!
74
- snow-flow queen "create incident management dashboard with charts"
75
-
76
- # 4. Check learning status
77
- snow-flow queen-status --detailed
78
-
79
- # 5. Export learning for reuse
80
- snow-flow queen-memory export my-patterns.json
81
- ```
82
-
83
- ---
84
-
85
- ## 🚀 Core Development Principles
86
-
87
- ### Concurrent Execution Strategy
88
- **Golden Rule**: "1 MESSAGE = ALL RELATED OPERATIONS"
89
- - Always batch related MCP tool calls in a single response
90
- - Use TodoWrite extensively for complex task coordination
91
- - Launch multiple agents concurrently for maximum performance
92
- - Leverage batch file operations whenever reading/writing multiple files
93
-
94
- ### ServiceNow Development Best Practices
95
- 1. **Never hardcode credentials** - Use OAuth and environment variables
96
- 2. **Always work in Update Sets** - MANDATORY SEQUENCE:
97
- a. FIRST: Create update set with `snow_update_set_create`
98
- b. THEN: Switch to it with `snow_update_set_switch`
99
- c. TRACK: Every artifact with `snow_update_set_add_artifact`
100
- d. CHECK: Current status with `snow_update_set_current`
101
- e. COMPLETE: Mark complete with `snow_update_set_complete`
102
- 3. **Test before deploy** - Use mock testing tools for validation
103
- 4. **Validate permissions** - Check OAuth scopes before operations
104
- 5. **Use fuzzy search** - ServiceNow names can vary (iPhone vs iPhone 6S)
105
- 6. **Track all artifacts** - Use snow_update_set_add_artifact after EVERY deployment
106
- 7. **Test with mock first** - Use snow_test_flow_with_mock before comprehensive testing
107
- 8. **Verify before test** - Check artifact exists with snow_get_by_sysid before testing
108
-
109
- ### Update Set Best Practices
110
- - NEVER deploy without active update set
111
- - ALWAYS track artifacts immediately after deployment
112
- - CHECK current update set before starting work
113
- - COMPLETE update sets before moving between environments
114
-
115
- ## 🔒 MANDATORY ServiceNow Development Workflow (v1.1.79+)
116
-
117
- ### 🚨 CRITICAL: All ServiceNow Operations MUST Follow This Workflow
118
-
119
- **Every single ServiceNow operation must start with authentication validation!** The MCP servers now automatically enforce this workflow.
120
-
121
- #### **STEP 1: MANDATORY Authentication Validation**
9
+ **Every ServiceNow task MUST start with this sequence:**
122
10
 
123
11
  ```javascript
124
- // This happens automatically in ALL MCP tools
125
- const connectionResult = await validateServiceNowConnection();
126
- if (!connectionResult.success) {
127
- return createAuthenticationError(connectionResult.error);
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);
128
17
  }
129
- ```
130
-
131
- **What This Checks:**
132
- 1. ✅ **Credentials Exist**: .env file has OAuth settings
133
- 2. ✅ **OAuth Session Active**: Valid access token exists
134
- 3. ✅ **Token Valid**: Not expired, auto-refresh if needed
135
- 4. ✅ **Live Connection**: Actual ServiceNow instance responds
136
-
137
- **If Authentication Fails, You Get:**
138
- ```
139
- ❌ ServiceNow Connection Failed
140
-
141
- OAuth authentication required. Run "snow-flow auth login" to authenticate.
142
18
 
143
- 🔧 To fix this:
144
-
145
- 1. Ensure .env file has OAuth credentials:
146
- SNOW_INSTANCE=your-instance.service-now.com
147
- SNOW_CLIENT_ID=your_oauth_client_id
148
- SNOW_CLIENT_SECRET=your_oauth_client_secret
19
+ // 2. MANDATORY: Discovery before creation
20
+ const discovery = await snow_find_artifact({
21
+ query: "your objective",
22
+ type: "widget|flow|script|any"
23
+ });
149
24
 
150
- 2. Authenticate with ServiceNow:
151
- snow-flow auth login
25
+ // 3. MANDATORY: Real ServiceNow deployment
26
+ const deployment = await snow_deploy({
27
+ type: "widget|flow|application",
28
+ config: { /* your config */ },
29
+ auto_update_set: true // Always track changes
30
+ });
152
31
 
153
- 3. If you still get errors, run diagnostics:
154
- snow_auth_diagnostics()
32
+ // 4. MANDATORY: Track in Update Set
33
+ await snow_update_set_add_artifact({
34
+ type: deployment.type,
35
+ sys_id: deployment.result.sys_id,
36
+ name: deployment.result.name
37
+ });
155
38
  ```
156
39
 
157
- #### **STEP 2: Smart Artifact Discovery (DRY Principle)**
158
-
159
- ```javascript
160
- // Automatic discovery before creating anything new
161
- const discovery = await discoverExistingArtifacts(
162
- type, // 'widget', 'flow', 'script', etc.
163
- artifactName, // Extracted from instruction/config
164
- searchTerms // Related keywords for comprehensive search
165
- );
166
-
167
- if (discovery.found) {
168
- console.log(`🔍 Found ${discovery.artifacts.length} existing artifacts`);
169
- console.log(`💡 Suggestions: ${discovery.suggestions.join(', ')}`);
170
- }
171
- ```
40
+ ### 🚫 FORBIDDEN ACTIONS
172
41
 
173
- **Discovery Results Include:**
174
- - 📋 **Existing Artifacts**: Similar names and functionality
175
- - 💡 **Reuse Suggestions**: "Consider reusing: Widget A, Widget B"
176
- - 🔍 **Related Items**: Found by description and keywords
177
- - ⚠️ **Duplication Warnings**: Prevents creating identical artifacts
42
+ **THESE ACTIONS ARE BANNED - NEVER DO THESE:**
178
43
 
179
- #### **STEP 3: Automatic Update Set Management**
44
+ ❌ **Creating local files** without MCP check first
45
+ ❌ **Generating mock data** instead of using MCP tools
46
+ ❌ **Working in "offline mode"** when ServiceNow is available
47
+ ❌ **Skipping authentication validation**
48
+ ❌ **Planning mode** without trying MCP tools first
180
49
 
181
- ```javascript
182
- // Automatic Update Set creation and tracking
183
- const updateSetId = await ensureUpdateSet(context, purpose);
50
+ ### ✅ CORRECT: MCP-First Decision Tree
184
51
 
185
- // After every deployment
186
- await trackArtifact(sysId, type, name, updateSetId);
187
52
  ```
188
-
189
- **Update Set Features:**
190
- - 📦 **Auto-Creation**: Creates Update Set if none exists
191
- - 🏷️ **Smart Naming**: `Snow-Flow Widget Deployment - 2024-01-15`
192
- - 📋 **Auto-Tracking**: Every artifact automatically tracked
193
- - 🔄 **Session Management**: Links to Agent session for coordination
194
-
195
- ### 🛡️ Error Recovery Patterns with Specific Next Steps
196
-
197
- #### **Authentication Errors (403, 401)**
198
-
199
- ```javascript
200
- // OLD: Generic error
201
- ❌ "Authentication failed"
202
-
203
- // NEW: Specific recovery steps
204
- ❌ ServiceNow Connection Failed
205
-
206
- OAuth token expired and refresh failed. Run "snow-flow auth login" to re-authenticate.
207
-
208
- 🔧 To fix this:
209
- 1. Check .env credentials are correct
210
- 2. Run: snow-flow auth login
211
- 3. If issues persist: snow_auth_diagnostics()
53
+ User Request → ALWAYS START HERE:
54
+ ↓
55
+ 1. snow_validate_live_connection()
56
+ ↓
57
+ SUCCESS? → Continue to Step 2
58
+ ↓
59
+ FAILURE? → Fix auth: snow_auth_diagnostics()
60
+ Then guide user: "snow-flow auth login"
61
+ STOP until auth works
62
+ ↓
63
+ 2. snow_find_artifact() // Check if exists
64
+ ↓
65
+ FOUND? → Ask: "Reuse existing or create new?"
66
+ ↓
67
+ NOT FOUND? → Continue to Step 3
68
+ ↓
69
+ 3. snow_deploy() // Real deployment to ServiceNow
70
+ ↓
71
+ SUCCESS? → Step 4: Track in Update Set
72
+ ↓
73
+ FAILURE? → Use fallback strategies (see below)
74
+ ↓
75
+ 4. snow_update_set_add_artifact() // Always track
76
+ ↓
77
+ DONE! ✅
212
78
  ```
213
79
 
214
- #### **Deployment Errors with Fallback Strategies**
80
+ ## 🔧 Error Recovery - MCP Fallback Strategies
215
81
 
82
+ **Only if MCP tools fail, use these fallbacks:**
83
+
84
+ ### Authentication Failures
216
85
  ```javascript
217
- // Automatic fallback strategies
218
- if (deployment.failed) {
219
- // Strategy 1: Try global scope
220
- if (error.includes('insufficient privileges')) {
221
- await escalateToGlobalScope();
222
- }
223
-
224
- // Strategy 2: Manual steps guide
225
- if (fallback_strategy === 'manual_steps') {
226
- return createManualStepsGuide(artifact, error);
227
- }
228
-
229
- // Strategy 3: Update Set only
230
- if (fallback_strategy === 'update_set_only') {
231
- await createUpdateSetWithInstructions(artifact);
232
- }
233
- }
234
- ```
86
+ if (error.includes('authentication') || error.includes('401') || error.includes('403')) {
87
+ return `
88
+ ❌ ServiceNow Authentication Required
235
89
 
236
- #### **Discovery Conflicts with Resolution Options**
90
+ Fix this now:
91
+ 1. Run: snow-flow auth login
92
+ 2. Check .env: SNOW_INSTANCE, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET
93
+ 3. Test: snow_validate_live_connection()
237
94
 
238
- ```javascript
239
- // When existing artifacts found
240
- if (discovery.found) {
241
- return {
242
- options: [
243
- "1. Reuse existing: incident_dashboard_v2 (recommended)",
244
- "2. Extend existing with new features",
245
- "3. Create new with different name: incident_dashboard_v3",
246
- "4. Override existing (not recommended)"
247
- ],
248
- recommendations: [
249
- "✅ Reusing saves development time",
250
- "⚠️ Check if existing meets requirements first",
251
- "💡 Consider extending instead of duplicating"
252
- ]
253
- };
95
+ Cannot proceed until authentication works!
96
+ `;
254
97
  }
255
98
  ```
256
99
 
257
- ### 🔧 Enhanced OAuth Implementation (v1.1.79+)
258
-
259
- #### **Environment Variable Fallback**
260
-
261
- The OAuth system now properly supports .env fallback:
262
-
100
+ ### Permission Escalation
263
101
  ```javascript
264
- // 1. Try OAuth tokens from ~/.snow-flow/auth.json
265
- // 2. Fallback to .env credentials if no tokens
266
- // 3. Provide specific error messages for each failure
267
-
268
- async loadCredentials(): Promise<ServiceNowCredentials | null> {
269
- // Try saved OAuth tokens first
270
- const tokens = await this.loadTokens();
271
- if (tokens?.accessToken) {
272
- return tokens; // ✅ Valid session found
273
- }
274
-
275
- // 🔧 NEW: Fallback to .env file
276
- const envCredentials = this.loadFromEnv();
277
- if (envCredentials) {
278
- // Return credentials without accessToken - signals OAuth login needed
279
- return envCredentials;
280
- }
281
-
282
- // ❌ No credentials found anywhere
283
- return null;
102
+ if (error.includes('insufficient privileges')) {
103
+ await snow_escalate_permissions({
104
+ required_roles: ['admin', 'app_creator'],
105
+ reason: 'ServiceNow development requires elevated permissions'
106
+ });
284
107
  }
285
108
  ```
286
109
 
287
- #### **Automatic Token Refresh**
288
-
110
+ ### Deployment Failures - Graceful Degradation
289
111
  ```javascript
290
- // Smart token management
291
- if (token.expired) {
292
- console.log('🔄 Token expired, attempting refresh...');
112
+ if (deployment.failed) {
113
+ // Strategy 1: Try global scope
114
+ const globalAttempt = await snow_deploy({
115
+ ...config,
116
+ scope_preference: 'global'
117
+ });
293
118
 
294
- const refreshResult = await oauth.refreshAccessToken();
295
- if (refreshResult.success) {
296
- console.log('✅ Token refreshed successfully');
297
- } else {
298
- return authenticationError('Token refresh failed - login required');
119
+ if (globalAttempt.failed) {
120
+ // Strategy 2: Manual steps guide
121
+ return createManualStepsGuide(config, error);
299
122
  }
300
123
  }
301
124
  ```
302
125
 
303
- ### 📋 MANDATORY Pre-Flight Checklist
126
+ ## 🚀 Swarm Command - MCP-Orchestrated Multi-Agent Intelligence
304
127
 
305
- Before ANY ServiceNow development, ensure:
128
+ **The Swarm system is now MCP-native and ALWAYS uses ServiceNow tools first!**
306
129
 
307
- #### **Environment Setup**
308
- - [ ] ✅ `.env` file has SNOW_INSTANCE, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET
309
- - [ ] ✅ `snow-flow auth login` completed successfully
310
- - [ ] ✅ `snow_validate_live_connection()` returns success
311
-
312
- #### **Development Workflow**
313
- - [ ] ✅ Start with discovery: `snow_find_artifact()` or `snow_comprehensive_search()`
314
- - [ ] ✅ Check for reusable components before creating new
315
- - [ ] ✅ Ensure active Update Set before deployment
316
- - [ ] ✅ Test with mock data first: `snow_test_flow_with_mock()`
317
-
318
- #### **Deployment Verification**
319
- - [ ] ✅ All artifacts tracked in Update Set
320
- - [ ] ✅ Authentication validated before each operation
321
- - [ ] ✅ Error recovery plan in place
322
- - [ ] ✅ Rollback strategy documented
323
-
324
- ### 🚨 Queen Agent Must Develop IN ServiceNow First
325
-
326
- **CRITICAL RULE**: The Queen Agent and all specialists must always develop directly in the live ServiceNow instance using the MCP tools, never create local documentation or placeholder code.
130
+ ### 🚀 Primary Development Interface (RECOMMENDED)
327
131
 
328
132
  ```bash
329
- # ✅ CORRECT: Live development
330
- snow-flow queen "create incident widget"
331
- # → Queen uses snow_deploy() with real ServiceNow instance
332
- # → Creates actual widget in ServiceNow
333
- # → Tracks in Update Set
334
- # → Returns sys_id and live URL
335
-
336
- # ❌ INCORRECT: Local/mock development
337
- # → Creates local HTML/CSS files
338
- # → Uses placeholder data
339
- # → No ServiceNow integration
133
+ # Swarm with automatic MCP-first workflow
134
+ snow-flow swarm "create incident dashboard with charts and real-time data"
135
+ snow-flow swarm "build approval workflow for equipment requests"
136
+ snow-flow swarm "deploy mobile-responsive widget with accessibility features"
340
137
  ```
341
138
 
342
- **Why This Matters:**
343
- - 🎯 **Real Validation**: Only live environment shows real constraints
344
- - 🔗 **Actual Integration**: Real data connections and dependencies
345
- - 📋 **Proper Tracking**: Update Sets only work with live changes
346
- - 🚀 **Immediate Value**: User can see and test results instantly
347
-
348
- ## 🎯 Simplified Deployment API (v1.1.73+)
349
-
350
- ### One Tool for All Deployments
351
- **NEW**: All deployment operations now use the unified `snow_deploy` tool instead of multiple separate tools:
352
-
353
- ```javascript
354
- // ✅ SIMPLIFIED API - One tool for everything
355
- snow_deploy({
356
- type: "widget", // widget, flow, application, script, batch
357
- config: { ... }, // Configuration for widgets/scripts
358
- instruction: "...", // Natural language for flows
359
- artifacts: [...], // For batch deployments
360
- dry_run: false, // Preview mode
361
- parallel: true, // Batch optimization
362
- transaction_mode: true // All-or-nothing deployment
363
- });
364
- ```
139
+ **What happens internally in every swarm:**
140
+ 1. ✅ **Pre-flight auth check** with `snow_validate_live_connection()`
141
+ 2. ✅ **Smart discovery** with `snow_comprehensive_search()`
142
+ 3. ✅ **Multi-agent coordination** with shared MCP context
143
+ 4. ✅ **Real deployment** with `snow_deploy()`
144
+ 5. ✅ **Automatic tracking** with `snow_update_set_add_artifact()`
145
+ 6. ✅ **Live testing** with `snow_test_flow_with_mock()` or `snow_widget_test()`
365
146
 
366
- ### Backward Compatibility
367
- All old deployment tools still work but show deprecation warnings:
368
- - `snow_deploy_widget()` → redirects to `snow_deploy({type: "widget"})`
369
- - `snow_deploy_flow()` → redirects to `snow_deploy({type: "flow"})`
370
- - `snow_deploy_application()` → redirects to `snow_deploy({type: "application"})`
371
- - `snow_bulk_deploy()` → redirects to `snow_deploy({type: "batch"})`
147
+ ### Swarm MCP Integration Features
372
148
 
373
- ### Benefits
374
- - **75% fewer deployment commands** - One tool instead of 4+
375
- - **Consistent interface** - Same parameters across all artifact types
376
- - **Automatic fallbacks** - Built-in resilience and error recovery
377
- - **Better error messages** - Unified error handling and guidance
149
+ - **🎯 Auto MCP Validation**: Every swarm operation starts with auth check
150
+ - **📊 Smart Discovery**: Uses `snow_comprehensive_search()` to find existing artifacts
151
+ - **🔄 Update Set Management**: Automatic `snow_smart_update_set()` creation
152
+ - **🐝 Swarm Coordination**: All agents share MCP context and coordinate via real ServiceNow data
153
+ - **🚀 Live Deployment**: Direct ServiceNow integration via MCP tools
154
+ - **⚡ Parallel Execution**: Multiple agents work simultaneously on ServiceNow
378
155
 
379
- ## 📋 Essential MCP Tool Patterns
156
+ ## 🔒 MANDATORY ServiceNow Development Workflow
380
157
 
381
- ### Batch Operations for Maximum Efficiency
382
- ```javascript
383
- // GOOD: Single message with multiple tool calls
384
- TodoWrite([...tasks]);
385
- Task("Architect", "Design system architecture");
386
- Task("Developer", "Implement components");
387
- Task("Tester", "Create test scenarios");
388
-
389
- // BAD: Sequential single operations
390
- TodoWrite([task1]);
391
- // wait for response
392
- TodoWrite([task2]);
393
- // wait for response
394
- ```
158
+ ### **STEP 1: Authentication Validation (ALWAYS FIRST)**
395
159
 
396
- ### Memory-Driven Coordination
397
- Use Memory to coordinate information across agents:
398
160
  ```javascript
399
- // Store architecture decisions
400
- snow_memory_store({
401
- key: "widget_architecture",
402
- value: "Service Portal widget with Chart.js for data visualization"
161
+ // This happens automatically in ALL MCP tools
162
+ const connectionResult = await snow_validate_live_connection({
163
+ test_level: "permissions" // Test actual write capabilities
403
164
  });
404
165
 
405
- // All agents can reference this
406
- Task("Frontend Dev", "Implement widget based on widget_architecture in memory");
407
- Task("Backend Dev", "Create REST endpoints for widget_architecture requirements");
408
- ```
409
-
410
- ### Team-Driven Development Coordination
411
- Use specialized teams for complex ServiceNow development:
412
-
413
- ```bash
414
- # Team with shared memory and quality gates
415
- snow-flow sparc team widget "dashboard" --shared-memory --validation --monitor
416
-
417
- # Store team requirements and coordination data
418
- snow-flow memory store "team_requirements" "Dashboard with real-time KPIs and mobile responsiveness"
166
+ if (!connectionResult.success) {
167
+ throw new AuthenticationError(`
168
+ ❌ ServiceNow Connection Failed: ${connectionResult.error}
419
169
 
420
- # All team specialists can access shared context
421
- snow-flow memory get "team_requirements"
170
+ 🔧 Fix this now:
171
+ 1. Check .env credentials
172
+ 2. Run: snow-flow auth login
173
+ 3. Test: snow_auth_diagnostics()
174
+ `);
175
+ }
422
176
  ```
423
177
 
424
- ## 🛠️ Complete ServiceNow MCP Tools Reference
178
+ ### **STEP 2: Smart Discovery (Prevent Duplication)**
425
179
 
426
- ### Discovery & Search Tools
427
180
  ```javascript
428
- // Find any ServiceNow artifact using natural language
429
- snow_find_artifact({
430
- query: "the widget that shows incidents on homepage",
431
- type: "widget" // or "flow", "script", "application", "any"
432
- });
433
-
434
- // Search catalog items with fuzzy matching
435
- snow_catalog_item_search({
436
- query: "laptop",
437
- fuzzy_match: true, // Finds variations: notebook, MacBook, etc.
438
- category_filter: "hardware",
439
- include_variables: true // Get catalog variables too
181
+ // ALWAYS check before creating
182
+ const discovery = await snow_comprehensive_search({
183
+ query: "incident dashboard widget",
184
+ include_inactive: false
440
185
  });
441
186
 
442
- // Direct sys_id lookup (faster than search)
443
- snow_get_by_sysid({
444
- sys_id: "abc123...",
445
- table: "sp_widget"
446
- });
187
+ if (discovery.found.length > 0) {
188
+ console.log(`🔍 Found ${discovery.found.length} similar artifacts:`);
189
+ discovery.found.forEach(artifact => {
190
+ console.log(`💡 Consider reusing: ${artifact.name} (${artifact.sys_id})`);
191
+ });
192
+ }
447
193
  ```
448
194
 
449
- ### Flow Development Tools
450
- ```javascript
451
- // Create flows from natural language
452
- snow_create_flow({
453
- instruction: "create a flow that sends email when incident priority is high",
454
- deploy_immediately: true,
455
- enable_intelligent_analysis: true
456
- });
457
-
458
- // Test flows with mock data
459
- snow_test_flow_with_mock({
460
- flow_id: "incident_notification_flow",
461
- create_test_user: true,
462
- mock_catalog_items: true,
463
- test_inputs: {
464
- priority: "1",
465
- category: "hardware"
466
- },
467
- simulate_approvals: true
468
- });
469
-
470
- // Link catalog items to flows
471
- snow_link_catalog_to_flow({
472
- catalog_item_id: "New Laptop Request",
473
- flow_id: "laptop_provisioning_flow",
474
- link_type: "flow_catalog_process",
475
- variable_mapping: [
476
- {
477
- catalog_variable: "laptop_model",
478
- flow_input: "equipment_type"
479
- }
480
- ]
481
- });
482
- ```
195
+ ### **STEP 3: Real ServiceNow Deployment**
483
196
 
484
- ### Widget Development Tools
485
197
  ```javascript
486
- // Deploy widgets with automatic validation (SIMPLIFIED API v1.1.73+)
487
- snow_deploy({
198
+ // Deploy directly to ServiceNow - NO local files!
199
+ const deployment = await snow_deploy({
488
200
  type: "widget",
489
201
  config: {
490
202
  name: "incident_dashboard",
491
- title: "Incident Dashboard",
203
+ title: "Incident Dashboard",
492
204
  template: htmlContent,
493
- css: cssContent,
494
- client_script: clientJS,
495
205
  server_script: serverJS,
496
- demo_data: { incidents: [...] }
497
- }
498
- });
499
-
500
- // OLD API (deprecated but still works with automatic redirection)
501
- // snow_deploy_widget() - shows deprecation warning, redirects to snow_deploy
502
-
503
- // Preview and test widgets
504
- snow_preview_widget({
505
- widget_id: "incident_dashboard",
506
- check_dependencies: true
507
- });
508
-
509
- snow_widget_test({
510
- widget_id: "incident_dashboard",
511
- test_scenarios: [
512
- {
513
- name: "Load with no data",
514
- server_data: { incidents: [] }
515
- }
516
- ]
206
+ client_script: clientJS,
207
+ css: cssStyles
208
+ },
209
+ auto_update_set: true, // Automatic Update Set management
210
+ fallback_strategy: "manual_steps" // Graceful degradation
517
211
  });
518
212
  ```
519
213
 
520
- ### Bulk Operations
521
- ```javascript
522
- // Deploy multiple artifacts at once (SIMPLIFIED API v1.1.73+)
523
- snow_deploy({
524
- type: "batch",
525
- artifacts: [
526
- { type: "widget", config: widgetData },
527
- { type: "flow", instruction: "approval flow" },
528
- { type: "script", config: scriptData }
529
- ],
530
- transaction_mode: true, // All or nothing
531
- parallel: true, // Deploy simultaneously
532
- dry_run: false
533
- });
214
+ ### **STEP 4: Automatic Update Set Tracking**
534
215
 
535
- // OLD API (deprecated but still works with automatic redirection)
536
- // snow_bulk_deploy() - shows deprecation warning, redirects to snow_deploy
537
- ```
538
-
539
- ### Intelligent Analysis
540
216
  ```javascript
541
- // Analyze incidents with AI
542
- snow_analyze_incident({
543
- incident_id: "INC0010001",
544
- include_similar: true,
545
- suggest_resolution: true
217
+ // Every deployment is automatically tracked
218
+ await snow_update_set_add_artifact({
219
+ type: deployment.type,
220
+ sys_id: deployment.result.sys_id,
221
+ name: deployment.result.name
546
222
  });
547
223
 
548
- // Pattern analysis
549
- snow_pattern_analysis({
550
- analysis_type: "incident_patterns",
551
- timeframe: "month"
552
- });
224
+ console.log(`✅ Widget deployed: ${deployment.result.sys_id}`);
225
+ console.log(`📋 Tracked in Update Set: ${deployment.update_set_id}`);
553
226
  ```
554
227
 
555
- ## Flow Testing Guidelines
556
-
557
- ### Test Flow Hierarchy (use in this order):
558
- 1. **snow_test_flow_with_mock** - Always works, use for basic validation
559
- 2. **snow_get_by_sysid** - Verify flow exists before advanced testing
560
- 3. **snow_comprehensive_flow_test** - Only if above work (often 404)
228
+ ## 🎯 MCP Tool Reference (Use These ALWAYS!)
561
229
 
562
- ### Flow Creation Best Practices
563
- ❌ NEVER use snow_deploy_flow with manual JSON
564
- ✅ ALWAYS use snow_create_flow with natural language
565
- ✅ OR use snow_flow_wizard for step-by-step
566
-
567
- Example:
230
+ ### Core Deployment Tools
568
231
  ```javascript
569
- // BEST - Natural language with simplified deployment (v1.1.73+)
570
- snow_create_flow({
571
- instruction: "create approval flow for user provisioning",
572
- deploy_immediately: true
573
- })
232
+ // Universal deployment (replaces all old deploy_* tools)
233
+ snow_deploy({ type: "widget|flow|application", config: {...} })
574
234
 
575
- // ALTERNATIVE - Direct deployment with simplified API
576
- snow_deploy({
577
- type: "flow",
578
- instruction: "approval flow for user provisioning"
579
- })
580
-
581
- // OLD API (deprecated but still works with automatic redirection)
582
- // snow_deploy_flow() - shows deprecation warning, redirects to snow_deploy
583
- ```
235
+ // Smart artifact discovery
236
+ snow_find_artifact({ query: "natural language", type: "widget" })
237
+ snow_comprehensive_search({ query: "broader search" })
584
238
 
585
- ## ⚡ Performance Optimization
239
+ // Live connection testing
240
+ snow_validate_live_connection({ test_level: "permissions" })
586
241
 
587
- ### Parallel Execution Patterns
588
- ```javascript
589
- // Execute multiple searches concurrently
590
- Promise.all([
591
- snow_find_artifact({ query: "incident widget" }),
592
- snow_catalog_item_search({ query: "laptop" }),
593
- snow_query_incidents({ query: "priority=1" })
594
- ]);
242
+ // Update Set management (automatic in snow_deploy)
243
+ snow_smart_update_set({ auto_track_related_artifacts: true })
595
244
  ```
596
245
 
597
- ### Batch File Operations
246
+ ### Testing & Validation Tools
598
247
  ```javascript
599
- // Read multiple files in one operation
600
- MultiRead([
601
- "/path/to/widget.html",
602
- "/path/to/widget.css",
603
- "/path/to/widget.js"
604
- ]);
605
- ```
606
-
607
- ## 📝 Workflow Guidelines
608
-
609
- ### Standard Development Flow
610
- 1. **Discovery Phase**: Use search tools to find existing artifacts
611
- 2. **Planning Phase**: Use TodoWrite to plan all tasks
612
- 3. **Development Phase**: Launch agents concurrently
613
- 4. **Testing Phase**: Use mock testing tools
614
- 5. **Deployment Phase**: Use simplified snow_deploy with validation
615
-
616
- ### Error Recovery Patterns
617
- ```javascript
618
- // Always implement rollback strategies
619
- if (deployment.failed) {
620
- snow_deployment_rollback_manager({
621
- update_set_id: deployment.update_set,
622
- restore_point: deployment.backup_id
623
- });
624
- }
625
- ```
626
-
627
- ## 🔧 Advanced Configuration
628
-
629
- ## Build Commands
630
- - `npm run build`: Build the project
631
- - `npm run test`: Run the full test suite
632
- - `npm run lint`: Run ESLint and format checks
633
- - `npm run typecheck`: Run TypeScript type checking
634
-
635
- ## Snow-Flow Commands
636
- - `snow-flow init --sparc`: Initialize project with SPARC environment
637
- - `snow-flow auth login`: Authenticate with ServiceNow OAuth
638
- - `snow-flow swarm "<objective>"`: Start multi-agent swarm - één command voor alles!
639
- - `snow-flow sparc <mode> "<task>"`: Run specific SPARC mode
640
-
641
- ## Enhanced Swarm Command with Queen Agent Orchestration (v1.1.75+)
642
-
643
- ### 👑 Queen Agent Architecture
644
- The swarm command now uses Queen Agent orchestration, where a master coordinator spawns and manages specialized agents through Claude Code:
645
-
646
- ```bash
647
- # Simple usage - Queen Agent handles everything!
648
- snow-flow swarm "create incident management dashboard"
649
- ```
650
-
651
- ### What Happens:
652
- 1. **Memory Initialization**: SQLite-based swarm memory system starts
653
- 2. **Session Creation**: Unique session ID generated for tracking
654
- 3. **Queen Agent Launch**: Master coordinator analyzes objective
655
- 4. **Agent Spawning**: Specialized agents created via Task tool
656
- 5. **Memory Coordination**: Agents communicate through shared memory
657
- 6. **Progress Monitoring**: Real-time status updates via TodoWrite
658
-
659
- ### Default Settings (no flags needed):
660
- - ✅ `--smart-discovery` - Automatically discovers and reuses existing artifacts
661
- - ✅ `--live-testing` - Tests in real-time on your ServiceNow instance
662
- - ✅ `--auto-deploy` - Deploys automatically (safe with update sets)
663
- - ✅ `--auto-rollback` - Automatically rollbacks on failures
664
- - ✅ `--shared-memory` - All agents share context and coordination
665
- - ✅ `--progress-monitoring` - Real-time progress tracking
666
- - ❌ `--auto-permissions` - Disabled by default (enable with flag for automatic role elevation)
667
-
668
- ### Advanced Usage:
669
- ```bash
670
- # Enable automatic permission escalation
671
- snow-flow swarm "create global workflow" --auto-permissions
672
-
673
- # Disable specific features
674
- snow-flow swarm "test widget" --no-auto-deploy --no-live-testing
675
-
676
- # Full control with Queen Agent
677
- snow-flow swarm "complex integration" \
678
- --max-agents 8 \
679
- --strategy development \
680
- --mode hierarchical \
681
- --parallel \
682
- --auto-permissions
683
- ```
684
-
685
- ### Monitoring Swarm Progress:
686
- ```bash
687
- # Check status of a running swarm
688
- snow-flow swarm-status <sessionId>
248
+ // Test flows with mock data (safer than live testing)
249
+ snow_test_flow_with_mock({
250
+ flow_id: "approval_flow",
251
+ create_test_user: true,
252
+ cleanup_after_test: true
253
+ })
689
254
 
690
- # Continuously monitor progress
691
- snow-flow swarm-status <sessionId> --watch --interval 10
255
+ // Widget testing
256
+ snow_widget_test({
257
+ sys_id: "widget_sys_id",
258
+ test_scenarios: [...]
259
+ })
692
260
 
693
- # List recent swarm sessions
694
- snow-flow swarm-status
261
+ // Live deployment validation
262
+ snow_validate_deployment({ type: "widget", artifact: {...} })
695
263
  ```
696
264
 
697
- ### Queen Agent Memory Patterns:
698
- The Queen Agent uses these memory keys for coordination:
699
- - `swarm_session_<sessionId>` - Main session data
700
- - `agent_<type>_progress` - Individual agent progress
701
- - `agent_<type>_complete` - Agent completion status
702
- - `swarm_session_<sessionId>_results` - Final results
703
-
704
-
705
- ## New MCP Tools (v1.1.44+)
706
-
707
- ### Catalog Item Search
708
- Find catalog items with intelligent fuzzy matching:
265
+ ### Authentication & Recovery Tools
709
266
  ```javascript
710
- snow_catalog_item_search({
711
- query: "iPhone", // Will find iPhone 6S, iPhone 7, etc.
712
- fuzzy_match: true, // Enable intelligent variations
713
- include_variables: true // Include catalog variables
267
+ // Authentication diagnostics
268
+ snow_auth_diagnostics({
269
+ run_write_test: true,
270
+ include_recommendations: true
714
271
  })
715
- ```
716
272
 
717
- ### Flow Testing with Mock Data
718
- Test flows without real data:
719
- ```javascript
720
- snow_test_flow_with_mock({
721
- flow_id: "equipment_provisioning_flow",
722
- create_test_user: true, // Creates test user
723
- mock_catalog_items: true, // Creates test catalog items
724
- simulate_approvals: true, // Auto-approves during test
725
- cleanup_after_test: true // Removes test data after
273
+ // Permission escalation (when needed)
274
+ snow_escalate_permissions({
275
+ required_roles: ['admin'],
276
+ reason: 'Widget deployment requires admin access'
726
277
  })
727
278
  ```
728
279
 
729
- ### Direct Catalog-Flow Linking
730
- Link catalog items directly to flows:
731
- ```javascript
732
- snow_link_catalog_to_flow({
733
- catalog_item_id: "iPhone 6S",
734
- flow_id: "mobile_provisioning_flow",
735
- link_type: "flow_catalog_process", // Modern approach
736
- variable_mapping: [
737
- {
738
- catalog_variable: "phone_model",
739
- flow_input: "device_type"
740
- }
741
- ],
742
- test_link: true // Creates test request
743
- })
744
- ```
280
+ ## 🚨 Error Patterns & Recovery
745
281
 
746
- ### OAuth Configuration
747
- ```env
748
- # .env file
749
- SNOW_INSTANCE=dev123456
750
- SNOW_CLIENT_ID=your_oauth_client_id
751
- SNOW_CLIENT_SECRET=your_oauth_client_secret
752
- SNOW_USERNAME=admin
753
- SNOW_PASSWORD=admin_password
754
- ```
282
+ ### Common Errors & MCP Solutions
755
283
 
756
- ### Update Set Management
284
+ **Authentication Errors (401/403)**
757
285
  ```javascript
758
- // Smart update set creation
759
- snow_smart_update_set({
760
- name: "Auto-generated for widget development",
761
- detect_context: true, // Auto-detects what you're working on
762
- auto_switch: true // Switches when context changes
763
- });
764
- ```
765
-
766
- ## 🚀 NEW: Team-Based Agent Architecture (v1.1.62+)
767
-
768
- ### Specialized Development Teams
769
-
770
- Snow-Flow now uses specialized teams that mirror real software development teams, replacing monolithic agents with expert specialists:
771
-
772
- #### **Widget Development Team**
773
- ```bash
774
- # Complete widget development with specialized roles
775
- snow-flow sparc team widget "create incident dashboard with charts and filters"
776
- ```
777
-
778
- **Team Composition:**
779
- - 🎨 **Frontend Developer**: HTML templates, CSS styling, responsive design
780
- - ⚙️ **Backend Developer**: Server scripts, API calls, data processing
781
- - 🖼️ **UI/UX Designer**: User experience, design patterns, accessibility
782
- - 🔧 **ServiceNow Specialist**: Platform integration, best practices
783
- - 🧪 **QA Tester**: Widget testing, validation, edge cases
784
-
785
- #### **Flow Development Team**
786
- ```bash
787
- # Complete flow development with process experts
788
- snow-flow sparc team flow "build approval process for equipment requests"
789
- ```
790
-
791
- **Team Composition:**
792
- - 🔄 **Process Designer**: Business logic, workflow design
793
- - 🎯 **Trigger Specialist**: Event handling, conditions, automation
794
- - 📊 **Data Specialist**: Variables, transformations, integrations
795
- - 🔗 **Integration Expert**: APIs, external systems, data sync
796
- - 🛡️ **Security Reviewer**: Permissions, validation, compliance
797
-
798
- #### **Application Development Team**
799
- ```bash
800
- # Complete application development with enterprise specialists
801
- snow-flow sparc team app "create complete ITSM solution with custom tables"
802
- ```
803
-
804
- **Team Composition:**
805
- - 🏗️ **Database Designer**: Tables, relationships, indexes, performance
806
- - 🎯 **Business Logic Developer**: Rules, scripts, calculations
807
- - 🎨 **Interface Designer**: Forms, lists, UI components
808
- - 🔐 **Security Engineer**: ACLs, roles, access control
809
- - 📈 **Performance Optimizer**: Queries, caching, efficiency
810
-
811
- #### **Adaptive Team (Generic Scenario)**
812
- ```bash
813
- # For unknown/custom tasks - dynamically assembled specialists
814
- snow-flow sparc team adaptive "create integration between ServiceNow and external API"
815
- ```
816
-
817
- **Dynamic Assembly:**
818
- - 🤖 **Task Analyzer**: Understands requirements and assembles optimal team
819
- - 🔧 **Specialist Pool**: Data, Integration, Automation, Security, Reporting specialists
820
- - 📋 **Coordination Patterns**: Sequential, parallel, or hybrid execution
821
- - 🎯 **Quality Gates**: Validation checkpoints between specialist handoffs
822
-
823
- ### Team Coordination Features
824
-
825
- #### **Shared Memory System**
826
- Teams share context and communicate through intelligent memory:
827
- ```bash
828
- # Enable shared memory (default: true)
829
- snow-flow sparc team widget "dashboard" --shared-memory
830
- ```
831
-
832
- - **Context Sharing**: All specialists access shared requirements and progress
833
- - **Version Control**: Track changes and enable rollback if needed
834
- - **Real-time Updates**: Specialists notified when dependencies complete
835
-
836
- #### **Quality Gates**
837
- Automated validation between specialist handoffs:
838
- ```bash
839
- # Enable validation gates (recommended)
840
- snow-flow sparc team flow "approval" --validation
841
- ```
842
-
843
- **Quality Gate Types:**
844
- - **Code Quality**: Syntax, standards, best practices
845
- - **Security Review**: Vulnerability scanning, access controls
846
- - **Performance Check**: Query optimization, response times
847
- - **Accessibility**: WCAG compliance, usability testing
848
-
849
- #### **Execution Patterns**
850
- Teams automatically select optimal coordination:
851
-
852
- **Sequential Pattern** (Dependencies):
853
- ```
854
- Architecture → Database → Business Logic → Interface → Testing
286
+ if (error.status === 401 || error.status === 403) {
287
+ const diagnostics = await snow_auth_diagnostics();
288
+ if (!diagnostics.oauth_configured) {
289
+ return "Run: snow-flow auth login";
290
+ }
291
+ if (diagnostics.token_expired) {
292
+ return "Token expired - please re-authenticate";
293
+ }
294
+ }
855
295
  ```
856
296
 
857
- **Parallel Pattern** (Independent work):
858
- ```
859
- Frontend ⟷ Backend ⟷ Security ⟷ Testing (simultaneously)
297
+ **Permission Errors**
298
+ ```javascript
299
+ if (error.includes('insufficient privileges')) {
300
+ await snow_escalate_permissions({
301
+ required_roles: ['admin', 'app_creator'],
302
+ workflow_context: 'ServiceNow widget development'
303
+ });
304
+ }
860
305
  ```
861
306
 
862
- **Hybrid Pattern** (Optimized):
863
- ```
864
- Phase 1: Architecture (sequential)
865
- Phase 2: Frontend + Backend + Security (parallel)
866
- Phase 3: Integration + Testing (sequential)
307
+ **Deployment Conflicts**
308
+ ```javascript
309
+ if (error.includes('already exists')) {
310
+ const existing = await snow_find_artifact({
311
+ query: config.name,
312
+ type: config.type
313
+ });
314
+
315
+ return `
316
+ 🔍 Artifact exists: ${existing.name} (${existing.sys_id})
317
+ Options:
318
+ 1. Update existing: snow_edit_by_sysid()
319
+ 2. Create with different name
320
+ 3. Use existing as-is
321
+ `;
322
+ }
867
323
  ```
868
324
 
869
- ### Individual Specialist Modes
870
-
871
- Access specific specialists directly for focused tasks:
325
+ ## 📋 Quick Start Workflows
872
326
 
327
+ ### 🚀 Widget Development (MCP-First)
873
328
  ```bash
874
- # Frontend specialist
875
- snow-flow sparc frontend "optimize widget responsiveness for mobile"
329
+ # 1. Authentication check (automatic in Swarm)
330
+ snow-flow swarm "create incident dashboard widget"
876
331
 
877
- # Backend specialist
878
- snow-flow sparc backend "optimize database queries for performance"
879
-
880
- # Security specialist
881
- snow-flow sparc security "review application access controls"
882
-
883
- # Data specialist
884
- snow-flow sparc data "design table relationships for ITSM"
885
-
886
- # Integration specialist
887
- snow-flow sparc integration "create REST API for external system"
888
- ```
889
-
890
- ### Team Command Options
891
-
892
- ```bash
893
- # Basic team execution
894
- snow-flow sparc team widget "create dashboard"
895
-
896
- # Advanced coordination options
897
- snow-flow sparc team widget "dashboard" \
898
- --parallel \ # Enable parallel execution
899
- --monitor \ # Real-time progress monitoring
900
- --shared-memory \ # Enable context sharing (default: true)
901
- --validation \ # Enable quality gates (recommended)
902
- --dry-run # Preview team assembly and plan
903
-
904
- # Specialist-specific options
905
- snow-flow sparc frontend "template" \
906
- --responsive \ # Focus on mobile responsiveness
907
- --accessibility # WCAG compliance focus
332
+ # Manual MCP workflow (what happens internally):
333
+ # snow_validate_live_connection() → snow_find_artifact() → snow_deploy() → snow_update_set_add_artifact()
908
334
  ```
909
335
 
910
- ### Team vs Individual Agent Comparison
911
-
912
- | Scenario | Old Approach | New Team Approach |
913
- |----------|-------------|-------------------|
914
- | **Widget Creation** | Single agent does everything | Frontend + Backend + UI/UX + Platform specialists |
915
- | **Flow Development** | Flow agent handles all aspects | Process + Trigger + Data + Security specialists |
916
- | **Complex Integration** | Generic coder attempts everything | Adaptive team assembles: Integration + Data + Security + Testing |
917
- | **Quality Assurance** | No systematic validation | Quality gates between each specialist handoff |
918
- | **Knowledge Sharing** | Isolated agent knowledge | Shared memory with version control |
919
-
920
- ### Best Practices for Team Usage
921
-
922
- #### **When to Use Teams vs Individual Agents**
923
-
924
- **✅ Use Teams For:**
925
- - Complete widget/flow/application development
926
- - Complex multi-component tasks
927
- - Production-quality deliverables
928
- - When you need multiple expertise areas
929
-
336
+ ### 🔄 Flow Development (MCP-First)
930
337
  ```bash
931
- # Good: Complete solution
932
- snow-flow sparc team widget "create executive dashboard with KPIs"
338
+ # Swarm handles all MCP orchestration with multiple agents
339
+ snow-flow swarm "create approval workflow for equipment requests"
933
340
 
934
- # Good: Complex process
935
- snow-flow sparc team flow "multi-step approval with integrations"
341
+ # What happens: snow_create_flow() → snow_test_flow_with_mock() → multi-agent validation → auto tracking
936
342
  ```
937
343
 
938
- **✅ Use Individual Specialists For:**
939
- - Focused single-component tasks
940
- - Quick fixes or optimizations
941
- - Specific expertise needed
942
- - Learning/exploration
943
-
344
+ ### 🎯 Smart Discovery Before Creation
944
345
  ```bash
945
- # Good: Focused task
946
- snow-flow sparc frontend "fix mobile responsiveness issue"
947
-
948
- # Good: Specific expertise
949
- snow-flow sparc security "review permissions for table X"
950
- ```
951
-
952
- #### **Team Coordination Guidelines**
346
+ # Always check first!
347
+ snow-flow swarm "find existing incident widgets and create improved version"
953
348
 
954
- 1. **Let the Architect Lead**: Team coordinators (architects) analyze requirements and manage specialists
955
- 2. **Enable Shared Memory**: Always use `--shared-memory` for complex tasks
956
- 3. **Use Quality Gates**: Enable `--validation` for production deployments
957
- 4. **Monitor Progress**: Use `--monitor` for long-running team tasks
958
- 5. **Dry Run First**: Use `--dry-run` to preview team assembly for complex tasks
959
-
960
- #### **Error Handling and Recovery**
961
-
962
- Teams include automatic error recovery:
963
- - **Quality Gate Failures**: Automatic retry with specialist feedback
964
- - **Specialist Errors**: Fallback to alternative approaches
965
- - **Dependency Issues**: Intelligent rescheduling and re-coordination
966
- - **Shared Memory Conflicts**: Version control and conflict resolution
967
-
968
- ### Migration from Old Agent System
969
-
970
- **Old Command → New Team Command:**
971
- ```bash
972
- # Old: Monolithic approach
973
- snow-flow sparc coder "create widget"
974
- # New: Specialized team
975
- snow-flow sparc team widget "create widget"
976
-
977
- # Old: Generic development
978
- snow-flow sparc designer "create flow"
979
- # New: Process-focused team
980
- snow-flow sparc team flow "create flow"
981
-
982
- # Old: Single agent application
983
- snow-flow sparc architect "design app"
984
- # New: Full development team
985
- snow-flow sparc team app "design app"
349
+ # Uses: snow_comprehensive_search() → swarm analysis → smart reuse recommendations
986
350
  ```
987
351
 
988
- **Backward Compatibility:**
989
- - All existing individual SPARC modes still work
990
- - Old commands automatically suggest team alternatives
991
- - Gradual migration path available
352
+ ## 🔧 Build Commands & Testing
353
+ - `npm run build`: Build project
354
+ - `npm run test`: Run test suite
355
+ - `npm run lint`: Code quality checks
356
+ - `npm run typecheck`: TypeScript validation
357
+ - `snow-flow auth login`: ServiceNow authentication
358
+ - `snow-flow status`: System health check
992
359
 
993
- ## 🎯 Quick Start Workflows
360
+ ## 💡 Important Development Rules
994
361
 
995
- ### 🚀 Advanced Development Approaches
362
+ ### ✅ DO THESE ALWAYS:
363
+ - ✅ **Start with MCP tools** - `snow_validate_live_connection()` first
364
+ - ✅ **Use discovery** - `snow_find_artifact()` before creating
365
+ - ✅ **Deploy real artifacts** - `snow_deploy()` to ServiceNow
366
+ - ✅ **Track everything** - Automatic in `snow_deploy()` with `auto_update_set: true`
367
+ - ✅ **Test with mock data** - `snow_test_flow_with_mock()` for safety
996
368
 
997
- #### Team-Based Development (v1.1.62+)
369
+ ### ❌ NEVER DO THESE:
370
+ - ❌ **Create local files** without MCP check first
371
+ - ❌ **Generate mock sys_ids** instead of real deployment
372
+ - ❌ **Skip authentication** validation
373
+ - ❌ **Work offline** when ServiceNow is available
374
+ - ❌ **Ignore discovery** results
998
375
 
999
- ```bash
1000
- # Widget Development Team
1001
- snow-flow sparc team widget "create incident dashboard"
376
+ ## 🚀 System Architecture
1002
377
 
1003
- # Flow Development Team
1004
- snow-flow sparc team flow "build approval workflow"
378
+ Snow-flow is built on **MCP-native architecture**:
1005
379
 
1006
- # Application Development Team
1007
- snow-flow sparc team app "create ITSM solution"
380
+ 1. **BaseMCPServer Pattern**: All 11 MCP servers use consistent error handling
381
+ 2. **MCPExecutionBridge**: Queen Agent uses real MCP tools, not mocks
382
+ 3. **Smart Update Sets**: Automatic artifact tracking and management
383
+ 4. **Authentication-First**: Every operation validates ServiceNow access
384
+ 5. **Discovery-Driven**: Prevent duplication through intelligent search
1008
385
 
1009
- # Adaptive Team (for custom/unknown tasks)
1010
- snow-flow sparc team adaptive "create complex integration"
386
+ ---
1011
387
 
1012
- # Individual Specialists
1013
- snow-flow sparc frontend "mobile responsiveness"
1014
- snow-flow sparc backend "API optimization"
1015
- snow-flow sparc security "access control review"
1016
- ```
388
+ **Remember: Snow-flow's value is REAL ServiceNow integration. Always use `snow-flow swarm` with MCP tools first!** 🚀
1017
389
 
1018
- ### 🎯 Quick Start Comparison
390
+ ## 🎯 PRIMARY COMMAND: snow-flow swarm
1019
391
 
1020
- #### **👑 RECOMMENDED: Queen Agent (Primary)**
1021
- ```bash
1022
- # 1-3: Same setup
1023
- # 4. Queen does everything automatically!
1024
- snow-flow queen "create incident management widget"
1025
- ```
392
+ **The `swarm` command is your main interface - it orchestrates everything MCP-first:**
1026
393
 
1027
- #### **🤖 Alternative: Enhanced Swarm**
1028
394
  ```bash
1029
- # 4. Use Queen intelligence with swarm
1030
- snow-flow swarm "create widget" --queen
1031
- ```
395
+ # ✅ PRIMARY INTERFACE - Use this!
396
+ snow-flow swarm "create incident dashboard widget"
397
+ snow-flow swarm "build approval workflow for equipment requests"
398
+ snow-flow swarm "deploy mobile-responsive widget with accessibility features"
1032
399
 
1033
- #### **⚙️ Traditional: Team-Based**
1034
- ```bash
1035
- # 4. Manual team coordination
1036
- snow-flow sparc team widget "create dashboard"
400
+ # ✅ All swarm operations automatically include:
401
+ # 1. snow_validate_live_connection() - Auth check
402
+ # 2. snow_comprehensive_search() - Smart discovery
403
+ # 3. snow_deploy() - Real ServiceNow deployment
404
+ # 4. snow_update_set_add_artifact() - Automatic tracking
1037
405
  ```
1038
406
 
1039
- ## 💡 Important Notes
1040
-
1041
- ### Do's
1042
- - ✅ Use TodoWrite extensively for task tracking
1043
- - ✅ Batch MCP tool calls for performance
1044
- - ✅ Store important data in Memory for coordination
1045
- - ✅ Test with mock data before deploying
1046
- - ✅ Work within Update Sets for safety
1047
- - ✅ Use fuzzy search for finding artifacts
1048
- - ✅ Write out code thats important for the whole objective to work
1049
-
1050
- ### Don'ts
1051
- - ❌ Don't make sequential tool calls when batch is possible
1052
- - ❌ Don't hardcode credentials or sys_ids
1053
- - ❌ Don't deploy without testing
1054
- - ❌ Don't ignore OAuth permission errors
1055
- - ❌ Don't create artifacts without checking if they exist
1056
- - ❌ Don't use mock data or placeholder code
1057
-
1058
- ## 🚀 Performance Benchmarks
1059
-
1060
- With concurrent execution and batch operations:
1061
- - **Widget Development**: 3x faster than sequential
1062
- - **Flow Creation**: 2.5x faster with parallel validation
1063
- - **Bulk Deployment**: Up to 5x faster with parallel mode
1064
- - **Search Operations**: 4x faster with concurrent queries
1065
-
1066
- ---
1067
-
1068
- ## 📚 Advanced Reference (MCP Tools & Traditional Approaches)
1069
-
1070
- *Note: The sections below contain advanced MCP tools and traditional approaches. For most users, the Queen Agent above is the recommended primary interface.*
1071
-
1072
- ### MCP Server Documentation
1073
- - **servicenow-deployment**: Widget, flow, and application deployment
1074
- - **servicenow-intelligent**: Smart search and artifact discovery
1075
- - **servicenow-operations**: Incident management and catalog operations
1076
- - **servicenow-flow-composer**: Natural language flow creation
1077
- - **servicenow-platform-development**: Scripts, rules, and policies
1078
-
1079
- ### SPARC Modes
1080
-
1081
- #### **Individual SPARC Modes**
1082
- - `orchestrator`: Coordinates complex multi-step tasks
1083
- - `coder`: Focused code implementation
1084
- - `researcher`: Deep analysis and discovery
1085
- - `tester`: Comprehensive testing strategies
1086
- - `architect`: System design and architecture
1087
-
1088
- #### **Team SPARC Modes (v1.1.62+)**
1089
- - `team widget`: Widget development with Frontend + Backend + UI/UX + Platform + QA specialists
1090
- - `team flow`: Flow development with Process + Trigger + Data + Integration + Security specialists
1091
- - `team app`: Application development with Database + Business Logic + Interface + Security + Performance specialists
1092
- - `team adaptive`: Dynamic team assembly based on task requirements
1093
-
1094
- #### **Individual Specialist Modes (v1.1.62+)**
1095
- - `frontend`: HTML templates, CSS styling, responsive design
1096
- - `backend`: Server scripts, API calls, data processing, performance optimization
1097
- - `security`: Access controls, permissions, vulnerability assessment, compliance review
1098
- - `data`: Database design, table relationships, data transformations
1099
- - `integration`: APIs, external systems, data synchronization
1100
-
1101
- ---
1102
-
1103
- *This configuration ensures optimal use of Claude Code's batch tools for Snow-Flow ServiceNow development with maximum efficiency and safety.*
407
+ **Every swarm operation is MCP-native and ServiceNow-first!** 🐝