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,488 +0,0 @@
1
- /**
2
- * Intelligent Gap Analysis Engine - The core orchestrator
3
- *
4
- * This is the main engine that orchestrates all components to analyze objectives,
5
- * detect missing ServiceNow configurations beyond MCP tools, and attempt automated
6
- * resolution with fallback to detailed manual instructions.
7
- *
8
- * This fulfills the user's vision: "alle mogelijke soorten handelingen die nodig
9
- * zouden zijn om een objective te bereiken die vallen buiten de standaard mcps"
10
- *
11
- * Usage:
12
- * const engine = new GapAnalysisEngine(mcpTools, logger, autoPermissions);
13
- * const result = await engine.analyzeAndResolve("create incident widget with charts");
14
- */
15
-
16
- import { RequirementsAnalyzer, ServiceNowRequirement, ObjectiveAnalysis } from './requirements-analyzer';
17
- import { McpCoverageAnalyzer, CoverageAnalysis } from './mcp-coverage-analyzer';
18
- import { AutoResolutionEngine, BulkResolutionResult } from './auto-resolution-engine';
19
- import { ManualInstructionsGenerator, BulkManualGuide } from './manual-instructions-generator';
20
-
21
- export interface GapAnalysisResult {
22
- objective: string;
23
- analysisId: string;
24
- timestamp: number;
25
-
26
- // Analysis Results
27
- requirements: ServiceNowRequirement[];
28
- totalRequirements: number;
29
- mcpCoverage: CoverageAnalysis;
30
-
31
- // Resolution Results
32
- automationResults: BulkResolutionResult;
33
- manualGuides: BulkManualGuide | null;
34
-
35
- // Summary
36
- summary: {
37
- totalTime: number;
38
- automationRate: number;
39
- successfulAutomation: number;
40
- requiresManualWork: number;
41
- completionPercentage: number;
42
- };
43
-
44
- // Next Steps
45
- nextSteps: {
46
- automated: string[];
47
- manual: string[];
48
- recommendations: string[];
49
- risks: string[];
50
- };
51
-
52
- // Execution Report
53
- executionPlan: {
54
- phase: string;
55
- description: string;
56
- estimatedTime: string;
57
- status: 'completed' | 'pending' | 'manual_required';
58
- actions: string[];
59
- }[];
60
- }
61
-
62
- export interface GapAnalysisOptions {
63
- autoPermissions?: boolean;
64
- environment?: 'development' | 'testing' | 'production';
65
- enableAutomation?: boolean;
66
- includeManualGuides?: boolean;
67
- riskTolerance?: 'low' | 'medium' | 'high';
68
- dryRun?: boolean;
69
- }
70
-
71
- export class GapAnalysisEngine {
72
- private mcpTools: any;
73
- private logger: any;
74
- private autoResolutionEngine: AutoResolutionEngine;
75
-
76
- constructor(mcpTools: any, logger: any, autoPermissions = false) {
77
- this.mcpTools = mcpTools;
78
- this.logger = logger;
79
- this.autoResolutionEngine = new AutoResolutionEngine(mcpTools, logger, autoPermissions);
80
- }
81
-
82
- /**
83
- * Main entry point - analyze objective and resolve all gaps
84
- */
85
- async analyzeAndResolve(
86
- objective: string,
87
- options: GapAnalysisOptions = {}
88
- ): Promise<GapAnalysisResult> {
89
- const startTime = Date.now();
90
- const analysisId = `gap_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
91
-
92
- this.logger.info(`🧠 Starting Intelligent Gap Analysis for: "${objective}"`);
93
- this.logger.info(`📊 Analysis ID: ${analysisId}`);
94
-
95
- try {
96
- // Step 1: Analyze requirements from natural language objective
97
- this.logger.info('🔍 Step 1: Analyzing requirements...');
98
- const requirementsAnalysis = RequirementsAnalyzer.analyzeObjective(objective);
99
-
100
- if (requirementsAnalysis.requirements.length === 0) {
101
- this.logger.warn('⚠️ No specific ServiceNow requirements detected');
102
- return this.createEmptyResult(objective, analysisId, startTime);
103
- }
104
-
105
- this.logger.info(`📋 Detected ${requirementsAnalysis.requirements.length} requirements`);
106
-
107
- // Step 2: Analyze MCP coverage vs gaps
108
- this.logger.info('🎯 Step 2: Analyzing MCP coverage...');
109
- const mcpCoverage = McpCoverageAnalyzer.analyzeCoverage(requirementsAnalysis.requirements);
110
-
111
- this.logger.info(`✅ MCP Coverage: ${mcpCoverage.coveragePercentage}% (${mcpCoverage.covered.length}/${requirementsAnalysis.requirements.length})`);
112
- this.logger.info(`❌ Gaps requiring attention: ${mcpCoverage.gaps.length}`);
113
- this.logger.info(`⚠️ Partial coverage items: ${mcpCoverage.partialCoverage.length}`);
114
-
115
- // Step 3: Attempt automated resolution for gaps
116
- let automationResults: BulkResolutionResult;
117
- if (options.enableAutomation !== false && !options.dryRun) {
118
- this.logger.info('🤖 Step 3: Attempting automated resolution...');
119
- automationResults = await this.autoResolutionEngine.resolveBulk(mcpCoverage.gaps);
120
-
121
- this.logger.info(`🚀 Automation complete: ${automationResults.successRate}% success rate`);
122
- this.logger.info(`✅ Automated: ${automationResults.successful.length}`);
123
- this.logger.info(`❌ Failed: ${automationResults.failed.length}`);
124
- this.logger.info(`📋 Manual: ${automationResults.manual.length}`);
125
- } else {
126
- // Dry run or automation disabled
127
- automationResults = {
128
- successful: [],
129
- failed: [],
130
- manual: mcpCoverage.gaps.map(req => ({
131
- requirement: req,
132
- status: 'manual_required' as const,
133
- manualSteps: ['Automation disabled - manual configuration required']
134
- })),
135
- totalTime: 0,
136
- successRate: 0,
137
- recommendations: ['Enable automation to attempt automatic resolution']
138
- };
139
- }
140
-
141
- // Step 4: Generate manual guides for remaining gaps
142
- let manualGuides: BulkManualGuide | null = null;
143
- const manualRequirements = [
144
- ...automationResults.failed.map(r => r.requirement),
145
- ...automationResults.manual.map(r => r.requirement)
146
- ];
147
-
148
- if (manualRequirements.length > 0 && options.includeManualGuides !== false) {
149
- this.logger.info(`📚 Step 4: Generating manual guides for ${manualRequirements.length} items...`);
150
- manualGuides = ManualInstructionsGenerator.generateBulkInstructions(manualRequirements);
151
- }
152
-
153
- // Step 5: Build comprehensive result
154
- const totalTime = Date.now() - startTime;
155
- const result = this.buildGapAnalysisResult(
156
- objective,
157
- analysisId,
158
- startTime,
159
- requirementsAnalysis,
160
- mcpCoverage,
161
- automationResults,
162
- manualGuides,
163
- totalTime
164
- );
165
-
166
- this.logger.info(`🎉 Gap Analysis complete in ${totalTime}ms`);
167
- this.logger.info(`📊 Final Summary:`);
168
- this.logger.info(` • Total Requirements: ${result.totalRequirements}`);
169
- this.logger.info(` • MCP Coverage: ${result.mcpCoverage.coveragePercentage}%`);
170
- this.logger.info(` • Automation Rate: ${result.summary.automationRate}%`);
171
- this.logger.info(` • Manual Work Required: ${result.summary.requiresManualWork} items`);
172
-
173
- return result;
174
-
175
- } catch (error) {
176
- this.logger.error('❌ Gap Analysis failed:', error);
177
- throw new Error(`Gap Analysis failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
178
- }
179
- }
180
-
181
- /**
182
- * Quick _analysis without resolution - useful for planning
183
- */
184
- async analyzeOnly(objective: string): Promise<{
185
- requirements: ServiceNowRequirement[];
186
- coverage: CoverageAnalysis;
187
- canAutomate: number;
188
- requiresManual: number;
189
- estimatedTime: string;
190
- }> {
191
- this.logger.info(`🔍 Quick _analysis for: "${objective}"`);
192
-
193
- const _analysis = RequirementsAnalyzer.analyzeObjective(objective);
194
- const coverage = McpCoverageAnalyzer.analyzeCoverage(_analysis.requirements);
195
-
196
- let canAutomate = coverage.covered.length;
197
- let requiresManual = coverage.gaps.length;
198
-
199
- // Check automation capabilities for gaps
200
- for (const gap of coverage.gaps) {
201
- if (this.autoResolutionEngine.canAutoResolve(gap)) {
202
- canAutomate++;
203
- requiresManual--;
204
- }
205
- }
206
-
207
- const estimatedTime = this.estimateTotalTime(_analysis.requirements, canAutomate, requiresManual);
208
-
209
- return {
210
- requirements: _analysis.requirements,
211
- coverage,
212
- canAutomate,
213
- requiresManual,
214
- estimatedTime
215
- };
216
- }
217
-
218
- /**
219
- * Get detailed _analysis for a specific requirement type
220
- */
221
- analyzeRequirementType(requirementType: string): {
222
- mcpTools: string[];
223
- automationStrategies: string[];
224
- manualSteps: string[];
225
- riskLevel: string;
226
- } {
227
- const mcpTools = McpCoverageAnalyzer.getAvailableTools(requirementType as any);
228
- const automationStrategies = this.autoResolutionEngine.getResolutionStrategies(requirementType as any);
229
-
230
- return {
231
- mcpTools: mcpTools.map(tool => tool.tool),
232
- automationStrategies: automationStrategies.map(strategy => strategy.automationMethod),
233
- manualSteps: automationStrategies.flatMap(strategy => strategy.fallbackInstructions),
234
- riskLevel: automationStrategies[0]?.riskLevel || 'medium'
235
- };
236
- }
237
-
238
- // Private helper methods
239
-
240
- private createEmptyResult(objective: string, analysisId: string, startTime: number): GapAnalysisResult {
241
- return {
242
- objective,
243
- analysisId,
244
- timestamp: startTime,
245
- requirements: [],
246
- totalRequirements: 0,
247
- mcpCoverage: {
248
- covered: [],
249
- gaps: [],
250
- partialCoverage: [],
251
- coveragePercentage: 100,
252
- recommendations: ['No specific ServiceNow requirements detected in objective']
253
- },
254
- automationResults: {
255
- successful: [],
256
- failed: [],
257
- manual: [],
258
- totalTime: 0,
259
- successRate: 100,
260
- recommendations: ['Consider more specific ServiceNow requirements']
261
- },
262
- manualGuides: null,
263
- summary: {
264
- totalTime: Date.now() - startTime,
265
- automationRate: 100,
266
- successfulAutomation: 0,
267
- requiresManualWork: 0,
268
- completionPercentage: 100
269
- },
270
- nextSteps: {
271
- automated: [],
272
- manual: ['Refine objective with specific ServiceNow requirements'],
273
- recommendations: ['Use more specific ServiceNow terminology in objective'],
274
- risks: []
275
- },
276
- executionPlan: []
277
- };
278
- }
279
-
280
- private buildGapAnalysisResult(
281
- objective: string,
282
- analysisId: string,
283
- startTime: number,
284
- requirementsAnalysis: ObjectiveAnalysis,
285
- mcpCoverage: CoverageAnalysis,
286
- automationResults: BulkResolutionResult,
287
- manualGuides: BulkManualGuide | null,
288
- totalTime: number
289
- ): GapAnalysisResult {
290
-
291
- const totalRequirements = requirementsAnalysis.requirements.length;
292
- const automationRate = totalRequirements > 0
293
- ? Math.round(((automationResults.successful.length) / totalRequirements) * 100)
294
- : 100;
295
-
296
- const completionPercentage = totalRequirements > 0
297
- ? Math.round(((mcpCoverage.covered.length + automationResults.successful.length) / totalRequirements) * 100)
298
- : 100;
299
-
300
- return {
301
- objective,
302
- analysisId,
303
- timestamp: startTime,
304
- requirements: requirementsAnalysis.requirements,
305
- totalRequirements,
306
- mcpCoverage,
307
- automationResults,
308
- manualGuides,
309
- summary: {
310
- totalTime,
311
- automationRate,
312
- successfulAutomation: automationResults.successful.length,
313
- requiresManualWork: automationResults.failed.length + automationResults.manual.length,
314
- completionPercentage
315
- },
316
- nextSteps: this.generateNextSteps(mcpCoverage, automationResults, manualGuides),
317
- executionPlan: this.generateExecutionPlan(mcpCoverage, automationResults, manualGuides)
318
- };
319
- }
320
-
321
- private generateNextSteps(
322
- mcpCoverage: CoverageAnalysis,
323
- automationResults: BulkResolutionResult,
324
- manualGuides: BulkManualGuide | null
325
- ): GapAnalysisResult['nextSteps'] {
326
- const automated: string[] = [];
327
- const manual: string[] = [];
328
- const recommendations: string[] = [];
329
- const risks: string[] = [];
330
-
331
- // MCP-covered items
332
- if (mcpCoverage.covered.length > 0) {
333
- automated.push(`✅ ${mcpCoverage.covered.length} items fully covered by MCP tools`);
334
- }
335
-
336
- // Successfully automated items
337
- if (automationResults.successful.length > 0) {
338
- automated.push(`🤖 ${automationResults.successful.length} gaps automatically resolved`);
339
- }
340
-
341
- // Failed automation items
342
- if (automationResults.failed.length > 0) {
343
- manual.push(`❌ ${automationResults.failed.length} automation attempts failed - manual setup required`);
344
- recommendations.push('Review failed automation attempts and adjust permissions or configurations');
345
- }
346
-
347
- // Manual-only items
348
- if (automationResults.manual.length > 0) {
349
- manual.push(`📋 ${automationResults.manual.length} items require manual configuration`);
350
- }
351
-
352
- // Manual guides available
353
- if (manualGuides) {
354
- manual.push(`📚 Detailed manual guides available for ${manualGuides.guides.length} configurations`);
355
- }
356
-
357
- // Recommendations from sub-systems
358
- recommendations.push(...mcpCoverage.recommendations);
359
- recommendations.push(...automationResults.recommendations);
360
-
361
- // Risk identification
362
- if (manualGuides?.overallRisks) {
363
- risks.push(...manualGuides.overallRisks);
364
- }
365
-
366
- // Add strategic recommendations
367
- const automationRate = automationResults.successful.length /
368
- (automationResults.successful.length + automationResults.failed.length + automationResults.manual.length);
369
-
370
- if (automationRate < 0.5) {
371
- recommendations.push('💡 Consider enabling auto-permissions to increase automation success rate');
372
- }
373
-
374
- if (manual.length > automated.length) {
375
- recommendations.push('🔧 Significant manual work required - consider phased implementation approach');
376
- }
377
-
378
- return { automated, manual, recommendations, risks };
379
- }
380
-
381
- private generateExecutionPlan(
382
- mcpCoverage: CoverageAnalysis,
383
- automationResults: BulkResolutionResult,
384
- manualGuides: BulkManualGuide | null
385
- ): GapAnalysisResult['executionPlan'] {
386
- const plan: GapAnalysisResult['executionPlan'] = [];
387
-
388
- // Phase 1: MCP Tool Deployment
389
- if (mcpCoverage.covered.length > 0) {
390
- plan.push({
391
- phase: 'Phase 1: MCP Tool Deployment',
392
- description: 'Deploy artifacts using standard MCP tools',
393
- estimatedTime: `${mcpCoverage.covered.length * 3} minutes`,
394
- status: 'pending',
395
- actions: mcpCoverage.covered.map(req => `Deploy ${req.type}: ${req.name}`)
396
- });
397
- }
398
-
399
- // Phase 2: Automated Gap Resolution
400
- if (automationResults.successful.length > 0) {
401
- plan.push({
402
- phase: 'Phase 2: Automated Gap Resolution',
403
- description: 'Automatically resolve configuration gaps',
404
- estimatedTime: `${automationResults.totalTime}ms`,
405
- status: 'completed',
406
- actions: automationResults.successful.map(res =>
407
- `✅ Automated: ${res.requirement.type} - ${res.requirement.name}`
408
- )
409
- });
410
- }
411
-
412
- // Phase 3: Manual Configuration
413
- const manualItems = automationResults.failed.length + automationResults.manual.length;
414
- if (manualItems > 0) {
415
- plan.push({
416
- phase: 'Phase 3: Manual Configuration',
417
- description: 'Complete remaining configurations manually',
418
- estimatedTime: manualGuides?.executionOrder.reduce((total, phase) =>
419
- total + parseInt(phase.estimatedTime.match(/\d+/)?.[0] || '10'), 0
420
- ) + ' minutes' || `${manualItems * 15} minutes`,
421
- status: 'manual_required',
422
- actions: [
423
- ...automationResults.failed.map(res => `❌ Manual fix needed: ${res.requirement.name}`),
424
- ...automationResults.manual.map(res => `📋 Manual setup: ${res.requirement.name}`)
425
- ]
426
- });
427
- }
428
-
429
- return plan;
430
- }
431
-
432
- private estimateTotalTime(
433
- requirements: ServiceNowRequirement[],
434
- canAutomate: number,
435
- requiresManual: number
436
- ): string {
437
- const automationTime = canAutomate * 2; // 2 minutes per automated item
438
- const manualTime = requiresManual * 15; // 15 minutes per manual item
439
- const totalMinutes = automationTime + manualTime;
440
-
441
- if (totalMinutes < 60) {
442
- return `${totalMinutes} minutes`;
443
- } else {
444
- const hours = Math.floor(totalMinutes / 60);
445
- const minutes = totalMinutes % 60;
446
- return `${hours}h ${minutes}m`;
447
- }
448
- }
449
- }
450
-
451
- /**
452
- * Convenience function for quick gap analysis
453
- */
454
- export async function analyzeGaps(
455
- objective: string,
456
- mcpTools: any,
457
- logger: any,
458
- options: GapAnalysisOptions = {}
459
- ): Promise<GapAnalysisResult> {
460
- const engine = new GapAnalysisEngine(mcpTools, logger, options.autoPermissions);
461
- return engine.analyzeAndResolve(objective, options);
462
- }
463
-
464
- /**
465
- * Quick _analysis without resolution
466
- */
467
- export function quickAnalyze(objective: string): {
468
- requirements: ServiceNowRequirement[];
469
- coverage: CoverageAnalysis;
470
- estimatedComplexity: 'simple' | 'moderate' | 'complex';
471
- } {
472
- const _analysis = RequirementsAnalyzer.analyzeObjective(objective);
473
- const coverage = McpCoverageAnalyzer.analyzeCoverage(_analysis.requirements);
474
-
475
- let estimatedComplexity: 'simple' | 'moderate' | 'complex' = 'simple';
476
-
477
- if (_analysis.requirements.length > 10 || coverage.coveragePercentage < 50) {
478
- estimatedComplexity = 'complex';
479
- } else if (_analysis.requirements.length > 5 || coverage.coveragePercentage < 80) {
480
- estimatedComplexity = 'moderate';
481
- }
482
-
483
- return {
484
- requirements: _analysis.requirements,
485
- coverage,
486
- estimatedComplexity
487
- };
488
- }