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/dist/cli.js CHANGED
@@ -1747,6 +1747,799 @@ This mode provides specialized ${mode} capabilities for ServiceNow development p
1747
1747
  `;
1748
1748
  await fs_1.promises.writeFile((0, path_1.join)(targetDir, `.claude/commands/sparc/${mode}.md`), content);
1749
1749
  }
1750
+ // Create additional swarm documentation files
1751
+ console.log('📋 Creating swarm patterns documentation...');
1752
+ // Create swarm-patterns.md
1753
+ const swarmPatternsContent = `# Swarm Command Patterns - MCP-FIRST Workflow
1754
+
1755
+ ## 🎯 Primary Interface: snow-flow swarm
1756
+
1757
+ The swarm command is your primary interface for ServiceNow development. It uses the Queen Agent backend to orchestrate multiple specialized agents through Claude Code.
1758
+
1759
+ ## Basic Widget Creation
1760
+ \`\`\`bash
1761
+ snow-flow swarm "create incident dashboard widget"
1762
+ snow-flow swarm "build responsive widget with Chart.js for incident analytics"
1763
+ snow-flow swarm "create service portal widget for hardware requests"
1764
+ \`\`\`
1765
+
1766
+ ## Flow Development
1767
+ \`\`\`bash
1768
+ snow-flow swarm "create approval workflow for equipment requests"
1769
+ snow-flow swarm "build multi-step approval flow with email notifications"
1770
+ snow-flow swarm "create automated incident escalation workflow"
1771
+ \`\`\`
1772
+
1773
+ ## Complex Integration
1774
+ \`\`\`bash
1775
+ snow-flow swarm "integrate ServiceNow with Slack notifications"
1776
+ snow-flow swarm "create REST API integration with external ticketing system"
1777
+ snow-flow swarm "build bi-directional sync with Microsoft Teams"
1778
+ \`\`\`
1779
+
1780
+ ## Testing Patterns
1781
+ \`\`\`bash
1782
+ snow-flow swarm "test existing flows and create comprehensive test report"
1783
+ snow-flow swarm "validate all widgets in service portal for mobile responsiveness"
1784
+ snow-flow swarm "performance test catalog item workflows"
1785
+ \`\`\`
1786
+
1787
+ ## Application Development
1788
+ \`\`\`bash
1789
+ snow-flow swarm "create complete ITSM solution with custom tables"
1790
+ snow-flow swarm "build employee onboarding application with approval flows"
1791
+ snow-flow swarm "develop asset management system with automated workflows"
1792
+ \`\`\`
1793
+
1794
+ ## Advanced Patterns with Options
1795
+
1796
+ ### Disable Auto-Deploy for Testing
1797
+ \`\`\`bash
1798
+ snow-flow swarm "test new widget locally" --no-auto-deploy --no-live-testing
1799
+ \`\`\`
1800
+
1801
+ ### Enable Permission Escalation
1802
+ \`\`\`bash
1803
+ snow-flow swarm "create global enterprise workflow" --auto-permissions
1804
+ \`\`\`
1805
+
1806
+ ### Parallel Execution for Large Projects
1807
+ \`\`\`bash
1808
+ snow-flow swarm "migrate 50 workflows from legacy system" --parallel --max-agents 8
1809
+ \`\`\`
1810
+
1811
+ ### Monitor Real-Time Progress
1812
+ \`\`\`bash
1813
+ snow-flow swarm "complex ITSM implementation" --monitor
1814
+ \`\`\`
1815
+
1816
+ ## 🔐 MCP-FIRST Workflow
1817
+
1818
+ Every swarm command follows this mandatory workflow:
1819
+
1820
+ 1. **Authentication Check**: Validates ServiceNow OAuth credentials
1821
+ 2. **Smart Discovery**: Finds existing artifacts to prevent duplication
1822
+ 3. **Live Development**: Creates real artifacts in ServiceNow
1823
+ 4. **Update Set Tracking**: All changes tracked for deployment
1824
+
1825
+ ## 💡 Best Practices
1826
+
1827
+ - Start simple: Let the Queen Agent determine complexity
1828
+ - Use natural language: Describe what you want, not how to build it
1829
+ - Trust the defaults: Intelligent features are enabled automatically
1830
+ - Monitor progress: Use --monitor for long-running tasks
1831
+
1832
+ ## 🎯 Common Success Patterns
1833
+
1834
+ ### Pattern 1: Quick Widget
1835
+ \`\`\`bash
1836
+ snow-flow swarm "simple dashboard widget"
1837
+ # Queen Agent will:
1838
+ # - Spawn widget-creator agent
1839
+ # - Create HTML/CSS/JS
1840
+ # - Deploy to ServiceNow
1841
+ # - Test automatically
1842
+ \`\`\`
1843
+
1844
+ ### Pattern 2: Complex Flow
1845
+ \`\`\`bash
1846
+ snow-flow swarm "multi-department approval workflow with dynamic routing"
1847
+ # Queen Agent will:
1848
+ # - Spawn flow-builder, tester, and security agents
1849
+ # - Design flow architecture
1850
+ # - Implement with conditions
1851
+ # - Test all paths
1852
+ # - Validate permissions
1853
+ \`\`\`
1854
+
1855
+ ### Pattern 3: Full Application
1856
+ \`\`\`bash
1857
+ snow-flow swarm "complete HR onboarding system"
1858
+ # Queen Agent will:
1859
+ # - Spawn app-architect, flow-builder, widget-creator, tester
1860
+ # - Design data model
1861
+ # - Create tables and relationships
1862
+ # - Build UI components
1863
+ # - Implement workflows
1864
+ # - Test end-to-end
1865
+ \`\`\`
1866
+ `;
1867
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.claude/commands/swarm-patterns.md'), swarmPatternsContent);
1868
+ // Create agent-types.md
1869
+ const agentTypesContent = `# Agent Types and Specializations
1870
+
1871
+ ## 🤖 Primary Development Agents
1872
+
1873
+ ### widget-creator
1874
+ **Specialization**: Service Portal widgets, HTML/CSS/JS, responsive design
1875
+ **When spawned**: Any widget-related objective
1876
+ **Key capabilities**:
1877
+ - HTML template generation
1878
+ - CSS styling and animations
1879
+ - Client-side JavaScript controllers
1880
+ - Server-side data scripts
1881
+ - Chart.js and data visualization
1882
+ - Mobile responsiveness
1883
+
1884
+ ### flow-builder
1885
+ **Specialization**: Flow Designer, process automation, approvals
1886
+ **When spawned**: Workflow and automation objectives
1887
+ **Key capabilities**:
1888
+ - Trigger configuration
1889
+ - Conditional logic
1890
+ - Approval routing
1891
+ - Email notifications
1892
+ - Integration with catalog items
1893
+ - Subflow creation
1894
+
1895
+ ### script-writer
1896
+ **Specialization**: Business rules, script includes, client scripts
1897
+ **When spawned**: Scripting and automation objectives
1898
+ **Key capabilities**:
1899
+ - GlideRecord operations
1900
+ - Business rule creation
1901
+ - Script include development
1902
+ - Background scripts
1903
+ - Fix scripts
1904
+ - Scheduled jobs
1905
+
1906
+ ### app-architect
1907
+ **Specialization**: Application design, data modeling, system architecture
1908
+ **When spawned**: Full application development
1909
+ **Key capabilities**:
1910
+ - Table design and relationships
1911
+ - Application scoping
1912
+ - Security model design
1913
+ - Integration architecture
1914
+ - Performance optimization
1915
+ - Scalability planning
1916
+
1917
+ ## 🛠️ Supporting Agents
1918
+
1919
+ ### researcher
1920
+ **Specialization**: Discovery, best practices, documentation
1921
+ **When spawned**: Complex or unknown requirements
1922
+ **Key capabilities**:
1923
+ - ServiceNow best practices
1924
+ - Platform feature discovery
1925
+ - Existing artifact analysis
1926
+ - Documentation generation
1927
+ - Knowledge base creation
1928
+
1929
+ ### tester
1930
+ **Specialization**: Quality assurance, validation, performance testing
1931
+ **When spawned**: After any development task
1932
+ **Key capabilities**:
1933
+ - Unit test creation
1934
+ - Integration testing
1935
+ - UI/UX validation
1936
+ - Performance benchmarking
1937
+ - Security testing
1938
+ - Accessibility compliance
1939
+
1940
+ ### security
1941
+ **Specialization**: Access controls, compliance, vulnerability assessment
1942
+ **When spawned**: Enterprise or sensitive applications
1943
+ **Key capabilities**:
1944
+ - ACL configuration
1945
+ - Role management
1946
+ - Data encryption
1947
+ - Compliance validation
1948
+ - Security scanning
1949
+ - Audit trail setup
1950
+
1951
+ ### ui-designer
1952
+ **Specialization**: User experience, design patterns, accessibility
1953
+ **When spawned**: Complex UI requirements
1954
+ **Key capabilities**:
1955
+ - Design system implementation
1956
+ - Accessibility (WCAG) compliance
1957
+ - Responsive layouts
1958
+ - User journey mapping
1959
+ - Style guide creation
1960
+
1961
+ ## 🎯 How Agents are Selected
1962
+
1963
+ The Queen Agent analyzes your objective and automatically selects the optimal team:
1964
+
1965
+ ### Example 1: "create incident dashboard"
1966
+ - **Primary**: widget-creator
1967
+ - **Supporting**: ui-designer, tester
1968
+ - **Reasoning**: Widget development with UI focus
1969
+
1970
+ ### Example 2: "build approval workflow"
1971
+ - **Primary**: flow-builder
1972
+ - **Supporting**: security, tester
1973
+ - **Reasoning**: Process automation with security needs
1974
+
1975
+ ### Example 3: "create ITSM application"
1976
+ - **Primary**: app-architect
1977
+ - **Supporting**: flow-builder, widget-creator, security, tester
1978
+ - **Reasoning**: Full application requiring all capabilities
1979
+
1980
+ ## 💡 Agent Coordination Patterns
1981
+
1982
+ ### Sequential Coordination
1983
+ Used when tasks have dependencies:
1984
+ \`\`\`
1985
+ app-architect → widget-creator → flow-builder → tester
1986
+ \`\`\`
1987
+
1988
+ ### Parallel Coordination
1989
+ Used when tasks are independent:
1990
+ \`\`\`
1991
+ widget-creator ⟷ flow-builder ⟷ script-writer
1992
+ ↓ ↓ ↓
1993
+ tester
1994
+ \`\`\`
1995
+
1996
+ ### Hybrid Coordination
1997
+ Used for complex projects:
1998
+ \`\`\`
1999
+ Phase 1: app-architect (solo)
2000
+ Phase 2: widget-creator + flow-builder (parallel)
2001
+ Phase 3: security + tester (parallel)
2002
+ Phase 4: Final integration (sequential)
2003
+ \`\`\`
2004
+
2005
+ ## 🔧 Manual Agent Control
2006
+
2007
+ While the Queen Agent handles selection automatically, you can influence agent selection:
2008
+
2009
+ ### Request Specific Expertise
2010
+ \`\`\`bash
2011
+ snow-flow swarm "create widget with heavy security focus"
2012
+ # Queen will prioritize security agent
2013
+ \`\`\`
2014
+
2015
+ ### Exclude Certain Agents
2016
+ \`\`\`bash
2017
+ snow-flow swarm "simple widget" --max-agents 2
2018
+ # Queen will use only essential agents
2019
+ \`\`\`
2020
+
2021
+ ### Force Comprehensive Team
2022
+ \`\`\`bash
2023
+ snow-flow swarm "production-ready incident system" --max-agents 8
2024
+ # Queen will assemble full team with all specialists
2025
+ \`\`\`
2026
+ `;
2027
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.claude/commands/agent-types.md'), agentTypesContent);
2028
+ // Create mcp-tools-quick-ref.md
2029
+ const mcpToolsContent = `# MCP Tools Quick Reference
2030
+
2031
+ ## 🔐 Authentication & Connection
2032
+
2033
+ ### snow_validate_live_connection
2034
+ \`\`\`javascript
2035
+ snow_validate_live_connection({
2036
+ test_level: "permissions" // basic, full, permissions
2037
+ })
2038
+ \`\`\`
2039
+ **Use for**: Checking ServiceNow connection and OAuth status
2040
+
2041
+ ### snow_auth_diagnostics
2042
+ \`\`\`javascript
2043
+ snow_auth_diagnostics({
2044
+ include_recommendations: true,
2045
+ run_write_test: true
2046
+ })
2047
+ \`\`\`
2048
+ **Use for**: Debugging authentication issues
2049
+
2050
+ ## 🔍 Discovery & Search
2051
+
2052
+ ### snow_find_artifact
2053
+ \`\`\`javascript
2054
+ snow_find_artifact({
2055
+ query: "incident dashboard widget",
2056
+ type: "widget" // widget, flow, script, application, any
2057
+ })
2058
+ \`\`\`
2059
+ **Use for**: Finding existing ServiceNow artifacts with natural language
2060
+
2061
+ ### snow_catalog_item_search
2062
+ \`\`\`javascript
2063
+ snow_catalog_item_search({
2064
+ query: "laptop",
2065
+ fuzzy_match: true,
2066
+ include_variables: true
2067
+ })
2068
+ \`\`\`
2069
+ **Use for**: Finding catalog items with intelligent matching
2070
+
2071
+ ### snow_get_by_sysid
2072
+ \`\`\`javascript
2073
+ snow_get_by_sysid({
2074
+ sys_id: "abc123...",
2075
+ table: "sp_widget"
2076
+ })
2077
+ \`\`\`
2078
+ **Use for**: Direct lookup when you have the sys_id
2079
+
2080
+ ## 🚀 Deployment Tools
2081
+
2082
+ ### snow_deploy (Universal - v1.1.73+)
2083
+ \`\`\`javascript
2084
+ snow_deploy({
2085
+ type: "widget", // widget, flow, application, script, batch
2086
+ config: {
2087
+ name: "incident_dashboard",
2088
+ title: "Incident Dashboard",
2089
+ template: htmlContent,
2090
+ css: cssContent,
2091
+ client_script: clientJS,
2092
+ server_script: serverJS
2093
+ },
2094
+ auto_update_set: true
2095
+ })
2096
+ \`\`\`
2097
+ **Use for**: All deployments - replaces individual deploy tools
2098
+
2099
+ ## 🔄 Flow Development
2100
+
2101
+ ### snow_create_flow
2102
+ \`\`\`javascript
2103
+ snow_create_flow({
2104
+ instruction: "create approval flow for purchases over $1000",
2105
+ deploy_immediately: true,
2106
+ enable_intelligent_analysis: true
2107
+ })
2108
+ \`\`\`
2109
+ **Use for**: Creating flows from natural language
2110
+
2111
+ ### snow_test_flow_with_mock
2112
+ \`\`\`javascript
2113
+ snow_test_flow_with_mock({
2114
+ flow_id: "equipment_approval",
2115
+ create_test_user: true,
2116
+ mock_catalog_items: true,
2117
+ simulate_approvals: true,
2118
+ cleanup_after_test: true
2119
+ })
2120
+ \`\`\`
2121
+ **Use for**: Testing flows without affecting real data
2122
+
2123
+ ### snow_link_catalog_to_flow
2124
+ \`\`\`javascript
2125
+ snow_link_catalog_to_flow({
2126
+ catalog_item_id: "New Laptop",
2127
+ flow_id: "laptop_provisioning",
2128
+ variable_mapping: [{
2129
+ catalog_variable: "model",
2130
+ flow_input: "equipment_type"
2131
+ }]
2132
+ })
2133
+ \`\`\`
2134
+ **Use for**: Connecting catalog items to flows
2135
+
2136
+ ## 📦 Update Set Management
2137
+
2138
+ ### snow_update_set_create
2139
+ \`\`\`javascript
2140
+ snow_update_set_create({
2141
+ name: "Widget Development - Jan 2024",
2142
+ description: "Dashboard widgets for incident management",
2143
+ auto_switch: true
2144
+ })
2145
+ \`\`\`
2146
+ **Use for**: Creating new update sets
2147
+
2148
+ ### snow_update_set_add_artifact
2149
+ \`\`\`javascript
2150
+ snow_update_set_add_artifact({
2151
+ type: "widget",
2152
+ sys_id: "abc123...",
2153
+ name: "incident_dashboard"
2154
+ })
2155
+ \`\`\`
2156
+ **Use for**: Tracking artifacts in update sets
2157
+
2158
+ ### snow_smart_update_set
2159
+ \`\`\`javascript
2160
+ snow_smart_update_set({
2161
+ detect_context: true,
2162
+ separate_by_task: true,
2163
+ close_previous: true
2164
+ })
2165
+ \`\`\`
2166
+ **Use for**: Automatic update set management
2167
+
2168
+ ## 🧪 Testing Tools
2169
+
2170
+ ### snow_widget_test
2171
+ \`\`\`javascript
2172
+ snow_widget_test({
2173
+ sys_id: "widget_sys_id",
2174
+ test_scenarios: [{
2175
+ name: "No data test",
2176
+ input: { incidents: [] },
2177
+ expected: { message: "No incidents found" }
2178
+ }],
2179
+ validate_dependencies: true
2180
+ })
2181
+ \`\`\`
2182
+ **Use for**: Widget functionality testing
2183
+
2184
+ ### snow_comprehensive_flow_test
2185
+ \`\`\`javascript
2186
+ snow_comprehensive_flow_test({
2187
+ flow_sys_id: "flow_id",
2188
+ test_data_generation: "automatic",
2189
+ edge_case_detection: true,
2190
+ performance_validation: true
2191
+ })
2192
+ \`\`\`
2193
+ **Use for**: Comprehensive flow testing
2194
+
2195
+ ## 🔄 Batch Operations
2196
+
2197
+ ### Parallel Tool Execution
2198
+ \`\`\`javascript
2199
+ // Execute multiple operations in one message
2200
+ Promise.all([
2201
+ snow_find_artifact({ query: "widget" }),
2202
+ snow_catalog_item_search({ query: "laptop" }),
2203
+ snow_update_set_current()
2204
+ ])
2205
+ \`\`\`
2206
+ **Use for**: Maximum performance with concurrent operations
2207
+
2208
+ ## 💡 Common Patterns
2209
+
2210
+ ### Pre-flight Check Pattern
2211
+ \`\`\`javascript
2212
+ // Always start with authentication
2213
+ const auth = await snow_validate_live_connection();
2214
+ if (!auth.success) {
2215
+ // Switch to planning mode
2216
+ return "Run: snow-flow auth login";
2217
+ }
2218
+
2219
+ // Then discover existing artifacts
2220
+ const existing = await snow_find_artifact({
2221
+ query: "similar to what I want to create"
2222
+ });
2223
+
2224
+ // Finally deploy new artifact
2225
+ const result = await snow_deploy({
2226
+ type: "widget",
2227
+ config: widgetConfig
2228
+ });
2229
+ \`\`\`
2230
+
2231
+ ### Error Recovery Pattern
2232
+ \`\`\`javascript
2233
+ try {
2234
+ await snow_deploy({ type: "flow", config });
2235
+ } catch (error) {
2236
+ if (error.includes("permissions")) {
2237
+ // Try global scope
2238
+ await snow_escalate_permissions();
2239
+ } else if (error.includes("validation")) {
2240
+ // Create manual deployment guide
2241
+ await snow_create_manual_guide();
2242
+ }
2243
+ }
2244
+ \`\`\`
2245
+
2246
+ ### Update Set Pattern
2247
+ \`\`\`javascript
2248
+ // Ensure update set exists
2249
+ await snow_smart_update_set();
2250
+
2251
+ // Deploy artifact
2252
+ const artifact = await snow_deploy({ type: "widget", config });
2253
+
2254
+ // Track in update set
2255
+ await snow_update_set_add_artifact({
2256
+ type: "widget",
2257
+ sys_id: artifact.sys_id,
2258
+ name: artifact.name
2259
+ });
2260
+ \`\`\`
2261
+ `;
2262
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, '.claude/commands/mcp-tools-quick-ref.md'), mcpToolsContent);
2263
+ // Create examples directory
2264
+ await fs_1.promises.mkdir((0, path_1.join)(targetDir, 'examples'), { recursive: true });
2265
+ // Create memory patterns directory and sample patterns
2266
+ await fs_1.promises.mkdir((0, path_1.join)(targetDir, 'memory/patterns'), { recursive: true });
2267
+ const successfulPatternsContent = {
2268
+ patterns: [
2269
+ {
2270
+ objective: "create incident dashboard widget",
2271
+ agents: ["widget-creator", "ui-designer", "tester"],
2272
+ mcpTools: ["snow_deploy", "snow_widget_test", "snow_preview_widget"],
2273
+ successRate: 0.95,
2274
+ avgDuration: "5-10 minutes",
2275
+ commonIssues: ["Missing Chart.js dependency", "Mobile responsiveness"],
2276
+ bestPractices: ["Always test on mobile", "Use Chart.js from CDN"]
2277
+ },
2278
+ {
2279
+ objective: "create approval workflow",
2280
+ agents: ["flow-builder", "security", "tester"],
2281
+ mcpTools: ["snow_create_flow", "snow_test_flow_with_mock", "snow_link_catalog_to_flow"],
2282
+ successRate: 0.92,
2283
+ avgDuration: "10-15 minutes",
2284
+ commonIssues: ["Complex approval routing", "Email notification setup"],
2285
+ bestPractices: ["Test all approval paths", "Use mock data first"]
2286
+ },
2287
+ {
2288
+ objective: "create ITSM application",
2289
+ agents: ["app-architect", "flow-builder", "widget-creator", "security", "tester"],
2290
+ mcpTools: ["snow_deploy", "snow_create_flow", "snow_update_set_create"],
2291
+ successRate: 0.88,
2292
+ avgDuration: "30-45 minutes",
2293
+ commonIssues: ["Table relationships", "Permission model"],
2294
+ bestPractices: ["Design data model first", "Use Update Sets throughout"]
2295
+ }
2296
+ ],
2297
+ agentCapabilities: {
2298
+ "widget-creator": {
2299
+ strengths: ["HTML/CSS/JS", "Chart.js", "Responsive design"],
2300
+ limitations: ["Complex backend logic", "Database design"]
2301
+ },
2302
+ "flow-builder": {
2303
+ strengths: ["Process automation", "Conditional logic", "Approvals"],
2304
+ limitations: ["UI development", "Complex integrations"]
2305
+ },
2306
+ "app-architect": {
2307
+ strengths: ["System design", "Data modeling", "Architecture"],
2308
+ limitations: ["Detailed implementation", "UI/UX design"]
2309
+ }
2310
+ },
2311
+ mcpToolPatterns: {
2312
+ "authentication_first": {
2313
+ pattern: "Always start with snow_validate_live_connection",
2314
+ reason: "Ensures OAuth is valid before attempting operations"
2315
+ },
2316
+ "discovery_before_creation": {
2317
+ pattern: "Use snow_find_artifact before snow_deploy",
2318
+ reason: "Prevents duplicate artifacts and wasted effort"
2319
+ },
2320
+ "update_set_tracking": {
2321
+ pattern: "Create Update Set, deploy, then track artifacts",
2322
+ reason: "Professional change management like ServiceNow pros"
2323
+ }
2324
+ }
2325
+ };
2326
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'memory/patterns/successful-deployments.json'), JSON.stringify(successfulPatternsContent, null, 2));
2327
+ // Create workflow patterns JSON
2328
+ const workflowPatternsContent = {
2329
+ workflowTemplates: [
2330
+ {
2331
+ name: "Standard Widget Development",
2332
+ steps: [
2333
+ "snow_validate_live_connection",
2334
+ "snow_find_artifact (check existing)",
2335
+ "snow_update_set_create",
2336
+ "snow_deploy (type: widget)",
2337
+ "snow_widget_test",
2338
+ "snow_update_set_add_artifact"
2339
+ ]
2340
+ },
2341
+ {
2342
+ name: "Flow Development with Testing",
2343
+ steps: [
2344
+ "snow_validate_live_connection",
2345
+ "snow_discover_existing_flows",
2346
+ "snow_create_flow",
2347
+ "snow_test_flow_with_mock",
2348
+ "snow_link_catalog_to_flow (if needed)",
2349
+ "snow_comprehensive_flow_test (if authenticated)"
2350
+ ]
2351
+ },
2352
+ {
2353
+ name: "Full Application Deployment",
2354
+ steps: [
2355
+ "snow_validate_live_connection",
2356
+ "snow_analyze_requirements",
2357
+ "snow_update_set_create",
2358
+ "snow_deploy (multiple artifacts)",
2359
+ "snow_create_flow (for workflows)",
2360
+ "snow_deploy (for widgets)",
2361
+ "snow_update_set_complete"
2362
+ ]
2363
+ }
2364
+ ]
2365
+ };
2366
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'memory/patterns/workflow-templates.json'), JSON.stringify(workflowPatternsContent, null, 2));
2367
+ // Create quick start guide
2368
+ const quickStartContent = `# Snow-Flow Quick Start Guide
2369
+
2370
+ ## 🚀 5-Minute Setup
2371
+
2372
+ ### 1. Initialize Your Project
2373
+ \`\`\`bash
2374
+ snow-flow init --sparc
2375
+ \`\`\`
2376
+
2377
+ ### 2. Configure ServiceNow OAuth
2378
+ Edit the .env file with your ServiceNow credentials:
2379
+ \`\`\`env
2380
+ SNOW_INSTANCE=dev123456.service-now.com
2381
+ SNOW_CLIENT_ID=your_oauth_client_id
2382
+ SNOW_CLIENT_SECRET=your_oauth_client_secret
2383
+ \`\`\`
2384
+
2385
+ ### 3. Authenticate
2386
+ \`\`\`bash
2387
+ snow-flow auth login
2388
+ \`\`\`
2389
+
2390
+ ### 4. Create Your First Widget
2391
+ \`\`\`bash
2392
+ snow-flow swarm "create simple incident counter widget"
2393
+ \`\`\`
2394
+
2395
+ ## 📋 What Just Happened?
2396
+
2397
+ When you ran the swarm command, Snow-Flow:
2398
+ 1. ✅ Validated your ServiceNow connection
2399
+ 2. ✅ Analyzed your objective using Queen Agent
2400
+ 3. ✅ Spawned specialized agents (widget-creator, tester)
2401
+ 4. ✅ Created a real widget in your ServiceNow instance
2402
+ 5. ✅ Tracked everything in an Update Set
2403
+ 6. ✅ Tested the widget automatically
2404
+
2405
+ ## 🎯 Next Steps
2406
+
2407
+ ### Try More Examples
2408
+ \`\`\`bash
2409
+ # Create a workflow
2410
+ snow-flow swarm "create simple approval workflow"
2411
+
2412
+ # Build a dashboard
2413
+ snow-flow swarm "create IT dashboard with KPIs"
2414
+
2415
+ # Develop an application
2416
+ snow-flow swarm "create basic ticketing system"
2417
+ \`\`\`
2418
+
2419
+ ### Explore Documentation
2420
+ - **Swarm Patterns**: .claude/commands/swarm-patterns.md
2421
+ - **Agent Types**: .claude/commands/agent-types.md
2422
+ - **MCP Tools**: .claude/commands/mcp-tools-quick-ref.md
2423
+ - **Examples**: ./examples/
2424
+
2425
+ ### Monitor Progress
2426
+ \`\`\`bash
2427
+ # Check swarm status
2428
+ snow-flow swarm-status <sessionId>
2429
+
2430
+ # View system status
2431
+ snow-flow status
2432
+ \`\`\`
2433
+
2434
+ ## 💡 Pro Tips
2435
+
2436
+ 1. **Start Simple**: Let the Queen Agent handle complexity
2437
+ 2. **Use Natural Language**: Describe what you want, not how
2438
+ 3. **Trust the Defaults**: Intelligent features are enabled
2439
+ 4. **Check Examples**: Run scripts in ./examples/ folder
2440
+
2441
+ ## 🆘 Need Help?
2442
+
2443
+ - **Auth Issues**: Run \`snow-flow auth status\`
2444
+ - **MCP Tools**: Check .claude/commands/mcp-tools-quick-ref.md
2445
+ - **Agent Info**: See .claude/commands/agent-types.md
2446
+ - **GitHub**: https://github.com/groeimetai/snow-flow
2447
+
2448
+ Happy ServiceNow Development! 🎉
2449
+ `;
2450
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'QUICK_START.md'), quickStartContent);
2451
+ // Create example scripts
2452
+ const widgetExampleContent = `#!/bin/bash
2453
+ # Example: Create an incident dashboard widget
2454
+
2455
+ # This example shows how to create a comprehensive incident dashboard
2456
+ # with real-time data, charts, and mobile responsiveness
2457
+
2458
+ snow-flow swarm "create incident dashboard widget with:
2459
+ - Real-time incident counts by priority (Critical, High, Medium, Low)
2460
+ - Chart.js bar chart showing incidents by category
2461
+ - Line graph for incident trends over the last 7 days
2462
+ - Responsive grid layout for mobile devices
2463
+ - Auto-refresh every 30 seconds
2464
+ - Click-through to incident details
2465
+ - Color coding for priority levels (red for critical, orange for high)
2466
+ - Export to PDF functionality
2467
+ - Filter by assignment group"
2468
+
2469
+ # The Queen Agent will:
2470
+ # 1. Spawn widget-creator as primary agent
2471
+ # 2. Add ui-designer for responsive design
2472
+ # 3. Add tester for validation
2473
+ # 4. Create complete widget in ServiceNow
2474
+ # 5. Test on mobile and desktop
2475
+ # 6. Deploy with Update Set tracking
2476
+ `;
2477
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'examples/widget-dashboard.sh'), widgetExampleContent);
2478
+ await fs_1.promises.chmod((0, path_1.join)(targetDir, 'examples/widget-dashboard.sh'), '755');
2479
+ const approvalFlowExampleContent = `#!/bin/bash
2480
+ # Example: Create equipment approval workflow
2481
+
2482
+ # This example demonstrates creating a multi-level approval workflow
2483
+ # with dynamic routing based on cost and department
2484
+
2485
+ snow-flow swarm "create approval workflow for equipment requests with:
2486
+ - Automatic approval for items under $100
2487
+ - Manager approval for items $100-$1000
2488
+ - Department head approval for items $1000-$5000
2489
+ - VP approval for items over $5000
2490
+ - IT approval required for all technology items regardless of cost
2491
+ - Finance review for items over $10000
2492
+ - Email notifications at each approval step
2493
+ - Slack notifications for urgent requests
2494
+ - 48-hour SLA with escalation
2495
+ - Rejection reasons and resubmission process
2496
+ - Integration with catalog items for equipment selection
2497
+ - Automatic PO generation upon final approval"
2498
+
2499
+ # The Queen Agent will:
2500
+ # 1. Spawn flow-builder as primary agent
2501
+ # 2. Add security agent for approval permissions
2502
+ # 3. Add tester for all approval paths
2503
+ # 4. Create complex flow with conditions
2504
+ # 5. Link to catalog items
2505
+ # 6. Test all approval scenarios
2506
+ # 7. Validate email notifications
2507
+ `;
2508
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'examples/approval-workflow.sh'), approvalFlowExampleContent);
2509
+ await fs_1.promises.chmod((0, path_1.join)(targetDir, 'examples/approval-workflow.sh'), '755');
2510
+ const itsmApplicationExampleContent = `#!/bin/bash
2511
+ # Example: Create complete ITSM solution
2512
+
2513
+ # This example shows how to build a full IT Service Management application
2514
+ # with custom tables, workflows, and user interfaces
2515
+
2516
+ snow-flow swarm "create complete ITSM solution for laptop provisioning with:
2517
+ - Custom request table extending task table
2518
+ - Fields: laptop_model, specifications, justification, cost_center
2519
+ - Catalog item for laptop requests with dynamic pricing
2520
+ - Multi-stage approval workflow based on cost and user role
2521
+ - Integration with asset management for laptop assignment
2522
+ - Automated Active Directory account provisioning
2523
+ - Email notifications to user, manager, and IT
2524
+ - Dashboard showing request status and metrics
2525
+ - SLA tracking with 5-day fulfillment target
2526
+ - Mobile-friendly request portal
2527
+ - Reporting on request volumes and fulfillment times
2528
+ - Return process for laptop replacement
2529
+ - Integration with purchase order system"
2530
+
2531
+ # The Queen Agent will:
2532
+ # 1. Spawn app-architect to design the solution
2533
+ # 2. Add flow-builder for approval workflows
2534
+ # 3. Add widget-creator for dashboards
2535
+ # 4. Add script-writer for integrations
2536
+ # 5. Add security for access controls
2537
+ # 6. Add tester for end-to-end validation
2538
+ # 7. Create all components in sequence
2539
+ # 8. Deploy complete solution
2540
+ `;
2541
+ await fs_1.promises.writeFile((0, path_1.join)(targetDir, 'examples/itsm-application.sh'), itsmApplicationExampleContent);
2542
+ await fs_1.promises.chmod((0, path_1.join)(targetDir, 'examples/itsm-application.sh'), '755');
1750
2543
  // Create CLAUDE.md by copying from source (v1.1.62+)
1751
2544
  let claudeMdContent = '';
1752
2545
  try {
@@ -2924,7 +3717,13 @@ program
2924
3717
  if (options.sparc) {
2925
3718
  console.log('🎯 Creating SPARC environment...');
2926
3719
  await createSparcFiles(targetDir);
2927
- console.log('✅ SPARC environment created\n');
3720
+ console.log('✅ SPARC environment created');
3721
+ console.log('📋 Added swarm documentation:');
3722
+ console.log(' - swarm-patterns.md: Common swarm command examples');
3723
+ console.log(' - agent-types.md: Agent specializations guide');
3724
+ console.log(' - mcp-tools-quick-ref.md: MCP tools reference');
3725
+ console.log(' - examples/: Ready-to-run example scripts');
3726
+ console.log(' - memory/patterns/: Success patterns and templates\n');
2928
3727
  }
2929
3728
  // Phase 4: Create .env file
2930
3729
  console.log('🔐 Creating environment configuration...');
@@ -3399,6 +4198,12 @@ echo "💡 Check MCP servers with: /mcp in Claude Code"
3399
4198
  console.log(' 2. Run: snow-flow auth login');
3400
4199
  console.log(' 3. Start your first swarm: snow-flow swarm "create a widget for incident management"');
3401
4200
  console.log('');
4201
+ console.log('📚 Documentation created:');
4202
+ console.log(' - QUICK_START.md: 5-minute getting started guide');
4203
+ console.log(' - CLAUDE.md: Complete development guide with MCP-FIRST workflow');
4204
+ console.log(' - .claude/commands/: Swarm patterns, agent types, MCP tools reference');
4205
+ console.log(' - examples/: Ready-to-run example scripts for common tasks');
4206
+ console.log('');
3402
4207
  console.log('✅ Project is ready to use!');
3403
4208
  console.log('');
3404
4209
  console.log('🔧 MCP Servers:');