snow-flow 3.4.6 → 3.4.8

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.
@@ -559,6 +559,37 @@ class ServiceNowDeploymentMCP {
559
559
  let updateSetId = null;
560
560
  let updateSetName = 'No Update Set';
561
561
  try {
562
+ // CRITICAL: Validate required fields FIRST for clear error messages
563
+ if (!args.name) {
564
+ return {
565
+ success: false,
566
+ error: 'Widget name is required',
567
+ content: [{
568
+ type: 'text',
569
+ text: `❌ Widget deployment failed: Missing required field\n\n**Error:** Widget name is required\n\n**Required fields for widget deployment:**\n• name: Internal identifier for the widget (e.g., "my_dashboard_widget")\n• title: Display title shown in Service Portal (e.g., "My Dashboard")\n• template: HTML template for the widget\n\n**Example usage:**\n\`\`\`javascript\nsnow_deploy({\n type: "widget",\n config: {\n name: "my_widget",\n title: "My Widget Title",\n template: "<div>{{data.message}}</div>",\n server_script: "data.message = 'Hello World';",\n client_script: "function() { var c = this; }"\n }\n})\n\`\`\``
570
+ }]
571
+ };
572
+ }
573
+ if (!args.title) {
574
+ return {
575
+ success: false,
576
+ error: 'Widget title is required',
577
+ content: [{
578
+ type: 'text',
579
+ text: `❌ Widget deployment failed: Missing required field\n\n**Error:** Widget title is required for display in Service Portal\n\n**Required fields for widget deployment:**\n• name: Internal identifier for the widget\n• title: Display title shown in Service Portal ← MISSING\n• template: HTML template for the widget\n\n**Why title is required:**\nThe title is displayed in Service Portal widget picker and page designer.\nIt's what users see when selecting widgets to add to pages.\n\n**Example:**\n\`\`\`javascript\nconfig: {\n name: "incident_list",\n title: "Active Incidents", // ← This is what users will see\n template: "<div>...</div>"\n}\n\`\`\``
580
+ }]
581
+ };
582
+ }
583
+ if (!args.template && !args.html_template) {
584
+ return {
585
+ success: false,
586
+ error: 'Widget template (HTML) is required',
587
+ content: [{
588
+ type: 'text',
589
+ text: `❌ Widget deployment failed: Missing required field\n\n**Error:** Widget template (HTML) is required\n\n**Required fields for widget deployment:**\n• name: Internal identifier for the widget\n• title: Display title shown in Service Portal\n• template: HTML template for the widget ← MISSING\n\n**Template defines the widget's visual structure:**\n\`\`\`html\n<div class="my-widget">\n <h3>{{data.title}}</h3>\n <ul>\n <li ng-repeat="item in data.items">\n {{item.name}}\n </li>\n </ul>\n</div>\n\`\`\`\n\n**Note:** Use either 'template' or 'html_template' parameter.`
590
+ }]
591
+ };
592
+ }
562
593
  // Enhanced authentication check with token refresh for deployment
563
594
  const authResult = await this.deploymentAuthManager.ensureDeploymentAuth();
564
595
  if (!authResult.isValid) {
@@ -6614,11 +6645,17 @@ Use individual deployment tools like \`snow_deploy_${args.type}\` with manual co
6614
6645
  }
6615
6646
  // For widgets, delegate to widget composer
6616
6647
  if (type === 'widget') {
6648
+ const widgetName = this.extractNameFromInstruction(instruction);
6649
+ // Ensure title is always valid and user-friendly
6650
+ const widgetTitle = widgetName
6651
+ .replace(/_/g, ' ')
6652
+ .replace(/\b\w/g, l => l.toUpperCase())
6653
+ || 'Auto Generated Widget';
6617
6654
  return {
6618
- name: this.extractNameFromInstruction(instruction),
6619
- title: this.extractNameFromInstruction(instruction),
6655
+ name: widgetName,
6656
+ title: widgetTitle, // Always ensure a valid display title
6620
6657
  description: instruction,
6621
- template: this.generateWidgetTemplate(instruction),
6658
+ template: this.generateWidgetTemplate(instruction) || '<div>{{data.message}}</div>', // Ensure template is never empty
6622
6659
  css: this.generateWidgetCss(instruction),
6623
6660
  server_script: this.generateWidgetServerScript(instruction),
6624
6661
  client_script: this.generateWidgetClientScript(instruction),
@@ -6638,8 +6675,9 @@ Use individual deployment tools like \`snow_deploy_${args.type}\` with manual co
6638
6675
  // Simple name extraction - could be enhanced with NLP
6639
6676
  const words = instruction.toLowerCase().split(/\s+/);
6640
6677
  const name = words.filter(word => word.length > 2 &&
6641
- !['the', 'and', 'for', 'with', 'that', 'will', 'can', 'should'].includes(word)).slice(0, 3).join('_');
6642
- return name || 'auto_generated_artifact';
6678
+ !['the', 'and', 'for', 'with', 'that', 'will', 'can', 'should', 'create', 'make', 'build', 'new'].includes(word)).slice(0, 3).join('_');
6679
+ // Ensure we always return a valid name
6680
+ return name || `auto_generated_${Date.now().toString().slice(-6)}`;
6643
6681
  }
6644
6682
  /**
6645
6683
  * Generate HTML template based on widget requirements
@@ -0,0 +1,2 @@
1
+ export declare const CLAUDE_MD_TEMPLATE = "# Snow-Flow Configuration & Best Practices\n\nThis document provides comprehensive instructions for Snow-Flow, an advanced ServiceNow development and orchestration framework powered by Claude AI.\n\n## Table of Contents\n1. [Core Philosophy](#core-philosophy)\n2. [Fundamental Rules](#fundamental-rules)\n3. [ServiceNow Development Standards](#servicenow-development-standards)\n4. [MCP Server Capabilities](#mcp-server-capabilities)\n5. [Debugging Best Practices](#debugging-best-practices)\n6. [Command Reference](#command-reference)\n7. [Workflow Guidelines](#workflow-guidelines)\n\n## Core Philosophy\n\n### The Prime Directive: Verify, Don't Assume\n\nSnow-Flow operates on evidence-based development. Never make assumptions about what exists or doesn't exist in a ServiceNow environment. Every environment is unique with custom tables, fields, integrations, and configurations that you cannot predict.\n\n**Cardinal Rules:**\n1. If code references something, it probably exists\n2. Test before declaring something broken\n3. Verify before modifying\n4. Fix only what's confirmed broken\n5. Respect existing configurations\n\n### The Verification-First Approach\n\n```javascript\n// Before claiming anything doesn't work or exist:\n// Step 1: Test the actual implementation\nconst verify = await snow_execute_script_with_output({\n script: `/* Test the exact code or resource */`\n});\n\n// Step 2: Check if resources exist\nconst tableCheck = await snow_discover_table_fields({\n table_name: 'potentially_custom_table'\n});\n\n// Step 3: Validate configurations\nconst propertyCheck = await snow_property_manager({\n action: 'get',\n name: 'system.property'\n});\n\n// Step 4: Only then make informed decisions\n```\n\n## Fundamental Rules\n\n### Rule 1: ES5 JavaScript Only in ServiceNow\n\nServiceNow uses the Rhino JavaScript engine which supports only ES5. Modern JavaScript syntax will fail.\n\n**Never Use:**\n- `const` or `let` - use `var`\n- Arrow functions `() => {}` - use `function() {}`\n- Template literals `` `${var}` `` - use string concatenation\n- Destructuring `{a, b} = obj` - use explicit property access\n- `for...of` loops - use traditional `for` loops\n- Default parameters - use `typeof` checks\n- `async/await` - use callbacks or GlideAjax\n\n**Always Use:**\n```javascript\n// ES5 compatible code\nvar name = 'value';\nfunction processData() {\n return 'result';\n}\nvar message = 'Hello ' + userName;\nfor (var i = 0; i < array.length; i++) {\n var item = array[i];\n}\n```\n\n### Rule 2: Background Scripts as Primary Debug Tool\n\nBackground scripts provide immediate, factual feedback from the actual ServiceNow instance. Use them extensively for verification and debugging.\n\n```javascript\n// Universal verification pattern\nconst verify = await snow_execute_script_with_output({\n script: `\n gs.info('=== VERIFICATION TEST ===');\n \n // Test table existence\n var table = new GlideRecord('table_name');\n gs.info('Table valid: ' + table.isValid());\n \n // Test property existence\n var prop = gs.getProperty('property.name');\n gs.info('Property: ' + (prop || 'NOT SET'));\n \n // Test actual code\n try {\n // User's code here\n gs.info('SUCCESS');\n } catch(e) {\n gs.error('ERROR: ' + e.message);\n }\n `\n});\n```\n\n### Rule 3: Widget Coherence - Critical Client-Server Communication\n\nServiceNow widgets MUST have perfect communication between client and server scripts. This is not optional - widgets fail when these components don't talk to each other correctly.\n\n**The Three-Way Contract:**\n\n**Server Script Must:**\n- Initialize all `data` properties that HTML will reference\n- Handle every `input.action` that client sends\n- Return data in the format client expects\n\n**Client Script Must:**\n- Implement every method that HTML calls via `ng-click`\n- Use `c.server.get({action: 'name'})` for server communication\n- Update `c.data` when server responds\n\n**HTML Template Must:**\n- Only reference `data` properties that server provides\n- Only call methods that client implements\n- Use correct Angular directives and bindings\n\n**Critical Communication Points:**\n\n1. **Server \u2192 Client Data Flow**\n - Server sets `data.property`\n - Client receives via `c.data.property`\n - HTML displays with `{{data.property}}`\n\n2. **Client \u2192 Server Requests**\n - Client sends `c.server.get({action: 'name'})`\n - Server receives via `input.action`\n - Server processes and returns updated `data`\n\n3. **HTML \u2192 Client Method Calls**\n - HTML has `ng-click=\"methodName()\"`\n - Client must have `$scope.methodName = function()`\n - Method typically calls server with `c.server.get()`\n\n**Common Failures to Avoid:**\n- Action name mismatches between client and server\n- Method name mismatches between HTML and client \n- Property name mismatches between server and HTML\n- Missing handlers for client requests\n- Orphaned data properties or methods\n\n**Coherence Validation Checklist:**\n- [ ] Every `data.property` in server is used in HTML/client\n- [ ] Every `ng-click` in HTML has matching `$scope.method` in client\n- [ ] Every `c.server.get({action})` in client has matching `if(input.action)` in server\n- [ ] Data flows correctly: Server \u2192 HTML \u2192 Client \u2192 Server\n- [ ] No orphaned methods or unused data properties\n\n### Rule 4: Evidence-Based Debugging\n\nFollow this systematic approach for all debugging:\n\n1. **Reproduce** - Run the exact failing code\n2. **Inventory** - List all dependencies\n3. **Verify** - Test each dependency exists\n4. **Fix** - Correct only confirmed issues\n\n**Fix only:**\n- \u2705 Confirmed syntax errors\n- \u2705 Verified null references\n- \u2705 Missing dependencies (after verification)\n- \u2705 Real type mismatches\n\n**Never change:**\n- \u274C Unverified resources\n- \u274C Configurations that \"seem wrong\"\n- \u274C APIs you haven't tested\n- \u274C Working code that could be \"better\"\n\n## ServiceNow Development Standards\n\n### Table Operations\n- Always verify table existence before operations\n- Use proper field types and references\n- Check for ACLs and permissions\n- Handle large datasets with pagination\n\n### Script Development\n- Use Script Includes for reusable code\n- Implement proper error handling\n- Add meaningful logging with gs.info/warn/error\n- Test in scoped applications when applicable\n\n### Widget Development\n- Ensure HTML/Client/Server coherence\n- Use Angular providers correctly\n- Implement proper data binding\n- Test across different themes and portals\n\n### Flow Development\n- Use proper trigger conditions\n- Implement error handling paths\n- Add appropriate logging actions\n- Test with various data scenarios\n\n## MCP Server Capabilities\n\nSnow-Flow includes 12 specialized MCP servers, each providing specific ServiceNow capabilities:\n\n### 1. ServiceNow Deployment Server\n**Purpose:** Widget and artifact deployment with coherence validation\n\n**Key Tools:**\n- `snow_deploy_widget` - Deploy widgets with HTML/Client/Server validation\n- `snow_deploy_portal_page` - Deploy portal pages\n- `snow_deploy_flow` - Deploy Flow Designer flows\n- `snow_create_update_set` - Create update sets\n- `snow_validate_deployment` - Validate deployed artifacts\n- `snow_rollback_deployment` - Rollback failed deployments\n\n**Special Features:**\n- Automatic widget coherence validation\n- Data flow contract verification\n- Method implementation checking\n- CSS class validation\n\n### 2. ServiceNow Operations Server\n**Purpose:** Core ServiceNow operations and queries\n\n**Key Tools:**\n- `snow_query_table` - Universal table querying with pagination\n- `snow_create_incident` - Create and manage incidents\n- `snow_update_record` - Update any table record\n- `snow_delete_record` - Delete records with validation\n- `snow_discover_table_fields` - Discover table schema\n- `snow_cmdb_search` - Search Configuration Management Database\n\n**Features:**\n- Full CRUD operations on any table\n- Advanced query capabilities\n- Field discovery and validation\n- Relationship navigation\n\n### 3. ServiceNow Automation Server\n**Purpose:** Script execution and automation\n\n**Key Tools:**\n- `snow_execute_script_with_output` - Execute scripts with output capture\n- `snow_get_script_output` - Retrieve script execution history\n- `snow_execute_script_sync` - Synchronous script execution\n- `snow_get_logs` - Access system logs\n- `snow_test_rest_connection` - Test REST integrations\n- `snow_trace_execution` - Trace script execution\n- `snow_schedule_job` - Create scheduled jobs\n- `snow_create_event` - Trigger system events\n\n**Features:**\n- Full output capture (gs.print/info/warn/error)\n- Execution history tracking\n- System log access\n- REST message testing\n- Performance tracing\n\n### 4. ServiceNow Platform Development Server\n**Purpose:** Platform development artifacts\n\n**Key Tools:**\n- `snow_create_script_include` - Create reusable scripts\n- `snow_create_business_rule` - Create business rules\n- `snow_create_client_script` - Create client-side scripts\n- `snow_create_ui_policy` - Create UI policies\n- `snow_create_ui_action` - Create UI actions\n- `snow_create_ui_page` - Create UI pages\n\n**Features:**\n- Full artifact creation\n- Proper scoping support\n- Condition builder integration\n- Script validation\n\n### 5. ServiceNow Integration Server\n**Purpose:** Integration and data management\n\n**Key Tools:**\n- `snow_create_rest_message` - Create REST integrations\n- `snow_create_transform_map` - Create data transformation maps\n- `snow_create_import_set` - Manage import sets\n- `snow_test_web_service` - Test web services\n- `snow_configure_email` - Configure email settings\n\n**Features:**\n- REST/SOAP integration\n- Data transformation\n- Import/Export capabilities\n- Email configuration\n\n### 6. ServiceNow System Properties Server\n**Purpose:** System property management\n\n**Key Tools:**\n- `snow_property_get` - Retrieve property values\n- `snow_property_set` - Set property values\n- `snow_property_list` - List properties by pattern\n- `snow_property_delete` - Remove properties\n- `snow_property_bulk_update` - Bulk operations\n- `snow_property_export` - Export to JSON\n- `snow_property_import` - Import from JSON\n\n**Features:**\n- Full CRUD on sys_properties\n- Bulk operations\n- Import/Export capabilities\n- Property validation\n\n### 7. ServiceNow Update Set Server\n**Purpose:** Change management and deployment\n\n**Key Tools:**\n- `snow_create_update_set` - Create new update sets\n- `snow_switch_update_set` - Switch active update set\n- `snow_complete_update_set` - Mark as complete\n- `snow_preview_update_set` - Preview changes\n- `snow_export_update_set` - Export as XML\n\n**Features:**\n- Full update set lifecycle\n- Change tracking\n- XML export/import\n- Conflict detection\n\n### 8. ServiceNow Development Assistant Server\n**Purpose:** Code generation and best practices\n\n**Key Tools:**\n- `snow_generate_code` - Generate ServiceNow code\n- `snow_suggest_pattern` - Suggest design patterns\n- `snow_review_code` - Code review and analysis\n- `snow_optimize_performance` - Performance recommendations\n\n**Features:**\n- Pattern-based code generation\n- Best practice enforcement\n- Performance optimization\n- Security review\n\n### 9. ServiceNow Security & Compliance Server\n**Purpose:** Security and compliance management\n\n**Key Tools:**\n- `snow_create_security_policy` - Create security policies\n- `snow_audit_compliance` - Compliance auditing\n- `snow_scan_vulnerabilities` - Vulnerability scanning\n- `snow_assess_risk` - Risk assessment\n- `snow_review_access_control` - ACL review\n\n**Features:**\n- SOX/GDPR/HIPAA compliance\n- Security policy management\n- Vulnerability assessment\n- Access control validation\n\n### 10. ServiceNow Reporting & Analytics Server\n**Purpose:** Reporting and data visualization\n\n**Key Tools:**\n- `snow_create_report` - Create reports\n- `snow_create_dashboard` - Create dashboards\n- `snow_define_kpi` - Define KPIs\n- `snow_schedule_report` - Schedule report delivery\n- `snow_analyze_data_quality` - Data quality analysis\n\n**Features:**\n- Advanced reporting\n- Dashboard creation\n- KPI management\n- Scheduled delivery\n\n### 11. ServiceNow Machine Learning Server\n**Purpose:** AI/ML capabilities\n\n**Key Tools:**\n- `snow_train_classifier` - Train incident classifier\n- `snow_predict_change_risk` - Predict change risks\n- `snow_detect_anomalies` - Anomaly detection\n- `snow_forecast_incidents` - Incident forecasting\n- `snow_optimize_process` - Process optimization\n\n**Features:**\n- Predictive analytics\n- Pattern recognition\n- Anomaly detection\n- Process optimization\n\n### 12. Snow-Flow Orchestration Server\n**Purpose:** Multi-agent coordination and task management\n\n**Key Tools:**\n- `snow_swarm_init` - Initialize agent swarms\n- `snow_agent_spawn` - Create specialized agents\n- `snow_task_orchestrate` - Orchestrate complex tasks\n- `snow_memory_store` - Persistent memory storage\n- `snow_neural_train` - Train neural networks\n- `snow_performance_analyze` - Performance analysis\n\n**Features:**\n- Multi-agent coordination\n- Task orchestration\n- Neural network training (TensorFlow.js)\n- Memory management\n- Performance monitoring\n\n## Debugging Best Practices\n\n### Systematic Debugging Protocol\n\n1. **Reproduce the Issue**\n ```javascript\n // Always use ES5 and test exact code\n const result = await snow_execute_script_with_output({\n script: `/* Exact failing code in ES5 */`\n });\n ```\n\n2. **Verify Dependencies**\n - Check all referenced tables exist\n - Verify all properties are set\n - Confirm all fields are present\n - Test all integrations work\n\n3. **Test in Context**\n - Use same scope and variables\n - Include same imports\n - Test with same data\n\n4. **Apply Evidence-Based Fixes**\n - Fix only confirmed issues\n - Document why changes were made\n - Test fixes thoroughly\n\n### Common Verification Patterns\n\n**Table Verification:**\n```javascript\nvar table = new GlideRecord('table_name');\ngs.info('Table exists: ' + table.isValid());\n```\n\n**Property Verification:**\n```javascript\nvar prop = gs.getProperty('property.name');\ngs.info('Property value: ' + (prop || 'NOT SET'));\n```\n\n**Field Verification:**\n```javascript\nvar gr = new GlideRecord('table');\nvar element = gr.getElement('field_name');\ngs.info('Field exists: ' + (element ? 'Yes' : 'No'));\n```\n\n## Command Reference\n\n### Core Commands\n- `./snow-flow start` - Start orchestration system\n- `./snow-flow status` - System status\n- `./snow-flow monitor` - Real-time monitoring\n\n### Agent Management\n- `./snow-flow agent spawn <type>` - Create agents\n- `./snow-flow agent list` - List active agents\n\n### Task Management\n- `./snow-flow task create` - Create tasks\n- `./snow-flow task list` - View task queue\n\n### Memory Operations\n- `./snow-flow memory store <key> <data>` - Store data\n- `./snow-flow memory get <key>` - Retrieve data\n- `./snow-flow memory list` - List all keys\n\n### SPARC Modes\n- `./snow-flow sparc \"<task>\"` - Orchestrator mode\n- `./snow-flow sparc run <mode> \"<task>\"` - Specific mode\n- `./snow-flow sparc tdd \"<feature>\"` - Test-driven development\n\n### Swarm Coordination\n- `./snow-flow swarm \"<objective>\"` - Multi-agent coordination\n- Options: `--strategy`, `--mode`, `--parallel`, `--monitor`\n\n## Workflow Guidelines\n\n### Development Workflow\n1. **Plan** - Use TodoWrite for task management\n2. **Verify** - Check existing resources\n3. **Develop** - Follow ES5 standards\n4. **Test** - Use background scripts\n5. **Deploy** - Use update sets\n6. **Validate** - Verify deployment\n\n### Testing Workflow\n1. Run unit tests with background scripts\n2. Test integrations with REST tools\n3. Validate UI with widget coherence\n4. Check performance with tracing\n5. Review logs for errors\n\n### Debugging Workflow\n1. Reproduce issue exactly\n2. Gather evidence with scripts\n3. Verify all assumptions\n4. Apply minimal fixes\n5. Test thoroughly\n6. Document changes\n\n## Important Reminders\n\n### Always Remember\n- Every ServiceNow instance is unique\n- Custom implementations exist that you don't know about\n- Preview/beta features may be available\n- Organization-specific configurations are common\n- Test everything before making assumptions\n\n### Never Assume\n- That something doesn't exist without verification\n- That configurations are wrong without testing\n- That APIs aren't available without checking\n- That code won't work without running it\n- That you know better than existing implementations\n\n### Golden Rules\n1. **Verify First** - Test before declaring broken\n2. **ES5 Only** - No modern JavaScript in ServiceNow\n3. **Evidence-Based** - Make decisions on facts, not assumptions\n4. **Minimal Changes** - Fix only what's broken\n5. **Respect Context** - Understand why things exist as they do\n\n## Conclusion\n\nSnow-Flow is a powerful framework for ServiceNow development that emphasizes verification, testing, and evidence-based decision making. By following these guidelines and best practices, you ensure reliable, maintainable, and effective ServiceNow solutions.\n\nRemember: Your job is to solve problems, not to judge implementations. Every environment has its reasons for existing configurations. Verify, test, and respect what you find.";
2
+ //# sourceMappingURL=claude-md-template.d.ts.map
@@ -0,0 +1,546 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLAUDE_MD_TEMPLATE = void 0;
4
+ exports.CLAUDE_MD_TEMPLATE = `# Snow-Flow Configuration & Best Practices
5
+
6
+ This document provides comprehensive instructions for Snow-Flow, an advanced ServiceNow development and orchestration framework powered by Claude AI.
7
+
8
+ ## Table of Contents
9
+ 1. [Core Philosophy](#core-philosophy)
10
+ 2. [Fundamental Rules](#fundamental-rules)
11
+ 3. [ServiceNow Development Standards](#servicenow-development-standards)
12
+ 4. [MCP Server Capabilities](#mcp-server-capabilities)
13
+ 5. [Debugging Best Practices](#debugging-best-practices)
14
+ 6. [Command Reference](#command-reference)
15
+ 7. [Workflow Guidelines](#workflow-guidelines)
16
+
17
+ ## Core Philosophy
18
+
19
+ ### The Prime Directive: Verify, Don't Assume
20
+
21
+ Snow-Flow operates on evidence-based development. Never make assumptions about what exists or doesn't exist in a ServiceNow environment. Every environment is unique with custom tables, fields, integrations, and configurations that you cannot predict.
22
+
23
+ **Cardinal Rules:**
24
+ 1. If code references something, it probably exists
25
+ 2. Test before declaring something broken
26
+ 3. Verify before modifying
27
+ 4. Fix only what's confirmed broken
28
+ 5. Respect existing configurations
29
+
30
+ ### The Verification-First Approach
31
+
32
+ \`\`\`javascript
33
+ // Before claiming anything doesn't work or exist:
34
+ // Step 1: Test the actual implementation
35
+ const verify = await snow_execute_script_with_output({
36
+ script: \`/* Test the exact code or resource */\`
37
+ });
38
+
39
+ // Step 2: Check if resources exist
40
+ const tableCheck = await snow_discover_table_fields({
41
+ table_name: 'potentially_custom_table'
42
+ });
43
+
44
+ // Step 3: Validate configurations
45
+ const propertyCheck = await snow_property_manager({
46
+ action: 'get',
47
+ name: 'system.property'
48
+ });
49
+
50
+ // Step 4: Only then make informed decisions
51
+ \`\`\`
52
+
53
+ ## Fundamental Rules
54
+
55
+ ### Rule 1: ES5 JavaScript Only in ServiceNow
56
+
57
+ ServiceNow uses the Rhino JavaScript engine which supports only ES5. Modern JavaScript syntax will fail.
58
+
59
+ **Never Use:**
60
+ - \`const\` or \`let\` - use \`var\`
61
+ - Arrow functions \`() => {}\` - use \`function() {}\`
62
+ - Template literals \`\` \`\${var}\` \`\` - use string concatenation
63
+ - Destructuring \`{a, b} = obj\` - use explicit property access
64
+ - \`for...of\` loops - use traditional \`for\` loops
65
+ - Default parameters - use \`typeof\` checks
66
+ - \`async/await\` - use callbacks or GlideAjax
67
+
68
+ **Always Use:**
69
+ \`\`\`javascript
70
+ // ES5 compatible code
71
+ var name = 'value';
72
+ function processData() {
73
+ return 'result';
74
+ }
75
+ var message = 'Hello ' + userName;
76
+ for (var i = 0; i < array.length; i++) {
77
+ var item = array[i];
78
+ }
79
+ \`\`\`
80
+
81
+ ### Rule 2: Background Scripts as Primary Debug Tool
82
+
83
+ Background scripts provide immediate, factual feedback from the actual ServiceNow instance. Use them extensively for verification and debugging.
84
+
85
+ \`\`\`javascript
86
+ // Universal verification pattern
87
+ const verify = await snow_execute_script_with_output({
88
+ script: \`
89
+ gs.info('=== VERIFICATION TEST ===');
90
+
91
+ // Test table existence
92
+ var table = new GlideRecord('table_name');
93
+ gs.info('Table valid: ' + table.isValid());
94
+
95
+ // Test property existence
96
+ var prop = gs.getProperty('property.name');
97
+ gs.info('Property: ' + (prop || 'NOT SET'));
98
+
99
+ // Test actual code
100
+ try {
101
+ // User's code here
102
+ gs.info('SUCCESS');
103
+ } catch(e) {
104
+ gs.error('ERROR: ' + e.message);
105
+ }
106
+ \`
107
+ });
108
+ \`\`\`
109
+
110
+ ### Rule 3: Widget Coherence - Critical Client-Server Communication
111
+
112
+ ServiceNow widgets MUST have perfect communication between client and server scripts. This is not optional - widgets fail when these components don't talk to each other correctly.
113
+
114
+ **The Three-Way Contract:**
115
+
116
+ **Server Script Must:**
117
+ - Initialize all \`data\` properties that HTML will reference
118
+ - Handle every \`input.action\` that client sends
119
+ - Return data in the format client expects
120
+
121
+ **Client Script Must:**
122
+ - Implement every method that HTML calls via \`ng-click\`
123
+ - Use \`c.server.get({action: 'name'})\` for server communication
124
+ - Update \`c.data\` when server responds
125
+
126
+ **HTML Template Must:**
127
+ - Only reference \`data\` properties that server provides
128
+ - Only call methods that client implements
129
+ - Use correct Angular directives and bindings
130
+
131
+ **Critical Communication Points:**
132
+
133
+ 1. **Server → Client Data Flow**
134
+ - Server sets \`data.property\`
135
+ - Client receives via \`c.data.property\`
136
+ - HTML displays with \`{{data.property}}\`
137
+
138
+ 2. **Client → Server Requests**
139
+ - Client sends \`c.server.get({action: 'name'})\`
140
+ - Server receives via \`input.action\`
141
+ - Server processes and returns updated \`data\`
142
+
143
+ 3. **HTML → Client Method Calls**
144
+ - HTML has \`ng-click="methodName()"\`
145
+ - Client must have \`$scope.methodName = function()\`
146
+ - Method typically calls server with \`c.server.get()\`
147
+
148
+ **Common Failures to Avoid:**
149
+ - Action name mismatches between client and server
150
+ - Method name mismatches between HTML and client
151
+ - Property name mismatches between server and HTML
152
+ - Missing handlers for client requests
153
+ - Orphaned data properties or methods
154
+
155
+ **Coherence Validation Checklist:**
156
+ - [ ] Every \`data.property\` in server is used in HTML/client
157
+ - [ ] Every \`ng-click\` in HTML has matching \`$scope.method\` in client
158
+ - [ ] Every \`c.server.get({action})\` in client has matching \`if(input.action)\` in server
159
+ - [ ] Data flows correctly: Server → HTML → Client → Server
160
+ - [ ] No orphaned methods or unused data properties
161
+
162
+ ### Rule 4: Evidence-Based Debugging
163
+
164
+ Follow this systematic approach for all debugging:
165
+
166
+ 1. **Reproduce** - Run the exact failing code
167
+ 2. **Inventory** - List all dependencies
168
+ 3. **Verify** - Test each dependency exists
169
+ 4. **Fix** - Correct only confirmed issues
170
+
171
+ **Fix only:**
172
+ - ✅ Confirmed syntax errors
173
+ - ✅ Verified null references
174
+ - ✅ Missing dependencies (after verification)
175
+ - ✅ Real type mismatches
176
+
177
+ **Never change:**
178
+ - ❌ Unverified resources
179
+ - ❌ Configurations that "seem wrong"
180
+ - ❌ APIs you haven't tested
181
+ - ❌ Working code that could be "better"
182
+
183
+ ## ServiceNow Development Standards
184
+
185
+ ### Table Operations
186
+ - Always verify table existence before operations
187
+ - Use proper field types and references
188
+ - Check for ACLs and permissions
189
+ - Handle large datasets with pagination
190
+
191
+ ### Script Development
192
+ - Use Script Includes for reusable code
193
+ - Implement proper error handling
194
+ - Add meaningful logging with gs.info/warn/error
195
+ - Test in scoped applications when applicable
196
+
197
+ ### Widget Development
198
+ - Ensure HTML/Client/Server coherence
199
+ - Use Angular providers correctly
200
+ - Implement proper data binding
201
+ - Test across different themes and portals
202
+
203
+ ### Flow Development
204
+ - Use proper trigger conditions
205
+ - Implement error handling paths
206
+ - Add appropriate logging actions
207
+ - Test with various data scenarios
208
+
209
+ ## MCP Server Capabilities
210
+
211
+ Snow-Flow includes 12 specialized MCP servers, each providing specific ServiceNow capabilities:
212
+
213
+ ### 1. ServiceNow Deployment Server
214
+ **Purpose:** Widget and artifact deployment with coherence validation
215
+
216
+ **Key Tools:**
217
+ - \`snow_deploy_widget\` - Deploy widgets with HTML/Client/Server validation
218
+ - \`snow_deploy_portal_page\` - Deploy portal pages
219
+ - \`snow_deploy_flow\` - Deploy Flow Designer flows
220
+ - \`snow_create_update_set\` - Create update sets
221
+ - \`snow_validate_deployment\` - Validate deployed artifacts
222
+ - \`snow_rollback_deployment\` - Rollback failed deployments
223
+
224
+ **Special Features:**
225
+ - Automatic widget coherence validation
226
+ - Data flow contract verification
227
+ - Method implementation checking
228
+ - CSS class validation
229
+
230
+ ### 2. ServiceNow Operations Server
231
+ **Purpose:** Core ServiceNow operations and queries
232
+
233
+ **Key Tools:**
234
+ - \`snow_query_table\` - Universal table querying with pagination
235
+ - \`snow_create_incident\` - Create and manage incidents
236
+ - \`snow_update_record\` - Update any table record
237
+ - \`snow_delete_record\` - Delete records with validation
238
+ - \`snow_discover_table_fields\` - Discover table schema
239
+ - \`snow_cmdb_search\` - Search Configuration Management Database
240
+
241
+ **Features:**
242
+ - Full CRUD operations on any table
243
+ - Advanced query capabilities
244
+ - Field discovery and validation
245
+ - Relationship navigation
246
+
247
+ ### 3. ServiceNow Automation Server
248
+ **Purpose:** Script execution and automation
249
+
250
+ **Key Tools:**
251
+ - \`snow_execute_script_with_output\` - Execute scripts with output capture
252
+ - \`snow_get_script_output\` - Retrieve script execution history
253
+ - \`snow_execute_script_sync\` - Synchronous script execution
254
+ - \`snow_get_logs\` - Access system logs
255
+ - \`snow_test_rest_connection\` - Test REST integrations
256
+ - \`snow_trace_execution\` - Trace script execution
257
+ - \`snow_schedule_job\` - Create scheduled jobs
258
+ - \`snow_create_event\` - Trigger system events
259
+
260
+ **Features:**
261
+ - Full output capture (gs.print/info/warn/error)
262
+ - Execution history tracking
263
+ - System log access
264
+ - REST message testing
265
+ - Performance tracing
266
+
267
+ ### 4. ServiceNow Platform Development Server
268
+ **Purpose:** Platform development artifacts
269
+
270
+ **Key Tools:**
271
+ - \`snow_create_script_include\` - Create reusable scripts
272
+ - \`snow_create_business_rule\` - Create business rules
273
+ - \`snow_create_client_script\` - Create client-side scripts
274
+ - \`snow_create_ui_policy\` - Create UI policies
275
+ - \`snow_create_ui_action\` - Create UI actions
276
+ - \`snow_create_ui_page\` - Create UI pages
277
+
278
+ **Features:**
279
+ - Full artifact creation
280
+ - Proper scoping support
281
+ - Condition builder integration
282
+ - Script validation
283
+
284
+ ### 5. ServiceNow Integration Server
285
+ **Purpose:** Integration and data management
286
+
287
+ **Key Tools:**
288
+ - \`snow_create_rest_message\` - Create REST integrations
289
+ - \`snow_create_transform_map\` - Create data transformation maps
290
+ - \`snow_create_import_set\` - Manage import sets
291
+ - \`snow_test_web_service\` - Test web services
292
+ - \`snow_configure_email\` - Configure email settings
293
+
294
+ **Features:**
295
+ - REST/SOAP integration
296
+ - Data transformation
297
+ - Import/Export capabilities
298
+ - Email configuration
299
+
300
+ ### 6. ServiceNow System Properties Server
301
+ **Purpose:** System property management
302
+
303
+ **Key Tools:**
304
+ - \`snow_property_get\` - Retrieve property values
305
+ - \`snow_property_set\` - Set property values
306
+ - \`snow_property_list\` - List properties by pattern
307
+ - \`snow_property_delete\` - Remove properties
308
+ - \`snow_property_bulk_update\` - Bulk operations
309
+ - \`snow_property_export\` - Export to JSON
310
+ - \`snow_property_import\` - Import from JSON
311
+
312
+ **Features:**
313
+ - Full CRUD on sys_properties
314
+ - Bulk operations
315
+ - Import/Export capabilities
316
+ - Property validation
317
+
318
+ ### 7. ServiceNow Update Set Server
319
+ **Purpose:** Change management and deployment
320
+
321
+ **Key Tools:**
322
+ - \`snow_create_update_set\` - Create new update sets
323
+ - \`snow_switch_update_set\` - Switch active update set
324
+ - \`snow_complete_update_set\` - Mark as complete
325
+ - \`snow_preview_update_set\` - Preview changes
326
+ - \`snow_export_update_set\` - Export as XML
327
+
328
+ **Features:**
329
+ - Full update set lifecycle
330
+ - Change tracking
331
+ - XML export/import
332
+ - Conflict detection
333
+
334
+ ### 8. ServiceNow Development Assistant Server
335
+ **Purpose:** Code generation and best practices
336
+
337
+ **Key Tools:**
338
+ - \`snow_generate_code\` - Generate ServiceNow code
339
+ - \`snow_suggest_pattern\` - Suggest design patterns
340
+ - \`snow_review_code\` - Code review and analysis
341
+ - \`snow_optimize_performance\` - Performance recommendations
342
+
343
+ **Features:**
344
+ - Pattern-based code generation
345
+ - Best practice enforcement
346
+ - Performance optimization
347
+ - Security review
348
+
349
+ ### 9. ServiceNow Security & Compliance Server
350
+ **Purpose:** Security and compliance management
351
+
352
+ **Key Tools:**
353
+ - \`snow_create_security_policy\` - Create security policies
354
+ - \`snow_audit_compliance\` - Compliance auditing
355
+ - \`snow_scan_vulnerabilities\` - Vulnerability scanning
356
+ - \`snow_assess_risk\` - Risk assessment
357
+ - \`snow_review_access_control\` - ACL review
358
+
359
+ **Features:**
360
+ - SOX/GDPR/HIPAA compliance
361
+ - Security policy management
362
+ - Vulnerability assessment
363
+ - Access control validation
364
+
365
+ ### 10. ServiceNow Reporting & Analytics Server
366
+ **Purpose:** Reporting and data visualization
367
+
368
+ **Key Tools:**
369
+ - \`snow_create_report\` - Create reports
370
+ - \`snow_create_dashboard\` - Create dashboards
371
+ - \`snow_define_kpi\` - Define KPIs
372
+ - \`snow_schedule_report\` - Schedule report delivery
373
+ - \`snow_analyze_data_quality\` - Data quality analysis
374
+
375
+ **Features:**
376
+ - Advanced reporting
377
+ - Dashboard creation
378
+ - KPI management
379
+ - Scheduled delivery
380
+
381
+ ### 11. ServiceNow Machine Learning Server
382
+ **Purpose:** AI/ML capabilities
383
+
384
+ **Key Tools:**
385
+ - \`snow_train_classifier\` - Train incident classifier
386
+ - \`snow_predict_change_risk\` - Predict change risks
387
+ - \`snow_detect_anomalies\` - Anomaly detection
388
+ - \`snow_forecast_incidents\` - Incident forecasting
389
+ - \`snow_optimize_process\` - Process optimization
390
+
391
+ **Features:**
392
+ - Predictive analytics
393
+ - Pattern recognition
394
+ - Anomaly detection
395
+ - Process optimization
396
+
397
+ ### 12. Snow-Flow Orchestration Server
398
+ **Purpose:** Multi-agent coordination and task management
399
+
400
+ **Key Tools:**
401
+ - \`snow_swarm_init\` - Initialize agent swarms
402
+ - \`snow_agent_spawn\` - Create specialized agents
403
+ - \`snow_task_orchestrate\` - Orchestrate complex tasks
404
+ - \`snow_memory_store\` - Persistent memory storage
405
+ - \`snow_neural_train\` - Train neural networks
406
+ - \`snow_performance_analyze\` - Performance analysis
407
+
408
+ **Features:**
409
+ - Multi-agent coordination
410
+ - Task orchestration
411
+ - Neural network training (TensorFlow.js)
412
+ - Memory management
413
+ - Performance monitoring
414
+
415
+ ## Debugging Best Practices
416
+
417
+ ### Systematic Debugging Protocol
418
+
419
+ 1. **Reproduce the Issue**
420
+ \`\`\`javascript
421
+ // Always use ES5 and test exact code
422
+ const result = await snow_execute_script_with_output({
423
+ script: \`/* Exact failing code in ES5 */\`
424
+ });
425
+ \`\`\`
426
+
427
+ 2. **Verify Dependencies**
428
+ - Check all referenced tables exist
429
+ - Verify all properties are set
430
+ - Confirm all fields are present
431
+ - Test all integrations work
432
+
433
+ 3. **Test in Context**
434
+ - Use same scope and variables
435
+ - Include same imports
436
+ - Test with same data
437
+
438
+ 4. **Apply Evidence-Based Fixes**
439
+ - Fix only confirmed issues
440
+ - Document why changes were made
441
+ - Test fixes thoroughly
442
+
443
+ ### Common Verification Patterns
444
+
445
+ **Table Verification:**
446
+ \`\`\`javascript
447
+ var table = new GlideRecord('table_name');
448
+ gs.info('Table exists: ' + table.isValid());
449
+ \`\`\`
450
+
451
+ **Property Verification:**
452
+ \`\`\`javascript
453
+ var prop = gs.getProperty('property.name');
454
+ gs.info('Property value: ' + (prop || 'NOT SET'));
455
+ \`\`\`
456
+
457
+ **Field Verification:**
458
+ \`\`\`javascript
459
+ var gr = new GlideRecord('table');
460
+ var element = gr.getElement('field_name');
461
+ gs.info('Field exists: ' + (element ? 'Yes' : 'No'));
462
+ \`\`\`
463
+
464
+ ## Command Reference
465
+
466
+ ### Core Commands
467
+ - \`./snow-flow start\` - Start orchestration system
468
+ - \`./snow-flow status\` - System status
469
+ - \`./snow-flow monitor\` - Real-time monitoring
470
+
471
+ ### Agent Management
472
+ - \`./snow-flow agent spawn <type>\` - Create agents
473
+ - \`./snow-flow agent list\` - List active agents
474
+
475
+ ### Task Management
476
+ - \`./snow-flow task create\` - Create tasks
477
+ - \`./snow-flow task list\` - View task queue
478
+
479
+ ### Memory Operations
480
+ - \`./snow-flow memory store <key> <data>\` - Store data
481
+ - \`./snow-flow memory get <key>\` - Retrieve data
482
+ - \`./snow-flow memory list\` - List all keys
483
+
484
+ ### SPARC Modes
485
+ - \`./snow-flow sparc "<task>"\` - Orchestrator mode
486
+ - \`./snow-flow sparc run <mode> "<task>"\` - Specific mode
487
+ - \`./snow-flow sparc tdd "<feature>"\` - Test-driven development
488
+
489
+ ### Swarm Coordination
490
+ - \`./snow-flow swarm "<objective>"\` - Multi-agent coordination
491
+ - Options: \`--strategy\`, \`--mode\`, \`--parallel\`, \`--monitor\`
492
+
493
+ ## Workflow Guidelines
494
+
495
+ ### Development Workflow
496
+ 1. **Plan** - Use TodoWrite for task management
497
+ 2. **Verify** - Check existing resources
498
+ 3. **Develop** - Follow ES5 standards
499
+ 4. **Test** - Use background scripts
500
+ 5. **Deploy** - Use update sets
501
+ 6. **Validate** - Verify deployment
502
+
503
+ ### Testing Workflow
504
+ 1. Run unit tests with background scripts
505
+ 2. Test integrations with REST tools
506
+ 3. Validate UI with widget coherence
507
+ 4. Check performance with tracing
508
+ 5. Review logs for errors
509
+
510
+ ### Debugging Workflow
511
+ 1. Reproduce issue exactly
512
+ 2. Gather evidence with scripts
513
+ 3. Verify all assumptions
514
+ 4. Apply minimal fixes
515
+ 5. Test thoroughly
516
+ 6. Document changes
517
+
518
+ ## Important Reminders
519
+
520
+ ### Always Remember
521
+ - Every ServiceNow instance is unique
522
+ - Custom implementations exist that you don't know about
523
+ - Preview/beta features may be available
524
+ - Organization-specific configurations are common
525
+ - Test everything before making assumptions
526
+
527
+ ### Never Assume
528
+ - That something doesn't exist without verification
529
+ - That configurations are wrong without testing
530
+ - That APIs aren't available without checking
531
+ - That code won't work without running it
532
+ - That you know better than existing implementations
533
+
534
+ ### Golden Rules
535
+ 1. **Verify First** - Test before declaring broken
536
+ 2. **ES5 Only** - No modern JavaScript in ServiceNow
537
+ 3. **Evidence-Based** - Make decisions on facts, not assumptions
538
+ 4. **Minimal Changes** - Fix only what's broken
539
+ 5. **Respect Context** - Understand why things exist as they do
540
+
541
+ ## Conclusion
542
+
543
+ Snow-Flow is a powerful framework for ServiceNow development that emphasizes verification, testing, and evidence-based decision making. By following these guidelines and best practices, you ensure reliable, maintainable, and effective ServiceNow solutions.
544
+
545
+ Remember: Your job is to solve problems, not to judge implementations. Every environment has its reasons for existing configurations. Verify, test, and respect what you find.`;
546
+ //# sourceMappingURL=claude-md-template.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.6",
3
+ "version": "3.4.8",
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",