snow-flow 3.4.36 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +414 -287
- package/dist/cli/deploy-artifact.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -2
- package/dist/mcp/enhancements/smart-query-enhancement.d.ts +49 -0
- package/dist/mcp/enhancements/smart-query-enhancement.js +233 -0
- package/dist/mcp/servicenow-deployment-mcp.js +1 -1
- package/dist/mcp/servicenow-local-development-mcp.d.ts +48 -0
- package/dist/mcp/servicenow-local-development-mcp.js +570 -0
- package/dist/mcp/servicenow-mcp-server.js +2 -2
- package/dist/queen/agent-factory.js +134 -52
- package/dist/queen/queen-knowledge-base.d.ts +151 -0
- package/dist/queen/queen-knowledge-base.js +283 -0
- package/dist/queen/servicenow-queen.d.ts +129 -2
- package/dist/queen/servicenow-queen.js +1069 -618
- package/dist/services/widget-deployment-service.d.ts +1 -1
- package/dist/services/widget-deployment-service.js +1 -1
- package/dist/templates/claude-md-template.d.ts +1 -1
- package/dist/templates/claude-md-template.js +2 -2
- package/dist/types/servicenow.types.d.ts +1 -1
- package/dist/utils/artifact-local-sync.d.ts +115 -0
- package/dist/utils/artifact-local-sync.js +705 -0
- package/dist/utils/artifact-sync/artifact-registry.d.ts +66 -0
- package/dist/utils/artifact-sync/artifact-registry.js +450 -0
- package/dist/utils/artifact-sync/index.d.ts +33 -0
- package/dist/utils/artifact-sync/index.js +52 -0
- package/dist/utils/dependency-detector.d.ts +1 -1
- package/dist/utils/dependency-detector.js +1 -1
- package/dist/utils/mcp-tool-registry.js +109 -0
- package/dist/utils/servicenow-client.d.ts +1 -1
- package/dist/utils/servicenow-client.js +4 -8
- package/dist/utils/smart-field-fetcher.d.ts +68 -0
- package/dist/utils/smart-field-fetcher.js +395 -0
- package/package.json +2 -2
- package/website/.dockerignore +64 -0
- package/website/Dockerfile +36 -0
- package/website/README.md +40 -1
- package/website/cloudbuild.yaml +69 -0
- package/website/components/README.md +419 -0
- package/website/components/code-display/CodeDisplay.css +583 -0
- package/website/components/code-display/CodeDisplay.html +200 -0
- package/website/components/code-display/CodeDisplay.js +375 -0
- package/website/components/code-display/CodeDisplay.jsx +268 -0
- package/website/components/demo/ComponentLibraryDemo.html +845 -0
- package/website/components/feature-cards/FeatureCards.css +573 -0
- package/website/components/feature-cards/FeatureCards.html +247 -0
- package/website/components/feature-cards/FeatureCards.js +382 -0
- package/website/components/feature-cards/FeatureCards.jsx +235 -0
- package/website/components/hero/Hero.css +558 -0
- package/website/components/hero/Hero.html +98 -0
- package/website/components/hero/Hero.js +415 -0
- package/website/components/hero/Hero.jsx +214 -0
- package/website/components/interactive/InteractiveElements.css +776 -0
- package/website/components/interactive/InteractiveElements.html +283 -0
- package/website/components/interactive/InteractiveElements.js +489 -0
- package/website/components/interactive/InteractiveElements.jsx +444 -0
- package/website/components/layout/LayoutComponents.css +697 -0
- package/website/components/layout/LayoutComponents.html +374 -0
- package/website/components/layout/LayoutComponents.js +447 -0
- package/website/components/layout/LayoutComponents.jsx +379 -0
- package/website/components/navigation/Navigation.css +383 -0
- package/website/components/navigation/Navigation.html +89 -0
- package/website/components/navigation/Navigation.js +248 -0
- package/website/components/navigation/Navigation.jsx +124 -0
- package/website/css/animations.css +854 -0
- package/website/css/style.css +1010 -924
- package/website/index.html +728 -412
- package/website/js/animations.js +707 -0
- package/website/js/main.js +333 -381
- package/website/mcp-servers.html +310 -0
- package/website/nginx.conf +116 -0
- package/website/service.yaml +61 -0
|
@@ -109,7 +109,7 @@ class WidgetDeploymentService {
|
|
|
109
109
|
title: config.title,
|
|
110
110
|
template: config.template || '<div>Widget Template</div>',
|
|
111
111
|
css: config.css || '',
|
|
112
|
-
|
|
112
|
+
script: config.script || '', // ServiceNow uses 'script' field
|
|
113
113
|
client_controller: config.client_script || '',
|
|
114
114
|
demo_data: config.demo_data || '{}',
|
|
115
115
|
option_schema: config.option_schema || '[]',
|
|
@@ -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 server_script: 'data.message = \"Hello\";',\n client_script: 'function($scope) { var c = this; }'\n }\n})\n```\n\n**Updating Existing Widgets:**\n```javascript\nsnow_update({\n type: 'widget',\n identifier: 'my_widget', // Name or sys_id\n config: {\n template: '<div>Updated HTML</div>', // Only update what changes\n server_script: 'data.updated = true;'\n }\n})\n```\n\n### Flow Development\n- Use proper trigger conditions\n- Implement error handling paths\n- Add appropriate logging actions\n- Test with various data scenarios\n\n## MCP Server Capabilities\n\nSnow-Flow includes 16+ specialized MCP servers with over 200 tools for comprehensive ServiceNow integration:\n\n### 1. ServiceNow Deployment Server\n**Purpose:** Widget and artifact deployment with coherence validation\n\n**Key Tools:**\n- `snow_deploy` - Create NEW artifacts (widgets, pages, etc.) - use with `type: 'widget'`\n- `snow_update` - UPDATE existing artifacts - use for widget field updates\n- `snow_validate_deployment` - Validate deployed artifacts\n- `snow_rollback_deployment` - Rollback failed deployments\n- `snow_preview_widget` - Preview widget before deployment\n- `snow_widget_test` - Test widget functionality\n\n**Special Features:**\n- Automatic widget coherence validation\n- Data flow contract verification\n- Method implementation checking\n- CSS class validation\n\n### 2. ServiceNow Operations Server\n**Purpose:** Core ServiceNow operations and queries\n\n**Key Tools:**\n- `snow_query_table` - Universal table querying with pagination\n- `snow_query_incidents` - Query and analyze incidents\n- `snow_cmdb_search` - Search Configuration Management Database\n- `snow_user_lookup` - Find and manage users\n- `snow_operational_metrics` - Get operational metrics\n- `snow_knowledge_search` - Search knowledge base\n\n**Features:**\n- Full CRUD operations on any table\n- Advanced query capabilities\n- Field discovery and validation\n- Relationship navigation\n\n### 3. ServiceNow Automation Server\n**Purpose:** Script execution and automation\n\n**\uD83D\uDEA8 CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!**\nServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script failure.\n\n**Key Tools:**\n- `snow_execute_background_script` - Execute background scripts (**ES5 ONLY!** with optional autoConfirm)\n- `snow_confirm_script_execution` - Confirm script execution after user approval\n- `snow_execute_script_with_output` - Execute scripts with output capture (**ES5 ONLY!**)\n- `snow_get_script_output` - Retrieve script execution history\n- `snow_execute_script_sync` - Synchronous script execution (**ES5 ONLY!**)\n- `snow_get_logs` - Access system logs\n- `snow_test_rest_connection` - Test REST integrations\n- `snow_trace_execution` - Trace script execution (**ES5 ONLY!**)\n- `snow_schedule_job` - Create scheduled jobs\n- `snow_create_event` - Trigger system events\n\n**Remember:** Use `var`, `function(){}`, string concatenation, traditional for loops only!\n\n**Features:**\n- Full output capture (gs.print/info/warn/error)\n- Execution history tracking\n- System log access\n- REST message testing\n- Performance tracing\n\n### 4. ServiceNow Platform Development Server\n**Purpose:** Platform development artifacts\n\n**Key Tools:**\n- `snow_create_ui_page` - Create UI pages\n- `snow_create_script_include` - Create reusable scripts\n- `snow_create_business_rule` - Create business rules\n- `snow_create_client_script` - Create client-side scripts\n- `snow_create_ui_policy` - Create UI policies\n- `snow_create_ui_action` - Create UI actions\n\n**Features:**\n- Full artifact creation\n- Proper scoping support\n- Condition builder integration\n- Script validation\n\n### 5. ServiceNow Integration Server\n**Purpose:** Integration and data management\n\n**Key Tools:**\n- `snow_create_rest_message` - Create REST integrations\n- `snow_create_transform_map` - Create data transformation maps\n- `snow_create_import_set` - Manage import sets\n- `snow_test_web_service` - Test web services\n- `snow_configure_email` - Configure email settings\n\n**Features:**\n- REST/SOAP integration\n- Data transformation\n- Import/Export capabilities\n- Email configuration\n\n### 6. ServiceNow System Properties Server\n**Purpose:** System property management\n\n**Key Tools:**\n- `snow_property_get` - Retrieve property values\n- `snow_property_set` - Set property values\n- `snow_property_list` - List properties by pattern\n- `snow_property_delete` - Remove properties\n- `snow_property_bulk_update` - Bulk operations\n- `snow_property_export` - Export to JSON\n- `snow_property_import` - Import from JSON\n\n**Features:**\n- Full CRUD on sys_properties\n- Bulk operations\n- Import/Export capabilities\n- Property validation\n\n### 7. ServiceNow Update Set Server\n**Purpose:** Change management and deployment\n\n**Key Tools:**\n- `snow_update_set_create` - Create new update sets\n- `snow_update_set_switch` - Switch active update set\n- `snow_update_set_current` - Get current update set\n- `snow_update_set_complete` - Mark as complete\n- `snow_update_set_export` - Export as XML\n- `snow_ensure_active_update_set` - Ensure update set is active\n\n**Features:**\n- Full update set lifecycle\n- Change tracking\n- XML export/import\n- Conflict detection\n\n### 8. ServiceNow Development Assistant Server\n**Purpose:** Intelligent artifact search, editing and development assistance\n\n**Key Tools:**\n- `snow_find_artifact` - Find any ServiceNow artifact by name/type\n- `snow_edit_artifact` - Edit existing artifacts intelligently\n- `snow_get_by_sysid` - Get artifact by sys_id\n- `snow_analyze_artifact` - Analyze artifact structure and dependencies\n- `snow_comprehensive_search` - Deep search across all tables\n- `snow_analyze_requirements` - Analyze development requirements\n\n**Features:**\n- Pattern-based code generation\n- Best practice enforcement\n- Performance optimization\n- Security review\n\n### 9. ServiceNow Security & Compliance Server\n**Purpose:** Security and compliance management\n\n**Key Tools:**\n- `snow_create_security_policy` - Create security policies\n- `snow_audit_compliance` - Compliance auditing\n- `snow_scan_vulnerabilities` - Vulnerability scanning\n- `snow_assess_risk` - Risk assessment\n- `snow_review_access_control` - ACL review\n\n**Features:**\n- SOX/GDPR/HIPAA compliance\n- Security policy management\n- Vulnerability assessment\n- Access control validation\n\n### 10. ServiceNow Reporting & Analytics Server\n**Purpose:** Reporting and data visualization\n\n**Key Tools:**\n- `snow_create_report` - Create reports\n- `snow_create_dashboard` - Create dashboards\n- `snow_define_kpi` - Define KPIs\n- `snow_schedule_report` - Schedule report delivery\n- `snow_analyze_data_quality` - Data quality analysis\n\n**Features:**\n- Advanced reporting\n- Dashboard creation\n- KPI management\n- Scheduled delivery\n\n### 11. ServiceNow Machine Learning Server\n**Purpose:** AI/ML capabilities with TensorFlow.js and native ML integration\n\n**Key Tools:**\n- `ml_train_incident_classifier` - Train incident classifier with LSTM neural networks\n- `ml_predict_change_risk` - Predict change risks\n- `ml_detect_anomalies` - Anomaly detection\n- `ml_forecast_incidents` - Incident forecasting with time series\n- `ml_performance_analytics` - Native Performance Analytics ML\n- `ml_hybrid_recommendation` - Hybrid ML recommendations\n\n**Features:**\n- Predictive analytics\n- Pattern recognition\n- Anomaly detection\n- Process optimization\n\n### 12. Snow-Flow Orchestration Server\n**Purpose:** Multi-agent coordination and task management\n\n**Key Tools:**\n- `swarm_init` - Initialize agent swarms\n- `agent_spawn` - Create specialized agents\n- `task_orchestrate` - Orchestrate complex tasks\n- `memory_search` - Search persistent memory\n- `neural_train` - Train neural networks with TensorFlow.js\n- `performance_report` - Generate performance reports\n\n### Additional Servers:\n\n**ServiceNow CMDB/Event/HR/CSM/DevOps Server** - CI management, event correlation, HR processes, customer service, DevOps pipelines\n\n**ServiceNow Knowledge & Catalog Server** - Knowledge articles, service catalog items, catalog variables and policies\n\n**ServiceNow Change/Virtual Agent/PA Server** - Change management, virtual agent NLU, predictive analytics\n\n**ServiceNow Flow/Workspace/Mobile Server** - Flow Designer, workspace configuration, mobile app management\n\n**Features:**\n- Multi-agent coordination\n- Task orchestration\n- Neural network training (TensorFlow.js)\n- Memory management\n- Performance monitoring\n\n## Debugging Best Practices\n\n### Systematic Debugging Protocol\n\n1. **Reproduce the Issue**\n ```javascript\n // Always use ES5 and test exact code\n const result = await snow_execute_script_with_output({\n script: `/* Exact failing code in ES5 */`\n });\n ```\n\n2. **Verify Dependencies**\n - Check all referenced tables exist\n - Verify all properties are set\n - Confirm all fields are present\n - Test all integrations work\n\n3. **Test in Context**\n - Use same scope and variables\n - Include same imports\n - Test with same data\n\n4. **Apply Evidence-Based Fixes**\n - Fix only confirmed issues\n - Document why changes were made\n - Test fixes thoroughly\n\n### Common Verification Patterns\n\n**Table Verification:**\n```javascript\nvar table = new GlideRecord('table_name');\ngs.info('Table exists: ' + table.isValid());\n```\n\n**Property Verification:**\n```javascript\nvar prop = gs.getProperty('property.name');\ngs.info('Property value: ' + (prop || 'NOT SET'));\n```\n\n**Field Verification:**\n```javascript\nvar gr = new GlideRecord('table');\nvar element = gr.getElement('field_name');\ngs.info('Field exists: ' + (element ? 'Yes' : 'No'));\n```\n\n## Command Reference\n\n### Core Commands\n- `./snow-flow start` - Start orchestration system\n- `./snow-flow status` - System status\n- `./snow-flow monitor` - Real-time monitoring\n\n### Agent Management\n- `./snow-flow agent spawn <type>` - Create agents\n- `./snow-flow agent list` - List active agents\n\n### Task Management\n- `./snow-flow task create` - Create tasks\n- `./snow-flow task list` - View task queue\n\n### Memory Operations\n- `./snow-flow memory store <key> <data>` - Store data\n- `./snow-flow memory get <key>` - Retrieve data\n- `./snow-flow memory list` - List all keys\n\n### SPARC Modes\n- `./snow-flow sparc \"<task>\"` - Orchestrator mode\n- `./snow-flow sparc run <mode> \"<task>\"` - Specific mode\n- `./snow-flow sparc tdd \"<feature>\"` - Test-driven development\n\n### Swarm Coordination\n- `./snow-flow swarm \"<objective>\"` - Multi-agent coordination\n- Options: `--strategy`, `--mode`, `--parallel`, `--monitor`\n\n## Workflow Guidelines\n\n### Development Workflow\n1. **Plan** - Use TodoWrite for task management\n2. **Verify** - Check existing resources\n3. **Develop** - Follow ES5 standards\n4. **Test** - Use background scripts\n5. **Deploy** - Use update sets\n6. **Validate** - Verify deployment\n\n### Testing Workflow\n1. Run unit tests with background scripts\n2. Test integrations with REST tools\n3. Validate UI with widget coherence\n4. Check performance with tracing\n5. Review logs for errors\n\n### Debugging Workflow\n1. Reproduce issue exactly\n2. Gather evidence with scripts\n3. Verify all assumptions\n4. Apply minimal fixes\n5. Test thoroughly\n6. Document changes\n\n## Important Reminders\n\n### Always Remember\n- Every ServiceNow instance is unique\n- Custom implementations exist that you don't know about\n- Preview/beta features may be available\n- Organization-specific configurations are common\n- Test everything before making assumptions\n\n### Never Assume\n- That something doesn't exist without verification\n- That configurations are wrong without testing\n- That APIs aren't available without checking\n- That code won't work without running it\n- That you know better than existing implementations\n\n### Golden Rules\n1. **Verify First** - Test before declaring broken\n2. **ES5 Only** - No modern JavaScript in ServiceNow\n3. **Evidence-Based** - Make decisions on facts, not assumptions\n4. **Minimal Changes** - Fix only what's broken\n5. **Respect Context** - Understand why things exist as they do\n\n## Conclusion\n\nSnow-Flow is a powerful framework for ServiceNow development that emphasizes verification, testing, and evidence-based decision making. By following these guidelines and best practices, you ensure reliable, maintainable, and effective ServiceNow solutions.\n\nRemember: Your job is to solve problems, not to judge implementations. Every environment has its reasons for existing configurations. Verify, test, and respect what you find.";
|
|
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.";
|
|
2
2
|
//# sourceMappingURL=claude-md-template.d.ts.map
|
|
@@ -395,7 +395,7 @@ snow_deploy({
|
|
|
395
395
|
name: 'my_widget',
|
|
396
396
|
title: 'My Widget', // Required for display
|
|
397
397
|
template: '<div>{{data.message}}</div>', // Required HTML
|
|
398
|
-
|
|
398
|
+
script: 'data.message = "Hello";', // ServiceNow uses 'script' field
|
|
399
399
|
client_script: 'function($scope) { var c = this; }'
|
|
400
400
|
}
|
|
401
401
|
})
|
|
@@ -408,7 +408,7 @@ snow_update({
|
|
|
408
408
|
identifier: 'my_widget', // Name or sys_id
|
|
409
409
|
config: {
|
|
410
410
|
template: '<div>Updated HTML</div>', // Only update what changes
|
|
411
|
-
|
|
411
|
+
script: 'data.updated = true;' // ServiceNow uses 'script' field
|
|
412
412
|
}
|
|
413
413
|
})
|
|
414
414
|
\`\`\`
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Local Sync System
|
|
3
|
+
*
|
|
4
|
+
* Creates temporary local files from ServiceNow artifacts so Claude Code
|
|
5
|
+
* can use its native tools (search, edit, multi-file operations, etc.)
|
|
6
|
+
* Then syncs changes back to ServiceNow.
|
|
7
|
+
*
|
|
8
|
+
* THIS IS THE BRIDGE BETWEEN SERVICENOW AND CLAUDE CODE!
|
|
9
|
+
*/
|
|
10
|
+
import { ServiceNowClient } from './servicenow-client';
|
|
11
|
+
import { ArtifactTypeConfig, FieldMapping, ValidationResult } from './artifact-sync/artifact-registry';
|
|
12
|
+
export interface LocalArtifact {
|
|
13
|
+
sys_id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
tableName: string;
|
|
17
|
+
localPath: string;
|
|
18
|
+
files: LocalFile[];
|
|
19
|
+
metadata: any;
|
|
20
|
+
syncStatus: 'synced' | 'modified' | 'pending_upload';
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
lastSyncedAt: Date;
|
|
23
|
+
artifactConfig?: ArtifactTypeConfig;
|
|
24
|
+
}
|
|
25
|
+
export interface LocalFile {
|
|
26
|
+
filename: string;
|
|
27
|
+
path: string;
|
|
28
|
+
field: string;
|
|
29
|
+
type: string;
|
|
30
|
+
originalContent: string;
|
|
31
|
+
currentContent?: string;
|
|
32
|
+
isModified: boolean;
|
|
33
|
+
fieldMapping?: FieldMapping;
|
|
34
|
+
}
|
|
35
|
+
export declare class ArtifactLocalSync {
|
|
36
|
+
private baseDir;
|
|
37
|
+
private artifacts;
|
|
38
|
+
private client;
|
|
39
|
+
private smartFetcher;
|
|
40
|
+
constructor(client: ServiceNowClient);
|
|
41
|
+
/**
|
|
42
|
+
* DYNAMIC pull artifact from ServiceNow using artifact registry
|
|
43
|
+
* Works with ANY artifact type defined in the registry!
|
|
44
|
+
*/
|
|
45
|
+
pullArtifact(tableName: string, sys_id: string): Promise<LocalArtifact>;
|
|
46
|
+
/**
|
|
47
|
+
* Pull a widget from ServiceNow and create local files
|
|
48
|
+
* This is the magic that lets Claude Code use its native tools!
|
|
49
|
+
* (Wrapper for backward compatibility)
|
|
50
|
+
*/
|
|
51
|
+
pullWidget(sys_id: string): Promise<LocalArtifact>;
|
|
52
|
+
/**
|
|
53
|
+
* DYNAMIC push local changes back to ServiceNow using artifact registry
|
|
54
|
+
*/
|
|
55
|
+
pushArtifact(sys_id: string): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Push local changes back to ServiceNow
|
|
58
|
+
* (Wrapper for backward compatibility)
|
|
59
|
+
*/
|
|
60
|
+
pushWidget(sys_id: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Clean up local files after successful sync
|
|
63
|
+
*/
|
|
64
|
+
cleanup(sys_id: string, force?: boolean): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a local file with appropriate headers
|
|
67
|
+
*/
|
|
68
|
+
private createLocalFile;
|
|
69
|
+
/**
|
|
70
|
+
* Generate README with artifact-specific context using registry
|
|
71
|
+
*/
|
|
72
|
+
private generateArtifactReadme;
|
|
73
|
+
/**
|
|
74
|
+
* Replace placeholders in wrapper strings
|
|
75
|
+
*/
|
|
76
|
+
private replacePlaceholders;
|
|
77
|
+
/**
|
|
78
|
+
* Generate README with widget context
|
|
79
|
+
* (Wrapper for backward compatibility)
|
|
80
|
+
*/
|
|
81
|
+
private generateWidgetReadme;
|
|
82
|
+
/**
|
|
83
|
+
* Validate ES5 compliance
|
|
84
|
+
*/
|
|
85
|
+
private validateES5;
|
|
86
|
+
/**
|
|
87
|
+
* Strip headers/footers we added - now uses field mapping for accuracy
|
|
88
|
+
*/
|
|
89
|
+
private stripAddedWrappers;
|
|
90
|
+
/**
|
|
91
|
+
* Sanitize filename for filesystem
|
|
92
|
+
*/
|
|
93
|
+
private sanitizeFilename;
|
|
94
|
+
/**
|
|
95
|
+
* List all local artifacts
|
|
96
|
+
*/
|
|
97
|
+
listLocalArtifacts(): LocalArtifact[];
|
|
98
|
+
/**
|
|
99
|
+
* Get sync status for an artifact
|
|
100
|
+
*/
|
|
101
|
+
getSyncStatus(sys_id: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Pull any supported artifact type by detecting table from sys_id
|
|
104
|
+
*/
|
|
105
|
+
pullArtifactBySysId(sys_id: string): Promise<LocalArtifact>;
|
|
106
|
+
/**
|
|
107
|
+
* Get supported artifact types
|
|
108
|
+
*/
|
|
109
|
+
getSupportedTypes(): string[];
|
|
110
|
+
/**
|
|
111
|
+
* Validate coherence for an artifact
|
|
112
|
+
*/
|
|
113
|
+
validateArtifactCoherence(sys_id: string): Promise<ValidationResult[]>;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=artifact-local-sync.d.ts.map
|