snow-flow 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.claude/mcp-config.json → .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- 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
|
-
}
|