snow-flow 3.4.9 → 3.4.10
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.
|
@@ -179,7 +179,7 @@ class ServiceNowAutomationMCP {
|
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
name: 'snow_execute_background_script',
|
|
182
|
-
description: '🚨 REQUIRES USER CONFIRMATION: Executes a JavaScript background script in ServiceNow. Script runs in server-side context with full API access.
|
|
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.',
|
|
183
183
|
inputSchema: {
|
|
184
184
|
type: 'object',
|
|
185
185
|
properties: {
|
|
@@ -189,7 +189,7 @@ class ServiceNowAutomationMCP {
|
|
|
189
189
|
},
|
|
190
190
|
description: {
|
|
191
191
|
type: 'string',
|
|
192
|
-
description: 'Clear description of what the script does (shown to user for approval)'
|
|
192
|
+
description: 'Clear description of what the script does (shown to user for approval unless autoConfirm=true)'
|
|
193
193
|
},
|
|
194
194
|
runAsUser: {
|
|
195
195
|
type: 'string',
|
|
@@ -199,6 +199,11 @@ class ServiceNowAutomationMCP {
|
|
|
199
199
|
type: 'boolean',
|
|
200
200
|
description: 'Whether script is allowed to modify data (CREATE/UPDATE/DELETE operations)',
|
|
201
201
|
default: false
|
|
202
|
+
},
|
|
203
|
+
autoConfirm: {
|
|
204
|
+
type: 'boolean',
|
|
205
|
+
description: '⚠️ DANGEROUS: Skip user confirmation and execute immediately. Only use for trusted/verified scripts!',
|
|
206
|
+
default: false
|
|
202
207
|
}
|
|
203
208
|
},
|
|
204
209
|
required: ['script', 'description']
|
|
@@ -1006,16 +1011,33 @@ class ServiceNowAutomationMCP {
|
|
|
1006
1011
|
return scheduleData;
|
|
1007
1012
|
}
|
|
1008
1013
|
/**
|
|
1009
|
-
* Execute Background Script with User Confirmation
|
|
1010
|
-
* 🚨 SECURITY:
|
|
1014
|
+
* Execute Background Script with User Confirmation (unless autoConfirm=true)
|
|
1015
|
+
* 🚨 SECURITY: Requires user approval by default, can be bypassed with autoConfirm=true
|
|
1011
1016
|
*/
|
|
1012
1017
|
async executeBackgroundScript(args) {
|
|
1013
1018
|
try {
|
|
1014
|
-
const { script, description, runAsUser, allowDataModification = false } = args;
|
|
1015
|
-
this.logger.info('Background script execution requested');
|
|
1019
|
+
const { script, description, runAsUser, allowDataModification = false, autoConfirm = false } = args;
|
|
1020
|
+
this.logger.info('Background script execution requested', { autoConfirm });
|
|
1016
1021
|
// 🛡️ SECURITY ANALYSIS: Analyze script for dangerous operations
|
|
1017
1022
|
const securityAnalysis = this.analyzeScriptSecurity(script);
|
|
1018
|
-
//
|
|
1023
|
+
// ⚠️ AUTO-CONFIRM MODE: Skip user confirmation if explicitly requested
|
|
1024
|
+
if (autoConfirm === true) {
|
|
1025
|
+
this.logger.warn('⚠️ AUTO-CONFIRM MODE: Executing script without user confirmation');
|
|
1026
|
+
// Log the auto-execution for audit trail
|
|
1027
|
+
const executionId = `snow_flow_exec_auto_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
1028
|
+
this.logger.info(`Auto-executing script with ID: ${executionId}`, {
|
|
1029
|
+
description,
|
|
1030
|
+
riskLevel: securityAnalysis.riskLevel,
|
|
1031
|
+
dataModification: allowDataModification
|
|
1032
|
+
});
|
|
1033
|
+
// Directly execute the script
|
|
1034
|
+
return await this.confirmScriptExecution({
|
|
1035
|
+
script,
|
|
1036
|
+
executionId,
|
|
1037
|
+
userConfirmed: true // Auto-confirmed
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
// 🚨 STANDARD MODE: Require user confirmation
|
|
1019
1041
|
const confirmationPrompt = this.generateConfirmationPrompt({
|
|
1020
1042
|
script,
|
|
1021
1043
|
description,
|
|
@@ -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```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_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: 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.";
|
|
2
2
|
//# sourceMappingURL=claude-md-template.d.ts.map
|
|
@@ -86,7 +86,33 @@ for (var i = 0; i < array.length; i++) {
|
|
|
86
86
|
- ✅ Use \`snow_update\` to directly modify widget records
|
|
87
87
|
- ❌ Do NOT try to import server scripts into client scripts via background scripts
|
|
88
88
|
|
|
89
|
-
Background scripts are excellent for verification and debugging, but widget updates must go through proper MCP tools
|
|
89
|
+
Background scripts are excellent for verification and debugging, but widget updates must go through proper MCP tools.
|
|
90
|
+
|
|
91
|
+
**NEW: Auto-Confirm Mode for Background Scripts (v3.4.10+)**
|
|
92
|
+
You can now skip the human-in-the-loop confirmation for trusted scripts:
|
|
93
|
+
|
|
94
|
+
\`\`\`javascript
|
|
95
|
+
// Standard mode - requires user confirmation
|
|
96
|
+
snow_execute_background_script({
|
|
97
|
+
script: "var gr = new GlideRecord('incident'); gr.query();",
|
|
98
|
+
description: "Query incidents",
|
|
99
|
+
allowDataModification: false
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Auto-confirm mode - executes immediately ⚠️ USE WITH CAUTION!
|
|
103
|
+
snow_execute_background_script({
|
|
104
|
+
script: "var gr = new GlideRecord('incident'); gr.query();",
|
|
105
|
+
description: "Query incidents",
|
|
106
|
+
allowDataModification: false,
|
|
107
|
+
autoConfirm: true // ⚠️ Bypasses user confirmation!
|
|
108
|
+
});
|
|
109
|
+
\`\`\`
|
|
110
|
+
|
|
111
|
+
**⚠️ Security Warning:**
|
|
112
|
+
- Only use \`autoConfirm: true\` for verified, safe scripts
|
|
113
|
+
- High-risk operations will still be logged
|
|
114
|
+
- All auto-executions are tracked with audit IDs
|
|
115
|
+
- Default behavior (without autoConfirm) remains unchanged
|
|
90
116
|
|
|
91
117
|
\`\`\`javascript
|
|
92
118
|
// Universal verification pattern
|
|
@@ -289,6 +315,8 @@ Snow-Flow includes 16+ specialized MCP servers with over 200 tools for comprehen
|
|
|
289
315
|
**Purpose:** Script execution and automation
|
|
290
316
|
|
|
291
317
|
**Key Tools:**
|
|
318
|
+
- \`snow_execute_background_script\` - Execute background scripts (with optional autoConfirm)
|
|
319
|
+
- \`snow_confirm_script_execution\` - Confirm script execution after user approval
|
|
292
320
|
- \`snow_execute_script_with_output\` - Execute scripts with output capture
|
|
293
321
|
- \`snow_get_script_output\` - Retrieve script execution history
|
|
294
322
|
- \`snow_execute_script_sync\` - Synchronous script execution
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.10",
|
|
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",
|