snow-flow 3.6.6 → 3.6.12

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.
@@ -139,7 +139,7 @@
139
139
  "args": [
140
140
  "{{PROJECT_ROOT}}/dist/mcp/servicenow-knowledge-catalog-mcp.js"
141
141
  ],
142
- "description": "Knowledge and catalog management - create/search/update knowledge articles, knowledge bases, catalog items, catalog variables, UI policies, client scripts, order items, discover catalogs",
142
+ "description": "Knowledge and catalog management - CORRECTED v3.6.10 with proper catalog UI policy creation (2-table system: policy with embedded conditions string, separate actions table). Create/search/update knowledge articles, catalog items, variables, UI policies with conditions as query string and actions array",
143
143
  "env": {
144
144
  "SNOW_INSTANCE": "{{SNOW_INSTANCE}}",
145
145
  "SNOW_CLIENT_ID": "{{SNOW_CLIENT_ID}}",
@@ -170,19 +170,50 @@ class ServiceNowKnowledgeCatalogMCP {
170
170
  },
171
171
  {
172
172
  name: 'snow_create_catalog_ui_policy',
173
- description: 'Creates UI policies for catalog items to control form behavior based on user input.',
173
+ description: 'Creates comprehensive UI policies for catalog items with conditions and actions to control form behavior dynamically.',
174
174
  inputSchema: {
175
175
  type: 'object',
176
176
  properties: {
177
177
  cat_item: { type: 'string', description: 'Catalog item sys_id' },
178
178
  short_description: { type: 'string', description: 'Policy name' },
179
- condition: { type: 'string', description: 'Condition script' },
179
+ condition: { type: 'string', description: 'Legacy condition script (optional if conditions array provided)' },
180
180
  applies_to: { type: 'string', description: 'Applies to: item, set, or variable' },
181
181
  active: { type: 'boolean', description: 'Active status', default: true },
182
182
  on_load: { type: 'boolean', description: 'Run on form load', default: true },
183
- reverse_if_false: { type: 'boolean', description: 'Reverse actions if false', default: true }
183
+ reverse_if_false: { type: 'boolean', description: 'Reverse actions if false', default: true },
184
+ conditions: {
185
+ type: 'array',
186
+ description: 'Array of condition objects for dynamic policy evaluation',
187
+ items: {
188
+ type: 'object',
189
+ properties: {
190
+ type: { type: 'string', description: 'Condition type (catalog_variable, javascript)', default: 'catalog_variable' },
191
+ catalog_variable: { type: 'string', description: 'Target catalog variable sys_id or name' },
192
+ operation: { type: 'string', description: 'Comparison operation: is, is_not, is_empty, is_not_empty, contains, does_not_contain', default: 'is' },
193
+ value: { type: 'string', description: 'Comparison value' },
194
+ and_or: { type: 'string', description: 'Logical operator with next condition: AND, OR', default: 'AND' }
195
+ },
196
+ required: ['catalog_variable', 'operation']
197
+ }
198
+ },
199
+ actions: {
200
+ type: 'array',
201
+ description: 'Array of action objects to execute when conditions are met',
202
+ items: {
203
+ type: 'object',
204
+ properties: {
205
+ type: { type: 'string', description: 'Action type: set_mandatory, set_visible, set_readonly, set_value', default: 'set_visible' },
206
+ catalog_variable: { type: 'string', description: 'Target catalog variable sys_id or name' },
207
+ mandatory: { type: 'boolean', description: 'Set field as mandatory (for set_mandatory type)' },
208
+ visible: { type: 'boolean', description: 'Set field visibility (for set_visible type)' },
209
+ readonly: { type: 'boolean', description: 'Set field as readonly (for set_readonly type)' },
210
+ value: { type: 'string', description: 'Value to set (for set_value type)' }
211
+ },
212
+ required: ['type', 'catalog_variable']
213
+ }
214
+ }
184
215
  },
185
- required: ['cat_item', 'short_description', 'condition']
216
+ required: ['cat_item', 'short_description']
186
217
  }
187
218
  },
188
219
  {
@@ -734,38 +765,173 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
734
765
  }
735
766
  }
736
767
  /**
737
- * Create Catalog UI Policy
738
- * Uses catalog_ui_policy table
768
+ * Create Catalog UI Policy with Actions
769
+ * Creates records in 2 tables: catalog_ui_policy and catalog_ui_policy_action
770
+ *
771
+ * BELANGRIJKE WIJZIGINGEN:
772
+ * - Conditions worden NIET in een aparte tabel opgeslagen
773
+ * - Conditions worden als string/script in catalog_conditions veld gezet
774
+ * - catalog_ui_policy_condition tabel bestaat niet in ServiceNow
739
775
  */
740
776
  async createCatalogUIPolicy(args) {
741
777
  try {
742
- this.logger.info('Creating catalog UI policy...');
778
+ this.logger.info('Creating comprehensive catalog UI policy...');
779
+ // Helper function to resolve variable names to sys_ids
780
+ const resolveVariableId = async (variableName, catalogItem) => {
781
+ // If already a sys_id, return as-is
782
+ if (variableName && variableName.match(/^[a-f0-9]{32}$/)) {
783
+ return variableName;
784
+ }
785
+ // Search for variable by name in this catalog item
786
+ const varResponse = await this.client.searchRecords('item_option_new', `cat_item=${catalogItem}^name=${variableName}`, 1);
787
+ if (varResponse.success && varResponse.data.result.length > 0) {
788
+ return varResponse.data.result[0].sys_id;
789
+ }
790
+ this.logger.warn(`Variable '${variableName}' not found for catalog item ${catalogItem}`);
791
+ return variableName; // Return original if not found
792
+ };
793
+ // Build condition string from conditions array
794
+ let conditionString = '';
795
+ if (args.conditions && Array.isArray(args.conditions)) {
796
+ const conditionParts = [];
797
+ for (const condition of args.conditions) {
798
+ // Resolve variable name to sys_id
799
+ const variableId = await resolveVariableId(condition.catalog_variable, args.cat_item);
800
+ // Build condition string in ServiceNow format
801
+ // Format: variable_name=value^ORvariable_name2=value2
802
+ const operator = condition.operation || '=';
803
+ const connector = condition.and_or === 'OR' ? '^OR' : '^';
804
+ // Map common operations to ServiceNow syntax
805
+ let operatorSymbol = '=';
806
+ switch (operator.toLowerCase()) {
807
+ case 'is':
808
+ case 'equals':
809
+ operatorSymbol = '=';
810
+ break;
811
+ case 'is not':
812
+ case 'not equals':
813
+ operatorSymbol = '!=';
814
+ break;
815
+ case 'contains':
816
+ operatorSymbol = 'CONTAINS';
817
+ break;
818
+ case 'greater than':
819
+ operatorSymbol = '>';
820
+ break;
821
+ case 'less than':
822
+ operatorSymbol = '<';
823
+ break;
824
+ case 'is empty':
825
+ operatorSymbol = 'ISEMPTY';
826
+ break;
827
+ default:
828
+ operatorSymbol = operator;
829
+ }
830
+ // Build the condition part
831
+ let conditionPart = '';
832
+ if (operatorSymbol === 'ISEMPTY') {
833
+ conditionPart = `${variableId}ISEMPTY`;
834
+ }
835
+ else if (operatorSymbol === 'CONTAINS') {
836
+ conditionPart = `${variableId}LIKE${condition.value}`;
837
+ }
838
+ else {
839
+ conditionPart = `${variableId}${operatorSymbol}${condition.value}`;
840
+ }
841
+ conditionParts.push(conditionPart);
842
+ }
843
+ // Join all conditions
844
+ conditionString = conditionParts.join('');
845
+ }
846
+ // Step 1: Create main catalog UI policy record with embedded conditions
743
847
  const policyData = {
744
- catalog_item: args.cat_item,
848
+ catalog_item: args.cat_item, // ✅ Link naar het catalog item
745
849
  short_description: args.short_description,
746
- catalog_conditions: args.condition,
747
- applies_catalog: args.applies_to || 'item',
850
+ catalog_conditions: conditionString || args.condition || '', // Conditions as string
851
+ applies_to: args.applies_to || 'item', // ✅ Correct veld: 'item', 'req_item', or 'task'
748
852
  active: args.active !== false,
749
853
  applies_on_load: args.on_load !== false,
750
- reverse_if_false: args.reverse_if_false !== false
854
+ reverse_if_false: args.reverse_if_false !== false,
855
+ // Optional script fields if needed
856
+ script_true: args.script_true || '',
857
+ script_false: args.script_false || ''
751
858
  };
752
- const response = await this.client.createRecord('catalog_ui_policy', policyData);
753
- if (!response.success) {
754
- throw new Error(`Failed to create catalog UI policy: ${response.error}`);
859
+ const policyResponse = await this.client.createRecord('catalog_ui_policy', policyData);
860
+ if (!policyResponse.success) {
861
+ throw new Error(`Failed to create catalog UI policy: ${policyResponse.error}`);
755
862
  }
756
- return {
757
- content: [{
758
- type: 'text',
759
- text: `✅ Catalog UI Policy created successfully!
863
+ const policyId = policyResponse.data.sys_id;
864
+ this.logger.info(`Created main policy with sys_id: ${policyId}`);
865
+ const createdActions = [];
866
+ // Step 2: Create action records (dit werkt wel met aparte tabel)
867
+ if (args.actions && Array.isArray(args.actions)) {
868
+ this.logger.info(`Creating ${args.actions.length} action records...`);
869
+ for (let i = 0; i < args.actions.length; i++) {
870
+ const action = args.actions[i];
871
+ // Resolve variable name to sys_id
872
+ const variableId = await resolveVariableId(action.catalog_variable, args.cat_item);
873
+ // Actions structuur in ServiceNow:
874
+ // - catalog_ui_policy_action.catalog_variable -> item_option_new (variable)
875
+ // - item_option_new.cat_item -> sc_cat_item (catalog item)
876
+ // - catalog_ui_policy.catalog_item -> sc_cat_item (catalog item)
877
+ // Mogelijk is er toch een ui_policy veld, maar het lijkt niet verplicht
878
+ const actionData = {
879
+ // Primaire koppeling: naar de variable
880
+ catalog_variable: variableId, // Verplicht: koppeling naar variable
881
+ // Mogelijk ook een policy koppeling (als het veld bestaat)
882
+ ui_policy: policyId, // Probeer dit ook, kan optioneel zijn
883
+ // Action settings - gebruik strings zoals ServiceNow verwacht
884
+ mandatory: action.mandatory === true ? 'true' : action.mandatory === false ? 'false' : 'ignore',
885
+ visible: action.visible === false ? 'false' : action.visible === true ? 'true' : 'ignore',
886
+ disabled: action.readonly === true ? 'true' : action.readonly === false ? 'false' : 'ignore',
887
+ // Waarde velden (voor set_value acties)
888
+ value: action.value || '',
889
+ // Metadata
890
+ order: (i + 1) * 100,
891
+ active: true
892
+ };
893
+ this.logger.info(`Attempting to create action ${i + 1}:`, actionData);
894
+ const actionResponse = await this.client.createRecord('catalog_ui_policy_action', actionData);
895
+ if (actionResponse.success) {
896
+ createdActions.push({
897
+ sys_id: actionResponse.data.sys_id,
898
+ variable: action.catalog_variable,
899
+ details: this.formatActionDetails(action)
900
+ });
901
+ this.logger.info(`✅ Created action: ${action.type || 'default'} for ${action.catalog_variable}`);
902
+ }
903
+ else {
904
+ const errorMsg = `❌ Failed to create action ${i + 1}: ${actionResponse.error || 'Unknown error'}`;
905
+ this.logger.error(errorMsg);
906
+ this.logger.error('Action data was:', actionData);
907
+ // BELANGRIJK: Gooi een error zodat de gebruiker weet dat het faalt!
908
+ throw new Error(errorMsg);
909
+ }
910
+ }
911
+ }
912
+ // Build comprehensive response
913
+ let responseText = `✅ Catalog UI Policy created successfully!
760
914
 
761
915
  📋 **${args.short_description}**
762
- 🆔 sys_id: ${response.data.sys_id}
916
+ 🆔 Policy sys_id: ${policyId}
763
917
  🎯 Applies to: ${args.applies_to || 'item'}
764
918
  🔄 Active: ${args.active !== false ? 'Yes' : 'No'}
765
919
  ⚡ On Load: ${args.on_load !== false ? 'Yes' : 'No'}
766
- 🔁 Reverse if False: ${args.reverse_if_false !== false ? 'Yes' : 'No'}
767
-
768
- UI policy configured!`
920
+ 🔁 Reverse if False: ${args.reverse_if_false !== false ? 'Yes' : 'No'}`;
921
+ if (conditionString) {
922
+ responseText += `\n\n📝 **Conditions:**\n${conditionString}`;
923
+ }
924
+ if (createdActions.length > 0) {
925
+ responseText += `\n\n⚡ **Actions Created (${createdActions.length}):**\n`;
926
+ createdActions.forEach((action, i) => {
927
+ responseText += ` ${i + 1}. ${action.details} on ${action.variable}\n`;
928
+ });
929
+ }
930
+ responseText += `\n\n✨ UI policy configured successfully with ${createdActions.length} actions!`;
931
+ return {
932
+ content: [{
933
+ type: 'text',
934
+ text: responseText
769
935
  }]
770
936
  };
771
937
  }
@@ -774,6 +940,46 @@ ${args.help_text ? `❓ Help: ${args.help_text}` : ''}
774
940
  throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create catalog UI policy: ${error}`);
775
941
  }
776
942
  }
943
+ /**
944
+ * Helper function to determine action type based on provided fields
945
+ * Note: ServiceNow might not use 'type' field, actions are determined by field values
946
+ */
947
+ determineActionType(action) {
948
+ // ServiceNow bepaalt het type waarschijnlijk op basis van de velden zelf
949
+ // Dit is alleen voor logging/display
950
+ if (action.value !== undefined && action.value !== '') {
951
+ return 'set_value';
952
+ }
953
+ if (action.mandatory === true) {
954
+ return 'set_mandatory';
955
+ }
956
+ if (action.visible === false) {
957
+ return 'set_hidden';
958
+ }
959
+ if (action.readonly === true) {
960
+ return 'set_readonly';
961
+ }
962
+ return 'default';
963
+ }
964
+ /**
965
+ * Helper function to format action details for display
966
+ */
967
+ formatActionDetails(action) {
968
+ const details = [];
969
+ if (action.mandatory !== undefined) {
970
+ details.push(`Mandatory: ${action.mandatory}`);
971
+ }
972
+ if (action.visible !== undefined) {
973
+ details.push(`Visible: ${action.visible}`);
974
+ }
975
+ if (action.readonly !== undefined) {
976
+ details.push(`Read-only: ${action.readonly}`);
977
+ }
978
+ if (action.value !== undefined && action.value !== '') {
979
+ details.push(`Value: "${action.value}"`);
980
+ }
981
+ return details.length > 0 ? details.join(', ') : 'No specific action';
982
+ }
777
983
  /**
778
984
  * Create Catalog Client Script
779
985
  * Uses catalog_script_client table
@@ -1,3 +1,3 @@
1
- export declare const CLAUDE_MD_TEMPLATE = "# Snow-Flow ServiceNow Development Framework\n\n## \uD83D\uDEA8 ABSOLUTE RULES - NO EXCEPTIONS\n\n### Rule #1: NO MOCK DATA - EVERYTHING REAL & COMPLETE\n**FORBIDDEN:** Mock data, placeholders, TODOs, stub implementations, test values, simulations, \"this would normally...\", partial implementations.\n**REQUIRED:** Complete, production-ready, fully functional code. Take time to implement EVERYTHING properly. Real integrations, comprehensive error handling, full validation.\n\n### Rule #2: ES5 ONLY - ServiceNow Rhino Engine\n**NEVER USE:** const/let, arrow functions =>, template literals `${}`, destructuring, for...of, default parameters, classes\n**ALWAYS USE:** var, function(){}, string concatenation +, traditional for loops, typeof checks\n\n### Rule #3: VERIFY FIRST - Never Assume\nTest before claiming broken. Check resources exist. Validate configurations. Evidence-based fixes only.\n\n## \uD83D\uDCCB MCP SERVERS & TOOLS (18 Servers, 200+ Tools)\n\n### 1. **servicenow-local-development** \uD83D\uDD27 Widget/Artifact Sync\n```\nsnow_pull_artifact - Pull ANY artifact to local files for native editing\nsnow_push_artifact - Push local changes back to ServiceNow \nsnow_cleanup_artifacts - Clean local artifact cache\nsnow_get_sync_status - Check artifact sync status\nsnow_list_local_artifacts - List all pulled artifacts\n```\n\n### 2. **servicenow-deployment** \uD83D\uDE80 Complete Deployment System\n```\nsnow_deploy - Create NEW artifacts (widgets, flows, scripts, pages)\nsnow_update - UPDATE existing artifacts directly\nsnow_validate_deployment - Validate before deploy\nsnow_rollback_deployment - Rollback failed deployments\nsnow_preview_widget - Preview widget rendering\nsnow_widget_test - Test widget functionality\nsnow_deployment_history - View deployment history\nsnow_check_widget_coherence - Validate HTML/Client/Server communication\n```\n\n### 3. **servicenow-operations** \uD83D\uDCCA Core Operations\n```\nsnow_query_table - Universal table query with pagination\nsnow_query_incidents - Query and analyze incidents\nsnow_analyze_incident - AI-powered incident analysis\nsnow_auto_resolve_incident - Automated resolution\nsnow_cmdb_search - Configuration database search\nsnow_user_lookup - Find users and groups\nsnow_operational_metrics - Performance metrics\nsnow_knowledge_search - Search knowledge base\nsnow_catalog_item_manager - Manage service catalog\n```\n\n### 4. **servicenow-automation** \u2699\uFE0F Scripts & Automation\n```\nsnow_execute_background_script - Run ES5 scripts (autoConfirm available)\nsnow_execute_script_with_output - Execute with output capture\nsnow_execute_script_sync - Synchronous execution\nsnow_get_script_output - Retrieve script results\nsnow_schedule_job - Create scheduled jobs\nsnow_create_event - Trigger system events\nsnow_get_logs - Access system logs\nsnow_test_rest_connection - Test REST endpoints\nsnow_trace_execution - Performance tracing\n```\n\n### 5. **servicenow-platform-development** \uD83C\uDFD7\uFE0F Development Artifacts\n```\nsnow_create_ui_page - Create UI pages\nsnow_create_script_include - Reusable scripts\nsnow_create_business_rule - Business rules\nsnow_create_client_script - Client-side scripts\nsnow_create_ui_policy - UI policies\nsnow_create_ui_action - UI actions\nsnow_create_acl - Access controls\nsnow_create_ui_macro - UI macros\n```\n\n### 6. **servicenow-integration** \uD83D\uDD0C Integrations\n```\nsnow_create_rest_message - REST integrations\nsnow_create_soap_message - SOAP integrations\nsnow_create_transform_map - Data transformation\nsnow_create_import_set - Import management\nsnow_test_web_service - Test services\nsnow_configure_email - Email configuration\nsnow_create_data_source - Data sources\n```\n\n### 7. **servicenow-system-properties** \u2699\uFE0F Properties\n```\nsnow_property_get - Get property value\nsnow_property_set - Set property value\nsnow_property_list - List by pattern\nsnow_property_bulk_update - Bulk operations\nsnow_property_export/import - Export/Import JSON\nsnow_property_validate - Validate properties\n```\n\n### 8. **servicenow-update-set** \uD83D\uDCE6 Change Management\n```\nsnow_update_set_create - Create update set\nsnow_update_set_switch - Switch active set\nsnow_update_set_complete - Mark complete\nsnow_update_set_export - Export as XML\nsnow_update_set_preview - Preview changes\nsnow_ensure_active_update_set - Auto-create if needed\n```\n\n### 9. **servicenow-development-assistant** \uD83E\uDD16 AI Assistant\n```\nsnow_find_artifact - Find any artifact by name/type\nsnow_edit_artifact - Edit existing artifacts\nsnow_analyze_artifact - Analyze dependencies\nsnow_comprehensive_search - Deep search all tables\nsnow_analyze_requirements - Requirement analysis\nsnow_generate_code - Pattern-based generation\nsnow_optimize_script - Performance optimization\n```\n\n### 10. **servicenow-security-compliance** \uD83D\uDEE1\uFE0F Security\n```\nsnow_create_security_policy - Security policies\nsnow_audit_compliance - SOX/GDPR/HIPAA audit\nsnow_scan_vulnerabilities - Vulnerability scan\nsnow_assess_risk - Risk assessment\nsnow_review_access_control - ACL review\nsnow_encrypt_field - Field encryption\nsnow_audit_trail_analysis - Audit analysis\n```\n\n### 11. **servicenow-reporting-analytics** \uD83D\uDCC8 Reporting\n```\nsnow_create_report - Create reports\nsnow_create_dashboard - Build dashboards\nsnow_define_kpi - Define KPIs\nsnow_schedule_report - Schedule delivery\nsnow_analyze_data_quality - Data quality\nsnow_create_pa_widget - Performance analytics\n```\n\n### 12. **servicenow-machine-learning** \uD83E\uDDE0 AI/ML\n```\nml_train_incident_classifier - Train LSTM classifier\nml_predict_change_risk - Risk prediction\nml_detect_anomalies - Anomaly detection\nml_forecast_incidents - Time series forecast\nml_cluster_similar - Similarity clustering\nml_performance_analytics - Native PA ML\n```\n\n### 13. **servicenow-change-virtualagent-pa** \uD83D\uDD04 Change & Virtual Agent\n```\nsnow_create_change_request - Change requests\nsnow_assess_change_risk - Risk assessment\nsnow_create_nlu_model - NLU models\nsnow_train_virtual_agent - Train VA\nsnow_configure_conversation - VA conversations\nsnow_analyze_pa_trends - Performance trends\n```\n\n### 14. **servicenow-cmdb-event-hr-csm-devops** \uD83C\uDFE2 Enterprise\n```\nsnow_manage_ci - Configuration items\nsnow_correlate_events - Event correlation\nsnow_manage_hr_case - HR cases\nsnow_csm_project - Customer projects\nsnow_devops_pipeline - CI/CD pipelines\nsnow_manage_cmdb_relationships - CI relationships\n```\n\n### 15. **servicenow-knowledge-catalog** \uD83D\uDCDA Knowledge & Catalog\n```\nsnow_create_knowledge_article - KB articles\nsnow_manage_catalog_item - Catalog items\nsnow_configure_variables - Variable sets\nsnow_create_catalog_policy - Catalog policies\nsnow_manage_categories - Categories\n```\n\n### 16. **servicenow-flow-workspace-mobile** \uD83D\uDCF1 Modern UX\n```\nsnow_create_flow - Flow Designer flows\nsnow_add_flow_action - Flow actions\nsnow_create_workspace - Workspace config\nsnow_configure_mobile_app - Mobile apps\nsnow_configure_offline_sync - Offline mode\n```\n\n### 17. **servicenow-advanced-features** \uD83C\uDFAF Advanced\n```\nsnow_performance_optimization - Optimize instance\nsnow_batch_operations - Bulk processing\nsnow_instance_scan - Health check\nsnow_dependency_analysis - Dependencies\nsnow_code_search - Search all code\n```\n\n### 18. **snow-flow** \uD83C\uDF9B\uFE0F Orchestration\n```\nswarm_init - Initialize agent swarms\nagent_spawn - Create specialized agents\ntask_orchestrate - Complex task coordination\nmemory_search - Search persistent memory\nneural_train - Train neural networks\n```\n\n## \uD83D\uDD04 Critical Workflows\n\n### Widget Debugging (ALWAYS use Local Sync!)\n```javascript\n// \u2705 CORRECT - Local sync for debugging\nawait snow_pull_artifact({ sys_id: 'widget_sys_id' });\n// Edit with native tools (search, multi-file, etc.)\nawait snow_push_artifact({ sys_id: 'widget_sys_id' });\n\n// \u274C WRONG - Token limit explosion\nawait snow_query_table({ table: 'sp_widget', query: 'sys_id=...' });\n```\n\n### Verification Pattern\n```javascript\n// Always verify with REAL data, not placeholders\nawait snow_execute_script_with_output({\n script: `\n var gr = new GlideRecord('incident');\n gr.addQuery('active', true);\n gr.query();\n gs.info('Found: ' + gr.getRowCount() + ' active incidents');\n \n // Test actual property\n var prop = gs.getProperty('instance_name');\n gs.info('Instance: ' + prop);\n `\n});\n```\n\n### Complete Widget Creation (NO PLACEHOLDERS)\n```javascript\nawait snow_deploy({\n type: 'widget',\n config: {\n name: 'my_widget',\n title: 'Production Widget',\n template: '<div ng-repeat=\"item in data.items\">{{item.name}}</div>',\n script: `\n (function() {\n data.items = [];\n var gr = new GlideRecord('incident');\n gr.addQuery('active', true);\n gr.setLimit(10);\n gr.query();\n while (gr.next()) {\n data.items.push({\n name: gr.getDisplayValue('number'),\n description: gr.getDisplayValue('short_description')\n });\n }\n })();\n `,\n client_script: `\n function($scope) {\n var c = this;\n c.refresh = function() {\n c.server.get().then(function(r) {\n console.log('Refreshed');\n });\n };\n }\n `\n }\n});\n```\n\n## \u26A1 Command Reference\n\n### Core Commands\n- `snow-flow init` - Initialize project with this CLAUDE.md\n- `snow-flow auth login` - Authenticate with ServiceNow\n- `snow-flow status` - System status\n- `snow-flow swarm \"<task>\"` - Multi-agent coordination\n\n### Development Flow\n1. **Pull artifact**: `snow_pull_artifact` for local editing\n2. **Edit locally**: Use Claude's native search/edit tools\n3. **Push changes**: `snow_push_artifact` to ServiceNow\n4. **Test**: `snow_execute_script_with_output` with REAL code\n5. **Deploy**: `snow_update_set_complete` when ready\n\n## \uD83C\uDFAF Golden Rules\n\n1. **NO MOCK DATA** - Everything real, complete, production-ready\n2. **ES5 ONLY** - var, function(){}, no modern JS\n3. **VERIFY FIRST** - Test before assuming\n4. **LOCAL SYNC** - Use snow_pull_artifact for widgets\n5. **COMPLETE CODE** - No TODOs, no placeholders\n6. **TOKEN AWARE** - Use batch operations\n7. **UPDATE SETS** - Track all changes\n\n## \uD83D\uDCCA Quick Reference\n\n| Issue | Solution |\n|-------|----------|\n| Widget doesn't work | `snow_pull_artifact` \u2192 debug locally |\n| Script syntax error | ES5 only! var, function(){} |\n| Can't find table | `snow_discover_table_fields` |\n| Property missing | `snow_property_manager` |\n| Need to test | `snow_execute_script_with_output` |\n| Deployment failed | `snow_rollback_deployment` |\n\nRemember: TAKE THE TIME. DO IT RIGHT. NO MOCK DATA. NO EXCEPTIONS.";
1
+ export declare const CLAUDE_MD_TEMPLATE = "# Snow-Flow ServiceNow Development Framework\n\n## \uD83D\uDEA8 ABSOLUTE RULES - NO EXCEPTIONS\n\n### \uD83D\uDD34 CRITICAL: Widget Debugging MUST Use Local Sync!\n\n**When user reports ANY widget issue, ALWAYS use:**\n```\nsnow_pull_artifact({ sys_id: 'widget_sys_id' })\n```\n\n**NEVER use snow_query_table for widgets!** It will hit token limits and you can't use native tools.\n\n**Common scenarios requiring snow_pull_artifact:**\n- \"Widget skips questions\" \u2192 snow_pull_artifact\n- \"Form doesn't submit\" \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- Widget script > 1000 chars \u2192 snow_pull_artifact\n\n### Rule #1: NO MOCK DATA - EVERYTHING REAL & COMPLETE\n**FORBIDDEN:** Mock data, placeholders, TODOs, stub implementations, test values, simulations, \"this would normally...\", partial implementations.\n**REQUIRED:** Complete, production-ready, fully functional code. Take time to implement EVERYTHING properly. Real integrations, comprehensive error handling, full validation.\n\n### Rule #2: ES5 ONLY - ServiceNow Rhino Engine\n**NEVER USE:** const/let, arrow functions =>, template literals `${}`, destructuring, for...of, default parameters, classes\n**ALWAYS USE:** var, function(){}, string concatenation +, traditional for loops, typeof checks\n\n### Rule #3: VERIFY FIRST - Never Assume\nTest before claiming broken. Check resources exist. Validate configurations. Evidence-based fixes only.\n\n## \uD83D\uDCCB MCP SERVERS & TOOLS (18 Servers, 200+ Tools)\n\n### 1. **servicenow-local-development** \uD83D\uDD27 Widget/Artifact Sync [USE THIS FOR WIDGETS!]\n```\nsnow_pull_artifact - Pull ANY artifact to local files (ALWAYS use for widgets!)\nsnow_push_artifact - Push local changes back to ServiceNow \nsnow_cleanup_artifacts - Clean local artifact cache\nsnow_get_sync_status - Check artifact sync status\nsnow_list_local_artifacts - List all pulled artifacts\n```\n**\u26A0\uFE0F CRITICAL: For ANY widget work, use snow_pull_artifact FIRST, not snow_query_table!**\n\n### 2. **servicenow-deployment** \uD83D\uDE80 Complete Deployment System\n```\nsnow_deploy - Create NEW artifacts (widgets, flows, scripts, pages)\nsnow_update - UPDATE existing artifacts directly\nsnow_validate_deployment - Validate before deploy\nsnow_rollback_deployment - Rollback failed deployments\nsnow_preview_widget - Preview widget rendering\nsnow_widget_test - Test widget functionality\nsnow_deployment_history - View deployment history\nsnow_check_widget_coherence - Validate HTML/Client/Server communication\n```\n\n### 3. **servicenow-operations** \uD83D\uDCCA Core Operations\n```\nsnow_query_table - Universal table query (NOT for widgets - use snow_pull_artifact!)\nsnow_query_incidents - Query and analyze incidents\nsnow_analyze_incident - AI-powered incident analysis\nsnow_auto_resolve_incident - Automated resolution\nsnow_cmdb_search - Configuration database search\nsnow_user_lookup - Find users and groups\nsnow_operational_metrics - Performance metrics\nsnow_knowledge_search - Search knowledge base\nsnow_catalog_item_manager - Manage service catalog\n```\n\n### 4. **servicenow-automation** \u2699\uFE0F Scripts & Automation\n```\nsnow_execute_background_script - Run ES5 scripts (autoConfirm available)\nsnow_execute_script_with_output - Execute with output capture\nsnow_execute_script_sync - Synchronous execution\nsnow_get_script_output - Retrieve script results\nsnow_schedule_job - Create scheduled jobs\nsnow_create_event - Trigger system events\nsnow_get_logs - Access system logs\nsnow_test_rest_connection - Test REST endpoints\nsnow_trace_execution - Performance tracing\n```\n\n### 5. **servicenow-platform-development** \uD83C\uDFD7\uFE0F Development Artifacts\n```\nsnow_create_ui_page - Create UI pages\nsnow_create_script_include - Reusable scripts\nsnow_create_business_rule - Business rules\nsnow_create_client_script - Client-side scripts\nsnow_create_ui_policy - UI policies\nsnow_create_ui_action - UI actions\nsnow_create_acl - Access controls\nsnow_create_ui_macro - UI macros\n```\n\n### 6. **servicenow-integration** \uD83D\uDD0C Integrations\n```\nsnow_create_rest_message - REST integrations\nsnow_create_soap_message - SOAP integrations\nsnow_create_transform_map - Data transformation\nsnow_create_import_set - Import management\nsnow_test_web_service - Test services\nsnow_configure_email - Email configuration\nsnow_create_data_source - Data sources\n```\n\n### 7. **servicenow-system-properties** \u2699\uFE0F Properties\n```\nsnow_property_get - Get property value\nsnow_property_set - Set property value\nsnow_property_list - List by pattern\nsnow_property_bulk_update - Bulk operations\nsnow_property_export/import - Export/Import JSON\nsnow_property_validate - Validate properties\n```\n\n### 8. **servicenow-update-set** \uD83D\uDCE6 Change Management\n```\nsnow_update_set_create - Create update set\nsnow_update_set_switch - Switch active set\nsnow_update_set_complete - Mark complete\nsnow_update_set_export - Export as XML\nsnow_update_set_preview - Preview changes\nsnow_ensure_active_update_set - Auto-create if needed\n```\n\n### 9. **servicenow-development-assistant** \uD83E\uDD16 AI Assistant\n```\nsnow_find_artifact - Find any artifact by name/type\nsnow_edit_artifact - Edit existing artifacts\nsnow_analyze_artifact - Analyze dependencies\nsnow_comprehensive_search - Deep search all tables\nsnow_analyze_requirements - Requirement analysis\nsnow_generate_code - Pattern-based generation\nsnow_optimize_script - Performance optimization\n```\n\n### 10. **servicenow-security-compliance** \uD83D\uDEE1\uFE0F Security\n```\nsnow_create_security_policy - Security policies\nsnow_audit_compliance - SOX/GDPR/HIPAA audit\nsnow_scan_vulnerabilities - Vulnerability scan\nsnow_assess_risk - Risk assessment\nsnow_review_access_control - ACL review\nsnow_encrypt_field - Field encryption\nsnow_audit_trail_analysis - Audit analysis\n```\n\n### 11. **servicenow-reporting-analytics** \uD83D\uDCC8 Reporting\n```\nsnow_create_report - Create reports\nsnow_create_dashboard - Build dashboards\nsnow_define_kpi - Define KPIs\nsnow_schedule_report - Schedule delivery\nsnow_analyze_data_quality - Data quality\nsnow_create_pa_widget - Performance analytics\n```\n\n### 12. **servicenow-machine-learning** \uD83E\uDDE0 AI/ML\n```\nml_train_incident_classifier - Train LSTM classifier\nml_predict_change_risk - Risk prediction\nml_detect_anomalies - Anomaly detection\nml_forecast_incidents - Time series forecast\nml_cluster_similar - Similarity clustering\nml_performance_analytics - Native PA ML\n```\n\n### 13. **servicenow-change-virtualagent-pa** \uD83D\uDD04 Change & Virtual Agent\n```\nsnow_create_change_request - Change requests\nsnow_assess_change_risk - Risk assessment\nsnow_create_nlu_model - NLU models\nsnow_train_virtual_agent - Train VA\nsnow_configure_conversation - VA conversations\nsnow_analyze_pa_trends - Performance trends\n```\n\n### 14. **servicenow-cmdb-event-hr-csm-devops** \uD83C\uDFE2 Enterprise\n```\nsnow_manage_ci - Configuration items\nsnow_correlate_events - Event correlation\nsnow_manage_hr_case - HR cases\nsnow_csm_project - Customer projects\nsnow_devops_pipeline - CI/CD pipelines\nsnow_manage_cmdb_relationships - CI relationships\n```\n\n### 15. **servicenow-knowledge-catalog** \uD83D\uDCDA Knowledge & Catalog (v3.6.10 Corrected!)\n```\nsnow_create_knowledge_article - KB articles\nsnow_create_catalog_item - Catalog items\nsnow_create_catalog_variable - Variable sets\nsnow_create_catalog_ui_policy - CORRECTED: Creates in 2 tables (conditions as string, actions as records)\nsnow_order_catalog_item - Order catalog items\nsnow_discover_catalogs - Discover available catalogs\n```\n**\u2705 Corrected UI Policy (v3.6.10):** Conditions stored as query string in catalog_conditions field. Actions created in catalog_ui_policy_action table. Based on actual ServiceNow structure!\n\n### 16. **servicenow-flow-workspace-mobile** \uD83D\uDCF1 Modern UX\n```\nsnow_create_flow - Flow Designer flows\nsnow_add_flow_action - Flow actions\nsnow_create_workspace - Workspace config\nsnow_configure_mobile_app - Mobile apps\nsnow_configure_offline_sync - Offline mode\n```\n\n### 17. **servicenow-advanced-features** \uD83C\uDFAF Advanced\n```\nsnow_performance_optimization - Optimize instance\nsnow_batch_operations - Bulk processing\nsnow_instance_scan - Health check\nsnow_dependency_analysis - Dependencies\nsnow_code_search - Search all code\n```\n\n### 18. **snow-flow** \uD83C\uDF9B\uFE0F Orchestration\n```\nswarm_init - Initialize agent swarms\nagent_spawn - Create specialized agents\ntask_orchestrate - Complex task coordination\nmemory_search - Search persistent memory\nneural_train - Train neural networks\n```\n\n## \uD83D\uDD04 Critical Workflows\n\n### Widget Debugging (ALWAYS use Local Sync!)\n```javascript\n// \u2705 CORRECT - Local sync for debugging\nawait snow_pull_artifact({ sys_id: 'widget_sys_id' });\n// Edit with native tools (search, multi-file, etc.)\nawait snow_push_artifact({ sys_id: 'widget_sys_id' });\n\n// \u274C WRONG - Token limit explosion\nawait snow_query_table({ table: 'sp_widget', query: 'sys_id=...' });\n```\n\n### Verification Pattern\n```javascript\n// Always verify with REAL data, not placeholders\nawait snow_execute_script_with_output({\n script: `\n var gr = new GlideRecord('incident');\n gr.addQuery('active', true);\n gr.query();\n gs.info('Found: ' + gr.getRowCount() + ' active incidents');\n \n // Test actual property\n var prop = gs.getProperty('instance_name');\n gs.info('Instance: ' + prop);\n `\n});\n```\n\n### Complete Widget Creation (NO PLACEHOLDERS)\n```javascript\nawait snow_deploy({\n type: 'widget',\n config: {\n name: 'my_widget',\n title: 'Production Widget',\n template: '<div ng-repeat=\"item in data.items\">{{item.name}}</div>',\n script: `\n (function() {\n data.items = [];\n var gr = new GlideRecord('incident');\n gr.addQuery('active', true);\n gr.setLimit(10);\n gr.query();\n while (gr.next()) {\n data.items.push({\n name: gr.getDisplayValue('number'),\n description: gr.getDisplayValue('short_description')\n });\n }\n })();\n `,\n client_script: `\n function($scope) {\n var c = this;\n c.refresh = function() {\n c.server.get().then(function(r) {\n console.log('Refreshed');\n });\n };\n }\n `\n }\n});\n```\n\n### Catalog UI Policy (v3.6.10 Corrected)\n```javascript\nawait snow_create_catalog_ui_policy({\n cat_item: 'catalog_item_sys_id',\n short_description: 'Dynamic Field Control',\n // Conditions converted to ServiceNow query string format\n conditions: [\n {\n catalog_variable: 'user_type', // Can use name or sys_id\n operation: 'is', // or 'is not', 'contains', 'is empty', etc.\n value: 'employee',\n and_or: 'AND' // Connect with AND or OR\n },\n {\n catalog_variable: 'department',\n operation: 'is not empty',\n value: ''\n }\n ],\n // Actions still create separate records\n actions: [\n {\n catalog_variable: 'manager_approval',\n visible: true,\n mandatory: true\n },\n {\n catalog_variable: 'cost_center',\n mandatory: true\n }\n ]\n});\n// Creates policy with conditions as query string in catalog_conditions field\n// Actions created as separate records in catalog_ui_policy_action table\n```\n\n## \u26A1 Command Reference\n\n### Core Commands\n- `snow-flow init` - Initialize project with this CLAUDE.md\n- `snow-flow auth login` - Authenticate with ServiceNow\n- `snow-flow status` - System status\n- `snow-flow swarm \"<task>\"` - Multi-agent coordination\n\n### Development Flow\n1. **Pull artifact**: `snow_pull_artifact` for local editing\n2. **Edit locally**: Use Claude's native search/edit tools\n3. **Push changes**: `snow_push_artifact` to ServiceNow\n4. **Test**: `snow_execute_script_with_output` with REAL code\n5. **Deploy**: `snow_update_set_complete` when ready\n\n## \uD83C\uDFAF Golden Rules\n\n1. **NO MOCK DATA** - Everything real, complete, production-ready\n2. **ES5 ONLY** - var, function(){}, no modern JS\n3. **VERIFY FIRST** - Test before assuming\n4. **LOCAL SYNC** - Use snow_pull_artifact for widgets\n5. **COMPLETE CODE** - No TODOs, no placeholders\n6. **TOKEN AWARE** - Use batch operations\n7. **UPDATE SETS** - Track all changes\n\n## \uD83D\uDCCA Quick Reference\n\n| Issue | Solution |\n|-------|----------|\n| Widget doesn't work | `snow_pull_artifact` \u2192 debug locally |\n| Script syntax error | ES5 only! var, function(){} |\n| Can't find table | `snow_discover_table_fields` |\n| Property missing | `snow_property_manager` |\n| Need to test | `snow_execute_script_with_output` |\n| Deployment failed | `snow_rollback_deployment` |\n\nRemember: TAKE THE TIME. DO IT RIGHT. NO MOCK DATA. NO EXCEPTIONS.";
2
2
  export declare const CLAUDE_MD_TEMPLATE_VERSION = "3.6.2-CONSOLIDATED";
3
3
  //# sourceMappingURL=claude-md-template.d.ts.map
@@ -5,6 +5,24 @@ exports.CLAUDE_MD_TEMPLATE = `# Snow-Flow ServiceNow Development Framework
5
5
 
6
6
  ## 🚨 ABSOLUTE RULES - NO EXCEPTIONS
7
7
 
8
+ ### 🔴 CRITICAL: Widget Debugging MUST Use Local Sync!
9
+
10
+ **When user reports ANY widget issue, ALWAYS use:**
11
+ \`\`\`
12
+ snow_pull_artifact({ sys_id: 'widget_sys_id' })
13
+ \`\`\`
14
+
15
+ **NEVER use snow_query_table for widgets!** It will hit token limits and you can't use native tools.
16
+
17
+ **Common scenarios requiring snow_pull_artifact:**
18
+ - "Widget skips questions" → snow_pull_artifact
19
+ - "Form doesn't submit" → snow_pull_artifact
20
+ - "Data not displaying" → snow_pull_artifact
21
+ - "Button doesn't work" → snow_pull_artifact
22
+ - "Debug this widget" → snow_pull_artifact
23
+ - "Fix widget issue" → snow_pull_artifact
24
+ - Widget script > 1000 chars → snow_pull_artifact
25
+
8
26
  ### Rule #1: NO MOCK DATA - EVERYTHING REAL & COMPLETE
9
27
  **FORBIDDEN:** Mock data, placeholders, TODOs, stub implementations, test values, simulations, "this would normally...", partial implementations.
10
28
  **REQUIRED:** Complete, production-ready, fully functional code. Take time to implement EVERYTHING properly. Real integrations, comprehensive error handling, full validation.
@@ -18,14 +36,15 @@ Test before claiming broken. Check resources exist. Validate configurations. Evi
18
36
 
19
37
  ## 📋 MCP SERVERS & TOOLS (18 Servers, 200+ Tools)
20
38
 
21
- ### 1. **servicenow-local-development** 🔧 Widget/Artifact Sync
39
+ ### 1. **servicenow-local-development** 🔧 Widget/Artifact Sync [USE THIS FOR WIDGETS!]
22
40
  \`\`\`
23
- snow_pull_artifact - Pull ANY artifact to local files for native editing
41
+ snow_pull_artifact - Pull ANY artifact to local files (ALWAYS use for widgets!)
24
42
  snow_push_artifact - Push local changes back to ServiceNow
25
43
  snow_cleanup_artifacts - Clean local artifact cache
26
44
  snow_get_sync_status - Check artifact sync status
27
45
  snow_list_local_artifacts - List all pulled artifacts
28
46
  \`\`\`
47
+ **⚠️ CRITICAL: For ANY widget work, use snow_pull_artifact FIRST, not snow_query_table!**
29
48
 
30
49
  ### 2. **servicenow-deployment** 🚀 Complete Deployment System
31
50
  \`\`\`
@@ -41,7 +60,7 @@ snow_check_widget_coherence - Validate HTML/Client/Server communication
41
60
 
42
61
  ### 3. **servicenow-operations** 📊 Core Operations
43
62
  \`\`\`
44
- snow_query_table - Universal table query with pagination
63
+ snow_query_table - Universal table query (NOT for widgets - use snow_pull_artifact!)
45
64
  snow_query_incidents - Query and analyze incidents
46
65
  snow_analyze_incident - AI-powered incident analysis
47
66
  snow_auto_resolve_incident - Automated resolution
@@ -170,14 +189,16 @@ snow_devops_pipeline - CI/CD pipelines
170
189
  snow_manage_cmdb_relationships - CI relationships
171
190
  \`\`\`
172
191
 
173
- ### 15. **servicenow-knowledge-catalog** 📚 Knowledge & Catalog
192
+ ### 15. **servicenow-knowledge-catalog** 📚 Knowledge & Catalog (v3.6.10 Corrected!)
174
193
  \`\`\`
175
194
  snow_create_knowledge_article - KB articles
176
- snow_manage_catalog_item - Catalog items
177
- snow_configure_variables - Variable sets
178
- snow_create_catalog_policy - Catalog policies
179
- snow_manage_categories - Categories
195
+ snow_create_catalog_item - Catalog items
196
+ snow_create_catalog_variable - Variable sets
197
+ snow_create_catalog_ui_policy - CORRECTED: Creates in 2 tables (conditions as string, actions as records)
198
+ snow_order_catalog_item - Order catalog items
199
+ snow_discover_catalogs - Discover available catalogs
180
200
  \`\`\`
201
+ **✅ Corrected UI Policy (v3.6.10):** Conditions stored as query string in catalog_conditions field. Actions created in catalog_ui_policy_action table. Based on actual ServiceNow structure!
181
202
 
182
203
  ### 16. **servicenow-flow-workspace-mobile** 📱 Modern UX
183
204
  \`\`\`
@@ -273,6 +294,42 @@ await snow_deploy({
273
294
  });
274
295
  \`\`\`
275
296
 
297
+ ### Catalog UI Policy (v3.6.10 Corrected)
298
+ \`\`\`javascript
299
+ await snow_create_catalog_ui_policy({
300
+ cat_item: 'catalog_item_sys_id',
301
+ short_description: 'Dynamic Field Control',
302
+ // Conditions converted to ServiceNow query string format
303
+ conditions: [
304
+ {
305
+ catalog_variable: 'user_type', // Can use name or sys_id
306
+ operation: 'is', // or 'is not', 'contains', 'is empty', etc.
307
+ value: 'employee',
308
+ and_or: 'AND' // Connect with AND or OR
309
+ },
310
+ {
311
+ catalog_variable: 'department',
312
+ operation: 'is not empty',
313
+ value: ''
314
+ }
315
+ ],
316
+ // Actions still create separate records
317
+ actions: [
318
+ {
319
+ catalog_variable: 'manager_approval',
320
+ visible: true,
321
+ mandatory: true
322
+ },
323
+ {
324
+ catalog_variable: 'cost_center',
325
+ mandatory: true
326
+ }
327
+ ]
328
+ });
329
+ // Creates policy with conditions as query string in catalog_conditions field
330
+ // Actions created as separate records in catalog_ui_policy_action table
331
+ \`\`\`
332
+
276
333
  ## ⚡ Command Reference
277
334
 
278
335
  ### Core Commands
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.6.6",
4
- "description": "MCP TEMPLATE FIX - v3.6.6 ensures snow-flow init generates correct .mcp.json with UNIVERSAL ARTIFACT DETECTION. Uses sys_metadata to find ANY ServiceNow record by sys_id alone. Generic artifact support for custom/unknown tables. Auto-creates editable file structure for ANY table type. Includes early auto-compact, audit logging, and consolidated CLAUDE.md.",
3
+ "version": "3.6.12",
4
+ "description": "COMPLETE UI POLICY FIX - v3.6.12 fixes both policy and actions. Policy uses catalog_item + applies_to fields. Actions link to catalog_variable. Conditions stored as query string. Based on actual ServiceNow table structure.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
7
7
  "bin": {