snow-flow 3.4.6 → 3.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -2183,455 +2183,10 @@ async function copyCLAUDEmd(targetDir, force = false) {
2183
2183
  }
2184
2184
  }
2185
2185
  if (!foundSource) {
2186
- // Use Snow-Flow specific CLAUDE.md content
2187
- console.log('⚠️ Could not find CLAUDE.md source, creating minimal version');
2188
- claudeMdContent = `# Snow-Flow Development with Claude Code
2189
-
2190
- ## 🚨 CRITICAL: MCP-FIRST WORKFLOW (READ THIS FIRST!)
2191
-
2192
- **Snow-flow's core value is REAL ServiceNow integration through MCP tools. NEVER work in offline mode!**
2193
-
2194
- ### ⚠️ MANDATORY WORKFLOW - NO EXCEPTIONS
2195
-
2196
- **Every ServiceNow task MUST start with this sequence:**
2197
-
2198
- \`\`\`javascript
2199
- // 1. MANDATORY: Pre-flight authentication check
2200
- const authCheck = await snow_validate_live_connection({ test_level: "permissions" });
2201
- if (!authCheck.success) {
2202
- // STOP! Fix authentication first
2203
- return authenticationError(authCheck.error);
2204
- }
2205
-
2206
- // 2. MANDATORY: Discovery before creation
2207
- const discovery = await snow_find_artifact({
2208
- query: "your objective",
2209
- type: "widget|flow|script|any"
2210
- });
2211
-
2212
- // 3. MANDATORY: Real ServiceNow deployment
2213
- const deployment = await snow_deploy({
2214
- type: "widget|application", // Note: flow removed in v1.4.0+
2215
- config: { /* your config */ },
2216
- auto_update_set: true // Always track changes
2217
- });
2218
-
2219
- // 4. MANDATORY: Track in Update Set
2220
- await snow_update_set_add_artifact({
2221
- type: deployment.type,
2222
- sys_id: deployment.result.sys_id,
2223
- name: deployment.result.name
2224
- });
2225
- \`\`\`
2226
-
2227
- ### 🚫 FORBIDDEN ACTIONS
2228
-
2229
- **THESE ACTIONS ARE BANNED - NEVER DO THESE:**
2230
-
2231
- ❌ **Creating local files** without MCP check first
2232
- ❌ **Generating mock data** instead of using MCP tools
2233
- ❌ **Working in "offline mode"** when ServiceNow is available
2234
- ❌ **Skipping authentication validation**
2235
- ❌ **Planning mode** without trying MCP tools first
2236
-
2237
- ### ✅ CORRECT: MCP-First Decision Tree
2238
-
2239
- \`\`\`
2240
- User Request → ALWAYS START HERE:
2241
-
2242
- 1. snow_validate_live_connection()
2243
-
2244
- SUCCESS? → Continue to Step 2
2245
-
2246
- FAILURE? → Fix auth: snow_auth_diagnostics()
2247
- Then guide user: "snow-flow auth login"
2248
- STOP until auth works
2249
-
2250
- 2. snow_find_artifact() // Check if exists
2251
-
2252
- FOUND? → Ask: "Reuse existing or create new?"
2253
-
2254
- NOT FOUND? → Continue to Step 3
2255
-
2256
- 3. snow_deploy() // Real deployment to ServiceNow
2257
-
2258
- SUCCESS? → Step 4: Track in Update Set
2259
-
2260
- FAILURE? → Use fallback strategies
2261
-
2262
- 4. snow_update_set_add_artifact() // Always track
2263
-
2264
- DONE! ✅
2265
- \`\`\`
2266
-
2267
- ## 🚀 Snow-Flow Swarm Command - MCP-Orchestrated Multi-Agent Intelligence
2268
-
2269
- **The Swarm system is MCP-native and ALWAYS uses ServiceNow tools first!**
2270
-
2271
- ### 🧠 Queen Agent with Parallel Execution (v1.4.0+)
2272
- - Automatically spawns 6+ specialized agents for widget development
2273
- - Achieves proven 2.8x speedup through intelligent parallel execution
2274
- - All agents coordinate through Snow-Flow's memory system
2275
- - Every agent uses MCP tools directly - no offline mode
2276
-
2277
- ## 🛠️ Complete ServiceNow MCP Tools Reference
2278
-
2279
- ### Discovery & Search Tools
2280
- \`\`\`javascript
2281
- // Find any ServiceNow artifact using natural language
2282
- snow_find_artifact({
2283
- query: "the widget that shows incidents on homepage",
2284
- type: "widget" // or "flow", "script", "application", "any"
2285
- });
2286
-
2287
- // Search catalog items with fuzzy matching
2288
- snow_catalog_item_search({
2289
- query: "laptop",
2290
- fuzzy_match: true, // Finds variations: notebook, MacBook, etc.
2291
- category_filter: "hardware",
2292
- include_variables: true // Get catalog variables too
2293
- });
2294
-
2295
- // Direct sys_id lookup (faster than search)
2296
- snow_get_by_sysid({
2297
- sys_id: "<artifact_sys_id>",
2298
- table: "sp_widget"
2299
- });
2300
- \`\`\`
2301
-
2302
- ### Flow Development Tools
2303
- \`\`\`javascript
2304
- // Create flows from natural language
2305
- snow_create_flow({
2306
- instruction: "create a flow that sends email when incident priority is high",
2307
- deploy_immediately: true // Automatically deploys XML to ServiceNow
2308
- });
2309
-
2310
- // Test flows with mock data
2311
- snow_test_flow_with_mock({
2312
- flow_id: "incident_notification_flow",
2313
- create_test_user: true,
2314
- mock_catalog_items: true,
2315
- test_inputs: {
2316
- priority: "1",
2317
- category: "hardware"
2318
- },
2319
- simulate_approvals: true
2320
- });
2321
-
2322
- // Link catalog items to flows
2323
- snow_link_catalog_to_flow({
2324
- catalog_item_id: "New Laptop Request",
2325
- flow_id: "laptop_provisioning_flow",
2326
- link_type: "flow_catalog_process",
2327
- variable_mapping: [
2328
- {
2329
- catalog_variable: "laptop_model",
2330
- flow_input: "equipment_type"
2331
- }
2332
- ]
2333
- });
2334
- \`\`\`
2335
-
2336
- ### Widget Development Tools
2337
- \`\`\`javascript
2338
- // Deploy widgets with automatic validation
2339
- snow_deploy_widget({
2340
- name: "incident_dashboard",
2341
- title: "Incident Dashboard",
2342
- template: htmlContent,
2343
- css: cssContent,
2344
- client_script: clientJS,
2345
- server_script: serverJS,
2346
- demo_data: { incidents: [...] }
2347
- });
2348
-
2349
- // Preview and test widgets
2350
- snow_preview_widget({
2351
- widget_id: "incident_dashboard",
2352
- check_dependencies: true
2353
- });
2354
-
2355
- snow_widget_test({
2356
- widget_id: "incident_dashboard",
2357
- test_scenarios: [
2358
- {
2359
- name: "Load with no data",
2360
- server_data: { incidents: [] }
2361
- }
2362
- ]
2363
- });
2364
- \`\`\`
2365
-
2366
- ### Bulk Operations
2367
- \`\`\`javascript
2368
- // Deploy multiple artifacts at once
2369
- snow_bulk_deploy({
2370
- artifacts: [
2371
- { type: "widget", data: widgetData },
2372
- { type: "flow", data: flowData },
2373
- { type: "script", data: scriptData }
2374
- ],
2375
- transaction_mode: true, // All or nothing
2376
- parallel: true, // Deploy simultaneously
2377
- dry_run: false
2378
- });
2379
- \`\`\`
2380
-
2381
- ### Intelligent Analysis
2382
- \`\`\`javascript
2383
- // Analyze incidents with AI
2384
- snow_analyze_incident({
2385
- incident_id: "INC0010001",
2386
- include_similar: true,
2387
- suggest_resolution: true
2388
- });
2389
-
2390
- // Pattern analysis
2391
- snow_pattern__analysis({
2392
- analysis_type: "incident_patterns",
2393
- timeframe: "month"
2394
- });
2395
- \`\`\`
2396
-
2397
- ## ⚡ Performance Optimization
2398
-
2399
- ### Parallel Execution Patterns
2400
- \`\`\`javascript
2401
- // Execute multiple searches concurrently
2402
- Promise.all([
2403
- snow_find_artifact({ query: "incident widget" }),
2404
- snow_catalog_item_search({ query: "laptop" }),
2405
- snow_query_table({ table: "incident", query: "priority=1" }) // Universal query tool
2406
- ]);
2407
- \`\`\`
2408
-
2409
- ### Batch File Operations
2410
- \`\`\`javascript
2411
- // Read multiple files in one operation
2412
- MultiRead([
2413
- "/path/to/widget.html",
2414
- "/path/to/widget.css",
2415
- "/path/to/widget.js"
2416
- ]);
2417
- \`\`\`
2418
-
2419
- ## 📝 Workflow Guidelines
2420
-
2421
- ### Standard Development Flow
2422
- 1. **Discovery Phase**: Use search tools to find existing artifacts
2423
- 2. **Planning Phase**: Use TodoWrite to plan all tasks
2424
- 3. **Development Phase**: Launch agents concurrently
2425
- 4. **Testing Phase**: Use mock testing tools
2426
- 5. **Deployment Phase**: Use bulk deploy with validation
2427
-
2428
- ### Error Recovery Patterns
2429
- \`\`\`javascript
2430
- // Always implement rollback strategies
2431
- if (deployment.failed) {
2432
- snow_deployment_rollback_manager({
2433
- update_set_id: deployment.update_set,
2434
- restore_point: deployment.backup_id
2435
- });
2436
- }
2437
- \`\`\`
2438
-
2439
- ## 🔧 Advanced Configuration
2440
-
2441
- ## Build Commands
2442
- - \`npm run build\`: Build the project
2443
- - \`npm run test\`: Run the full test suite
2444
- - \`npm run lint\`: Run ESLint and format checks
2445
- - \`npm run typecheck\`: Run TypeScript type checking
2446
-
2447
- ## Snow-Flow Commands
2448
- - \`snow-flow init\`: Initialize project with MCP servers and SPARC environment and SPARC environment
2449
- - \`snow-flow auth login\`: Authenticate with ServiceNow OAuth
2450
- - \`snow-flow swarm "<objective>"\`: Start multi-agent swarm - één command voor alles!
2451
- - \`snow-flow sparc <mode> "<task>"\`: Run specific SPARC mode
2452
-
2453
- ## Enhanced Swarm Command (v1.1.41+)
2454
- The swarm command now includes intelligent features that are **enabled by default**:
2455
-
2456
- \`\`\`bash
2457
- # Simple usage - ALL autonomous systems enabled by default!
2458
- snow-flow swarm "create incident management dashboard"
2459
-
2460
- # Disable specific autonomous systems if needed
2461
- snow-flow swarm "create simple widget" --no-autonomous-cost-optimization --no-autonomous-compliance
2462
-
2463
- # Disable ALL autonomous systems
2464
- snow-flow swarm "basic development only" --no-autonomous-all
2465
-
2466
- # Force enable all (overrides any --no- flags)
2467
- snow-flow swarm "full orchestration mode" --autonomous-all
2468
- \`\`\`
2469
-
2470
- ### 🤖 NEW: Autonomous Systems (v1.3.26+) - **ENABLED BY DEFAULT!**
2471
- True orchestration with zero manual intervention - all systems active unless disabled:
2472
-
2473
- - ✅ **Documentation**: Self-documenting system (auto-generates and updates docs)
2474
- - ✅ **Cost Optimization**: AI-driven cost management with auto-optimization
2475
- - ✅ **Compliance**: Multi-framework compliance monitoring with auto-remediation
2476
- - ✅ **Self-Healing**: Predictive failure detection with automatic recovery
2477
-
2478
- **Disable Options**:
2479
- - \`--no-autonomous-documentation\`: Disable documentation system
2480
- - \`--no-autonomous-cost-optimization\`: Disable cost optimization
2481
- - \`--no-autonomous-compliance\`: Disable compliance monitoring
2482
- - \`--no-autonomous-healing\`: Disable self-healing
2483
- - \`--no-autonomous-all\`: Disable ALL autonomous systems
2484
-
2485
- **Force Options**:
2486
- - \`--autonomous-all\`: Force enable all (overrides --no- flags)
2487
-
2488
- **Perfect Orchestrator**: Systems work autonomously, make intelligent decisions, and continuously improve - no manual intervention needed!
2489
-
2490
- ### Default Settings (no flags needed):
2491
- - ✅ \`--smart-discovery\` - Automatically discovers and reuses existing artifacts
2492
- - ✅ \`--live-testing\` - Tests in real-time on your ServiceNow instance
2493
- - ✅ \`--auto-deploy\` - Deploys automatically (safe with update sets)
2494
- - ✅ \`--auto-rollback\` - Automatically rollbacks on failures
2495
- - ✅ \`--shared-memory\` - All agents share context and coordination
2496
- - ✅ \`--progress-monitoring\` - Real-time progress tracking
2497
- - ❌ \`--auto-permissions\` - Disabled by default (enable with flag for automatic role elevation)
2498
-
2499
- ### Advanced Usage:
2500
- \`\`\`bash
2501
- # Enable automatic permission escalation
2502
- snow-flow swarm "create global workflow" --auto-permissions
2503
-
2504
- # Disable specific features
2505
- snow-flow swarm "test widget" --no-auto-deploy --no-live-testing
2506
-
2507
- # Full control
2508
- snow-flow swarm "complex integration" \\
2509
- --max-agents 8 \\
2510
- --strategy development \\
2511
- --mode distributed \\
2512
- --parallel \\
2513
- --auto-permissions
2514
- \`\`\`
2515
-
2516
- ## New MCP Tools (v1.1.44+)
2517
-
2518
- ### Catalog Item Search
2519
- Find catalog items with intelligent fuzzy matching:
2520
- \`\`\`javascript
2521
- snow_catalog_item_search({
2522
- query: "iPhone", // Will find iPhone 6S, iPhone 7, etc.
2523
- fuzzy_match: true, // Enable intelligent variations
2524
- include_variables: true // Include catalog variables
2525
- })
2526
- \`\`\`
2527
-
2528
- ### Flow Testing with Mock Data
2529
- Test flows without real data:
2530
- \`\`\`javascript
2531
- snow_test_flow_with_mock({
2532
- flow_id: "equipment_provisioning_flow",
2533
- create_test_user: true, // Creates test user
2534
- mock_catalog_items: true, // Creates test catalog items
2535
- simulate_approvals: true, // Auto-approves during test
2536
- cleanup_after_test: true // Removes test data after
2537
- })
2538
- \`\`\`
2539
-
2540
- ### Direct Catalog-Flow Linking
2541
- Link catalog items directly to flows:
2542
- \`\`\`javascript
2543
- snow_link_catalog_to_flow({
2544
- catalog_item_id: "iPhone 6S",
2545
- flow_id: "mobile_provisioning_flow",
2546
- link_type: "flow_catalog_process", // Modern approach
2547
- variable_mapping: [
2548
- {
2549
- catalog_variable: "phone_model",
2550
- flow_input: "device_type"
2551
- }
2552
- ],
2553
- test_link: true // Creates test request
2554
- })
2555
- \`\`\`
2556
-
2557
- ### OAuth Configuration
2558
- \`\`\`env
2559
- # .env file
2560
- SNOW_INSTANCE=dev123456
2561
- SNOW_CLIENT_ID=your_oauth_client_id
2562
- SNOW_CLIENT_SECRET=your_oauth_client_secret
2563
- SNOW_USERNAME=admin
2564
- SNOW_PASSWORD=admin_password
2565
- \`\`\`
2566
-
2567
- ### Update Set Management
2568
- \`\`\`javascript
2569
- // Smart update set creation
2570
- snow_smart_update_set({
2571
- name: "Auto-generated for widget development",
2572
- detect_context: true, // Auto-detects what you're working on
2573
- auto_switch: true // Switches when context changes
2574
- });
2575
- \`\`\`
2576
-
2577
- ## 🎯 Quick Start
2578
- 1. \`snow-flow init\` - Initialize project with MCP servers and SPARC environment and SPARC environment
2579
- 2. Configure ServiceNow credentials in .env file
2580
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow OAuth
2581
- 4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
2582
-
2583
- ## 💡 Important Notes
2584
-
2585
- ### Do's
2586
- - ✅ Use TodoWrite extensively for task tracking
2587
- - ✅ Batch MCP tool calls for performance
2588
- - ✅ Store important data in Memory for coordination
2589
- - ✅ Test with mock data before deploying
2590
- - ✅ Work within Update Sets for safety
2591
- - ✅ Use fuzzy search for finding artifacts
2592
-
2593
- ### Don'ts
2594
- - ❌ Don't make sequential tool calls when batch is possible
2595
- - ❌ Don't hardcode credentials or sys_ids
2596
- - ❌ Don't deploy without testing
2597
- - ❌ Don't ignore OAuth permission errors
2598
- - ❌ Don't create artifacts without checking if they exist
2599
-
2600
- ## 🚀 Performance Benchmarks
2601
-
2602
- With concurrent execution and batch operations:
2603
- - **Widget Development**: 3x faster than sequential
2604
- - **Flow Creation**: 2.5x faster with parallel validation
2605
- - **Bulk Deployment**: Up to 5x faster with parallel mode
2606
- - **Search Operations**: 4x faster with concurrent queries
2607
-
2608
- ## 📚 Additional Resources
2609
-
2610
- ### MCP Server Documentation
2611
- - **servicenow-deployment**: Widget, flow, and application deployment
2612
- - **servicenow-intelligent**: Smart search and artifact discovery
2613
- - **servicenow-operations**: Incident management and catalog operations
2614
- - **servicenow-platform-development**: Scripts, rules, and policies
2615
-
2616
- ### SPARC Modes
2617
- - \`orchestrator\`: Coordinates complex multi-step tasks
2618
- - \`coder\`: Focused code implementation
2619
- - \`researcher\`: Deep _analysis and discovery
2620
- - \`tester\`: Comprehensive testing strategies
2621
- - \`architect\`: System design and architecture
2622
-
2623
- ---
2624
-
2625
- This is a minimal CLAUDE.md file. The full documentation should be available in your Snow-Flow installation.
2626
-
2627
- ## Quick Start
2628
- 1. \`snow-flow init\` - Initialize project with MCP servers and SPARC environment and SPARC environment
2629
- 2. Configure ServiceNow credentials in .env file
2630
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow OAuth
2631
- 4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
2632
-
2633
- For full documentation, visit: https://github.com/groeimetai/snow-flow
2634
- `;
2186
+ // Import the template from the dedicated file
2187
+ const { CLAUDE_MD_TEMPLATE } = await Promise.resolve().then(() => __importStar(require('./templates/claude-md-template.js')));
2188
+ claudeMdContent = CLAUDE_MD_TEMPLATE;
2189
+ console.log('✅ Using built-in CLAUDE.md template');
2635
2190
  }
2636
2191
  const claudeMdPath = (0, path_1.join)(targetDir, 'CLAUDE.md');
2637
2192
  try {
@@ -2650,273 +2205,11 @@ For full documentation, visit: https://github.com/groeimetai/snow-flow
2650
2205
  }
2651
2206
  catch (error) {
2652
2207
  console.log('⚠️ Error copying CLAUDE.md, creating Snow-Flow specific version');
2653
- // Snow-Flow specific fallback content
2654
- const claudeMdFallback = `# Snow-Flow Development with Claude Code
2655
-
2656
- ## 🚨 CRITICAL: MCP-FIRST WORKFLOW (READ THIS FIRST!)
2657
-
2658
- **Snow-flow's core value is REAL ServiceNow integration through MCP tools. NEVER work in offline mode!**
2659
-
2660
- ### ⚠️ MANDATORY WORKFLOW - NO EXCEPTIONS
2661
-
2662
- **Every ServiceNow task MUST start with this sequence:**
2663
-
2664
- \`\`\`javascript
2665
- // 1. MANDATORY: Pre-flight authentication check
2666
- const authCheck = await snow_validate_live_connection({ test_level: "permissions" });
2667
- if (!authCheck.success) {
2668
- // STOP! Fix authentication first
2669
- return authenticationError(authCheck.error);
2670
- }
2671
-
2672
- // 2. MANDATORY: Discovery before creation
2673
- const discovery = await snow_find_artifact({
2674
- query: "your objective",
2675
- type: "widget|flow|script|any"
2676
- });
2677
-
2678
- // 3. MANDATORY: Real ServiceNow deployment
2679
- const deployment = await snow_deploy({
2680
- type: "widget|application", // Note: flow removed in v1.4.0+
2681
- config: { /* your config */ },
2682
- auto_update_set: true // Always track changes
2683
- });
2684
-
2685
- // 4. MANDATORY: Track in Update Set
2686
- await snow_update_set_add_artifact({
2687
- type: deployment.type,
2688
- sys_id: deployment.result.sys_id,
2689
- name: deployment.result.name
2690
- });
2691
- \`\`\`
2692
-
2693
- ### 🚫 FORBIDDEN ACTIONS
2694
-
2695
- **THESE ACTIONS ARE BANNED - NEVER DO THESE:**
2696
-
2697
- ❌ **Creating local files** without MCP check first
2698
- ❌ **Generating mock data** instead of using MCP tools
2699
- ❌ **Working in "offline mode"** when ServiceNow is available
2700
- ❌ **Skipping authentication validation**
2701
- ❌ **Planning mode** without trying MCP tools first
2702
-
2703
- ### ✅ CORRECT: MCP-First Decision Tree
2704
-
2705
- \`\`\`
2706
- User Request → ALWAYS START HERE:
2707
-
2708
- 1. snow_validate_live_connection()
2709
-
2710
- SUCCESS? → Continue to Step 2
2711
-
2712
- FAILURE? → Fix auth: snow_auth_diagnostics()
2713
- Then guide user: "snow-flow auth login"
2714
- STOP until auth works
2715
-
2716
- 2. snow_find_artifact() // Check if exists
2717
-
2718
- FOUND? → Ask: "Reuse existing or create new?"
2719
-
2720
- NOT FOUND? → Continue to Step 3
2721
-
2722
- 3. snow_deploy() // Real deployment to ServiceNow
2723
-
2724
- SUCCESS? → Step 4: Track in Update Set
2725
-
2726
- FAILURE? → Use fallback strategies
2727
-
2728
- 4. snow_update_set_add_artifact() // Always track
2729
-
2730
- DONE! ✅
2731
- \`\`\`
2732
-
2733
- ## 🚀 Snow-Flow Swarm Command - MCP-Orchestrated Multi-Agent Intelligence
2734
-
2735
- **The Swarm system is MCP-native and ALWAYS uses ServiceNow tools first!**
2736
-
2737
- ### 🧠 Queen Agent with Parallel Execution (v1.4.0+)
2738
- - Automatically spawns 6+ specialized agents for widget development
2739
- - Achieves proven 2.8x speedup through intelligent parallel execution
2740
- - All agents coordinate through Snow-Flow's memory system
2741
- - Every agent uses MCP tools directly - no offline mode
2742
-
2743
- ### Swarm Command Examples
2744
- \`\`\`bash
2745
- # Simple widget creation
2746
- snow-flow swarm "create incident dashboard widget"
2747
-
2748
- # Complex development
2749
- snow-flow swarm "build employee onboarding portal with approval workflows"
2750
-
2751
- # With specific options
2752
- snow-flow swarm "create service catalog item" --no-auto-deploy --monitor
2753
- \`\`\`
2754
-
2755
- ## 🛠️ Complete ServiceNow MCP Tools Reference
2756
-
2757
- ### Discovery & Search Tools
2758
- \`\`\`javascript
2759
- // Find any ServiceNow artifact using natural language
2760
- snow_find_artifact({
2761
- query: "the widget that shows incidents on homepage",
2762
- type: "widget" // or "flow", "script", "application", "any"
2763
- });
2764
-
2765
- // Search catalog items with fuzzy matching
2766
- snow_catalog_item_search({
2767
- query: "laptop",
2768
- fuzzy_match: true, // Finds variations: notebook, MacBook, etc.
2769
- include_variables: true // Include catalog variables
2770
- });
2771
-
2772
- // Comprehensive search across all tables
2773
- snow_comprehensive_search({
2774
- query: "approval",
2775
- include_inactive: false
2776
- });
2777
- \`\`\`
2778
-
2779
- ### Deployment Tools
2780
- \`\`\`javascript
2781
- // Universal deployment tool
2782
- snow_deploy({
2783
- type: "widget",
2784
- config: {
2785
- name: "Incident Dashboard",
2786
- template: "<html>...</html>",
2787
- css: "/* styles */",
2788
- server_script: "// server code",
2789
- client_script: "// client code"
2790
- },
2791
- auto_update_set: true
2792
- });
2793
-
2794
- // Bulk deployment
2795
- snow_bulk_deploy({
2796
- artifacts: [...],
2797
- transaction_mode: true,
2798
- rollback_on_error: true
2799
- });
2800
- \`\`\`
2801
-
2802
- ### Update Set Management
2803
- \`\`\`javascript
2804
- // Ensure active Update Set
2805
- snow_ensure_active_update_set({
2806
- context: "Widget development"
2807
- });
2808
-
2809
- // Track artifacts
2810
- snow_update_set_add_artifact({
2811
- type: "widget",
2812
- sys_id: "abc123",
2813
- name: "My Widget"
2814
- });
2815
-
2816
- // Preview changes
2817
- snow_update_set_preview({
2818
- update_set_id: "current"
2819
- });
2820
- \`\`\`
2821
-
2822
- ### Testing Tools
2823
- \`\`\`javascript
2824
- // Test flows with mock data
2825
- snow_test_flow_with_mock({
2826
- flow_id: "equipment_provisioning_flow",
2827
- create_test_user: true,
2828
- mock_catalog_items: true,
2829
- simulate_approvals: true,
2830
- cleanup_after_test: true
2831
- });
2832
-
2833
- // Link catalog to flow
2834
- snow_link_catalog_to_flow({
2835
- catalog_item_id: "iPhone 6S",
2836
- flow_id: "mobile_provisioning_flow",
2837
- test_link: true
2838
- });
2839
- \`\`\`
2840
-
2841
- ## 📋 Essential Patterns
2842
-
2843
- ### Authentication Handling
2844
- \`\`\`javascript
2845
- // Always handle auth failures gracefully
2846
- if (error.includes('401') || error.includes('403')) {
2847
- // Guide user to fix authentication
2848
- console.log('Run: snow-flow auth login');
2849
- console.log('Check .env file for credentials');
2850
- // STOP - don't continue without auth
2851
- }
2852
- \`\`\`
2853
-
2854
- ### Error Recovery
2855
- \`\`\`javascript
2856
- // Implement fallback strategies
2857
- if (deployment.failed) {
2858
- // Try global scope
2859
- const globalAttempt = await snow_deploy({
2860
- ...config,
2861
- scope_preference: 'global'
2862
- });
2863
-
2864
- if (globalAttempt.failed) {
2865
- // Provide manual instructions
2866
- return createManualStepsGuide(config, error);
2867
- }
2868
- }
2869
- \`\`\`
2870
-
2871
- ## 🔧 Configuration
2872
-
2873
- ### Build Commands
2874
- - \`npm run build\`: Build the project
2875
- - \`npm run test\`: Run the full test suite
2876
- - \`npm run lint\`: Run ESLint and format checks
2877
- - \`npm run typecheck\`: Run TypeScript type checking
2878
-
2879
- ### Snow-Flow Commands
2880
- - \`snow-flow init\`: Initialize project with MCP servers and SPARC environment
2881
- - \`snow-flow auth login\`: Authenticate with ServiceNow
2882
- - \`snow-flow swarm "<objective>"\`: Execute multi-agent development
2883
- - \`snow-flow mcp start\`: Start MCP servers manually
2884
-
2885
- ### Environment Setup
2886
- \`\`\`bash
2887
- # .env file
2888
- SNOW_INSTANCE=dev123456
2889
- SNOW_CLIENT_ID=your_oauth_client_id
2890
- SNOW_CLIENT_SECRET=your_oauth_client_secret
2891
- \`\`\`
2892
-
2893
- ## 💡 Best Practices
2894
-
2895
- ### DO's
2896
- ✅ Always use \`snow_validate_live_connection()\` first
2897
- ✅ Check for existing artifacts with \`snow_find_artifact()\`
2898
- ✅ Use Update Sets for all changes
2899
- ✅ Test with mock data before production
2900
- ✅ Handle errors gracefully with fallbacks
2901
-
2902
- ### DON'Ts
2903
- ❌ Don't create local files first
2904
- ❌ Don't skip authentication
2905
- ❌ Don't hardcode sys_ids or credentials
2906
- ❌ Don't work in offline mode
2907
- ❌ Don't deploy without testing
2908
-
2909
- ## 🎯 Quick Start
2910
- 1. \`snow-flow init\` - Initialize project with MCP servers and SPARC environment
2911
- 2. Configure ServiceNow credentials in .env file
2912
- 3. \`snow-flow auth login\` - Authenticate with ServiceNow
2913
- 4. \`snow-flow swarm "create a widget for incident management"\` - Everything automatic!
2914
-
2915
- For full documentation, visit: https://github.com/groeimetai/snow-flow
2916
- `;
2208
+ // Import the template as fallback
2209
+ const { CLAUDE_MD_TEMPLATE } = await Promise.resolve().then(() => __importStar(require('./templates/claude-md-template.js')));
2917
2210
  const claudeMdPath = (0, path_1.join)(targetDir, 'CLAUDE.md');
2918
2211
  if (force || !(0, fs_2.existsSync)(claudeMdPath)) {
2919
- await fs_1.promises.writeFile(claudeMdPath, claudeMdFallback);
2212
+ await fs_1.promises.writeFile(claudeMdPath, CLAUDE_MD_TEMPLATE);
2920
2213
  }
2921
2214
  }
2922
2215
  }
@@ -0,0 +1,2 @@
1
+ export declare const CLAUDE_MD_TEMPLATE = "# Snow-Flow Configuration & Best Practices\n\nThis document provides comprehensive instructions for Snow-Flow, an advanced ServiceNow development and orchestration framework powered by Claude AI.\n\n## Table of Contents\n1. [Core Philosophy](#core-philosophy)\n2. [Fundamental Rules](#fundamental-rules)\n3. [ServiceNow Development Standards](#servicenow-development-standards)\n4. [MCP Server Capabilities](#mcp-server-capabilities)\n5. [Debugging Best Practices](#debugging-best-practices)\n6. [Command Reference](#command-reference)\n7. [Workflow Guidelines](#workflow-guidelines)\n\n## Core Philosophy\n\n### The Prime Directive: Verify, Don't Assume\n\nSnow-Flow operates on evidence-based development. Never make assumptions about what exists or doesn't exist in a ServiceNow environment. Every environment is unique with custom tables, fields, integrations, and configurations that you cannot predict.\n\n**Cardinal Rules:**\n1. If code references something, it probably exists\n2. Test before declaring something broken\n3. Verify before modifying\n4. Fix only what's confirmed broken\n5. Respect existing configurations\n\n### The Verification-First Approach\n\n```javascript\n// Before claiming anything doesn't work or exist:\n// Step 1: Test the actual implementation\nconst verify = await snow_execute_script_with_output({\n script: `/* Test the exact code or resource */`\n});\n\n// Step 2: Check if resources exist\nconst tableCheck = await snow_discover_table_fields({\n table_name: 'potentially_custom_table'\n});\n\n// Step 3: Validate configurations\nconst propertyCheck = await snow_property_manager({\n action: 'get',\n name: 'system.property'\n});\n\n// Step 4: Only then make informed decisions\n```\n\n## Fundamental Rules\n\n### Rule 1: ES5 JavaScript Only in ServiceNow\n\nServiceNow uses the Rhino JavaScript engine which supports only ES5. Modern JavaScript syntax will fail.\n\n**Never Use:**\n- `const` or `let` - use `var`\n- Arrow functions `() => {}` - use `function() {}`\n- Template literals `` `${var}` `` - use string concatenation\n- Destructuring `{a, b} = obj` - use explicit property access\n- `for...of` loops - use traditional `for` loops\n- Default parameters - use `typeof` checks\n- `async/await` - use callbacks or GlideAjax\n\n**Always Use:**\n```javascript\n// ES5 compatible code\nvar name = 'value';\nfunction processData() {\n return 'result';\n}\nvar message = 'Hello ' + userName;\nfor (var i = 0; i < array.length; i++) {\n var item = array[i];\n}\n```\n\n### Rule 2: Background Scripts as Primary Debug Tool\n\nBackground scripts provide immediate, factual feedback from the actual ServiceNow instance. Use them extensively for verification and debugging.\n\n```javascript\n// Universal verification pattern\nconst verify = await snow_execute_script_with_output({\n script: `\n gs.info('=== VERIFICATION TEST ===');\n \n // Test table existence\n var table = new GlideRecord('table_name');\n gs.info('Table valid: ' + table.isValid());\n \n // Test property existence\n var prop = gs.getProperty('property.name');\n gs.info('Property: ' + (prop || 'NOT SET'));\n \n // Test actual code\n try {\n // User's code here\n gs.info('SUCCESS');\n } catch(e) {\n gs.error('ERROR: ' + e.message);\n }\n `\n});\n```\n\n### Rule 3: Widget Coherence - Critical Client-Server Communication\n\nServiceNow widgets MUST have perfect communication between client and server scripts. This is not optional - widgets fail when these components don't talk to each other correctly.\n\n**The Three-Way Contract:**\n\n**Server Script Must:**\n- Initialize all `data` properties that HTML will reference\n- Handle every `input.action` that client sends\n- Return data in the format client expects\n\n**Client Script Must:**\n- Implement every method that HTML calls via `ng-click`\n- Use `c.server.get({action: 'name'})` for server communication\n- Update `c.data` when server responds\n\n**HTML Template Must:**\n- Only reference `data` properties that server provides\n- Only call methods that client implements\n- Use correct Angular directives and bindings\n\n**Critical Communication Points:**\n\n1. **Server \u2192 Client Data Flow**\n - Server sets `data.property`\n - Client receives via `c.data.property`\n - HTML displays with `{{data.property}}`\n\n2. **Client \u2192 Server Requests**\n - Client sends `c.server.get({action: 'name'})`\n - Server receives via `input.action`\n - Server processes and returns updated `data`\n\n3. **HTML \u2192 Client Method Calls**\n - HTML has `ng-click=\"methodName()\"`\n - Client must have `$scope.methodName = function()`\n - Method typically calls server with `c.server.get()`\n\n**Common Failures to Avoid:**\n- Action name mismatches between client and server\n- Method name mismatches between HTML and client \n- Property name mismatches between server and HTML\n- Missing handlers for client requests\n- Orphaned data properties or methods\n\n**Coherence Validation Checklist:**\n- [ ] Every `data.property` in server is used in HTML/client\n- [ ] Every `ng-click` in HTML has matching `$scope.method` in client\n- [ ] Every `c.server.get({action})` in client has matching `if(input.action)` in server\n- [ ] Data flows correctly: Server \u2192 HTML \u2192 Client \u2192 Server\n- [ ] No orphaned methods or unused data properties\n\n### Rule 4: Evidence-Based Debugging\n\nFollow this systematic approach for all debugging:\n\n1. **Reproduce** - Run the exact failing code\n2. **Inventory** - List all dependencies\n3. **Verify** - Test each dependency exists\n4. **Fix** - Correct only confirmed issues\n\n**Fix only:**\n- \u2705 Confirmed syntax errors\n- \u2705 Verified null references\n- \u2705 Missing dependencies (after verification)\n- \u2705 Real type mismatches\n\n**Never change:**\n- \u274C Unverified resources\n- \u274C Configurations that \"seem wrong\"\n- \u274C APIs you haven't tested\n- \u274C Working code that could be \"better\"\n\n## ServiceNow Development Standards\n\n### Table Operations\n- Always verify table existence before operations\n- Use proper field types and references\n- Check for ACLs and permissions\n- Handle large datasets with pagination\n\n### Script Development\n- Use Script Includes for reusable code\n- Implement proper error handling\n- Add meaningful logging with gs.info/warn/error\n- Test in scoped applications when applicable\n\n### Widget Development\n- Ensure HTML/Client/Server coherence\n- Use Angular providers correctly\n- Implement proper data binding\n- Test across different themes and portals\n\n### Flow Development\n- Use proper trigger conditions\n- Implement error handling paths\n- Add appropriate logging actions\n- Test with various data scenarios\n\n## MCP Server Capabilities\n\nSnow-Flow includes 12 specialized MCP servers, each providing specific ServiceNow capabilities:\n\n### 1. ServiceNow Deployment Server\n**Purpose:** Widget and artifact deployment with coherence validation\n\n**Key Tools:**\n- `snow_deploy_widget` - Deploy widgets with HTML/Client/Server validation\n- `snow_deploy_portal_page` - Deploy portal pages\n- `snow_deploy_flow` - Deploy Flow Designer flows\n- `snow_create_update_set` - Create update sets\n- `snow_validate_deployment` - Validate deployed artifacts\n- `snow_rollback_deployment` - Rollback failed deployments\n\n**Special Features:**\n- Automatic widget coherence validation\n- Data flow contract verification\n- Method implementation checking\n- CSS class validation\n\n### 2. ServiceNow Operations Server\n**Purpose:** Core ServiceNow operations and queries\n\n**Key Tools:**\n- `snow_query_table` - Universal table querying with pagination\n- `snow_create_incident` - Create and manage incidents\n- `snow_update_record` - Update any table record\n- `snow_delete_record` - Delete records with validation\n- `snow_discover_table_fields` - Discover table schema\n- `snow_cmdb_search` - Search Configuration Management Database\n\n**Features:**\n- Full CRUD operations on any table\n- Advanced query capabilities\n- Field discovery and validation\n- Relationship navigation\n\n### 3. ServiceNow Automation Server\n**Purpose:** Script execution and automation\n\n**Key Tools:**\n- `snow_execute_script_with_output` - Execute scripts with output capture\n- `snow_get_script_output` - Retrieve script execution history\n- `snow_execute_script_sync` - Synchronous script execution\n- `snow_get_logs` - Access system logs\n- `snow_test_rest_connection` - Test REST integrations\n- `snow_trace_execution` - Trace script execution\n- `snow_schedule_job` - Create scheduled jobs\n- `snow_create_event` - Trigger system events\n\n**Features:**\n- Full output capture (gs.print/info/warn/error)\n- Execution history tracking\n- System log access\n- REST message testing\n- Performance tracing\n\n### 4. ServiceNow Platform Development Server\n**Purpose:** Platform development artifacts\n\n**Key Tools:**\n- `snow_create_script_include` - Create reusable scripts\n- `snow_create_business_rule` - Create business rules\n- `snow_create_client_script` - Create client-side scripts\n- `snow_create_ui_policy` - Create UI policies\n- `snow_create_ui_action` - Create UI actions\n- `snow_create_ui_page` - Create UI pages\n\n**Features:**\n- Full artifact creation\n- Proper scoping support\n- Condition builder integration\n- Script validation\n\n### 5. ServiceNow Integration Server\n**Purpose:** Integration and data management\n\n**Key Tools:**\n- `snow_create_rest_message` - Create REST integrations\n- `snow_create_transform_map` - Create data transformation maps\n- `snow_create_import_set` - Manage import sets\n- `snow_test_web_service` - Test web services\n- `snow_configure_email` - Configure email settings\n\n**Features:**\n- REST/SOAP integration\n- Data transformation\n- Import/Export capabilities\n- Email configuration\n\n### 6. ServiceNow System Properties Server\n**Purpose:** System property management\n\n**Key Tools:**\n- `snow_property_get` - Retrieve property values\n- `snow_property_set` - Set property values\n- `snow_property_list` - List properties by pattern\n- `snow_property_delete` - Remove properties\n- `snow_property_bulk_update` - Bulk operations\n- `snow_property_export` - Export to JSON\n- `snow_property_import` - Import from JSON\n\n**Features:**\n- Full CRUD on sys_properties\n- Bulk operations\n- Import/Export capabilities\n- Property validation\n\n### 7. ServiceNow Update Set Server\n**Purpose:** Change management and deployment\n\n**Key Tools:**\n- `snow_create_update_set` - Create new update sets\n- `snow_switch_update_set` - Switch active update set\n- `snow_complete_update_set` - Mark as complete\n- `snow_preview_update_set` - Preview changes\n- `snow_export_update_set` - Export as XML\n\n**Features:**\n- Full update set lifecycle\n- Change tracking\n- XML export/import\n- Conflict detection\n\n### 8. ServiceNow Development Assistant Server\n**Purpose:** Code generation and best practices\n\n**Key Tools:**\n- `snow_generate_code` - Generate ServiceNow code\n- `snow_suggest_pattern` - Suggest design patterns\n- `snow_review_code` - Code review and analysis\n- `snow_optimize_performance` - Performance recommendations\n\n**Features:**\n- Pattern-based code generation\n- Best practice enforcement\n- Performance optimization\n- Security review\n\n### 9. ServiceNow Security & Compliance Server\n**Purpose:** Security and compliance management\n\n**Key Tools:**\n- `snow_create_security_policy` - Create security policies\n- `snow_audit_compliance` - Compliance auditing\n- `snow_scan_vulnerabilities` - Vulnerability scanning\n- `snow_assess_risk` - Risk assessment\n- `snow_review_access_control` - ACL review\n\n**Features:**\n- SOX/GDPR/HIPAA compliance\n- Security policy management\n- Vulnerability assessment\n- Access control validation\n\n### 10. ServiceNow Reporting & Analytics Server\n**Purpose:** Reporting and data visualization\n\n**Key Tools:**\n- `snow_create_report` - Create reports\n- `snow_create_dashboard` - Create dashboards\n- `snow_define_kpi` - Define KPIs\n- `snow_schedule_report` - Schedule report delivery\n- `snow_analyze_data_quality` - Data quality analysis\n\n**Features:**\n- Advanced reporting\n- Dashboard creation\n- KPI management\n- Scheduled delivery\n\n### 11. ServiceNow Machine Learning Server\n**Purpose:** AI/ML capabilities\n\n**Key Tools:**\n- `snow_train_classifier` - Train incident classifier\n- `snow_predict_change_risk` - Predict change risks\n- `snow_detect_anomalies` - Anomaly detection\n- `snow_forecast_incidents` - Incident forecasting\n- `snow_optimize_process` - Process optimization\n\n**Features:**\n- Predictive analytics\n- Pattern recognition\n- Anomaly detection\n- Process optimization\n\n### 12. Snow-Flow Orchestration Server\n**Purpose:** Multi-agent coordination and task management\n\n**Key Tools:**\n- `snow_swarm_init` - Initialize agent swarms\n- `snow_agent_spawn` - Create specialized agents\n- `snow_task_orchestrate` - Orchestrate complex tasks\n- `snow_memory_store` - Persistent memory storage\n- `snow_neural_train` - Train neural networks\n- `snow_performance_analyze` - Performance analysis\n\n**Features:**\n- Multi-agent coordination\n- Task orchestration\n- Neural network training (TensorFlow.js)\n- Memory management\n- Performance monitoring\n\n## Debugging Best Practices\n\n### Systematic Debugging Protocol\n\n1. **Reproduce the Issue**\n ```javascript\n // Always use ES5 and test exact code\n const result = await snow_execute_script_with_output({\n script: `/* Exact failing code in ES5 */`\n });\n ```\n\n2. **Verify Dependencies**\n - Check all referenced tables exist\n - Verify all properties are set\n - Confirm all fields are present\n - Test all integrations work\n\n3. **Test in Context**\n - Use same scope and variables\n - Include same imports\n - Test with same data\n\n4. **Apply Evidence-Based Fixes**\n - Fix only confirmed issues\n - Document why changes were made\n - Test fixes thoroughly\n\n### Common Verification Patterns\n\n**Table Verification:**\n```javascript\nvar table = new GlideRecord('table_name');\ngs.info('Table exists: ' + table.isValid());\n```\n\n**Property Verification:**\n```javascript\nvar prop = gs.getProperty('property.name');\ngs.info('Property value: ' + (prop || 'NOT SET'));\n```\n\n**Field Verification:**\n```javascript\nvar gr = new GlideRecord('table');\nvar element = gr.getElement('field_name');\ngs.info('Field exists: ' + (element ? 'Yes' : 'No'));\n```\n\n## Command Reference\n\n### Core Commands\n- `./snow-flow start` - Start orchestration system\n- `./snow-flow status` - System status\n- `./snow-flow monitor` - Real-time monitoring\n\n### Agent Management\n- `./snow-flow agent spawn <type>` - Create agents\n- `./snow-flow agent list` - List active agents\n\n### Task Management\n- `./snow-flow task create` - Create tasks\n- `./snow-flow task list` - View task queue\n\n### Memory Operations\n- `./snow-flow memory store <key> <data>` - Store data\n- `./snow-flow memory get <key>` - Retrieve data\n- `./snow-flow memory list` - List all keys\n\n### SPARC Modes\n- `./snow-flow sparc \"<task>\"` - Orchestrator mode\n- `./snow-flow sparc run <mode> \"<task>\"` - Specific mode\n- `./snow-flow sparc tdd \"<feature>\"` - Test-driven development\n\n### Swarm Coordination\n- `./snow-flow swarm \"<objective>\"` - Multi-agent coordination\n- Options: `--strategy`, `--mode`, `--parallel`, `--monitor`\n\n## Workflow Guidelines\n\n### Development Workflow\n1. **Plan** - Use TodoWrite for task management\n2. **Verify** - Check existing resources\n3. **Develop** - Follow ES5 standards\n4. **Test** - Use background scripts\n5. **Deploy** - Use update sets\n6. **Validate** - Verify deployment\n\n### Testing Workflow\n1. Run unit tests with background scripts\n2. Test integrations with REST tools\n3. Validate UI with widget coherence\n4. Check performance with tracing\n5. Review logs for errors\n\n### Debugging Workflow\n1. Reproduce issue exactly\n2. Gather evidence with scripts\n3. Verify all assumptions\n4. Apply minimal fixes\n5. Test thoroughly\n6. Document changes\n\n## Important Reminders\n\n### Always Remember\n- Every ServiceNow instance is unique\n- Custom implementations exist that you don't know about\n- Preview/beta features may be available\n- Organization-specific configurations are common\n- Test everything before making assumptions\n\n### Never Assume\n- That something doesn't exist without verification\n- That configurations are wrong without testing\n- That APIs aren't available without checking\n- That code won't work without running it\n- That you know better than existing implementations\n\n### Golden Rules\n1. **Verify First** - Test before declaring broken\n2. **ES5 Only** - No modern JavaScript in ServiceNow\n3. **Evidence-Based** - Make decisions on facts, not assumptions\n4. **Minimal Changes** - Fix only what's broken\n5. **Respect Context** - Understand why things exist as they do\n\n## Conclusion\n\nSnow-Flow is a powerful framework for ServiceNow development that emphasizes verification, testing, and evidence-based decision making. By following these guidelines and best practices, you ensure reliable, maintainable, and effective ServiceNow solutions.\n\nRemember: Your job is to solve problems, not to judge implementations. Every environment has its reasons for existing configurations. Verify, test, and respect what you find.";
2
+ //# sourceMappingURL=claude-md-template.d.ts.map
@@ -0,0 +1,546 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLAUDE_MD_TEMPLATE = void 0;
4
+ exports.CLAUDE_MD_TEMPLATE = `# Snow-Flow Configuration & Best Practices
5
+
6
+ This document provides comprehensive instructions for Snow-Flow, an advanced ServiceNow development and orchestration framework powered by Claude AI.
7
+
8
+ ## Table of Contents
9
+ 1. [Core Philosophy](#core-philosophy)
10
+ 2. [Fundamental Rules](#fundamental-rules)
11
+ 3. [ServiceNow Development Standards](#servicenow-development-standards)
12
+ 4. [MCP Server Capabilities](#mcp-server-capabilities)
13
+ 5. [Debugging Best Practices](#debugging-best-practices)
14
+ 6. [Command Reference](#command-reference)
15
+ 7. [Workflow Guidelines](#workflow-guidelines)
16
+
17
+ ## Core Philosophy
18
+
19
+ ### The Prime Directive: Verify, Don't Assume
20
+
21
+ Snow-Flow operates on evidence-based development. Never make assumptions about what exists or doesn't exist in a ServiceNow environment. Every environment is unique with custom tables, fields, integrations, and configurations that you cannot predict.
22
+
23
+ **Cardinal Rules:**
24
+ 1. If code references something, it probably exists
25
+ 2. Test before declaring something broken
26
+ 3. Verify before modifying
27
+ 4. Fix only what's confirmed broken
28
+ 5. Respect existing configurations
29
+
30
+ ### The Verification-First Approach
31
+
32
+ \`\`\`javascript
33
+ // Before claiming anything doesn't work or exist:
34
+ // Step 1: Test the actual implementation
35
+ const verify = await snow_execute_script_with_output({
36
+ script: \`/* Test the exact code or resource */\`
37
+ });
38
+
39
+ // Step 2: Check if resources exist
40
+ const tableCheck = await snow_discover_table_fields({
41
+ table_name: 'potentially_custom_table'
42
+ });
43
+
44
+ // Step 3: Validate configurations
45
+ const propertyCheck = await snow_property_manager({
46
+ action: 'get',
47
+ name: 'system.property'
48
+ });
49
+
50
+ // Step 4: Only then make informed decisions
51
+ \`\`\`
52
+
53
+ ## Fundamental Rules
54
+
55
+ ### Rule 1: ES5 JavaScript Only in ServiceNow
56
+
57
+ ServiceNow uses the Rhino JavaScript engine which supports only ES5. Modern JavaScript syntax will fail.
58
+
59
+ **Never Use:**
60
+ - \`const\` or \`let\` - use \`var\`
61
+ - Arrow functions \`() => {}\` - use \`function() {}\`
62
+ - Template literals \`\` \`\${var}\` \`\` - use string concatenation
63
+ - Destructuring \`{a, b} = obj\` - use explicit property access
64
+ - \`for...of\` loops - use traditional \`for\` loops
65
+ - Default parameters - use \`typeof\` checks
66
+ - \`async/await\` - use callbacks or GlideAjax
67
+
68
+ **Always Use:**
69
+ \`\`\`javascript
70
+ // ES5 compatible code
71
+ var name = 'value';
72
+ function processData() {
73
+ return 'result';
74
+ }
75
+ var message = 'Hello ' + userName;
76
+ for (var i = 0; i < array.length; i++) {
77
+ var item = array[i];
78
+ }
79
+ \`\`\`
80
+
81
+ ### Rule 2: Background Scripts as Primary Debug Tool
82
+
83
+ Background scripts provide immediate, factual feedback from the actual ServiceNow instance. Use them extensively for verification and debugging.
84
+
85
+ \`\`\`javascript
86
+ // Universal verification pattern
87
+ const verify = await snow_execute_script_with_output({
88
+ script: \`
89
+ gs.info('=== VERIFICATION TEST ===');
90
+
91
+ // Test table existence
92
+ var table = new GlideRecord('table_name');
93
+ gs.info('Table valid: ' + table.isValid());
94
+
95
+ // Test property existence
96
+ var prop = gs.getProperty('property.name');
97
+ gs.info('Property: ' + (prop || 'NOT SET'));
98
+
99
+ // Test actual code
100
+ try {
101
+ // User's code here
102
+ gs.info('SUCCESS');
103
+ } catch(e) {
104
+ gs.error('ERROR: ' + e.message);
105
+ }
106
+ \`
107
+ });
108
+ \`\`\`
109
+
110
+ ### Rule 3: Widget Coherence - Critical Client-Server Communication
111
+
112
+ ServiceNow widgets MUST have perfect communication between client and server scripts. This is not optional - widgets fail when these components don't talk to each other correctly.
113
+
114
+ **The Three-Way Contract:**
115
+
116
+ **Server Script Must:**
117
+ - Initialize all \`data\` properties that HTML will reference
118
+ - Handle every \`input.action\` that client sends
119
+ - Return data in the format client expects
120
+
121
+ **Client Script Must:**
122
+ - Implement every method that HTML calls via \`ng-click\`
123
+ - Use \`c.server.get({action: 'name'})\` for server communication
124
+ - Update \`c.data\` when server responds
125
+
126
+ **HTML Template Must:**
127
+ - Only reference \`data\` properties that server provides
128
+ - Only call methods that client implements
129
+ - Use correct Angular directives and bindings
130
+
131
+ **Critical Communication Points:**
132
+
133
+ 1. **Server → Client Data Flow**
134
+ - Server sets \`data.property\`
135
+ - Client receives via \`c.data.property\`
136
+ - HTML displays with \`{{data.property}}\`
137
+
138
+ 2. **Client → Server Requests**
139
+ - Client sends \`c.server.get({action: 'name'})\`
140
+ - Server receives via \`input.action\`
141
+ - Server processes and returns updated \`data\`
142
+
143
+ 3. **HTML → Client Method Calls**
144
+ - HTML has \`ng-click="methodName()"\`
145
+ - Client must have \`$scope.methodName = function()\`
146
+ - Method typically calls server with \`c.server.get()\`
147
+
148
+ **Common Failures to Avoid:**
149
+ - Action name mismatches between client and server
150
+ - Method name mismatches between HTML and client
151
+ - Property name mismatches between server and HTML
152
+ - Missing handlers for client requests
153
+ - Orphaned data properties or methods
154
+
155
+ **Coherence Validation Checklist:**
156
+ - [ ] Every \`data.property\` in server is used in HTML/client
157
+ - [ ] Every \`ng-click\` in HTML has matching \`$scope.method\` in client
158
+ - [ ] Every \`c.server.get({action})\` in client has matching \`if(input.action)\` in server
159
+ - [ ] Data flows correctly: Server → HTML → Client → Server
160
+ - [ ] No orphaned methods or unused data properties
161
+
162
+ ### Rule 4: Evidence-Based Debugging
163
+
164
+ Follow this systematic approach for all debugging:
165
+
166
+ 1. **Reproduce** - Run the exact failing code
167
+ 2. **Inventory** - List all dependencies
168
+ 3. **Verify** - Test each dependency exists
169
+ 4. **Fix** - Correct only confirmed issues
170
+
171
+ **Fix only:**
172
+ - ✅ Confirmed syntax errors
173
+ - ✅ Verified null references
174
+ - ✅ Missing dependencies (after verification)
175
+ - ✅ Real type mismatches
176
+
177
+ **Never change:**
178
+ - ❌ Unverified resources
179
+ - ❌ Configurations that "seem wrong"
180
+ - ❌ APIs you haven't tested
181
+ - ❌ Working code that could be "better"
182
+
183
+ ## ServiceNow Development Standards
184
+
185
+ ### Table Operations
186
+ - Always verify table existence before operations
187
+ - Use proper field types and references
188
+ - Check for ACLs and permissions
189
+ - Handle large datasets with pagination
190
+
191
+ ### Script Development
192
+ - Use Script Includes for reusable code
193
+ - Implement proper error handling
194
+ - Add meaningful logging with gs.info/warn/error
195
+ - Test in scoped applications when applicable
196
+
197
+ ### Widget Development
198
+ - Ensure HTML/Client/Server coherence
199
+ - Use Angular providers correctly
200
+ - Implement proper data binding
201
+ - Test across different themes and portals
202
+
203
+ ### Flow Development
204
+ - Use proper trigger conditions
205
+ - Implement error handling paths
206
+ - Add appropriate logging actions
207
+ - Test with various data scenarios
208
+
209
+ ## MCP Server Capabilities
210
+
211
+ Snow-Flow includes 12 specialized MCP servers, each providing specific ServiceNow capabilities:
212
+
213
+ ### 1. ServiceNow Deployment Server
214
+ **Purpose:** Widget and artifact deployment with coherence validation
215
+
216
+ **Key Tools:**
217
+ - \`snow_deploy_widget\` - Deploy widgets with HTML/Client/Server validation
218
+ - \`snow_deploy_portal_page\` - Deploy portal pages
219
+ - \`snow_deploy_flow\` - Deploy Flow Designer flows
220
+ - \`snow_create_update_set\` - Create update sets
221
+ - \`snow_validate_deployment\` - Validate deployed artifacts
222
+ - \`snow_rollback_deployment\` - Rollback failed deployments
223
+
224
+ **Special Features:**
225
+ - Automatic widget coherence validation
226
+ - Data flow contract verification
227
+ - Method implementation checking
228
+ - CSS class validation
229
+
230
+ ### 2. ServiceNow Operations Server
231
+ **Purpose:** Core ServiceNow operations and queries
232
+
233
+ **Key Tools:**
234
+ - \`snow_query_table\` - Universal table querying with pagination
235
+ - \`snow_create_incident\` - Create and manage incidents
236
+ - \`snow_update_record\` - Update any table record
237
+ - \`snow_delete_record\` - Delete records with validation
238
+ - \`snow_discover_table_fields\` - Discover table schema
239
+ - \`snow_cmdb_search\` - Search Configuration Management Database
240
+
241
+ **Features:**
242
+ - Full CRUD operations on any table
243
+ - Advanced query capabilities
244
+ - Field discovery and validation
245
+ - Relationship navigation
246
+
247
+ ### 3. ServiceNow Automation Server
248
+ **Purpose:** Script execution and automation
249
+
250
+ **Key Tools:**
251
+ - \`snow_execute_script_with_output\` - Execute scripts with output capture
252
+ - \`snow_get_script_output\` - Retrieve script execution history
253
+ - \`snow_execute_script_sync\` - Synchronous script execution
254
+ - \`snow_get_logs\` - Access system logs
255
+ - \`snow_test_rest_connection\` - Test REST integrations
256
+ - \`snow_trace_execution\` - Trace script execution
257
+ - \`snow_schedule_job\` - Create scheduled jobs
258
+ - \`snow_create_event\` - Trigger system events
259
+
260
+ **Features:**
261
+ - Full output capture (gs.print/info/warn/error)
262
+ - Execution history tracking
263
+ - System log access
264
+ - REST message testing
265
+ - Performance tracing
266
+
267
+ ### 4. ServiceNow Platform Development Server
268
+ **Purpose:** Platform development artifacts
269
+
270
+ **Key Tools:**
271
+ - \`snow_create_script_include\` - Create reusable scripts
272
+ - \`snow_create_business_rule\` - Create business rules
273
+ - \`snow_create_client_script\` - Create client-side scripts
274
+ - \`snow_create_ui_policy\` - Create UI policies
275
+ - \`snow_create_ui_action\` - Create UI actions
276
+ - \`snow_create_ui_page\` - Create UI pages
277
+
278
+ **Features:**
279
+ - Full artifact creation
280
+ - Proper scoping support
281
+ - Condition builder integration
282
+ - Script validation
283
+
284
+ ### 5. ServiceNow Integration Server
285
+ **Purpose:** Integration and data management
286
+
287
+ **Key Tools:**
288
+ - \`snow_create_rest_message\` - Create REST integrations
289
+ - \`snow_create_transform_map\` - Create data transformation maps
290
+ - \`snow_create_import_set\` - Manage import sets
291
+ - \`snow_test_web_service\` - Test web services
292
+ - \`snow_configure_email\` - Configure email settings
293
+
294
+ **Features:**
295
+ - REST/SOAP integration
296
+ - Data transformation
297
+ - Import/Export capabilities
298
+ - Email configuration
299
+
300
+ ### 6. ServiceNow System Properties Server
301
+ **Purpose:** System property management
302
+
303
+ **Key Tools:**
304
+ - \`snow_property_get\` - Retrieve property values
305
+ - \`snow_property_set\` - Set property values
306
+ - \`snow_property_list\` - List properties by pattern
307
+ - \`snow_property_delete\` - Remove properties
308
+ - \`snow_property_bulk_update\` - Bulk operations
309
+ - \`snow_property_export\` - Export to JSON
310
+ - \`snow_property_import\` - Import from JSON
311
+
312
+ **Features:**
313
+ - Full CRUD on sys_properties
314
+ - Bulk operations
315
+ - Import/Export capabilities
316
+ - Property validation
317
+
318
+ ### 7. ServiceNow Update Set Server
319
+ **Purpose:** Change management and deployment
320
+
321
+ **Key Tools:**
322
+ - \`snow_create_update_set\` - Create new update sets
323
+ - \`snow_switch_update_set\` - Switch active update set
324
+ - \`snow_complete_update_set\` - Mark as complete
325
+ - \`snow_preview_update_set\` - Preview changes
326
+ - \`snow_export_update_set\` - Export as XML
327
+
328
+ **Features:**
329
+ - Full update set lifecycle
330
+ - Change tracking
331
+ - XML export/import
332
+ - Conflict detection
333
+
334
+ ### 8. ServiceNow Development Assistant Server
335
+ **Purpose:** Code generation and best practices
336
+
337
+ **Key Tools:**
338
+ - \`snow_generate_code\` - Generate ServiceNow code
339
+ - \`snow_suggest_pattern\` - Suggest design patterns
340
+ - \`snow_review_code\` - Code review and analysis
341
+ - \`snow_optimize_performance\` - Performance recommendations
342
+
343
+ **Features:**
344
+ - Pattern-based code generation
345
+ - Best practice enforcement
346
+ - Performance optimization
347
+ - Security review
348
+
349
+ ### 9. ServiceNow Security & Compliance Server
350
+ **Purpose:** Security and compliance management
351
+
352
+ **Key Tools:**
353
+ - \`snow_create_security_policy\` - Create security policies
354
+ - \`snow_audit_compliance\` - Compliance auditing
355
+ - \`snow_scan_vulnerabilities\` - Vulnerability scanning
356
+ - \`snow_assess_risk\` - Risk assessment
357
+ - \`snow_review_access_control\` - ACL review
358
+
359
+ **Features:**
360
+ - SOX/GDPR/HIPAA compliance
361
+ - Security policy management
362
+ - Vulnerability assessment
363
+ - Access control validation
364
+
365
+ ### 10. ServiceNow Reporting & Analytics Server
366
+ **Purpose:** Reporting and data visualization
367
+
368
+ **Key Tools:**
369
+ - \`snow_create_report\` - Create reports
370
+ - \`snow_create_dashboard\` - Create dashboards
371
+ - \`snow_define_kpi\` - Define KPIs
372
+ - \`snow_schedule_report\` - Schedule report delivery
373
+ - \`snow_analyze_data_quality\` - Data quality analysis
374
+
375
+ **Features:**
376
+ - Advanced reporting
377
+ - Dashboard creation
378
+ - KPI management
379
+ - Scheduled delivery
380
+
381
+ ### 11. ServiceNow Machine Learning Server
382
+ **Purpose:** AI/ML capabilities
383
+
384
+ **Key Tools:**
385
+ - \`snow_train_classifier\` - Train incident classifier
386
+ - \`snow_predict_change_risk\` - Predict change risks
387
+ - \`snow_detect_anomalies\` - Anomaly detection
388
+ - \`snow_forecast_incidents\` - Incident forecasting
389
+ - \`snow_optimize_process\` - Process optimization
390
+
391
+ **Features:**
392
+ - Predictive analytics
393
+ - Pattern recognition
394
+ - Anomaly detection
395
+ - Process optimization
396
+
397
+ ### 12. Snow-Flow Orchestration Server
398
+ **Purpose:** Multi-agent coordination and task management
399
+
400
+ **Key Tools:**
401
+ - \`snow_swarm_init\` - Initialize agent swarms
402
+ - \`snow_agent_spawn\` - Create specialized agents
403
+ - \`snow_task_orchestrate\` - Orchestrate complex tasks
404
+ - \`snow_memory_store\` - Persistent memory storage
405
+ - \`snow_neural_train\` - Train neural networks
406
+ - \`snow_performance_analyze\` - Performance analysis
407
+
408
+ **Features:**
409
+ - Multi-agent coordination
410
+ - Task orchestration
411
+ - Neural network training (TensorFlow.js)
412
+ - Memory management
413
+ - Performance monitoring
414
+
415
+ ## Debugging Best Practices
416
+
417
+ ### Systematic Debugging Protocol
418
+
419
+ 1. **Reproduce the Issue**
420
+ \`\`\`javascript
421
+ // Always use ES5 and test exact code
422
+ const result = await snow_execute_script_with_output({
423
+ script: \`/* Exact failing code in ES5 */\`
424
+ });
425
+ \`\`\`
426
+
427
+ 2. **Verify Dependencies**
428
+ - Check all referenced tables exist
429
+ - Verify all properties are set
430
+ - Confirm all fields are present
431
+ - Test all integrations work
432
+
433
+ 3. **Test in Context**
434
+ - Use same scope and variables
435
+ - Include same imports
436
+ - Test with same data
437
+
438
+ 4. **Apply Evidence-Based Fixes**
439
+ - Fix only confirmed issues
440
+ - Document why changes were made
441
+ - Test fixes thoroughly
442
+
443
+ ### Common Verification Patterns
444
+
445
+ **Table Verification:**
446
+ \`\`\`javascript
447
+ var table = new GlideRecord('table_name');
448
+ gs.info('Table exists: ' + table.isValid());
449
+ \`\`\`
450
+
451
+ **Property Verification:**
452
+ \`\`\`javascript
453
+ var prop = gs.getProperty('property.name');
454
+ gs.info('Property value: ' + (prop || 'NOT SET'));
455
+ \`\`\`
456
+
457
+ **Field Verification:**
458
+ \`\`\`javascript
459
+ var gr = new GlideRecord('table');
460
+ var element = gr.getElement('field_name');
461
+ gs.info('Field exists: ' + (element ? 'Yes' : 'No'));
462
+ \`\`\`
463
+
464
+ ## Command Reference
465
+
466
+ ### Core Commands
467
+ - \`./snow-flow start\` - Start orchestration system
468
+ - \`./snow-flow status\` - System status
469
+ - \`./snow-flow monitor\` - Real-time monitoring
470
+
471
+ ### Agent Management
472
+ - \`./snow-flow agent spawn <type>\` - Create agents
473
+ - \`./snow-flow agent list\` - List active agents
474
+
475
+ ### Task Management
476
+ - \`./snow-flow task create\` - Create tasks
477
+ - \`./snow-flow task list\` - View task queue
478
+
479
+ ### Memory Operations
480
+ - \`./snow-flow memory store <key> <data>\` - Store data
481
+ - \`./snow-flow memory get <key>\` - Retrieve data
482
+ - \`./snow-flow memory list\` - List all keys
483
+
484
+ ### SPARC Modes
485
+ - \`./snow-flow sparc "<task>"\` - Orchestrator mode
486
+ - \`./snow-flow sparc run <mode> "<task>"\` - Specific mode
487
+ - \`./snow-flow sparc tdd "<feature>"\` - Test-driven development
488
+
489
+ ### Swarm Coordination
490
+ - \`./snow-flow swarm "<objective>"\` - Multi-agent coordination
491
+ - Options: \`--strategy\`, \`--mode\`, \`--parallel\`, \`--monitor\`
492
+
493
+ ## Workflow Guidelines
494
+
495
+ ### Development Workflow
496
+ 1. **Plan** - Use TodoWrite for task management
497
+ 2. **Verify** - Check existing resources
498
+ 3. **Develop** - Follow ES5 standards
499
+ 4. **Test** - Use background scripts
500
+ 5. **Deploy** - Use update sets
501
+ 6. **Validate** - Verify deployment
502
+
503
+ ### Testing Workflow
504
+ 1. Run unit tests with background scripts
505
+ 2. Test integrations with REST tools
506
+ 3. Validate UI with widget coherence
507
+ 4. Check performance with tracing
508
+ 5. Review logs for errors
509
+
510
+ ### Debugging Workflow
511
+ 1. Reproduce issue exactly
512
+ 2. Gather evidence with scripts
513
+ 3. Verify all assumptions
514
+ 4. Apply minimal fixes
515
+ 5. Test thoroughly
516
+ 6. Document changes
517
+
518
+ ## Important Reminders
519
+
520
+ ### Always Remember
521
+ - Every ServiceNow instance is unique
522
+ - Custom implementations exist that you don't know about
523
+ - Preview/beta features may be available
524
+ - Organization-specific configurations are common
525
+ - Test everything before making assumptions
526
+
527
+ ### Never Assume
528
+ - That something doesn't exist without verification
529
+ - That configurations are wrong without testing
530
+ - That APIs aren't available without checking
531
+ - That code won't work without running it
532
+ - That you know better than existing implementations
533
+
534
+ ### Golden Rules
535
+ 1. **Verify First** - Test before declaring broken
536
+ 2. **ES5 Only** - No modern JavaScript in ServiceNow
537
+ 3. **Evidence-Based** - Make decisions on facts, not assumptions
538
+ 4. **Minimal Changes** - Fix only what's broken
539
+ 5. **Respect Context** - Understand why things exist as they do
540
+
541
+ ## Conclusion
542
+
543
+ Snow-Flow is a powerful framework for ServiceNow development that emphasizes verification, testing, and evidence-based decision making. By following these guidelines and best practices, you ensure reliable, maintainable, and effective ServiceNow solutions.
544
+
545
+ Remember: Your job is to solve problems, not to judge implementations. Every environment has its reasons for existing configurations. Verify, test, and respect what you find.`;
546
+ //# sourceMappingURL=claude-md-template.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.6",
3
+ "version": "3.4.7",
4
4
  "description": "ServiceNow development framework with MCP server integration. Executes background scripts using ES5 JavaScript only (ServiceNow Rhino engine requirement). Provides 12 MCP servers for ServiceNow operations including widget deployment with coherence validation, table operations, script execution, and system property management.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",