snow-flow 3.4.11 → 3.4.13

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
@@ -852,16 +852,58 @@ ${hasIntelligentFeatures ? `✅ **INTELLIGENT MODE ACTIVE** - The following feat
852
852
 
853
853
  **CRITICAL RULE**: All agents MUST attempt to use ServiceNow MCP tools first, regardless of authentication status.
854
854
 
855
- ### 📝 Background Script Execution Settings
856
- ${options.autoConfirm ? '⚠️ **AUTO-CONFIRM MODE ENABLED**: When calling snow_execute_background_script, ALWAYS add autoConfirm: true parameter to skip user confirmation.\n```javascript\nsnow_execute_background_script({\n script: "your ES5 script here",\n description: "Clear description",\n autoConfirm: true // ⚠️ User enabled auto-confirm mode\n})\n```' : options.autoConfirm === false ? '🔒 **FORCE CONFIRM MODE**: All background scripts will require user confirmation, even simple ones.' : '🤚 **DEFAULT MODE**: Background scripts will ask for user confirmation based on risk level.'}
857
-
858
- #### Current MCP Tools Available (Snow-Flow v3.3.4)
859
- ${isAuthenticated ? '✅ Authentication detected - full deployment capabilities' : '⚠️ No authentication detected - MCP tools will provide specific instructions if auth needed'}
860
-
861
- Your agents MUST use these MCP tools IN THIS ORDER:
862
-
863
- 🔍 **PRE-FLIGHT CHECKS** (Always do first!):
864
- 1. \`snow_auth_diagnostics\` - Test authentication and permissions
855
+ ### 🚨 MANDATORY: ES5 JavaScript Only for ALL ServiceNow Scripts
856
+ **⚠️ SERVICENOW RHINO ENGINE = ES5 ONLY - NO MODERN SYNTAX!**
857
+
858
+ **Before writing ANY background script, verify it's ES5-compliant:**\n` ``, javascript, n; // ❌ THIS BREAKS SERVICENOW:\nconst data = items.filter(x => x.active);\nlet results = data.map(item => ({\n id: item.sys_id,\n name: item.name\n}));\n\n// ✅ THIS WORKS IN SERVICENOW:\nvar data = [];\nfor (var i = 0; i < items.length; i++) {\n if (items[i].active) {\n data.push(items[i]);\n }\n}\nvar results = [];\nfor (var j = 0; j < data.length; j++) {\n results.push({\n id: data[j].sys_id,\n name: data[j].name\n });\n}\n```
859
+ ** ;
860
+ If;
861
+ you;
862
+ use;
863
+ ES6 + syntax, the;
864
+ script;
865
+ WILL;
866
+ FAIL;
867
+ with (SyntaxError ** )
868
+ #;
869
+ #;
870
+ Background;
871
+ Script;
872
+ Execution;
873
+ Settings;
874
+ $;
875
+ {
876
+ options.autoConfirm ? '⚠️ **AUTO-CONFIRM MODE ENABLED**: When calling snow_execute_background_script, ALWAYS add autoConfirm: true parameter to skip user confirmation.\n```javascript\nsnow_execute_background_script({\n script: "your ES5 script here",\n description: "Clear description",\n autoConfirm: true // ⚠️ User enabled auto-confirm mode\n})\n```' : options.autoConfirm === false ? '🔒 **FORCE CONFIRM MODE**: All background scripts will require user confirmation, even simple ones.' : '🤚 **DEFAULT MODE**: Background scripts will ask for user confirmation based on risk level.';
877
+ }
878
+ #;
879
+ #;
880
+ #;
881
+ #;
882
+ Current;
883
+ MCP;
884
+ Tools;
885
+ Available(Snow - Flow, v3, .3, .4);
886
+ $;
887
+ {
888
+ isAuthenticated ? '✅ Authentication detected - full deployment capabilities' : '⚠️ No authentication detected - MCP tools will provide specific instructions if auth needed';
889
+ }
890
+ Your;
891
+ agents;
892
+ MUST;
893
+ use;
894
+ these;
895
+ MCP;
896
+ tools;
897
+ IN;
898
+ THIS;
899
+ ORDER: ;
900
+ ** PRE - FLIGHT;
901
+ CHECKS ** (Always);
902
+ do
903
+ first;
904
+ while ();
905
+ 1.;
906
+ `snow_auth_diagnostics\` - Test authentication and permissions
865
907
  2. If auth fails, the tool provides specific instructions
866
908
  3. Continue with appropriate strategy based on auth status
867
909
 
@@ -38,7 +38,7 @@ class ServiceNowAutomationMCP {
38
38
  type: 'object',
39
39
  properties: {
40
40
  name: { type: 'string', description: 'Scheduled Job name' },
41
- script: { type: 'string', description: 'JavaScript code to execute' },
41
+ script: { type: 'string', description: '🚨 ES5 ONLY! JavaScript code to execute (no const/let/arrows/templates - Rhino engine)' },
42
42
  description: { type: 'string', description: 'Job description' },
43
43
  schedule: { type: 'string', description: 'Schedule pattern (daily, weekly, monthly, or cron)' },
44
44
  active: { type: 'boolean', description: 'Job active status' },
@@ -56,8 +56,8 @@ class ServiceNowAutomationMCP {
56
56
  properties: {
57
57
  name: { type: 'string', description: 'Event Rule name' },
58
58
  eventName: { type: 'string', description: 'Event name to listen for' },
59
- condition: { type: 'string', description: 'Event condition script' },
60
- script: { type: 'string', description: 'Action script to execute' },
59
+ condition: { type: 'string', description: 'Event condition script (ES5 only!)' },
60
+ script: { type: 'string', description: '🚨 ES5 ONLY! Action script to execute (no const/let/arrows/templates - Rhino engine)' },
61
61
  description: { type: 'string', description: 'Rule description' },
62
62
  active: { type: 'boolean', description: 'Rule active status' },
63
63
  order: { type: 'number', description: 'Execution order' }
@@ -179,13 +179,13 @@ class ServiceNowAutomationMCP {
179
179
  },
180
180
  {
181
181
  name: 'snow_execute_background_script',
182
- description: '🚨 REQUIRES USER CONFIRMATION (unless autoConfirm=true): Executes a JavaScript background script in ServiceNow. Script runs in server-side context with full API access. By default asks for user approval.',
182
+ description: '🚨 REQUIRES USER CONFIRMATION (unless autoConfirm=true): Executes JavaScript background script in ServiceNow. ⚠️ CRITICAL: Script MUST be ES5-only (no const/let/arrow functions/template literals) - ES6+ will cause SyntaxError on Rhino engine!',
183
183
  inputSchema: {
184
184
  type: 'object',
185
185
  properties: {
186
186
  script: {
187
187
  type: 'string',
188
- description: 'JavaScript code to execute in background. Has access to GlideRecord, GlideAggregate, gs, etc.'
188
+ description: '🚨 ES5 JAVASCRIPT ONLY! Use var (not const/let), function(){} (not arrows), string concatenation (not templates). Has access to GlideRecord, GlideAggregate, gs, etc.'
189
189
  },
190
190
  description: {
191
191
  type: 'string',
@@ -308,11 +308,11 @@ class ServiceNowAutomationMCP {
308
308
  },
309
309
  {
310
310
  name: 'snow_execute_script_with_output',
311
- description: 'Executes a background script and retrieves the actual output. Waits for execution to complete and returns the results.',
311
+ description: 'Executes a background script and retrieves the actual output. ⚠️ CRITICAL: Script MUST be ES5-only (Rhino engine) - no const/let/arrows/templates!',
312
312
  inputSchema: {
313
313
  type: 'object',
314
314
  properties: {
315
- script: { type: 'string', description: 'JavaScript code to execute' },
315
+ script: { type: 'string', description: '🚨 ES5 ONLY! Use var, function(){}, string+concatenation. JavaScript code to execute on ServiceNow server.' },
316
316
  return_output: { type: 'boolean', description: 'Return script output', default: true },
317
317
  max_wait: { type: 'number', description: 'Maximum wait time in milliseconds', default: 5000 },
318
318
  capture_logs: { type: 'boolean', description: 'Capture system logs during execution', default: true }
@@ -333,11 +333,11 @@ class ServiceNowAutomationMCP {
333
333
  },
334
334
  {
335
335
  name: 'snow_execute_script_sync',
336
- description: 'Synchronously executes a script and waits for the result. Returns output immediately.',
336
+ description: 'Synchronously executes a script and waits for the result. ⚠️ CRITICAL: Script MUST be ES5-only (Rhino engine)!',
337
337
  inputSchema: {
338
338
  type: 'object',
339
339
  properties: {
340
- script: { type: 'string', description: 'JavaScript code to execute' },
340
+ script: { type: 'string', description: '🚨 ES5 ONLY! No const/let/arrows/templates. JavaScript code to execute synchronously.' },
341
341
  timeout: { type: 'number', description: 'Timeout in milliseconds', default: 3000 },
342
342
  capture_output: { type: 'boolean', description: 'Capture and return output', default: true }
343
343
  },
@@ -1,2 +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 for Verification Only (Not Widget Updates!)\n\n**CRITICAL DISTINCTION:**\n- \u2705 Use background scripts for TESTING and VERIFICATION\n- \u274C Do NOT use background scripts to UPDATE widget fields\n- \u2705 Use `snow_update` to directly modify widget records\n- \u274C Do NOT try to import server scripts into client scripts via background scripts\n\nBackground scripts are excellent for verification and debugging, but widget updates must go through proper MCP tools.\n\n**NEW: Auto-Confirm Mode for Background Scripts (v3.4.10+)**\nYou can now skip the human-in-the-loop confirmation for trusted scripts:\n\n```javascript\n// Standard mode - requires user confirmation\nsnow_execute_background_script({\n script: \"var gr = new GlideRecord('incident'); gr.query();\",\n description: \"Query incidents\",\n allowDataModification: false\n});\n\n// Auto-confirm mode - executes immediately \u26A0\uFE0F USE WITH CAUTION!\nsnow_execute_background_script({\n script: \"var gr = new GlideRecord('incident'); gr.query();\",\n description: \"Query incidents\",\n allowDataModification: false,\n autoConfirm: true // \u26A0\uFE0F Bypasses user confirmation!\n});\n```\n\n**\u26A0\uFE0F Security Warning:**\n- Only use `autoConfirm: true` for verified, safe scripts\n- High-risk operations will still be logged\n- All auto-executions are tracked with audit IDs\n- Default behavior (without autoConfirm) remains unchanged\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- **NEVER use background scripts to update widget fields - use `snow_update` instead**\n\n### Widget Development\n\n**CRITICAL: Direct Widget Updates (Not Background Scripts!)**\n- Use `snow_update({ type: 'widget', identifier: 'widget_name', config: { /* fields to update */ }})` \n- Updates widget fields DIRECTLY on the widget record\n- Do NOT use background scripts to update widget fields\n- Do NOT try to import server scripts into client scripts\n\n**Widget Coherence Requirements:**\n- Ensure HTML/Client/Server scripts communicate properly\n- Use Angular providers correctly \n- Implement proper data binding\n- Test across different themes and portals\n\n**Creating New Widgets:**\n```javascript\nsnow_deploy({\n type: 'widget',\n config: {\n name: 'my_widget',\n title: 'My Widget', // Required for display\n template: '<div>{{data.message}}</div>', // Required HTML\n server_script: 'data.message = \"Hello\";',\n client_script: 'function($scope) { var c = this; }'\n }\n})\n```\n\n**Updating Existing Widgets:**\n```javascript\nsnow_update({\n type: 'widget',\n identifier: 'my_widget', // Name or sys_id\n config: {\n template: '<div>Updated HTML</div>', // Only update what changes\n server_script: 'data.updated = true;'\n }\n})\n```\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 16+ specialized MCP servers with over 200 tools for comprehensive ServiceNow integration:\n\n### 1. ServiceNow Deployment Server\n**Purpose:** Widget and artifact deployment with coherence validation\n\n**Key Tools:**\n- `snow_deploy` - Create NEW artifacts (widgets, pages, etc.) - use with `type: 'widget'`\n- `snow_update` - UPDATE existing artifacts - use for widget field updates\n- `snow_validate_deployment` - Validate deployed artifacts\n- `snow_rollback_deployment` - Rollback failed deployments\n- `snow_preview_widget` - Preview widget before deployment\n- `snow_widget_test` - Test widget functionality\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_query_incidents` - Query and analyze incidents\n- `snow_cmdb_search` - Search Configuration Management Database\n- `snow_user_lookup` - Find and manage users\n- `snow_operational_metrics` - Get operational metrics\n- `snow_knowledge_search` - Search knowledge base\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_background_script` - Execute background scripts (with optional autoConfirm)\n- `snow_confirm_script_execution` - Confirm script execution after user approval\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_ui_page` - Create UI pages\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\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_update_set_create` - Create new update sets\n- `snow_update_set_switch` - Switch active update set\n- `snow_update_set_current` - Get current update set\n- `snow_update_set_complete` - Mark as complete\n- `snow_update_set_export` - Export as XML\n- `snow_ensure_active_update_set` - Ensure update set is active\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:** Intelligent artifact search, editing and development assistance\n\n**Key Tools:**\n- `snow_find_artifact` - Find any ServiceNow artifact by name/type\n- `snow_edit_artifact` - Edit existing artifacts intelligently\n- `snow_get_by_sysid` - Get artifact by sys_id\n- `snow_analyze_artifact` - Analyze artifact structure and dependencies\n- `snow_comprehensive_search` - Deep search across all tables\n- `snow_analyze_requirements` - Analyze development requirements\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 with TensorFlow.js and native ML integration\n\n**Key Tools:**\n- `ml_train_incident_classifier` - Train incident classifier with LSTM neural networks\n- `ml_predict_change_risk` - Predict change risks\n- `ml_detect_anomalies` - Anomaly detection\n- `ml_forecast_incidents` - Incident forecasting with time series\n- `ml_performance_analytics` - Native Performance Analytics ML\n- `ml_hybrid_recommendation` - Hybrid ML recommendations\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- `swarm_init` - Initialize agent swarms\n- `agent_spawn` - Create specialized agents\n- `task_orchestrate` - Orchestrate complex tasks\n- `memory_search` - Search persistent memory\n- `neural_train` - Train neural networks with TensorFlow.js\n- `performance_report` - Generate performance reports\n\n### Additional Servers:\n\n**ServiceNow CMDB/Event/HR/CSM/DevOps Server** - CI management, event correlation, HR processes, customer service, DevOps pipelines\n\n**ServiceNow Knowledge & Catalog Server** - Knowledge articles, service catalog items, catalog variables and policies\n\n**ServiceNow Change/Virtual Agent/PA Server** - Change management, virtual agent NLU, predictive analytics\n\n**ServiceNow Flow/Workspace/Mobile Server** - Flow Designer, workspace configuration, mobile app management\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.";
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: \uD83D\uDEA8 ES5 JavaScript ONLY in ServiceNow - NO EXCEPTIONS!\n\n**\u26A0\uFE0F CRITICAL WARNING: ServiceNow uses Rhino engine - ES6/ES7/ES8+ WILL FAIL!**\n\nServiceNow's server-side JavaScript runs on Mozilla Rhino which **ONLY supports ES5 (2009)**. Any modern JavaScript syntax will cause **RUNTIME ERRORS**.\n\n**\u274C THESE WILL CRASH SERVICENOW (DO NOT USE):**\n```javascript\n// \u274C ES6+ features that BREAK ServiceNow:\nconst data = []; // SyntaxError: missing ; after for-loop initializer\nlet items = []; // SyntaxError: missing ; after for-loop initializer \nconst fn = () => {}; // SyntaxError: syntax error\nvar msg = `Hello ${name}`; // SyntaxError: syntax error\nfor (let item of items){} // SyntaxError: missing ; after for-loop initializer\nvar {name, id} = user; // SyntaxError: destructuring declaration not supported\narray.forEach(x => {}); // SyntaxError: syntax error \narray.map(x => x.id); // SyntaxError: syntax error\nfunction test(param = 'default') {} // SyntaxError: syntax error\nclass MyClass {} // SyntaxError: missing ; after for-loop initializer\n```\n\n**\u2705 ONLY USE ES5 SYNTAX (THIS WORKS):**\n```javascript\n// \u2705 ES5 compatible code that WORKS in ServiceNow:\nvar data = [];\nvar items = [];\nfunction fn() { return 'result'; }\nvar msg = 'Hello ' + name;\nfor (var i = 0; i < items.length; i++) {\n var item = items[i];\n}\nvar name = user.name;\nvar id = user.id;\nfor (var j = 0; j < array.length; j++) {\n // Process array[j]\n}\nfunction test(param) {\n if (typeof param === 'undefined') param = 'default';\n}\n```\n\n**\uD83D\uDD25 COMMON MISTAKES THAT BREAK SERVICENOW:**\n1. **Arrow Functions**: `() => {}` \u2192 Use `function() {}`\n2. **Template Literals**: `` `${var}` `` \u2192 Use `'text ' + var`\n3. **Let/Const**: `let x` \u2192 Use `var x`\n4. **Destructuring**: `{a, b} = obj` \u2192 Use `obj.a`, `obj.b`\n5. **For...of**: `for (x of arr)` \u2192 Use `for (var i=0; i<arr.length; i++)`\n6. **Default Parameters**: `fn(x='default')` \u2192 Use `typeof x === 'undefined'`\n7. **Array Methods with Arrows**: `.map(x => x)` \u2192 Use `.map(function(x) { return x; })`\n\n### Rule 2: Background Scripts for Verification Only (Not Widget Updates!)\n\n**CRITICAL DISTINCTION:**\n- \u2705 Use background scripts for TESTING and VERIFICATION \n- \u274C Do NOT use background scripts to UPDATE widget fields\n- \u2705 Use `snow_update` to directly modify widget records\n- \u274C Do NOT try to import server scripts into client scripts via background scripts\n\n**\uD83D\uDEA8 ES5 ENFORCEMENT FOR BACKGROUND SCRIPTS:**\nBackground scripts run on ServiceNow's server-side Rhino engine. **EVERY background script MUST be ES5-only or it will fail.**\n\n**Quick ES5 Validation Checklist:**\n- [ ] No `const` or `let` (only `var`)\n- [ ] No arrow functions `() => {}` (only `function() {}`)\n- [ ] No template literals `` `${var}` `` (only string concatenation)\n- [ ] No destructuring `{a, b} = obj` (only explicit `obj.a`)\n- [ ] No `for...of` loops (only traditional `for` loops)\n- [ ] No default parameters (use `typeof` checks)\n- [ ] No modern array methods with arrows (use traditional functions)\n\nBackground scripts are excellent for verification and debugging, but widget updates must go through proper MCP tools.\n\n**NEW: Auto-Confirm Mode for Background Scripts (v3.4.10+)**\nYou can now skip the human-in-the-loop confirmation for trusted scripts:\n\n```javascript\n// Standard mode - requires user confirmation (ES5 ONLY!)\nsnow_execute_background_script({\n script: \"var gr = new GlideRecord('incident'); gr.query();\", // \u2705 ES5 syntax\n description: \"Query incidents\",\n allowDataModification: false\n});\n\n// Auto-confirm mode - executes immediately \u26A0\uFE0F USE WITH CAUTION!\nsnow_execute_background_script({\n script: \"var gr = new GlideRecord('incident'); gr.query();\", // \u2705 ES5 syntax\n description: \"Query incidents\",\n allowDataModification: false,\n autoConfirm: true // \u26A0\uFE0F Bypasses user confirmation!\n});\n\n// \u274C WRONG - This will FAIL in ServiceNow:\n// script: \"const gr = new GlideRecord('incident'); gr.query();\", // SyntaxError!\n// script: \"incidents.forEach(i => console.log(i.number));\", // SyntaxError!\n```\n\n**\uD83D\uDEA8 ES5 Validation Required:**\nBefore using any background script tool, validate your script is ES5-only:\n- No `const`/`let` (use `var`)\n- No arrow functions (use `function()`)\n- No template literals (use string concatenation)\n- No destructuring (use explicit property access)\n\n**\u26A0\uFE0F Security Warning:**\n- Only use `autoConfirm: true` for verified, safe scripts\n- High-risk operations will still be logged\n- All auto-executions are tracked with audit IDs\n- Default behavior (without autoConfirm) remains unchanged\n\n## \uD83D\uDEA8 CRITICAL: Common ES5 Mistakes That Break ServiceNow\n\nServiceNow developers frequently use modern JavaScript that fails on the Rhino engine. Here are the most common mistakes:\n\n### \uD83D\uDD25 Top ES5 Violations (Fix These Immediately!)\n\n**1. Arrow Functions with Array Methods**\n```javascript\n// \u274C BREAKS ServiceNow:\nvar activeIncidents = incidents.filter(inc => inc.active);\nvar numbers = activeIncidents.map(inc => inc.number);\n\n// \u2705 WORKS in ServiceNow:\nvar activeIncidents = [];\nfor (var i = 0; i < incidents.length; i++) {\n if (incidents[i].active) {\n activeIncidents.push(incidents[i]);\n }\n}\nvar numbers = [];\nfor (var j = 0; j < activeIncidents.length; j++) {\n numbers.push(activeIncidents[j].number);\n}\n```\n\n**2. Template Literals for String Building**\n```javascript\n// \u274C BREAKS ServiceNow:\nvar message = `Incident ${incident.number} assigned to ${user.name}`;\n\n// \u2705 WORKS in ServiceNow:\nvar message = 'Incident ' + incident.number + ' assigned to ' + user.name;\n```\n\n**3. Const/Let Variable Declarations**\n```javascript\n// \u274C BREAKS ServiceNow:\nconst MAX_RETRIES = 3;\nlet currentUser = gs.getUser();\n\n// \u2705 WORKS in ServiceNow:\nvar MAX_RETRIES = 3;\nvar currentUser = gs.getUser();\n```\n\n**4. Object Destructuring**\n```javascript\n// \u274C BREAKS ServiceNow:\nvar {name, email, department} = user;\nvar {sys_id: id, short_description: desc} = incident;\n\n// \u2705 WORKS in ServiceNow:\nvar name = user.name;\nvar email = user.email;\nvar department = user.department;\nvar id = incident.sys_id;\nvar desc = incident.short_description;\n```\n\n**5. For...of Loops**\n```javascript\n// \u274C BREAKS ServiceNow:\nfor (let incident of incidents) {\n gs.info('Processing: ' + incident.number);\n}\n\n// \u2705 WORKS in ServiceNow:\nfor (var i = 0; i < incidents.length; i++) {\n gs.info('Processing: ' + incidents[i].number);\n}\n```\n\n**6. Default Function Parameters**\n```javascript\n// \u274C BREAKS ServiceNow:\nfunction processIncident(incident, priority = 3, assignee = 'unassigned') {\n // Process incident\n}\n\n// \u2705 WORKS in ServiceNow:\nfunction processIncident(incident, priority, assignee) {\n if (typeof priority === 'undefined') priority = 3;\n if (typeof assignee === 'undefined') assignee = 'unassigned';\n // Process incident\n}\n```\n\n### \uD83C\uDFAF Quick ES5 Conversion Guide\n| Modern (ES6+) | ES5 Equivalent |\n|---------------|----------------|\n| `const x = 5;` | `var x = 5;` |\n| `let items = [];` | `var items = [];` |\n| `() => {}` | `function() {}` |\n| `` `Hello ${name}` `` | `'Hello ' + name` |\n| `{a, b} = obj` | `var a = obj.a; var b = obj.b;` |\n| `for (item of items)` | `for (var i = 0; i < items.length; i++)` |\n| `func(x = 'default')` | `if (typeof x === 'undefined') x = 'default';` |\n| `arr.map(x => x.id)` | `arr.map(function(x) { return x.id; })` |\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- **NEVER use background scripts to update widget fields - use `snow_update` instead**\n\n### Widget Development\n\n**CRITICAL: Direct Widget Updates (Not Background Scripts!)**\n- Use `snow_update({ type: 'widget', identifier: 'widget_name', config: { /* fields to update */ }})` \n- Updates widget fields DIRECTLY on the widget record\n- Do NOT use background scripts to update widget fields\n- Do NOT try to import server scripts into client scripts\n\n**Widget Coherence Requirements:**\n- Ensure HTML/Client/Server scripts communicate properly\n- Use Angular providers correctly \n- Implement proper data binding\n- Test across different themes and portals\n\n**Creating New Widgets:**\n```javascript\nsnow_deploy({\n type: 'widget',\n config: {\n name: 'my_widget',\n title: 'My Widget', // Required for display\n template: '<div>{{data.message}}</div>', // Required HTML\n server_script: 'data.message = \"Hello\";',\n client_script: 'function($scope) { var c = this; }'\n }\n})\n```\n\n**Updating Existing Widgets:**\n```javascript\nsnow_update({\n type: 'widget',\n identifier: 'my_widget', // Name or sys_id\n config: {\n template: '<div>Updated HTML</div>', // Only update what changes\n server_script: 'data.updated = true;'\n }\n})\n```\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 16+ specialized MCP servers with over 200 tools for comprehensive ServiceNow integration:\n\n### 1. ServiceNow Deployment Server\n**Purpose:** Widget and artifact deployment with coherence validation\n\n**Key Tools:**\n- `snow_deploy` - Create NEW artifacts (widgets, pages, etc.) - use with `type: 'widget'`\n- `snow_update` - UPDATE existing artifacts - use for widget field updates\n- `snow_validate_deployment` - Validate deployed artifacts\n- `snow_rollback_deployment` - Rollback failed deployments\n- `snow_preview_widget` - Preview widget before deployment\n- `snow_widget_test` - Test widget functionality\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_query_incidents` - Query and analyze incidents\n- `snow_cmdb_search` - Search Configuration Management Database\n- `snow_user_lookup` - Find and manage users\n- `snow_operational_metrics` - Get operational metrics\n- `snow_knowledge_search` - Search knowledge base\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**\uD83D\uDEA8 CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!**\nServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script failure.\n\n**Key Tools:**\n- `snow_execute_background_script` - Execute background scripts (**ES5 ONLY!** with optional autoConfirm)\n- `snow_confirm_script_execution` - Confirm script execution after user approval\n- `snow_execute_script_with_output` - Execute scripts with output capture (**ES5 ONLY!**)\n- `snow_get_script_output` - Retrieve script execution history\n- `snow_execute_script_sync` - Synchronous script execution (**ES5 ONLY!**)\n- `snow_get_logs` - Access system logs\n- `snow_test_rest_connection` - Test REST integrations\n- `snow_trace_execution` - Trace script execution (**ES5 ONLY!**)\n- `snow_schedule_job` - Create scheduled jobs\n- `snow_create_event` - Trigger system events\n\n**Remember:** Use `var`, `function(){}`, string concatenation, traditional for loops only!\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_ui_page` - Create UI pages\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\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_update_set_create` - Create new update sets\n- `snow_update_set_switch` - Switch active update set\n- `snow_update_set_current` - Get current update set\n- `snow_update_set_complete` - Mark as complete\n- `snow_update_set_export` - Export as XML\n- `snow_ensure_active_update_set` - Ensure update set is active\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:** Intelligent artifact search, editing and development assistance\n\n**Key Tools:**\n- `snow_find_artifact` - Find any ServiceNow artifact by name/type\n- `snow_edit_artifact` - Edit existing artifacts intelligently\n- `snow_get_by_sysid` - Get artifact by sys_id\n- `snow_analyze_artifact` - Analyze artifact structure and dependencies\n- `snow_comprehensive_search` - Deep search across all tables\n- `snow_analyze_requirements` - Analyze development requirements\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 with TensorFlow.js and native ML integration\n\n**Key Tools:**\n- `ml_train_incident_classifier` - Train incident classifier with LSTM neural networks\n- `ml_predict_change_risk` - Predict change risks\n- `ml_detect_anomalies` - Anomaly detection\n- `ml_forecast_incidents` - Incident forecasting with time series\n- `ml_performance_analytics` - Native Performance Analytics ML\n- `ml_hybrid_recommendation` - Hybrid ML recommendations\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- `swarm_init` - Initialize agent swarms\n- `agent_spawn` - Create specialized agents\n- `task_orchestrate` - Orchestrate complex tasks\n- `memory_search` - Search persistent memory\n- `neural_train` - Train neural networks with TensorFlow.js\n- `performance_report` - Generate performance reports\n\n### Additional Servers:\n\n**ServiceNow CMDB/Event/HR/CSM/DevOps Server** - CI management, event correlation, HR processes, customer service, DevOps pipelines\n\n**ServiceNow Knowledge & Catalog Server** - Knowledge articles, service catalog items, catalog variables and policies\n\n**ServiceNow Change/Virtual Agent/PA Server** - Change management, virtual agent NLU, predictive analytics\n\n**ServiceNow Flow/Workspace/Mobile Server** - Flow Designer, workspace configuration, mobile app management\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
2
  //# sourceMappingURL=claude-md-template.d.ts.map
@@ -52,68 +52,214 @@ const propertyCheck = await snow_property_manager({
52
52
 
53
53
  ## Fundamental Rules
54
54
 
55
- ### Rule 1: ES5 JavaScript Only in ServiceNow
55
+ ### Rule 1: 🚨 ES5 JavaScript ONLY in ServiceNow - NO EXCEPTIONS!
56
56
 
57
- ServiceNow uses the Rhino JavaScript engine which supports only ES5. Modern JavaScript syntax will fail.
57
+ **⚠️ CRITICAL WARNING: ServiceNow uses Rhino engine - ES6/ES7/ES8+ WILL FAIL!**
58
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
59
+ ServiceNow's server-side JavaScript runs on Mozilla Rhino which **ONLY supports ES5 (2009)**. Any modern JavaScript syntax will cause **RUNTIME ERRORS**.
67
60
 
68
- **Always Use:**
61
+ **❌ THESE WILL CRASH SERVICENOW (DO NOT USE):**
69
62
  \`\`\`javascript
70
- // ES5 compatible code
71
- var name = 'value';
72
- function processData() {
73
- return 'result';
63
+ // ES6+ features that BREAK ServiceNow:
64
+ const data = []; // SyntaxError: missing ; after for-loop initializer
65
+ let items = []; // SyntaxError: missing ; after for-loop initializer
66
+ const fn = () => {}; // SyntaxError: syntax error
67
+ var msg = \`Hello \${name}\`; // SyntaxError: syntax error
68
+ for (let item of items){} // SyntaxError: missing ; after for-loop initializer
69
+ var {name, id} = user; // SyntaxError: destructuring declaration not supported
70
+ array.forEach(x => {}); // SyntaxError: syntax error
71
+ array.map(x => x.id); // SyntaxError: syntax error
72
+ function test(param = 'default') {} // SyntaxError: syntax error
73
+ class MyClass {} // SyntaxError: missing ; after for-loop initializer
74
+ \`\`\`
75
+
76
+ **✅ ONLY USE ES5 SYNTAX (THIS WORKS):**
77
+ \`\`\`javascript
78
+ // ✅ ES5 compatible code that WORKS in ServiceNow:
79
+ var data = [];
80
+ var items = [];
81
+ function fn() { return 'result'; }
82
+ var msg = 'Hello ' + name;
83
+ for (var i = 0; i < items.length; i++) {
84
+ var item = items[i];
74
85
  }
75
- var message = 'Hello ' + userName;
76
- for (var i = 0; i < array.length; i++) {
77
- var item = array[i];
86
+ var name = user.name;
87
+ var id = user.id;
88
+ for (var j = 0; j < array.length; j++) {
89
+ // Process array[j]
90
+ }
91
+ function test(param) {
92
+ if (typeof param === 'undefined') param = 'default';
78
93
  }
79
94
  \`\`\`
80
95
 
96
+ **🔥 COMMON MISTAKES THAT BREAK SERVICENOW:**
97
+ 1. **Arrow Functions**: \`() => {}\` → Use \`function() {}\`
98
+ 2. **Template Literals**: \`\` \`\${var}\` \`\` → Use \`'text ' + var\`
99
+ 3. **Let/Const**: \`let x\` → Use \`var x\`
100
+ 4. **Destructuring**: \`{a, b} = obj\` → Use \`obj.a\`, \`obj.b\`
101
+ 5. **For...of**: \`for (x of arr)\` → Use \`for (var i=0; i<arr.length; i++)\`
102
+ 6. **Default Parameters**: \`fn(x='default')\` → Use \`typeof x === 'undefined'\`
103
+ 7. **Array Methods with Arrows**: \`.map(x => x)\` → Use \`.map(function(x) { return x; })\`
104
+
81
105
  ### Rule 2: Background Scripts for Verification Only (Not Widget Updates!)
82
106
 
83
107
  **CRITICAL DISTINCTION:**
84
- - ✅ Use background scripts for TESTING and VERIFICATION
108
+ - ✅ Use background scripts for TESTING and VERIFICATION
85
109
  - ❌ Do NOT use background scripts to UPDATE widget fields
86
110
  - ✅ Use \`snow_update\` to directly modify widget records
87
111
  - ❌ Do NOT try to import server scripts into client scripts via background scripts
88
112
 
113
+ **🚨 ES5 ENFORCEMENT FOR BACKGROUND SCRIPTS:**
114
+ Background scripts run on ServiceNow's server-side Rhino engine. **EVERY background script MUST be ES5-only or it will fail.**
115
+
116
+ **Quick ES5 Validation Checklist:**
117
+ - [ ] No \`const\` or \`let\` (only \`var\`)
118
+ - [ ] No arrow functions \`() => {}\` (only \`function() {}\`)
119
+ - [ ] No template literals \`\` \`\${var}\` \`\` (only string concatenation)
120
+ - [ ] No destructuring \`{a, b} = obj\` (only explicit \`obj.a\`)
121
+ - [ ] No \`for...of\` loops (only traditional \`for\` loops)
122
+ - [ ] No default parameters (use \`typeof\` checks)
123
+ - [ ] No modern array methods with arrows (use traditional functions)
124
+
89
125
  Background scripts are excellent for verification and debugging, but widget updates must go through proper MCP tools.
90
126
 
91
127
  **NEW: Auto-Confirm Mode for Background Scripts (v3.4.10+)**
92
128
  You can now skip the human-in-the-loop confirmation for trusted scripts:
93
129
 
94
130
  \`\`\`javascript
95
- // Standard mode - requires user confirmation
131
+ // Standard mode - requires user confirmation (ES5 ONLY!)
96
132
  snow_execute_background_script({
97
- script: "var gr = new GlideRecord('incident'); gr.query();",
133
+ script: "var gr = new GlideRecord('incident'); gr.query();", // ✅ ES5 syntax
98
134
  description: "Query incidents",
99
135
  allowDataModification: false
100
136
  });
101
137
 
102
138
  // Auto-confirm mode - executes immediately ⚠️ USE WITH CAUTION!
103
139
  snow_execute_background_script({
104
- script: "var gr = new GlideRecord('incident'); gr.query();",
140
+ script: "var gr = new GlideRecord('incident'); gr.query();", // ✅ ES5 syntax
105
141
  description: "Query incidents",
106
142
  allowDataModification: false,
107
143
  autoConfirm: true // ⚠️ Bypasses user confirmation!
108
144
  });
145
+
146
+ // ❌ WRONG - This will FAIL in ServiceNow:
147
+ // script: "const gr = new GlideRecord('incident'); gr.query();", // SyntaxError!
148
+ // script: "incidents.forEach(i => console.log(i.number));", // SyntaxError!
109
149
  \`\`\`
110
150
 
151
+ **🚨 ES5 Validation Required:**
152
+ Before using any background script tool, validate your script is ES5-only:
153
+ - No \`const\`/\`let\` (use \`var\`)
154
+ - No arrow functions (use \`function()\`)
155
+ - No template literals (use string concatenation)
156
+ - No destructuring (use explicit property access)
157
+
111
158
  **⚠️ Security Warning:**
112
159
  - Only use \`autoConfirm: true\` for verified, safe scripts
113
160
  - High-risk operations will still be logged
114
161
  - All auto-executions are tracked with audit IDs
115
162
  - Default behavior (without autoConfirm) remains unchanged
116
163
 
164
+ ## 🚨 CRITICAL: Common ES5 Mistakes That Break ServiceNow
165
+
166
+ ServiceNow developers frequently use modern JavaScript that fails on the Rhino engine. Here are the most common mistakes:
167
+
168
+ ### 🔥 Top ES5 Violations (Fix These Immediately!)
169
+
170
+ **1. Arrow Functions with Array Methods**
171
+ \`\`\`javascript
172
+ // ❌ BREAKS ServiceNow:
173
+ var activeIncidents = incidents.filter(inc => inc.active);
174
+ var numbers = activeIncidents.map(inc => inc.number);
175
+
176
+ // ✅ WORKS in ServiceNow:
177
+ var activeIncidents = [];
178
+ for (var i = 0; i < incidents.length; i++) {
179
+ if (incidents[i].active) {
180
+ activeIncidents.push(incidents[i]);
181
+ }
182
+ }
183
+ var numbers = [];
184
+ for (var j = 0; j < activeIncidents.length; j++) {
185
+ numbers.push(activeIncidents[j].number);
186
+ }
187
+ \`\`\`
188
+
189
+ **2. Template Literals for String Building**
190
+ \`\`\`javascript
191
+ // ❌ BREAKS ServiceNow:
192
+ var message = \`Incident \${incident.number} assigned to \${user.name}\`;
193
+
194
+ // ✅ WORKS in ServiceNow:
195
+ var message = 'Incident ' + incident.number + ' assigned to ' + user.name;
196
+ \`\`\`
197
+
198
+ **3. Const/Let Variable Declarations**
199
+ \`\`\`javascript
200
+ // ❌ BREAKS ServiceNow:
201
+ const MAX_RETRIES = 3;
202
+ let currentUser = gs.getUser();
203
+
204
+ // ✅ WORKS in ServiceNow:
205
+ var MAX_RETRIES = 3;
206
+ var currentUser = gs.getUser();
207
+ \`\`\`
208
+
209
+ **4. Object Destructuring**
210
+ \`\`\`javascript
211
+ // ❌ BREAKS ServiceNow:
212
+ var {name, email, department} = user;
213
+ var {sys_id: id, short_description: desc} = incident;
214
+
215
+ // ✅ WORKS in ServiceNow:
216
+ var name = user.name;
217
+ var email = user.email;
218
+ var department = user.department;
219
+ var id = incident.sys_id;
220
+ var desc = incident.short_description;
221
+ \`\`\`
222
+
223
+ **5. For...of Loops**
224
+ \`\`\`javascript
225
+ // ❌ BREAKS ServiceNow:
226
+ for (let incident of incidents) {
227
+ gs.info('Processing: ' + incident.number);
228
+ }
229
+
230
+ // ✅ WORKS in ServiceNow:
231
+ for (var i = 0; i < incidents.length; i++) {
232
+ gs.info('Processing: ' + incidents[i].number);
233
+ }
234
+ \`\`\`
235
+
236
+ **6. Default Function Parameters**
237
+ \`\`\`javascript
238
+ // ❌ BREAKS ServiceNow:
239
+ function processIncident(incident, priority = 3, assignee = 'unassigned') {
240
+ // Process incident
241
+ }
242
+
243
+ // ✅ WORKS in ServiceNow:
244
+ function processIncident(incident, priority, assignee) {
245
+ if (typeof priority === 'undefined') priority = 3;
246
+ if (typeof assignee === 'undefined') assignee = 'unassigned';
247
+ // Process incident
248
+ }
249
+ \`\`\`
250
+
251
+ ### 🎯 Quick ES5 Conversion Guide
252
+ | Modern (ES6+) | ES5 Equivalent |
253
+ |---------------|----------------|
254
+ | \`const x = 5;\` | \`var x = 5;\` |
255
+ | \`let items = [];\` | \`var items = [];\` |
256
+ | \`() => {}\` | \`function() {}\` |
257
+ | \`\` \`Hello \${name}\` \`\` | \`'Hello ' + name\` |
258
+ | \`{a, b} = obj\` | \`var a = obj.a; var b = obj.b;\` |
259
+ | \`for (item of items)\` | \`for (var i = 0; i < items.length; i++)\` |
260
+ | \`func(x = 'default')\` | \`if (typeof x === 'undefined') x = 'default';\` |
261
+ | \`arr.map(x => x.id)\` | \`arr.map(function(x) { return x.id; })\` |
262
+
117
263
  \`\`\`javascript
118
264
  // Universal verification pattern
119
265
  const verify = await snow_execute_script_with_output({
@@ -314,18 +460,23 @@ Snow-Flow includes 16+ specialized MCP servers with over 200 tools for comprehen
314
460
  ### 3. ServiceNow Automation Server
315
461
  **Purpose:** Script execution and automation
316
462
 
463
+ **🚨 CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!**
464
+ ServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script failure.
465
+
317
466
  **Key Tools:**
318
- - \`snow_execute_background_script\` - Execute background scripts (with optional autoConfirm)
467
+ - \`snow_execute_background_script\` - Execute background scripts (**ES5 ONLY!** with optional autoConfirm)
319
468
  - \`snow_confirm_script_execution\` - Confirm script execution after user approval
320
- - \`snow_execute_script_with_output\` - Execute scripts with output capture
469
+ - \`snow_execute_script_with_output\` - Execute scripts with output capture (**ES5 ONLY!**)
321
470
  - \`snow_get_script_output\` - Retrieve script execution history
322
- - \`snow_execute_script_sync\` - Synchronous script execution
471
+ - \`snow_execute_script_sync\` - Synchronous script execution (**ES5 ONLY!**)
323
472
  - \`snow_get_logs\` - Access system logs
324
473
  - \`snow_test_rest_connection\` - Test REST integrations
325
- - \`snow_trace_execution\` - Trace script execution
474
+ - \`snow_trace_execution\` - Trace script execution (**ES5 ONLY!**)
326
475
  - \`snow_schedule_job\` - Create scheduled jobs
327
476
  - \`snow_create_event\` - Trigger system events
328
477
 
478
+ **Remember:** Use \`var\`, \`function(){}\`, string concatenation, traditional for loops only!
479
+
329
480
  **Features:**
330
481
  - Full output capture (gs.print/info/warn/error)
331
482
  - Execution history tracking
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.11",
3
+ "version": "3.4.13",
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",