snow-flow 2.0.2 → 2.0.4

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.
Files changed (173) hide show
  1. package/{.claude/mcp-config.json → .mcp.json} +13 -12
  2. package/.releaserc.json +47 -0
  3. package/README.md +48 -1
  4. package/package.json +1 -1
  5. package/.claude/claude-settings.json +0 -15
  6. package/.claude/commands/analysis/README.md +0 -9
  7. package/.claude/commands/automation/README.md +0 -9
  8. package/.claude/commands/github/README.md +0 -11
  9. package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
  10. package/.claude/commands/hooks/README.md +0 -11
  11. package/.claude/commands/monitoring/README.md +0 -9
  12. package/.claude/commands/optimization/README.md +0 -9
  13. package/.claude/commands/training/README.md +0 -9
  14. package/.claude/commands/workflows/README.md +0 -9
  15. package/.claude/config.json +0 -36
  16. package/.claude/helpers/github-setup.sh +0 -28
  17. package/.claude/helpers/quick-start.sh +0 -19
  18. package/.claude/helpers/setup-mcp.sh +0 -18
  19. package/.claude/settings.json +0 -114
  20. package/.claude/settings.local.json +0 -33
  21. package/.claude-flow/metrics/agent-metrics.json +0 -1
  22. package/.claude-flow/metrics/performance.json +0 -9
  23. package/.claude-flow/metrics/system-metrics.json +0 -15986
  24. package/.claude-flow/metrics/task-metrics.json +0 -10
  25. package/.roo/README.md +0 -402
  26. package/.roo/mcp-list.txt +0 -257
  27. package/.roo/mcp.json +0 -32
  28. package/.roo/workflows/basic-tdd.json +0 -32
  29. package/.roomodes +0 -201
  30. package/CLAUDE.md +0 -393
  31. package/bin/snow-flow.js +0 -3
  32. package/dist/cli.js.bak +0 -2052
  33. package/dist/config/snow-flow-config.d.ts +0 -1492
  34. package/dist/config/snow-flow-config.js +0 -938
  35. package/scripts/create-env.js +0 -91
  36. package/scripts/postinstall.js +0 -30
  37. package/scripts/register-mcp-servers.js +0 -210
  38. package/scripts/reset-mcp-servers.js +0 -246
  39. package/scripts/setup-mcp.js +0 -106
  40. package/scripts/update-version.js +0 -31
  41. package/src/agents/README.md +0 -192
  42. package/src/agents/base-agent.ts +0 -251
  43. package/src/agents/coordinator.ts +0 -971
  44. package/src/agents/index.ts +0 -18
  45. package/src/agents/queen-403-handler.ts +0 -230
  46. package/src/agents/queen-agent.ts +0 -1399
  47. package/src/agents/script-writer-agent.ts +0 -769
  48. package/src/agents/security-agent.ts +0 -726
  49. package/src/agents/widget-creator-agent.ts +0 -568
  50. package/src/api/error-handling.ts +0 -1758
  51. package/src/api/natural-language-mapper.ts +0 -630
  52. package/src/api/performance-optimizer.ts +0 -891
  53. package/src/api/transaction-manager.ts +0 -754
  54. package/src/cli/deploy-artifact.ts +0 -304
  55. package/src/cli/snow-flow-cli-integration.ts +0 -434
  56. package/src/cli.ts +0 -4455
  57. package/src/cli.ts.bak +0 -5616
  58. package/src/compliance/advanced-compliance-system.ts +0 -1268
  59. package/src/compliance/index.ts +0 -19
  60. package/src/config/snow-flow-config.ts +0 -1019
  61. package/src/documentation/index.ts +0 -16
  62. package/src/documentation/self-documenting-system.ts +0 -1421
  63. package/src/dynamic-version.ts +0 -44
  64. package/src/healing/index.ts +0 -20
  65. package/src/healing/self-healing-system.ts +0 -1435
  66. package/src/health/README.md +0 -161
  67. package/src/health/system-health.ts +0 -995
  68. package/src/index.ts +0 -60
  69. package/src/intelligence/acl-analyzer.ts +0 -377
  70. package/src/intelligence/auto-resolution-engine.ts +0 -643
  71. package/src/intelligence/gap-analysis-engine.ts +0 -488
  72. package/src/intelligence/manual-instructions-generator.ts +0 -744
  73. package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
  74. package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
  75. package/src/intelligence/performance-recommendations-engine.ts +0 -1223
  76. package/src/intelligence/requirements-analyzer.ts +0 -1148
  77. package/src/intelligence/task-analyzer.ts +0 -628
  78. package/src/managers/scope-manager.ts +0 -555
  79. package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
  80. package/src/mcp/base-mcp-server.ts +0 -660
  81. package/src/mcp/http-transport-wrapper.ts +0 -426
  82. package/src/mcp/service-discovery-client.ts +0 -312
  83. package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
  84. package/src/mcp/servicenow-automation-mcp.ts +0 -838
  85. package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
  86. package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
  87. package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
  88. package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
  89. package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
  90. package/src/mcp/servicenow-integration-mcp.ts +0 -819
  91. package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
  92. package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
  93. package/src/mcp/servicenow-mcp-server.ts +0 -728
  94. package/src/mcp/servicenow-memory-mcp.ts +0 -474
  95. package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
  96. package/src/mcp/servicenow-operations-mcp.ts +0 -3384
  97. package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
  98. package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
  99. package/src/mcp/servicenow-progressive-indexer.ts +0 -370
  100. package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
  101. package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
  102. package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
  103. package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
  104. package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
  105. package/src/mcp/servicenow-update-set-mcp.ts +0 -811
  106. package/src/mcp/shared/agent-context-provider.ts +0 -365
  107. package/src/mcp/shared/base-mcp-server.ts +0 -2463
  108. package/src/mcp/shared/mcp-memory-manager.ts +0 -540
  109. package/src/mcp/shared/mcp-resource-manager.ts +0 -367
  110. package/src/mcp/snow-flow-mcp.ts +0 -911
  111. package/src/mcp/start-all-mcp-servers.ts +0 -102
  112. package/src/mcp/start-servicenow-mcp.ts +0 -67
  113. package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
  114. package/src/monitoring/performance-tracker.ts +0 -777
  115. package/src/optimization/cost-optimization-engine.ts +0 -1125
  116. package/src/optimization/index.ts +0 -10
  117. package/src/queen/README.md +0 -403
  118. package/src/queen/agent-factory.ts +0 -574
  119. package/src/queen/index.ts +0 -94
  120. package/src/queen/mcp-execution-bridge.ts +0 -681
  121. package/src/queen/neural-learning.ts +0 -319
  122. package/src/queen/parallel-agent-engine.ts +0 -848
  123. package/src/queen/queen-memory-system.ts +0 -490
  124. package/src/queen/queen-memory.ts +0 -456
  125. package/src/queen/servicenow-queen.ts +0 -1029
  126. package/src/queen/types.ts +0 -87
  127. package/src/rollback/smart-rollback-system.ts +0 -866
  128. package/src/schemas/deployment.schema.json +0 -58
  129. package/src/schemas/flow.schema.json +0 -79
  130. package/src/schemas/widget.schema.json +0 -72
  131. package/src/snow-flow-system.ts +0 -541
  132. package/src/sparc/sparc-help.ts +0 -49
  133. package/src/sparc/team-sparc.ts +0 -88
  134. package/src/strategies/global-scope-strategy.ts +0 -736
  135. package/src/templates/base/application.template.json +0 -45
  136. package/src/templates/base/business_rule.template.json +0 -33
  137. package/src/templates/base/script_include.template.json +0 -18
  138. package/src/templates/base/table.template.json +0 -64
  139. package/src/templates/base/widget.template.json +0 -25
  140. package/src/templates/patterns/composite.incident-management.template.json +0 -140
  141. package/src/templates/patterns/widget.dashboard.template.json +0 -238
  142. package/src/templates/patterns/widget.datatable.template.json +0 -292
  143. package/src/testing/integration-test-suite.ts +0 -1276
  144. package/src/types/index.ts +0 -183
  145. package/src/types/neo4j-driver.d.ts +0 -23
  146. package/src/types/servicenow.types.ts +0 -307
  147. package/src/types/snow-flow.types.ts +0 -186
  148. package/src/types/todo.types.ts +0 -70
  149. package/src/utils/action-type-cache.ts +0 -286
  150. package/src/utils/agent-detector.ts +0 -573
  151. package/src/utils/artifact-tracker.ts +0 -379
  152. package/src/utils/dependency-detector.ts +0 -233
  153. package/src/utils/deployment-metadata-handler.ts +0 -518
  154. package/src/utils/error-recovery.ts +0 -680
  155. package/src/utils/logger.ts +0 -60
  156. package/src/utils/mcp-auth-middleware.ts +0 -262
  157. package/src/utils/mcp-config-manager.ts +0 -270
  158. package/src/utils/mcp-server-manager.ts +0 -446
  159. package/src/utils/mcp-tool-registry.ts +0 -298
  160. package/src/utils/migrate-snow-flow.ts +0 -98
  161. package/src/utils/oauth-html-templates.ts +0 -188
  162. package/src/utils/scope-utils.ts +0 -443
  163. package/src/utils/servicenow-client.ts +0 -3321
  164. package/src/utils/servicenow-id-generator.ts +0 -181
  165. package/src/utils/snow-memory-manager.ts +0 -605
  166. package/src/utils/snow-oauth.ts +0 -797
  167. package/src/utils/template-engine.ts +0 -463
  168. package/src/utils/theme-manager.ts +0 -295
  169. package/src/utils/unified-auth-store.ts +0 -222
  170. package/src/utils/update-set-importer.ts +0 -422
  171. package/src/utils/update-set-xml-packager.ts +0 -371
  172. package/src/utils/widget-template-generator.ts +0 -1744
  173. package/src/version.ts +0 -1950
@@ -1,1148 +0,0 @@
1
- /**
2
- * Requirements Analyzer - Intelligent Gap Analysis Engine
3
- *
4
- * Analyzes objectives to identify ALL required ServiceNow components,
5
- * not just what MCP tools can handle.
6
- */
7
-
8
- import { logger } from '../utils/logger';
9
-
10
- export interface ServiceNowRequirement {
11
- id: string;
12
- type: RequirementType;
13
- name: string;
14
- description: string;
15
- priority: 'high' | 'medium' | 'low';
16
- dependencies: string[];
17
- estimatedEffort: 'low' | 'medium' | 'high';
18
- automatable: boolean;
19
- mcpCoverage: boolean;
20
- category: RequirementCategory;
21
- specificSteps?: string[];
22
- validationCriteria?: string[];
23
- riskLevel: 'low' | 'medium' | 'high';
24
- }
25
-
26
- export type RequirementType =
27
- // Core Artifacts (MCP Covered)
28
- | 'widget' | 'flow' | 'business_rule' | 'script_include' | 'table' | 'application'
29
- // Authentication & Security
30
- | 'user_role' | 'acl_rule' | 'oauth_provider' | 'sso_config' | 'data_policy'
31
- | 'security_policy' | 'audit_rule' | 'encryption_context' | 'saml_config' | 'mfa_config'
32
- // Data & Integration
33
- | 'import_set' | 'transform_map' | 'field_map' | 'web_service' | 'rest_message'
34
- | 'email_config' | 'ldap_config' | 'database_view' | 'database_index'
35
- | 'soap_message' | 'import_set_transformer' | 'coremeta_data' | 'ldap_server'
36
- // User Interface
37
- | 'ui_action' | 'ui_policy' | 'ui_page' | 'ui_macro' | 'ui_script'
38
- | 'client_script' | 'css_include' | 'navigator_module' | 'homepage'
39
- | 'form_layout' | 'form_section' | 'list_layout' | 'related_list' | 'formatter'
40
- | 'application_menu' | 'module_navigation'
41
- // Workflow & Process
42
- | 'workflow' | 'scheduled_job' | 'event_rule' | 'notification' | 'email_template'
43
- | 'sla_definition' | 'escalation_rule' | 'approval_rule' | 'state_flow'
44
- | 'workflow_activity' | 'workflow_transition' | 'approval_definition' | 'approval_workflow'
45
- | 'notification_rule' | 'scheduled_task' | 'event_registration'
46
- // Configuration & Setup
47
- | 'dictionary_entry' | 'choice_list' | 'ui_formatter' | 'display_value'
48
- | 'reference_qualifier' | 'data_lookup' | 'sys_property' | 'system_setting'
49
- | 'system_property' | 'system_definition' | 'theme_configuration' | 'branding_config'
50
- | 'table_rotation' | 'partitioning_config' | 'cache_configuration'
51
- // Reporting & Analytics
52
- | 'report' | 'dashboard' | 'metric' | 'kpi' | 'scheduled_report'
53
- | 'data_source' | 'gauge' | 'chart_configuration' | 'dashboard_tab'
54
- | 'performance_analytics' | 'metric_definition' | 'job_queue' | 'transaction_quota'
55
- // Operations & Service Management
56
- | 'incident_table' | 'incident__analysis' | 'query_rule' | 'catalog_item' | 'catalog_category'
57
- | 'catalog_variable' | 'workflow_integration' | 'user_account' | 'user_group'
58
- | 'group_membership' | 'integration_endpoint' | 'update_set'
59
- // Automation & Monitoring
60
- | 'probe' | 'sensor' | 'discovery_rule' | 'cmdb_identification'
61
- | 'orchestration_workflow' | 'runbook' | 'knowledge_article'
62
- | 'inbound_email_action' | 'processor' | 'pdf_generator' | 'sys_script_validator'
63
- // Mobile & Portal
64
- | 'mobile_app_config' | 'service_portal_config' | 'portal_widget'
65
- | 'portal_page' | 'portal_theme' | 'mobile_ui_policy';
66
-
67
- export type RequirementCategory =
68
- | 'core_development' | 'security_compliance' | 'data_integration'
69
- | 'user_interface' | 'process_automation' | 'system_configuration'
70
- | 'reporting_analytics' | 'mobile_portal' | 'monitoring_operations';
71
-
72
- export interface ObjectiveAnalysis {
73
- objective: string;
74
- requirements: ServiceNowRequirement[];
75
- totalRequirements: number;
76
- mcpCoveredCount: number;
77
- gapCount: number;
78
- mcpCoveragePercentage: number;
79
- estimatedComplexity: 'low' | 'medium' | 'high' | 'enterprise';
80
- riskAssessment: 'low' | 'medium' | 'high';
81
- categories: RequirementCategory[];
82
- criticalPath: string[];
83
- estimatedDuration: string;
84
- }
85
-
86
- export class RequirementsAnalyzer {
87
- private static readonly OBJECTIVE_PATTERNS = {
88
- // User Management & Security
89
- user_provisioning: {
90
- keywords: ['user', 'provisioning', 'account', 'create user', 'new employee', 'onboarding'],
91
- requirements: ['user_role', 'acl_rule', 'group_membership', 'email_template', 'workflow']
92
- },
93
- access_control: {
94
- keywords: ['access', 'permission', 'role', 'security', 'authorization'],
95
- requirements: ['user_role', 'acl_rule', 'security_policy', 'audit_rule']
96
- },
97
-
98
- // Data Integration
99
- data_import: {
100
- keywords: ['import', 'data load', 'csv', 'excel', 'migration', 'sync'],
101
- requirements: ['import_set', 'transform_map', 'field_map', 'scheduled_job']
102
- },
103
- api_integration: {
104
- keywords: ['api', 'rest', 'soap', 'web service', 'integration', 'external'],
105
- requirements: ['rest_message', 'web_service', 'oauth_provider', 'business_rule']
106
- },
107
-
108
- // Process Automation
109
- approval_process: {
110
- keywords: ['approval', 'review', 'authorize', 'escalate', 'workflow'],
111
- requirements: ['workflow', 'approval_rule', 'notification', 'email_template', 'sla_definition']
112
- },
113
- notification_system: {
114
- keywords: ['notification', 'email', 'alert', 'notify', 'message'],
115
- requirements: ['notification', 'email_template', 'event_rule', 'email_config']
116
- },
117
-
118
- // User Interface
119
- dashboard_portal: {
120
- keywords: ['dashboard', 'portal', 'homepage', 'overview', 'metrics'],
121
- requirements: ['widget', 'portal_page', 'portal_theme', 'navigator_module']
122
- },
123
- custom_form: {
124
- keywords: ['form', 'ui', 'input', 'custom fields', 'validation'],
125
- requirements: ['dictionary_entry', 'ui_policy', 'client_script', 'data_policy']
126
- },
127
-
128
- // Reporting & Analytics
129
- reporting_system: {
130
- keywords: ['report', 'analytics', 'metrics', 'kpi', 'dashboard'],
131
- requirements: ['report', 'dashboard', 'scheduled_report', 'data_source']
132
- },
133
-
134
- // Infrastructure & Monitoring
135
- monitoring_system: {
136
- keywords: ['monitor', 'alert', 'health', 'performance', 'discovery'],
137
- requirements: ['probe', 'sensor', 'event_rule', 'notification', 'scheduled_job']
138
- },
139
-
140
- // ITSM Processes
141
- incident_management: {
142
- keywords: ['incident', 'ticket', 'issue', 'problem', 'support'],
143
- requirements: ['table', 'workflow', 'business_rule', 'notification', 'sla_definition']
144
- },
145
- change_management: {
146
- keywords: ['change', 'release', 'deployment', 'cab', 'approval'],
147
- requirements: ['workflow', 'approval_rule', 'scheduled_job', 'notification']
148
- },
149
-
150
- // Mobile & Modern
151
- mobile_app: {
152
- keywords: ['mobile', 'app', 'phone', 'tablet', 'ios', 'android'],
153
- requirements: ['mobile_app_config', 'mobile_ui_policy', 'rest_message']
154
- }
155
- };
156
-
157
- private static readonly REQUIREMENT_DEFINITIONS: Partial<Record<RequirementType, {
158
- description: string;
159
- category: RequirementCategory;
160
- automatable: boolean;
161
- mcpCoverage: boolean;
162
- estimatedEffort: 'low' | 'medium' | 'high';
163
- riskLevel: 'low' | 'medium' | 'high';
164
- prerequisites: RequirementType[];
165
- }>> = {
166
- // Core Development (MCP Covered)
167
- widget: {
168
- description: 'Service Portal widget for user interface',
169
- category: 'core_development',
170
- automatable: true,
171
- mcpCoverage: true,
172
- estimatedEffort: 'medium',
173
- riskLevel: 'low',
174
- prerequisites: []
175
- },
176
- flow: {
177
- description: 'Flow Designer workflow for process automation',
178
- category: 'core_development',
179
- automatable: true,
180
- mcpCoverage: true,
181
- estimatedEffort: 'medium',
182
- riskLevel: 'low',
183
- prerequisites: []
184
- },
185
- business_rule: {
186
- description: 'Server-side business logic and validation',
187
- category: 'core_development',
188
- automatable: true,
189
- mcpCoverage: true,
190
- estimatedEffort: 'low',
191
- riskLevel: 'medium',
192
- prerequisites: []
193
- },
194
- script_include: {
195
- description: 'Reusable server-side JavaScript functions',
196
- category: 'core_development',
197
- automatable: true,
198
- mcpCoverage: true,
199
- estimatedEffort: 'low',
200
- riskLevel: 'low',
201
- prerequisites: []
202
- },
203
- table: {
204
- description: 'Database table for data storage',
205
- category: 'core_development',
206
- automatable: true,
207
- mcpCoverage: true,
208
- estimatedEffort: 'high',
209
- riskLevel: 'high',
210
- prerequisites: []
211
- },
212
- application: {
213
- description: 'ServiceNow application container',
214
- category: 'core_development',
215
- automatable: true,
216
- mcpCoverage: true,
217
- estimatedEffort: 'high',
218
- riskLevel: 'medium',
219
- prerequisites: []
220
- },
221
-
222
- // Security & Compliance (Gaps!)
223
- user_role: {
224
- description: 'User roles and permission groups',
225
- category: 'security_compliance',
226
- automatable: true,
227
- mcpCoverage: false,
228
- estimatedEffort: 'medium',
229
- riskLevel: 'high',
230
- prerequisites: []
231
- },
232
- acl_rule: {
233
- description: 'Access control list rules for data security',
234
- category: 'security_compliance',
235
- automatable: true,
236
- mcpCoverage: false,
237
- estimatedEffort: 'medium',
238
- riskLevel: 'high',
239
- prerequisites: ['table']
240
- },
241
- oauth_provider: {
242
- description: 'OAuth authentication provider configuration',
243
- category: 'security_compliance',
244
- automatable: false,
245
- mcpCoverage: false,
246
- estimatedEffort: 'high',
247
- riskLevel: 'high',
248
- prerequisites: []
249
- },
250
- sso_config: {
251
- description: 'Single Sign-On configuration',
252
- category: 'security_compliance',
253
- automatable: false,
254
- mcpCoverage: false,
255
- estimatedEffort: 'high',
256
- riskLevel: 'high',
257
- prerequisites: []
258
- },
259
- data_policy: {
260
- description: 'Data validation and mandatory field policies',
261
- category: 'security_compliance',
262
- automatable: true,
263
- mcpCoverage: false,
264
- estimatedEffort: 'low',
265
- riskLevel: 'low',
266
- prerequisites: ['table']
267
- },
268
- security_policy: {
269
- description: 'Security policies and compliance rules',
270
- category: 'security_compliance',
271
- automatable: true,
272
- mcpCoverage: true,
273
- estimatedEffort: 'medium',
274
- riskLevel: 'high',
275
- prerequisites: []
276
- },
277
- audit_rule: {
278
- description: 'Audit rules for tracking data changes',
279
- category: 'security_compliance',
280
- automatable: true,
281
- mcpCoverage: true,
282
- estimatedEffort: 'low',
283
- riskLevel: 'medium',
284
- prerequisites: ['table']
285
- },
286
- encryption_context: {
287
- description: 'Field encryption configuration',
288
- category: 'security_compliance',
289
- automatable: false,
290
- mcpCoverage: false,
291
- estimatedEffort: 'high',
292
- riskLevel: 'high',
293
- prerequisites: ['table']
294
- },
295
-
296
- // Data Integration (Partial MCP Coverage)
297
- import_set: {
298
- description: 'Import set table for data loading',
299
- category: 'data_integration',
300
- automatable: true,
301
- mcpCoverage: true,
302
- estimatedEffort: 'medium',
303
- riskLevel: 'low',
304
- prerequisites: []
305
- },
306
- transform_map: {
307
- description: 'Transform map for data transformation',
308
- category: 'data_integration',
309
- automatable: true,
310
- mcpCoverage: true,
311
- estimatedEffort: 'medium',
312
- riskLevel: 'medium',
313
- prerequisites: ['import_set']
314
- },
315
- field_map: {
316
- description: 'Field mapping for data transformation',
317
- category: 'data_integration',
318
- automatable: true,
319
- mcpCoverage: true,
320
- estimatedEffort: 'low',
321
- riskLevel: 'low',
322
- prerequisites: ['transform_map']
323
- },
324
- web_service: {
325
- description: 'SOAP web service for integration',
326
- category: 'data_integration',
327
- automatable: true,
328
- mcpCoverage: true,
329
- estimatedEffort: 'medium',
330
- riskLevel: 'medium',
331
- prerequisites: []
332
- },
333
- rest_message: {
334
- description: 'REST message for API integration',
335
- category: 'data_integration',
336
- automatable: true,
337
- mcpCoverage: true,
338
- estimatedEffort: 'medium',
339
- riskLevel: 'medium',
340
- prerequisites: []
341
- },
342
- email_config: {
343
- description: 'Email server configuration',
344
- category: 'data_integration',
345
- automatable: true,
346
- mcpCoverage: true,
347
- estimatedEffort: 'high',
348
- riskLevel: 'high',
349
- prerequisites: []
350
- },
351
- ldap_config: {
352
- description: 'LDAP server configuration for user sync',
353
- category: 'data_integration',
354
- automatable: false,
355
- mcpCoverage: false,
356
- estimatedEffort: 'high',
357
- riskLevel: 'high',
358
- prerequisites: []
359
- },
360
- database_view: {
361
- description: 'Database view for complex queries',
362
- category: 'data_integration',
363
- automatable: false,
364
- mcpCoverage: false,
365
- estimatedEffort: 'high',
366
- riskLevel: 'high',
367
- prerequisites: ['table']
368
- },
369
- database_index: {
370
- description: 'Database index for performance optimization',
371
- category: 'data_integration',
372
- automatable: false,
373
- mcpCoverage: false,
374
- estimatedEffort: 'medium',
375
- riskLevel: 'medium',
376
- prerequisites: ['table']
377
- },
378
-
379
- // User Interface (Partial MCP Coverage)
380
- ui_action: {
381
- description: 'Custom UI actions and buttons',
382
- category: 'user_interface',
383
- automatable: true,
384
- mcpCoverage: true,
385
- estimatedEffort: 'low',
386
- riskLevel: 'low',
387
- prerequisites: ['table']
388
- },
389
- ui_policy: {
390
- description: 'UI policies for dynamic form behavior',
391
- category: 'user_interface',
392
- automatable: true,
393
- mcpCoverage: true,
394
- estimatedEffort: 'medium',
395
- riskLevel: 'low',
396
- prerequisites: ['table']
397
- },
398
- ui_page: {
399
- description: 'Custom UI pages and interfaces',
400
- category: 'user_interface',
401
- automatable: true,
402
- mcpCoverage: true,
403
- estimatedEffort: 'high',
404
- riskLevel: 'medium',
405
- prerequisites: []
406
- },
407
- ui_macro: {
408
- description: 'Reusable UI components and macros',
409
- category: 'user_interface',
410
- automatable: false,
411
- mcpCoverage: false,
412
- estimatedEffort: 'medium',
413
- riskLevel: 'low',
414
- prerequisites: []
415
- },
416
- ui_script: {
417
- description: 'UI scripts for enhanced functionality',
418
- category: 'user_interface',
419
- automatable: true,
420
- mcpCoverage: true,
421
- estimatedEffort: 'low',
422
- riskLevel: 'low',
423
- prerequisites: []
424
- },
425
- client_script: {
426
- description: 'Client-side JavaScript for forms',
427
- category: 'user_interface',
428
- automatable: true,
429
- mcpCoverage: true,
430
- estimatedEffort: 'low',
431
- riskLevel: 'low',
432
- prerequisites: ['table']
433
- },
434
- css_include: {
435
- description: 'Custom CSS styles and themes',
436
- category: 'user_interface',
437
- automatable: false,
438
- mcpCoverage: false,
439
- estimatedEffort: 'low',
440
- riskLevel: 'low',
441
- prerequisites: []
442
- },
443
- navigator_module: {
444
- description: 'Application navigator menu items',
445
- category: 'user_interface',
446
- automatable: false,
447
- mcpCoverage: false,
448
- estimatedEffort: 'low',
449
- riskLevel: 'low',
450
- prerequisites: ['application']
451
- },
452
- homepage: {
453
- description: 'Custom homepage and dashboards',
454
- category: 'user_interface',
455
- automatable: false,
456
- mcpCoverage: false,
457
- estimatedEffort: 'high',
458
- riskLevel: 'medium',
459
- prerequisites: ['widget']
460
- },
461
-
462
- // Process Automation (Partial MCP Coverage)
463
- workflow: {
464
- description: 'Legacy workflow for process automation',
465
- category: 'process_automation',
466
- automatable: true,
467
- mcpCoverage: false,
468
- estimatedEffort: 'high',
469
- riskLevel: 'medium',
470
- prerequisites: []
471
- },
472
- scheduled_job: {
473
- description: 'Scheduled jobs for automation',
474
- category: 'process_automation',
475
- automatable: true,
476
- mcpCoverage: true,
477
- estimatedEffort: 'medium',
478
- riskLevel: 'medium',
479
- prerequisites: []
480
- },
481
- event_rule: {
482
- description: 'Event rules for automatic actions',
483
- category: 'process_automation',
484
- automatable: true,
485
- mcpCoverage: true,
486
- estimatedEffort: 'medium',
487
- riskLevel: 'medium',
488
- prerequisites: []
489
- },
490
- notification: {
491
- description: 'Email notifications and alerts',
492
- category: 'process_automation',
493
- automatable: true,
494
- mcpCoverage: true,
495
- estimatedEffort: 'low',
496
- riskLevel: 'low',
497
- prerequisites: ['email_template']
498
- },
499
- email_template: {
500
- description: 'Email templates for notifications',
501
- category: 'process_automation',
502
- automatable: false,
503
- mcpCoverage: false,
504
- estimatedEffort: 'low',
505
- riskLevel: 'low',
506
- prerequisites: []
507
- },
508
- sla_definition: {
509
- description: 'SLA definitions and tracking',
510
- category: 'process_automation',
511
- automatable: true,
512
- mcpCoverage: true,
513
- estimatedEffort: 'medium',
514
- riskLevel: 'medium',
515
- prerequisites: ['table']
516
- },
517
- escalation_rule: {
518
- description: 'Escalation rules for SLA breaches',
519
- category: 'process_automation',
520
- automatable: true,
521
- mcpCoverage: true,
522
- estimatedEffort: 'medium',
523
- riskLevel: 'medium',
524
- prerequisites: ['sla_definition']
525
- },
526
- approval_rule: {
527
- description: 'Approval rules and delegation',
528
- category: 'process_automation',
529
- automatable: false,
530
- mcpCoverage: false,
531
- estimatedEffort: 'medium',
532
- riskLevel: 'medium',
533
- prerequisites: []
534
- },
535
- state_flow: {
536
- description: 'State flow for record transitions',
537
- category: 'process_automation',
538
- automatable: false,
539
- mcpCoverage: false,
540
- estimatedEffort: 'high',
541
- riskLevel: 'high',
542
- prerequisites: ['table']
543
- },
544
-
545
- // System Configuration (Major Gaps!)
546
- dictionary_entry: {
547
- description: 'Table field definitions and properties',
548
- category: 'system_configuration',
549
- automatable: false,
550
- mcpCoverage: false,
551
- estimatedEffort: 'low',
552
- riskLevel: 'medium',
553
- prerequisites: ['table']
554
- },
555
- choice_list: {
556
- description: 'Choice lists for dropdown fields',
557
- category: 'system_configuration',
558
- automatable: false,
559
- mcpCoverage: false,
560
- estimatedEffort: 'low',
561
- riskLevel: 'low',
562
- prerequisites: ['dictionary_entry']
563
- },
564
- ui_formatter: {
565
- description: 'Custom field formatters and displays',
566
- category: 'system_configuration',
567
- automatable: false,
568
- mcpCoverage: false,
569
- estimatedEffort: 'medium',
570
- riskLevel: 'low',
571
- prerequisites: []
572
- },
573
- display_value: {
574
- description: 'Display value configurations',
575
- category: 'system_configuration',
576
- automatable: false,
577
- mcpCoverage: false,
578
- estimatedEffort: 'low',
579
- riskLevel: 'low',
580
- prerequisites: ['dictionary_entry']
581
- },
582
- reference_qualifier: {
583
- description: 'Reference field qualifiers and filters',
584
- category: 'system_configuration',
585
- automatable: false,
586
- mcpCoverage: false,
587
- estimatedEffort: 'medium',
588
- riskLevel: 'medium',
589
- prerequisites: ['dictionary_entry']
590
- },
591
- data_lookup: {
592
- description: 'Data lookup definitions and rules',
593
- category: 'system_configuration',
594
- automatable: false,
595
- mcpCoverage: false,
596
- estimatedEffort: 'medium',
597
- riskLevel: 'low',
598
- prerequisites: []
599
- },
600
- sys_property: {
601
- description: 'System properties and configuration',
602
- category: 'system_configuration',
603
- automatable: false,
604
- mcpCoverage: false,
605
- estimatedEffort: 'low',
606
- riskLevel: 'high',
607
- prerequisites: []
608
- },
609
- system_setting: {
610
- description: 'System settings and preferences',
611
- category: 'system_configuration',
612
- automatable: false,
613
- mcpCoverage: false,
614
- estimatedEffort: 'medium',
615
- riskLevel: 'high',
616
- prerequisites: []
617
- },
618
-
619
- // Reporting & Analytics (Partial MCP Coverage)
620
- report: {
621
- description: 'Reports and data _analysis',
622
- category: 'reporting_analytics',
623
- automatable: true,
624
- mcpCoverage: true,
625
- estimatedEffort: 'medium',
626
- riskLevel: 'low',
627
- prerequisites: ['table']
628
- },
629
- dashboard: {
630
- description: 'Dashboards and data visualization',
631
- category: 'reporting_analytics',
632
- automatable: true,
633
- mcpCoverage: true,
634
- estimatedEffort: 'medium',
635
- riskLevel: 'low',
636
- prerequisites: ['report']
637
- },
638
- metric: {
639
- description: 'Custom metrics and indicators',
640
- category: 'reporting_analytics',
641
- automatable: true,
642
- mcpCoverage: true,
643
- estimatedEffort: 'low',
644
- riskLevel: 'low',
645
- prerequisites: []
646
- },
647
- kpi: {
648
- description: 'Key Performance Indicators',
649
- category: 'reporting_analytics',
650
- automatable: true,
651
- mcpCoverage: true,
652
- estimatedEffort: 'medium',
653
- riskLevel: 'low',
654
- prerequisites: ['metric']
655
- },
656
- scheduled_report: {
657
- description: 'Scheduled report delivery',
658
- category: 'reporting_analytics',
659
- automatable: true,
660
- mcpCoverage: true,
661
- estimatedEffort: 'low',
662
- riskLevel: 'low',
663
- prerequisites: ['report']
664
- },
665
- data_source: {
666
- description: 'Data sources for reporting',
667
- category: 'reporting_analytics',
668
- automatable: false,
669
- mcpCoverage: false,
670
- estimatedEffort: 'high',
671
- riskLevel: 'medium',
672
- prerequisites: []
673
- },
674
- gauge: {
675
- description: 'Performance gauges and meters',
676
- category: 'reporting_analytics',
677
- automatable: false,
678
- mcpCoverage: false,
679
- estimatedEffort: 'medium',
680
- riskLevel: 'low',
681
- prerequisites: ['metric']
682
- },
683
- chart_configuration: {
684
- description: 'Chart configuration and styling',
685
- category: 'reporting_analytics',
686
- automatable: false,
687
- mcpCoverage: false,
688
- estimatedEffort: 'low',
689
- riskLevel: 'low',
690
- prerequisites: ['dashboard']
691
- },
692
-
693
- // Mobile & Portal (Major Gaps!)
694
- mobile_app_config: {
695
- description: 'Mobile application configuration',
696
- category: 'mobile_portal',
697
- automatable: false,
698
- mcpCoverage: false,
699
- estimatedEffort: 'high',
700
- riskLevel: 'high',
701
- prerequisites: []
702
- },
703
- service_portal_config: {
704
- description: 'Service Portal configuration',
705
- category: 'mobile_portal',
706
- automatable: false,
707
- mcpCoverage: false,
708
- estimatedEffort: 'high',
709
- riskLevel: 'medium',
710
- prerequisites: []
711
- },
712
- portal_widget: {
713
- description: 'Service Portal widgets',
714
- category: 'mobile_portal',
715
- automatable: true,
716
- mcpCoverage: true,
717
- estimatedEffort: 'medium',
718
- riskLevel: 'low',
719
- prerequisites: ['service_portal_config']
720
- },
721
- portal_page: {
722
- description: 'Service Portal pages',
723
- category: 'mobile_portal',
724
- automatable: false,
725
- mcpCoverage: false,
726
- estimatedEffort: 'medium',
727
- riskLevel: 'low',
728
- prerequisites: ['service_portal_config']
729
- },
730
- portal_theme: {
731
- description: 'Service Portal themes and styling',
732
- category: 'mobile_portal',
733
- automatable: false,
734
- mcpCoverage: false,
735
- estimatedEffort: 'high',
736
- riskLevel: 'low',
737
- prerequisites: ['service_portal_config']
738
- },
739
- mobile_ui_policy: {
740
- description: 'Mobile-specific UI policies',
741
- category: 'mobile_portal',
742
- automatable: false,
743
- mcpCoverage: false,
744
- estimatedEffort: 'medium',
745
- riskLevel: 'medium',
746
- prerequisites: ['mobile_app_config']
747
- },
748
-
749
- // Monitoring & Operations (Major Gaps!)
750
- probe: {
751
- description: 'Discovery probes for monitoring',
752
- category: 'monitoring_operations',
753
- automatable: false,
754
- mcpCoverage: false,
755
- estimatedEffort: 'high',
756
- riskLevel: 'high',
757
- prerequisites: []
758
- },
759
- sensor: {
760
- description: 'Discovery sensors and patterns',
761
- category: 'monitoring_operations',
762
- automatable: false,
763
- mcpCoverage: false,
764
- estimatedEffort: 'high',
765
- riskLevel: 'high',
766
- prerequisites: []
767
- },
768
- discovery_rule: {
769
- description: 'Discovery rules and classification',
770
- category: 'monitoring_operations',
771
- automatable: false,
772
- mcpCoverage: false,
773
- estimatedEffort: 'high',
774
- riskLevel: 'high',
775
- prerequisites: []
776
- },
777
- cmdb_identification: {
778
- description: 'CMDB identification rules',
779
- category: 'monitoring_operations',
780
- automatable: false,
781
- mcpCoverage: false,
782
- estimatedEffort: 'high',
783
- riskLevel: 'high',
784
- prerequisites: []
785
- },
786
- orchestration_workflow: {
787
- description: 'Orchestration workflows',
788
- category: 'monitoring_operations',
789
- automatable: false,
790
- mcpCoverage: false,
791
- estimatedEffort: 'high',
792
- riskLevel: 'high',
793
- prerequisites: []
794
- },
795
- runbook: {
796
- description: 'Automated runbooks',
797
- category: 'monitoring_operations',
798
- automatable: false,
799
- mcpCoverage: false,
800
- estimatedEffort: 'high',
801
- riskLevel: 'medium',
802
- prerequisites: []
803
- },
804
- knowledge_article: {
805
- description: 'Knowledge base articles',
806
- category: 'monitoring_operations',
807
- automatable: false,
808
- mcpCoverage: false,
809
- estimatedEffort: 'medium',
810
- riskLevel: 'low',
811
- prerequisites: []
812
- }
813
- };
814
-
815
- /**
816
- * Analyze an objective and identify all required ServiceNow components
817
- */
818
- static analyzeObjective(objective: string): ObjectiveAnalysis {
819
- logger.info(`🔍 Analyzing objective: ${objective}`);
820
-
821
- const requirements = this.identifyRequirements(objective);
822
- const mcpCoveredCount = requirements.filter(r => r.mcpCoverage).length;
823
- const gapCount = requirements.length - mcpCoveredCount;
824
- const mcpCoveragePercentage = Math.round((mcpCoveredCount / requirements.length) * 100);
825
-
826
- const categories = [...new Set(requirements.map(r => r.category))];
827
- const estimatedComplexity = this.calculateComplexity(requirements);
828
- const riskAssessment = this.assessRisk(requirements);
829
- const criticalPath = this.calculateCriticalPath(requirements);
830
- const estimatedDuration = this.estimateDuration(requirements);
831
-
832
- const _analysis: ObjectiveAnalysis = {
833
- objective,
834
- requirements,
835
- totalRequirements: requirements.length,
836
- mcpCoveredCount,
837
- gapCount,
838
- mcpCoveragePercentage,
839
- estimatedComplexity,
840
- riskAssessment,
841
- categories,
842
- criticalPath,
843
- estimatedDuration
844
- };
845
-
846
- logger.info(`📊 Analysis complete: ${requirements.length} requirements, ${gapCount} gaps (${100 - mcpCoveragePercentage}% coverage gap)`);
847
-
848
- return _analysis;
849
- }
850
-
851
- private static identifyRequirements(objective: string): ServiceNowRequirement[] {
852
- const requirements: ServiceNowRequirement[] = [];
853
- const objectiveLower = objective.toLowerCase();
854
-
855
- // Check against all pattern definitions
856
- for (const [patternName, pattern] of Object.entries(this.OBJECTIVE_PATTERNS)) {
857
- const matchScore = pattern.keywords.reduce((score, keyword) => {
858
- return objectiveLower.includes(keyword.toLowerCase()) ? score + 1 : score;
859
- }, 0);
860
-
861
- if (matchScore > 0) {
862
- logger.info(`🎯 Matched pattern: ${patternName} (score: ${matchScore})`);
863
-
864
- // Add pattern requirements
865
- for (const reqType of pattern.requirements) {
866
- if (!requirements.find(r => r.type === reqType)) {
867
- const requirement = this.createRequirement(reqType as RequirementType, objective);
868
- if (requirement) {
869
- requirements.push(requirement);
870
- }
871
- }
872
- }
873
- }
874
- }
875
-
876
- // Add core requirements based on direct keyword matching
877
- this.addCoreRequirements(objectiveLower, requirements);
878
-
879
- // Add implied requirements based on dependencies
880
- this.addImpliedRequirements(requirements);
881
-
882
- // Sort by priority and dependencies
883
- return this.sortRequirements(requirements);
884
- }
885
-
886
- private static createRequirement(
887
- type: RequirementType,
888
- objective: string
889
- ): ServiceNowRequirement | null {
890
- const definition = this.REQUIREMENT_DEFINITIONS[type];
891
- if (!definition) return null;
892
-
893
- return {
894
- id: `req_${type}_${Date.now()}`,
895
- type,
896
- name: this.generateRequirementName(type, objective),
897
- description: definition.description,
898
- priority: this.calculatePriority(type, objective),
899
- dependencies: definition.prerequisites,
900
- estimatedEffort: definition.estimatedEffort,
901
- automatable: definition.automatable,
902
- mcpCoverage: definition.mcpCoverage,
903
- category: definition.category,
904
- specificSteps: this.generateSpecificSteps(type, objective),
905
- validationCriteria: this.generateValidationCriteria(type),
906
- riskLevel: definition.riskLevel
907
- };
908
- }
909
-
910
- private static addCoreRequirements(objective: string, requirements: ServiceNowRequirement[]): void {
911
- // Widget keywords
912
- if (/widget|dashboard|portal|chart|display/.test(objective)) {
913
- this.addRequirementIfMissing('widget', objective, requirements);
914
- }
915
-
916
- // Flow keywords
917
- if (/flow|workflow|process|approval|automation/.test(objective)) {
918
- this.addRequirementIfMissing('flow', objective, requirements);
919
- }
920
-
921
- // Table keywords
922
- if (/table|record|data|store|database/.test(objective)) {
923
- this.addRequirementIfMissing('table', objective, requirements);
924
- }
925
-
926
- // Security keywords
927
- if (/security|permission|access|role|auth/.test(objective)) {
928
- this.addRequirementIfMissing('user_role', objective, requirements);
929
- this.addRequirementIfMissing('acl_rule', objective, requirements);
930
- }
931
-
932
- // Email keywords
933
- if (/email|notification|alert|notify/.test(objective)) {
934
- this.addRequirementIfMissing('email_template', objective, requirements);
935
- this.addRequirementIfMissing('notification', objective, requirements);
936
- }
937
- }
938
-
939
- private static addRequirementIfMissing(
940
- type: RequirementType,
941
- objective: string,
942
- requirements: ServiceNowRequirement[]
943
- ): void {
944
- if (!requirements.find(r => r.type === type)) {
945
- const requirement = this.createRequirement(type, objective);
946
- if (requirement) {
947
- requirements.push(requirement);
948
- }
949
- }
950
- }
951
-
952
- private static addImpliedRequirements(requirements: ServiceNowRequirement[]): void {
953
- const typesPresent = new Set(requirements.map(r => r.type));
954
-
955
- // If we have flows, we probably need notifications
956
- if (typesPresent.has('flow') && !typesPresent.has('notification')) {
957
- const notification = this.createRequirement('notification', 'flow notification');
958
- if (notification) requirements.push(notification);
959
- }
960
-
961
- // If we have tables, we probably need some basic security
962
- if (typesPresent.has('table') && !typesPresent.has('acl_rule')) {
963
- const acl = this.createRequirement('acl_rule', 'table security');
964
- if (acl) requirements.push(acl);
965
- }
966
-
967
- // If we have widgets, we might need portal configuration
968
- if (typesPresent.has('widget') && !typesPresent.has('service_portal_config')) {
969
- const portalConfig = this.createRequirement('service_portal_config', 'widget portal setup');
970
- if (portalConfig) requirements.push(portalConfig);
971
- }
972
- }
973
-
974
- private static generateRequirementName(type: RequirementType, objective: string): string {
975
- const words = objective.toLowerCase().replace(/[^a-z\s]/g, '').split(/\s+/);
976
- const relevantWords = words.filter(w => w.length > 3).slice(0, 3);
977
- const prefix = relevantWords.join(' ') || 'custom';
978
-
979
- return `${prefix} ${type.replace(/_/g, ' ')}`;
980
- }
981
-
982
- private static calculatePriority(type: RequirementType, objective: string): 'high' | 'medium' | 'low' {
983
- const definition = this.REQUIREMENT_DEFINITIONS[type];
984
-
985
- // High priority for core functionality and security
986
- if (['table', 'acl_rule', 'user_role', 'security_policy'].includes(type)) {
987
- return 'high';
988
- }
989
-
990
- // High priority if mentioned directly in objective
991
- if (objective.toLowerCase().includes(type.replace(/_/g, ' '))) {
992
- return 'high';
993
- }
994
-
995
- // Medium priority for automation and integration
996
- if (['flow', 'workflow', 'business_rule'].includes(type)) {
997
- return 'medium';
998
- }
999
-
1000
- return definition.riskLevel === 'high' ? 'medium' : 'low';
1001
- }
1002
-
1003
- private static generateSpecificSteps(type: RequirementType, objective: string): string[] {
1004
- // Generate specific implementation steps based on requirement type
1005
- const steps: string[] = [];
1006
-
1007
- switch (type) {
1008
- case 'email_template':
1009
- steps.push(
1010
- 'Navigate to System Notification > Email > Templates',
1011
- 'Create new email template with subject and body',
1012
- 'Configure template variables and placeholders',
1013
- 'Test template with sample data'
1014
- );
1015
- break;
1016
-
1017
- case 'user_role':
1018
- steps.push(
1019
- 'Navigate to User Administration > Roles',
1020
- 'Create new role with appropriate name',
1021
- 'Add necessary permissions and ACLs',
1022
- 'Assign role to relevant users or groups'
1023
- );
1024
- break;
1025
-
1026
- case 'navigator_module':
1027
- steps.push(
1028
- 'Navigate to System Definition > Application Menus',
1029
- 'Create new module under appropriate application',
1030
- 'Configure table, view, and filter settings',
1031
- 'Set proper role requirements for access'
1032
- );
1033
- break;
1034
-
1035
- default:
1036
- steps.push(`Configure ${type.replace(/_/g, ' ')} according to requirements`);
1037
- }
1038
-
1039
- return steps;
1040
- }
1041
-
1042
- private static generateValidationCriteria(type: RequirementType): string[] {
1043
- const criteria: string[] = [];
1044
-
1045
- switch (type) {
1046
- case 'email_template':
1047
- criteria.push(
1048
- 'Template renders correctly with test data',
1049
- 'All variables are properly substituted',
1050
- 'Email formatting is valid HTML'
1051
- );
1052
- break;
1053
-
1054
- case 'user_role':
1055
- criteria.push(
1056
- 'Role has minimum required permissions',
1057
- 'Role can be assigned to users',
1058
- 'Access controls work as expected'
1059
- );
1060
- break;
1061
-
1062
- default:
1063
- criteria.push(`${type.replace(/_/g, ' ')} functions as intended`);
1064
- }
1065
-
1066
- return criteria;
1067
- }
1068
-
1069
- private static sortRequirements(requirements: ServiceNowRequirement[]): ServiceNowRequirement[] {
1070
- // Sort by: priority (high first), then by dependency order, then by MCP coverage
1071
- return requirements.sort((a, b) => {
1072
- // Priority sorting
1073
- const priorityOrder = { high: 3, medium: 2, low: 1 };
1074
- if (priorityOrder[a.priority] !== priorityOrder[b.priority]) {
1075
- return priorityOrder[b.priority] - priorityOrder[a.priority];
1076
- }
1077
-
1078
- // MCP coverage (covered items first for easier handling)
1079
- if (a.mcpCoverage !== b.mcpCoverage) {
1080
- return a.mcpCoverage ? -1 : 1;
1081
- }
1082
-
1083
- // Risk level (low risk first)
1084
- const riskOrder = { low: 1, medium: 2, high: 3 };
1085
- return riskOrder[a.riskLevel] - riskOrder[b.riskLevel];
1086
- });
1087
- }
1088
-
1089
- private static calculateComplexity(requirements: ServiceNowRequirement[]): 'low' | 'medium' | 'high' | 'enterprise' {
1090
- const totalCount = requirements.length;
1091
- const highEffortCount = requirements.filter(r => r.estimatedEffort === 'high').length;
1092
- const gapCount = requirements.filter(r => !r.mcpCoverage).length;
1093
- const categories = new Set(requirements.map(r => r.category)).size;
1094
-
1095
- if (totalCount > 15 || highEffortCount > 5 || categories > 5) {
1096
- return 'enterprise';
1097
- } else if (totalCount > 10 || gapCount > 5 || categories > 3) {
1098
- return 'high';
1099
- } else if (totalCount > 5 || gapCount > 2) {
1100
- return 'medium';
1101
- } else {
1102
- return 'low';
1103
- }
1104
- }
1105
-
1106
- private static assessRisk(requirements: ServiceNowRequirement[]): 'low' | 'medium' | 'high' {
1107
- const highRiskCount = requirements.filter(r => r.riskLevel === 'high').length;
1108
- const securityCount = requirements.filter(r => r.category === 'security_compliance').length;
1109
- const nonAutomatableCount = requirements.filter(r => !r.automatable).length;
1110
-
1111
- if (highRiskCount > 3 || securityCount > 2 || nonAutomatableCount > 5) {
1112
- return 'high';
1113
- } else if (highRiskCount > 1 || securityCount > 0 || nonAutomatableCount > 2) {
1114
- return 'medium';
1115
- } else {
1116
- return 'low';
1117
- }
1118
- }
1119
-
1120
- private static calculateCriticalPath(requirements: ServiceNowRequirement[]): string[] {
1121
- // Find the sequence of high-priority requirements that are dependencies for others
1122
- const highPriorityReqs = requirements.filter(r => r.priority === 'high');
1123
- const path = highPriorityReqs
1124
- .filter(r => !r.mcpCoverage) // Focus on gaps
1125
- .slice(0, 5) // Top 5 critical items
1126
- .map(r => r.name);
1127
-
1128
- return path;
1129
- }
1130
-
1131
- private static estimateDuration(requirements: ServiceNowRequirement[]): string {
1132
- const effortHours = requirements.reduce((total, req) => {
1133
- const baseHours = req.estimatedEffort === 'high' ? 8 :
1134
- req.estimatedEffort === 'medium' ? 4 : 2;
1135
- // Add complexity for non-MCP items
1136
- const complexity = req.mcpCoverage ? 1 : 2;
1137
- return total + (baseHours * complexity);
1138
- }, 0);
1139
-
1140
- if (effortHours > 80) {
1141
- return `${Math.ceil(effortHours / 40)} weeks`;
1142
- } else if (effortHours > 16) {
1143
- return `${Math.ceil(effortHours / 8)} days`;
1144
- } else {
1145
- return `${effortHours} hours`;
1146
- }
1147
- }
1148
- }