snow-flow 3.5.2 → 3.5.3
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.
|
@@ -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: \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 script: 'data.message = \"Hello\";', // ServiceNow uses 'script' field\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 script: 'data.updated = true;' // ServiceNow uses 'script' field\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.";
|
|
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## CRITICAL: Widget Debugging Must Use Local Sync\n\n### \uD83D\uDD34 When User Reports Widget Issues, ALWAYS Use `snow_pull_artifact` FIRST!\n\n**Common scenarios that REQUIRE Local Sync:**\n- \"Widget skips questions\" \u2192 `snow_pull_artifact`\n- \"Form doesn't submit properly\" \u2192 `snow_pull_artifact`\n- \"Data not displaying\" \u2192 `snow_pull_artifact`\n- \"Button doesn't work\" \u2192 `snow_pull_artifact`\n- \"Debug this widget\" \u2192 `snow_pull_artifact`\n- \"Fix widget issue\" \u2192 `snow_pull_artifact`\n\n**DO NOT use `snow_query_table` for widget debugging!** It will hit token limits and you can't use native search/edit tools.\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### \uD83D\uDD04 CRITICAL: Sync User Modifications Before Working\n\n**When a user mentions they've modified an artifact directly in ServiceNow, ALWAYS fetch the latest version first!**\n\nIf a user says any of these:\n- \"I've updated the widget in ServiceNow\"\n- \"I made some changes to the flow\"\n- \"I modified the script\"\n- \"I adjusted the configuration\"\n- \"Ik heb het zelf aangepast\" (Dutch: I adjusted it myself)\n\n**YOU MUST:**\n\n1. **Immediately fetch the current version from ServiceNow:**\n```javascript\n// For any artifact the user has modified\nconst currentVersion = await snow_query_table({\n table: 'artifact_table_name',\n query: `sys_id=${artifact_sys_id}`,\n fields: ['*'], // Get all fields\n limit: 1\n});\n\n// Or for widgets specifically\nconst widgetData = await snow_query_table({\n table: 'sp_widget',\n query: `sys_id=${widget_sys_id}`,\n fields: ['name', 'template', 'client_script', 'script', 'css', 'option_schema'],\n limit: 1\n});\n\n// Or use snow_get_by_sysid for comprehensive retrieval\nconst artifact = await snow_get_by_sysid({\n table: 'table_name',\n sys_id: 'the_sys_id'\n});\n```\n\n2. **Analyze the user's modifications:**\n - Review what they changed\n - Understand their intent\n - Preserve their modifications\n\n3. **Build upon their changes:**\n - Don't overwrite their work\n - Integrate new features with their modifications\n - Maintain their code style and patterns\n\n4. **Inform the user:**\n - Acknowledge that you've fetched their latest changes\n - Summarize what modifications you found\n - Explain how you'll build upon their work\n\n**Example Workflow:**\n```javascript\n// User: \"I've updated the widget to add a loading spinner\"\n// Snow-Flow response:\n\n// 1. Fetch current version\nconst widget = await snow_query_table({\n table: 'sp_widget',\n query: `sys_id=${widgetSysId}`,\n fields: ['*'],\n limit: 1\n});\n\n// 2. Analyze changes\nconsole.log(\"\u2705 Fetched your latest widget version from ServiceNow\");\nconsole.log(\"\uD83D\uDCDD I see you've added a loading spinner in the template\");\n\n// 3. Work with the updated version\n// ... make additional changes based on user's modifications ...\n```\n\n**Why This Matters:**\n- User modifications are not tracked locally\n- Working with outdated versions causes conflicts\n- User's work could be lost if not synced\n- Builds trust by respecting user's contributions\n- Ensures coherent development flow\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: Use Local Sync for Widget Debugging - NOT snow_query_table!\n\n**CRITICAL: When debugging widgets, ALWAYS use `snow_pull_artifact` first!**\n\n```javascript\n// \u2705 CORRECT - Use Local Sync for widget debugging\nsnow_pull_artifact({ \n sys_id: 'widget_sys_id',\n table: 'sp_widget' \n});\n// Now use Claude Code native search, multi-file edit, etc.\n\n// \u274C WRONG - Don't use snow_query_table for debugging widgets\nsnow_query_table({ \n table: 'sp_widget',\n query: 'sys_id=...',\n fields: ['template', 'script', 'client_script'] \n});\n// This hits token limits and can't use native tools!\n```\n\n**Why Local Sync for Widget Debugging:**\n- **No token limits** - Handle widgets of ANY size\n- **Native search** - Find issues across all files instantly\n- **Multi-file view** - See relationships between components\n- **Better debugging** - Trace data flow, find missing methods\n- **Coherence checking** - Validate all parts work together\n\n**Widget Debugging Workflow:**\n1. User reports issue \u2192 `snow_pull_artifact`\n2. Search for error patterns across files\n3. Fix using multi-file edit\n4. Validate coherence \u2192 `snow_validate_artifact_coherence`\n5. Push fixes back \u2192 `snow_push_artifact`\n\n**IMPORTANT: Use Local Sync Instead of Query for Large Widgets**\n\nWhen you see \"exceeds maximum allowed tokens\" errors, don't try to fetch fields separately with `snow_query_table`. Use Local Sync instead:\n\n```javascript\n// \u274C WRONG - Don't do this when debugging:\nsnow_query_table({ table: 'sp_widget', fields: ['name'] });\nsnow_query_table({ table: 'sp_widget', fields: ['script'] });\nsnow_query_table({ table: 'sp_widget', fields: ['client_script'] });\n// This is inefficient and can't use native tools!\n\n// \u2705 CORRECT - Use Local Sync:\nsnow_pull_artifact({ \n sys_id: '01d01d6983176a502a7ea130ceaad376' \n});\n// All files available locally with NO token limits!\n```\n\n**Local Sync Benefits:**\n- Handles widgets of ANY size automatically\n- All files available for native tool usage\n- Maintains relationships between components\n- Enables powerful search and refactoring\n\n### Rule 5: 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 script: 'data.message = \"Hello\";', // ServiceNow uses 'script' field\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 script: 'data.updated = true;' // ServiceNow uses 'script' field\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. ServiceNow Local Development Server\n**Purpose:** Bridge between ServiceNow artifacts and Claude Code's native development tools\n\n**Key Tools:**\n- `snow_pull_artifact` - Pull any ServiceNow artifact to local files\n- `snow_push_artifact` - Push local changes back with validation\n- `snow_validate_artifact_coherence` - Validate artifact relationships\n- `snow_list_supported_artifacts` - List all supported artifact types\n- `snow_sync_status` - Check sync status of local artifacts\n- `snow_sync_cleanup` - Clean up local files after sync\n- `snow_convert_to_es5` - Convert modern JavaScript to ES5\n\n**Features:**\n- Supports 12+ artifact types dynamically\n- Smart field chunking for large artifacts\n- ES5 validation for server-side scripts\n- Coherence validation for widgets\n- Full Claude Code native tool integration\n\n**Supported Artifact Types:**\n- Service Portal Widgets (`sp_widget`)\n- Flow Designer Flows (`sys_hub_flow`)\n- Script Includes (`sys_script_include`)\n- Business Rules (`sys_script`)\n- UI Pages (`sys_ui_page`)\n- Client Scripts (`sys_script_client`)\n- UI Policies (`sys_ui_policy`)\n- REST Messages (`sys_rest_message`)\n- Transform Maps (`sys_transform_map`)\n- Scheduled Jobs (`sysauto_script`)\n- Fix Scripts (`sys_script_fix`)\n\n### 13. 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**Features:**\n- Multi-agent coordination\n- Task orchestration\n- Neural network training (TensorFlow.js)\n- Memory management\n- Performance monitoring\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## Local Development with Artifact Sync\n\n### Dynamic Artifact Synchronization\n\nThe Local Development Server enables editing ServiceNow artifacts using Claude Code's native file tools. This creates a powerful development bridge between ServiceNow and local development environments.\n\n**Workflow:**\n\n1. **Pull Artifact to Local Files**\n ```javascript\n // Auto-detect artifact type\n snow_pull_artifact({ sys_id: 'any_sys_id' });\n \n // Or specify table for faster pull\n snow_pull_artifact({ \n sys_id: 'widget_sys_id',\n table: 'sp_widget' \n });\n ```\n\n2. **Edit with Claude Code Native Tools**\n - Full search capabilities across files\n - Multi-file editing and refactoring\n - Syntax highlighting and validation\n - Git-like diff viewing\n - Go-to-definition and references\n\n3. **Validate Coherence**\n ```javascript\n // Check artifact relationships\n snow_validate_artifact_coherence({ \n sys_id: 'artifact_sys_id' \n });\n ```\n\n4. **Push Changes Back**\n ```javascript\n // Push with automatic validation\n snow_push_artifact({ sys_id: 'artifact_sys_id' });\n \n // Force push despite warnings\n snow_push_artifact({ \n sys_id: 'artifact_sys_id',\n force: true \n });\n ```\n\n5. **Clean Up**\n ```javascript\n // Remove local files after sync\n snow_sync_cleanup({ sys_id: 'artifact_sys_id' });\n ```\n\n**Artifact Registry:**\n\nEach artifact type is configured with:\n- Field mappings to local files\n- Context-aware wrappers for better editing\n- ES5 validation flags for server scripts\n- Coherence rules for interconnected fields\n- Preprocessors/postprocessors for data transformation\n\n**File Structure Example:**\n```\n/tmp/snow-flow-artifacts/\n\u251C\u2500\u2500 widgets/\n\u2502 \u2514\u2500\u2500 my_widget/\n\u2502 \u251C\u2500\u2500 my_widget.html # Template\n\u2502 \u251C\u2500\u2500 my_widget.server.js # Server script (ES5)\n\u2502 \u251C\u2500\u2500 my_widget.client.js # Client script\n\u2502 \u251C\u2500\u2500 my_widget.css # Styles\n\u2502 \u251C\u2500\u2500 my_widget.config.json # Configuration\n\u2502 \u2514\u2500\u2500 README.md # Context & instructions\n\u251C\u2500\u2500 script_includes/\n\u2502 \u2514\u2500\u2500 MyScriptInclude/\n\u2502 \u251C\u2500\u2500 MyScriptInclude.js # Script\n\u2502 \u2514\u2500\u2500 MyScriptInclude.docs.md # Documentation\n\u2514\u2500\u2500 business_rules/\n \u2514\u2500\u2500 my_rule/\n \u251C\u2500\u2500 my_rule.js # Rule script\n \u2514\u2500\u2500 my_rule.condition.js # Condition\n```\n\n**Benefits:**\n- Use your favorite editor features\n- Full search and replace capabilities\n- Version control integration\n- Bulk operations across artifacts\n- Offline development capability\n- Advanced refactoring tools\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
|
|
@@ -14,6 +14,20 @@ This document provides comprehensive instructions for Snow-Flow, an advanced Ser
|
|
|
14
14
|
6. [Command Reference](#command-reference)
|
|
15
15
|
7. [Workflow Guidelines](#workflow-guidelines)
|
|
16
16
|
|
|
17
|
+
## CRITICAL: Widget Debugging Must Use Local Sync
|
|
18
|
+
|
|
19
|
+
### 🔴 When User Reports Widget Issues, ALWAYS Use \`snow_pull_artifact\` FIRST!
|
|
20
|
+
|
|
21
|
+
**Common scenarios that REQUIRE Local Sync:**
|
|
22
|
+
- "Widget skips questions" → \`snow_pull_artifact\`
|
|
23
|
+
- "Form doesn't submit properly" → \`snow_pull_artifact\`
|
|
24
|
+
- "Data not displaying" → \`snow_pull_artifact\`
|
|
25
|
+
- "Button doesn't work" → \`snow_pull_artifact\`
|
|
26
|
+
- "Debug this widget" → \`snow_pull_artifact\`
|
|
27
|
+
- "Fix widget issue" → \`snow_pull_artifact\`
|
|
28
|
+
|
|
29
|
+
**DO NOT use \`snow_query_table\` for widget debugging!** It will hit token limits and you can't use native search/edit tools.
|
|
30
|
+
|
|
17
31
|
## Core Philosophy
|
|
18
32
|
|
|
19
33
|
### The Prime Directive: Verify, Don't Assume
|
|
@@ -50,6 +64,87 @@ const propertyCheck = await snow_property_manager({
|
|
|
50
64
|
// Step 4: Only then make informed decisions
|
|
51
65
|
\`\`\`
|
|
52
66
|
|
|
67
|
+
### 🔄 CRITICAL: Sync User Modifications Before Working
|
|
68
|
+
|
|
69
|
+
**When a user mentions they've modified an artifact directly in ServiceNow, ALWAYS fetch the latest version first!**
|
|
70
|
+
|
|
71
|
+
If a user says any of these:
|
|
72
|
+
- "I've updated the widget in ServiceNow"
|
|
73
|
+
- "I made some changes to the flow"
|
|
74
|
+
- "I modified the script"
|
|
75
|
+
- "I adjusted the configuration"
|
|
76
|
+
- "Ik heb het zelf aangepast" (Dutch: I adjusted it myself)
|
|
77
|
+
|
|
78
|
+
**YOU MUST:**
|
|
79
|
+
|
|
80
|
+
1. **Immediately fetch the current version from ServiceNow:**
|
|
81
|
+
\`\`\`javascript
|
|
82
|
+
// For any artifact the user has modified
|
|
83
|
+
const currentVersion = await snow_query_table({
|
|
84
|
+
table: 'artifact_table_name',
|
|
85
|
+
query: \`sys_id=\${artifact_sys_id}\`,
|
|
86
|
+
fields: ['*'], // Get all fields
|
|
87
|
+
limit: 1
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Or for widgets specifically
|
|
91
|
+
const widgetData = await snow_query_table({
|
|
92
|
+
table: 'sp_widget',
|
|
93
|
+
query: \`sys_id=\${widget_sys_id}\`,
|
|
94
|
+
fields: ['name', 'template', 'client_script', 'script', 'css', 'option_schema'],
|
|
95
|
+
limit: 1
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Or use snow_get_by_sysid for comprehensive retrieval
|
|
99
|
+
const artifact = await snow_get_by_sysid({
|
|
100
|
+
table: 'table_name',
|
|
101
|
+
sys_id: 'the_sys_id'
|
|
102
|
+
});
|
|
103
|
+
\`\`\`
|
|
104
|
+
|
|
105
|
+
2. **Analyze the user's modifications:**
|
|
106
|
+
- Review what they changed
|
|
107
|
+
- Understand their intent
|
|
108
|
+
- Preserve their modifications
|
|
109
|
+
|
|
110
|
+
3. **Build upon their changes:**
|
|
111
|
+
- Don't overwrite their work
|
|
112
|
+
- Integrate new features with their modifications
|
|
113
|
+
- Maintain their code style and patterns
|
|
114
|
+
|
|
115
|
+
4. **Inform the user:**
|
|
116
|
+
- Acknowledge that you've fetched their latest changes
|
|
117
|
+
- Summarize what modifications you found
|
|
118
|
+
- Explain how you'll build upon their work
|
|
119
|
+
|
|
120
|
+
**Example Workflow:**
|
|
121
|
+
\`\`\`javascript
|
|
122
|
+
// User: "I've updated the widget to add a loading spinner"
|
|
123
|
+
// Snow-Flow response:
|
|
124
|
+
|
|
125
|
+
// 1. Fetch current version
|
|
126
|
+
const widget = await snow_query_table({
|
|
127
|
+
table: 'sp_widget',
|
|
128
|
+
query: \`sys_id=\${widgetSysId}\`,
|
|
129
|
+
fields: ['*'],
|
|
130
|
+
limit: 1
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 2. Analyze changes
|
|
134
|
+
console.log("✅ Fetched your latest widget version from ServiceNow");
|
|
135
|
+
console.log("📝 I see you've added a loading spinner in the template");
|
|
136
|
+
|
|
137
|
+
// 3. Work with the updated version
|
|
138
|
+
// ... make additional changes based on user's modifications ...
|
|
139
|
+
\`\`\`
|
|
140
|
+
|
|
141
|
+
**Why This Matters:**
|
|
142
|
+
- User modifications are not tracked locally
|
|
143
|
+
- Working with outdated versions causes conflicts
|
|
144
|
+
- User's work could be lost if not synced
|
|
145
|
+
- Builds trust by respecting user's contributions
|
|
146
|
+
- Ensures coherent development flow
|
|
147
|
+
|
|
53
148
|
## Fundamental Rules
|
|
54
149
|
|
|
55
150
|
### Rule 1: 🚨 ES5 JavaScript ONLY in ServiceNow - NO EXCEPTIONS!
|
|
@@ -337,7 +432,66 @@ ServiceNow widgets MUST have perfect communication between client and server scr
|
|
|
337
432
|
- [ ] Data flows correctly: Server → HTML → Client → Server
|
|
338
433
|
- [ ] No orphaned methods or unused data properties
|
|
339
434
|
|
|
340
|
-
### Rule 4:
|
|
435
|
+
### Rule 4: Use Local Sync for Widget Debugging - NOT snow_query_table!
|
|
436
|
+
|
|
437
|
+
**CRITICAL: When debugging widgets, ALWAYS use \`snow_pull_artifact\` first!**
|
|
438
|
+
|
|
439
|
+
\`\`\`javascript
|
|
440
|
+
// ✅ CORRECT - Use Local Sync for widget debugging
|
|
441
|
+
snow_pull_artifact({
|
|
442
|
+
sys_id: 'widget_sys_id',
|
|
443
|
+
table: 'sp_widget'
|
|
444
|
+
});
|
|
445
|
+
// Now use Claude Code native search, multi-file edit, etc.
|
|
446
|
+
|
|
447
|
+
// ❌ WRONG - Don't use snow_query_table for debugging widgets
|
|
448
|
+
snow_query_table({
|
|
449
|
+
table: 'sp_widget',
|
|
450
|
+
query: 'sys_id=...',
|
|
451
|
+
fields: ['template', 'script', 'client_script']
|
|
452
|
+
});
|
|
453
|
+
// This hits token limits and can't use native tools!
|
|
454
|
+
\`\`\`
|
|
455
|
+
|
|
456
|
+
**Why Local Sync for Widget Debugging:**
|
|
457
|
+
- **No token limits** - Handle widgets of ANY size
|
|
458
|
+
- **Native search** - Find issues across all files instantly
|
|
459
|
+
- **Multi-file view** - See relationships between components
|
|
460
|
+
- **Better debugging** - Trace data flow, find missing methods
|
|
461
|
+
- **Coherence checking** - Validate all parts work together
|
|
462
|
+
|
|
463
|
+
**Widget Debugging Workflow:**
|
|
464
|
+
1. User reports issue → \`snow_pull_artifact\`
|
|
465
|
+
2. Search for error patterns across files
|
|
466
|
+
3. Fix using multi-file edit
|
|
467
|
+
4. Validate coherence → \`snow_validate_artifact_coherence\`
|
|
468
|
+
5. Push fixes back → \`snow_push_artifact\`
|
|
469
|
+
|
|
470
|
+
**IMPORTANT: Use Local Sync Instead of Query for Large Widgets**
|
|
471
|
+
|
|
472
|
+
When you see "exceeds maximum allowed tokens" errors, don't try to fetch fields separately with \`snow_query_table\`. Use Local Sync instead:
|
|
473
|
+
|
|
474
|
+
\`\`\`javascript
|
|
475
|
+
// ❌ WRONG - Don't do this when debugging:
|
|
476
|
+
snow_query_table({ table: 'sp_widget', fields: ['name'] });
|
|
477
|
+
snow_query_table({ table: 'sp_widget', fields: ['script'] });
|
|
478
|
+
snow_query_table({ table: 'sp_widget', fields: ['client_script'] });
|
|
479
|
+
// This is inefficient and can't use native tools!
|
|
480
|
+
|
|
481
|
+
// ✅ CORRECT - Use Local Sync:
|
|
482
|
+
snow_pull_artifact({
|
|
483
|
+
sys_id: '01d01d6983176a502a7ea130ceaad376'
|
|
484
|
+
});
|
|
485
|
+
// All files available locally with NO token limits!
|
|
486
|
+
\`\`\`
|
|
487
|
+
|
|
488
|
+
**Local Sync Benefits:**
|
|
489
|
+
- Handles widgets of ANY size automatically
|
|
490
|
+
- All files available for native tool usage
|
|
491
|
+
- Maintains relationships between components
|
|
492
|
+
- Enables powerful search and refactoring
|
|
493
|
+
|
|
494
|
+
### Rule 5: Evidence-Based Debugging
|
|
341
495
|
|
|
342
496
|
Follow this systematic approach for all debugging:
|
|
343
497
|
|
|
@@ -618,7 +772,39 @@ ServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script
|
|
|
618
772
|
- Anomaly detection
|
|
619
773
|
- Process optimization
|
|
620
774
|
|
|
621
|
-
### 12.
|
|
775
|
+
### 12. ServiceNow Local Development Server
|
|
776
|
+
**Purpose:** Bridge between ServiceNow artifacts and Claude Code's native development tools
|
|
777
|
+
|
|
778
|
+
**Key Tools:**
|
|
779
|
+
- \`snow_pull_artifact\` - Pull any ServiceNow artifact to local files
|
|
780
|
+
- \`snow_push_artifact\` - Push local changes back with validation
|
|
781
|
+
- \`snow_validate_artifact_coherence\` - Validate artifact relationships
|
|
782
|
+
- \`snow_list_supported_artifacts\` - List all supported artifact types
|
|
783
|
+
- \`snow_sync_status\` - Check sync status of local artifacts
|
|
784
|
+
- \`snow_sync_cleanup\` - Clean up local files after sync
|
|
785
|
+
- \`snow_convert_to_es5\` - Convert modern JavaScript to ES5
|
|
786
|
+
|
|
787
|
+
**Features:**
|
|
788
|
+
- Supports 12+ artifact types dynamically
|
|
789
|
+
- Smart field chunking for large artifacts
|
|
790
|
+
- ES5 validation for server-side scripts
|
|
791
|
+
- Coherence validation for widgets
|
|
792
|
+
- Full Claude Code native tool integration
|
|
793
|
+
|
|
794
|
+
**Supported Artifact Types:**
|
|
795
|
+
- Service Portal Widgets (\`sp_widget\`)
|
|
796
|
+
- Flow Designer Flows (\`sys_hub_flow\`)
|
|
797
|
+
- Script Includes (\`sys_script_include\`)
|
|
798
|
+
- Business Rules (\`sys_script\`)
|
|
799
|
+
- UI Pages (\`sys_ui_page\`)
|
|
800
|
+
- Client Scripts (\`sys_script_client\`)
|
|
801
|
+
- UI Policies (\`sys_ui_policy\`)
|
|
802
|
+
- REST Messages (\`sys_rest_message\`)
|
|
803
|
+
- Transform Maps (\`sys_transform_map\`)
|
|
804
|
+
- Scheduled Jobs (\`sysauto_script\`)
|
|
805
|
+
- Fix Scripts (\`sys_script_fix\`)
|
|
806
|
+
|
|
807
|
+
### 13. Snow-Flow Orchestration Server
|
|
622
808
|
**Purpose:** Multi-agent coordination and task management
|
|
623
809
|
|
|
624
810
|
**Key Tools:**
|
|
@@ -629,6 +815,13 @@ ServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script
|
|
|
629
815
|
- \`neural_train\` - Train neural networks with TensorFlow.js
|
|
630
816
|
- \`performance_report\` - Generate performance reports
|
|
631
817
|
|
|
818
|
+
**Features:**
|
|
819
|
+
- Multi-agent coordination
|
|
820
|
+
- Task orchestration
|
|
821
|
+
- Neural network training (TensorFlow.js)
|
|
822
|
+
- Memory management
|
|
823
|
+
- Performance monitoring
|
|
824
|
+
|
|
632
825
|
### Additional Servers:
|
|
633
826
|
|
|
634
827
|
**ServiceNow CMDB/Event/HR/CSM/DevOps Server** - CI management, event correlation, HR processes, customer service, DevOps pipelines
|
|
@@ -646,6 +839,97 @@ ServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script
|
|
|
646
839
|
- Memory management
|
|
647
840
|
- Performance monitoring
|
|
648
841
|
|
|
842
|
+
## Local Development with Artifact Sync
|
|
843
|
+
|
|
844
|
+
### Dynamic Artifact Synchronization
|
|
845
|
+
|
|
846
|
+
The Local Development Server enables editing ServiceNow artifacts using Claude Code's native file tools. This creates a powerful development bridge between ServiceNow and local development environments.
|
|
847
|
+
|
|
848
|
+
**Workflow:**
|
|
849
|
+
|
|
850
|
+
1. **Pull Artifact to Local Files**
|
|
851
|
+
\`\`\`javascript
|
|
852
|
+
// Auto-detect artifact type
|
|
853
|
+
snow_pull_artifact({ sys_id: 'any_sys_id' });
|
|
854
|
+
|
|
855
|
+
// Or specify table for faster pull
|
|
856
|
+
snow_pull_artifact({
|
|
857
|
+
sys_id: 'widget_sys_id',
|
|
858
|
+
table: 'sp_widget'
|
|
859
|
+
});
|
|
860
|
+
\`\`\`
|
|
861
|
+
|
|
862
|
+
2. **Edit with Claude Code Native Tools**
|
|
863
|
+
- Full search capabilities across files
|
|
864
|
+
- Multi-file editing and refactoring
|
|
865
|
+
- Syntax highlighting and validation
|
|
866
|
+
- Git-like diff viewing
|
|
867
|
+
- Go-to-definition and references
|
|
868
|
+
|
|
869
|
+
3. **Validate Coherence**
|
|
870
|
+
\`\`\`javascript
|
|
871
|
+
// Check artifact relationships
|
|
872
|
+
snow_validate_artifact_coherence({
|
|
873
|
+
sys_id: 'artifact_sys_id'
|
|
874
|
+
});
|
|
875
|
+
\`\`\`
|
|
876
|
+
|
|
877
|
+
4. **Push Changes Back**
|
|
878
|
+
\`\`\`javascript
|
|
879
|
+
// Push with automatic validation
|
|
880
|
+
snow_push_artifact({ sys_id: 'artifact_sys_id' });
|
|
881
|
+
|
|
882
|
+
// Force push despite warnings
|
|
883
|
+
snow_push_artifact({
|
|
884
|
+
sys_id: 'artifact_sys_id',
|
|
885
|
+
force: true
|
|
886
|
+
});
|
|
887
|
+
\`\`\`
|
|
888
|
+
|
|
889
|
+
5. **Clean Up**
|
|
890
|
+
\`\`\`javascript
|
|
891
|
+
// Remove local files after sync
|
|
892
|
+
snow_sync_cleanup({ sys_id: 'artifact_sys_id' });
|
|
893
|
+
\`\`\`
|
|
894
|
+
|
|
895
|
+
**Artifact Registry:**
|
|
896
|
+
|
|
897
|
+
Each artifact type is configured with:
|
|
898
|
+
- Field mappings to local files
|
|
899
|
+
- Context-aware wrappers for better editing
|
|
900
|
+
- ES5 validation flags for server scripts
|
|
901
|
+
- Coherence rules for interconnected fields
|
|
902
|
+
- Preprocessors/postprocessors for data transformation
|
|
903
|
+
|
|
904
|
+
**File Structure Example:**
|
|
905
|
+
\`\`\`
|
|
906
|
+
/tmp/snow-flow-artifacts/
|
|
907
|
+
├── widgets/
|
|
908
|
+
│ └── my_widget/
|
|
909
|
+
│ ├── my_widget.html # Template
|
|
910
|
+
│ ├── my_widget.server.js # Server script (ES5)
|
|
911
|
+
│ ├── my_widget.client.js # Client script
|
|
912
|
+
│ ├── my_widget.css # Styles
|
|
913
|
+
│ ├── my_widget.config.json # Configuration
|
|
914
|
+
│ └── README.md # Context & instructions
|
|
915
|
+
├── script_includes/
|
|
916
|
+
│ └── MyScriptInclude/
|
|
917
|
+
│ ├── MyScriptInclude.js # Script
|
|
918
|
+
│ └── MyScriptInclude.docs.md # Documentation
|
|
919
|
+
└── business_rules/
|
|
920
|
+
└── my_rule/
|
|
921
|
+
├── my_rule.js # Rule script
|
|
922
|
+
└── my_rule.condition.js # Condition
|
|
923
|
+
\`\`\`
|
|
924
|
+
|
|
925
|
+
**Benefits:**
|
|
926
|
+
- Use your favorite editor features
|
|
927
|
+
- Full search and replace capabilities
|
|
928
|
+
- Version control integration
|
|
929
|
+
- Bulk operations across artifacts
|
|
930
|
+
- Offline development capability
|
|
931
|
+
- Advanced refactoring tools
|
|
932
|
+
|
|
649
933
|
## Debugging Best Practices
|
|
650
934
|
|
|
651
935
|
### Systematic Debugging Protocol
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.3",
|
|
4
4
|
"description": "ServiceNow development framework with MCP server integration. Executes background scripts using ES5 JavaScript only (ServiceNow Rhino engine requirement). Provides 18 MCP servers including local development sync for editing ServiceNow artifacts with Claude Code native tools, widget deployment with coherence validation, table operations, script execution, machine learning, advanced features, and comprehensive platform management.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|