mcp-adr-analysis-server 2.0.21 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -839
- package/dist/.tsbuildinfo +1 -1
- package/dist/src/config/ai-config.d.ts.map +1 -1
- package/dist/src/config/ai-config.js +9 -9
- package/dist/src/config/ai-config.js.map +1 -1
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1594 -837
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompts/analysis-prompts.d.ts +4 -1
- package/dist/src/prompts/analysis-prompts.d.ts.map +1 -1
- package/dist/src/prompts/analysis-prompts.js +61 -30
- package/dist/src/prompts/analysis-prompts.js.map +1 -1
- package/dist/src/prompts/index.d.ts +17 -1
- package/dist/src/prompts/index.d.ts.map +1 -1
- package/dist/src/prompts/index.js +325 -1
- package/dist/src/prompts/index.js.map +1 -1
- package/dist/src/prompts/rule-generation-prompts.d.ts +5 -1
- package/dist/src/prompts/rule-generation-prompts.d.ts.map +1 -1
- package/dist/src/prompts/rule-generation-prompts.js +5 -1
- package/dist/src/prompts/rule-generation-prompts.js.map +1 -1
- package/dist/src/prompts/security-prompts.d.ts +6 -1
- package/dist/src/prompts/security-prompts.d.ts.map +1 -1
- package/dist/src/prompts/security-prompts.js +6 -1
- package/dist/src/prompts/security-prompts.js.map +1 -1
- package/dist/src/prompts/todo-prompts.d.ts +49 -0
- package/dist/src/prompts/todo-prompts.d.ts.map +1 -0
- package/dist/src/prompts/todo-prompts.js +824 -0
- package/dist/src/prompts/todo-prompts.js.map +1 -0
- package/dist/src/resources/index.d.ts.map +1 -1
- package/dist/src/resources/index.js +9 -7
- package/dist/src/resources/index.js.map +1 -1
- package/dist/src/tools/adr-bootstrap-validation-tool.d.ts +47 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.d.ts.map +1 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.js +979 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.js.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
- package/dist/src/tools/adr-suggestion-tool.js +330 -32
- package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
- package/dist/src/tools/content-masking-tool.d.ts +5 -0
- package/dist/src/tools/content-masking-tool.d.ts.map +1 -1
- package/dist/src/tools/content-masking-tool.js +631 -28
- package/dist/src/tools/content-masking-tool.js.map +1 -1
- package/dist/src/tools/deployment-readiness-tool.d.ts +8 -5
- package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
- package/dist/src/tools/deployment-readiness-tool.js +1017 -93
- package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
- package/dist/src/tools/environment-analysis-tool.d.ts +4 -0
- package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -1
- package/dist/src/tools/environment-analysis-tool.js +568 -24
- package/dist/src/tools/environment-analysis-tool.js.map +1 -1
- package/dist/src/tools/interactive-adr-planning-tool.d.ts.map +1 -1
- package/dist/src/tools/interactive-adr-planning-tool.js +270 -108
- package/dist/src/tools/interactive-adr-planning-tool.js.map +1 -1
- package/dist/src/tools/mcp-planning-tool.d.ts.map +1 -1
- package/dist/src/tools/mcp-planning-tool.js +316 -183
- package/dist/src/tools/mcp-planning-tool.js.map +1 -1
- package/dist/src/tools/memory-loading-tool.d.ts +60 -0
- package/dist/src/tools/memory-loading-tool.d.ts.map +1 -0
- package/dist/src/tools/memory-loading-tool.js +457 -0
- package/dist/src/tools/memory-loading-tool.js.map +1 -0
- package/dist/src/tools/research-integration-tool.d.ts +4 -1
- package/dist/src/tools/research-integration-tool.d.ts.map +1 -1
- package/dist/src/tools/research-integration-tool.js +5 -1
- package/dist/src/tools/research-integration-tool.js.map +1 -1
- package/dist/src/tools/review-existing-adrs-tool.d.ts +19 -0
- package/dist/src/tools/review-existing-adrs-tool.d.ts.map +1 -0
- package/dist/src/tools/review-existing-adrs-tool.js +1204 -0
- package/dist/src/tools/review-existing-adrs-tool.js.map +1 -0
- package/dist/src/tools/rule-generation-tool.d.ts +2 -0
- package/dist/src/tools/rule-generation-tool.d.ts.map +1 -1
- package/dist/src/tools/rule-generation-tool.js +274 -33
- package/dist/src/tools/rule-generation-tool.js.map +1 -1
- package/dist/src/tools/smart-git-push-tool-v2.d.ts +4 -0
- package/dist/src/tools/smart-git-push-tool-v2.d.ts.map +1 -1
- package/dist/src/tools/smart-git-push-tool-v2.js +423 -229
- package/dist/src/tools/smart-git-push-tool-v2.js.map +1 -1
- package/dist/src/tools/smart-git-push-tool.d.ts +3 -0
- package/dist/src/tools/smart-git-push-tool.d.ts.map +1 -1
- package/dist/src/tools/smart-git-push-tool.js +241 -235
- package/dist/src/tools/smart-git-push-tool.js.map +1 -1
- package/dist/src/tools/tool-chain-orchestrator.d.ts +2 -2
- package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
- package/dist/src/tools/tool-chain-orchestrator.js +152 -93
- package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
- package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +22 -13
- package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
- package/dist/src/tools/troubleshoot-guided-workflow-tool.js +660 -28
- package/dist/src/tools/troubleshoot-guided-workflow-tool.js.map +1 -1
- package/dist/src/types/ape-framework.d.ts +93 -0
- package/dist/src/types/ape-framework.d.ts.map +1 -1
- package/dist/src/types/ape-framework.js +10 -10
- package/dist/src/types/ape-framework.js.map +1 -1
- package/dist/src/types/enhanced-errors.d.ts +173 -0
- package/dist/src/types/enhanced-errors.d.ts.map +1 -0
- package/dist/src/types/enhanced-errors.js +668 -0
- package/dist/src/types/enhanced-errors.js.map +1 -0
- package/dist/src/types/index.d.ts +129 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +15 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/knowledge-generation.d.ts +78 -0
- package/dist/src/types/knowledge-generation.d.ts.map +1 -1
- package/dist/src/types/knowledge-generation.js +10 -6
- package/dist/src/types/knowledge-generation.js.map +1 -1
- package/dist/src/types/knowledge-graph-schemas.d.ts +92 -0
- package/dist/src/types/knowledge-graph-schemas.d.ts.map +1 -1
- package/dist/src/types/knowledge-graph-schemas.js +45 -17
- package/dist/src/types/knowledge-graph-schemas.js.map +1 -1
- package/dist/src/types/memory-entities.d.ts +7209 -0
- package/dist/src/types/memory-entities.d.ts.map +1 -0
- package/dist/src/types/memory-entities.js +395 -0
- package/dist/src/types/memory-entities.js.map +1 -0
- package/dist/src/types/reflexion-framework.d.ts +44 -0
- package/dist/src/types/reflexion-framework.d.ts.map +1 -1
- package/dist/src/types/reflexion-framework.js +7 -7
- package/dist/src/types/reflexion-framework.js.map +1 -1
- package/dist/src/types/todo-json-schemas.d.ts +7 -653
- package/dist/src/types/todo-json-schemas.d.ts.map +1 -1
- package/dist/src/types/todo-json-schemas.js +6 -110
- package/dist/src/types/todo-json-schemas.js.map +1 -1
- package/dist/src/types/tool-arguments.d.ts +224 -0
- package/dist/src/types/tool-arguments.d.ts.map +1 -0
- package/dist/src/types/tool-arguments.js +6 -0
- package/dist/src/types/tool-arguments.js.map +1 -0
- package/dist/src/utils/actual-file-operations.d.ts.map +1 -1
- package/dist/src/utils/actual-file-operations.js +25 -9
- package/dist/src/utils/actual-file-operations.js.map +1 -1
- package/dist/src/utils/adr-discovery.d.ts +33 -1
- package/dist/src/utils/adr-discovery.d.ts.map +1 -1
- package/dist/src/utils/adr-discovery.js +14 -9
- package/dist/src/utils/adr-discovery.js.map +1 -1
- package/dist/src/utils/adr-suggestions.d.ts +72 -0
- package/dist/src/utils/adr-suggestions.d.ts.map +1 -1
- package/dist/src/utils/adr-suggestions.js +6 -0
- package/dist/src/utils/adr-suggestions.js.map +1 -1
- package/dist/src/utils/cache.d.ts.map +1 -1
- package/dist/src/utils/cache.js +22 -19
- package/dist/src/utils/cache.js.map +1 -1
- package/dist/src/utils/chain-of-thought-template.d.ts +13 -1
- package/dist/src/utils/chain-of-thought-template.d.ts.map +1 -1
- package/dist/src/utils/chain-of-thought-template.js +31 -22
- package/dist/src/utils/chain-of-thought-template.js.map +1 -1
- package/dist/src/utils/config.d.ts.map +1 -1
- package/dist/src/utils/config.js +1 -0
- package/dist/src/utils/config.js.map +1 -1
- package/dist/src/utils/directory-compat.js +1 -1
- package/dist/src/utils/directory-compat.js.map +1 -1
- package/dist/src/utils/enhanced-logging.d.ts +195 -0
- package/dist/src/utils/enhanced-logging.d.ts.map +1 -0
- package/dist/src/utils/enhanced-logging.js +449 -0
- package/dist/src/utils/enhanced-logging.js.map +1 -0
- package/dist/src/utils/file-system.d.ts +182 -34
- package/dist/src/utils/file-system.d.ts.map +1 -1
- package/dist/src/utils/file-system.js +648 -774
- package/dist/src/utils/file-system.js.map +1 -1
- package/dist/src/utils/gitleaks-detector.d.ts +50 -0
- package/dist/src/utils/gitleaks-detector.d.ts.map +1 -0
- package/dist/src/utils/gitleaks-detector.js +334 -0
- package/dist/src/utils/gitleaks-detector.js.map +1 -0
- package/dist/src/utils/interactive-approval.d.ts +1 -1
- package/dist/src/utils/interactive-approval.d.ts.map +1 -1
- package/dist/src/utils/interactive-approval.js +22 -17
- package/dist/src/utils/interactive-approval.js.map +1 -1
- package/dist/src/utils/json-safe.d.ts.map +1 -1
- package/dist/src/utils/json-safe.js +9 -6
- package/dist/src/utils/json-safe.js.map +1 -1
- package/dist/src/utils/knowledge-graph-manager.d.ts +37 -1
- package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
- package/dist/src/utils/knowledge-graph-manager.js +315 -70
- package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
- package/dist/src/utils/location-filter.d.ts +35 -10
- package/dist/src/utils/location-filter.d.ts.map +1 -1
- package/dist/src/utils/location-filter.js +360 -94
- package/dist/src/utils/location-filter.js.map +1 -1
- package/dist/src/utils/mcp-response-validator.d.ts.map +1 -1
- package/dist/src/utils/mcp-response-validator.js +34 -19
- package/dist/src/utils/mcp-response-validator.js.map +1 -1
- package/dist/src/utils/memory-entity-manager.d.ts +134 -0
- package/dist/src/utils/memory-entity-manager.d.ts.map +1 -0
- package/dist/src/utils/memory-entity-manager.js +851 -0
- package/dist/src/utils/memory-entity-manager.js.map +1 -0
- package/dist/src/utils/memory-health-scoring.d.ts +125 -0
- package/dist/src/utils/memory-health-scoring.d.ts.map +1 -0
- package/dist/src/utils/memory-health-scoring.js +277 -0
- package/dist/src/utils/memory-health-scoring.js.map +1 -0
- package/dist/src/utils/memory-migration-manager.d.ts +93 -0
- package/dist/src/utils/memory-migration-manager.d.ts.map +1 -0
- package/dist/src/utils/memory-migration-manager.js +842 -0
- package/dist/src/utils/memory-migration-manager.js.map +1 -0
- package/dist/src/utils/memory-relationship-mapper.d.ts +87 -0
- package/dist/src/utils/memory-relationship-mapper.d.ts.map +1 -0
- package/dist/src/utils/memory-relationship-mapper.js +482 -0
- package/dist/src/utils/memory-relationship-mapper.js.map +1 -0
- package/dist/src/utils/memory-rollback-manager.d.ts +105 -0
- package/dist/src/utils/memory-rollback-manager.d.ts.map +1 -0
- package/dist/src/utils/memory-rollback-manager.js +575 -0
- package/dist/src/utils/memory-rollback-manager.js.map +1 -0
- package/dist/src/utils/memory-transformation.d.ts +59 -0
- package/dist/src/utils/memory-transformation.d.ts.map +1 -0
- package/dist/src/utils/memory-transformation.js +742 -0
- package/dist/src/utils/memory-transformation.js.map +1 -0
- package/dist/src/utils/output-masking.d.ts +12 -0
- package/dist/src/utils/output-masking.d.ts.map +1 -1
- package/dist/src/utils/output-masking.js +5 -0
- package/dist/src/utils/output-masking.js.map +1 -1
- package/dist/src/utils/prompt-execution.d.ts.map +1 -1
- package/dist/src/utils/prompt-execution.js +72 -51
- package/dist/src/utils/prompt-execution.js.map +1 -1
- package/dist/src/utils/release-readiness-detector.d.ts.map +1 -1
- package/dist/src/utils/release-readiness-detector.js +43 -42
- package/dist/src/utils/release-readiness-detector.js.map +1 -1
- package/dist/src/utils/research-integration.d.ts.map +1 -1
- package/dist/src/utils/research-integration.js +73 -44
- package/dist/src/utils/research-integration.js.map +1 -1
- package/dist/src/utils/research-questions.d.ts.map +1 -1
- package/dist/src/utils/research-questions.js +40 -14
- package/dist/src/utils/research-questions.js.map +1 -1
- package/dist/src/utils/ripgrep-wrapper.d.ts +84 -0
- package/dist/src/utils/ripgrep-wrapper.d.ts.map +1 -0
- package/dist/src/utils/ripgrep-wrapper.js +255 -0
- package/dist/src/utils/ripgrep-wrapper.js.map +1 -0
- package/dist/src/utils/rule-generation.d.ts.map +1 -1
- package/dist/src/utils/rule-generation.js +26 -15
- package/dist/src/utils/rule-generation.js.map +1 -1
- package/dist/src/utils/todo-file-watcher.d.ts +11 -23
- package/dist/src/utils/todo-file-watcher.d.ts.map +1 -1
- package/dist/src/utils/todo-file-watcher.js +18 -156
- package/dist/src/utils/todo-file-watcher.js.map +1 -1
- package/dist/src/utils/tree-sitter-analyzer.d.ts +185 -0
- package/dist/src/utils/tree-sitter-analyzer.d.ts.map +1 -0
- package/dist/src/utils/tree-sitter-analyzer.js +885 -0
- package/dist/src/utils/tree-sitter-analyzer.js.map +1 -0
- package/package.json +51 -10
- package/dist/src/tools/smart-score-tool.d.ts +0 -173
- package/dist/src/tools/smart-score-tool.d.ts.map +0 -1
- package/dist/src/tools/smart-score-tool.js +0 -681
- package/dist/src/tools/smart-score-tool.js.map +0 -1
- package/dist/src/tools/todo-management-tool-v2.d.ts +0 -368
- package/dist/src/tools/todo-management-tool-v2.d.ts.map +0 -1
- package/dist/src/tools/todo-management-tool-v2.js +0 -922
- package/dist/src/tools/todo-management-tool-v2.js.map +0 -1
- package/dist/src/utils/enhanced-sensitive-detector.d.ts +0 -61
- package/dist/src/utils/enhanced-sensitive-detector.d.ts.map +0 -1
- package/dist/src/utils/enhanced-sensitive-detector.js +0 -437
- package/dist/src/utils/enhanced-sensitive-detector.js.map +0 -1
- package/dist/src/utils/project-health-scoring.d.ts +0 -177
- package/dist/src/utils/project-health-scoring.d.ts.map +0 -1
- package/dist/src/utils/project-health-scoring.js +0 -370
- package/dist/src/utils/project-health-scoring.js.map +0 -1
- package/dist/src/utils/todo-json-manager.d.ts +0 -71
- package/dist/src/utils/todo-json-manager.d.ts.map +0 -1
- package/dist/src/utils/todo-json-manager.js +0 -396
- package/dist/src/utils/todo-json-manager.js.map +0 -1
- package/dist/src/utils/todo-markdown-converter.d.ts +0 -16
- package/dist/src/utils/todo-markdown-converter.d.ts.map +0 -1
- package/dist/src/utils/todo-markdown-converter.js +0 -362
- package/dist/src/utils/todo-markdown-converter.js.map +0 -1
- package/dist/src/utils/todo-migration.d.ts +0 -47
- package/dist/src/utils/todo-migration.d.ts.map +0 -1
- package/dist/src/utils/todo-migration.js +0 -261
- package/dist/src/utils/todo-migration.js.map +0 -1
|
@@ -2,16 +2,375 @@
|
|
|
2
2
|
* MCP Tool for environment context analysis
|
|
3
3
|
* Implements prompt-driven environment analysis and compliance assessment
|
|
4
4
|
* Enhanced with Generated Knowledge Prompting (GKP) for DevOps and infrastructure expertise
|
|
5
|
+
* Now includes memory integration for environment snapshot tracking and evolution analysis
|
|
5
6
|
*/
|
|
6
7
|
import { McpAdrError } from '../types/index.js';
|
|
8
|
+
import { MemoryEntityManager } from '../utils/memory-entity-manager.js';
|
|
9
|
+
import { EnhancedLogger } from '../utils/enhanced-logging.js';
|
|
10
|
+
/**
|
|
11
|
+
* Environment Memory Manager for tracking environment snapshots and evolution
|
|
12
|
+
*/
|
|
13
|
+
class EnvironmentMemoryManager {
|
|
14
|
+
memoryManager;
|
|
15
|
+
logger;
|
|
16
|
+
constructor() {
|
|
17
|
+
this.memoryManager = new MemoryEntityManager();
|
|
18
|
+
this.logger = new EnhancedLogger();
|
|
19
|
+
}
|
|
20
|
+
async initialize() {
|
|
21
|
+
await this.memoryManager.initialize();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Store environment snapshot as memory entity
|
|
25
|
+
*/
|
|
26
|
+
async storeEnvironmentSnapshot(environmentType, configuration, complianceData, projectPath) {
|
|
27
|
+
try {
|
|
28
|
+
const environmentData = {
|
|
29
|
+
environmentType: environmentType,
|
|
30
|
+
configuration: {
|
|
31
|
+
infrastructure: configuration.infrastructure || {},
|
|
32
|
+
containerization: configuration.containerization || {},
|
|
33
|
+
cloudServices: configuration.cloudServices || {},
|
|
34
|
+
networking: configuration.networking || {},
|
|
35
|
+
storage: configuration.storage || {},
|
|
36
|
+
security: configuration.security || {},
|
|
37
|
+
monitoring: configuration.monitoring || {},
|
|
38
|
+
deployment: configuration.deployment || {},
|
|
39
|
+
},
|
|
40
|
+
complianceStatus: {
|
|
41
|
+
performanceMetrics: complianceData?.performanceMetrics || {},
|
|
42
|
+
securityPosture: complianceData?.securityPosture || 0,
|
|
43
|
+
adrAlignment: complianceData?.adrAlignment || 0,
|
|
44
|
+
lastValidation: new Date().toISOString(),
|
|
45
|
+
complianceIssues: complianceData?.violations?.map((v) => v.description) || [],
|
|
46
|
+
},
|
|
47
|
+
infrastructureSpecs: {
|
|
48
|
+
dependencies: configuration.dependencies || [],
|
|
49
|
+
containerization: configuration.containerization || {},
|
|
50
|
+
resourceLimits: configuration.resourceLimits || {},
|
|
51
|
+
networkConfiguration: configuration.networking || {},
|
|
52
|
+
storageConfiguration: configuration.storage || {},
|
|
53
|
+
},
|
|
54
|
+
changeHistory: [
|
|
55
|
+
{
|
|
56
|
+
timestamp: new Date().toISOString(),
|
|
57
|
+
changeType: 'configuration',
|
|
58
|
+
description: `Environment snapshot created for ${environmentType}`,
|
|
59
|
+
impact: 'medium',
|
|
60
|
+
author: 'environment-analysis-tool',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
recommendations: configuration.recommendations || [],
|
|
64
|
+
qualityAttributes: configuration.qualityAttributes || {},
|
|
65
|
+
riskAssessment: configuration.riskAssessment || {},
|
|
66
|
+
optimizationOpportunities: this.identifyOptimizationOpportunities(configuration),
|
|
67
|
+
complianceGaps: complianceData?.violations?.map((v) => ({
|
|
68
|
+
requirement: v.requirement,
|
|
69
|
+
gap: v.description,
|
|
70
|
+
severity: v.severity || 'medium',
|
|
71
|
+
remediation: v.remediation,
|
|
72
|
+
})) || [],
|
|
73
|
+
};
|
|
74
|
+
const entity = await this.memoryManager.upsertEntity({
|
|
75
|
+
type: 'environment_snapshot',
|
|
76
|
+
title: `Environment Snapshot: ${environmentType} - ${new Date().toISOString().split('T')[0]}`,
|
|
77
|
+
description: `Comprehensive environment analysis snapshot for ${environmentType} environment`,
|
|
78
|
+
tags: [
|
|
79
|
+
'environment',
|
|
80
|
+
environmentType.toLowerCase(),
|
|
81
|
+
'infrastructure',
|
|
82
|
+
complianceData ? 'compliance-assessed' : 'configuration-only',
|
|
83
|
+
...(configuration.containerization?.detected ? ['containerized'] : []),
|
|
84
|
+
...(configuration.cloudServices?.providers?.length > 0 ? ['cloud-native'] : []),
|
|
85
|
+
],
|
|
86
|
+
environmentData,
|
|
87
|
+
relationships: [],
|
|
88
|
+
context: {
|
|
89
|
+
projectPhase: 'environment-analysis',
|
|
90
|
+
technicalStack: this.extractTechnicalStack(configuration),
|
|
91
|
+
environmentalFactors: [environmentType, projectPath || 'unknown-project'].filter(Boolean),
|
|
92
|
+
stakeholders: ['infrastructure-team', 'devops-team', 'security-team'],
|
|
93
|
+
},
|
|
94
|
+
accessPattern: {
|
|
95
|
+
lastAccessed: new Date().toISOString(),
|
|
96
|
+
accessCount: 1,
|
|
97
|
+
accessContext: ['environment-analysis'],
|
|
98
|
+
},
|
|
99
|
+
evolution: {
|
|
100
|
+
origin: 'created',
|
|
101
|
+
transformations: [
|
|
102
|
+
{
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
type: 'snapshot_creation',
|
|
105
|
+
description: `Environment snapshot created for ${environmentType}`,
|
|
106
|
+
agent: 'environment-analysis-tool',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
validation: {
|
|
111
|
+
isVerified: Boolean(complianceData && complianceData.overallScore > 70),
|
|
112
|
+
verificationMethod: complianceData ? 'compliance-assessment' : 'configuration-analysis',
|
|
113
|
+
verificationTimestamp: new Date().toISOString(),
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
this.logger.info(`Environment snapshot stored for ${environmentType}`, 'EnvironmentMemoryManager', {
|
|
117
|
+
environmentType,
|
|
118
|
+
entityId: entity.id,
|
|
119
|
+
complianceScore: complianceData?.overallScore,
|
|
120
|
+
configurationsStored: Object.keys(environmentData.configuration).length,
|
|
121
|
+
});
|
|
122
|
+
return entity.id;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
this.logger.error('Failed to store environment snapshot', 'EnvironmentMemoryManager', error);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Track configuration changes between snapshots
|
|
131
|
+
*/
|
|
132
|
+
async trackConfigurationChange(previousSnapshotId, newSnapshotId, changeDescription, changeDetails) {
|
|
133
|
+
try {
|
|
134
|
+
// Create relationship between snapshots using relationship creation
|
|
135
|
+
await this.memoryManager.upsertRelationship({
|
|
136
|
+
sourceId: previousSnapshotId,
|
|
137
|
+
targetId: newSnapshotId,
|
|
138
|
+
type: 'supersedes',
|
|
139
|
+
strength: 1.0,
|
|
140
|
+
context: changeDescription,
|
|
141
|
+
evidence: [JSON.stringify(changeDetails)],
|
|
142
|
+
});
|
|
143
|
+
this.logger.info('Configuration change relationship created', 'EnvironmentMemoryManager', {
|
|
144
|
+
from: previousSnapshotId,
|
|
145
|
+
to: newSnapshotId,
|
|
146
|
+
change: changeDescription,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
this.logger.error('Failed to track configuration change', 'EnvironmentMemoryManager', error);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Analyze environment evolution over time
|
|
156
|
+
*/
|
|
157
|
+
async analyzeEnvironmentEvolution(environmentType) {
|
|
158
|
+
try {
|
|
159
|
+
const snapshots = await this.memoryManager.queryEntities({
|
|
160
|
+
entityTypes: ['environment_snapshot'],
|
|
161
|
+
tags: [environmentType.toLowerCase()],
|
|
162
|
+
limit: 50,
|
|
163
|
+
sortBy: 'lastModified',
|
|
164
|
+
});
|
|
165
|
+
const trends = this.calculateEnvironmentTrends(snapshots.entities);
|
|
166
|
+
const recommendations = this.generateEvolutionRecommendations(trends);
|
|
167
|
+
return {
|
|
168
|
+
snapshots: snapshots.entities,
|
|
169
|
+
trends,
|
|
170
|
+
recommendations,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
this.logger.error('Failed to analyze environment evolution', 'EnvironmentMemoryManager', error);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Compare current environment with previous snapshots
|
|
180
|
+
*/
|
|
181
|
+
async compareWithPreviousSnapshots(currentConfiguration, environmentType) {
|
|
182
|
+
try {
|
|
183
|
+
const recentSnapshots = await this.memoryManager.queryEntities({
|
|
184
|
+
entityTypes: ['environment_snapshot'],
|
|
185
|
+
tags: [environmentType.toLowerCase()],
|
|
186
|
+
limit: 5,
|
|
187
|
+
sortBy: 'lastModified',
|
|
188
|
+
});
|
|
189
|
+
if (recentSnapshots.entities.length === 0) {
|
|
190
|
+
return {
|
|
191
|
+
hasChanges: true,
|
|
192
|
+
changes: ['Initial environment snapshot'],
|
|
193
|
+
regressions: [],
|
|
194
|
+
improvements: [],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const lastSnapshot = recentSnapshots.entities[0];
|
|
198
|
+
const comparison = this.compareConfigurations(lastSnapshot.environmentData?.configuration || {}, currentConfiguration);
|
|
199
|
+
return comparison;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
this.logger.error('Failed to compare with previous snapshots', 'EnvironmentMemoryManager', error);
|
|
203
|
+
return {
|
|
204
|
+
hasChanges: true,
|
|
205
|
+
changes: ['Comparison failed - treating as new snapshot'],
|
|
206
|
+
regressions: [],
|
|
207
|
+
improvements: [],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Private helper methods
|
|
212
|
+
identifyOptimizationOpportunities(configuration) {
|
|
213
|
+
const opportunities = [];
|
|
214
|
+
// Containerization opportunities
|
|
215
|
+
if (!configuration.containerization?.detected) {
|
|
216
|
+
opportunities.push('Consider containerizing application for better deployment consistency');
|
|
217
|
+
}
|
|
218
|
+
// Cloud optimization
|
|
219
|
+
if (!configuration.cloudServices?.providers?.length) {
|
|
220
|
+
opportunities.push('Evaluate cloud services adoption for improved scalability');
|
|
221
|
+
}
|
|
222
|
+
// Security improvements
|
|
223
|
+
if (!configuration.security?.httpsEnabled) {
|
|
224
|
+
opportunities.push('Enable HTTPS for secure communication');
|
|
225
|
+
}
|
|
226
|
+
// Monitoring gaps
|
|
227
|
+
if (!configuration.monitoring?.metrics) {
|
|
228
|
+
opportunities.push('Implement comprehensive monitoring and metrics collection');
|
|
229
|
+
}
|
|
230
|
+
// Performance optimization
|
|
231
|
+
if (!configuration.deployment?.loadBalancing) {
|
|
232
|
+
opportunities.push('Consider load balancing for improved performance and availability');
|
|
233
|
+
}
|
|
234
|
+
return opportunities;
|
|
235
|
+
}
|
|
236
|
+
extractTechnicalStack(configuration) {
|
|
237
|
+
const stack = [];
|
|
238
|
+
// Container technologies
|
|
239
|
+
if (configuration.containerization?.technologies) {
|
|
240
|
+
stack.push(...configuration.containerization.technologies);
|
|
241
|
+
}
|
|
242
|
+
// Cloud providers
|
|
243
|
+
if (configuration.cloudServices?.providers) {
|
|
244
|
+
stack.push(...configuration.cloudServices.providers);
|
|
245
|
+
}
|
|
246
|
+
// Infrastructure components
|
|
247
|
+
if (configuration.infrastructure?.components) {
|
|
248
|
+
stack.push(...Object.keys(configuration.infrastructure.components));
|
|
249
|
+
}
|
|
250
|
+
return [...new Set(stack)]; // Remove duplicates
|
|
251
|
+
}
|
|
252
|
+
calculateEnvironmentTrends(snapshots) {
|
|
253
|
+
const trends = [];
|
|
254
|
+
if (snapshots.length < 2) {
|
|
255
|
+
return trends;
|
|
256
|
+
}
|
|
257
|
+
// Analyze compliance score trends
|
|
258
|
+
const complianceScores = snapshots
|
|
259
|
+
.filter(s => s.environmentData.complianceStatus?.overallScore)
|
|
260
|
+
.map(s => ({
|
|
261
|
+
timestamp: s.lastModified,
|
|
262
|
+
score: s.environmentData.complianceStatus.overallScore,
|
|
263
|
+
}))
|
|
264
|
+
.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
265
|
+
if (complianceScores.length >= 2) {
|
|
266
|
+
const latest = complianceScores[complianceScores.length - 1];
|
|
267
|
+
const previous = complianceScores[complianceScores.length - 2];
|
|
268
|
+
if (latest && previous) {
|
|
269
|
+
trends.push({
|
|
270
|
+
metric: 'compliance_score',
|
|
271
|
+
direction: latest.score > previous.score ? 'improving' : 'declining',
|
|
272
|
+
change: latest.score - previous.score,
|
|
273
|
+
trend: 'compliance_trend',
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Analyze technology adoption trends
|
|
278
|
+
const techStacks = snapshots.map(s => s.context?.technicalStack || []);
|
|
279
|
+
const techGrowth = this.calculateTechGrowth(techStacks);
|
|
280
|
+
if (techGrowth.length > 0) {
|
|
281
|
+
trends.push({
|
|
282
|
+
metric: 'technology_adoption',
|
|
283
|
+
direction: 'expanding',
|
|
284
|
+
change: techGrowth,
|
|
285
|
+
trend: 'technology_trend',
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
return trends;
|
|
289
|
+
}
|
|
290
|
+
calculateTechGrowth(techStacks) {
|
|
291
|
+
if (techStacks.length < 2)
|
|
292
|
+
return [];
|
|
293
|
+
const latest = new Set(techStacks[techStacks.length - 1]);
|
|
294
|
+
const previous = new Set(techStacks[techStacks.length - 2]);
|
|
295
|
+
return Array.from(latest).filter(tech => !previous.has(tech));
|
|
296
|
+
}
|
|
297
|
+
generateEvolutionRecommendations(trends) {
|
|
298
|
+
const recommendations = [];
|
|
299
|
+
trends.forEach(trend => {
|
|
300
|
+
if (trend.trend === 'compliance_trend') {
|
|
301
|
+
if (trend.direction === 'declining') {
|
|
302
|
+
recommendations.push(`Address compliance regression: score decreased by ${Math.abs(trend.change)} points`);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
recommendations.push(`Maintain compliance momentum: score improved by ${trend.change} points`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (trend.trend === 'technology_trend') {
|
|
309
|
+
recommendations.push(`Document new technology adoption: ${trend.change.join(', ')}`);
|
|
310
|
+
recommendations.push('Create ADRs for significant technology choices');
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
if (recommendations.length === 0) {
|
|
314
|
+
recommendations.push('Continue regular environment monitoring');
|
|
315
|
+
recommendations.push('Consider setting up automated compliance checks');
|
|
316
|
+
}
|
|
317
|
+
return recommendations;
|
|
318
|
+
}
|
|
319
|
+
compareConfigurations(previous, current) {
|
|
320
|
+
const changes = [];
|
|
321
|
+
const regressions = [];
|
|
322
|
+
const improvements = [];
|
|
323
|
+
// Compare infrastructure components
|
|
324
|
+
const prevInfra = previous.infrastructure?.components || {};
|
|
325
|
+
const currInfra = current.infrastructure?.components || {};
|
|
326
|
+
Object.keys(currInfra).forEach(component => {
|
|
327
|
+
if (!prevInfra[component]) {
|
|
328
|
+
changes.push(`Added infrastructure component: ${component}`);
|
|
329
|
+
improvements.push(`New component improves infrastructure: ${component}`);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
Object.keys(prevInfra).forEach(component => {
|
|
333
|
+
if (!currInfra[component]) {
|
|
334
|
+
changes.push(`Removed infrastructure component: ${component}`);
|
|
335
|
+
regressions.push(`Lost infrastructure component: ${component}`);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
// Compare security settings
|
|
339
|
+
const prevSecurity = previous.security || {};
|
|
340
|
+
const currSecurity = current.security || {};
|
|
341
|
+
if (prevSecurity.httpsEnabled && !currSecurity.httpsEnabled) {
|
|
342
|
+
changes.push('HTTPS disabled');
|
|
343
|
+
regressions.push('Security regression: HTTPS disabled');
|
|
344
|
+
}
|
|
345
|
+
else if (!prevSecurity.httpsEnabled && currSecurity.httpsEnabled) {
|
|
346
|
+
changes.push('HTTPS enabled');
|
|
347
|
+
improvements.push('Security improvement: HTTPS enabled');
|
|
348
|
+
}
|
|
349
|
+
return {
|
|
350
|
+
hasChanges: changes.length > 0,
|
|
351
|
+
changes,
|
|
352
|
+
regressions,
|
|
353
|
+
improvements,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
7
357
|
/**
|
|
8
358
|
* Analyze environment context and provide optimization recommendations
|
|
9
359
|
* Enhanced with Generated Knowledge Prompting for DevOps and infrastructure expertise
|
|
360
|
+
* Now includes memory integration for environment tracking
|
|
10
361
|
*/
|
|
11
362
|
export async function analyzeEnvironment(args) {
|
|
12
363
|
const { projectPath = process.cwd(), adrDirectory = 'docs/adrs', analysisType = 'comprehensive', currentEnvironment, requirements, industryStandards, knowledgeEnhancement = true, // Default to GKP enabled
|
|
13
364
|
enhancedMode = true, // Default to enhanced mode
|
|
365
|
+
enableMemoryIntegration = true, // Default to memory integration enabled
|
|
366
|
+
environmentType = 'development', // Default environment type
|
|
14
367
|
} = args;
|
|
368
|
+
// Initialize memory manager if enabled
|
|
369
|
+
let memoryManager = null;
|
|
370
|
+
if (enableMemoryIntegration) {
|
|
371
|
+
memoryManager = new EnvironmentMemoryManager();
|
|
372
|
+
await memoryManager.initialize();
|
|
373
|
+
}
|
|
15
374
|
try {
|
|
16
375
|
const { analyzeEnvironmentSpecs, detectContainerization, determineEnvironmentRequirements, assessEnvironmentCompliance, } = await import('../utils/environment-analysis.js');
|
|
17
376
|
switch (analysisType) {
|
|
@@ -26,11 +385,11 @@ export async function analyzeEnvironment(args) {
|
|
|
26
385
|
projectPath,
|
|
27
386
|
technologies: [],
|
|
28
387
|
patterns: [],
|
|
29
|
-
projectType: 'infrastructure-environment-analysis'
|
|
388
|
+
projectType: 'infrastructure-environment-analysis',
|
|
30
389
|
}, {
|
|
31
390
|
domains: ['cloud-infrastructure', 'devops-cicd'],
|
|
32
391
|
depth: 'intermediate',
|
|
33
|
-
cacheEnabled: true
|
|
392
|
+
cacheEnabled: true,
|
|
34
393
|
});
|
|
35
394
|
knowledgeContext = `\n## Infrastructure & DevOps Knowledge Enhancement\n\n${knowledgeResult.prompt}\n\n---\n`;
|
|
36
395
|
}
|
|
@@ -52,10 +411,58 @@ Leverage the provided cloud infrastructure and DevOps knowledge to create compre
|
|
|
52
411
|
Focus on providing actionable insights for environment optimization, security, scalability, and modern DevOps practices.
|
|
53
412
|
Consider cloud-native patterns, containerization best practices, and deployment automation.
|
|
54
413
|
Provide specific recommendations with implementation guidance.`,
|
|
55
|
-
responseFormat: 'text'
|
|
414
|
+
responseFormat: 'text',
|
|
56
415
|
});
|
|
57
416
|
if (executionResult.isAIGenerated) {
|
|
58
417
|
// AI execution successful - return actual environment analysis results
|
|
418
|
+
// Store environment snapshot in memory if enabled
|
|
419
|
+
let memoryIntegrationInfo = '';
|
|
420
|
+
if (memoryManager) {
|
|
421
|
+
try {
|
|
422
|
+
// Parse AI result to extract configuration data
|
|
423
|
+
const analysisData = parseAnalysisResults(executionResult.content, result.actualData);
|
|
424
|
+
// Compare with previous snapshots
|
|
425
|
+
const comparison = await memoryManager.compareWithPreviousSnapshots(analysisData, environmentType);
|
|
426
|
+
// Store new snapshot
|
|
427
|
+
const snapshotId = await memoryManager.storeEnvironmentSnapshot(environmentType, analysisData, undefined, // No compliance data for specs analysis
|
|
428
|
+
projectPath);
|
|
429
|
+
memoryIntegrationInfo = `
|
|
430
|
+
## 🧠 Memory Integration Status
|
|
431
|
+
|
|
432
|
+
- **Snapshot Stored**: ✅ Environment snapshot saved (ID: ${snapshotId.substring(0, 8)}...)
|
|
433
|
+
- **Environment Type**: ${environmentType}
|
|
434
|
+
- **Change Detection**: ${comparison.hasChanges ? '🔄 Changes detected' : '✅ No changes from previous snapshot'}
|
|
435
|
+
- **Improvements**: ${comparison.improvements.length} detected
|
|
436
|
+
- **Regressions**: ${comparison.regressions.length} detected
|
|
437
|
+
|
|
438
|
+
${comparison.changes.length > 0
|
|
439
|
+
? `### Configuration Changes
|
|
440
|
+
${comparison.changes.map(change => `- ${change}`).join('\n')}
|
|
441
|
+
`
|
|
442
|
+
: ''}
|
|
443
|
+
|
|
444
|
+
${comparison.improvements.length > 0
|
|
445
|
+
? `### Improvements Detected
|
|
446
|
+
${comparison.improvements.map(improvement => `- ${improvement}`).join('\n')}
|
|
447
|
+
`
|
|
448
|
+
: ''}
|
|
449
|
+
|
|
450
|
+
${comparison.regressions.length > 0
|
|
451
|
+
? `### Regressions Detected
|
|
452
|
+
${comparison.regressions.map(regression => `- ⚠️ ${regression}`).join('\n')}
|
|
453
|
+
`
|
|
454
|
+
: ''}
|
|
455
|
+
`;
|
|
456
|
+
}
|
|
457
|
+
catch (memoryError) {
|
|
458
|
+
memoryIntegrationInfo = `
|
|
459
|
+
## 🧠 Memory Integration Status
|
|
460
|
+
|
|
461
|
+
- **Status**: ⚠️ Memory storage failed - analysis continued without persistence
|
|
462
|
+
- **Error**: ${memoryError instanceof Error ? memoryError.message : 'Unknown error'}
|
|
463
|
+
`;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
59
466
|
return formatMCPResponse({
|
|
60
467
|
...executionResult,
|
|
61
468
|
content: `# Environment Specification Analysis Results (GKP Enhanced)
|
|
@@ -63,17 +470,23 @@ Provide specific recommendations with implementation guidance.`,
|
|
|
63
470
|
## Enhancement Features
|
|
64
471
|
- **Generated Knowledge Prompting**: ${knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
65
472
|
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
473
|
+
- **Memory Integration**: ${enableMemoryIntegration ? '✅ Enabled' : '❌ Disabled'}
|
|
66
474
|
- **Knowledge Domains**: Cloud infrastructure, DevOps practices, containerization, deployment patterns
|
|
67
475
|
|
|
476
|
+
${memoryIntegrationInfo}
|
|
477
|
+
|
|
68
478
|
## Analysis Information
|
|
69
479
|
- **Project Path**: ${projectPath}
|
|
70
480
|
- **ADR Directory**: ${adrDirectory}
|
|
71
481
|
- **Analysis Type**: Environment Specifications
|
|
482
|
+
- **Environment Type**: ${environmentType}
|
|
72
483
|
|
|
73
|
-
${knowledgeContext
|
|
484
|
+
${knowledgeContext
|
|
485
|
+
? `## Applied Infrastructure Knowledge
|
|
74
486
|
|
|
75
487
|
${knowledgeContext}
|
|
76
|
-
`
|
|
488
|
+
`
|
|
489
|
+
: ''}
|
|
77
490
|
|
|
78
491
|
## AI Environment Analysis Results
|
|
79
492
|
|
|
@@ -119,10 +532,12 @@ For deeper insights, consider running:
|
|
|
119
532
|
- **Generated Knowledge Prompting**: ${knowledgeEnhancement ? '✅ Applied' : '❌ Disabled'}
|
|
120
533
|
- **Enhanced Mode**: ${enhancedMode ? '✅ Applied' : '❌ Disabled'}
|
|
121
534
|
|
|
122
|
-
${knowledgeContext
|
|
535
|
+
${knowledgeContext
|
|
536
|
+
? `## Infrastructure Knowledge Context
|
|
123
537
|
|
|
124
538
|
${knowledgeContext}
|
|
125
|
-
`
|
|
539
|
+
`
|
|
540
|
+
: ''}
|
|
126
541
|
|
|
127
542
|
${result.instructions}
|
|
128
543
|
|
|
@@ -153,11 +568,11 @@ ${enhancedPrompt}
|
|
|
153
568
|
projectPath,
|
|
154
569
|
technologies: [],
|
|
155
570
|
patterns: [],
|
|
156
|
-
projectType: 'containerization-analysis'
|
|
571
|
+
projectType: 'containerization-analysis',
|
|
157
572
|
}, {
|
|
158
573
|
domains: ['cloud-infrastructure', 'devops-cicd'],
|
|
159
574
|
depth: 'intermediate',
|
|
160
|
-
cacheEnabled: true
|
|
575
|
+
cacheEnabled: true,
|
|
161
576
|
});
|
|
162
577
|
knowledgeContext = `\n## Containerization Knowledge Enhancement\n\n${knowledgeResult.prompt}\n\n---\n`;
|
|
163
578
|
}
|
|
@@ -179,10 +594,12 @@ ${enhancedPrompt}
|
|
|
179
594
|
- **Enhanced Mode**: ${enhancedMode ? '✅ Applied' : '❌ Disabled'}
|
|
180
595
|
- **Knowledge Domains**: Containerization, Kubernetes, Docker best practices, container security
|
|
181
596
|
|
|
182
|
-
${knowledgeContext
|
|
597
|
+
${knowledgeContext
|
|
598
|
+
? `## Containerization Knowledge Context
|
|
183
599
|
|
|
184
600
|
${knowledgeContext}
|
|
185
|
-
`
|
|
601
|
+
`
|
|
602
|
+
: ''}
|
|
186
603
|
|
|
187
604
|
${result.instructions}
|
|
188
605
|
|
|
@@ -234,11 +651,11 @@ Use the detection results to:
|
|
|
234
651
|
projectPath,
|
|
235
652
|
technologies: [],
|
|
236
653
|
patterns: [],
|
|
237
|
-
projectType: 'requirements-analysis'
|
|
654
|
+
projectType: 'requirements-analysis',
|
|
238
655
|
}, {
|
|
239
656
|
domains: ['cloud-infrastructure', 'performance-optimization'],
|
|
240
657
|
depth: 'intermediate',
|
|
241
|
-
cacheEnabled: true
|
|
658
|
+
cacheEnabled: true,
|
|
242
659
|
});
|
|
243
660
|
knowledgeContext = `\n## Requirements Engineering Knowledge Enhancement\n\n${knowledgeResult.prompt}\n\n---\n`;
|
|
244
661
|
}
|
|
@@ -260,10 +677,12 @@ Use the detection results to:
|
|
|
260
677
|
- **Enhanced Mode**: ${enhancedMode ? '✅ Applied' : '❌ Disabled'}
|
|
261
678
|
- **Knowledge Domains**: Requirements engineering, infrastructure planning, performance requirements, security requirements
|
|
262
679
|
|
|
263
|
-
${knowledgeContext
|
|
680
|
+
${knowledgeContext
|
|
681
|
+
? `## Requirements Knowledge Context
|
|
264
682
|
|
|
265
683
|
${knowledgeContext}
|
|
266
|
-
`
|
|
684
|
+
`
|
|
685
|
+
: ''}
|
|
267
686
|
|
|
268
687
|
${result.instructions}
|
|
269
688
|
|
|
@@ -317,11 +736,11 @@ Use the extracted requirements to:
|
|
|
317
736
|
projectPath,
|
|
318
737
|
technologies: [],
|
|
319
738
|
patterns: [],
|
|
320
|
-
projectType: 'compliance-assessment'
|
|
739
|
+
projectType: 'compliance-assessment',
|
|
321
740
|
}, {
|
|
322
741
|
domains: ['security-patterns', 'cloud-infrastructure'],
|
|
323
742
|
depth: 'intermediate',
|
|
324
|
-
cacheEnabled: true
|
|
743
|
+
cacheEnabled: true,
|
|
325
744
|
});
|
|
326
745
|
knowledgeContext = `\n## Compliance & Security Knowledge Enhancement\n\n${knowledgeResult.prompt}\n\n---\n`;
|
|
327
746
|
}
|
|
@@ -343,10 +762,12 @@ Use the extracted requirements to:
|
|
|
343
762
|
- **Enhanced Mode**: ${enhancedMode ? '✅ Applied' : '❌ Disabled'}
|
|
344
763
|
- **Knowledge Domains**: Compliance frameworks, security standards, regulatory requirements, audit practices
|
|
345
764
|
|
|
346
|
-
${knowledgeContext
|
|
765
|
+
${knowledgeContext
|
|
766
|
+
? `## Compliance Knowledge Context
|
|
347
767
|
|
|
348
768
|
${knowledgeContext}
|
|
349
|
-
`
|
|
769
|
+
`
|
|
770
|
+
: ''}
|
|
350
771
|
|
|
351
772
|
${result.instructions}
|
|
352
773
|
|
|
@@ -397,17 +818,18 @@ Use the assessment results to:
|
|
|
397
818
|
projectPath,
|
|
398
819
|
technologies: [],
|
|
399
820
|
patterns: [],
|
|
400
|
-
projectType: 'comprehensive-environment-analysis'
|
|
821
|
+
projectType: 'comprehensive-environment-analysis',
|
|
401
822
|
}, {
|
|
402
823
|
domains: ['cloud-infrastructure', 'devops-cicd', 'security-patterns'],
|
|
403
824
|
depth: 'advanced',
|
|
404
|
-
cacheEnabled: true
|
|
825
|
+
cacheEnabled: true,
|
|
405
826
|
});
|
|
406
827
|
comprehensiveKnowledgeContext = `\n## Comprehensive Environment Knowledge Enhancement\n\n${knowledgeResult.prompt}\n\n---\n`;
|
|
407
828
|
}
|
|
408
829
|
catch (error) {
|
|
409
830
|
console.error('[WARNING] GKP knowledge generation failed for comprehensive environment analysis:', error);
|
|
410
|
-
comprehensiveKnowledgeContext =
|
|
831
|
+
comprehensiveKnowledgeContext =
|
|
832
|
+
'<!-- Comprehensive environment knowledge generation unavailable -->\n';
|
|
411
833
|
}
|
|
412
834
|
}
|
|
413
835
|
const specsResult = await analyzeEnvironmentSpecs(projectPath);
|
|
@@ -425,10 +847,12 @@ Use the assessment results to:
|
|
|
425
847
|
- **Knowledge Domains**: Cloud infrastructure, DevOps practices, containerization, deployment patterns, compliance frameworks, security standards
|
|
426
848
|
- **Knowledge Depth**: Advanced (comprehensive coverage)
|
|
427
849
|
|
|
428
|
-
${comprehensiveKnowledgeContext
|
|
850
|
+
${comprehensiveKnowledgeContext
|
|
851
|
+
? `## Applied Comprehensive Knowledge
|
|
429
852
|
|
|
430
853
|
${comprehensiveKnowledgeContext}
|
|
431
|
-
`
|
|
854
|
+
`
|
|
855
|
+
: ''}
|
|
432
856
|
|
|
433
857
|
This comprehensive analysis will examine all aspects of your environment context and provide optimization recommendations.
|
|
434
858
|
|
|
@@ -515,4 +939,124 @@ All analyses follow these principles:
|
|
|
515
939
|
throw new McpAdrError(`Failed to analyze environment: ${error instanceof Error ? error.message : String(error)}`, 'ENVIRONMENT_ANALYSIS_ERROR');
|
|
516
940
|
}
|
|
517
941
|
}
|
|
942
|
+
/**
|
|
943
|
+
* Helper function to parse AI analysis results into structured configuration data
|
|
944
|
+
*/
|
|
945
|
+
function parseAnalysisResults(aiContent, actualData) {
|
|
946
|
+
// Try to extract structured data from AI response
|
|
947
|
+
const configuration = {
|
|
948
|
+
infrastructure: actualData?.infrastructure || {},
|
|
949
|
+
containerization: {
|
|
950
|
+
detected: aiContent.toLowerCase().includes('docker') || aiContent.toLowerCase().includes('container'),
|
|
951
|
+
technologies: extractTechnologies(aiContent, [
|
|
952
|
+
'docker',
|
|
953
|
+
'kubernetes',
|
|
954
|
+
'podman',
|
|
955
|
+
'containerd',
|
|
956
|
+
]),
|
|
957
|
+
},
|
|
958
|
+
cloudServices: {
|
|
959
|
+
providers: extractTechnologies(aiContent, [
|
|
960
|
+
'aws',
|
|
961
|
+
'azure',
|
|
962
|
+
'gcp',
|
|
963
|
+
'google cloud',
|
|
964
|
+
'heroku',
|
|
965
|
+
'vercel',
|
|
966
|
+
'netlify',
|
|
967
|
+
]),
|
|
968
|
+
},
|
|
969
|
+
security: {
|
|
970
|
+
httpsEnabled: aiContent.toLowerCase().includes('https') || aiContent.toLowerCase().includes('ssl'),
|
|
971
|
+
securityMentioned: aiContent.toLowerCase().includes('security'),
|
|
972
|
+
},
|
|
973
|
+
monitoring: {
|
|
974
|
+
metrics: aiContent.toLowerCase().includes('monitoring') ||
|
|
975
|
+
aiContent.toLowerCase().includes('metrics'),
|
|
976
|
+
},
|
|
977
|
+
deployment: {
|
|
978
|
+
automated: aiContent.toLowerCase().includes('ci/cd') || aiContent.toLowerCase().includes('pipeline'),
|
|
979
|
+
loadBalancing: aiContent.toLowerCase().includes('load balanc') || aiContent.toLowerCase().includes('lb'),
|
|
980
|
+
},
|
|
981
|
+
discoveredFiles: actualData?.discoveredFiles || [],
|
|
982
|
+
recommendations: extractRecommendations(aiContent),
|
|
983
|
+
qualityAttributes: extractQualityAttributes(aiContent),
|
|
984
|
+
riskAssessment: extractRiskAssessment(aiContent),
|
|
985
|
+
};
|
|
986
|
+
return configuration;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Extract technology mentions from AI content
|
|
990
|
+
*/
|
|
991
|
+
function extractTechnologies(content, technologies) {
|
|
992
|
+
const found = [];
|
|
993
|
+
const lowerContent = content.toLowerCase();
|
|
994
|
+
for (const tech of technologies) {
|
|
995
|
+
if (lowerContent.includes(tech.toLowerCase())) {
|
|
996
|
+
found.push(tech);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return found;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Extract recommendations from AI content
|
|
1003
|
+
*/
|
|
1004
|
+
function extractRecommendations(content) {
|
|
1005
|
+
const recommendations = [];
|
|
1006
|
+
const lines = content.split('\n');
|
|
1007
|
+
for (const line of lines) {
|
|
1008
|
+
const trimmed = line.trim();
|
|
1009
|
+
if (trimmed.startsWith('- ') &&
|
|
1010
|
+
(trimmed.toLowerCase().includes('recommend') ||
|
|
1011
|
+
trimmed.toLowerCase().includes('suggest') ||
|
|
1012
|
+
trimmed.toLowerCase().includes('consider') ||
|
|
1013
|
+
trimmed.toLowerCase().includes('should'))) {
|
|
1014
|
+
recommendations.push(trimmed.substring(2)); // Remove '- ' prefix
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return recommendations;
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Extract quality attributes from AI content
|
|
1021
|
+
*/
|
|
1022
|
+
function extractQualityAttributes(content) {
|
|
1023
|
+
const attributes = {};
|
|
1024
|
+
const lowerContent = content.toLowerCase();
|
|
1025
|
+
if (lowerContent.includes('performance')) {
|
|
1026
|
+
attributes.performance = 'mentioned';
|
|
1027
|
+
}
|
|
1028
|
+
if (lowerContent.includes('scalability') || lowerContent.includes('scalable')) {
|
|
1029
|
+
attributes.scalability = 'mentioned';
|
|
1030
|
+
}
|
|
1031
|
+
if (lowerContent.includes('security')) {
|
|
1032
|
+
attributes.security = 'mentioned';
|
|
1033
|
+
}
|
|
1034
|
+
if (lowerContent.includes('reliability') || lowerContent.includes('reliable')) {
|
|
1035
|
+
attributes.reliability = 'mentioned';
|
|
1036
|
+
}
|
|
1037
|
+
if (lowerContent.includes('maintainability') || lowerContent.includes('maintainable')) {
|
|
1038
|
+
attributes.maintainability = 'mentioned';
|
|
1039
|
+
}
|
|
1040
|
+
return attributes;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Extract risk assessment from AI content
|
|
1044
|
+
*/
|
|
1045
|
+
function extractRiskAssessment(content) {
|
|
1046
|
+
const risks = [];
|
|
1047
|
+
const lowerContent = content.toLowerCase();
|
|
1048
|
+
if (lowerContent.includes('risk') || lowerContent.includes('vulnerability')) {
|
|
1049
|
+
risks.push('Security risks mentioned in analysis');
|
|
1050
|
+
}
|
|
1051
|
+
if (lowerContent.includes('single point of failure') || lowerContent.includes('spof')) {
|
|
1052
|
+
risks.push('Single point of failure identified');
|
|
1053
|
+
}
|
|
1054
|
+
if (lowerContent.includes('outdated') || lowerContent.includes('deprecated')) {
|
|
1055
|
+
risks.push('Outdated technologies or dependencies detected');
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
risks,
|
|
1059
|
+
riskLevel: risks.length > 2 ? 'high' : risks.length > 0 ? 'medium' : 'low',
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
518
1062
|
//# sourceMappingURL=environment-analysis-tool.js.map
|